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


PHP UserRights::IsAdministrator方法代码示例

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


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

示例1: OnMenuCreation

 public static function OnMenuCreation()
 {
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new WebPageMenuNode('ConfigEditor', utils::GetAbsoluteUrlModulesRoot() . 'itop-config/config.php', $oAdminMenu->GetIndex(), 18);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:7,代码来源:main.itop-config.php

示例2: OnMenuCreation

 public static function OnMenuCreation()
 {
     // Add the admin menus
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1, true);
         new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2);
         new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/notifications.php', $oAdminMenu->GetIndex(), 3);
         new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4);
         new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/run_query.php', $oAdminMenu->GetIndex(), 8);
         new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5, true);
         new WebPageMenuNode('ExportMenu', utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php?interactive=1', $oAdminMenu->GetIndex(), 9);
         new WebPageMenuNode('DataModelMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/schema.php', $oAdminMenu->GetIndex(), 10);
         new WebPageMenuNode('UniversalSearchMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:16,代码来源:main.itop-welcome-itil.php

示例3: OnMenuCreation

 public static function OnMenuCreation()
 {
     $oToolsMenu = new MenuGroup('DataAdministration', 70, 'Organization', UR_ACTION_MODIFY, UR_ALLOWED_YES | UR_ALLOWED_DEPENDS);
     new WebPageMenuNode('CSVImportMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/csvimport.php', $oToolsMenu->GetIndex(), 1);
     // Add the admin menus
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1);
         new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2);
         new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/notifications.php', $oAdminMenu->GetIndex(), 3);
         new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4);
         new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/run_query.php', $oAdminMenu->GetIndex(), 8);
         new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5, true);
         new WebPageMenuNode('ExportMenu', utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php', $oAdminMenu->GetIndex(), 9);
         new WebPageMenuNode('DataModelMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/schema.php', $oAdminMenu->GetIndex(), 10);
         new WebPageMenuNode('UniversalSearchMenu', utils::GetAbsoluteUrlAppRoot() . 'pages/UniversalSearch.php', $oAdminMenu->GetIndex(), 11);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:18,代码来源:main.itop-welcome-itil.php

示例4: GetClassesSelect

 /**
  * Helper function to build a select from the list of valid classes for a given action
  * @param string $sName The name of the select in the HTML form
  * @param string $sDefaulfValue The defaut value (i.e the value selected by default)
  * @param integer $iWidthPx The width (in pixels) of the drop-down list
  * @param integer $iActionCode The ActionCode (from UserRights) to check for authorization for the classes
  * @return string The HTML fragment corresponding to the select tag
  */
 function GetClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null)
 {
     $sHtml = "<select id=\"select_{$sName}\" name=\"{$sName}\">";
     $sHtml .= "<option tyle=\"width: " . $iWidthPx . "px;\" title=\"Select the class you want to load\" value=\"\">" . Dict::S('UI:CSVImport:ClassesSelectOne') . "</option>\n";
     $aValidClasses = array();
     $aClassCategories = array('bizmodel');
     if (UserRights::IsAdministrator()) {
         $aClassCategories = array('bizmodel', 'application', 'addon/authentication');
     }
     foreach ($aClassCategories as $sClassCategory) {
         foreach (MetaModel::GetClasses($sClassCategory) as $sClassName) {
             if ((is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode)) && !MetaModel::IsAbstract($sClassName)) {
                 $sSelected = $sClassName == $sDefaultValue ? " selected" : "";
                 $sDescription = MetaModel::GetClassDescription($sClassName);
                 $sDisplayName = MetaModel::GetName($sClassName);
                 $aValidClasses[$sDisplayName] = "<option style=\"width: " . $iWidthPx . "px;\" title=\"{$sDescription}\" value=\"{$sClassName}\"{$sSelected}>{$sDisplayName}</option>";
             }
         }
     }
     ksort($aValidClasses);
     $sHtml .= implode("\n", $aValidClasses);
     $sHtml .= "</select>";
     return $sHtml;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:32,代码来源:csvimport.php

