本文整理汇总了PHP中OCP\IConfig::getSystemValue方法的典型用法代码示例。如果您正苦于以下问题:PHP IConfig::getSystemValue方法的具体用法?PHP IConfig::getSystemValue怎么用?PHP IConfig::getSystemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IConfig
的用法示例。
在下文中一共展示了IConfig::getSystemValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runStep
/**
* Send an email to {$limit} users
*
* @param int $limit Number of users we want to send an email to
* @return int Number of users we sent an email to
*/
protected function runStep($limit)
{
// We don't use time() but "time() - 1" here, so we don't run into
// runtime issues later and delete emails, which were created in the
// same second, but were not collected for the emails.
$sendTime = time() - 1;
// Get all users which should receive an email
$affectedUsers = $this->mqHandler->getAffectedUsers($limit, $sendTime);
if (empty($affectedUsers)) {
// No users found to notify, mission abort
return 0;
}
$userLanguages = $this->config->getUserValueForUsers('core', 'lang', $affectedUsers);
$userTimezones = $this->config->getUserValueForUsers('core', 'timezone', $affectedUsers);
$userEmails = $this->config->getUserValueForUsers('settings', 'email', $affectedUsers);
// Get all items for these users
$mailData = $this->mqHandler->getItemsForUsers($affectedUsers, $sendTime);
// Send Email
$default_lang = $this->config->getSystemValue('default_language', 'en');
$defaultTimeZone = date_default_timezone_get();
foreach ($mailData as $user => $data) {
if (empty($userEmails[$user])) {
// The user did not setup an email address
// So we will not send an email :(
$this->logger->debug("Couldn't send notification email to user '" . $user . "' (email address isn't set for that user)", ['app' => 'activity']);
continue;
}
$language = !empty($userLanguages[$user]) ? $userLanguages[$user] : $default_lang;
$timezone = !empty($userTimezones[$user]) ? $userTimezones[$user] : $defaultTimeZone;
$this->mqHandler->sendEmailToUser($user, $userEmails[$user], $language, $timezone, $data);
}
// Delete all entries we dealt with
$this->mqHandler->deleteSentItems($affectedUsers, $sendTime);
return sizeof($affectedUsers);
}
示例2: forceSingleUserAndTrashbin
/**
* Set single user mode and disable the trashbin app
*/
protected function forceSingleUserAndTrashbin()
{
$this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
$this->wasSingleUserModeEnabled = $this->config->getSystemValue('singleuser', false);
$this->config->setSystemValue('singleuser', true);
$this->appManager->disableApp('files_trashbin');
}
示例3: loadCommands
/**
* @param OutputInterface $output
*/
public function loadCommands(OutputInterface $output)
{
// $application is required to be defined in the register_command scripts
$application = $this->application;
require_once \OC::$SERVERROOT . '/core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if (!\OCP\Util::needUpgrade()) {
OC_App::loadApps();
foreach (OC_App::getAllApps() as $app) {
$file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
if (file_exists($file)) {
require $file;
}
}
} else {
$output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
}
} else {
$output->writeln("ownCloud is not installed - only a limited number of commands are available");
}
$input = new ArgvInput();
if ($input->getFirstArgument() !== 'check') {
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
if (!empty($errors)) {
foreach ($errors as $error) {
$output->writeln($error['error']);
$output->writeln($error['hint']);
$output->writeln('');
}
throw new \Exception("Environment not properly prepared.");
}
}
}
示例4: validateUserPass
/**
* Validates a username and password
*
* This method should return true or false depending on if login
* succeeded.
*
* @param string $username
* @param string $password
*
* @return bool
*/
protected function validateUserPass($username, $password)
{
$linkItem = \OCP\Share::getShareByToken($username, false);
\OC_User::setIncognitoMode(true);
$this->share = $linkItem;
if (!$linkItem) {
return false;
}
// check if the share is password protected
if (isset($linkItem['share_with'])) {
if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
// Check Password
$forcePortable = CRYPT_BLOWFISH != 1;
$hasher = new \PasswordHash(8, $forcePortable);
if (!$hasher->CheckPassword($password . $this->config->getSystemValue('passwordsalt', ''), $linkItem['share_with'])) {
return false;
} else {
return true;
}
} else {
return false;
}
} else {
return true;
}
}
示例5: linkTo
/**
* Creates an url
* @param string $app app
* @param string $file file
* @param array $args array with param=>value, will be appended to the returned url
* The value of $args will be urlencoded
* @return string the url
*
* Returns a url to the given app and file.
*/
public function linkTo($app, $file, $args = array())
{
$frontControllerActive = $this->config->getSystemValue('front_controller_active', 'false') == 'true';
if ($app != '') {
$app_path = \OC_App::getAppPath($app);
// Check if the app is in the app folder
if ($app_path && file_exists($app_path . '/' . $file)) {
if (substr($file, -3) == 'php') {
$urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
if ($frontControllerActive) {
$urlLinkTo = \OC::$WEBROOT . '/apps/' . $app;
}
$urlLinkTo .= $file != 'index.php' ? '/' . $file : '';
} else {
$urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
}
} else {
$urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file;
}
} else {
if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
$urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
} else {
if ($frontControllerActive && $file === 'index.php') {
$urlLinkTo = \OC::$WEBROOT;
} else {
$urlLinkTo = \OC::$WEBROOT . '/' . $file;
}
}
}
if ($args && ($query = http_build_query($args, '', '&'))) {
$urlLinkTo .= '?' . $query;
}
return $urlLinkTo;
}
示例6: createKey
/**
* Generate a keypair
*
* @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
*/
public function createKey()
{
$rsa = new RSACrypt();
$rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
$rsa->setPassword($this->config->getSystemValue('secret', ''));
return $rsa->createKey(self::CREATE_KEY_BITS);
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$includeExpensive = $input->getOption('include-expensive');
if ($includeExpensive) {
foreach ($this->repair->getExpensiveRepairSteps() as $step) {
$this->repair->addStep($step);
}
}
$maintenanceMode = $this->config->getSystemValue('maintenance', false);
$this->config->setSystemValue('maintenance', true);
$this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'warning', function ($description) use($output) {
$output->writeln(' - WARNING: ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
$output->writeln(' - ERROR: ' . $description);
});
$this->repair->run();
$this->config->setSystemValue('maintenance', $maintenanceMode);
}
示例8: format
/**
* @param IEvent $event
* @param string $parameter The parameter to be formatted
* @param bool $allowHtml Should HTML be used to format the parameter?
* @param bool $verbose Should paths, names, etc be shortened or full length
* @return string The formatted parameter
*/
public function format(IEvent $event, $parameter, $allowHtml, $verbose = false)
{
// If the username is empty, the action has been performed by a remote
// user, or via a public share. We don't know the username in that case
if ($parameter === '') {
if ($allowHtml === null) {
return '<user display-name="' . Util::sanitizeHTML($this->l->t('"remote user"')) . '">' . Util::sanitizeHTML('') . '</user>';
}
if ($allowHtml) {
return '<strong>' . $this->l->t('"remote user"') . '</strong>';
} else {
return $this->l->t('"remote user"');
}
}
$user = $this->manager->get($parameter);
$displayName = $user ? $user->getDisplayName() : $parameter;
$parameter = Util::sanitizeHTML($parameter);
if ($allowHtml === null) {
return '<user display-name="' . Util::sanitizeHTML($displayName) . '">' . Util::sanitizeHTML($parameter) . '</user>';
}
if ($allowHtml) {
$avatarPlaceholder = '';
if ($this->config->getSystemValue('enable_avatars', true)) {
$avatarPlaceholder = '<div class="avatar" data-user="' . $parameter . '"></div>';
}
return $avatarPlaceholder . '<strong>' . Util::sanitizeHTML($displayName) . '</strong>';
} else {
return $displayName;
}
}
示例9: trustedDomains
/**
* Add a new trusted domain
* @param string $newTrustedDomain The newly to add trusted domain
* @return array
*/
public function trustedDomains($newTrustedDomain)
{
$trustedDomains = $this->config->getSystemValue('trusted_domains');
$trustedDomains[] = $newTrustedDomain;
$this->config->setSystemValue('trusted_domains', $trustedDomains);
return $this->returnSuccess();
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// collate config setting to the end, to avoid partial configuration
$toBeSet = [];
if ($backend = $input->getOption('backend')) {
$this->validateBackend($backend);
$toBeSet['log_type'] = $backend;
}
if ($level = $input->getOption('level')) {
if (is_numeric($level)) {
$levelNum = $level;
// sanity check
$this->convertLevelNumber($levelNum);
} else {
$levelNum = $this->convertLevelString($level);
}
$toBeSet['loglevel'] = $levelNum;
}
if ($timezone = $input->getOption('timezone')) {
$this->validateTimezone($timezone);
$toBeSet['logtimezone'] = $timezone;
}
// set config
foreach ($toBeSet as $option => $value) {
$this->config->setSystemValue($option, $value);
}
// display configuration
$backend = $this->config->getSystemValue('log_type', self::DEFAULT_BACKEND);
$output->writeln('Enabled logging backend: ' . $backend);
$levelNum = $this->config->getSystemValue('loglevel', self::DEFAULT_LOG_LEVEL);
$level = $this->convertLevelNumber($levelNum);
$output->writeln('Log level: ' . $level . ' (' . $levelNum . ')');
$timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE);
$output->writeln('Log timezone: ' . $timezone);
}
示例11: listCertificates
/**
* Returns all certificates trusted by the user
*
* @return \OCP\ICertificate[]
*/
public function listCertificates()
{
if (!$this->config->getSystemValue('installed', false)) {
return array();
}
$path = $this->getPathToCertificates() . 'uploads/';
if (!$this->view->is_dir($path)) {
return array();
}
$result = array();
$handle = $this->view->opendir($path);
if (!is_resource($handle)) {
return array();
}
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
try {
$result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
} catch (\Exception $e) {
}
}
}
closedir($handle);
return $result;
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->config = \OC::$server->getConfig();
$this->connection = \OC::$server->getDatabaseConnection();
$this->manager = new MDB2SchemaManager($this->connection);
$this->testPrefix = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_'), 3));
}
示例13: run
public function run()
{
$ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
if (version_compare($ocVersionFromBeforeUpdate, '8.2.0.7', '<')) {
// this situation was only possible before 8.2
$this->removeExpirationDateFromNonLinkShares();
}
}
示例14: setUp
protected function setUp()
{
parent::setUp();
$this->config = \OC::$server->getConfig();
$this->connection = \OC::$server->getDatabaseConnection();
$this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
$this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection);
$this->outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
}
示例15: isEnabled
/**
* Check if encryption is enabled
*
* @return bool true if enabled, false if not
*/
public function isEnabled()
{
$installed = $this->config->getSystemValue('installed', false);
if (!$installed) {
return false;
}
$enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
return $enabled === 'yes';
}