本文整理匯總了PHP中OC_Preferences::getValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Preferences::getValue方法的具體用法?PHP OC_Preferences::getValue怎麽用?PHP OC_Preferences::getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC_Preferences
的用法示例。
在下文中一共展示了OC_Preferences::getValue方法的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: __construct
/**
* @brief Constructor.
* @param $app The application identifier e.g. 'contacts' or 'calendar'.
* @param $user The user whos data the object will operate on. This
* parameter should normally be omitted but to make an app able to
* update categories for all users it is made possible to provide it.
* @param $defcategories An array of default categories to be used if none is stored.
*/
public function __construct($app, $user = null, $defcategories = array())
{
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
$this->categories = $categories != '' ? unserialize($categories) : $defcategories;
}
示例3: 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);
}
}
示例4: getFreeSpace
private function getFreeSpace()
{
$usedSpace = OC_Filesystem::filesize('');
$totalSpace = OC_Preferences::getValue(OC_User::getUser(), 'files', 'quota', 0);
if ($totalSpace == 0) {
return 0;
}
return $totalSpace - $usedSpace;
}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-owncloud_.htaccess-,代碼行數:9,代碼來源:owncloud_lib_fileproxy_quota.php
示例5: getUser
/**
* gets user info
*/
public static function getUser($parameters)
{
$userid = $parameters['userid'];
$return = array();
$return['email'] = OC_Preferences::getValue($userid, 'settings', 'email', '');
$default = OC_Appconfig::getValue('files', 'default_quota', 0);
$return['quota'] = OC_Preferences::getValue($userid, 'files', 'quota', $default);
return $return;
}
示例6: testGetValue
public function testGetValue()
{
$this->assertNull(\OC_Preferences::getValue('nonexistant', 'nonexistant', 'nonexistant'));
$this->assertEquals('default', \OC_Preferences::getValue('nonexistant', 'nonexistant', 'nonexistant', 'default'));
$query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?');
$result = $query->execute(array('Someuser', 'getvalueapp', 'key'));
$row = $result->fetchRow();
$expected = $row['configvalue'];
$this->assertEquals($expected, \OC_Preferences::getValue('Someuser', 'getvalueapp', 'key'));
}
示例7: sendInternalShareMail
/**
* inform users if a file was shared with them
*
* @param array $recipientList list of recipients
* @param string $itemSource shared item source
* @param string $itemType shared item type
* @return array list of user to whom the mail send operation failed
*/
public function sendInternalShareMail($recipientList, $itemSource, $itemType) {
$noMail = array();
foreach ($recipientList as $recipient) {
$recipientDisplayName = \OCP\User::getDisplayName($recipient);
$to = \OC_Preferences::getValue($recipient, 'settings', 'email', '');
if ($to === '') {
$noMail[] = $recipientDisplayName;
continue;
}
$items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
$filename = trim($items[0]['file_target'], '/');
$subject = (string) $this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
$expiration = null;
if (isset($items[0]['expiration'])) {
try {
$date = new DateTime($items[0]['expiration']);
$expiration = $date->getTimestamp();
} catch (\Exception $e) {
\OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
}
}
// Link to folder, or root folder if a file
if ($itemType === 'folder') {
$args = array(
'dir' => $filename,
);
} else {
$args = array(
'dir' => '/',
'scrollto' => $filename,
);
}
$link = \OCP\Util::linkToAbsolute('files', 'index.php', $args);
list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
// send it out now
try {
\OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
} catch (\Exception $e) {
\OCP\Util::writeLog('sharing', "Can't send mail to inform the user about an internal share: " . $e->getMessage() , \OCP\Util::ERROR);
$noMail[] = $recipientDisplayName;
}
}
return $noMail;
}
示例8: 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));
}
}
示例9: getUserQuota
public static function getUserQuota($user)
{
$userQuota = OC_Preferences::getValue($user, 'files', 'quota', 'default');
if ($userQuota === 'default') {
$userQuota = OC_AppConfig::getValue('files', 'default_quota', 'none');
}
if ($userQuota === 'none') {
return \OC\Files\SPACE_UNLIMITED;
} else {
return OC_Helper::computerFileSize($userQuota);
}
}
示例10: __construct
/**
* @param string $uid
* @param \OC_User_Backend $backend
* @param Emitter $emitter
*/
public function __construct($uid, $backend, $emitter = null)
{
$this->uid = $uid;
if ($backend and $backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) {
$this->displayName = $backend->getDisplayName($uid);
} else {
$this->displayName = $uid;
}
$this->backend = $backend;
$this->emitter = $emitter;
$enabled = \OC_Preferences::getValue($uid, 'core', 'enabled', 'true');
//TODO: DI for OC_Preferences
$this->enabled = $enabled === 'true';
}
示例11: __construct
/**
* @param string $uid
* @param \OC_User_Interface $backend
* @param \OC\Hooks\Emitter $emitter
* @param \OC\AllConfig $config
*/
public function __construct($uid, $backend, $emitter = null, $config = null)
{
$this->uid = $uid;
$this->backend = $backend;
$this->emitter = $emitter;
$this->config = $config;
if ($this->config) {
$enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
$this->enabled = $enabled === 'true';
} else {
$this->enabled = true;
}
$this->lastLogin = \OC_Preferences::getValue($uid, 'login', 'lastLogin', 0);
}
示例12: getQuota
/**
* get the quota for the user
* @param user
* @return int
*/
private function getQuota($user)
{
if (in_array($user, $this->userQuota)) {
return $this->userQuota[$user];
}
$userQuota = OC_Preferences::getValue($user, 'files', 'quota', 'default');
if ($userQuota == 'default') {
$userQuota = OC_AppConfig::getValue('files', 'default_quota', 'none');
}
if ($userQuota == 'none') {
$this->userQuota[$user] = -1;
} else {
$this->userQuota[$user] = OC_Helper::computerFileSize($userQuota);
}
return $this->userQuota[$user];
}
示例13: getQuota
/**
* get the quota for the current user
* @return int
*/
private function getQuota()
{
if ($this->userQuota != -1) {
return $this->userQuota;
}
$userQuota = OC_Preferences::getValue(OC_User::getUser(), 'files', 'quota', 'default');
if ($userQuota == 'default') {
$userQuota = OC_AppConfig::getValue('files', 'default_quota', 'none');
}
if ($userQuota == 'none') {
$this->userQuota = 0;
} else {
$this->userQuota = OC_Helper::computerFileSize($userQuota);
}
return $this->userQuota;
}
示例14: sendTaskCreationMail
/**
* @brief Send an email while creating and assigning a task
* @param Title of the task
* @param Task description
* @param Project ID to which the task belongs
* @param To whom the task is assigned
* @param Deadline for completing the task
*/
public static function sendTaskCreationMail($title, $desc, $pid, $member, $deadline)
{
try {
$subject = 'You are assigned a task \'' . $title . '\'';
$message = 'Hello ' . $member . ',';
$message .= '<br /><p style="text-indent: 50px;" >';
$message .= 'You are assigned to the task \'' . $title . '\' under the project \'' . OC_Collaboration_Project::getProjectTitle($pid) . '\'.';
$message .= '<br /><p style="text-align: justify;" ><span style="font-weight: bold;" >';
$message .= 'Description: ';
$message .= '</span>' . $desc . '<br /><br /><span style="font-weight: bold;" >';
$message .= 'Deadline: ';
$message .= '</span>' . $deadline . '</p><br /><br />';
$message .= 'For further details, logon to your owncloud account.';
$message .= '<br /><br />';
\OC_Mail::send(OC_Preferences::getValue($member, 'settings', 'email'), $member, $subject, $message, OC_Config::getValue('mail_smtpname', ''), 'Owncloud Collaboration App', true);
} catch (\Exception $e) {
OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
return false;
}
}
示例15: sendTestMail
/**
* Send a mail to test the settings
*/
public static function sendTestMail()
{
\OC_Util::checkAdminUser();
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
$email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
if (!empty($email)) {
$defaults = new \OC_Defaults();
try {
\OC_Mail::send($email, \OC_User::getDisplayName(), $l->t('test email settings'), $l->t('If you received this email, the settings seem to be correct.'), \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
} catch (\Exception $e) {
$message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
\OC_JSON::error(array("data" => array("message" => $message)));
exit;
}
\OC_JSON::success(array("data" => array("message" => $l->t("Email sent"))));
} else {
$message = $l->t('You need to set your user email before being able to send test emails.');
\OC_JSON::error(array("data" => array("message" => $message)));
}
}