當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OC_Preferences::getKeys方法代碼示例

本文整理匯總了PHP中OC_Preferences::getKeys方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Preferences::getKeys方法的具體用法?PHP OC_Preferences::getKeys怎麽用?PHP OC_Preferences::getKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC_Preferences的用法示例。


在下文中一共展示了OC_Preferences::getKeys方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetKeys

 public function testGetKeys()
 {
     $query = \OC_DB::prepare('SELECT DISTINCT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?');
     $result = $query->execute(array('Someuser', 'getkeysapp'));
     $expected = array();
     while ($row = $result->fetchRow()) {
         $expected[] = $row['configkey'];
     }
     $this->assertEquals($expected, \OC_Preferences::getKeys('Someuser', 'getkeysapp'));
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:10,代碼來源:preferences-singleton.php

示例2: loginWithCookie

 /**
  * perform login using the magic cookie (remember login)
  *
  * @param string $uid the username
  * @param string $currentToken
  * @return bool
  */
 public function loginWithCookie($uid, $currentToken)
 {
     $this->manager->emit('\\OC\\User', 'preRememberedLogin', array($uid));
     $user = $this->manager->get($uid);
     if (is_null($user)) {
         // user does not exist
         return false;
     }
     // get stored tokens
     $tokens = \OC_Preferences::getKeys($uid, 'login_token');
     // test cookies token against stored tokens
     if (!in_array($currentToken, $tokens, true)) {
         return false;
     }
     // replace successfully used token with a new one
     \OC_Preferences::deleteKey($uid, 'login_token', $currentToken);
     $newToken = \OC_Util::generateRandomBytes(32);
     \OC_Preferences::setValue($uid, 'login_token', $newToken, time());
     $this->setMagicInCookie($user->getUID(), $newToken);
     //login
     $this->setUser($user);
     $this->manager->emit('\\OC\\User', 'postRememberedLogin', array($user));
     return true;
 }
開發者ID:WYSAC,項目名稱:oregon-owncloud,代碼行數:31,代碼來源:session.php

示例3: tryRememberLogin

 protected static function tryRememberLogin()
 {
     if (!isset($_COOKIE["oc_remember_login"]) || !isset($_COOKIE["oc_token"]) || !isset($_COOKIE["oc_username"]) || !$_COOKIE["oc_remember_login"]) {
         return false;
     }
     OC_App::loadApps(array('authentication'));
     if (defined("DEBUG") && DEBUG) {
         OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
     }
     // confirm credentials in cookie
     if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) {
         // delete outdated cookies
         self::cleanupLoginTokens($_COOKIE['oc_username']);
         // get stored tokens
         $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token');
         // test cookies token against stored tokens
         if (in_array($_COOKIE['oc_token'], $tokens, true)) {
             // replace successfully used token with a new one
             OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']);
             $token = OC_Util::generate_random_bytes(32);
             OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time());
             OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
             // login
             OC_User::setUserId($_COOKIE['oc_username']);
             OC_Util::redirectToDefaultPage();
             // doesn't return
         }
         // if you reach this point you have changed your password
         // or you are an attacker
         // we can not delete tokens here because users may reach
         // this point multiple times after a password change
         OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN);
     }
     OC_User::unsetMagicInCookie();
     return true;
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:36,代碼來源:base.php

示例4: cleanupLoginTokens

 /**
  * Remove outdated and therefore invalid tokens for a user
  * @param string $user
  */
 protected static function cleanupLoginTokens($user)
 {
     $cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
     $tokens = OC_Preferences::getKeys($user, 'login_token');
     foreach ($tokens as $token) {
         $time = OC_Preferences::getValue($user, 'login_token', $token);
         if ($time < $cutoff) {
             OC_Preferences::deleteKey($user, 'login_token', $token);
         }
     }
 }
開發者ID:pinoniq,項目名稱:core,代碼行數:15,代碼來源:base.php

示例5: getData

 /**
  * get private data
  * @param string $user
  * @param string $app
  * @param string $key
  * @param bool $like use LIKE instead of = when comparing keys
  * @return array
  */
 public static function getData($user, $app = "", $key = "")
 {
     if ($app) {
         $apps = array($app);
     } else {
         $apps = OC_Preferences::getApps($user);
     }
     if ($key) {
         $keys = array($key);
     } else {
         foreach ($apps as $app) {
             $keys = OC_Preferences::getKeys($user, $app);
         }
     }
     $result = array();
     foreach ($apps as $app) {
         foreach ($keys as $key) {
             $value = OC_Preferences::getValue($user, $app, $key);
             $result[] = array('app' => $app, 'key' => $key, 'value' => $value);
         }
     }
     return $result;
 }
開發者ID:ryanshoover,項目名稱:core,代碼行數:31,代碼來源:ocs.php

示例6: getUserKeys

 /**
  * Get the keys of all stored by an app for the user
  *
  * @param string $userId the userId of the user that we want to store the value under
  * @param string $appName the appName that we stored the value under
  * @return string[]
  */
 public function getUserKeys($userId, $appName)
 {
     return \OC_Preferences::getKeys($userId, $appName);
 }
開發者ID:Romua1d,項目名稱:core,代碼行數:11,代碼來源:allconfig.php


注:本文中的OC_Preferences::getKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。