本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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"))));
}
示例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);
}
示例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);
}
}
示例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