コード例 #1
0
 public static function OnMenuCreation()
 {
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new WebPageMenuNode('ConfigEditor', utils::GetAbsoluteUrlModulesRoot() . 'itop-config/config.php', $oAdminMenu->GetIndex(), 18);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
ファイル: csvimport.php プロジェクト: leandroborgeseng/bhtm
 /**
  * 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;
 }
コード例 #5
0
 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) {
                 $oDataSource = $aStruct['datasource'];
                 $sLink = $aStruct['url'];
                 $sTip .= "<p style=\"white-space:nowrap\">" . $oDataSource->GetIcon(true, 'style="vertical-align:middle"') . "&nbsp;{$sLink}<br/>";
                 $sTip .= Dict::S('Core:Synchro:LastSynchro') . '<br/>' . $aStruct['last_synchro'] . "</p>";
             }
             $aIcons[] = '&nbsp;<img style="vertical-align:middle;" id="synchro_icon" src="../images/locked.png"/>';
             $sTip = addslashes($sTip);
             $oPage->add_ready_script("\$('#synchro_icon').qtip( { content: '{$sTip}', show: 'mouseover', hide: { fixed: true }, style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
         }
     }
     $sIcons = implode(' ', $aIcons);
     $oPage->add(MetaModel::GetName(get_class($this)) . ": <span class=\"hilite\">" . $this->GetName() . "</span>{$sIcons}</h1>\n");
     $oPage->add("</div>\n");
 }
コード例 #6
0
 /**
  * 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;
     }
 }
コード例 #7
0
    /**
     * 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";
            }
            $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 = '';
            if (strlen($sRestrictions) > 0) {
                $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message'));
                $sApplicationBanner .= '<div id="admin-banner">';
                $sApplicationBanner .= '<img src="../images/locked.png" style="vertical-align:middle;">';
                $sApplicationBanner .= '&nbsp;<b>' . $sRestrictions . '</b>';
                if (strlen($sAdminMessage) > 0) {
                    $sApplicationBanner .= '&nbsp;<b>' . $sAdminMessage . '</b>';
                }
                $sApplicationBanner .= '</div>';
            }
            if (strlen($this->m_sMessage)) {
                $sApplicationBanner .= '<div id="admin-banner"><span style="padding:5px;">' . $this->m_sMessage . '<span></div>';
            }
            $sApplicationBanner .= $sBannerExtraHtml;
            if (!empty($sNorthPane)) {
                $sNorthPane = '<div id="bottom-pane" class="ui-layout-north">' . $sNorthPane . '</div>';
            }
            if (!empty($sSouthPane)) {
                $sSouthPane = '<div id="bottom-pane" class="ui-layout-south">' . $sSouthPane . '</div>';
            }
            $sIconUrl = Utils::GetConfig()->Get('app_icon_url');
            $sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help');
            //$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
            $sDisplayIcon = utils::GetAbsoluteUrlAppRoot() . 'images/itop-logo.png';
            if (file_exists(MODULESROOT . 'branding/main-logo.png')) {
                $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot() . 'branding/main-logo.png';
            }
            $sHtml .= $sNorthPane;
            $sHtml .= '<div id="left-pane" class="ui-layout-west">';
            $sHtml .= '<!-- Beginning of the left pane -->';
            $sHtml .= ' <div class="ui-layout-north">';
            $sHtml .= ' <div id="header-logo">';
            $sHtml .= ' <div id="top-left"></div><div id="logo"><a href="' . htmlentities($sIconUrl, ENT_QUOTES, 'UTF-8') . '"><img src="' . $sDisplayIcon . '" title="' . htmlentities($sVersionString, ENT_QUOTES, 'UTF-8') . '" style="border:0; margin-top:16px; margin-right:40px;"/></a></div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div class="header-menu">';
            if (!MetaModel::GetConfig()->Get('demo_mode')) {
                $sHtml .= '		<div class="icon ui-state-default ui-corner-all"><span id="tPinMenu" class="ui-icon ui-icon-pin-w">pin</span></div>';
            }
            $sHtml .= '		<div style="text-align:center;">' . self::FilterXSS($sForm) . '</div>';
            $sHtml .= ' </div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div id="menu" class="ui-layout-center">';
            $sHtml .= '		<div id="inner_menu">';
            $sHtml .= '			<div id="accordion">';
            $sHtml .= self::FilterXSS($this->m_sMenu);
            $sHtml .= '			<!-- Beginning of the accordion menu -->';
            $sHtml .= '			<!-- End of the accordion menu-->';
            $sHtml .= '			</div>';
            $sHtml .= '		</div> <!-- /inner menu -->';
            $sHtml .= ' </div> <!-- /menu -->';
            $sHtml .= ' <div class="footer ui-layout-south"><div id="combodo_logo"><a href="http://www.combodo.com" title="www.combodo.com" target="_blank"><img src="../images/logo-combodo.png"/></a></div></div>';
            $sHtml .= '<!-- End of the left pane -->';
            $sHtml .= '</div>';
            $sHtml .= '<div class="ui-layout-center">';
            $sHtml .= ' <div id="top-bar" style="width:100%">';
            $sHtml .= self::FilterXSS($sApplicationBanner);
            $sHtml .= '		<div id="global-search"><form action="' . utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php"><table><tr><td></td><td id="g-search-input"><input type="text" name="text" value="' . $sText . '"' . $sOnClick . '/></td>';
            $sHtml .= '<td><input type="image" src="../images/searchBtn.png"/></a></td>';
            $sHtml .= '<td><a style="background:transparent;" href="' . $sOnlineHelpUrl . '" target="_blank"><img style="border:0;padding-left:20px;padding-right:10px;" title="' . Dict::S('UI:Help') . '" src="../images/help.png"/></td>';
            $sHtml .= '<td style="padding-right:20px;padding-left:10px;">' . self::FilterXSS($sLogOffMenu) . '</td><td><input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
            //echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div class="ui-layout-content" style="overflow:auto;">';
            $sHtml .= ' <!-- Beginning of page content -->';
            $sHtml .= self::FilterXSS($this->s_content);
            $sHtml .= ' <!-- End of page content -->';
            $sHtml .= ' </div>';
            $sHtml .= '</div>';
            $sHtml .= $sSouthPane;
            // Add the captured output
            if (trim($s_captured_output) != "") {
                $sHtml .= "<div id=\"rawOutput\" title=\"Debug Output\"><div style=\"height:500px; overflow-y:auto;\">" . self::FilterXSS($s_captured_output) . "</div></div>\n";
            }
            $sHtml .= "<div id=\"at_the_end\">" . self::FilterXSS($this->s_deferred_content) . "</div>";
            $sHtml .= "<div style=\"display:none\" title=\"ex2\" id=\"ex2\">Please wait...</div>\n";
            // jqModal Window
            $sHtml .= "<div style=\"display:none\" title=\"dialog\" id=\"ModalDlg\"></div>";
            $sHtml .= "<div style=\"display:none\" id=\"ajax_content\"></div>";
        } else {
            $sHtml .= self::FilterXSS($this->s_content);
        }
        $sHtml .= "</body>\n";
        $sHtml .= "</html>\n";
        if ($this->GetOutputFormat() == 'html') {
            $oKPI = new ExecutionKPI();
            echo $sHtml;
            $oKPI->ComputeAndReport('Echoing (' . round(strlen($sHtml) / 1024) . ' Kb)');
        } else {
            if ($this->GetOutputFormat() == 'pdf' && $this->IsOutputFormatAvailable('pdf')) {
                if (@is_readable(APPROOT . 'lib/MPDF/mpdf.php')) {
                    require_once APPROOT . 'lib/MPDF/mpdf.php';
                    $oMPDF = new mPDF('c');
                    $oMPDF->mirroMargins = false;
                    if ($this->a_base['href'] != '') {
                        $oMPDF->setBasePath($this->a_base['href']);
                        // Seems that the <BASE> tag is not recognized by mPDF...
                    }
                    $oMPDF->showWatermarkText = true;
                    if ($this->GetOutputOption('pdf', 'template_path')) {
                        $oMPDF->setImportUse();
                        // Allow templates
                        $oMPDF->SetDocTemplate($this->GetOutputOption('pdf', 'template_path'), 1);
                    }
                    $oMPDF->WriteHTML($sHtml);
                    $sOutputName = $this->s_title . '.pdf';
                    if ($this->GetOutputOption('pdf', 'output_name')) {
                        $sOutputName = $this->GetOutputOption('pdf', 'output_name');
                    }
                    $oMPDF->Output($sOutputName, 'I');
                }
            }
        }
        DBSearch::RecordQueryTrace();
        ExecutionKPI::ReportStats();
    }
コード例 #8
0
 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);
 }
コード例 #9
0
 /**
  * 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'));
     }
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 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;
 }
コード例 #12
0
ファイル: cron.php プロジェクト: kira8565/ITOP203-ZHCN
    $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;
コード例 #13
0
 /**
  * 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) {
         return $iRet;
     } else {
         return $sMessage;
     }
 }
コード例 #14
0
 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;
                 }
             }
         }
     }
 }
コード例 #15
0
 public static function OnMenuCreation()
 {
     if (UserRights::IsAdministrator()) {
         $oAdminMenu = new MenuGroup('AdminTools', 80);
         new WebPageMenuNode('BackupStatus', utils::GetAbsoluteUrlModulePage('itop-backup', 'status.php'), $oAdminMenu->GetIndex(), 15);
     }
 }
コード例 #16
0
 function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
 {
     // Standard Header with name, actions menu and history block
     //
     // Is there a message for this object ??
     $sMessageKey = get_class($this) . '::' . $this->GetKey();
     if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, $_SESSION['obj_messages'])) {
         $aMessages = array();
         $aRanks = array();
         foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) {
             $sMsgClass = 'message_' . $aMessageData['severity'];
             $aMessages[] = "<div class=\"header_message {$sMsgClass}\">" . $aMessageData['message'] . "</div>";
             $aRanks[] = $aMessageData['rank'];
         }
         array_multisort($aRanks, $aMessages);
         foreach ($aMessages as $sMessage) {
             $oPage->add($sMessage);
         }
         unset($_SESSION['obj_messages'][$sMessageKey]);
     }
     // action menu
     $oSingletonFilter = new DBObjectSearch(get_class($this));
     $oSingletonFilter->AddCondition('id', $this->GetKey(), '=');
     $oBlock = new MenuBlock($oSingletonFilter, 'details', false);
     $oBlock->Display($oPage, -1);
     // Master data sources
     $sSynchroIcon = '';
     $oReplicaSet = $this->GetMasterReplica();
     $bSynchronized = false;
     $oCreatorTask = null;
     $bCanBeDeletedByTask = false;
     $bCanBeDeletedByUser = true;
     $aMasterSources = array();
     if ($oReplicaSet->Count() > 0) {
         $bSynchronized = true;
         while ($aData = $oReplicaSet->FetchAssoc()) {
             // Assumption: $aData['datasource'] will not be null because the data source id is always set...
             $sApplicationURL = $aData['datasource']->GetApplicationUrl($this, $aData['replica']);
             $sLink = $aData['datasource']->GetName();
             if (!empty($sApplicationURL)) {
                 $sLink = "<a href=\"{$sApplicationURL}\" target=\"_blank\">" . $aData['datasource']->GetName() . "</a>";
             }
             if ($aData['replica']->Get('status_dest_creator') == 1) {
                 $oCreatorTask = $aData['datasource'];
                 $bCreatedByTask = true;
             } else {
                 $bCreatedByTask = false;
             }
             if ($bCreatedByTask) {
                 $sDeletePolicy = $aData['datasource']->Get('delete_policy');
                 if ($sDeletePolicy == 'delete' || $sDeletePolicy == 'update_then_delete') {
                     $bCanBeDeletedByTask = true;
                 }
                 $sUserDeletePolicy = $aData['datasource']->Get('user_delete_policy');
                 if ($sUserDeletePolicy == 'nobody') {
                     $bCanBeDeletedByUser = false;
                 } elseif ($sUserDeletePolicy == 'administrators' && !UserRights::IsAdministrator()) {
                     $bCanBeDeletedByUser = false;
                 } else {
                 }
             }
             $aMasterSources[$aData['datasource']->GetKey()]['datasource'] = $aData['datasource'];
             $aMasterSources[$aData['datasource']->GetKey()]['url'] = $sLink;
             $aMasterSources[$aData['datasource']->GetKey()]['last_synchro'] = $aData['replica']->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) {
             $oDataSource = $aStruct['datasource'];
             $sLink = $aStruct['url'];
             $sTip .= "<p style=\"white-space:nowrap\">" . $oDataSource->GetIcon(true, 'style="vertical-align:middle"') . "&nbsp;{$sLink}<br/>";
             $sTip .= Dict::S('Core:Synchro:LastSynchro') . '<br/>' . $aStruct['last_synchro'] . "</p>";
         }
         $sSynchroIcon = '&nbsp;<img style="vertical-align:middle;" id="synchro_icon" src="../images/locked.png"/>';
         $sTip = addslashes($sTip);
         $oPage->add_ready_script("\$('#synchro_icon').qtip( { content: '{$sTip}', show: 'mouseover', hide: { fixed: true }, style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
     }
     $oPage->add("<div class=\"page_header\"><h1>" . $this->GetIcon() . "&nbsp;\n");
     $sRefreshIcon = '';
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $sRefreshIcon = '<img src="../images/reload.png" style="cursor:pointer;vertical-align:middle;margin-left:1em;" onclick="window.location.reload();" title="' . htmlentities(Dict::S('UI:Button:Refresh'), ENT_QUOTES, 'UTF-8') . '"/>';
     }
     $oPage->add(MetaModel::GetName(get_class($this)) . ": <span class=\"hilite\">" . $this->GetName() . "</span>{$sRefreshIcon} {$sSynchroIcon}</h1>\n");
     $oPage->add("</div>\n");
 }
コード例 #17
0
ファイル: metamodel.class.php プロジェクト: henryavila/itop
 public static function DBIsReadOnly()
 {
     // Improvement: check the mySQL variable -> Read-only
     if (UserRights::IsAdministrator()) {
         return !self::DBHasAccess(ACCESS_ADMIN_WRITE);
     } else {
         return !self::DBHasAccess(ACCESS_USER_WRITE);
     }
 }