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


PHP OC_Preferences::setValue方法代码示例

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


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

示例1: sendEmail

 public static function sendEmail($args)
 {
     $isEncrypted = OC_App::isEnabled('files_encryption');
     if (!$isEncrypted || isset($_POST['continue'])) {
         $continue = true;
     } else {
         $continue = false;
     }
     if (OC_User::userExists($_POST['user']) && $continue) {
         $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
         OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = OC_Helper::makeURLAbsolute($link);
             $tmpl = new OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = OC_L10N::get('core');
             $from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
             try {
                 OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             } catch (Exception $e) {
                 OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
             }
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:34,代码来源:controller.php

示例2: sendEmail

 public static function sendEmail($args)
 {
     if (OC_User::userExists($_POST['user'])) {
         $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
         OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = OC_Helper::makeURLAbsolute($link);
             $tmpl = new OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = OC_L10N::get('core');
             $from = 'lostpassword-noreply@' . OCP\Util::getServerHost();
             OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             echo 'Mailsent';
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
开发者ID:ryanshoover,项目名称:core,代码行数:25,代码来源:controller.php

示例3: setUp

 public function setUp()
 {
     OCA_mozilla_sync\Utils::setTestState();
     // Create Owncloud Test User
     OC_User::createUser($this->userName, $this->password);
     OC_Preferences::setValue($this->userName, 'settings', 'email', $this->email);
     OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer;
     OCA_mozilla_sync\Utils::setTestState();
     OCA_mozilla_sync\User::createUser($this->userHash, $this->password, $this->email);
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:10,代码来源:storageservice.php

示例4: setupFS

 public static function setupFS($user = '')
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         $user_dir = '/' . $user . '/files';
         $user_root = OC_User::getHome($user);
         $userdirectory = $user_root . '/files';
         if (!is_dir($userdirectory)) {
             mkdir($userdirectory, 0755, true);
         }
         //jail the user into his "home" directory
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
         OC_Filesystem::init($user_dir);
         $quotaProxy = new OC_FileProxy_Quota();
         OC_FileProxy::register($quotaProxy);
         // Load personal mount config
         if (is_file($user_root . '/mount.php')) {
             $mountConfig = (include $user_root . '/mount.php');
             if (isset($mountConfig['user'][$user])) {
                 foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
                     OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
                 }
             }
             $mtime = filemtime($user_root . '/mount.php');
             $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0);
             if ($mtime > $previousMTime) {
                 //mount config has changed, filecache needs to be updated
                 OC_FileCache::triggerUpdate($user);
                 OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime);
             }
         }
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
     }
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:55,代码来源:util.php

示例5: setUp

 public function setUp()
 {
     OCA_mozilla_sync\Utils::setTestState();
     // Create ownCloud Test User
     OC_User::createUser($this->userName, $this->password);
     OC_User::setUserId($this->userName);
     OC_Preferences::setValue($this->userName, 'settings', 'email', $this->email);
     OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer;
     OCA_mozilla_sync\Utils::setTestState();
     $this->urlParser = new OCA_mozilla_sync\UrlParser('/1.0/' . $this->userHash);
 }
开发者ID:netcon-source,项目名称:apps,代码行数:11,代码来源:userservice.php

示例6: set

 public static function set($parameters)
 {
     OC_Util::checkLoggedIn();
     $user = OC_User::getUser();
     $app = addslashes(strip_tags($parameters['app']));
     $key = addslashes(strip_tags($parameters['key']));
     $value = OC_OCS::readData('post', 'value', 'text');
     if (OC_Preferences::setValue($user, $app, $key, $value)) {
         return new OC_OCS_Result(null, 100);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:11,代码来源:privatedata.php

示例7: dropTableEncryption

 public function dropTableEncryption()
 {
     $tableName = $this->tableName;
     if (!\OC_DB::tableExists($tableName)) {
         return;
     }
     $sql = "select `uid`, max(`recovery_enabled`) as `recovery_enabled`, min(`migration_status`) as `migration_status` from `*PREFIX*{$tableName}` group by `uid`";
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array())->fetchAll();
     foreach ($result as $row) {
         \OC_Preferences::setValue($row['uid'], 'files_encryption', 'recovery_enabled', $row['recovery_enabled']);
         \OC_Preferences::setValue($row['uid'], 'files_encryption', 'migration_status', $row['migration_status']);
     }
     \OC_DB::dropTable($tableName);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:15,代码来源:migration.php

示例8: setEmail

 /**
  * @brief Set email address
  * @param $uid The username
  */
 private function setEmail($uid)
 {
     if (!$this->db_conn) {
         return false;
     }
     $sql = 'SELECT email FROM auth_user WHERE username = :uid';
     $sth = $this->db->prepare($sql);
     if ($sth->execute(array(':uid' => $uid))) {
         $row = $sth->fetch();
         if ($row) {
             if (OC_Preferences::setValue($uid, 'settings', 'email', $row['email'])) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:nutztherookie,项目名称:owncloud-user_django_auth,代码行数:21,代码来源:user_django_auth.php

示例9: loadUserMountPoints

 public static function loadUserMountPoints($user)
 {
     $user_dir = '/' . $user . '/files';
     $user_root = OC_User::getHome($user);
     $userdirectory = $user_root . '/files';
     if (is_file($user_root . '/mount.php')) {
         $mountConfig = (include $user_root . '/mount.php');
         if (isset($mountConfig['user'][$user])) {
             foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
                 OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
             }
         }
         $mtime = filemtime($user_root . '/mount.php');
         $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0);
         if ($mtime > $previousMTime) {
             //mount config has changed, filecache needs to be updated
             OC_FileCache::triggerUpdate($user);
             OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime);
         }
     }
 }
开发者ID:ryanshoover,项目名称:core,代码行数:21,代码来源:util.php

示例10: tryFormLogin

 protected static function tryFormLogin()
 {
     if (!isset($_POST["user"]) || !isset($_POST['password'])) {
         return false;
     }
     OC_App::loadApps();
     //setup extra user backends
     OC_User::setupBackends();
     if (OC_User::login($_POST["user"], $_POST["password"])) {
         // setting up the time zone
         if (isset($_POST['timezone-offset'])) {
             $_SESSION['timezone'] = $_POST['timezone-offset'];
         }
         self::cleanupLoginTokens($_POST['user']);
         if (!empty($_POST["remember_login"])) {
             if (defined("DEBUG") && DEBUG) {
                 OC_Log::write('core', 'Setting remember login to cookie', OC_Log::DEBUG);
             }
             $token = OC_Util::generate_random_bytes(32);
             OC_Preferences::setValue($_POST['user'], 'login_token', $token, time());
             OC_User::setMagicInCookie($_POST["user"], $token);
         } else {
             OC_User::unsetMagicInCookie();
         }
         OC_Util::redirectToDefaultPage();
         exit;
     }
     return true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:29,代码来源:base.php

示例11: setUserValue

 /**
  * Sets a value in the preferences
  * @param string $user user
  * @param string $app app
  * @param string $key key
  * @param string $value value
  * @return bool
  *
  * Adds a value to the preferences. If the key did not exist before, it
  * will be added automagically.
  */
 public static function setUserValue($user, $app, $key, $value)
 {
     try {
         \OC_Preferences::setValue($user, $app, $key, $value);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:20,代码来源:config.php

示例12: trim

<?php

// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkLoggedIn();
$l = OC_L10N::get('core');
// Get data
if (isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $email = trim($_POST['email']);
    OC_Preferences::setValue(OC_User::getUser(), 'settings', 'email', $email);
    OC_JSON::success(array("data" => array("message" => $l->t("Email saved"))));
} else {
    OC_JSON::error(array("data" => array("message" => $l->t("Invalid email"))));
}
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:14,代码来源:lostpassword.php

示例13: testSetValueWithPreCondition

 public function testSetValueWithPreCondition()
 {
     // remove existing key
     $this->assertTrue(\OC_Preferences::deleteKey('Someuser', 'setvalueapp', 'newkey'));
     // add new preference with pre-condition should fails
     $this->assertFalse(\OC_Preferences::setValue('Someuser', 'setvalueapp', 'newkey', 'newvalue', 'preCondition'));
     $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?');
     $result = $query->execute(array('Someuser', 'setvalueapp', 'newkey'));
     $row = $result->fetchRow();
     $this->assertFalse($row);
     // add new preference without pre-condition should insert the new value
     $this->assertTrue(\OC_Preferences::setValue('Someuser', 'setvalueapp', 'newkey', 'newvalue'));
     $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?');
     $result = $query->execute(array('Someuser', 'setvalueapp', 'newkey'));
     $row = $result->fetchRow();
     $value = $row['configvalue'];
     $this->assertEquals('newvalue', $value);
     // wrong pre-condition, value should stay the same
     $this->assertFalse(\OC_Preferences::setValue('Someuser', 'setvalueapp', 'newkey', 'othervalue', 'preCondition'));
     $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?');
     $result = $query->execute(array('Someuser', 'setvalueapp', 'newkey'));
     $row = $result->fetchRow();
     $value = $row['configvalue'];
     $this->assertEquals('newvalue', $value);
     // correct pre-condition, value should change
     $this->assertTrue(\OC_Preferences::setValue('Someuser', 'setvalueapp', 'newkey', 'othervalue', 'newvalue'));
     $query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?');
     $result = $query->execute(array('Someuser', 'setvalueapp', 'newkey'));
     $row = $result->fetchRow();
     $value = $row['configvalue'];
     $this->assertEquals('othervalue', $value);
 }
开发者ID:Combustible,项目名称:core,代码行数:32,代码来源:preferences-singleton.php

示例14: update_mail

 private static function update_mail($uid, $email)
 {
     if ($email != OC_Preferences::getValue($uid, 'settings', 'email', '')) {
         OC_Preferences::setValue($uid, 'settings', 'email', $email);
         OC_Log::write('saml', 'Set email "' . $email . '" for the user: ' . $uid, OC_Log::DEBUG);
     }
 }
开发者ID:AARNet,项目名称:user_saml,代码行数:7,代码来源:hooks.php

示例15:

<?php

/**
 * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
require_once '../../../lib/base.php';
OC_JSON::checkLoggedIn();
if (isset($_POST["duration"])) {
    OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]);
    OC_JSON::success();
} else {
    OC_JSON::error();
}
?>
 
 
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:17,代码来源:owncloud_apps_calendar_ajax_setduration.php


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