本文整理汇总了PHP中CApi::getAuthenticatedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::getAuthenticatedUser方法的具体用法?PHP CApi::getAuthenticatedUser怎么用?PHP CApi::getAuthenticatedUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::getAuthenticatedUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkUserRoleIsAtLeast
/**
* Checks if authenticated user has at least specified role.
* @param int $iRole
* @throws \System\Exceptions\AuroraApiException
*/
public static function checkUserRoleIsAtLeast($iRole)
{
$oUser = \CApi::getAuthenticatedUser();
$bUserRoleIsAtLeast = empty($oUser) && $iRole === \EUserRole::Anonymous || !empty($oUser) && $oUser->Role === \EUserRole::Customer && ($iRole === \EUserRole::Customer || $iRole === \EUserRole::Anonymous) || !empty($oUser) && $oUser->Role === \EUserRole::NormalUser && ($iRole === \EUserRole::NormalUser || $iRole === \EUserRole::Customer || $iRole === \EUserRole::Anonymous) || !empty($oUser) && $oUser->Role === \EUserRole::TenantAdmin && ($iRole === \EUserRole::TenantAdmin || $iRole === \EUserRole::NormalUser || $iRole === \EUserRole::Customer || $iRole === \EUserRole::Anonymous) || !empty($oUser) && $oUser->Role === \EUserRole::SuperAdmin && ($iRole === \EUserRole::SuperAdmin || $iRole === \EUserRole::TenantAdmin || $iRole === \EUserRole::NormalUser || $iRole === \EUserRole::Customer || $iRole === \EUserRole::Anonymous);
if (!$bUserRoleIsAtLeast) {
throw new \System\Exceptions\AuroraApiException(\System\Notifications::AccessDenied);
}
}
示例2: getThemeAndLanguage
/**
* @return array
*/
public function getThemeAndLanguage()
{
static $sLanguage = false;
static $sTheme = false;
static $sSiteName = false;
if (false === $sLanguage && false === $sTheme && false === $sSiteName) {
$oSettings =& CApi::GetSettings();
$sSiteName = $oSettings->GetConf('SiteName');
$sLanguage = $oSettings->GetConf('DefaultLanguage');
$sTheme = $oSettings->GetConf('DefaultSkin');
$oUser = \CApi::getAuthenticatedUser();
if ($oUser) {
$sSiteName = '';
} else {
}
$sLanguage = $this->validatedLanguageValue($sLanguage);
$this->setLoginLanguage($sLanguage);
// todo: sash
$sTheme = $this->validatedThemeValue($sTheme);
}
/*** temporary fix to the problems in mobile version in rtl mode ***/
/* @var $oApiCapability \CApiCapabilityManager */
$oApiCapability = \CApi::GetSystemManager('capability');
if (in_array($sLanguage, array('Arabic', 'Hebrew', 'Persian')) && $oApiCapability && $oApiCapability->isNotLite() && 1 === $this->isMobile()) {
$sLanguage = 'English';
}
/*** end of temporary fix to the problems in mobile version in rtl mode ***/
return array($sLanguage, $sTheme, $sSiteName);
}