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


PHP MetaModel::GetClasses方法代码示例

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


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

示例1: DoShowGrantSumary

 function DoShowGrantSumary($oPage)
 {
     if ($this->GetRawName() == "Administrator") {
         // Looks dirty, but ok that's THE ONE
         $oPage->p(Dict::S('UI:UserManagement:AdminProfile+'));
         return;
     }
     // Note: for sure, we assume that the instance is derived from UserRightsProjection
     $oUserRights = UserRights::GetModuleInstance();
     $aDisplayData = array();
     foreach (MetaModel::GetClasses('bizmodel') as $sClass) {
         // Skip non instantiable classes
         if (MetaModel::IsAbstract($sClass)) {
             continue;
         }
         $aStimuli = array();
         foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) {
             $oGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode);
             if (is_object($oGrant) && $oGrant->Get('permission') == 'yes') {
                 $aStimuli[] = '<span title="' . $sStimulusCode . ': ' . htmlentities($oStimulus->GetDescription(), ENT_QUOTES, 'UTF-8') . '">' . htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8') . '</span>';
             }
         }
         $sStimuli = implode(', ', $aStimuli);
         $aDisplayData[] = array('class' => MetaModel::GetName($sClass), 'read' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Read'), 'bulkread' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Read'), 'write' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Modify'), 'bulkwrite' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Modify'), 'delete' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Delete'), 'bulkdelete' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Delete'), 'stimuli' => $sStimuli);
     }
     $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['delete'] = array('label' => Dict::S('UI:UserManagement:Action:Delete'), 'description' => Dict::S('UI:UserManagement:Action:Delete+'));
     $aDisplayConfig['bulkdelete'] = array('label' => Dict::S('UI:UserManagement:Action:BulkDelete'), 'description' => Dict::S('UI:UserManagement:Action:BulkDelete+'));
     $aDisplayConfig['stimuli'] = array('label' => Dict::S('UI:UserManagement:Action:Stimuli'), 'description' => Dict::S('UI:UserManagement:Action:Stimuli+'));
     $oPage->table($aDisplayConfig, $aDisplayData);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:36,代码来源:userrightsprojection.class.inc.php

示例2: GetClassesSelect

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

