当前位置: 首页>>代码示例>>PHP>>正文


PHP IConfig::setUserValue方法代码示例

本文整理汇总了PHP中OCP\IConfig::setUserValue方法的典型用法代码示例。如果您正苦于以下问题:PHP IConfig::setUserValue方法的具体用法?PHP IConfig::setUserValue怎么用?PHP IConfig::setUserValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\IConfig的用法示例。


在下文中一共展示了IConfig::setUserValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * @NoAdminRequired
  *
  * @param int $id
  * @return DataResponse
  */
 public function get($id)
 {
     // save the last viewed note
     $this->settings->setUserValue($this->userId, $this->appName, 'notesLastViewedNote', $id);
     return $this->respond(function () use($id) {
         return $this->notesService->get($id, $this->userId);
     });
 }
开发者ID:ErikPel,项目名称:notes,代码行数:14,代码来源:notescontroller.php

示例2: setRecoveryForUser

 /**
  * @param $enabled
  * @return bool
  */
 public function setRecoveryForUser($enabled)
 {
     $value = $enabled ? '1' : '0';
     try {
         $this->config->setUserValue($this->user->getUID(), 'encryption', 'recoveryEnabled', $value);
         return true;
     } catch (PreConditionNotMetException $e) {
         return false;
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:14,代码来源:util.php

示例3: propagateDirtyMountPoints

 /**
  * Propagate the etag changes for all shares marked as dirty and mark the shares as clean
  *
  * @param array $shares the shares for the users
  * @param int $time
  */
 public function propagateDirtyMountPoints(array $shares, $time = null)
 {
     if ($time === null) {
         $time = microtime(true);
     }
     $dirtyShares = $this->getDirtyShares($shares);
     foreach ($dirtyShares as $share) {
         $this->changePropagator->addChange($share['file_target']);
     }
     if (count($dirtyShares)) {
         $this->config->setUserValue($this->userId, 'files_sharing', 'last_propagate', $time);
         $this->changePropagator->propagateChanges(floor($time));
     }
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:20,代码来源:recipientpropagator.php

示例4: propagateDirtyMountPoints

 /**
  * Propagate the etag changes for all mountpoints marked as dirty and mark the mountpoints as clean
  *
  * @param int $time
  */
 public function propagateDirtyMountPoints($time = null)
 {
     if ($time === null) {
         $time = time();
     }
     $mountPoints = $this->getDirtyMountPoints();
     foreach ($mountPoints as $mountPoint) {
         $this->changePropagator->addChange($mountPoint);
         $this->config->setUserValue($this->user->getUID(), 'files_external', $mountPoint, $time);
     }
     if (count($mountPoints)) {
         $this->changePropagator->propagateChanges($time);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:19,代码来源:etagpropagator.php

示例5: setView

 /**
  * set a new view
  *
  * @param string $view
  * @return JSONResponse
  *
  * @NoAdminRequired
  */
 public function setView($view)
 {
     if (!$this->isViewAllowed($view)) {
         return new JSONResponse([], Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     $userId = $this->userSession->getUser()->getUID();
     $app = $this->appName;
     try {
         $this->config->setUserValue($userId, $app, 'currentView', $view);
     } catch (\Exception $e) {
         return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
     }
     return new JSONResponse();
 }
开发者ID:dominicrico,项目名称:calendar-rework,代码行数:22,代码来源:settingscontroller.php

示例6: setValue

 /**
  * set a config value
  *
  * @param string $value
  * @return JSONResponse
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function setValue($value)
 {
     try {
         $userId = $this->user->getUID();
         $app = $this->appName;
         $info = $this->getInfoFromRoute();
         if (isset($info['options']) && !in_array($value, $info['options'])) {
             throw new Exception('Value not supported', HTTP::STATUS_UNPROCESSABLE_ENTITY);
         }
         $this->config->setUserValue($userId, $app, $info['configKey'], $value);
         return new JSONResponse(['message' => 'Value stored successfully'], HTTP::STATUS_OK);
     } catch (\Exception $ex) {
         return $this->handleException($ex);
     }
 }
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:24,代码来源:settingscontroller.php

示例7: sendEmail

 /**
  * @param string $user
  * @throws \Exception
  */
 protected function sendEmail($user)
 {
     if (!$this->userManager->userExists($user)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
     }
     $email = $this->config->getUserValue($user, 'settings', 'email');
     if (empty($email)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email because there is no ' . 'email address for this username. Please ' . 'contact your administrator.'));
     }
     $token = $this->secureRandom->getMediumStrengthGenerator()->generate(21, ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER);
     $this->config->setUserValue($user, 'owncloud', 'lostpassword', $token);
     $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
     $tmpl = new \OC_Template('core/lostpassword', 'email');
     $tmpl->assign('link', $link, false);
     $msg = $tmpl->fetchPage();
     try {
         $message = $this->mailer->createMessage();
         $message->setTo([$email => $user]);
         $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
         $message->setPlainBody($msg);
         $message->setFrom([$this->from => $this->defaults->getName()]);
         $this->mailer->send($message);
     } catch (\Exception $e) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:30,代码来源:lostcontroller.php

示例8: updateDB

 /**
  * update database
  */
 public function updateDB()
 {
     // make sure that we don't update the file cache multiple times
     // only update during the first run
     if ($this->installedVersion === '-1') {
         return;
     }
     // delete left-over from old encryption which is no longer needed
     $this->config->deleteAppValue('files_encryption', 'ocsid');
     $this->config->deleteAppValue('files_encryption', 'types');
     $this->config->deleteAppValue('files_encryption', 'enabled');
     $oldAppValues = $this->connection->createQueryBuilder();
     $oldAppValues->select('*')->from('`*PREFIX*appconfig`')->where($oldAppValues->expr()->eq('`appid`', ':appid'))->setParameter('appid', 'files_encryption');
     $appSettings = $oldAppValues->execute();
     while ($row = $appSettings->fetch()) {
         // 'installed_version' gets deleted at the end of the migration process
         if ($row['configkey'] !== 'installed_version') {
             $this->config->setAppValue('encryption', $row['configkey'], $row['configvalue']);
             $this->config->deleteAppValue('files_encryption', $row['configkey']);
         }
     }
     $oldPreferences = $this->connection->createQueryBuilder();
     $oldPreferences->select('*')->from('`*PREFIX*preferences`')->where($oldPreferences->expr()->eq('`appid`', ':appid'))->setParameter('appid', 'files_encryption');
     $preferenceSettings = $oldPreferences->execute();
     while ($row = $preferenceSettings->fetch()) {
         $this->config->setUserValue($row['userid'], 'encryption', $row['configkey'], $row['configvalue']);
         $this->config->deleteUserValue($row['userid'], 'files_encryption', $row['configkey']);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:32,代码来源:migration.php

示例9: setMailAddress

 /**
  * Set the mail address of a user
  *
  * @NoAdminRequired
  * @NoSubadminRequired
  *
  * @param string $id
  * @param string $mailAddress
  * @return DataResponse
  */
 public function setMailAddress($id, $mailAddress)
 {
     $userId = $this->userSession->getUser()->getUID();
     $user = $this->userManager->get($id);
     if ($userId !== $id && !$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Forbidden'))), Http::STATUS_FORBIDDEN);
     }
     if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Invalid mail address'))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     if (!$user) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Invalid user'))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     // this is the only permission a backend provides and is also used
     // for the permission of setting a email address
     if (!$user->canChangeDisplayName()) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Unable to change mail address'))), Http::STATUS_FORBIDDEN);
     }
     // delete user value if email address is empty
     if ($mailAddress === '') {
         $this->config->deleteUserValue($id, 'settings', 'email');
     } else {
         $this->config->setUserValue($id, 'settings', 'email', $mailAddress);
     }
     return new DataResponse(array('status' => 'success', 'data' => array('username' => $id, 'mailAddress' => $mailAddress, 'message' => (string) $this->l10n->t('Email saved'))), Http::STATUS_OK);
 }
开发者ID:evanjt,项目名称:core,代码行数:36,代码来源:userscontroller.php

示例10: sendEmail

 protected function sendEmail($user, $proceed)
 {
     if ($this->isDataEncrypted && !$proceed) {
         throw new EncryptedDataException();
     }
     if (!$this->userManager->userExists($user)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure ' . 'your username is correct.'));
     }
     $token = hash('sha256', \OC_Util::generateRandomBytes(30));
     // Hash the token again to prevent timing attacks
     $this->config->setUserValue($user, 'owncloud', 'lostpassword', hash('sha256', $token));
     $email = $this->config->getUserValue($user, 'settings', 'email');
     if (empty($email)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email because there is no ' . 'email address for this username. Please ' . 'contact your administrator.'));
     }
     $link = $this->getLink('core.lost.resetform', $user, $token);
     $tmpl = new \OC_Template('core/lostpassword', 'email');
     $tmpl->assign('link', $link, false);
     $msg = $tmpl->fetchPage();
     try {
         // FIXME: should be added to the container and injected in here
         \OC_Mail::send($email, $user, $this->l10n->t('%s password reset', array($this->defaults->getName())), $msg, $this->from, $this->defaults->getName());
     } catch (\Exception $e) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:26,代码来源:lostcontroller.php

示例11: set

 /**
  * @NoAdminRequired
  *
  * @param string $key
  * @param string $value
  * @return JSONResponse
  */
 public function set($key = '', $value = '')
 {
     $response = new JSONResponse();
     if ($key === '' || $value === '') {
         $response->setStatus(Http::STATUS_PRECONDITION_FAILED);
         return $response;
     }
     try {
         $this->config->setUserValue($this->userId, $this->appName, $key, $value);
         $response->setData(['key' => $key, 'value' => $value]);
         return $response;
     } catch (\Exception $e) {
         $response->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
         return $response;
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:23,代码来源:settingscontroller.php

示例12: getMultiBucketObjectStoreConfig

 /**
  * @param IUser $user
  * @return array|null
  */
 private function getMultiBucketObjectStoreConfig(IUser $user)
 {
     $config = $this->config->getSystemValue('objectstore_multibucket');
     if (!is_array($config)) {
         return null;
     }
     // sanity checks
     if (empty($config['class'])) {
         \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
     }
     if (!isset($config['arguments'])) {
         $config['arguments'] = [];
     }
     $config['arguments']['user'] = $user;
     $bucket = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null);
     if ($bucket === null) {
         /*
          * Use any provided bucket argument as prefix
          * and add the mapping from username => bucket
          */
         if (!isset($config['arguments']['bucket'])) {
             $config['arguments']['bucket'] = '';
         }
         $mapper = new \OC\Files\ObjectStore\Mapper($user);
         $config['arguments']['bucket'] .= $mapper->getBucket();
         $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $config['arguments']['bucket']);
     } else {
         $config['arguments']['bucket'] = $bucket;
     }
     // instantiate object store implementation
     $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
     return $config;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:37,代码来源:ObjectHomeMountProvider.php

示例13: setEnabled

 /**
  * set the enabled status for the user
  *
  * @param bool $enabled
  */
 public function setEnabled($enabled)
 {
     $this->enabled = $enabled;
     if ($this->config) {
         $enabled = $enabled ? 'true' : 'false';
         $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled);
     }
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:13,代码来源:user.php

示例14: setValue

 /**
  * sets a value in the preferences
  * @param string $user user
  * @param string $app app
  * @param string $key key
  * @param string $value value
  * @param string $preCondition only set value if the key had a specific value before
  * @return bool true if value was set, otherwise false
  * @deprecated use setUserValue of \OCP\IConfig instead
  *
  * Adds a value to the preferences. If the key did not exist before, it
  * will be added automagically.
  */
 public function setValue($user, $app, $key, $value, $preCondition = null)
 {
     try {
         $this->config->setUserValue($user, $app, $key, $value, $preCondition);
         return true;
     } catch (PreConditionNotMetException $e) {
         return false;
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:22,代码来源:preferences.php

示例15: setQuota

 /**
  * set the users' quota
  *
  * @param string $quota
  * @return void
  * @since 9.0.0
  */
 public function setQuota($quota)
 {
     if ($quota !== 'none' and $quota !== 'default') {
         $quota = OC_Helper::computerFileSize($quota);
         $quota = OC_Helper::humanFileSize($quota);
     }
     $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
     $this->triggerChange('quota', $quota);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:16,代码来源:User.php


注:本文中的OCP\IConfig::setUserValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。