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


PHP MetaModel::GetConfig方法代码示例

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


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

示例1: GetProfileActionGrant

 public static function GetProfileActionGrant($iProfileId, $sClass, $sAction)
 {
     $bLegacyBehavior = MetaModel::GetConfig()->Get('user_rights_legacy');
     // Search for a grant, stoping if any deny is encountered (allowance implies the verification of all paths)
     $bAllow = null;
     // 1 - The class itself
     //
     $sGrantKey = $iProfileId . '_' . $sClass . '_' . $sAction;
     if (isset(self::$aGRANTS[$sGrantKey])) {
         $bAllow = self::$aGRANTS[$sGrantKey];
         if ($bLegacyBehavior) {
             return $bAllow;
         }
         if (!$bAllow) {
             return false;
         }
     }
     // 2 - The parent classes, up to the root class
     //
     foreach (MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_EXCLUDELEAF, false) as $sParent) {
         $sGrantKey = $iProfileId . '_' . $sParent . '+_' . $sAction;
         if (isset(self::$aGRANTS[$sGrantKey])) {
             $bAllow = self::$aGRANTS[$sGrantKey];
             if ($bLegacyBehavior) {
                 return $bAllow;
             }
             if (!$bAllow) {
                 return false;
             }
         }
     }
     // 3 - The related classes (if the current is an N-N link with DEL_AUTO/DEL_SILENT)
     //
     $bGrant = self::GetLinkActionGrant($iProfileId, $sClass, $sAction);
     if (!is_null($bGrant)) {
         $bAllow = $bGrant;
         if ($bLegacyBehavior) {
             return $bAllow;
         }
         if (!$bAllow) {
             return false;
         }
     }
     // 4 - All
     //
     $sGrantKey = $iProfileId . '_*_' . $sAction;
     if (isset(self::$aGRANTS[$sGrantKey])) {
         $bAllow = self::$aGRANTS[$sGrantKey];
         if ($bLegacyBehavior) {
             return $bAllow;
         }
         if (!$bAllow) {
             return false;
         }
     }
     // null or true
     return $bAllow;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:58,代码来源:model.itop-profiles-itil.php