示例3: GetClasses

 public function GetClasses($sCategories = '', $bExcludeLinks = false)
 {
     $aClasses = MetaModel::GetClasses($sCategories);
     if ($bExcludeLinks) {
         $aExcluded = MetaModel::GetLinkClasses();
         $aRes = array();
         foreach ($aClasses as $sClass) {
             if (!array_key_exists($sClass, $aExcluded)) {
                 $aRes[] = $sClass;
             }
         }
     } else {
         $aRes = $aClasses;
     }
     return $aRes;
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:16,代码来源:modelreflection.class.inc.php

示例4: array

 $aFullTextNeedles = utils::ReadParam('needles', array(), false, 'raw_data');
 $sFullText = trim(implode(' ', $aFullTextNeedles));
 $sClassName = utils::ReadParam('class', '');
 $iCount = utils::ReadParam('count', 0);
 $iCurrentPos = utils::ReadParam('position', 0);
 $iTune = utils::ReadParam('tune', 0);
 if (empty($sFullText)) {
     $oPage->p(Dict::S('UI:Search:NoSearch'));
     break;
 }
 // Search in full text mode in all the classes
 $aMatches = array();
 // 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);
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:ajax.render.php

示例5: SetupUser

 protected function SetupUser($iUserId, $bNewUser = false)
 {
     foreach (array('bizmodel', 'application', 'gui', 'core/cmdb') as $sCategory) {
         foreach (MetaModel::GetClasses($sCategory) as $sClass) {
             foreach (self::$m_aActionCodes as $iActionCode => $sAction) {
                 if ($bNewUser) {
                     $bAddCell = true;
                 } else {
                     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassGrant WHERE class = '{$sClass}' AND action = '{$sAction}' AND userid = {$iUserId}"));
                     $bAddCell = $oSet->Count() < 1;
                 }
                 if ($bAddCell) {
                     // Create a new entry
                     $oMyClassGrant = MetaModel::NewObject("UserRightsMatrixClassGrant");
                     $oMyClassGrant->Set("userid", $iUserId);
                     $oMyClassGrant->Set("class", $sClass);
                     $oMyClassGrant->Set("action", $sAction);
                     $oMyClassGrant->Set("permission", "yes");
                     $iId = $oMyClassGrant->DBInsertNoReload();
                 }
             }
             foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) {
                 if ($bNewUser) {
                     $bAddCell = true;
                 } else {
                     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassStimulusGrant WHERE class = '{$sClass}' AND stimulus = '{$sStimulusCode}' AND userid = {$iUserId}"));
                     $bAddCell = $oSet->Count() < 1;
                 }
                 if ($bAddCell) {
                     // Create a new entry
                     $oMyClassGrant = MetaModel::NewObject("UserRightsMatrixClassStimulusGrant");
                     $oMyClassGrant->Set("userid", $iUserId);
                     $oMyClassGrant->Set("class", $sClass);
                     $oMyClassGrant->Set("stimulus", $sStimulusCode);
                     $oMyClassGrant->Set("permission", "yes");
                     $iId = $oMyClassGrant->DBInsertNoReload();
                 }
             }
             foreach (MetaModel::GetAttributesList($sClass) as $sAttCode) {
                 if ($bNewUser) {
                     $bAddCell = true;
                 } else {
                     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixAttributeGrant WHERE class = '{$sClass}' AND attcode = '{$sAttCode}' AND userid = {$iUserId}"));
                     $bAddCell = $oSet->Count() < 1;
                 }
                 if ($bAddCell) {
                     foreach (array('read', 'modify') as $sAction) {
                         // Create a new entry
                         $oMyAttGrant = MetaModel::NewObject("UserRightsMatrixAttributeGrant");
                         $oMyAttGrant->Set("userid", $iUserId);
                         $oMyAttGrant->Set("class", $sClass);
                         $oMyAttGrant->Set("attcode", $sAttCode);
                         $oMyAttGrant->Set("action", $sAction);
                         $oMyAttGrant->Set("permission", "yes");
                         $iId = $oMyAttGrant->DBInsertNoReload();
                     }
                 }
             }
         }
     }
     /*
     // Create the "My Bookmarks" menu item (parent_id = 0, rank = 6)
     if ($bNewUser)
     {
     	$bAddMenu = true;
     }
     else
     {
     	$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT menuNode WHERE type = 'user' AND parent_id = 0 AND user_id = $iUserId"));
     	$bAddMenu = ($oSet->Count() < 1);
     }
     if ($bAddMenu)
     {
     	$oMenu = MetaModel::NewObject('menuNode');
     	$oMenu->Set('type', 'user');
     	$oMenu->Set('parent_id', 0);	// It's a toplevel entry
     	$oMenu->Set('rank', 6);			// Located just above the Admin Tools section (=7)
     	$oMenu->Set('name', 'My Bookmarks');
     	$oMenu->Set('label', 'My Favorite Items');
     	$oMenu->Set('hyperlink', 'UI.php');
     	$oMenu->Set('template', '<p></p><p></p><p style="text-align:center; font-family:Georgia, Times, serif; font-size:32px;">My bookmarks</p><p style="text-align:center; font-family:Georgia, Times, serif; font-size:14px;"><i>This section contains my most favorite search results</i></p>');
     	$oMenu->Set('user_id', $iUserId);
     	$oMenu->DBInsert();
     }
     */
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:86,代码来源:userrightsmatrix.class.inc.php

示例6: DoExecute

 protected function DoExecute()
 {
     foreach (MetaModel::GetClasses() as $sClassName) {
         if (MetaModel::HasTable($sClassName)) {
             continue;
         }
         $oNobody = MetaModel::GetObject($sClassName, 123);
         $oBaby = new $sClassName();
         $oFilter = new DBObjectSearch($sClassName);
         // Challenge reversibility of OQL / filter object
         //
         $sExpr1 = $oFilter->ToOQL();
         $oNewFilter = DBObjectSearch::FromOQL($sExpr1);
         $sExpr2 = $oNewFilter->ToOQL();
         if ($sExpr1 != $sExpr2) {
             $this->ReportError("Found two different OQL expression out of the (same?) filter: <em>{$sExpr1}</em> != <em>{$sExpr2}</em>");
         }
         // Use the filter (perform the query)
         //
         $oSet = new CMDBObjectSet($oFilter);
         $this->ReportSuccess('Found ' . $oSet->Count() . " objects of class {$sClassName}");
     }
     return true;
 }
开发者ID:henryavila,项目名称:itop,代码行数:24,代码来源:test.class.inc.php

示例7: DisplayRelationDetails

/**
 * Display the details of a given relation (e.g. "impacts")
 */
function DisplayRelationDetails($oPage, $sRelCode, $sContext)
{
    $sDesc = MetaModel::GetRelationDescription($sRelCode);
    $sVerbDown = MetaModel::GetRelationVerbDown($sRelCode);
    $sVerbUp = MetaModel::GetRelationVerbUp($sRelCode);
    $oPage->add("<h1>" . Dict::Format('UI:Schema:Relation_Code_Description', $sRelCode, $sDesc) . "</h1>");
    $oPage->p(Dict::Format('UI:Schema:RelationDown_Description', $sVerbDown));
    $oPage->p(Dict::Format('UI:Schema:RelationUp_Description', $sVerbUp));
    $oPage->add("<ul id=\"RelationshipDetails\" class=\"treeview\">\n");
    foreach (MetaModel::GetClasses() as $sClass) {
        $aRelQueries = MetaModel::EnumRelationQueries($sClass, $sRelCode);
        if (count($aRelQueries) > 0) {
            $oPage->add("<li>class " . MakeClassHLink($sClass, $sContext) . "\n");
            $oPage->add("<ul>\n");
            foreach ($aRelQueries as $sRelKey => $aQuery) {
                $sQuery = $aQuery['sQuery'];
                $iDistance = $aQuery['iDistance'];
                if ($aQuery['bPropagate']) {
                    $oPage->add("<li>" . Dict::Format('UI:Schema:RelationPropagates', $sRelKey, $iDistance, $sQuery) . "</li>\n");
                } else {
                    $oPage->add("<li>" . Dict::Format('UI:Schema:RelationDoesNotPropagate', $sRelKey, $iDistance, $sQuery) . "</li>\n");
                }
            }
            $oPage->add("</ul>\n");
            $oPage->add("</li>\n");
        }
    }
    $oPage->add_ready_script('$("#RelationshipDetails").treeview();');
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:32,代码来源:schema.php

示例8: DoShowGrantSumary

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

示例9: LoadValues

 protected function LoadValues($aArgs)
 {
     // Call the parent to parse the additional values...
     parent::LoadValues($aArgs);
     // Translate the labels of the additional values
     foreach ($this->m_aValues as $sClass => $void) {
         if (MetaModel::IsValidClass($sClass)) {
             $this->m_aValues[$sClass] = MetaModel::GetName($sClass);
         } else {
             unset($this->m_aValues[$sClass]);
         }
     }
     // Then, add the classes from the category definition
     foreach (MetaModel::GetClasses($this->m_sCategories) as $sClass) {
         if (MetaModel::IsValidClass($sClass)) {
             $this->m_aValues[$sClass] = MetaModel::GetName($sClass);
         } else {
             unset($this->m_aValues[$sClass]);
         }
     }
     return true;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:22,代码来源:valuesetdef.class.inc.php

示例10: DisplayRelationDetails

/**
 * Display the details of a given relation (e.g. "impacts")
 */
function DisplayRelationDetails($oPage, $sRelCode, $sContext)
{
    $sDesc = MetaModel::GetRelationDescription($sRelCode);
    $sLabel = MetaModel::GetRelationLabel($sRelCode);
    $oPage->add("<h1>" . Dict::Format('UI:Schema:Relation_Code_Description', $sRelCode, $sDesc) . "</h1>");
    $oPage->p(Dict::Format('UI:Schema:RelationUp_Description', $sLabel));
    $oPage->add("<ul id=\"RelationshipDetails\" class=\"treeview\">\n");
    foreach (MetaModel::GetClasses() as $sClass) {
        $aRelQueries = MetaModel::EnumRelationQueries($sClass, $sRelCode);
        if (count($aRelQueries) > 0) {
            $oPage->add("<li>class " . MakeClassHLink($sClass, $sContext) . "\n");
            $oPage->add("<ul>\n");
            foreach ($aRelQueries as $sRelKey => $aQuery) {
                $sQueryDown = isset($aQuery['sQueryDown']) ? $aQuery['sQueryDown'] : '';
                $sQueryUp = isset($aQuery['sQueryUp']) ? $aQuery['sQueryUp'] : '';
                $sAttribute = isset($aQuery['sAttribute']) ? $aQuery['sAttribute'] : '';
                /*
                if ($aQuery['bPropagate'])
                {
                	$oPage->add("<li>".Dict::Format('UI:Schema:RelationPropagates', $sRelKey, $iDistance, $sQuery)."</li>\n");
                }
                else
                {
                	$oPage->add("<li>".Dict::Format('UI:Schema:RelationDoesNotPropagate', $sRelKey, $iDistance, $sQuery)."</li>\n");
                }
                */
                $sLabel = strlen($sQueryDown) > 0 ? $sQueryDown : $sAttribute;
                if ($aQuery['_legacy_']) {
                    $sLabel .= ' (<b>Old style specification</b>: it is recommended to upgrade to XML)';
                }
                $oPage->add("<li>" . $sLabel . "</li>\n");
            }
            $oPage->add("</ul>\n");
            $oPage->add("</li>\n");
        }
    }
    $oPage->add_ready_script('$("#RelationshipDetails").treeview();');
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:41,代码来源:schema.php

示例11: MakeDictionaryTemplate

function MakeDictionaryTemplate($sModules = '', $sLanguage = 'EN US')
{
    $sRes = '';
    Dict::SetDefaultLanguage($sLanguage);
    $aAvailableLanguages = Dict::GetLanguages();
    $sDesc = $aAvailableLanguages[$sLanguage]['description'];
    $sLocalizedDesc = $aAvailableLanguages[$sLanguage]['localized_description'];
    $sRes .= "// Dictionary conventions\n";
    $sRes .= htmlentities("// Class:<class_name>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>\n", ENT_QUOTES, 'UTF-8');
    $sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>+\n", ENT_QUOTES, 'UTF-8');
    $sRes .= "\n";
    // Note: I did not use EnumCategories(), because a given class maybe found in several categories
    // Need to invent the "module", to characterize the origins of a class
    if (strlen($sModules) == 0) {
        $aModules = array('bizmodel', 'core/cmdb', 'gui', 'application', 'addon/userrights', 'monitoring');
    } else {
        $aModules = explode(', ', $sModules);
    }
    $sRes .= "//////////////////////////////////////////////////////////////////////\n";
    $sRes .= "// Note: The classes have been grouped by categories: " . implode(', ', $aModules) . "\n";
    $sRes .= "//////////////////////////////////////////////////////////////////////\n";
    foreach ($aModules as $sCategory) {
        $sRes .= "//////////////////////////////////////////////////////////////////////\n";
        $sRes .= "// Classes in '{$sCategory}'\n";
        $sRes .= "//////////////////////////////////////////////////////////////////////\n";
        $sRes .= "//\n";
        $sRes .= "\n";
        foreach (MetaModel::GetClasses($sCategory) as $sClass) {
            if (!MetaModel::HasTable($sClass)) {
                continue;
            }
            $bNotInDico = false;
            $bNotImportant = true;
            $sClassRes = "//\n";
            $sClassRes .= "// Class: {$sClass}\n";
            $sClassRes .= "//\n";
            $sClassRes .= "\n";
            $sClassRes .= "Dict::Add('{$sLanguage}', '{$sDesc}', '{$sLocalizedDesc}', array(\n";
            $sClassRes .= MakeDictEntry("Class:{$sClass}", MetaModel::GetName_Obsolete($sClass), $sClass, $bNotInDico);
            $sClassRes .= MakeDictEntry("Class:{$sClass}+", MetaModel::GetClassDescription_Obsolete($sClass), '', $bNotImportant);
            foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                if ($sAttCode == 'friendlyname') {
                    continue;
                }
                // Skip this attribute if not originaly defined in this class
                if (MetaModel::GetAttributeOrigin($sClass, $sAttCode) != $sClass) {
                    continue;
                }
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}", $oAttDef->GetLabel_Obsolete(), $sAttCode, $bNotInDico);
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}+", $oAttDef->GetDescription_Obsolete(), '', $bNotImportant);
                if ($oAttDef instanceof AttributeEnum) {
                    if (MetaModel::GetStateAttributeCode($sClass) == $sAttCode) {
                        foreach (MetaModel::EnumStates($sClass) as $sStateCode => $aStateData) {
                            if (array_key_exists('label', $aStateData)) {
                                $sValue = $aStateData['label'];
                            } else {
                                $sValue = MetaModel::GetStateLabel($sClass, $sStateCode);
                            }
                            if (array_key_exists('description', $aStateData)) {
                                $sValuePlus = $aStateData['description'];
                            } else {
                                $sValuePlus = MetaModel::GetStateDescription($sClass, $sStateCode);
                            }
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}", $sValue, '', $bNotInDico);
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}+", $sValuePlus, '', $bNotImportant);
                        }
                    } else {
                        foreach ($oAttDef->GetAllowedValues() as $sKey => $value) {
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}", $value, '', $bNotInDico);
                            $sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}+", $value, '', $bNotImportant);
                        }
                    }
                }
            }
            foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) {
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}", $oStimulus->GetLabel_Obsolete(), '', $bNotInDico);
                $sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}+", $oStimulus->GetDescription_Obsolete(), '', $bNotImportant);
            }
            $sClassRes .= "));\n";
            $sClassRes .= "\n";
            $sRes .= $sClassRes;
        }
    }
    return $sRes;
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:91,代码来源:ajax.toolkit.php

