本文整理汇总了PHP中OC_Preferences类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Preferences类的具体用法?PHP OC_Preferences怎么用?PHP OC_Preferences使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: tearDown
public function tearDown()
{
$userId = OCA_mozilla_sync\User::userHashToId($this->userHash);
if ($userId != false) {
OCA_mozilla_sync\User::deleteUser($userId);
}
OC_Preferences::deleteUser($this->userName);
OC_User::deleteUser($this->userName);
}
示例3: 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;
}
示例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: 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;
}
示例6: 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);
}
}
示例7: tearDown
public function tearDown()
{
$this->user = null;
if ($this->storageMock) {
$this->storageMock->getCache()->clear();
$this->storageMock = null;
}
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('');
\OC_User::deleteUser($this->user);
\OC_Preferences::deleteUser($this->user);
}
示例8: delete
public static function delete($parameters)
{
OC_Util::checkLoggedIn();
$user = OC_User::getUser();
$app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key']));
if ($key === "" or $app === "") {
return new OC_OCS_Result(null, 101);
//key and app are NOT optional here
}
if (OC_Preferences::deleteKey($user, $app, $key)) {
return new OC_OCS_Result(null, 100);
}
}
示例9: 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);
}
示例10: 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];
}
示例11: 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;
}
示例12: 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;
}
示例13: resetPassword
public static function resetPassword($args)
{
if (self::checkToken($args['user'], $args['token'])) {
if (isset($_POST['password'])) {
if (OC_User::setPassword($args['user'], $_POST['password'])) {
OC_Preferences::deleteKey($args['user'], 'owncloud', 'lostpassword');
OC_User::unsetMagicInCookie();
self::displayResetPasswordPage(true, $args);
} else {
self::displayResetPasswordPage(false, $args);
}
} else {
self::reset($args);
}
} else {
// Someone lost their password
self::displayLostPasswordPage(false, false);
}
}
示例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)));
}
}