本文整理汇总了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);
}
示例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();
}
}
示例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;
}