示例5: DisplayBareHeader

 function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
 {
     // Standard Header with name, actions menu and history block
     //
     if (!$oPage->IsPrintableVersion()) {
         // Is there a message for this object ??
         $aMessages = array();
         $aRanks = array();
         if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) {
             $aLockInfo = iTopOwnershipLock::IsLocked(get_class($this), $this->GetKey());
             if ($aLockInfo['locked']) {
                 $aRanks[] = 0;
                 $sName = $aLockInfo['owner']->GetName();
                 if ($aLockInfo['owner']->Get('contactid') != 0) {
                     $sName .= ' (' . $aLockInfo['owner']->Get('contactid_friendlyname') . ')';
                 }
                 $aResult['message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName);
                 $aMessages[] = "<div class=\"header_message message_error\">" . Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName) . "</div>";
             }
         }
         $sMessageKey = get_class($this) . '::' . $this->GetKey();
         if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, $_SESSION['obj_messages'])) {
             foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) {
                 $sMsgClass = 'message_' . $aMessageData['severity'];
                 $aMessages[] = "<div class=\"header_message {$sMsgClass}\">" . $aMessageData['message'] . "</div>";
                 $aRanks[] = $aMessageData['rank'];
             }
             unset($_SESSION['obj_messages'][$sMessageKey]);
         }
         array_multisort($aRanks, $aMessages);
         foreach ($aMessages as $sMessage) {
             $oPage->add($sMessage);
         }
     }
     if (!$oPage->IsPrintableVersion()) {
         // action menu
         $oSingletonFilter = new DBObjectSearch(get_class($this));
         $oSingletonFilter->AddCondition('id', $this->GetKey(), '=');
         $oBlock = new MenuBlock($oSingletonFilter, 'details', false);
         $oBlock->Display($oPage, -1);
     }
     $oPage->add("<div class=\"page_header\"><h1>" . $this->GetIcon() . "&nbsp;\n");
     // Master data sources
     $bSynchronized = false;
     $aIcons = array();
     if (!$oPage->IsPrintableVersion()) {
         $oCreatorTask = null;
         $bCanBeDeletedByTask = false;
         $bCanBeDeletedByUser = true;
         $aMasterSources = array();
         $aSyncData = $this->GetSynchroData();
         if (count($aSyncData) > 0) {
             $bSynchronized = true;
             foreach ($aSyncData as $iSourceId => $aSourceData) {
                 $oDataSource = $aSourceData['source'];
                 $oReplica = reset($aSourceData['replica']);
                 // Take the first one!
                 $sApplicationURL = $oDataSource->GetApplicationUrl($this, $oReplica);
                 $sLink = $oDataSource->GetName();
                 if (!empty($sApplicationURL)) {
                     $sLink = "<a href=\"{$sApplicationURL}\" target=\"_blank\">" . $oDataSource->GetName() . "</a>";
                 }
                 if ($oReplica->Get('status_dest_creator') == 1) {
                     $oCreatorTask = $oDataSource;
                     $bCreatedByTask = true;
                 } else {
                     $bCreatedByTask = false;
                 }
                 if ($bCreatedByTask) {
                     $sDeletePolicy = $oDataSource->Get('delete_policy');
                     if ($sDeletePolicy == 'delete' || $sDeletePolicy == 'update_then_delete') {
                         $bCanBeDeletedByTask = true;
                     }
                     $sUserDeletePolicy = $oDataSource->Get('user_delete_policy');
                     if ($sUserDeletePolicy == 'nobody') {
                         $bCanBeDeletedByUser = false;
                     } elseif ($sUserDeletePolicy == 'administrators' && !UserRights::IsAdministrator()) {
                         $bCanBeDeletedByUser = false;
                     } else {
                     }
                 }
                 $aMasterSources[$iSourceId]['datasource'] = $oDataSource;
                 $aMasterSources[$iSourceId]['url'] = $sLink;
                 $aMasterSources[$iSourceId]['last_synchro'] = $oReplica->Get('status_last_seen');
             }
             if (is_object($oCreatorTask)) {
                 $sTaskUrl = $aMasterSources[$oCreatorTask->GetKey()]['url'];
                 if (!$bCanBeDeletedByUser) {
                     $sTip = "<p>" . Dict::Format('Core:Synchro:TheObjectCannotBeDeletedByUser_Source', $sTaskUrl) . "</p>";
                 } else {
                     $sTip = "<p>" . Dict::Format('Core:Synchro:TheObjectWasCreatedBy_Source', $sTaskUrl) . "</p>";
                 }
                 if ($bCanBeDeletedByTask) {
                     $sTip .= "<p>" . Dict::Format('Core:Synchro:TheObjectCanBeDeletedBy_Source', $sTaskUrl) . "</p>";
                 }
             } else {
                 $sTip = "<p>" . Dict::S('Core:Synchro:ThisObjectIsSynchronized') . "</p>";
             }
             $sTip .= "<p><b>" . Dict::S('Core:Synchro:ListOfDataSources') . "</b></p>";
             foreach ($aMasterSources as $aStruct) {
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例6: DoLoginEx

 /**
  * Check if the user is already authentified, if yes, then performs some additional validations to redirect towards the desired "portal"
  * @param string|null $sRequestedPortalId The requested "portal" interface, null for any
  * @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  */
 static function DoLoginEx($sRequestedPortalId = null, $bMustBeAdmin = false, $iOnExit = self::EXIT_PROMPT)
 {
     $operation = utils::ReadParam('loginop', '');
     $sMessage = self::HandleOperations($operation);
     // May exit directly
     $iRet = self::Login($iOnExit);
     if ($iRet == self::EXIT_CODE_OK) {
         if ($bMustBeAdmin && !UserRights::IsAdministrator()) {
             if ($iOnExit == self::EXIT_RETURN) {
                 return self::EXIT_CODE_MUSTBEADMIN;
             } else {
                 require_once APPROOT . '/setup/setuppage.class.inc.php';
                 $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
                 $oP->add("<h1>" . Dict::S('UI:Login:Error:AccessAdmin') . "</h1>\n");
                 $oP->p("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/logoff.php\">" . Dict::S('UI:LogOffMenu') . "</a>");
                 $oP->output();
                 exit;
             }
         }
         $iRet = call_user_func(array(self::$sHandlerClass, 'ChangeLocation'), $sRequestedPortalId, $iOnExit);
     }
     if ($iOnExit == self::EXIT_RETURN) {
         return $iRet;
     } else {
         return $sMessage;
     }
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:33,代码来源:loginwebpage.class.inc.php

示例7: output

    /**
     * Outputs (via some echo) the complete HTML page by assembling all its elements
     */
    public function output()
    {
        $sAbsURLAppRoot = addslashes($this->m_sRootUrl);
        //$this->set_base($this->m_sRootUrl.'pages/');
        $sForm = $this->GetSiloSelectionForm();
        $this->DisplayMenu();
        // Compute the menu
        // Call the extensions to add content to the page, so that they can also add styles or scripts
        $sBannerExtraHtml = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sBannerExtraHtml .= $oExtensionInstance->GetBannerHtml($this);
        }
        $sNorthPane = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sNorthPane .= $oExtensionInstance->GetNorthPaneHtml($this);
        }
        if (UserRights::IsAdministrator() && ExecutionKPI::IsEnabled()) {
            $sNorthPane .= '<div id="admin-banner"><span style="padding:5px;">' . ExecutionKPI::GetDescription() . '<span></div>';
        }
        //$sSouthPane = '<p>Peak memory Usage: '.sprintf('%.3f MB', memory_get_peak_usage(true) / (1024*1024)).'</p>';
        $sSouthPane = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sSouthPane .= $oExtensionInstance->GetSouthPaneHtml($this);
        }
        // Put here the 'ready scripts' that must be executed after all others
        $aMultiselectOptions = array('header' => true, 'checkAllText' => Dict::S('UI:SearchValue:CheckAll'), 'uncheckAllText' => Dict::S('UI:SearchValue:UncheckAll'), 'noneSelectedText' => Dict::S('UI:SearchValue:Any'), 'selectedText' => Dict::S('UI:SearchValue:NbSelected'), 'selectedList' => 1);
        $sJSMultiselectOptions = json_encode($aMultiselectOptions);
        $this->add_ready_script(<<<EOF
\t\t// Since the event is only triggered when the hash changes, we need to trigger
\t\t// the event now, to handle the hash the page may have loaded with.
\t\t\$(window).trigger( 'hashchange' );
\t\t
\t\t// Some table are sort-able, some are not, let's fix this
\t\t\$('table.listResults').each( function() { FixTableSorter(\$(this)); } );
\t\t
\t\t\$('.multiselect').multiselect({$sJSMultiselectOptions});

\t\tFixSearchFormsDisposition();

EOF
);
        if ($this->GetOutputFormat() == 'html') {
            foreach ($this->a_headers as $s_header) {
                header($s_header);
            }
        }
        $s_captured_output = $this->ob_get_clean_safe();
        $sHtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
        $sHtml .= "<html>\n";
        $sHtml .= "<head>\n";
        // Make sure that Internet Explorer renders the page using its latest/highest/greatest standards !
        $sHtml .= "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n";
        $sHtml .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
        $sHtml .= "<title>" . htmlentities($this->s_title, ENT_QUOTES, 'UTF-8') . "</title>\n";
        $sHtml .= $this->get_base_tag();
        // Stylesheets MUST be loaded before any scripts otherwise
        // jQuery scripts may face some spurious problems (like failing on a 'reload')
        foreach ($this->a_linked_stylesheets as $a_stylesheet) {
            if ($a_stylesheet['condition'] != "") {
                $sHtml .= "<!--[if {$a_stylesheet['condition']}]>\n";
            }
            $sHtml .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$a_stylesheet['link']}\" />\n";
            if ($a_stylesheet['condition'] != "") {
                $sHtml .= "<![endif]-->\n";
            }
        }
        // special stylesheet for printing, hides the navigation gadgets
        $sHtml .= "<link rel=\"stylesheet\" media=\"print\" type=\"text/css\" href=\"../css/print.css\" />\n";
        if ($this->GetOutputFormat() == 'html') {
            $sHtml .= $this->output_dict_entries(true);
            // before any script so that they can benefit from the translations
            foreach ($this->a_linked_scripts as $s_script) {
                // Make sure that the URL to the script contains the application's version number
                // so that the new script do NOT get reloaded from the cache when the application is upgraded
                if (strpos($s_script, '?') === false) {
                    $s_script .= "?itopversion=" . ITOP_VERSION;
                } else {
                    $s_script .= "&itopversion=" . ITOP_VERSION;
                }
                $sHtml .= "<script type=\"text/javascript\" src=\"{$s_script}\"></script>\n";
            }
            $this->add_script("var iPaneVisWatchDog  = window.setTimeout('FixPaneVis()',5000);\n\$(document).ready(function() {\n{$this->m_sInitScript};\nwindow.setTimeout('onDelayedReady()',10)\n});");
            if (count($this->m_aReadyScripts) > 0) {
                $this->add_script("\nonDelayedReady = function() {\n" . implode("\n", $this->m_aReadyScripts) . "\n}\n");
            }
            if (count($this->a_scripts) > 0) {
                $sHtml .= "<script type=\"text/javascript\">\n";
                foreach ($this->a_scripts as $s_script) {
                    $sHtml .= "{$s_script}\n";
                }
                $sHtml .= "</script>\n";
            }
        }
        if (count($this->a_styles) > 0) {
            $sHtml .= "<style>\n";
            foreach ($this->a_styles as $s_style) {
                $sHtml .= "{$s_style}\n";
//.........这里部分代码省略.........
开发者ID:henryavila,项目名称:itop,代码行数:101,代码来源:itopwebpage.class.inc.php

示例8: DoShowGrantSumary

 function DoShowGrantSumary($oPage, $sClassCategory)
 {
     if (UserRights::IsAdministrator($this)) {
         // Looks dirty, but ok that's THE ONE
         $oPage->p(Dict::S('UI:UserManagement:AdminProfile+'));
         return;
     }
     $oKPI = new ExecutionKPI();
     $aDisplayData = array();
     foreach (MetaModel::GetClasses($sClassCategory) as $sClass) {
         $aClassStimuli = MetaModel::EnumStimuli($sClass);
         if (count($aClassStimuli) > 0) {
             $aStimuli = array();
             foreach ($aClassStimuli as $sStimulusCode => $oStimulus) {
                 if (UserRights::IsStimulusAllowed($sClass, $sStimulusCode, null, $this)) {
                     $aStimuli[] = '<span title="' . $sStimulusCode . ': ' . htmlentities($oStimulus->GetDescription(), ENT_QUOTES, 'UTF-8') . '">' . htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8') . '</span>';
                 }
             }
             $sStimuli = implode(', ', $aStimuli);
         } else {
             $sStimuli = '<em title="' . Dict::S('UI:UserManagement:NoLifeCycleApplicable+') . '">' . Dict::S('UI:UserManagement:NoLifeCycleApplicable') . '</em>';
         }
         $aDisplayData[] = array('class' => MetaModel::GetName($sClass), 'read' => $this->GetGrantAsHtml($sClass, UR_ACTION_READ), 'bulkread' => $this->GetGrantAsHtml($sClass, UR_ACTION_BULK_READ), 'write' => $this->GetGrantAsHtml($sClass, UR_ACTION_MODIFY), 'bulkwrite' => $this->GetGrantAsHtml($sClass, UR_ACTION_BULK_MODIFY), 'stimuli' => $sStimuli);
     }
     $oKPI->ComputeAndReport('Computation of user rights');
     $aDisplayConfig = array();
     $aDisplayConfig['class'] = array('label' => Dict::S('UI:UserManagement:Class'), 'description' => Dict::S('UI:UserManagement:Class+'));
     $aDisplayConfig['read'] = array('label' => Dict::S('UI:UserManagement:Action:Read'), 'description' => Dict::S('UI:UserManagement:Action:Read+'));
     $aDisplayConfig['bulkread'] = array('label' => Dict::S('UI:UserManagement:Action:BulkRead'), 'description' => Dict::S('UI:UserManagement:Action:BulkRead+'));
     $aDisplayConfig['write'] = array('label' => Dict::S('UI:UserManagement:Action:Modify'), 'description' => Dict::S('UI:UserManagement:Action:Modify+'));
     $aDisplayConfig['bulkwrite'] = array('label' => Dict::S('UI:UserManagement:Action:BulkModify'), 'description' => Dict::S('UI:UserManagement:Action:BulkModify+'));
     $aDisplayConfig['stimuli'] = array('label' => Dict::S('UI:UserManagement:Action:Stimuli'), 'description' => Dict::S('UI:UserManagement:Action:Stimuli+'));
     $oPage->table($aDisplayConfig, $aDisplayData);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:34,代码来源:userrights.class.inc.php

示例9: PrepareProcessing

 /**
  * Prepare structures in memory, to speedup the processing of a given replica
  */
 public function PrepareProcessing($bFirstPass = true)
 {
     if ($this->m_oDataSource->Get('status') == 'obsolete') {
         throw new SynchroExceptionNotStarted(Dict::S('Core:SyncDataSourceObsolete'));
     }
     if (!UserRights::IsAdministrator() && $this->m_oDataSource->Get('user_id') != UserRights::GetUserId()) {
         throw new SynchroExceptionNotStarted(Dict::S('Core:SyncDataSourceAccessRestriction'));
     }
     // Get the list of SQL columns
     $sClass = $this->m_oDataSource->GetTargetClass();
     $aAttCodesExpected = array();
     $aAttCodesToReconcile = array();
     $aAttCodesToUpdate = array();
     $sSelectAtt = "SELECT SynchroAttribute WHERE sync_source_id = :source_id AND (update = 1 OR reconcile = 1)";
     $oSetAtt = new DBObjectSet(DBObjectSearch::FromOQL($sSelectAtt), array(), array('source_id' => $this->m_oDataSource->GetKey()));
     while ($oSyncAtt = $oSetAtt->Fetch()) {
         if ($oSyncAtt->Get('update')) {
             $aAttCodesToUpdate[$oSyncAtt->Get('attcode')] = $oSyncAtt;
         }
         if ($oSyncAtt->Get('reconcile')) {
             $aAttCodesToReconcile[$oSyncAtt->Get('attcode')] = $oSyncAtt;
         }
         $aAttCodesExpected[$oSyncAtt->Get('attcode')] = $oSyncAtt;
     }
     $aColumns = $this->m_oDataSource->GetSQLColumns(array_keys($aAttCodesExpected));
     $aExtDataFields = array_keys($aColumns);
     $aExtDataFields[] = 'primary_key';
     $this->m_aExtDataSpec = array('table' => $this->m_oDataSource->GetDataTable(), 'join_key' => 'id', 'fields' => $aExtDataFields);
     // Get the list of attributes, determine reconciliation keys and update targets
     //
     if ($this->m_oDataSource->Get('reconciliation_policy') == 'use_attributes') {
         $this->m_aReconciliationKeys = $aAttCodesToReconcile;
     } elseif ($this->m_oDataSource->Get('reconciliation_policy') == 'use_primary_key') {
         // Override the settings made at the attribute level !
         $this->m_aReconciliationKeys = array("primary_key" => null);
     }
     if ($bFirstPass) {
         $this->m_oStatLog->AddTrace("Update of: {" . implode(', ', array_keys($aAttCodesToUpdate)) . "}");
         $this->m_oStatLog->AddTrace("Reconciliation on: {" . implode(', ', array_keys($this->m_aReconciliationKeys)) . "}");
     }
     if (count($aAttCodesToUpdate) == 0) {
         $this->m_oStatLog->AddTrace("No attribute to update");
         throw new SynchroExceptionNotStarted('There is no attribute to update');
     }
     if (count($this->m_aReconciliationKeys) == 0) {
         $this->m_oStatLog->AddTrace("No attribute for reconciliation");
         throw new SynchroExceptionNotStarted('No attribute for reconciliation');
     }
     $this->m_aAttributes = array();
     foreach ($aAttCodesToUpdate as $sAttCode => $oSyncAtt) {
         $oAttDef = MetaModel::GetAttributeDef($this->m_oDataSource->GetTargetClass(), $sAttCode);
         if ($oAttDef->IsWritable()) {
             $this->m_aAttributes[$sAttCode] = $oSyncAtt;
         }
     }
     // Compute and keep track of the limit date taken into account for obsoleting replicas
     //
     if ($this->m_oLastFullLoadStartDate == null) {
         // No previous import known, use the full_load_periodicity value... and the current date
         $this->m_oLastFullLoadStartDate = new DateTime();
         // Now
         $iLoadPeriodicity = $this->m_oDataSource->Get('full_load_periodicity');
         // Duration in seconds
         if ($iLoadPeriodicity > 0) {
             $sInterval = "-{$iLoadPeriodicity} seconds";
             $this->m_oLastFullLoadStartDate->Modify($sInterval);
         } else {
             $this->m_oLastFullLoadStartDate = new DateTime('1970-01-01');
         }
     }
     if ($bFirstPass) {
         $this->m_oStatLog->AddTrace("Limit Date: " . $this->m_oLastFullLoadStartDate->Format('Y-m-d H:i:s'));
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:77,代码来源:synchrodatasource.class.inc.php

示例10: MakeRealValue

 public function MakeRealValue($proposedValue, $oHostObj)
 {
     if (!is_object($proposedValue)) {
         if (file_exists($proposedValue) && UserRights::IsAdministrator()) {
             $sContent = file_get_contents($proposedValue);
             $sExtension = strtolower(pathinfo($proposedValue, PATHINFO_EXTENSION));
             $sMimeType = "application/x-octet-stream";
             $aKnownExtensions = array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12.xlsx', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'dot' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'vsd' => 'application/x-visio', 'vdx' => 'application/visio.drawing', 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'zip' => 'application/zip', 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'exe' => 'application/octet-stream');
             if (!array_key_exists($sExtension, $aKnownExtensions) && extension_loaded('fileinfo')) {
                 $finfo = new finfo(FILEINFO_MIME);
                 $sMimeType = $finfo->file($proposedValue);
             }
             return new ormDocument($sContent, $sMimeType);
         } else {
             return new ormDocument($proposedValue, 'text/plain');
         }
     }
     return $proposedValue;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:19,代码来源:attributedef.class.inc.php

示例11: 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

示例12: ReadMandatoryParam

    $sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
    if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
        UserRights::Login($sAuthUser);
        // Login & set the user's language
    } else {
        $oP->p("Access wrong credentials ('{$sAuthUser}')");
        $oP->output();
        exit - 1;
    }
} else {
    $_SESSION['login_mode'] = 'basic';
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
}
if (!UserRights::IsAdministrator()) {
    $oP->p("Access restricted to administrators");
    $oP->Output();
    exit - 1;
}
// Enumerate classes implementing BackgroundProcess
//
$aProcesses = array();
foreach (get_declared_classes() as $sPHPClass) {
    $oRefClass = new ReflectionClass($sPHPClass);
    $oExtensionInstance = null;
    if ($oRefClass->implementsInterface('iProcess')) {
        if (is_null($oExtensionInstance)) {
            $oExecInstance = new $sPHPClass();
        }
        $aProcesses[$sPHPClass] = $oExecInstance;
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:cron.php

示例13: DoLogin

 /**
  * Check if the user is already authentified, if yes, then performs some additional validations:
  * - if $bMustBeAdmin is true, then the user must be an administrator, otherwise an error is displayed
  * - if $bIsAllowedToPortalUsers is false and the user has only access to the portal, then the user is redirected to the portal
  * @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
  * @param bool $bIsAllowedToPortalUsers Whether or not the current page is considered as part of the portal
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  */
 static function DoLogin($bMustBeAdmin = false, $bIsAllowedToPortalUsers = false, $iOnExit = self::EXIT_PROMPT)
 {
     $sMessage = '';
     // In case we need to return a message to the calling web page
     $operation = utils::ReadParam('loginop', '');
     if ($operation == 'logoff') {
         if (isset($_SESSION['login_mode'])) {
             $sLoginMode = $_SESSION['login_mode'];
         } else {
             $aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
             if (count($aAllowedLoginTypes) > 0) {
                 $sLoginMode = $aAllowedLoginTypes[0];
             } else {
                 $sLoginMode = 'form';
             }
         }
         self::ResetSession();
         $oPage = self::NewLoginWebPage();
         $oPage->DisplayLoginForm($sLoginMode, false);
         $oPage->output();
         exit;
     } else {
         if ($operation == 'forgot_pwd') {
             $oPage = self::NewLoginWebPage();
             $oPage->DisplayForgotPwdForm();
             $oPage->output();
             exit;
         } else {
             if ($operation == 'forgot_pwd_go') {
                 $oPage = self::NewLoginWebPage();
                 $oPage->ForgotPwdGo();
                 $oPage->output();
                 exit;
             } else {
                 if ($operation == 'reset_pwd') {
                     $oPage = self::NewLoginWebPage();
                     $oPage->DisplayResetPwdForm();
                     $oPage->output();
                     exit;
                 } else {
                     if ($operation == 'do_reset_pwd') {
                         $oPage = self::NewLoginWebPage();
                         $oPage->DoResetPassword();
                         $oPage->output();
                         exit;
                     } else {
                         if ($operation == 'change_pwd') {
                             $sAuthUser = $_SESSION['auth_user'];
                             UserRights::Login($sAuthUser);
                             // Set the user's language
                             $oPage = self::NewLoginWebPage();
                             $oPage->DisplayChangePwdForm();
                             $oPage->output();
                             exit;
                         }
                     }
                 }
             }
         }
     }
     if ($operation == 'do_change_pwd') {
         $sAuthUser = $_SESSION['auth_user'];
         UserRights::Login($sAuthUser);
         // Set the user's language
         $sOldPwd = utils::ReadPostedParam('old_pwd', '', false, 'raw_data');
         $sNewPwd = utils::ReadPostedParam('new_pwd', '', false, 'raw_data');
         if (UserRights::CanChangePassword() && (!UserRights::CheckCredentials($sAuthUser, $sOldPwd) || !UserRights::ChangePassword($sOldPwd, $sNewPwd))) {
             $oPage = self::NewLoginWebPage();
             $oPage->DisplayChangePwdForm(true);
             // old pwd was wrong
             $oPage->output();
             exit;
         }
         $sMessage = Dict::S('UI:Login:PasswordChanged');
     }
     $iRet = self::Login($iOnExit);
     if ($iRet == self::EXIT_CODE_OK) {
         if ($bMustBeAdmin && !UserRights::IsAdministrator()) {
             if ($iOnExit == self::EXIT_RETURN) {
                 return self::EXIT_CODE_MUSTBEADMIN;
             } else {
                 require_once APPROOT . '/setup/setuppage.class.inc.php';
                 $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
                 $oP->add("<h1>" . Dict::S('UI:Login:Error:AccessAdmin') . "</h1>\n");
                 $oP->p("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/logoff.php\">" . Dict::S('UI:LogOffMenu') . "</a>");
                 $oP->output();
                 exit;
             }
         }
         $iRet = call_user_func(array(self::$sHandlerClass, 'ChangeLocation'), $bIsAllowedToPortalUsers, $iOnExit);
     }
     if ($iOnExit == self::EXIT_RETURN) {
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:loginwebpage.class.inc.php

示例14: DoCheckToDelete

 protected function DoCheckToDelete(&$oDeletionPlan)
 {
     $this->m_aDeleteIssues = array();
     // Ok
     if ($this->InSyncScope()) {
         $oReplicaSet = $this->GetMasterReplica();
         if ($oReplicaSet->Count() > 0) {
             while ($aData = $oReplicaSet->FetchAssoc()) {
                 $oDataSource = $aData['datasource'];
                 $oReplica = $aData['replica'];
                 $oDeletionPlan->AddToDelete($oReplica, DEL_SILENT);
                 if ($oDataSource->GetKey() == SynchroExecution::GetCurrentTaskId()) {
                     // The current task has the right to delete the object
                     continue;
                 }
                 if ($oReplica->Get('status_dest_creator') != 1) {
                     // The object is not owned by the task
                     continue;
                 }
                 $sLink = $oDataSource->GetName();
                 $sUserDeletePolicy = $oDataSource->Get('user_delete_policy');
                 switch ($sUserDeletePolicy) {
                     case 'nobody':
                         $this->m_aDeleteIssues[] = Dict::Format('Core:Synchro:TheObjectCannotBeDeletedByUser_Source', $sLink);
                         break;
                     case 'administrators':
                         if (!UserRights::IsAdministrator()) {
                             $this->m_aDeleteIssues[] = Dict::Format('Core:Synchro:TheObjectCannotBeDeletedByUser_Source', $sLink);
                         }
                         break;
                     case 'everybody':
                     default:
                         // Ok
                         break;
                 }
             }
         }
     }
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:39,代码来源:dbobject.class.php

示例15: OnMenuCreation

 public static function OnMenuCreation()
 {
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new WebPageMenuNode('BackupStatus', utils::GetAbsoluteUrlModulePage('itop-backup', 'status.php'), $oAdminMenu->GetIndex(), 15);
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:7,代码来源:main.itop-backup.php


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