本文整理汇总了PHP中UserRights::GetUserObject方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::GetUserObject方法的具体用法?PHP UserRights::GetUserObject怎么用?PHP UserRights::GetUserObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRights
的用法示例。
在下文中一共展示了UserRights::GetUserObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IsUserAllowed
public function IsUserAllowed()
{
if (array_key_exists('profile_list', $_SESSION)) {
$aProfiles = $_SESSION['profile_list'];
} else {
$oUser = UserRights::GetUserObject();
$oSet = $oUser->Get('profile_list');
while (($oLnkUserProfile = $oSet->Fetch()) !== null) {
$aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
}
$_SESSION['profile_list'] = $aProfiles;
}
foreach ($this->aData['deny'] as $sDeniedProfile) {
// If one denied profile is present, it's enough => return false
if (in_array($sDeniedProfile, $aProfiles)) {
return false;
}
}
foreach ($this->aData['allow'] as $sAllowProfile) {
// if one required profile is missing, it's enough => return false
if (!in_array($sAllowProfile, $aProfiles)) {
return false;
}
}
return true;
}
示例2: IsUserAllowed
public function IsUserAllowed()
{
$bRet = true;
if (array_key_exists('profile_list', $_SESSION)) {
$aProfiles = $_SESSION['profile_list'];
} else {
$oUser = UserRights::GetUserObject();
$oSet = $oUser->Get('profile_list');
while (($oLnkUserProfile = $oSet->Fetch()) !== null) {
$aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
}
$_SESSION['profile_list'] = $aProfiles;
}
foreach ($this->aData['deny'] as $sDeniedProfile) {
// If one denied profile is present, it's enough => return false
if (in_array($sDeniedProfile, $aProfiles)) {
return false;
}
}
// If there are some "allow" profiles, then by default the result is false
// since the user must have at least one of the profiles to be allowed
if (count($this->aData['allow']) > 0) {
$bRet = false;
}
foreach ($this->aData['allow'] as $sAllowProfile) {
// If one "allow" profile is present, it's enough => return true
if (in_array($sAllowProfile, $aProfiles)) {
return true;
}
}
return $bRet;
}
示例3: Login
//.........这里部分代码省略.........
}
break;
case 'external':
// Web server supplied authentication
$bExternalAuth = false;
$sExtAuthVar = MetaModel::GetConfig()->GetExternalAuthenticationVariable();
// In which variable is the info passed ?
eval('$sAuthUser = isset(' . $sExtAuthVar . ') ? ' . $sExtAuthVar . ' : false;');
// Retrieve the value
if ($sAuthUser && strlen($sAuthUser) > 0) {
$sAuthPwd = '';
// No password in this case the web server already authentified the user...
$sLoginMode = 'external';
$sAuthentication = 'external';
}
break;
case 'url':
// Credentials passed directly in the url
$sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
$sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
if ($sAuthUser != '' && $sAuthPwd !== null) {
$sLoginMode = 'url';
}
break;
}
$index++;
}
//echo "\nsLoginMode: $sLoginMode (user: $sAuthUser / pwd: $sAuthPwd\n)";
if ($sLoginMode == '') {
// First connection
$sDesiredLoginMode = utils::ReadParam('login_mode');
if (in_array($sDesiredLoginMode, $aAllowedLoginTypes)) {
$sLoginMode = $sDesiredLoginMode;
} else {
$sLoginMode = $aAllowedLoginTypes[0];
// First in the list...
}
if (array_key_exists('HTTP_X_COMBODO_AJAX', $_SERVER)) {
// X-Combodo-Ajax is a special header automatically added to all ajax requests
// Let's reply that we're currently logged-out
header('HTTP/1.0 401 Unauthorized');
exit;
}
if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=iso-8859-1');
exit;
} else {
if ($iOnExit == self::EXIT_RETURN) {
if ($sAuthUser !== '' && $sAuthPwd === null) {
return self::EXIT_CODE_MISSINGPASSWORD;
} else {
return self::EXIT_CODE_MISSINGLOGIN;
}
} else {
$oPage = self::NewLoginWebPage();
$oPage->DisplayLoginForm($sLoginMode, false);
$oPage->output();
exit;
}
}
} else {
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $sLoginMode, $sAuthentication)) {
//echo "Check Credentials returned false for user $sAuthUser!";
self::ResetSession();
if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=iso-8859-1');
exit;
} else {
if ($iOnExit == self::EXIT_RETURN) {
return self::EXIT_CODE_WRONGCREDENTIALS;
} else {
$oPage = self::NewLoginWebPage();
$oPage->DisplayLoginForm($sLoginMode, true);
$oPage->output();
exit;
}
}
} else {
// User is Ok, let's save it in the session and proceed with normal login
UserRights::Login($sAuthUser, $sAuthentication);
// Login & set the user's language
if (MetaModel::GetConfig()->Get('log_usage')) {
$oLog = new EventLoginUsage();
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('user_id', UserRights::GetUserObject()->GetKey());
$oLog->Set('message', 'Successful login');
$oLog->DBInsertNoReload();
}
$_SESSION['auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = $sLoginMode;
UserRights::_InitSessionCache();
}
}
}
return self::EXIT_CODE_OK;
}
示例4: GetRenderContent
//.........这里部分代码省略.........
$aTransitions = $oObj->EnumTransitions();
if (count($aTransitions)) {
$this->AddMenuSeparator($aActions);
$aStimuli = Metamodel::EnumStimuli(get_class($oObj));
foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
$iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet) : UR_ALLOWED_NO;
switch ($iActionAllowed) {
case UR_ALLOWED_YES:
$aActions[$sStimulusCode] = array('label' => $aStimuli[$sStimulusCode]->GetLabel(), 'url' => "{$sRootUrl}pages/UI.php?operation=stimulus&stimulus={$sStimulusCode}&class={$sClass}&id={$id}{$sContext}");
break;
default:
// Do nothing
}
}
}
}
// Relations...
$aRelations = MetaModel::EnumRelationsEx($sClass);
if (count($aRelations)) {
$this->AddMenuSeparator($aActions);
foreach ($aRelations as $sRelationCode => $aRelationInfo) {
if (array_key_exists('down', $aRelationInfo)) {
$aActions[$sRelationCode . '_down'] = array('label' => $aRelationInfo['down'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=down&class={$sClass}&id={$id}{$sContext}");
}
if (array_key_exists('up', $aRelationInfo)) {
$aActions[$sRelationCode . '_up'] = array('label' => $aRelationInfo['up'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=up&class={$sClass}&id={$id}{$sContext}");
}
}
}
if ($bLocked && $bRawModifiedAllowed) {
// Add a special menu to kill the lock, but only to allowed users who can also modify this object
$aAllowedProfiles = MetaModel::GetConfig()->Get('concurrent_lock_override_profiles');
$bCanKill = false;
$oUser = UserRights::GetUserObject();
$aUserProfiles = array();
if (!is_null($oUser)) {
$oProfileSet = $oUser->Get('profile_list');
while ($oProfile = $oProfileSet->Fetch()) {
$aUserProfiles[$oProfile->Get('profile')] = true;
}
}
foreach ($aAllowedProfiles as $sProfile) {
if (array_key_exists($sProfile, $aUserProfiles)) {
$bCanKill = true;
break;
}
}
if ($bCanKill) {
$this->AddMenuSeparator($aActions);
$aActions['concurrent_lock_unlock'] = array('label' => Dict::S('UI:Menu:KillConcurrentLock'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=kill_lock&class={$sClass}&id={$id}{$sContext}");
}
}
/*
$this->AddMenuSeparator($aActions);
// Static menus: Email this page & CSV Export
$sUrl = ApplicationContext::MakeObjectUrl($sClass, $id);
$aActions['UI:Menu:EMail'] = array ('label' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=".urlencode($oObj->GetRawName())."&body=".urlencode($sUrl));
$aActions['UI:Menu:CSVExport'] = array ('label' => Dict::S('UI:Menu:CSVExport'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=search&filter=".urlencode($sFilter)."&format=csv{$sContext}");
// The style tells us whether the menu is displayed on a list of one object, or on the details of the given object
if ($this->m_sStyle == 'list')
{
// Actions specific to the list
$sOQL = addslashes($sFilterDesc);
$aActions['UI:Menu:AddToDashboard'] = array ('label' => Dict::S('UI:Menu:AddToDashboard'), 'url' => "#", 'onclick' => "return DashletCreationDlg('$sOQL')");
}
*/
示例5: array
$oFilter = DBObjectSearch::FromOQL('SELECT Organization');
$sSelectionMode = utils::ReadParam('selectionMode', '');
$aExceptions = utils::ReadParam('storedSelection', array());
if ($sSelectionMode == 'negative' && count($aExceptions) == 0) {
// All Orgs selected
appUserPreferences::SetPref('favorite_orgs', null);
} else {
// Some organizations selected... store them
$aSelectOrgs = utils::ReadMultipleSelection($oFilter);
appUserPreferences::SetPref('favorite_orgs', $aSelectOrgs);
}
DisplayPreferences($oPage);
break;
case 'apply_language':
$sLangCode = utils::ReadParam('language', 'EN US');
$oUser = UserRights::GetUserObject();
$oUser->Set('language', $sLangCode);
$oUser->DBUpdate();
// Redirect to force a reload/display of the page with the new language
$oAppContext = new ApplicationContext();
$sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/preferences.php?' . $oAppContext->GetForLink();
$oPage->add_header('Location: ' . $sURL);
break;
case 'apply_others':
$iDefaultPageSize = (int) utils::ReadParam('default_page_size', -1);
if ($iDefaultPageSize > 0) {
appUserPreferences::SetPref('default_page_size', $iDefaultPageSize);
}
DisplayPreferences($oPage);
break;
case 'display':