当前位置: 首页>>代码示例>>PHP>>正文


PHP UserRights::GetUser方法代码示例

本文整理汇总了PHP中UserRights::GetUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::GetUser方法的具体用法?PHP UserRights::GetUser怎么用?PHP UserRights::GetUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserRights的用法示例。


在下文中一共展示了UserRights::GetUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: IsEnabled

 public static function IsEnabled()
 {
     if (self::$m_bEnabled_Duration || self::$m_bEnabled_Memory) {
         if (self::$m_sAllowedUser == '*' || UserRights::GetUser() == trim(self::$m_sAllowedUser)) {
             return true;
         }
     }
     return false;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:9,代码来源:kpi.class.inc.php

示例2: DoExecute

 public function DoExecute($oTrigger, $aContextArgs)
 {
     if (MetaModel::IsLogEnabledNotification()) {
         $oLog = new EventNotificationShellExec();
         if ($this->IsBeingTested()) {
             $oLog->Set('message', 'TEST - Executing script (' . $this->Get('script_path') . ')');
         } else {
             $oLog->Set('message', 'Executing script');
         }
         $oLog->Set('userinfo', UserRights::GetUser());
         $oLog->Set('trigger_id', $oTrigger->GetKey());
         $oLog->Set('action_id', $this->GetKey());
         $oLog->Set('object_id', $aContextArgs['this->object()']->GetKey());
         // Must be inserted now so that it gets a valid id that will make the link
         // between an eventual asynchronous task (queued) and the log
         $oLog->DBInsertNoReload();
     } else {
         $oLog = null;
     }
     try {
         $sRes = $this->_DoExecute($oTrigger, $aContextArgs, $oLog);
         if ($this->IsBeingTested()) {
             $sPrefix = 'TEST (' . $this->Get('script_path') . ') - ';
         } else {
             $sPrefix = '';
         }
         $oLog->Set('message', $sPrefix . $sRes);
     } catch (Exception $e) {
         if ($oLog) {
             $oLog->Set('message', 'Error: ' . $e->getMessage());
         }
     }
     if ($oLog) {
         $oLog->DBUpdate();
     }
 }
开发者ID:itop-itsm-ru,项目名称:action-shell-exec,代码行数:36,代码来源:main.action-shell-exec.php

示例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;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:loginwebpage.class.inc.php

示例4: LogUsage

 /**
  * Helper to log a service delivery
  *
  * @param string sVerb
  * @param array aArgs
  * @param WebServiceResult oRes
  *
  */
 protected function LogUsage($sVerb, $oRes)
 {
     if (!MetaModel::IsLogEnabledWebService()) {
         return;
     }
     $oLog = new EventWebService();
     if ($oRes->IsOk()) {
         $oLog->Set('message', $sVerb . ' was successfully invoked');
     } else {
         $oLog->Set('message', $sVerb . ' returned errors');
     }
     $oLog->Set('userinfo', UserRights::GetUser());
     $oLog->Set('verb', $sVerb);
     $oLog->Set('result', $oRes->IsOk());
     $this->TrimAndSetValue($oLog, 'log_info', (string) $oRes->GetInfoAsText());
     $this->TrimAndSetValue($oLog, 'log_warning', (string) $oRes->GetWarningsAsText());
     $this->TrimAndSetValue($oLog, 'log_error', (string) $oRes->GetErrorsAsText());
     $this->TrimAndSetValue($oLog, 'data', (string) $oRes->GetReturnedDataAsText());
     $oLog->DBInsertNoReload();
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:28,代码来源:webservices.class.inc.php

示例5: GetUserPrefix

 protected static function GetUserPrefix()
 {
     $sPrefix = substr(UserRights::GetUser(), 0, 10);
     $sPrefix = preg_replace('/[^a-zA-Z0-9-_]/', '_', $sPrefix);
     return $sPrefix . '-';
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:6,代码来源:transaction.class.inc.php

示例6: output


//.........这里部分代码省略.........
        if (count($this->a_styles) > 0) {
            $sHtml .= "<style>\n";
            foreach ($this->a_styles as $s_style) {
                $sHtml .= "{$s_style}\n";
            }
            $sHtml .= "</style>\n";
        }
        $sHtml .= "<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"iTop\" href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/opensearch.xml.php\" />\n";
        $sHtml .= "<link rel=\"shortcut icon\" href=\"" . utils::GetAbsoluteUrlAppRoot() . "images/favicon.ico\" />\n";
        $sHtml .= "</head>\n";
        $sHtml .= "<body>\n";
        // Render the revision number
        if (ITOP_REVISION == '$WCREV$') {
            // This is NOT a version built using the buil system, just display the main version
            $sVersionString = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
        } else {
            // This is a build made from SVN, let display the full information
            $sVersionString = Dict::Format('UI:iTopVersion:Long', ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
        }
        // Render the text of the global search form
        $sText = htmlentities(utils::ReadParam('text', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8');
        $sOnClick = "";
        if (empty($sText)) {
            // if no search text is supplied then
            // 1) the search text is filled with "your search"
            // 2) clicking on it will erase it
            $sText = Dict::S("UI:YourSearch");
            $sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
        }
        // Render the tabs in the page (if any)
        $this->s_content = $this->m_oTabs->RenderIntoContent($this->s_content);
        if ($this->GetOutputFormat() == 'html') {
            $oAppContext = new ApplicationContext();
            $sUserName = UserRights::GetUser();
            $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
            if (UserRights::IsAdministrator()) {
                $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
            } else {
                $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
            }
            $sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
            $sLogOffMenu .= "<li><span>{$sLogonMessage}</span></li>\n";
            $aActions = array();
            $oPrefs = new URLPopupMenuItem('UI:Preferences', Dict::S('UI:Preferences'), utils::GetAbsoluteUrlAppRoot() . "pages/preferences.php?" . $oAppContext->GetForLink());
            $aActions[$oPrefs->GetUID()] = $oPrefs->GetMenuItem();
            if (utils::CanLogOff()) {
                $oLogOff = new URLPopupMenuItem('UI:LogOffMenu', Dict::S('UI:LogOffMenu'), utils::GetAbsoluteUrlAppRoot() . 'pages/logoff.php?operation=do_logoff');
                $aActions[$oLogOff->GetUID()] = $oLogOff->GetMenuItem();
            }
            if (UserRights::CanChangePassword()) {
                $oChangePwd = new URLPopupMenuItem('UI:ChangePwdMenu', Dict::S('UI:ChangePwdMenu'), utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?loginop=change_pwd');
                $aActions[$oChangePwd->GetUID()] = $oChangePwd->GetMenuItem();
            }
            utils::GetPopupMenuItems($this, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aActions);
            $oAbout = new JSPopupMenuItem('UI:AboutBox', Dict::S('UI:AboutBox'), 'return ShowAboutBox();');
            $aActions[$oAbout->GetUID()] = $oAbout->GetMenuItem();
            $sLogOffMenu .= $this->RenderPopupMenuItems($aActions);
            $sRestrictions = '';
            if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) {
                if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) {
                    $sRestrictions = Dict::S('UI:AccessRO-All');
                }
            } elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) {
                $sRestrictions = Dict::S('UI:AccessRO-Users');
            }
            $sApplicationBanner = '';
开发者ID:henryavila,项目名称:itop,代码行数:67,代码来源:itopwebpage.class.inc.php

示例7: json_encode

// Output the results
//
$sResponse = json_encode($oResult);
$oP->add_header('Access-Control-Allow-Origin: *');
$sCallback = utils::ReadParam('callback', null);
if ($sCallback == null) {
    $oP->SetContentType('application/json');
    $oP->add($sResponse);
} else {
    $oP->SetContentType('application/javascript');
    $oP->add($sCallback . '(' . $sResponse . ')');
}
$oP->Output();
// Log usage
//
if (MetaModel::GetConfig()->Get('log_rest_service')) {
    $oLog = new EventRestService();
    $oLog->SetTrim('userinfo', UserRights::GetUser());
    $oLog->Set('version', $sVersion);
    $oLog->Set('operation', $sOperation);
    $oLog->SetTrim('json_input', $sJsonString);
    $oLog->Set('provider', $sProvider);
    $sMessage = $oResult->message;
    if (empty($oResult->message)) {
        $sMessage = 'Ok';
    }
    $oLog->SetTrim('message', $sMessage);
    $oLog->Set('code', $oResult->code);
    $oLog->SetTrim('json_output', $sResponse);
    $oLog->DBInsertNoReload();
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:rest.php

示例8: DoExecute

 protected function DoExecute()
 {
     $sUser = 'Romain';
     echo "<p>Totor: " . (UserRights::CheckCredentials('Totor', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>Romain: " . (UserRights::CheckCredentials('Romain', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: " . UserRights::GetUser() . "</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     echo "<p>Denis (impersonate) : " . (UserRights::Impersonate('Denis', 'tutu') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: " . UserRights::GetUser() . "</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT bizOrganization"));
     echo "<p>IsActionAllowed..." . (UserRights::IsActionAllowed('bizOrganization', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsStimulusAllowed..." . (UserRights::IsStimulusAllowed('bizOrganization', 'myStimulus', $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsActionAllowedOnAttribute..." . (UserRights::IsActionAllowedOnAttribute('bizOrganization', 'myattribute', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     return true;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:16,代码来源:testlist.inc.php

示例9: DeleteConnectedNetworkDevice

 protected function DeleteConnectedNetworkDevice()
 {
     $iNetworkDeviceID = $this->Get('networkdevice_id');
     $iDeviceID = $this->Get('connectableci_id');
     $oDevice = MetaModel::GetObject('ConnectableCI', $this->Get('connectableci_id'));
     $sOQL = "SELECT  lnkConnectableCIToNetworkDevice WHERE connectableci_id = :device AND networkdevice_id = :network AND network_port = :nwport AND device_port = :devport";
     $oConnectionSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('network' => $this->Get('connectableci_id'), 'device' => $this->Get('networkdevice_id'), 'devport' => $this->Get('network_port'), 'nwport' => $this->Get('device_port')));
     $iAlreadyExist = $oConnectionSet->count();
     if (get_class($oDevice) == 'NetworkDevice' && $iAlreadyExist != 0) {
         $oMyChange = MetaModel::NewObject("CMDBChange");
         $oMyChange->Set("date", time());
         if (UserRights::IsImpersonated()) {
             $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUser(), UserRights::GetUser());
         } else {
             $sUserString = UserRights::GetUser();
         }
         $oMyChange->Set("userinfo", $sUserString);
         $iChangeId = $oMyChange->DBInsert();
         $oConnection = $oConnectionSet->Fetch();
         $oConnection->DBDeleteTracked($oMyChange);
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:22,代码来源:model.itop-config-mgmt.php


注:本文中的UserRights::GetUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。