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


PHP UserRights::GetUserFriendlyName方法代码示例

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


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

示例1: GetCurrentUserName

 public static function GetCurrentUserName()
 {
     if (UserRights::IsImpersonated()) {
         $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUserFriendlyName(), UserRights::GetUserFriendlyName());
     } else {
         $sUserString = UserRights::GetUserFriendlyName();
     }
     return $sUserString;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:9,代码来源:cmdbchange.class.inc.php

示例2: DBObjectSearch

 $oSearch = new DBObjectSearch($sClassName);
 $oSearch->AddCondition('id', 0, '=');
 // Make sure we create an empty set
 $oSet = new CMDBObjectSet($oSearch);
 $sResult = cmdbAbstractObject::GetSetAsCSV($oSet, array('showMandatoryFields' => true));
 $sClassDisplayName = MetaModel::GetName($sClassName);
 $sDisposition = utils::ReadParam('disposition', 'inline');
 if ($sDisposition == 'attachment') {
     switch ($sFormat) {
         case 'xlsx':
             $oPage = new ajax_page("");
             $oPage->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
             $oPage->SetContentDisposition('attachment', $sClassDisplayName . '.xlsx');
             require_once APPROOT . '/application/excelexporter.class.inc.php';
             $writer = new XLSXWriter();
             $writer->setAuthor(UserRights::GetUserFriendlyName());
             $aHeaders = array(0 => explode(',', $sResult));
             // comma is the default separator
             $writer->writeSheet($aHeaders, $sClassDisplayName, array());
             $oPage->add($writer->writeToString());
             break;
         case 'csv':
         default:
             $oPage = new CSVPage("");
             $oPage->add_header("Content-type: text/csv; charset=utf-8");
             $oPage->add_header("Content-disposition: attachment; filename=\"{$sClassDisplayName}.csv\"");
             $oPage->no_cache();
             $oPage->add($sResult);
     }
 } else {
     $oPage = new ajax_page("");
开发者ID:henryavila,项目名称:itop,代码行数:31,代码来源:ajax.csvimport.php

示例3: AddLogEntryFromJSON

 public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
 {
     $sText = isset($oJson->message) ? $oJson->message : '';
     if (isset($oJson->user_id)) {
         if (!UserRights::IsAdministrator()) {
             throw new Exception("Only administrators can set the user id", RestResult::UNAUTHORIZED);
         }
         if ($bCheckUserId && $oJson->user_id != 0) {
             try {
                 $oUser = RestUtils::FindObjectFromKey('User', $oJson->user_id);
             } catch (Exception $e) {
                 throw new Exception('user_id: ' . $e->getMessage(), $e->getCode());
             }
             $iUserId = $oUser->GetKey();
             $sOnBehalfOf = $oUser->GetFriendlyName();
         } else {
             $iUserId = $oJson->user_id;
             $sOnBehalfOf = $oJson->user_login;
         }
     } else {
         $iUserId = UserRights::GetUserId();
         $sOnBehalfOf = UserRights::GetUserFriendlyName();
     }
     if (isset($oJson->date)) {
         $oDate = new DateTime($oJson->date);
         $iDate = (int) $oDate->format('U');
     } else {
         $iDate = time();
     }
     $sDate = date(Dict::S('UI:CaseLog:DateFormat'), $iDate);
     $sSeparator = sprintf(CASELOG_SEPARATOR, $sDate, $sOnBehalfOf, $iUserId);
     $iSepLength = strlen($sSeparator);
     $iTextlength = strlen($sText);
     $this->m_sLog = $sSeparator . $sText . $this->m_sLog;
     // Latest entry printed first
     $this->m_aIndex[] = array('user_name' => $sOnBehalfOf, 'user_id' => $iUserId, 'date' => $iDate, 'text_length' => $iTextlength, 'separator_length' => $iSepLength);
     $this->m_bModified = true;
 }
开发者ID:henryavila,项目名称:itop,代码行数:38,代码来源:ormcaselog.class.inc.php

示例4: explode

 ApplicationContext::SetUrlMakerClass('MyPortalURLMaker');
 $aClasses = explode(',', MetaModel::GetConfig()->Get('portal_tickets'));
 $sMainClass = trim(reset($aClasses));
 if (!class_exists($sMainClass)) {
     $oP = new WebPage(Dict::S('Portal:Title'));
     $oP->p(dict::Format('Portal:NoRequestMgmt', UserRights::GetUserFriendlyName()));
 } else {
     $oUserOrg = GetUserOrg();
     $sCode = $oUserOrg->Get('code');
     $sAlternateStylesheet = '';
     if (@file_exists("./{$sCode}/portal.css")) {
         $sAlternateStylesheet = "{$sCode}";
     }
     $oP = new PortalWebPage(Dict::S('Portal:Title'), $sAlternateStylesheet);
     $oP->EnableDisconnectButton(utils::CanLogOff());
     $oP->SetWelcomeMessage(Dict::Format('Portal:WelcomeUserOrg', UserRights::GetUserFriendlyName(), $oUserOrg->GetName()));
     if (is_object($oUserOrg)) {
         switch ($sOperation) {
             case 'show_closed':
                 $oP->set_title(Dict::S('Portal:ShowClosed'));
                 DisplayMainMenu($oP);
                 ShowClosedTickets($oP);
                 break;
             case 'create_request':
                 $oP->set_title(Dict::S('Portal:CreateNewRequest'));
                 DisplayMainMenu($oP);
                 if (!MetaModel::DBIsReadOnly()) {
                     CreateRequest($oP, $oUserOrg);
                 }
                 break;
             case 'details':
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:index.php

示例5: GetFooter

 public function GetFooter()
 {
     $hFile = @fopen($this->aStatusInfo['tmp_file'], 'rb');
     if ($hFile === false) {
         throw new Exception('ExcelBulkExport: Failed to open temporary data file: "' . $this->aStatusInfo['tmp_file'] . '" for reading.');
     }
     $sHeaders = fgets($hFile);
     $aHeaders = json_decode($sHeaders, true);
     $aData = array();
     while ($sLine = fgets($hFile)) {
         $aRow = json_decode($sLine);
         $aData[] = $aRow;
     }
     fclose($hFile);
     $fStartExcel = microtime(true);
     $writer = new XLSXWriter();
     $writer->setAuthor(UserRights::GetUserFriendlyName());
     $aHeaderTypes = array();
     $aHeaderNames = array();
     foreach ($aHeaders as $Header) {
         $aHeaderNames[] = $Header['label'];
         $aHeaderTypes[] = $Header['type'];
     }
     $writer->writeSheet($aData, 'Sheet1', $aHeaderTypes, $aHeaderNames);
     $fExcelTime = microtime(true) - $fStartExcel;
     //$this->aStatistics['excel_build_duration'] = $fExcelTime;
     $fTime = microtime(true);
     $data = $writer->writeToString();
     $fExcelSaveTime = microtime(true) - $fTime;
     //$this->aStatistics['excel_write_duration'] = $fExcelSaveTime;
     @unlink($this->aStatusInfo['tmp_file']);
     return $data;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:33,代码来源:excelbulkexport.class.inc.php

示例6: SetCurrentUser

 /**
  * Lifecycle action: Set the current logged in user for the given attribute
  */
 public function SetCurrentUser($sAttCode)
 {
     $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
     if ($oAttDef instanceof AttributeString) {
         // Note: the user friendly name is the contact friendly name if a contact is attached to the logged in user
         $this->Set($sAttCode, UserRights::GetUserFriendlyName());
     } else {
         if ($oAttDef->IsExternalKey()) {
             if ($oAttDef->GetTargetClass() != 'User') {
                 throw new Exception("SetCurrentUser: the attribute {$sAttCode} must be an external key to 'User', found '" . $oAttDef->GetTargetClass() . "'");
             }
         }
         $this->Set($sAttCode, UserRights::GetUserId());
     }
     return true;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:19,代码来源:dbobject.class.php

示例7: Run

 public function Run()
 {
     $sCode = 'error';
     $iPercentage = 100;
     $sMessage = Dict::Format('ExcelExporter:ErrorUnexpected_State', $this->sState);
     $fTime = microtime(true);
     try {
         switch ($this->sState) {
             case 'new':
                 $oIDSet = new DBObjectSet($this->oSearch);
                 $oIDSet->OptimizeColumnLoad(array('id'));
                 $this->aObjectsIDs = array();
                 while ($oObj = $oIDSet->Fetch()) {
                     $this->aObjectsIDs[] = $oObj->GetKey();
                 }
                 $sCode = 'retrieving-data';
                 $iPercentage = 5;
                 $sMessage = Dict::S('ExcelExporter:RetrievingData');
                 $this->iPosition = 0;
                 $this->aStatistics['objects_count'] = count($this->aObjectsIDs);
                 $this->aStatistics['data_retrieval_duration'] += microtime(true) - $fTime;
                 // The first line of the file is the "headers" specifying the label and the type of each column
                 $this->GetFieldsList($oIDSet, $this->bAdvancedMode);
                 $sRow = json_encode($this->aTableHeaders);
                 $hFile = @fopen($this->GetDataFile(), 'ab');
                 if ($hFile === false) {
                     throw new Exception('ExcelExporter: Failed to open temporary data file: "' . $this->GetDataFile() . '" for writing.');
                 }
                 fwrite($hFile, $sRow . "\n");
                 fclose($hFile);
                 // Next state
                 $this->sState = 'retrieving-data';
                 break;
             case 'retrieving-data':
                 $oCurrentSearch = clone $this->oSearch;
                 $aIDs = array_slice($this->aObjectsIDs, $this->iPosition, $this->iChunkSize);
                 $oCurrentSearch->AddCondition('id', $aIDs, 'IN');
                 $hFile = @fopen($this->GetDataFile(), 'ab');
                 if ($hFile === false) {
                     throw new Exception('ExcelExporter: Failed to open temporary data file: "' . $this->GetDataFile() . '" for writing.');
                 }
                 $oSet = new DBObjectSet($oCurrentSearch);
                 $this->GetFieldsList($oSet, $this->bAdvancedMode);
                 while ($aObjects = $oSet->FetchAssoc()) {
                     $aRow = array();
                     foreach ($this->aAuthorizedClasses as $sAlias => $sClassName) {
                         $oObj = $aObjects[$sAlias];
                         if ($this->bAdvancedMode) {
                             $aRow[] = $oObj->GetKey();
                         }
                         foreach ($this->aFieldsList[$sAlias] as $sAttCodeEx => $oAttDef) {
                             $value = $oObj->Get($sAttCodeEx);
                             if ($value instanceof ormCaseLog) {
                                 // Extract the case log as text and remove the "===" which make Excel think that the cell contains a formula the next time you edit it!
                                 $sExcelVal = trim(preg_replace('/========== ([^=]+) ============/', '********** $1 ************', $value->GetText()));
                             } else {
                                 $sExcelVal = $oAttDef->GetEditValue($value, $oObj);
                             }
                             $aRow[] = $sExcelVal;
                         }
                     }
                     $sRow = json_encode($aRow);
                     fwrite($hFile, $sRow . "\n");
                 }
                 fclose($hFile);
                 if ($this->iPosition + $this->iChunkSize > count($this->aObjectsIDs)) {
                     // Next state
                     $this->sState = 'building-excel';
                     $sCode = 'building-excel';
                     $iPercentage = 80;
                     $sMessage = Dict::S('ExcelExporter:BuildingExcelFile');
                 } else {
                     $sCode = 'retrieving-data';
                     $this->iPosition += $this->iChunkSize;
                     $iPercentage = 5 + round(75 * ($this->iPosition / count($this->aObjectsIDs)));
                     $sMessage = Dict::S('ExcelExporter:RetrievingData');
                 }
                 break;
             case 'building-excel':
                 $hFile = @fopen($this->GetDataFile(), 'rb');
                 if ($hFile === false) {
                     throw new Exception('ExcelExporter: Failed to open temporary data file: "' . $this->GetDataFile() . '" for reading.');
                 }
                 $sHeaders = fgets($hFile);
                 $aHeaders = json_decode($sHeaders, true);
                 $aData = array();
                 while ($sLine = fgets($hFile)) {
                     $aRow = json_decode($sLine);
                     $aData[] = $aRow;
                 }
                 fclose($hFile);
                 @unlink($this->GetDataFile());
                 $fStartExcel = microtime(true);
                 $writer = new XLSXWriter();
                 $writer->setAuthor(UserRights::GetUserFriendlyName());
                 $writer->writeSheet($aData, 'Sheet1', $aHeaders);
                 $fExcelTime = microtime(true) - $fStartExcel;
                 $this->aStatistics['excel_build_duration'] = $fExcelTime;
                 $fTime = microtime(true);
                 $writer->writeToFile($this->GetExcelFilePath());
//.........这里部分代码省略.........
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:101,代码来源:excelexporter.class.inc.php


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