示例12: CreateStructure

 public function CreateStructure($oP)
 {
     $aClasses = MetaModel::GetClasses();
     $aActions = array('Read', 'Bulk Read', 'Delete', 'Bulk Delete', 'Modify', 'Bulk Modify');
     $aStdProfiles = array(2, 3, 4, 5, 6, 7, 8, 9);
     ////////////////////////////////////////
     // New specific profile, giving access to everything
     //
     $aData = array('name' => 'Data guru', 'description' => 'Could do anything, because everything is granted');
     $iGuruProfile = $this->CreateObject('URP_Profiles', $aData);
     foreach ($aClasses as $sClass) {
         foreach ($aActions as $sAction) {
             $aData = array('profileid' => $iGuruProfile, 'class' => $sClass, 'permission' => 'yes', 'action' => $sAction);
             $this->CreateObject('URP_ActionGrant', $aData);
         }
     }
     // User login with super access rights
     //
     $aData = array('org_id' => self::FindId('Organization'), 'location_id' => self::FindId('Location'), 'first_name' => 'Jesus', 'name' => 'Deus', 'email' => 'guru@combodo.com');
     $iPerson = $this->CreateObject('Person', $aData);
     $aData = array('contactid' => $iPerson, 'login' => 'guru', 'password' => 'guru', 'language' => 'EN US', 'profile_list' => array("profileid:{$iGuruProfile};reason:he is the one"));
     $iLogin = $this->CreateObject('UserLocal', $aData);
     ////////////////////////////////////////
     // User login having all std profiles
     //
     $aData = array('org_id' => self::FindId('Organization'), 'location_id' => self::FindId('Location'), 'first_name' => 'Little ze', 'name' => 'Foo', 'email' => 'foo@combodo.com');
     $iPerson = $this->CreateObject('Person', $aData);
     $aProfileSet = array();
     foreach ($aStdProfiles as $iProfileId) {
         $aProfileSet[] = "profileid:{$iProfileId};reason:xxx";
     }
     $aData = array('contactid' => $iPerson, 'login' => 'foo', 'password' => 'foo', 'language' => 'EN US', 'profile_list' => $aProfileSet);
     $iLogin = $this->CreateObject('UserLocal', $aData);
     /////////////////////////
     //
     // Organizations
     //
     $aData = array('name' => 'Benchmark');
     $iOrg = $this->CreateObject('Organization', $aData);
     /////////////////////////
     //
     // Locations
     //
     $aData = array('org_id' => $iOrg, 'name' => 'Rio de Janeiro');
     $iLoc = $this->CreateObject('Location', $aData);
     /////////////////////////
     //
     // Teams
     //
     $aData = array('org_id' => $iOrg, 'location_id' => $iLoc, 'name' => 'Fluminense', 'email' => 'fluminense@combodo.com');
     $iTeam = $this->CreateObject('Team', $aData);
     /////////////////////////
     //
     // Persons
     //
     for ($i = 0; $i < $this->m_aPlanned['Contacts']; $i++) {
         $aData = array('org_id' => $iOrg, 'location_id' => $iLoc, 'first_name' => 'Joaõ', 'name' => 'Ningem #' . $i, 'email' => 'foo' . $i . '@nowhere.fr');
         $iPerson = $this->CreateObject('Person', $aData);
         // Contract/Infra
         //
         $aData = array('contact_id' => $iPerson, 'team_id' => $this->RandomId('Team'));
         $this->CreateObject('lnkTeamToContact', $aData);
     }
     /////////////////////////
     //
     // Services
     //
     $aData = array('org_id' => $iOrg, 'name' => 'My Service');
     $iService = $this->CreateObject('Service', $aData);
     /////////////////////////
     //
     // Service subcategories
     //
     $aData = array('name' => 'My subcategory', 'service_id' => $iService);
     $iOrg = $this->CreateObject('ServiceSubcategory', $aData);
     /////////////////////////
     //
     // Contracts
     //
     for ($i = 0; $i < $this->m_aPlanned['Contracts']; $i++) {
         $aData = array('name' => "Contract #{$i}", 'description' => 'Created for benchmarking purposes', 'org_id' => $this->RandomId('Organization'), 'provider_id' => $this->RandomId('Organization'), 'start_date' => '2009-12-25', 'end_date' => '2019-08-01', 'support_team_id' => $this->RandomId('Team'));
         $iContract = $this->CreateObject('CustomerContract', $aData);
         // Contract/Contact (10% of contacts)
         //
         $iContactCount = ceil($this->m_aPlanned['Contracts'] / 10);
         for ($iLinked = 0; $iLinked < $iContactCount; $iLinked++) {
             $aData = array('contact_id' => $this->RandomId('Person'), 'contract_id' => $iContract, 'role' => 'role ' . $iLinked);
             $this->CreateObject('lnkContractToContact', $aData);
         }
     }
     /////////////////////////
     //
     // Documents
     //
     $sMyDoc = '';
     for ($i = 0; $i < 1000; $i++) {
         // 100 chars
         $sMyDoc .= "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n";
     }
     $oRefDoc = new ormDocument($sMyDoc, 'text/plain');
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:benchmark.php

示例13: DoExecute

 protected function DoExecute()
 {
     $aQueries = array('SELECT Person AS PP WHERE PP.friendlyname LIKE "%dali"', 'SELECT Person AS PP WHERE PP.location_id_friendlyname LIKE "%ce ch%"', 'SELECT Organization AS OO JOIN Person AS PP ON PP.org_id = OO.id', 'SELECT lnkPersonToTeam AS lnk JOIN Team AS T ON lnk.team_id = T.id', 'SELECT lnkPersonToTeam AS lnk JOIN Team AS T ON lnk.team_id = T.id JOIN Person AS p ON lnk.person_id = p.id', 'SELECT UserRequest AS ur JOIN Person ON ur.agent_id = Person.id WHERE Person.id = 5');
     foreach (MetaModel::GetClasses() as $sClass) {
         $aQueries[] = 'SELECT ' . $sClass;
         $aQueries[] = 'SELECT ' . $sClass . ' AS zz';
         $aQueries[] = 'SELECT ' . $sClass . ' AS zz WHERE id = 1';
     }
     $aStats = array();
     foreach ($aQueries as $sOQL) {
         $aStats[$sOQL] = $this->DoBenchmark($sOQL);
     }
     $aData = array();
     foreach ($aStats as $sOQL => $aResults) {
         $aValues = array();
         $aValues['OQL'] = htmlentities($sOQL, ENT_QUOTES, 'UTF-8');
         foreach ($aResults as $sDesc => $sInfo) {
             $aValues[$sDesc] = htmlentities($sInfo, ENT_QUOTES, 'UTF-8');
         }
         $aData[] = $aValues;
     }
     echo MyHelpers::make_table_from_assoc_array($aData);
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:23,代码来源:testlist.inc.php

示例14: UpdatePredefinedObjects

 public function UpdatePredefinedObjects()
 {
     // Constant classes (e.g. User profiles)
     //
     foreach (MetaModel::GetClasses() as $sClass) {
         $aPredefinedObjects = call_user_func(array($sClass, 'GetPredefinedObjects'));
         if ($aPredefinedObjects != null) {
             $this->log_info("{$sClass}::GetPredefinedObjects() returned " . count($aPredefinedObjects) . " elements.");
             // Create/Delete/Update objects of this class,
             // according to the given constant values
             //
             $aDBIds = array();
             $oAll = new DBObjectSet(new DBObjectSearch($sClass));
             while ($oObj = $oAll->Fetch()) {
                 if (array_key_exists($oObj->GetKey(), $aPredefinedObjects)) {
                     $aObjValues = $aPredefinedObjects[$oObj->GetKey()];
                     foreach ($aObjValues as $sAttCode => $value) {
                         $oObj->Set($sAttCode, $value);
                     }
                     $oObj->DBUpdate();
                     $aDBIds[$oObj->GetKey()] = true;
                 } else {
                     $oObj->DBDelete();
                 }
             }
             foreach ($aPredefinedObjects as $iRefId => $aObjValues) {
                 if (!array_key_exists($iRefId, $aDBIds)) {
                     $oNewObj = MetaModel::NewObject($sClass);
                     $oNewObj->SetKey($iRefId);
                     foreach ($aObjValues as $sAttCode => $value) {
                         $oNewObj->Set($sAttCode, $value);
                     }
                     $oNewObj->DBInsert();
                 }
             }
         }
     }
 }
开发者ID:ucbpi,项目名称:itop,代码行数:38,代码来源:runtimeenv.class.inc.php

示例15: Process

 public function Process($iTimeLimit)
 {
     $aList = array();
     foreach (MetaModel::GetClasses() as $sClass) {
         foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
             if ($oAttDef instanceof AttributeStopWatch) {
                 foreach ($oAttDef->ListThresholds() as $iThreshold => $aThresholdData) {
                     $iPercent = $aThresholdData['percent'];
                     // could be different than the index !
                     $sNow = date('Y-m-d H:i:s');
                     $sExpression = "SELECT {$sClass} WHERE {$sAttCode}_laststart AND {$sAttCode}_{$iThreshold}_triggered = 0 AND {$sAttCode}_{$iThreshold}_deadline < '{$sNow}'";
                     $oFilter = DBObjectSearch::FromOQL($sExpression);
                     $oSet = new DBObjectSet($oFilter);
                     while (time() < $iTimeLimit && ($oObj = $oSet->Fetch())) {
                         $sClass = get_class($oObj);
                         $aList[] = $sClass . '::' . $oObj->GetKey() . ' ' . $sAttCode . ' ' . $iThreshold;
                         // Execute planned actions
                         //
                         foreach ($aThresholdData['actions'] as $aActionData) {
                             $sVerb = $aActionData['verb'];
                             $aParams = $aActionData['params'];
                             $aValues = array();
                             foreach ($aParams as $def) {
                                 if (is_string($def)) {
                                     // Old method (pre-2.1.0) non typed parameters
                                     $aValues[] = $def;
                                 } else {
                                     $sParamType = array_key_exists('type', $def) ? $def['type'] : 'string';
                                     switch ($sParamType) {
                                         case 'int':
                                             $value = (int) $def['value'];
                                             break;
                                         case 'float':
                                             $value = (double) $def['value'];
                                             break;
                                         case 'bool':
                                             $value = (bool) $def['value'];
                                             break;
                                         case 'reference':
                                             $value = ${$def['value']};
                                             break;
                                         case 'string':
                                         default:
                                             $value = (string) $def['value'];
                                     }
                                     $aValues[] = $value;
                                 }
                             }
                             $aCallSpec = array($oObj, $sVerb);
                             call_user_func_array($aCallSpec, $aValues);
                         }
                         // Mark the threshold as "triggered"
                         //
                         $oSW = $oObj->Get($sAttCode);
                         $oSW->MarkThresholdAsTriggered($iThreshold);
                         $oObj->Set($sAttCode, $oSW);
                         if ($oObj->IsModified()) {
                             CMDBObject::SetTrackInfo("Automatic - threshold triggered");
                             $oMyChange = CMDBObject::GetCurrentChange();
                             $oObj->DBUpdateTracked($oMyChange, true);
                         }
                         // Activate any existing trigger
                         //
                         $sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
                         $oTriggerSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnThresholdReached AS t WHERE t.target_class IN ('{$sClassList}') AND stop_watch_code=:stop_watch_code AND threshold_index = :threshold_index"), array(), array('stop_watch_code' => $sAttCode, 'threshold_index' => $iThreshold));
                         while ($oTrigger = $oTriggerSet->Fetch()) {
                             $oTrigger->DoActivate($oObj->ToArgs('this'));
                         }
                     }
                 }
             }
         }
     }
     $iProcessed = count($aList);
     return "Triggered {$iProcessed} threshold(s):" . implode(", ", $aList);
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:76,代码来源:ormstopwatch.class.inc.php


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