示例2: MakeObjectURL

 public static function MakeObjectURL($sClass, $iId)
 {
     if (strpos(MetaModel::GetConfig()->Get('portal_tickets'), $sClass) !== false) {
         $sAbsoluteUrl = utils::GetAbsoluteUrlAppRoot();
         $sUrl = "{$sAbsoluteUrl}portal/index.php?operation=details&class={$sClass}&id={$iId}";
     } else {
         $sUrl = '';
     }
     return $sUrl;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:10,代码来源:main.itop-welcome-itil.php

示例3: GetURL

 public function GetURL()
 {
     $aOverloads = MetaModel::GetConfig()->Get('portal_dispatch_urls');
     if (array_key_exists($this->sPortalid, $aOverloads)) {
         $sRet = $aOverloads[$this->sPortalid];
     } else {
         $sRet = utils::GetAbsoluteUrlAppRoot() . $this->aData['url'];
     }
     return $sRet;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:10,代码来源:portaldispatcher.class.inc.php

示例4: ComputeResults

 public function ComputeResults()
 {
     $this->m_iToDelete = 0;
     $this->m_iToUpdate = 0;
     foreach ($this->m_aToDelete as $sClass => $aToDelete) {
         foreach ($aToDelete as $iId => $aData) {
             $this->m_iToDelete++;
             if (isset($aData['issue'])) {
                 $this->m_bFoundStopper = true;
                 $this->m_bFoundManualOperation = true;
                 if (isset($aData['issue_security'])) {
                     $this->m_bFoundSecurityIssue = true;
                 }
             }
             if ($aData['mode'] == DEL_MANUAL) {
                 $this->m_aToDelete[$sClass][$iId]['issue'] = $sClass . '::' . $iId . ' ' . Dict::S('UI:Delete:MustBeDeletedManually');
                 $this->m_bFoundStopper = true;
                 $this->m_bFoundManualDelete = true;
             }
         }
     }
     // Getting and setting time limit are not symetric:
     // www.php.net/manual/fr/function.set-time-limit.php#72305
     $iPreviousTimeLimit = ini_get('max_execution_time');
     $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
     foreach ($this->m_aToUpdate as $sClass => $aToUpdate) {
         foreach ($aToUpdate as $iId => $aData) {
             set_time_limit($iLoopTimeLimit);
             $this->m_iToUpdate++;
             $oObject = $aData['to_reset'];
             $aExtKeyLabels = array();
             foreach ($aData['attributes'] as $sRemoteExtKey => $aRemoteAttDef) {
                 $oObject->Set($sRemoteExtKey, $aData['values'][$sRemoteExtKey]);
                 $aExtKeyLabels[] = $aRemoteAttDef->GetLabel();
             }
             $this->m_aToUpdate[$sClass][$iId]['attributes_list'] = implode(', ', $aExtKeyLabels);
             list($bRes, $aIssues, $bSecurityIssues) = $oObject->CheckToWrite();
             if (!$bRes) {
                 $this->m_aToUpdate[$sClass][$iId]['issue'] = implode(', ', $aIssues);
                 $this->m_bFoundStopper = true;
                 if ($bSecurityIssues) {
                     $this->m_aToUpdate[$sClass][$iId]['issue_security'] = true;
                     $this->m_bFoundSecurityIssue = true;
                 }
             }
         }
     }
     set_time_limit($iPreviousTimeLimit);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:49,代码来源:deletionplan.class.inc.php

示例5: GetRelatedObjectsAsXml

/**
 * Get the related objects through the given relation, output in XML
 * @param DBObject $oObj The current object
 * @param string $sRelation The name of the relation to search with
 */
function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode, $iDepth = 0, $aExcludedClasses)
{
    global $G_aCachedObjects;
    $iMaxRecursionDepth = MetaModel::GetConfig()->Get('relations_max_depth', 20);
    $aResults = array();
    $bAddLinks = false;
    if ($iDepth > $iMaxRecursionDepth - 1) {
        return;
    }
    $sIdxKey = get_class($oObj) . ':' . $oObj->GetKey();
    if (!array_key_exists($sIdxKey, $G_aCachedObjects)) {
        $oObj->GetRelatedObjects($sRelationName, 1, $aResults);
        $G_aCachedObjects[$sIdxKey] = true;
    } else {
        return;
        //$aResults = $G_aCachedObjects[$sIdxKey];
    }
    foreach ($aResults as $sRelatedClass => $aObjects) {
        foreach ($aObjects as $id => $oTargetObj) {
            if (is_object($oTargetObj)) {
                if (in_array(get_class($oTargetObj), $aExcludedClasses)) {
                    GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oLinks, $oXmlDoc, $oXmlNode, $iDepth + 1, $aExcludedClasses);
                } else {
                    $oLinkingNode = $oXmlDoc->CreateElement('link');
                    $oLinkingNode->SetAttribute('relation', $sRelationName);
                    $oLinkingNode->SetAttribute('arrow', 1);
                    // Such relations have a direction, display an arrow
                    $oLinkedNode = $oXmlDoc->CreateElement('node');
                    $oLinkedNode->SetAttribute('id', $oTargetObj->GetKey());
                    $oLinkedNode->SetAttribute('obj_class', get_class($oTargetObj));
                    $oLinkedNode->SetAttribute('obj_class_name', htmlspecialchars(MetaModel::GetName(get_class($oTargetObj))));
                    $oLinkedNode->SetAttribute('name', htmlspecialchars($oTargetObj->GetRawName()));
                    // htmlentities is too much for XML
                    $oLinkedNode->SetAttribute('icon', BuildIconPath($oTargetObj->GetIcon(false)));
                    AddNodeDetails($oLinkedNode, $oTargetObj);
                    $oSubLinks = $oXmlDoc->CreateElement('links');
                    // Recurse
                    GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oSubLinks, $oXmlDoc, $oLinkedNode, $iDepth + 1, $aExcludedClasses);
                    $oLinkingNode->AppendChild($oLinkedNode);
                    $oLinks->AppendChild($oLinkingNode);
                    $bAddLinks = true;
                }
            }
        }
    }
    if ($bAddLinks) {
        $oXmlNode->AppendChild($oLinks);
    }
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:54,代码来源:xml.navigator.php

示例6: GetTicketClasses

/**
 * Helper to determine the supported types of tickets
 */
function GetTicketClasses()
{
    $aClasses = array();
    foreach (explode(',', MetaModel::GetConfig()->Get('portal_tickets')) as $sRawClass) {
        $sRawClass = trim($sRawClass);
        if (!MetaModel::IsValidClass($sRawClass)) {
            throw new Exception("Class '{$sRawClass}' is not a valid class, please review your configuration (portal_tickets)");
        }
        if (!MetaModel::IsParentClass('Ticket', $sRawClass)) {
            throw new Exception("Class '{$sRawClass}' does not inherit from Ticket, please review your configuration (portal_tickets)");
        }
        $aClasses[] = $sRawClass;
    }
    return $aClasses;
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:18,代码来源:index.php

示例7: CronExec

function CronExec($oP, $aProcesses, $bVerbose)
{
    $iStarted = time();
    $iMaxDuration = MetaModel::GetConfig()->Get('cron_max_execution_time');
    $iTimeLimit = $iStarted + $iMaxDuration;
    if ($bVerbose) {
        $oP->p("Planned duration = {$iMaxDuration} seconds");
    }
    // Reset the next planned execution to take into account new settings
    $oSearch = new DBObjectSearch('BackgroundTask');
    $oTasks = new DBObjectSet($oSearch);
    while ($oTask = $oTasks->Fetch()) {
        $sTaskClass = $oTask->Get('class_name');
        $oRefClass = new ReflectionClass($sTaskClass);
        $oNow = new DateTime();
        if ($oRefClass->implementsInterface('iScheduledProcess') && ($oTask->Get('status') != 'active' || $oTask->Get('next_run_date') > $oNow->format('Y-m-d H:i:s'))) {
            if ($bVerbose) {
                $oP->p("Resetting the next run date for {$sTaskClass}");
            }
            $oProcess = $aProcesses[$sTaskClass];
            $oNextOcc = $oProcess->GetNextOccurrence();
            $oTask->Set('next_run_date', $oNextOcc->format('Y-m-d H:i:s'));
            $oTask->DBUpdate();
        }
    }
    $iCronSleep = MetaModel::GetConfig()->Get('cron_sleep');
    $oSearch = new DBObjectSearch('BackgroundTask');
    while (time() < $iTimeLimit) {
        $oTasks = new DBObjectSet($oSearch);
        $aTasks = array();
        while ($oTask = $oTasks->Fetch()) {
            $aTasks[$oTask->Get('class_name')] = $oTask;
        }
        foreach ($aProcesses as $oProcess) {
            $sTaskClass = get_class($oProcess);
            $oNow = new DateTime();
            if (!array_key_exists($sTaskClass, $aTasks)) {
                // New entry, let's create a new BackgroundTask record, and plan the first execution
                $oTask = new BackgroundTask();
                $oTask->Set('class_name', get_class($oProcess));
                $oTask->Set('total_exec_count', 0);
                $oTask->Set('min_run_duration', 99999.999);
                $oTask->Set('max_run_duration', 0);
                $oTask->Set('average_run_duration', 0);
                $oRefClass = new ReflectionClass($sTaskClass);
                if ($oRefClass->implementsInterface('iScheduledProcess')) {
                    $oNextOcc = $oProcess->GetNextOccurrence();
                    $oTask->Set('next_run_date', $oNextOcc->format('Y-m-d H:i:s'));
                } else {
                    // Background processes do start asap, i.e. "now"
                    $oTask->Set('next_run_date', $oNow->format('Y-m-d H:i:s'));
                }
                if ($bVerbose) {
                    $oP->p('Creating record for: ' . $sTaskClass);
                    $oP->p('First execution planned at: ' . $oTask->Get('next_run_date'));
                }
                $oTask->DBInsert();
                $aTasks[$oTask->Get('class_name')] = $oTask;
            }
            if ($aTasks[$sTaskClass]->Get('status') == 'active' && $aTasks[$sTaskClass]->Get('next_run_date') <= $oNow->format('Y-m-d H:i:s')) {
                // Run the task and record its next run time
                if ($bVerbose) {
                    $oP->p(">> === " . $oNow->format('Y-m-d H:i:s') . sprintf(" Starting:%-'=40s", ' ' . $sTaskClass . ' '));
                }
                $sMessage = RunTask($oProcess, $aTasks[$sTaskClass], $oNow, $iTimeLimit);
                if ($bVerbose) {
                    if (!empty($sMessage)) {
                        $oP->p("{$sTaskClass}: {$sMessage}");
                    }
                    $oEnd = new DateTime();
                    $oP->p("<< === " . $oEnd->format('Y-m-d H:i:s') . sprintf(" End of:  %-'=40s", ' ' . $sTaskClass . ' '));
                }
            } else {
                // will run later
                if ($aTasks[$sTaskClass]->Get('status') == 'active' && $bVerbose) {
                    $oP->p("Skipping asynchronous task: {$sTaskClass} until " . $aTasks[$sTaskClass]->Get('next_run_date'));
                }
            }
        }
        if ($bVerbose) {
            $oP->p("Sleeping");
        }
        sleep($iCronSleep);
    }
    if ($bVerbose) {
        $oP->p("Reached normal execution time limit (exceeded by " . (time() - $iTimeLimit) . "s)");
    }
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:88,代码来源:cron.php

示例8: GetDataModelSettings

 public static function GetDataModelSettings($aClassAliases, $bViewLink, $aDefaultLists)
 {
     $oSettings = new DataTableSettings($aClassAliases);
     // Retrieve the class specific settings for each class/alias based on the 'list' ZList
     //TODO let the caller pass some other default settings (another Zlist, extre fields...)
     $aColumns = array();
     foreach ($aClassAliases as $sAlias => $sClass) {
         if ($aDefaultLists == null) {
             $aList = cmdbAbstract::FlattenZList(MetaModel::GetZListItems($sClass, 'list'));
         } else {
             $aList = $aDefaultLists[$sAlias];
         }
         $aSortOrder = MetaModel::GetOrderByDefault($sClass);
         if ($bViewLink) {
             $sSort = 'none';
             if (array_key_exists('friendlyname', $aSortOrder)) {
                 $sSort = $aSortOrder['friendlyname'] ? 'asc' : 'desc';
             }
             $aColumns[$sAlias]['_key_'] = $oSettings->GetFieldData($sAlias, '_key_', null, true, $sSort);
         }
         foreach ($aList as $sAttCode) {
             $sSort = 'none';
             if (array_key_exists($sAttCode, $aSortOrder)) {
                 $sSort = $aSortOrder[$sAttCode] ? 'asc' : 'desc';
             }
             $oAttDef = Metamodel::GetAttributeDef($sClass, $sAttCode);
             $aFieldData = $oSettings->GetFieldData($sAlias, $sAttCode, $oAttDef, true, $sSort);
             if ($aFieldData) {
                 $aColumns[$sAlias][$sAttCode] = $aFieldData;
             }
         }
     }
     $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
     $oSettings->Init($iDefaultPageSize, $aSortOrder, $aColumns);
     return $oSettings;
 }
开发者ID:henryavila,项目名称:itop,代码行数:36,代码来源:datatable.class.inc.php

示例9: output


//.........这里部分代码省略.........
            $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>';
开发者ID:henryavila,项目名称:itop,代码行数:67,代码来源:itopwebpage.class.inc.php

示例10: Send

 public function Send(&$aIssues, $bForceSynchronous = false, $oLog = null)
 {
     if ($bForceSynchronous) {
         return $this->SendSynchronous($aIssues, $oLog);
     } else {
         $bConfigASYNC = MetaModel::GetConfig()->Get('email_asynchronous');
         if ($bConfigASYNC) {
             return $this->SendAsynchronous($aIssues, $oLog);
         } else {
             return $this->SendSynchronous($aIssues, $oLog);
         }
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:13,代码来源:email.class.inc.php

示例11: ReportStats

 public static function ReportStats()
 {
     if (!self::IsEnabled()) {
         return;
     }
     global $fItopStarted;
     $sExecId = microtime();
     // id to differentiate the hrefs!
     $aBeginTimes = array();
     foreach (self::$m_aExecData as $aOpStats) {
         $aBeginTimes[] = $aOpStats['time_begin'];
     }
     array_multisort($aBeginTimes, self::$m_aExecData);
     $sTableStyle = 'background-color: #ccc; margin: 10px;';
     self::Report("<hr/>");
     self::Report("<div style=\"background-color: grey; padding: 10px;\">");
     self::Report("<h3><a name=\"" . md5($sExecId) . "\">KPIs</a> - " . $_SERVER['REQUEST_URI'] . " (" . $_SERVER['REQUEST_METHOD'] . ")</h3>");
     self::Report("<p>" . date('Y-m-d H:i:s', $fItopStarted) . "</p>");
     self::Report("<p>log_kpi_user_id: " . MetaModel::GetConfig()->Get('log_kpi_user_id') . "</p>");
     self::Report("<div>");
     self::Report("<table border=\"1\" style=\"{$sTableStyle}\">");
     self::Report("<thead>");
     self::Report("   <th>Operation</th><th>Begin</th><th>End</th><th>Duration</th><th>Memory start</th><th>Memory end</th><th>Memory peak</th>");
     self::Report("</thead>");
     foreach (self::$m_aExecData as $aOpStats) {
         $sOperation = $aOpStats['op'];
         $sBegin = $sEnd = $sDuration = $sMemBegin = $sMemEnd = $sMemPeak = '?';
         $sBegin = round($aOpStats['time_begin'], 3);
         $sEnd = round($aOpStats['time_end'], 3);
         $fDuration = $aOpStats['time_end'] - $aOpStats['time_begin'];
         $sDuration = round($fDuration, 3);
         if (isset($aOpStats['mem_begin'])) {
             $sMemBegin = self::MemStr($aOpStats['mem_begin']);
             $sMemEnd = self::MemStr($aOpStats['mem_end']);
             if (isset($aOpStats['mem_peak'])) {
                 $sMemPeak = self::MemStr($aOpStats['mem_peak']);
             }
         }
         self::Report("<tr>");
         self::Report("   <td>{$sOperation}</td><td>{$sBegin}</td><td>{$sEnd}</td><td>{$sDuration}</td><td>{$sMemBegin}</td><td>{$sMemEnd}</td><td>{$sMemPeak}</td>");
         self::Report("</tr>");
     }
     self::Report("</table>");
     self::Report("</div>");
     $aConsolidatedStats = array();
     foreach (self::$m_aStats as $sOperation => $aOpStats) {
         $fTotalOp = 0;
         $iTotalOp = 0;
         $fMinOp = null;
         $fMaxOp = 0;
         $sMaxOpArguments = null;
         foreach ($aOpStats as $sArguments => $aEvents) {
             foreach ($aEvents as $aEventData) {
                 $fDuration = $aEventData['time'];
                 $fTotalOp += $fDuration;
                 $iTotalOp++;
                 $fMinOp = is_null($fMinOp) ? $fDuration : min($fMinOp, $fDuration);
                 if ($fDuration > $fMaxOp) {
                     $sMaxOpArguments = $sArguments;
                     $fMaxOp = $fDuration;
                 }
             }
         }
         $aConsolidatedStats[$sOperation] = array('count' => $iTotalOp, 'duration' => $fTotalOp, 'min' => $fMinOp, 'max' => $fMaxOp, 'avg' => $fTotalOp / $iTotalOp, 'max_args' => $sMaxOpArguments);
     }
     self::Report("<div>");
     self::Report("<table border=\"1\" style=\"{$sTableStyle}\">");
     self::Report("<thead>");
     self::Report("   <th>Operation</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th><th>Avg</th>");
     self::Report("</thead>");
     foreach ($aConsolidatedStats as $sOperation => $aOpStats) {
         $sOperation = '<a href="#' . md5($sExecId . $sOperation) . '">' . $sOperation . '</a>';
         $sCount = $aOpStats['count'];
         $sDuration = round($aOpStats['duration'], 3);
         $sMin = round($aOpStats['min'], 3);
         $sMax = '<a href="#' . md5($sExecId . $aOpStats['max_args']) . '">' . round($aOpStats['max'], 3) . '</a>';
         $sAvg = round($aOpStats['avg'], 3);
         self::Report("<tr>");
         self::Report("   <td>{$sOperation}</td><td>{$sCount}</td><td>{$sDuration}</td><td>{$sMin}</td><td>{$sMax}</td><td>{$sAvg}</td>");
         self::Report("</tr>");
     }
     self::Report("</table>");
     self::Report("</div>");
     self::Report("</div>");
     // Report operation details
     foreach (self::$m_aStats as $sOperation => $aOpStats) {
         $sOperationHtml = '<a name="' . md5($sExecId . $sOperation) . '">' . $sOperation . '</a>';
         self::Report("<h4>{$sOperationHtml}</h4>");
         self::Report("<p><a href=\"#" . md5($sExecId) . "\">Back to page stats</a></p>");
         self::Report("<table border=\"1\" style=\"{$sTableStyle}\">");
         self::Report("<thead>");
         self::Report("   <th>Operation details (+ blame caller if log_kpi_duration = 2)</th><th>Count</th><th>Duration</th><th>Min</th><th>Max</th>");
         self::Report("</thead>");
         foreach ($aOpStats as $sArguments => $aEvents) {
             $sHtmlArguments = '<a name="' . md5($sExecId . $sArguments) . '"><div style="white-space: pre-wrap;">' . $sArguments . '</div></a>';
             if ($aConsolidatedStats[$sOperation]['max_args'] == $sArguments) {
                 $sHtmlArguments = '<span style="color: red;">' . $sHtmlArguments . '</span>';
             }
             if (isset($aEvents[0]['callers'])) {
                 $sHtmlArguments .= '<div style="padding: 10px;">';
//.........这里部分代码省略.........
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:101,代码来源:kpi.class.inc.php

示例12: CreateZip

 public function CreateZip($sZipFile, $sSourceConfigFile = null)
 {
     // Note: the file is created by tempnam and might not be writeable by another process (Windows/IIS)
     // (delete it before spawning a process)
     $sDataFile = tempnam(SetupUtils::GetTmpDir(), 'itop-');
     $this->LogInfo("Data file: '{$sDataFile}'");
     $aContents = array();
     $aContents[] = array('source' => $sDataFile, 'dest' => 'itop-dump.sql');
     if (is_null($sSourceConfigFile)) {
         $sSourceConfigFile = MetaModel::GetConfig()->GetLoadedFile();
     }
     if (!empty($sSourceConfigFile)) {
         $aContents[] = array('source' => $sSourceConfigFile, 'dest' => 'config-itop.php');
     }
     $this->DoBackup($sDataFile);
     $sDeltaFile = APPROOT . 'data/' . utils::GetCurrentEnvironment() . '.delta.xml';
     if (file_exists($sDeltaFile)) {
         $aContents[] = array('source' => $sDeltaFile, 'dest' => 'delta.xml');
     }
     $sExtraDir = APPROOT . 'data/' . utils::GetCurrentEnvironment() . '-modules/';
     if (is_dir($sExtraDir)) {
         $aContents[] = array('source' => $sExtraDir, 'dest' => utils::GetCurrentEnvironment() . '-modules/');
     }
     $this->DoZip($aContents, $sZipFile);
     // Windows/IIS: the data file has been created by the spawned process...
     //   trying to delete it will issue a warning, itself stopping the setup abruptely
     @unlink($sDataFile);
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:28,代码来源:backup.class.inc.php

示例13: MakeDeletionPlan

 private function MakeDeletionPlan(&$oDeletionPlan, $aVisited = array(), $iDeleteOption = null)
 {
     static $iLoopTimeLimit = null;
     if ($iLoopTimeLimit == null) {
         $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
     }
     $sClass = get_class($this);
     $iThisId = $this->GetKey();
     $iDeleteOption = $oDeletionPlan->AddToDelete($this, $iDeleteOption);
     if (array_key_exists($sClass, $aVisited)) {
         if (in_array($iThisId, $aVisited[$sClass])) {
             return;
         }
     }
     $aVisited[$sClass] = $iThisId;
     if ($iDeleteOption == DEL_MANUAL) {
         // Stop the recursion here
         return;
     }
     // Check the node itself
     $this->DoCheckToDelete($oDeletionPlan);
     $oDeletionPlan->SetDeletionIssues($this, $this->m_aDeleteIssues, $this->m_bSecurityIssue);
     $aDependentObjects = $this->GetReferencingObjects(true);
     // Getting and setting time limit are not symetric:
     // www.php.net/manual/fr/function.set-time-limit.php#72305
     $iPreviousTimeLimit = ini_get('max_execution_time');
     foreach ($aDependentObjects as $sRemoteClass => $aPotentialDeletes) {
         foreach ($aPotentialDeletes as $sRemoteExtKey => $aData) {
             set_time_limit($iLoopTimeLimit);
             $oAttDef = $aData['attribute'];
             $iDeletePropagationOption = $oAttDef->GetDeletionPropagationOption();
             $oDepSet = $aData['objects'];
             $oDepSet->Rewind();
             while ($oDependentObj = $oDepSet->fetch()) {
                 $iId = $oDependentObj->GetKey();
                 if ($oAttDef->IsNullAllowed()) {
                     // Optional external key, list to reset
                     if ($iDeletePropagationOption == DEL_MOVEUP && $oAttDef->IsHierarchicalKey()) {
                         // Move the child up one level i.e. set the same parent as the current object
                         $iParentId = $this->Get($oAttDef->GetCode());
                         $oDeletionPlan->AddToUpdate($oDependentObj, $oAttDef, $iParentId);
                     } else {
                         $oDeletionPlan->AddToUpdate($oDependentObj, $oAttDef);
                     }
                 } else {
                     // Mandatory external key, list to delete
                     $oDependentObj->MakeDeletionPlan($oDeletionPlan, $aVisited, $iDeletePropagationOption);
                 }
             }
         }
     }
     set_time_limit($iPreviousTimeLimit);
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:53,代码来源:dbobject.class.php

示例14: GetRenderContent

 /**
  * Renders the "Actions" popup menu for the given set of objects
  * 
  * Note that the menu links containing (or ending) with a hash (#) will have their fragment
  * part (whatever is after the hash) dynamically replaced (by javascript) when the menu is
  * displayed, to correspond to the current hash/fragment in the page. This allows modifying
  * an object in with the same tab active by default as the tab that was active when selecting
  * the "Modify..." action.
  */
 public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
 {
     if ($this->m_sStyle == 'popup') {
         $this->m_sStyle = 'list';
     }
     $sHtml = '';
     $oAppContext = new ApplicationContext();
     $sContext = $oAppContext->GetForLink();
     if (!empty($sContext)) {
         $sContext = '&' . $sContext;
     }
     $sClass = $this->m_oFilter->GetClass();
     $oReflectionClass = new ReflectionClass($sClass);
     $oSet = new CMDBObjectSet($this->m_oFilter);
     $sFilter = $this->m_oFilter->serialize();
     $sFilterDesc = $this->m_oFilter->ToOql(true);
     $aActions = array();
     $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($sClass);
     $sRootUrl = utils::GetAbsoluteUrlAppRoot();
     // 1:n links, populate the target object as a default value when creating a new linked object
     if (isset($aExtraParams['target_attr'])) {
         $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
     }
     $sDefault = '';
     if (!empty($aExtraParams['default'])) {
         foreach ($aExtraParams['default'] as $sKey => $sValue) {
             $sDefault .= "&default[{$sKey}]={$sValue}";
         }
     }
     $bIsCreationAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_CREATE) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
     switch ($oSet->Count()) {
         case 0:
             // No object in the set, the only possible action is "new"
             if ($bIsCreationAllowed) {
                 $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
             }
             break;
         case 1:
             $oObj = $oSet->Fetch();
             $id = $oObj->GetKey();
             $bLocked = false;
             if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) {
                 $aLockInfo = iTopOwnershipLock::IsLocked(get_class($oObj), $id);
                 if ($aLockInfo['locked']) {
                     $bLocked = true;
                     //$this->AddMenuSeparator($aActions);
                     //$aActions['concurrent_lock_unlock'] = array ('label' => Dict::S('UI:Menu:ReleaseConcurrentLock'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=kill_lock&class=$sClass&id=$id{$sContext}");
                 }
             }
             $bRawModifiedAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
             $bIsModifyAllowed = !$bLocked && $bRawModifiedAllowed;
             $bIsDeleteAllowed = !$bLocked && UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
             // Just one object in the set, possible actions are "new / clone / modify and delete"
             if (!isset($aExtraParams['link_attr'])) {
                 if ($bIsModifyAllowed) {
                     $aActions['UI:Menu:Modify'] = array('label' => Dict::S('UI:Menu:Modify'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=modify&class={$sClass}&id={$id}{$sContext}#");
                 }
                 if ($bIsCreationAllowed) {
                     $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
                 }
                 if ($bIsDeleteAllowed) {
                     $aActions['UI:Menu:Delete'] = array('label' => Dict::S('UI:Menu:Delete'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=delete&class={$sClass}&id={$id}{$sContext}");
                 }
                 // Transitions / Stimuli
                 if (!$bLocked) {
                     $aTransitions = $oObj->EnumTransitions();
                     if (count($aTransitions)) {
                         $this->AddMenuSeparator($aActions);
                         $aStimuli = Metamodel::EnumStimuli(get_class($oObj));
                         foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                             $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet) : UR_ALLOWED_NO;
                             switch ($iActionAllowed) {
                                 case UR_ALLOWED_YES:
                                     $aActions[$sStimulusCode] = array('label' => $aStimuli[$sStimulusCode]->GetLabel(), 'url' => "{$sRootUrl}pages/UI.php?operation=stimulus&stimulus={$sStimulusCode}&class={$sClass}&id={$id}{$sContext}");
                                     break;
                                 default:
                                     // Do nothing
                             }
                         }
                     }
                 }
                 // Relations...
                 $aRelations = MetaModel::EnumRelationsEx($sClass);
                 if (count($aRelations)) {
                     $this->AddMenuSeparator($aActions);
                     foreach ($aRelations as $sRelationCode => $aRelationInfo) {
                         if (array_key_exists('down', $aRelationInfo)) {
                             $aActions[$sRelationCode . '_down'] = array('label' => $aRelationInfo['down'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=down&class={$sClass}&id={$id}{$sContext}");
                         }
                         if (array_key_exists('up', $aRelationInfo)) {
                             $aActions[$sRelationCode . '_up'] = array('label' => $aRelationInfo['up'], 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=swf_navigator&relation={$sRelationCode}&direction=up&class={$sClass}&id={$id}{$sContext}");
//.........这里部分代码省略.........
开发者ID:henryavila,项目名称:itop,代码行数:101,代码来源:displayblock.class.inc.php

示例15: foreach

 // Build the ordered list of classes to search into
 //
 if (empty($sClassName)) {
     $aSearchClasses = MetaModel::GetClasses('searchable');
 } else {
     // Search is limited to a given class and its subclasses
     $aSearchClasses = MetaModel::EnumChildClasses($sClassName, ENUM_CHILD_CLASSES_ALL);
 }
 // Skip abstract classes, since we search in all the child classes anyway
 foreach ($aSearchClasses as $idx => $sClass) {
     if (MetaModel::IsAbstract($sClass)) {
         unset($aSearchClasses[$idx]);
     }
 }
 $sMaxChunkDuration = MetaModel::GetConfig()->Get('full_text_chunk_duration');
 $aAccelerators = MetaModel::GetConfig()->Get('full_text_accelerators');
 foreach (array_reverse($aAccelerators) as $sClass => $aRestriction) {
     $bSkip = false;
     $iPos = array_search($sClass, $aSearchClasses);
     if ($iPos !== false) {
         unset($aSearchClasses[$iPos]);
     } else {
         $bSkip = true;
     }
     $bSkip |= array_key_exists('skip', $aRestriction) ? $aRestriction['skip'] : false;
     if (!in_array($sClass, $aSearchClasses)) {
         if ($sClass == $sClassName) {
             // Class explicitely requested, do NOT skip it
             // beware: there may not be a 'query' defined for a skipped class !
             $bSkip = false;
         }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:ajax.render.php


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