本文整理汇总了PHP中OCP\Config::getUserValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getUserValue方法的具体用法?PHP Config::getUserValue怎么用?PHP Config::getUserValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Config
的用法示例。
在下文中一共展示了Config::getUserValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* get the stored metadata of a file or folder
*
* @param string/int $file
* @return array
*/
public function get($file)
{
if ($file == '') {
$data = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
$etag = \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_sharing', 'etag');
if (!isset($etag)) {
$etag = $this->storage->getETag('');
\OCP\Config::setUserValue(\OCP\User::getUser(), 'files_sharing', 'etag', $etag);
}
$data['etag'] = $etag;
return $data;
} else {
if (is_string($file)) {
if ($cache = $this->getSourceCache($file)) {
return $cache->get($this->files[$file]);
}
} else {
$query = \OC_DB::prepare('SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`,' . ' `size`, `mtime`, `encrypted`' . ' FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$result = $query->execute(array($file));
$data = $result->fetchRow();
$data['fileid'] = (int) $data['fileid'];
$data['size'] = (int) $data['size'];
$data['mtime'] = (int) $data['mtime'];
$data['encrypted'] = (bool) $data['encrypted'];
$data['mimetype'] = $this->getMimetype($data['mimetype']);
$data['mimepart'] = $this->getMimetype($data['mimepart']);
return $data;
}
}
return false;
}
示例2: getGroups
/**
* @NoAdminRequired
*/
public function getGroups() {
$tags = $this->tags->getTags();
foreach ($tags as &$tag) {
try {
$ids = $this->tags->getIdsForTag($tag['id']);
$tag['contacts'] = $ids;
$tag['displayname'] = $this->displayName($tag);
} catch(\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $e->getMessage(), \OCP\Util::ERROR);
}
}
$favorites = $this->tags->getFavorites();
$shares = \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
$addressbookShare = new \OCA\Contacts\Share\Addressbook();
foreach ($shares as $key => $share) {
$children = $addressbookShare->getChildren($share['id']); // FIXME: This should be cheaper!
$shares[$key]['length'] = count($children);
}
$groups = array(
'categories' => $tags,
'favorites' => $favorites,
'shared' => $shares,
'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'),
'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''),
);
return new JSONResponse($groups);
}
示例3: updateAvatar
/**
* @brief reads jpegPhoto and set is as avatar if available
* @param $uid string ownCloud user name
* @param $dn string the user's LDAP DN
* @return void
*/
private function updateAvatar($uid, $dn)
{
$hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap', 'firstLoginAccomplished', 0);
$lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0);
if ($hasLoggedIn !== '1' || time() - intval($lastChecked) < 86400) {
//update only once a day
return;
}
$avatarImage = $this->getAvatarImage($uid, $dn);
if ($avatarImage === false) {
//not set, nothing left to do;
return;
}
$image = new \OCP\Image();
$image->loadFromBase64(base64_encode($avatarImage));
if (!$image->valid()) {
\OCP\Util::writeLog('user_ldap', 'jpegPhoto data invalid for ' . $dn, \OCP\Util::ERROR);
return;
}
//make sure it is a square and not bigger than 128x128
$size = min(array($image->width(), $image->height(), 128));
if (!$image->centerCrop($size)) {
\OCP\Util::writeLog('user_ldap', 'croping image for avatar failed for ' . $dn, \OCP\Util::ERROR);
return;
}
if (!\OC\Files\Filesystem::$loaded) {
\OC_Util::setupFS($uid);
}
$avatarManager = \OC::$server->getAvatarManager();
$avatar = $avatarManager->getAvatar($uid);
$avatar->set($image);
}
示例4: getSettings
/**
* @NoAdminRequired
*/
public function getSettings()
{
$settings = array(array('id' => 'various', 'showHidden' => (int) \OCP\Config::getUserValue($this->api->getUserId(), 'tasks_enhanced', 'various_showHidden'), 'startOfWeek' => (int) \OCP\Config::getUserValue($this->api->getUserId(), 'tasks_enhanced', 'various_startOfWeek'), 'userID' => $this->api->getUserId()));
$result = array('data' => array('settings' => $settings));
$response = new JSONResponse();
$response->setData($result);
return $response;
}
示例5: __construct
/**
*
* @param string $sender user id
*/
public function __construct($sender)
{
$this->l = \OC::$server->getL10N('lib');
$this->senderId = $sender;
$this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply');
$this->replyTo = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from);
$this->senderDisplayName = \OCP\User::getDisplayName($this->senderId);
}
示例6: __construct
/**
*
* @param string $sender user id (if nothing is set we use the currently logged-in user)
*/
public function __construct($sender = null)
{
$this->l = \OC_L10N::get('core');
$this->senderId = $sender;
$this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply');
if ($this->senderId) {
$this->from = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from);
$this->senderDisplayName = \OCP\User::getDisplayName($this->senderId);
} else {
$this->senderDisplayName = \OCP\User::getDisplayName();
}
}
示例7: getPrincipalByPath
/**
* Returns a specific principal, specified by it's path.
* The returned structure should be the exact same as from
* getPrincipalsByPrefix.
*
* @param string $path
* @return array
*/
public function getPrincipalByPath($path)
{
list($prefix, $name) = explode('/', $path);
if ($prefix == 'principals' && OC_User::userExists($name)) {
$principal = array('uri' => 'principals/' . $name, '{DAV:}displayname' => $name);
$email = \OCP\Config::getUserValue($user, 'settings', 'email');
if ($email) {
$principal['{http://sabredav.org/ns}email-address'] = $email;
}
return $principal;
}
return null;
}
示例8: getTimezone
/**
* @return (string) $timezone as set by user or the default timezone
*/
public static function getTimezone()
{
//FIXME
if (\OCP\User::isLoggedIn()) {
return \OCP\Config::getUserValue(\OCP\User::getUser(), self::$appName, 'timezone', date_default_timezone_get());
} else {
if (\OC::$server->getSession()->exists('public_link_timezone')) {
return \OC::$server->getSession()->get('public_link_timezone');
} else {
return date_default_timezone_get();
}
}
}
示例9: getGroups
/**
* @NoAdminRequired
*/
public function getGroups()
{
$tags = $this->tags->getTags();
foreach ($tags as &$tag) {
try {
$ids = $this->tags->getIdsForTag($tag['name']);
$tag['contacts'] = $ids;
} catch (\Exception $e) {
$this->api->log(__METHOD__ . ' ' . $e->getMessage());
}
}
$favorites = $this->tags->getFavorites();
$groups = array('categories' => $tags, 'favorites' => $favorites, 'shared' => \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS), 'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''));
return new JSONResponse($groups);
}
示例10: create
public static function create($args)
{
$uid = self::preDispatch();
$view = new \OC\Files\View('/' . $uid . '/files');
$dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
$path = Helper::getNewFileName($view, $dir . '/New Document.odt');
$content = base64_decode(self::ODT_TEMPLATE);
if (class_exists('\\OC\\Files\\Type\\TemplateManager')) {
$manager = \OC_Helper::getFileTemplateManager();
$templateContent = $manager->getTemplate('application/vnd.oasis.opendocument.text');
if ($templateContent) {
$content = $templateContent;
}
}
$view->file_put_contents($path, $content);
}
示例11: sendMail
public static function sendMail($path)
{
if (!\OCP\User::isLoggedIn()) {
return;
}
$email = \OCP\Config::getUserValue(\OCP\User::getUser(), 'settings', 'email', '');
\OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
if (!empty($email)) {
$defaults = new \OCP\Defaults();
$tmpl = new \OCP\Template('files_antivirus', 'notification');
$tmpl->assign('file', $path);
$tmpl->assign('host', \OCP\Util::getServerHost());
$tmpl->assign('user', \OCP\User::getDisplayName());
$msg = $tmpl->fetchPage();
$from = \OCP\Util::getDefaultEmailAddress('security-noreply');
\OCP\Util::sendMail($email, \OCP\User::getUser(), \OCP\Util::getL10N('files_antivirus')->t('Malware detected'), $msg, $from, $defaults->getName(), true);
}
}
示例12: send
/**
* send push notifications. Currently only pushover.net is supported
*
*/
public static function send($subject, $url)
{
$app_key = \OCP\Config::getSystemValue('pushnotifications_pushover_app', '');
$pushid = trim(\OCP\Config::getUserValue(\OCP\User::getUser(), 'pushnotifications', 'pushid', ''));
if (!empty($pushid)) {
$push = new \Pushover();
$push->setToken($app_key);
$push->setUser($pushid);
$push->setMessage($subject);
$push->setUrl($url);
$push->setUrlTitle('ownCloud');
$push->setCallback($url);
$push->setTimestamp(time());
$push->setDebug(true);
$go = $push->send();
unset($push);
}
}
示例13: userAddressBooks
/**
* @NoAdminRequired
*/
public function userAddressBooks()
{
$addressBooks = $this->app->getAddressBooksForUser();
$result = array();
$lastModified = 0;
foreach ($addressBooks as $addressBook) {
$data = $addressBook->getMetaData();
$result[] = $data;
if (!is_null($data['lastmodified'])) {
$lastModified = max($lastModified, $data['lastmodified']);
}
}
// To avoid invalid cache deletion time is saved
$lastModified = max($lastModified, \OCP\Config::getUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', 0));
$response = new JSONResponse(array('addressbooks' => $result));
if ($lastModified > 0) {
$response->setLastModified(\DateTime::createFromFormat('U', $lastModified) ?: null);
$response->setETag(md5($lastModified));
}
return $response;
}
示例14: create
public static function create($args)
{
$uid = self::preDispatch();
$view = new \OC\Files\View('/' . $uid . '/files');
$dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
if (!$view->is_dir($dir)) {
$dir = '/';
}
$path = Helper::getNewFileName($view, $dir . '/New Document.odt');
$content = base64_decode(self::ODT_TEMPLATE);
if (class_exists('\\OC\\Files\\Type\\TemplateManager')) {
$manager = \OC_Helper::getFileTemplateManager();
$templateContent = $manager->getTemplate(Storage::MIMETYPE_LIBREOFFICE_WORDPROCESSOR);
if ($templateContent) {
$content = $templateContent;
}
}
if ($view->file_put_contents($path, $content)) {
$info = $view->getFileInfo($path);
\OCP\JSON::success(array('fileid' => $info['fileid']));
} else {
\OCP\JSON::error(array('message' => Config::getL10n()->t('Can\'t create document')));
}
}
示例15: needUpgrade
/**
* check if a cache upgrade is required for $user
*
* @param string $user
* @return bool
*/
static function needUpgrade($user)
{
$cacheVersion = (int) \OCP\Config::getUserValue($user, 'files', 'cache_version', 4);
if ($cacheVersion < 5) {
$legacy = new \OC\Files\Cache\Legacy($user);
if ($legacy->hasItems()) {
return true;
}
self::upgradeDone($user);
}
return false;
}