public static function getExportDatasetName ( $datasetName, MetaModel $metamodel ) {
        $logicalDatasetName = StarSchemaNamingConvention::findFactsOwner($datasetName);

        if (isset($logicalDatasetName)) {
            $dataset = $metamodel->getDataset($logicalDatasetName);
            return isset($dataset->uuid) ? StarSchemaNamingConvention::getFactsRelatedName($dataset->uuid) : null;
        } else {
            $dataset = $metamodel->getDataset($datasetName);
            return isset($dataset->uuid) ? $dataset->uuid : null;
        }
    }
 public function prepareDimension(MetaModel $metamodel, DatasetMetaData $dataset, $columnName, CubeMetaData $cube)
 {
     $column = $dataset->getColumn($columnName);
     $sourceDatasetColumn = $cube->sourceDataset->getColumn($columnName);
     $dimension = $cube->getDimension($columnName);
     $this->prepareYearLevel($dimension, $column);
     // cube source dataset column contains a reference to year identifier
     $sourceDatasetColumn->initializeTypeFrom(Sequence::getSequenceColumnType());
     // adding a reference to date dataset
     $referenceName = DateDimensionDatasetNames::LEVEL_YEARS;
     $metamodel->registerSimpleReferencePoint($referenceName, DateDimensionDatasetNames::LEVEL_YEARS, 'year_id');
     $metamodel->registerSimpleReferencePoint($referenceName, $cube->sourceDatasetName, $columnName);
 }
 public static function Init()
 {
     $aParams = array("category" => "application", "key_type" => "autoincrement", "name_attcode" => "name", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_iotask", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values" => null, "sql" => "name", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values" => null, "sql" => "description", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("category", array("allowed_values" => new ValueSetEnum('Input, Ouput'), "sql" => "category", "default_value" => "Input", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("allowed_values" => new ValueSetEnum('File, Database, Web Service'), "sql" => "source_type", "default_value" => "File", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("allowed_values" => new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql" => "source_subtype", "default_value" => "CSV", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeString("source_path", array("allowed_values" => null, "sql" => "source_path", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeClass("objects_class", array("class_category" => "", "more_values" => "", "sql" => "objects_class", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("allowed_values" => new ValueSetEnum('Yes,No'), "sql" => "test_mode", "default_value" => 'No', "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("allowed_values" => new ValueSetEnum('Yes,No'), "sql" => "verbose_mode", "default_value" => 'No', "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("options", array("allowed_values" => new ValueSetEnum('Full, Update Only, Creation Only'), "sql" => "options", "default_value" => 'Full', "is_null_allowed" => true, "depends_on" => array())));
     // Display lists
     MetaModel::Init_SetZListItems('details', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype', 'source_path', 'options', 'test_mode', 'verbose_mode'));
     // Attributes to be displayed for the complete details
     MetaModel::Init_SetZListItems('list', array('description', 'category', 'objects_class', 'source_type', 'source_subtype', 'options'));
     // Attributes to be displayed for a list
     // Search criteria
     MetaModel::Init_SetZListItems('standard_search', array('name', 'category', 'objects_class', 'source_type', 'source_subtype'));
     // Criteria of the std search form
     MetaModel::Init_SetZListItems('advanced_search', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype'));
     // Criteria of the advanced search form
 }
 /**
  * Find the lowest common ancestor for each of the selected class
  */
 protected function ComputeSelectedClasses()
 {
     // 1 - Collect all the column/classes
     $aColumnToClasses = array();
     foreach ($this->aSearches as $iPos => $oSearch) {
         $aSelected = array_values($oSearch->GetSelectedClasses());
         if ($iPos != 0) {
             if (count($aSelected) < count($aColumnToClasses)) {
                 throw new Exception('Too few selected classes in the subquery #' . ($iPos + 1));
             }
             if (count($aSelected) > count($aColumnToClasses)) {
                 throw new Exception('Too many selected classes in the subquery #' . ($iPos + 1));
             }
         }
         foreach ($aSelected as $iColumn => $sClass) {
             $aColumnToClasses[$iColumn][] = $sClass;
         }
     }
     // 2 - Build the index column => alias
     $oFirstSearch = $this->aSearches[0];
     $aColumnToAlias = array_keys($oFirstSearch->GetSelectedClasses());
     // 3 - Compute alias => lowest common ancestor
     $this->aSelectedClasses = array();
     foreach ($aColumnToClasses as $iColumn => $aClasses) {
         $sAlias = $aColumnToAlias[$iColumn];
         $sAncestor = MetaModel::GetLowestCommonAncestor($aClasses);
         if (is_null($sAncestor)) {
             throw new Exception('Could not find a common ancestor for the column ' . ($iColumn + 1) . ' (Classes: ' . implode(', ', $aClasses) . ')');
         }
         $this->aSelectedClasses[$sAlias] = $sAncestor;
     }
 }
Example #5
0
function GetRuleResultFilter($iRuleId, $oDefinitionFilter, $oAppContext)
{
    $oRule = MetaModel::GetObject('AuditRule', $iRuleId);
    $sOql = $oRule->Get('query');
    $oRuleFilter = DBObjectSearch::FromOQL($sOql);
    FilterByContext($oRuleFilter, $oAppContext);
    // Not needed since this filter is a subset of the definition filter, but may speedup things
    if ($oRule->Get('valid_flag') == 'false') {
        // The query returns directly the invalid elements
        $oFilter = $oRuleFilter->Intersect($oDefinitionFilter);
    } else {
        // The query returns only the valid elements, all the others are invalid
        $aValidRows = $oRuleFilter->ToDataArray(array('id'));
        $aValidIds = array();
        foreach ($aValidRows as $aRow) {
            $aValidIds[] = $aRow['id'];
        }
        $oFilter = $oDefinitionFilter->DeepClone();
        if (count($aValidIds) > 0) {
            $aInDefSet = array();
            foreach ($oDefinitionFilter->ToDataArray(array('id')) as $aRow) {
                $aInDefSet[] = $aRow['id'];
            }
            $aInvalids = array_diff($aInDefSet, $aValidIds);
            if (count($aInvalids) > 0) {
                $oFilter->AddCondition('id', $aInvalids, 'IN');
            } else {
                $oFilter->AddCondition('id', 0, '=');
            }
        }
    }
    return $oFilter;
}
 /**
  * Split the string into placholders
  * @param Hash $aParamTypes Class of the expected parameters: hash array of '<param_id>' => '<class_name>'
  * @return void
  */
 protected function Analyze($aParamTypes = array())
 {
     if (!is_null($this->m_aPlaceholders)) {
         return;
     }
     $this->m_aPlaceholders = array();
     if (preg_match_all('/\\$([a-z0-9_]+(->[a-z0-9_]+)*)\\$/', $this->m_sRaw, $aMatches)) {
         foreach ($aMatches[1] as $sPlaceholder) {
             $oPlaceholder = new TemplateStringPlaceholder($sPlaceholder);
             $oPlaceholder->bIsValid = false;
             foreach ($aParamTypes as $sParamName => $sClass) {
                 $sParamPrefix = $sParamName . '->';
                 if (substr($sPlaceholder, 0, strlen($sParamPrefix)) == $sParamPrefix) {
                     // Todo - detect functions (label...)
                     $oPlaceholder->sFunction = '';
                     $oPlaceholder->sParamName = $sParamName;
                     $sAttcode = substr($sPlaceholder, strlen($sParamPrefix));
                     $oPlaceholder->sAttcode = $sAttcode;
                     $oPlaceholder->bIsValid = MetaModel::IsValidAttCode($sClass, $sAttcode, true);
                 }
             }
             $this->m_aPlaceholders[] = $oPlaceholder;
         }
     }
 }
 public static function Init()
 {
     $aParams = array("category" => "gui", "key_type" => "autoincrement", "name_attcode" => "user_id", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_app_dashboards", "db_key_field" => "id", "db_finalclass_field" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("targetclass" => "User", "allowed_values" => null, "sql" => "user_id", "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeString("menu_code", array("allowed_values" => null, "sql" => "menu_code", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeText("contents", array("allowed_values" => null, "sql" => "contents", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
 }
    public function findCube($cubeName, $localOnly = FALSE) {
        $cube = parent::findCube($cubeName);
        if (!isset($cube) && !$localOnly) {
            $cube = $this->parentMetaModel->findCube($cubeName);
        }

        return $cube;
    }
 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;
 }
 public function output()
 {
     if (class_exists('MetaModel')) {
         MetaModel::RecordQueryTrace();
     }
     if (class_exists('ExecutionKPI')) {
         ExecutionKPI::ReportStats();
     }
 }
 public static function GetProfileActionGrant($iProfileId, $sClass, $sAction)
 {
     // Search for a grant, starting from the most explicit declaration,
     // then searching for less and less explicit declaration
     // 1 - The class itself
     //
     $sGrantKey = $iProfileId . '_' . $sClass . '_' . $sAction;
     if (isset(self::$aGRANTS[$sGrantKey])) {
         return self::$aGRANTS[$sGrantKey];
     }
     // 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])) {
             return self::$aGRANTS[$sGrantKey];
         }
     }
     // 3 - The related classes (if the current is an N-N link with AUTO_DEL)
     //
     if (array_key_exists($sClass, self::$aLINKTOCLASSES)) {
         // Get the grant for the remote classes. The resulting grant is:
         // - One YES => YES
         // - 100% undefined => undefined
         // - otherwise => NO
         //
         // Having write allowed on the remote class implies write + delete on the N-N link class
         if ($sAction == 'd') {
             $sRemoteAction = 'w';
         } elseif ($sAction == 'bd') {
             $sRemoteAction = 'bw';
         } else {
             $sRemoteAction = $sAction;
         }
         foreach (self::$aLINKTOCLASSES[$sClass] as $sRemoteClass) {
             $bUndefined = true;
             $bGrant = self::GetProfileActionGrant($iProfileId, $sRemoteClass, $sAction);
             if ($bGrant === true) {
                 return true;
             }
             if ($bGrant === false) {
                 $bUndefined = false;
             }
         }
         if (!$bUndefined) {
             return false;
         }
     }
     // 4 - All
     //
     $sGrantKey = $iProfileId . '_*_' . $sAction;
     if (isset(self::$aGRANTS[$sGrantKey])) {
         return self::$aGRANTS[$sGrantKey];
     }
     // Still undefined for this class
     return null;
 }
 public static function Init()
 {
     $aParams = array("category" => "core/cmdb", "key_type" => "autoincrement", "name_attcode" => "date", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_change", "db_key_field" => "id", "db_finalclass_field" => "", 'indexes' => array(array('origin')));
     MetaModel::Init_Params($aParams);
     //MetaModel::Init_InheritAttributes();
     MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values" => null, "sql" => "date", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values" => null, "sql" => "userinfo", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("origin", array("allowed_values" => new ValueSetEnum('interactive,csv-interactive,csv-import.php,webservice-soap,webservice-rest,synchro-data-source,email-processing,custom-extension'), "sql" => "origin", "default_value" => "interactive", "is_null_allowed" => true, "depends_on" => array())));
 }
 /**
  * Helper to check wether the table has been created into the DB 
  * (this table did not exist in 1.0.1 and older versions)
  */
 public static function IsInstalled()
 {
     $sTable = MetaModel::DBGetTable(__CLASS__);
     if (CMDBSource::IsTable($sTable)) {
         return true;
     } else {
         return false;
     }
     return false;
 }
Example #14
0
File: Type.php Project: nabble/ajde
 /**
  * @param MetaModel $meta
  *
  * @return Ajde_Crud_Options_Fields_Field
  */
 protected function decorationFactory(MetaModel $meta)
 {
     $field = new Ajde_Crud_Options_Fields_Field();
     $field->setName('meta_' . $meta->getPK());
     $field->setType('text');
     $field->setLabel($meta->get('name'));
     if ($meta->getOption('help')) {
         $field->setHelp($meta->getOption('help'));
     }
     if ($meta->getOption('default')) {
         $field->setDefault($meta->getOption('default'));
     }
     if ($meta->getOption('readonly')) {
         $field->setIsReadonly(true);
     }
     $field->setLength($meta->getIntOption('length'));
     $field->setIsRequired($meta->getBooleanOption('required'));
     return $field;
 }
 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;
 }
 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;
 }
 public function encodeLangArray($varValue, MetaModel $objMetaModel)
 {
     // not translated, make it a plain string.
     if (!$objMetaModel->isTranslated()) {
         return $varValue;
     }
     $arrLangValues = deserialize($varValue);
     $arrOutput = array();
     foreach ($arrLangValues as $varSubValue) {
         $strLangCode = $varSubValue['langcode'];
         unset($varSubValue['langcode']);
         if (count($varSubValue) > 1) {
             $arrOutput[$strLangCode] = $varSubValue;
         } else {
             $arrKeys = array_keys($varSubValue);
             $arrOutput[$strLangCode] = $varSubValue[$arrKeys[0]];
         }
     }
     return serialize($arrOutput);
 }
Example #18
0
 public function beforeSave(MetaModel $meta, $value, Ajde_Model $model)
 {
     if ($value == 1) {
         // we need to publish this thing
         $stream = $meta->getOption('stream');
         $publisherClass = 'Ajde_Publisher_' . ucfirst($stream);
         /* @var $publisher Ajde_Publisher */
         $publisher = new $publisherClass();
         if (strtolower($stream) == 'twitter') {
             $publisher->setOptions(['consumerKey' => $meta->getOption('twitter_consumerkey'), 'consumerSecret' => $meta->getOption('twitter_consumersecret'), 'token' => $meta->getOption('twitter_token'), 'tokenSecret' => $meta->getOption('twitter_tokensecret')]);
         }
         if (strtolower($stream) == 'mail') {
             $addresses = $model->getPublishRecipients();
             $publisher->setRecipients($addresses);
         }
         // fill with content
         $publishData = $model->getPublishData();
         $publisher->setTitle($publishData['title']);
         $publisher->setMessage($publishData['message']);
         $publisher->setImage($publishData['image']);
         $publisher->setUrl($publishData['url']);
         $value = $publisher->publish();
     }
     return $value;
 }
 public static function Init()
 {
     $aParams = array('category' => 'bizmodel,configmgmt', 'key_type' => 'autoincrement', 'is_link' => true, 'name_attcode' => 'volume_id', 'state_attcode' => '', 'reconc_keys' => array(''), 'db_table' => 'lnkvirtualdevicetovolume', 'db_key_field' => 'id', 'db_finalclass_field' => '');
     MetaModel::Init_Params($aParams);
     MetaModel::Init_InheritAttributes();
     MetaModel::Init_AddAttribute(new AttributeExternalKey("volume_id", array("targetclass" => 'LogicalVolume', "allowed_values" => null, "sql" => 'volume_id', "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array(), "display_style" => 'select', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalField("volume_name", array("allowed_values" => null, "extkey_attcode" => 'volume_id', "target_attcode" => 'name', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalKey("virtualdevice_id", array("targetclass" => 'VirtualDevice', "allowed_values" => null, "sql" => 'virtualdevice_id', "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array(), "display_style" => 'select', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalField("virtualdevice_name", array("allowed_values" => null, "extkey_attcode" => 'virtualdevice_id', "target_attcode" => 'name', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeString("size_used", array("allowed_values" => null, "sql" => 'size_used', "default_value" => '', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_SetZListItems('details', array(0 => 'volume_id', 1 => 'virtualdevice_id', 2 => 'size_used'));
     MetaModel::Init_SetZListItems('standard_search', array(0 => 'volume_id', 1 => 'virtualdevice_id'));
     MetaModel::Init_SetZListItems('list', array(0 => 'volume_id', 1 => 'virtualdevice_id', 2 => 'size_used'));
 }
 public function output()
 {
     if (!$this->m_bPassThrough) {
         $this->s_content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?" . ">\n" . trim($this->s_content);
         $this->add_header("Content-Length: " . strlen($this->s_content));
         foreach ($this->a_headers as $s_header) {
             header($s_header);
         }
         echo $this->s_content;
     }
     if (class_exists('MetaModel')) {
         MetaModel::RecordQueryTrace();
     }
 }
 /**
  * Determines the shortest SLT, for this ticket, for the given metric. Returns null is no SLT was found
  * @param string $sMetric Type of metric 'TTO', 'TTR', etc as defined in the SLT class
  * @return hash Array with 'SLT' => name of the SLT selected, 'value' => duration in seconds of the SLT metric, null if no SLT applies to this ticket
  */
 protected static function ComputeSLT($oTicket, $sMetric = 'TTO')
 {
     $iDeadline = null;
     if (MetaModel::IsValidClass('SLT')) {
         $sType = get_class($oTicket);
         if ($sType == 'Incident') {
             $sRequestType = 'incident';
         } else {
             $sRequestType = $oTicket->Get('request_type');
         }
         $aArgs = $oTicket->ToArgs();
         $aArgs['metric'] = $sMetric;
         $aArgs['request_type'] = $sRequestType;
         //echo "<p>Managing:".$sMetric."-".$this->Get('request_type')."-".$this->Get('importance')."</p>\n";
         $oSLTSet = new DBObjectSet(DBObjectSearch::FromOQL(RESPONSE_TICKET_SLT_QUERY), array(), $aArgs);
         $iMinDuration = PHP_INT_MAX;
         $sSLTName = '';
         while ($oSLT = $oSLTSet->Fetch()) {
             $iDuration = (int) $oSLT->Get('value');
             $sUnit = $oSLT->Get('unit');
             switch ($sUnit) {
                 case 'days':
                     $iDuration = $iDuration * 24;
                     // 24 hours in 1 days
                     // Fall though
                 // 24 hours in 1 days
                 // Fall though
                 case 'hours':
                     $iDuration = $iDuration * 60;
                     // 60 minutes in 1 hour
                     // Fall though
                 // 60 minutes in 1 hour
                 // Fall though
                 case 'minutes':
                     $iDuration = $iDuration * 60;
             }
             if ($iDuration < $iMinDuration) {
                 $iMinDuration = $iDuration;
                 $sSLTName = $oSLT->GetName();
             }
         }
         if ($iMinDuration == PHP_INT_MAX) {
             $iDeadline = null;
         } else {
             // Store $sSLTName to keep track of which SLT has been used
             $iDeadline = $iMinDuration;
         }
     }
     return $iDeadline;
 }
 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);
 }
Example #23
0
/**
 * 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);
    }
}
 public function output()
 {
     $this->add_header("Content-Length: " . strlen(trim($this->s_content)));
     foreach ($this->a_headers as $s_header) {
         header($s_header);
     }
     echo trim($this->s_content);
     echo "\n";
     if (class_exists('MetaModel')) {
         MetaModel::RecordQueryTrace();
     }
     if (class_exists('ExecutionKPI')) {
         ExecutionKPI::ReportStats();
     }
 }
Example #25
0
 public static function Init()
 {
     $aParams = array("category" => "core/cmdb,view_in_gui,application", "key_type" => "autoincrement", "name_attcode" => "name", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_query_oql", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_InheritAttributes();
     MetaModel::Init_AddAttribute(new AttributeOQL("oql", array("allowed_values" => null, "sql" => "oql", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
     // Display lists
     MetaModel::Init_SetZListItems('details', array('name', 'description', 'oql', 'fields'));
     // Attributes to be displayed for the complete details
     MetaModel::Init_SetZListItems('list', array('description'));
     // Attributes to be displayed for a list
     // Search criteria
     MetaModel::Init_SetZListItems('standard_search', array('name', 'description', 'fields', 'oql'));
     // Criteria of the std search form
     //		MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
 }
 public static function Init()
 {
     $aParams = array("category" => "core/cmdb", "key_type" => "autoincrement", "name_attcode" => "class_name", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_backgroundtask", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_AddAttribute(new AttributeString("class_name", array("allowed_values" => null, "sql" => "class_name", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDateTime("first_run_date", array("allowed_values" => null, "sql" => "first_run_date", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDateTime("latest_run_date", array("allowed_values" => null, "sql" => "latest_run_date", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDateTime("next_run_date", array("allowed_values" => null, "sql" => "next_run_date", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeInteger("total_exec_count", array("allowed_values" => null, "sql" => "total_exec_count", "default_value" => "0", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDecimal("latest_run_duration", array("allowed_values" => null, "sql" => "latest_run_duration", "digits" => 8, "decimals" => 3, "default_value" => "0", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDecimal("min_run_duration", array("allowed_values" => null, "sql" => "min_run_duration", "digits" => 8, "decimals" => 3, "default_value" => "0", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDecimal("max_run_duration", array("allowed_values" => null, "sql" => "max_run_duration", "digits" => 8, "decimals" => 3, "default_value" => "0", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeDecimal("average_run_duration", array("allowed_values" => null, "sql" => "average_run_duration", "digits" => 8, "decimals" => 3, "default_value" => "0", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeBoolean("running", array("allowed_values" => null, "sql" => "running", "default_value" => false, "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values" => new ValueSetEnum('active,paused'), "sql" => "status", "default_value" => 'active', "is_null_allowed" => false, "depends_on" => array())));
 }
 public static function Init()
 {
     $aParams = array("category" => "addon/authentication", "key_type" => "autoincrement", "name_attcode" => "login", "state_attcode" => "", "reconc_keys" => array('login'), "db_table" => "", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_InheritAttributes();
     // Display lists
     MetaModel::Init_SetZListItems('details', array('contactid', 'first_name', 'email', 'login', 'language', 'profile_list', 'allowed_org_list'));
     // Attributes to be displayed for the complete details
     MetaModel::Init_SetZListItems('list', array('first_name', 'last_name', 'login'));
     // Attributes to be displayed for a list
     // Search criteria
     MetaModel::Init_SetZListItems('standard_search', array('login', 'contactid'));
     // Criteria of the std search form
     MetaModel::Init_SetZListItems('advanced_search', array('login', 'contactid'));
     // Criteria of the advanced search form
 }
 public static function Init()
 {
     $aParams = array('category' => 'bizmodel,searchable,changemgmt', 'key_type' => 'autoincrement', 'name_attcode' => 'ref', 'state_attcode' => 'status', 'reconc_keys' => array('ref'), 'db_table' => 'ticket_change', 'db_key_field' => 'id', 'db_finalclass_field' => '', 'icon' => utils::GetAbsoluteUrlModulesRoot() . 'itop-change-mgmt/images/change.png', 'order_by_default' => array('ref' => false));
     MetaModel::Init_Params($aParams);
     MetaModel::Init_InheritAttributes();
     MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values" => new ValueSetEnum("new,assigned,planned,approved,closed,rejected"), "display_style" => 'list', "sql" => 'status', "default_value" => 'new', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeEnum("category", array("allowed_values" => new ValueSetEnum("hardware,software,system,network,application,other"), "display_style" => 'list', "sql" => 'category', "default_value" => 'hardware', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeText("reject_reason", array("allowed_values" => null, "sql" => 'reject_reason', "default_value" => '', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalKey("changemanager_id", array("targetclass" => 'Person', "allowed_values" => null, "sql" => 'changemanager_id', "is_null_allowed" => true, "on_target_delete" => DEL_MANUAL, "depends_on" => array(), "display_style" => 'select', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalField("changemanager_email", array("allowed_values" => null, "extkey_attcode" => 'changemanager_id', "target_attcode" => 'email', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass" => 'Change', "allowed_values" => new ValueSetObjects("SELECT Change WHERE id != :this->id"), "sql" => 'parent_id', "is_null_allowed" => true, "on_target_delete" => DEL_MANUAL, "depends_on" => array(), "display_style" => 'select', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("allowed_values" => null, "extkey_attcode" => 'parent_id', "target_attcode" => 'ref', "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeDateTime("creation_date", array("allowed_values" => null, "sql" => 'creation_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeDateTime("approval_date", array("allowed_values" => null, "sql" => 'approval_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeText("fallback_plan", array("allowed_values" => null, "sql" => 'fallback_plan', "default_value" => '', "is_null_allowed" => true, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeEnum("outage", array("allowed_values" => new ValueSetEnum("yes,no"), "display_style" => 'list', "sql" => 'outage', "default_value" => 'no', "is_null_allowed" => false, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeLinkedSet("related_request_list", array("linked_class" => 'UserRequest', "ext_key_to_me" => 'parent_change_id', "count_min" => 0, "count_max" => 0, "edit_mode" => LINKSET_EDITMODE_ADDREMOVE, "allowed_values" => null, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeLinkedSet("related_incident_list", array("linked_class" => 'Incident', "ext_key_to_me" => 'parent_change_id', "count_min" => 0, "count_max" => 0, "edit_mode" => LINKSET_EDITMODE_ADDREMOVE, "allowed_values" => null, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeLinkedSet("related_problems_list", array("linked_class" => 'Problem', "ext_key_to_me" => 'related_change_id', "count_min" => 0, "count_max" => 0, "edit_mode" => LINKSET_EDITMODE_ADDREMOVE, "allowed_values" => null, "depends_on" => array(), "always_load_in_tables" => false)));
     MetaModel::Init_AddAttribute(new AttributeLinkedSet("child_changes_list", array("linked_class" => 'Change', "ext_key_to_me" => 'parent_id', "count_min" => 0, "count_max" => 0, "edit_mode" => LINKSET_EDITMODE_ADDREMOVE, "allowed_values" => new ValueSetObjects("SELECT Change WHERE id != :this->id"), "depends_on" => array(), "always_load_in_tables" => false)));
     // Lifecycle (status attribute: status)
     //
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_assign", array()));
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_plan", array()));
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reject", array()));
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_reopen", array()));
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_approve", array()));
     MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_finish", array()));
     MetaModel::Init_DefineState("new", array("attribute_inherit" => '', "attribute_list" => array('ref' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_MANDATORY, 'title' => OPT_ATT_MANDATORY, 'description' => OPT_ATT_MANDATORY, 'last_update' => OPT_ATT_READONLY, 'close_date' => OPT_ATT_HIDDEN, 'reject_reason' => OPT_ATT_HIDDEN, 'creation_date' => OPT_ATT_READONLY, 'approval_date' => OPT_ATT_HIDDEN, 'caller_id' => OPT_ATT_MANDATORY, 'team_id' => OPT_ATT_HIDDEN, 'agent_id' => OPT_ATT_HIDDEN, 'changemanager_id' => OPT_ATT_HIDDEN, 'outage' => OPT_ATT_HIDDEN)));
     MetaModel::Init_DefineTransition("new", "ev_assign", array("target_state" => "assigned", "actions" => array(), "user_restriction" => null));
     MetaModel::Init_DefineState("assigned", array("attribute_inherit" => 'new', "attribute_list" => array('team_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'agent_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'changemanager_id' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'caller_id' => OPT_ATT_NORMAL)));
     MetaModel::Init_DefineTransition("assigned", "ev_plan", array("target_state" => "planned", "actions" => array(), "user_restriction" => null));
     MetaModel::Init_DefineState("planned", array("attribute_inherit" => 'assigned', "attribute_list" => array('start_date' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'end_date' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'fallback_plan' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'caller_id' => OPT_ATT_MANDATORY, 'outage' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT)));
     MetaModel::Init_DefineTransition("planned", "ev_reject", array("target_state" => "rejected", "actions" => array(), "user_restriction" => null));
     MetaModel::Init_DefineTransition("planned", "ev_approve", array("target_state" => "approved", "actions" => array(array('verb' => 'SetCurrentDate', 'params' => array(array('type' => 'attcode', 'value' => "approval_date"))), array('verb' => 'Reset', 'params' => array(array('type' => 'attcode', 'value' => "reject_reason")))), "user_restriction" => null));
     MetaModel::Init_DefineState("rejected", array("attribute_inherit" => 'assigned', 'highlight' => array('code' => 'rejected'), "attribute_list" => array('start_date' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_READONLY, 'private_log' => OPT_ATT_READONLY, 'caller_id' => OPT_ATT_READONLY, 'fallback_plan' => OPT_ATT_READONLY, 'category' => OPT_ATT_READONLY, 'parent_id' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY, 'title' => OPT_ATT_READONLY, 'description' => OPT_ATT_READONLY, 'reject_reason' => OPT_ATT_MANDATORY | OPT_ATT_MUSTPROMPT, 'approval_date' => OPT_ATT_READONLY, 'team_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_READONLY, 'changemanager_id' => OPT_ATT_READONLY, 'outage' => OPT_ATT_READONLY)));
     MetaModel::Init_DefineTransition("rejected", "ev_reopen", array("target_state" => "assigned", "actions" => array(), "user_restriction" => null));
     MetaModel::Init_DefineState("approved", array("attribute_inherit" => 'planned', 'highlight' => array('code' => 'approved'), "attribute_list" => array('private_log' => OPT_ATT_NORMAL, 'category' => OPT_ATT_NORMAL, 'parent_id' => OPT_ATT_NORMAL, 'org_id' => OPT_ATT_READONLY, 'title' => OPT_ATT_READONLY, 'description' => OPT_ATT_READONLY, 'start_date' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_READONLY, 'reject_reason' => OPT_ATT_READONLY, 'creation_date' => OPT_ATT_HIDDEN, 'approval_date' => OPT_ATT_READONLY, 'caller_id' => OPT_ATT_READONLY, 'team_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_READONLY, 'changemanager_id' => OPT_ATT_READONLY, 'fallback_plan' => OPT_ATT_NORMAL, 'outage' => OPT_ATT_READONLY)));
     MetaModel::Init_DefineTransition("approved", "ev_finish", array("target_state" => "closed", "actions" => array(array('verb' => 'SetCurrentDate', 'params' => array(array('type' => 'attcode', 'value' => "close_date")))), "user_restriction" => null));
     MetaModel::Init_DefineState("closed", array("attribute_inherit" => 'approved', 'highlight' => array('code' => 'closed'), "attribute_list" => array('close_date' => OPT_ATT_READONLY, 'creation_date' => OPT_ATT_READONLY, 'private_log' => OPT_ATT_READONLY, 'fallback_plan' => OPT_ATT_READONLY, 'category' => OPT_ATT_READONLY, 'parent_id' => OPT_ATT_READONLY)));
     // Higlight Scale
     MetaModel::Init_DefineHighlightScale(array('approved' => array('rank' => 1, 'color' => HILIGHT_CLASS_NONE, 'icon' => utils::GetAbsoluteUrlModulesRoot() . 'itop-change-mgmt/images/change-approved.png'), 'rejected' => array('rank' => 2, 'color' => HILIGHT_CLASS_NONE, 'icon' => utils::GetAbsoluteUrlModulesRoot() . 'itop-change-mgmt/images/change-rejected.png'), 'closed' => array('rank' => 3, 'color' => HILIGHT_CLASS_NONE, 'icon' => utils::GetAbsoluteUrlModulesRoot() . 'itop-change-mgmt/images/change-closed.png')));
     MetaModel::Init_SetZListItems('details', array(0 => 'functionalcis_list', 1 => 'contacts_list', 2 => 'workorders_list', 3 => 'related_request_list', 4 => 'related_incident_list', 5 => 'related_problems_list', 6 => 'child_changes_list', 'col:col1' => array('fieldset:Ticket:baseinfo' => array(0 => 'ref', 1 => 'org_id', 2 => 'status', 3 => 'title', 4 => 'description'), 'fieldset:Ticket:contact' => array(0 => 'caller_id', 1 => 'team_id', 2 => 'agent_id', 3 => 'changemanager_id')), 'col:col2' => array('fieldset:Ticket:resolution' => array(0 => 'category', 1 => 'outage', 2 => 'reject_reason', 3 => 'fallback_plan'), 'fieldset:Ticket:relation' => array(0 => 'parent_id')), 'col:col3' => array('fieldset:Ticket:date' => array(0 => 'creation_date', 1 => 'start_date', 2 => 'end_date', 3 => 'last_update', 4 => 'approval_date', 5 => 'close_date'))));
     MetaModel::Init_SetZListItems('standard_search', array(0 => 'ref', 1 => 'title', 2 => 'org_id', 3 => 'status', 4 => 'start_date', 5 => 'end_date', 6 => 'creation_date', 7 => 'last_update', 8 => 'close_date', 9 => 'team_id', 10 => 'agent_id', 11 => 'changemanager_id'));
     MetaModel::Init_SetZListItems('list', array(0 => 'title', 1 => 'org_id', 2 => 'start_date', 3 => 'end_date', 4 => 'status', 5 => 'category', 6 => 'agent_id'));
 }
 public function __construct($aSearches)
 {
     if (count($aSearches) == 0) {
         throw new CoreException('A DBUnionSearch must be made of at least one search');
     }
     $this->aSearches = array();
     foreach ($aSearches as $oSearch) {
         if ($oSearch instanceof DBUnionSearch) {
             foreach ($oSearch->aSearches as $oSubSearch) {
                 $this->aSearches[] = $oSubSearch->DeepClone();
             }
         } else {
             $this->aSearches[] = $oSearch->DeepClone();
         }
     }
     // 1 - Collect all the column/classes
     $aColumnToClasses = array();
     foreach ($this->aSearches as $iPos => $oSearch) {
         $aSelected = array_values($oSearch->GetSelectedClasses());
         if ($iPos != 0) {
             if (count($aSelected) < count($aColumnToClasses)) {
                 throw new Exception('Too few selected classes in the subquery #' . ($iPos + 1));
             }
             if (count($aSelected) > count($aColumnToClasses)) {
                 throw new Exception('Too many selected classes in the subquery #' . ($iPos + 1));
             }
         }
         foreach ($aSelected as $iColumn => $sClass) {
             $aColumnToClasses[$iColumn][] = $sClass;
         }
     }
     // 2 - Build the index column => alias
     $oFirstSearch = $this->aSearches[0];
     $aColumnToAlias = array_keys($oFirstSearch->GetSelectedClasses());
     // 3 - Compute alias => lowest common ancestor
     $this->aSelectedClasses = array();
     foreach ($aColumnToClasses as $iColumn => $aClasses) {
         $sAlias = $aColumnToAlias[$iColumn];
         $sAncestor = MetaModel::GetLowestCommonAncestor($aClasses);
         if (is_null($sAncestor)) {
             throw new Exception('Could not find a common ancestor for the column ' . ($iColumn + 1) . ' (Classes: ' . implode(', ', $aClasses) . ')');
         }
         $this->aSelectedClasses[$sAlias] = $sAncestor;
     }
 }
 public static function Init()
 {
     $aParams = array("category" => "application", "key_type" => "autoincrement", "name_attcode" => "name", "state_attcode" => "", "reconc_keys" => array('name'), "db_table" => "priv_auditcategory", "db_key_field" => "id", "db_finalclass_field" => "");
     MetaModel::Init_Params($aParams);
     MetaModel::Init_AddAttribute(new AttributeString("name", array("description" => "Short name for this category", "allowed_values" => null, "sql" => "name", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values" => null, "sql" => "description", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeOQL("definition_set", array("allowed_values" => null, "sql" => "definition_set", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
     MetaModel::Init_AddAttribute(new AttributeLinkedSet("rules_list", array("linked_class" => "AuditRule", "ext_key_to_me" => "category_id", "allowed_values" => null, "count_min" => 0, "count_max" => 0, "depends_on" => array(), "edit_mode" => LINKSET_EDITMODE_INPLACE)));
     // Display lists
     MetaModel::Init_SetZListItems('details', array('name', 'description', 'definition_set', 'rules_list'));
     // Attributes to be displayed for the complete details
     MetaModel::Init_SetZListItems('list', array('description'));
     // Attributes to be displayed for a list
     // Search criteria
     MetaModel::Init_SetZListItems('standard_search', array('name', 'description'));
     // Criteria of the std search form
     MetaModel::Init_SetZListItems('advanced_search', array('name', 'description', 'definition_set'));
     // Criteria of the advanced search form
 }