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


PHP OA_Permission::getLinkedAccounts方法代碼示例

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


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

示例1: assignModel

 public static function assignModel(OA_Admin_Template $template, $query = '')
 {
     $accounts = OA_Permission::getLinkedAccounts(true, true);
     $remainingCounts = array();
     // Prepare recently used accountName
     $recentlyUsed = array();
     global $session;
     if (empty($query) && !empty($session['recentlyUsedAccounts'])) {
         $allAcountsNoGroups = array();
         foreach ($accounts as $k => $v) {
             foreach ($accounts[$k] as $accountId => $accountName) {
                 $allAcountsNoGroups[$accountId] = $accountName;
             }
         }
         $recentlyUsedAccountIds = $session['recentlyUsedAccounts'];
         $added = 0;
         foreach ($recentlyUsedAccountIds as $k => $recentlyUserAccountId) {
             if (++$added > self::MAX_ACCOUNTS_IN_GROUP) {
                 break;
             }
             $recentlyUsed[$recentlyUserAccountId] = $allAcountsNoGroups[$recentlyUserAccountId];
         }
     }
     // Prepare admin accounts
     if (isset($accounts[OA_ACCOUNT_ADMIN])) {
         $adminAccounts = self::filterByNameAndLimit($accounts[OA_ACCOUNT_ADMIN], $query, $remainingCounts, OA_ACCOUNT_ADMIN);
         unset($accounts[OA_ACCOUNT_ADMIN]);
     } else {
         $adminAccounts = array();
     }
     $showSearchAndRecent = false;
     foreach ($accounts as $k => $v) {
         $workingFor = sprintf($GLOBALS['strWorkingFor'], ucfirst(strtolower($k)));
         $accounts[$workingFor] = self::filterByNameAndLimit($v, $query, $remainingCounts, $workingFor);
         $count = count($accounts[$workingFor]);
         if ($count == 0) {
             unset($accounts[$workingFor]);
         }
         $showSearchAndRecent |= isset($remainingCounts[$workingFor]);
         unset($accounts[$k]);
     }
     // Prepend recently used to the results
     if (!empty($recentlyUsed) && $showSearchAndRecent) {
         $accounts = array_merge(array($GLOBALS['strRecentlyUsed'] => $recentlyUsed), $accounts);
     }
     $template->assign('adminAccounts', $adminAccounts);
     $template->assign('otherAccounts', $accounts);
     $template->assign('remainingCounts', $remainingCounts);
     $template->assign('query', $query);
     $template->assign('noAccountsMessage', sprintf($GLOBALS['strNoAccountWithXInNameFound'], $query));
     $template->assign('currentAccountId', OA_Permission::getAccountId());
     $template->assign('showSearchAndRecent', $showSearchAndRecent);
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:53,代碼來源:AccountSwitch.php

示例2: resetUserDefaultAccount

 /**
  * Resets default user's account to one of the account's ids which is linked to him.
  *
  * @param integer $userId
  * @param integer $accountId
  */
 function resetUserDefaultAccount($userId, $accountId)
 {
     $linkedAccounts = OA_Permission::getLinkedAccounts(false, $userId);
     $doUsers = OA_Dal::staticGetDO('users', $userId);
     if ($doUsers->default_account_id == $accountId) {
         $doUsers->default_account_id = array_shift($linkedAccounts);
         $doUsers->update();
     }
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:15,代碼來源:UserAccess.php

示例3: attemptToSwitchToAccount

 function attemptToSwitchToAccount($accountType)
 {
     $oUser = OA_Permission::getCurrentUser();
     if (!$oUser) {
         return false;
     }
     $aAccountTypes = is_array($accountType) ? $accountType : func_get_args();
     $aAccountIds = OA_Permission::getLinkedAccounts(true);
     $defaultUserAccountId = $oUser->aUser['default_account_id'];
     foreach ($aAccountTypes as $accountType) {
         if (isset($aAccountIds[$accountType])) {
             if (isset($aAccountIds[$accountType][$defaultUserAccountId])) {
                 $accountId = $defaultUserAccountId;
             } else {
                 $accountId = array_shift(array_keys($aAccountIds[$accountType]));
             }
             OA_Permission::switchAccount($accountId, $hasAccess = true);
             return true;
         }
     }
     return false;
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:22,代碼來源:Permission.php


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