public function DBInsertNoReload()
 {
     $oMutex = new iTopMutex('ticket_insert');
     $oMutex->Lock();
     $iNextId = MetaModel::GetNextKey(get_class($this));
     $sRef = $this->MakeTicketRef($iNextId);
     $this->Set('ref', $sRef);
     $iKey = parent::DBInsertNoReload();
     $oMutex->Unlock();
     return $iKey;
 }
 /**
  * Displays one step of the wizard
  */
 public function DisplayWizardStep($aStep, $iStepIndex, &$iMaxInputId, &$aFieldsMap, $bFinishEnabled = false, $aArgs = array())
 {
     if ($iStepIndex == 1) {
         $this->m_oPage->add("<form method=\"post\" enctype=\"multipart/form-data\" action=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php\">\n");
     }
     $this->m_oPage->add("<div class=\"wizContainer\" id=\"wizStep{$iStepIndex}\" style=\"display:none;\">\n");
     $this->m_oPage->add("<a name=\"step{$iStepIndex}\" />\n");
     $aStates = MetaModel::EnumStates($this->m_sClass);
     $aDetails = array();
     $sJSHandlerCode = '';
     // Javascript code to be executed each time this step of the wizard is entered
     foreach ($aStep as $sAttCode) {
         $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
         if ($oAttDef->IsWritable()) {
             $sAttLabel = $oAttDef->GetLabel();
             $iOptions = isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode]) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
             $aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
             if ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) {
                 $aFields[$sAttCode] = array();
                 foreach ($aPrerequisites as $sCode) {
                     $aFields[$sAttCode][$sCode] = '';
                 }
             }
             if (count($aPrerequisites) > 0) {
                 $aOptions[] = 'Prerequisites: ' . implode(', ', $aPrerequisites);
             }
             $sFieldFlag = $iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE) || !$oAttDef->IsNullAllowed() ? ' <span class="hilite">*</span>' : '';
             $oDefaultValuesSet = $oAttDef->GetDefaultValue();
             // @@@ TO DO: get the object's current value if the object exists
             $sHTMLValue = cmdbAbstractObject::GetFormElementForField($this->m_oPage, $this->m_sClass, $sAttCode, $oAttDef, $oDefaultValuesSet, '', "att_{$iMaxInputId}", '', $iOptions, $aArgs);
             $aFieldsMap["att_{$iMaxInputId}"] = $sAttCode;
             $aDetails[] = array('label' => '<span title="' . $oAttDef->GetDescription() . '">' . $oAttDef->GetLabel() . $sFieldFlag . '</span>', 'value' => "<span id=\"field_att_{$iMaxInputId}\">{$sHTMLValue}</span>");
             if ($oAttDef->GetValuesDef() != null) {
                 $sJSHandlerCode .= "\toWizardHelper.RequestAllowedValues('{$sAttCode}');\n";
             }
             if ($oAttDef->GetDefaultValue() != null) {
                 $sJSHandlerCode .= "\toWizardHelper.RequestDefaultValue('{$sAttCode}');\n";
             }
             if ($oAttDef->IsLinkSet()) {
                 $sJSHandlerCode .= "\toLinkWidgetatt_{$iMaxInputId}.Init();";
             }
             $iMaxInputId++;
         }
     }
     //$aDetails[] = array('label' => '', 'value' => '<input type="button" value="Next &gt;&gt;">');
     $this->m_oPage->details($aDetails);
     $sBackButtonDisabled = $iStepIndex <= 1 ? 'disabled' : '';
     $sDisabled = $bFinishEnabled ? '' : 'disabled';
     $nbSteps = count($this->m_aWizardSteps['mandatory']) + count($this->m_aWizardSteps['optional']);
     $this->m_oPage->add("<div style=\"text-align:center\">\r\n\t\t<input type=\"button\" value=\"" . Dict::S('UI:Button:Back') . "\" {$sBackButtonDisabled} onClick=\"GoToStep({$iStepIndex}, {$iStepIndex} - 1)\" />\r\n\t\t<input type=\"button\" value=\"" . Dict::S('UI:Button:Next') . "\" onClick=\"GoToStep({$iStepIndex}, 1+{$iStepIndex})\" />\r\n\t\t<input type=\"button\" value=\"" . Dict::S('UI:Button:Finish') . "\" {$sDisabled} onClick=\"GoToStep({$iStepIndex}, 1+{$nbSteps})\" />\r\n\t\t</div>\n");
     $this->m_oPage->add_script("\r\nfunction OnEnterStep{$iStepIndex}()\r\n{\r\n\toWizardHelper.ResetQuery();\r\n\toWizardHelper.UpdateWizard();\r\n\t\r\n{$sJSHandlerCode}\r\n\r\n\toWizardHelper.AjaxQueryServer();\r\n}\r\n");
     $this->m_oPage->add("</div>\n\n");
 }
Beispiel #3
0
 $iCategory = utils::ReadParam('category', '');
 $iRuleIndex = utils::ReadParam('rule', 0);
 $oAuditCategory = MetaModel::GetObject('AuditCategory', $iCategory);
 $oDefinitionFilter = DBObjectSearch::FromOQL($oAuditCategory->Get('definition_set'));
 FilterByContext($oDefinitionFilter, $oAppContext);
 $oDefinitionSet = new CMDBObjectSet($oDefinitionFilter);
 $oFilter = GetRuleResultFilter($iRuleIndex, $oDefinitionFilter, $oAppContext);
 $oErrorObjectSet = new CMDBObjectSet($oFilter);
 $oAuditRule = MetaModel::GetObject('AuditRule', $iRuleIndex);
 $sFileName = utils::ReadParam('filename', null, true, 'string');
 $bAdvanced = utils::ReadParam('advanced', false);
 $sAdvanced = $bAdvanced ? '&advanced=1' : '';
 if ($sFileName != null) {
     $oP = new CSVPage("iTop - Export");
     $sCharset = MetaModel::GetConfig()->Get('csv_file_default_charset');
     $sCSVData = cmdbAbstractObject::GetSetAsCSV($oErrorObjectSet, array('localize_values' => true, 'fields_advanced' => $bAdvanced), $sCharset);
     if ($sCharset == 'UTF-8') {
         $sOutputData = UTF8_BOM . $sCSVData;
     } else {
         $sOutputData = $sCSVData;
     }
     if ($sFileName == '') {
         // Plain text => Firefox will NOT propose to download the file
         $oP->add_header("Content-type: text/plain; charset={$sCharset}");
     } else {
         $oP->add_header("Content-type: text/csv; charset={$sCharset}");
     }
     $oP->add($sOutputData);
     $oP->TrashUnexpectedOutput();
     $oP->output();
     exit;
Beispiel #4
0
 /**
  * Builds an object that contains the values that are common to all the objects
  * in the set. If for a given attribute, objects in the set have various values
  * then the resulting object will contain null for this value.
  * @param $aValues Hash Output: the distribution of the values, in the set, for each attribute
  * @return DBObject The object with the common values
  */
 public function ComputeCommonObject(&$aValues)
 {
     $sClass = $this->GetClass();
     $aList = MetaModel::ListAttributeDefs($sClass);
     $aValues = array();
     foreach ($aList as $sAttCode => $oAttDef) {
         if ($oAttDef->IsScalar()) {
             $aValues[$sAttCode] = array();
         }
     }
     $this->Rewind();
     while ($oObj = $this->Fetch()) {
         foreach ($aList as $sAttCode => $oAttDef) {
             if ($oAttDef->IsScalar() && $oAttDef->IsWritable()) {
                 $currValue = $oObj->Get($sAttCode);
                 if (is_object($currValue)) {
                     continue;
                 }
                 // Skip non scalar values...
                 if (!array_key_exists($currValue, $aValues[$sAttCode])) {
                     $aValues[$sAttCode][$currValue] = array('count' => 1, 'display' => $oObj->GetAsHTML($sAttCode));
                 } else {
                     $aValues[$sAttCode][$currValue]['count']++;
                 }
             }
         }
     }
     foreach ($aValues as $sAttCode => $aMultiValues) {
         if (count($aMultiValues) > 1) {
             uasort($aValues[$sAttCode], 'HashCountComparison');
         }
     }
     // Now create an object that has values for the homogenous values only
     $oCommonObj = new $sClass();
     // @@ What if the class is abstract ?
     $aComments = array();
     $iFormId = cmdbAbstractObject::GetNextFormId();
     // Identifier that prefixes all the form fields
     $sReadyScript = '';
     $aDependsOn = array();
     $sFormPrefix = '2_';
     foreach ($aList as $sAttCode => $oAttDef) {
         if ($oAttDef->IsScalar() && $oAttDef->IsWritable()) {
             if ($oAttDef->GetEditClass() == 'One Way Password') {
                 $oCommonObj->Set($sAttCode, null);
             } else {
                 $iCount = count($aValues[$sAttCode]);
                 if ($iCount == 1) {
                     // Homogenous value
                     reset($aValues[$sAttCode]);
                     $aKeys = array_keys($aValues[$sAttCode]);
                     $currValue = $aKeys[0];
                     // The only value is the first key
                     $oCommonObj->Set($sAttCode, $currValue);
                 } else {
                     // Non-homogenous value
                     $oCommonObj->Set($sAttCode, null);
                 }
             }
         }
     }
     $this->Rewind();
     return $oCommonObj;
 }
 protected function GetFormRow($oP, $oLinkedObj, $currentLink = null)
 {
     $aRow = array();
     if (is_object($currentLink)) {
         $key = $currentLink->GetKey();
         $sNameSuffix = "[{$key}]";
         // To make a tabular form
         $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onChange=\"OnSelectChange();\" value=\"{$key}\">";
         $aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"linkId[{$key}]\" value=\"{$key}\">";
         foreach ($this->m_aEditableFields as $sFieldCode) {
             $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sFieldCode);
             $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sClass, $sFieldCode, $oAttDef, $currentLink->Get($sFieldCode), '', $key, $sNameSuffix);
         }
     } else {
         // form for creating a new record
         $sNameSuffix = "[{$currentLink}]";
         // To make a tabular form
         $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onChange=\"OnSelectChange();\" value=\"{$currentLink}\">";
         $aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"linkId[{$currentLink}]\" value=\"{$currentLink}\">";
         foreach ($this->m_aEditableFields as $sFieldCode) {
             $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sFieldCode);
             $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sClass, $sFieldCode, $oAttDef, '', '', '', $sNameSuffix);
         }
     }
     foreach (MetaModel::GetZListItems($this->m_sLinkedClass, 'list') as $sFieldCode) {
         $aRow['static::' . $sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
     }
     return $aRow;
 }
Beispiel #6
0
function ReloadAndDisplay($oPage, $oObj, $sMessageId = '', $sMessage = '', $sSeverity = null)
{
    $oAppContext = new ApplicationContext();
    if ($sMessageId != '') {
        cmdbAbstractObject::SetSessionMessage(get_class($oObj), $oObj->GetKey(), $sMessageId, $sMessage, $sSeverity, 0, true);
    }
    $oPage->add_header('Location: ' . utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=details&class=' . get_class($oObj) . '&id=' . $oObj->getKey() . '&' . $oAppContext->GetForLink());
}
 /**
  * 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}");
                         }
                     }
                 }
                 if ($bLocked && $bRawModifiedAllowed) {
                     // Add a special menu to kill the lock, but only to allowed users who can also modify this object
                     $aAllowedProfiles = MetaModel::GetConfig()->Get('concurrent_lock_override_profiles');
                     $bCanKill = false;
                     $oUser = UserRights::GetUserObject();
                     $aUserProfiles = array();
                     if (!is_null($oUser)) {
                         $oProfileSet = $oUser->Get('profile_list');
                         while ($oProfile = $oProfileSet->Fetch()) {
                             $aUserProfiles[$oProfile->Get('profile')] = true;
                         }
                     }
                     foreach ($aAllowedProfiles as $sProfile) {
                         if (array_key_exists($sProfile, $aUserProfiles)) {
                             $bCanKill = true;
                             break;
                         }
                     }
                     if ($bCanKill) {
                         $this->AddMenuSeparator($aActions);
                         $aActions['concurrent_lock_unlock'] = array('label' => Dict::S('UI:Menu:KillConcurrentLock'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=kill_lock&class={$sClass}&id={$id}{$sContext}");
                     }
                 }
                 /*
                 $this->AddMenuSeparator($aActions);
                 // Static menus: Email this page & CSV Export
                 $sUrl = ApplicationContext::MakeObjectUrl($sClass, $id);
                 $aActions['UI:Menu:EMail'] = array ('label' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=".urlencode($oObj->GetRawName())."&body=".urlencode($sUrl));
                 $aActions['UI:Menu:CSVExport'] = array ('label' => Dict::S('UI:Menu:CSVExport'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=search&filter=".urlencode($sFilter)."&format=csv{$sContext}");
                 // The style tells us whether the menu is displayed on a list of one object, or on the details of the given object 
                 if ($this->m_sStyle == 'list')
                 {
                 	// Actions specific to the list
                 	$sOQL = addslashes($sFilterDesc);
                 	$aActions['UI:Menu:AddToDashboard'] = array ('label' => Dict::S('UI:Menu:AddToDashboard'), 'url' => "#", 'onclick' => "return DashletCreationDlg('$sOQL')");
                 }
                 */
             }
             $this->AddMenuSeparator($aActions);
             foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
                 $oSet->Rewind();
                 foreach ($oExtensionInstance->EnumAllowedActions($oSet) as $sLabel => $sUrl) {
                     $aActions[$sLabel] = array('label' => $sLabel, 'url' => $sUrl);
                 }
             }
             break;
         default:
             // Check rights
             // New / Modify
             $bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet) && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
             $bIsBulkModifyAllowed = !MetaModel::IsAbstract($sClass) && UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_MODIFY, $oSet) && $oReflectionClass->IsSubclassOf('cmdbAbstractObject');
             $bIsBulkDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_DELETE, $oSet);
             if (isset($aExtraParams['link_attr'])) {
                 $id = $aExtraParams['object_id'];
                 $sTargetAttr = $aExtraParams['target_attr'];
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sTargetAttr);
                 $sTargetClass = $oAttDef->GetTargetClass();
                 $bIsDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
                 if ($bIsModifyAllowed) {
                     $aActions['UI:Menu:Add'] = array('label' => Dict::S('UI:Menu:Add'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=modify_links&class={$sClass}&link_attr=" . $aExtraParams['link_attr'] . "&target_class={$sTargetClass}&id={$id}&addObjects=true{$sContext}");
                 }
                 if ($bIsBulkModifyAllowed) {
                     $aActions['UI:Menu:Manage'] = array('label' => Dict::S('UI:Menu:Manage'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=modify_links&class={$sClass}&link_attr=" . $aExtraParams['link_attr'] . "&target_class={$sTargetClass}&id={$id}{$sContext}");
                 }
                 //if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Remove All...', 'url' => "#"); }
             } else {
                 // many objects in the set, possible actions are: new / modify all / delete all
                 if ($bIsCreationAllowed) {
                     $aActions['UI:Menu:New'] = array('label' => Dict::S('UI:Menu:New'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=new&class={$sClass}{$sContext}{$sDefault}");
                 }
                 if ($bIsBulkModifyAllowed) {
                     $aActions['UI:Menu:ModifyAll'] = array('label' => Dict::S('UI:Menu:ModifyAll'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=select_for_modify_all&class={$sClass}&filter=" . urlencode($sFilter) . "{$sContext}");
                 }
                 if ($bIsBulkDeleteAllowed) {
                     $aActions['UI:Menu:BulkDelete'] = array('label' => Dict::S('UI:Menu:BulkDelete'), 'url' => "{$sRootUrl}pages/{$sUIPage}?operation=select_for_deletion&filter=" . urlencode($sFilter) . "{$sContext}");
                 }
                 // Stimuli
                 $aStates = MetaModel::EnumStates($sClass);
                 // Do not perform time consuming computations if there are too may objects in the list
                 $iLimit = MetaModel::GetConfig()->Get('complex_actions_limit');
                 if (count($aStates) > 0 && ($iLimit == 0 || $oSet->Count() < $iLimit)) {
                     // Life cycle actions may be available... if all objects are in the same state
                     //
                     // Group by <state>
                     $oGroupByExp = new FieldExpression(MetaModel::GetStateAttributeCode($sClass), $this->m_oFilter->GetClassAlias());
                     $aGroupBy = array('__state__' => $oGroupByExp);
                     $aQueryParams = array();
                     if (isset($aExtraParams['query_params'])) {
                         $aQueryParams = $aExtraParams['query_params'];
                     }
                     $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy);
                     $aRes = CMDBSource::QueryToArray($sSql);
                     if (count($aRes) == 1) {
                         // All objects are in the same state...
                         $sState = $aRes[0]['__state__'];
                         $aTransitions = Metamodel::EnumTransitions($sClass, $sState);
                         if (count($aTransitions)) {
                             $this->AddMenuSeparator($aActions);
                             $aStimuli = Metamodel::EnumStimuli($sClass);
                             foreach ($aTransitions as $sStimulusCode => $aTransitionDef) {
                                 $oSet->Rewind();
                                 // As soon as the user rights implementation will browse the object set,
                                 // then we might consider using OptimizeColumnLoad() here
                                 $iActionAllowed = UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet);
                                 $iActionAllowed = get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction' ? $iActionAllowed : UR_ALLOWED_NO;
                                 switch ($iActionAllowed) {
                                     case UR_ALLOWED_YES:
                                     case UR_ALLOWED_DEPENDS:
                                         $aActions[$sStimulusCode] = array('label' => $aStimuli[$sStimulusCode]->GetLabel(), 'url' => "{$sRootUrl}pages/UI.php?operation=select_bulk_stimulus&stimulus={$sStimulusCode}&state={$sState}&class={$sClass}&filter=" . urlencode($sFilter) . "{$sContext}");
                                         break;
                                     default:
                                         // Do nothing
                                 }
                             }
                         }
                     }
                 }
                 /*
                 $this->AddMenuSeparator($aActions);
                 $sUrl = utils::GetAbsoluteUrlAppRoot();
                 $aActions['UI:Menu:EMail'] = array ('label' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=$sFilterDesc&body=".urlencode("{$sUrl}pages/$sUIPage?operation=search&filter=".urlencode($sFilter)."{$sContext}"));
                 $aActions['UI:Menu:CSVExport'] = array ('label' => Dict::S('UI:Menu:CSVExport'), 'url' => "{$sRootUrl}pages/$sUIPage?operation=search&filter=".urlencode($sFilter)."&format=csv{$sContext}");
                 $sOQL = addslashes($sFilterDesc);
                 $aActions['UI:Menu:AddToDashboard'] = array ('label' => Dict::S('UI:Menu:AddToDashboard'), 'url' => "#", 'onclick' => "return DashletCreationDlg('$sOQL')");
                 */
             }
     }
     $this->AddMenuSeparator($aActions);
     foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) {
         $oSet->Rewind();
         foreach ($oExtensionInstance->EnumAllowedActions($oSet) as $sLabel => $data) {
             if (is_array($data)) {
                 // New plugins can provide javascript handlers via the 'onclick' property
                 //TODO: enable extension of different menus by checking the 'target' property ??
                 $aActions[$sLabel] = array('label' => $sLabel, 'url' => isset($data['url']) ? $data['url'] : '#', 'onclick' => isset($data['onclick']) ? $data['onclick'] : '');
             } else {
                 // Backward compatibility with old plugins
                 $aActions[$sLabel] = array('label' => $sLabel, 'url' => $data);
             }
         }
     }
     // New extensions based on iPopupMenuItem interface
     switch ($this->m_sStyle) {
         case 'list':
             $oSet->Rewind();
             $param = $oSet;
             $iMenuId = iPopupMenuExtension::MENU_OBJLIST_ACTIONS;
             break;
         case 'details':
             $oSet->Rewind();
             $param = $oSet->Fetch();
             $iMenuId = iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS;
             break;
     }
     utils::GetPopupMenuItems($oPage, $iMenuId, $param, $aActions);
     $aFavoriteActions = array();
     $aCallSpec = array($sClass, 'GetShortcutActions');
     if (is_callable($aCallSpec)) {
         $aShortcutActions = call_user_func($aCallSpec, $sClass);
         foreach ($aActions as $key => $aAction) {
             if (in_array($key, $aShortcutActions)) {
                 $aFavoriteActions[] = $aAction;
                 unset($aActions[$key]);
             }
         }
     } else {
         $aShortcutActions = array();
     }
     if (count($aFavoriteActions) > 0) {
         $sHtml .= "<div class=\"itop_popup actions_menu\"><ul>\n<li>" . Dict::S('UI:Menu:OtherActions') . "\n<ul>\n";
     } else {
         $sHtml .= "<div class=\"itop_popup actions_menu\"><ul>\n<li>" . Dict::S('UI:Menu:Actions') . "\n<ul>\n";
     }
     $sHtml .= $oPage->RenderPopupMenuItems($aActions, $aFavoriteActions);
     static $bPopupScript = false;
     if (!$bPopupScript) {
         // Output this once per page...
         $oPage->add_ready_script("\$(\"div.itop_popup>ul\").popupmenu();\n");
         $bPopupScript = true;
     }
     return $sHtml;
 }
    /**
     * Display a form for modifying several objects at once
     * The form will be submitted to the current page, with the specified additional values	 
     */
    public static function DisplayBulkModifyForm($oP, $sClass, $aSelectedObj, $sCustomOperation, $sCancelUrl, $aExcludeAttributes = array(), $aContextData = array())
    {
        if (count($aSelectedObj) > 0) {
            $iAllowedCount = count($aSelectedObj);
            $sSelectedObj = implode(',', $aSelectedObj);
            $sOQL = "SELECT {$sClass} WHERE id IN (" . $sSelectedObj . ")";
            $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL));
            // Compute the distribution of the values for each field to determine which of the "scalar" fields are homogenous
            $aList = MetaModel::ListAttributeDefs($sClass);
            $aValues = array();
            foreach ($aList as $sAttCode => $oAttDef) {
                if ($oAttDef->IsScalar()) {
                    $aValues[$sAttCode] = array();
                }
            }
            while ($oObj = $oSet->Fetch()) {
                foreach ($aList as $sAttCode => $oAttDef) {
                    if ($oAttDef->IsScalar() && $oAttDef->IsWritable()) {
                        $currValue = $oObj->Get($sAttCode);
                        if ($oAttDef instanceof AttributeCaseLog) {
                            $currValue = ' ';
                            // Don't put an empty string, in case the field would be considered as mandatory...
                        }
                        if (is_object($currValue)) {
                            continue;
                        }
                        // Skip non scalar values...
                        if (!array_key_exists($currValue, $aValues[$sAttCode])) {
                            $aValues[$sAttCode][$currValue] = array('count' => 1, 'display' => $oObj->GetAsHTML($sAttCode));
                        } else {
                            $aValues[$sAttCode][$currValue]['count']++;
                        }
                    }
                }
            }
            // Now create an object that has values for the homogenous values only
            $oDummyObj = new $sClass();
            // @@ What if the class is abstract ?
            $aComments = array();
            function MyComparison($a, $b)
            {
                if ($a['count'] == $b['count']) {
                    return 0;
                }
                return $a['count'] > $b['count'] ? -1 : 1;
            }
            $iFormId = cmdbAbstractObject::GetNextFormId();
            // Identifier that prefixes all the form fields
            $sReadyScript = '';
            $aDependsOn = array();
            $sFormPrefix = '2_';
            foreach ($aList as $sAttCode => $oAttDef) {
                $aPrerequisites = MetaModel::GetPrerequisiteAttributes($sClass, $sAttCode);
                // List of attributes that are needed for the current one
                if (count($aPrerequisites) > 0) {
                    // When 'enabling' a field, all its prerequisites must be enabled too
                    $sFieldList = "['{$sFormPrefix}" . implode("','{$sFormPrefix}", $aPrerequisites) . "']";
                    $oP->add_ready_script("\$('#enable_{$sFormPrefix}{$sAttCode}').bind('change', function(evt, sFormId) { return PropagateCheckBox( this.checked, {$sFieldList}, true); } );\n");
                }
                $aDependents = MetaModel::GetDependentAttributes($sClass, $sAttCode);
                // List of attributes that are needed for the current one
                if (count($aDependents) > 0) {
                    // When 'disabling' a field, all its dependent fields must be disabled too
                    $sFieldList = "['{$sFormPrefix}" . implode("','{$sFormPrefix}", $aDependents) . "']";
                    $oP->add_ready_script("\$('#enable_{$sFormPrefix}{$sAttCode}').bind('change', function(evt, sFormId) { return PropagateCheckBox( this.checked, {$sFieldList}, false); } );\n");
                }
                if ($oAttDef->IsScalar() && $oAttDef->IsWritable()) {
                    if ($oAttDef->GetEditClass() == 'One Way Password') {
                        $sTip = "Unknown values";
                        $sReadyScript .= "\$('#multi_values_{$sAttCode}').qtip( { content: '{$sTip}', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );";
                        $oDummyObj->Set($sAttCode, null);
                        $aComments[$sAttCode] = '<input type="checkbox" id="enable_' . $iFormId . '_' . $sAttCode . '" onClick="ToogleField(this.checked, \'' . $iFormId . '_' . $sAttCode . '\')"/>';
                        $aComments[$sAttCode] .= '<div class="multi_values" id="multi_values_' . $sAttCode . '"> ? </div>';
                        $sReadyScript .= 'ToogleField(false, \'' . $iFormId . '_' . $sAttCode . '\');' . "\n";
                    } else {
                        $iCount = count($aValues[$sAttCode]);
                        if ($iCount == 1) {
                            // Homogenous value
                            reset($aValues[$sAttCode]);
                            $aKeys = array_keys($aValues[$sAttCode]);
                            $currValue = $aKeys[0];
                            // The only value is the first key
                            //echo "<p>current value for $sAttCode : $currValue</p>";
                            $oDummyObj->Set($sAttCode, $currValue);
                            $aComments[$sAttCode] = '';
                            if ($sAttCode != MetaModel::GetStateAttributeCode($sClass)) {
                                $aComments[$sAttCode] .= '<input type="checkbox" checked id="enable_' . $iFormId . '_' . $sAttCode . '"  onClick="ToogleField(this.checked, \'' . $iFormId . '_' . $sAttCode . '\')"/>';
                            }
                            $aComments[$sAttCode] .= '<div class="mono_value">1</div>';
                        } else {
                            // Non-homogenous value
                            $aMultiValues = $aValues[$sAttCode];
                            uasort($aMultiValues, 'MyComparison');
                            $iMaxCount = 5;
                            $sTip = "<p><b>" . Dict::Format('UI:BulkModify_Count_DistinctValues', $iCount) . "</b><ul>";
                            $index = 0;
                            foreach ($aMultiValues as $sCurrValue => $aVal) {
                                $sDisplayValue = empty($aVal['display']) ? '<i>' . Dict::S('Enum:Undefined') . '</i>' : str_replace(array("\n", "\r"), " ", $aVal['display']);
                                $sTip .= "<li>" . Dict::Format('UI:BulkModify:Value_Exists_N_Times', $sDisplayValue, $aVal['count']) . "</li>";
                                $index++;
                                if ($iMaxCount == $index) {
                                    $sTip .= "<li>" . Dict::Format('UI:BulkModify:N_MoreValues', count($aMultiValues) - $iMaxCount) . "</li>";
                                    break;
                                }
                            }
                            $sTip .= "</ul></p>";
                            $sTip = addslashes($sTip);
                            $sReadyScript .= "\$('#multi_values_{$sAttCode}').qtip( { content: '{$sTip}', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );";
                            $oDummyObj->Set($sAttCode, null);
                            $aComments[$sAttCode] = '';
                            if ($sAttCode != MetaModel::GetStateAttributeCode($sClass)) {
                                $aComments[$sAttCode] .= '<input type="checkbox" id="enable_' . $iFormId . '_' . $sAttCode . '" onClick="ToogleField(this.checked, \'' . $iFormId . '_' . $sAttCode . '\')"/>';
                            }
                            $aComments[$sAttCode] .= '<div class="multi_values" id="multi_values_' . $sAttCode . '">' . $iCount . '</div>';
                        }
                        $sReadyScript .= 'ToogleField(' . ($iCount == 1 ? 'true' : 'false') . ', \'' . $iFormId . '_' . $sAttCode . '\');' . "\n";
                    }
                }
            }
            $sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
            if ($sStateAttCode != '' && $oDummyObj->GetState() == '') {
                // Hmmm, it's not gonna work like this ! Set a default value for the "state"
                // Maybe we should use the "state" that is the most common among the objects...
                $aMultiValues = $aValues[$sStateAttCode];
                uasort($aMultiValues, 'MyComparison');
                foreach ($aMultiValues as $sCurrValue => $aVal) {
                    $oDummyObj->Set($sStateAttCode, $sCurrValue);
                    break;
                }
                //$oStateAtt = MetaModel::GetAttributeDef($sClass, $sStateAttCode);
                //$oDummyObj->Set($sStateAttCode, $oStateAtt->GetDefaultValue());
            }
            $oP->add("<div class=\"page_header\">\n");
            $oP->add("<h1>" . $oDummyObj->GetIcon() . "&nbsp;" . Dict::Format('UI:Modify_M_ObjectsOf_Class_OutOf_N', $iAllowedCount, $sClass, $iAllowedCount) . "</h1>\n");
            $oP->add("</div>\n");
            $oP->add("<div class=\"wizContainer\">\n");
            $sDisableFields = json_encode($aExcludeAttributes);
            $aParams = array('fieldsComments' => $aComments, 'noRelations' => true, 'custom_operation' => $sCustomOperation, 'custom_button' => Dict::S('UI:Button:PreviewModifications'), 'selectObj' => $sSelectedObj, 'preview_mode' => true, 'disabled_fields' => $sDisableFields, 'disable_plugins' => true);
            $aParams = $aParams + $aContextData;
            // merge keeping associations
            $oDummyObj->DisplayModifyForm($oP, $aParams);
            $oP->add("</div>\n");
            $oP->add_ready_script($sReadyScript);
            $oP->add_ready_script(<<<EOF
\$('.wizContainer button.cancel').unbind('click');
\$('.wizContainer button.cancel').click( function() { window.location.href = '{$sCancelUrl}'; } );
EOF
);
        } else {
            $oP->p("No object selected !, nothing to do");
        }
    }
 protected function AfterDelete()
 {
     parent::AfterDelete();
     $sTable = $this->GetDataTable();
     $sDropTable = "DROP TABLE `{$sTable}`";
     CMDBSource::Query($sDropTable);
     // TO DO - check that triggers get dropped with the table
 }
Beispiel #10
0
\t\t\$('select[name^=field]').change( DoCheckMapping );
\t\taDefaultKeys = new Array({$sDefaultKeys});
\t\tDoCheckMapping();
EOF
);
            }
            break;
        case 'get_csv_template':
            $sClassName = utils::ReadParam('class_name');
            $sFormat = utils::ReadParam('format', 'csv');
            if (MetaModel::IsValidClass($sClassName)) {
                $oSearch = new DBObjectSearch($sClassName);
                $oSearch->AddCondition('id', 0, '=');
                // Make sure we create an empty set
                $oSet = new CMDBObjectSet($oSearch);
                $sResult = cmdbAbstractObject::GetSetAsCSV($oSet, array('showMandatoryFields' => true));
                $sClassDisplayName = MetaModel::GetName($sClassName);
                $sDisposition = utils::ReadParam('disposition', 'inline');
                if ($sDisposition == 'attachment') {
                    switch ($sFormat) {
                        case 'xlsx':
                            $oPage = new ajax_page("");
                            $oPage->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                            $oPage->SetContentDisposition('attachment', $sClassDisplayName . '.xlsx');
                            require_once APPROOT . '/application/excelexporter.class.inc.php';
                            $writer = new XLSXWriter();
                            $writer->setAuthor(UserRights::GetUserFriendlyName());
                            $aHeaders = array(0 => explode(',', $sResult));
                            // comma is the default separator
                            $writer->writeSheet($aHeaders, $sClassDisplayName, array());
                            $oPage->add($writer->writeToString());
 protected function DBDeleteSingleObject()
 {
     if (MetaModel::GetConfig()->Get('demo_mode')) {
         // Users deletion is NOT allowed in demo mode
         return;
     }
     parent::DBDeleteSingleObject();
 }
Beispiel #12
0
/**
 * Create form to apply a stimulus
 * @param WebPage $oP The current web page
 * @param Object $oObj The target object
 * @param String $sStimulusCode Stimulus that will be applied
 * @param Array $aEditAtt List of attributes to edit
 * @return void
 */
function MakeStimulusForm(WebPage $oP, $oObj, $sStimulusCode, $aEditAtt)
{
    static $bHasStimulusForm = false;
    $sDialogId = $sStimulusCode . "_dialog";
    $sFormId = $sStimulusCode . "_form";
    $sCancelButtonLabel = Dict::S('UI:Button:Cancel');
    $oP->add('<div id="' . $sDialogId . '" style="display: none;">');
    $sClass = get_class($oObj);
    $oP->add('<form id="' . $sFormId . '" method="post">');
    $sTransactionId = utils::GetNewTransactionId();
    $oP->add("<input type=\"hidden\" id=\"transaction_id\" name=\"transaction_id\" value=\"{$sTransactionId}\">\n");
    $oP->add("<input type=\"hidden\" name=\"class\" value=\"{$sClass}\">");
    $oP->add("<input type=\"hidden\" name=\"id\" value=\"" . $oObj->GetKey() . "\">");
    $oP->add("<input type=\"hidden\" name=\"operation\" value=\"update_request\">");
    $oP->add("<input type=\"hidden\" id=\"stimulus_to_apply\" name=\"apply_stimulus\" value=\"{$sStimulusCode}\">\n");
    foreach ($aEditAtt as $sAttCode) {
        $sValue = $oObj->Get($sAttCode);
        $sDisplayValue = $oObj->GetEditValue($sAttCode);
        $aArgs = array('this' => $oObj, 'formPrefix' => '');
        $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
        $sInputId = 'input_' . $sAttCode;
        $sHTMLValue = "<span id=\"field_{$sStimulusCode}_{$sInputId}\">" . cmdbAbstractObject::GetFormElementForField($oP, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sInputId, '', 0, $aArgs) . '</span>';
        $oP->add('<h1>' . MetaModel::GetLabel($sClass, $sAttCode) . '</h1>');
        $oP->add($sHTMLValue);
    }
    $oP->add('</form>');
    $oP->add('</div>');
    if (!$bHasStimulusForm) {
        $bHasStimulusForm = true;
        $oP->add_script(<<<EOF

function RunStimulusDialog(sStimulusCode, sTitle, sOkButtonLabel)
{
\tvar sWidth = 'auto';
\tif (sStimulusCode == 'ev_reopen')
\t{
\t\t// Avoid having a dialog spanning the complete width of the window
\t\t// just because it contains a CaseLog entry
\t\tsWidth = '80%';
\t}
\t\t\t\t
\t\$('#'+sStimulusCode+'_dialog').dialog({
\t\theight: 'auto',
\t\twidth: sWidth,
\t\tmodal: true,
\t\ttitle: sTitle,
\t\tbuttons: [
\t\t{ text: sOkButtonLabel, click: function() {
\t\t\t\$(this).find('#'+sStimulusCode+'_form').submit();
\t\t} },
\t\t{ text: "{$sCancelButtonLabel}", click: function() {
\t\t\t\$(this).dialog( "close" );
\t\t} }
\t\t]
\t});
\t// Start the validation
\tCheckFields(sStimulusCode+'_form', false);
\t\$('#'+sStimulusCode+'_form').submit( function() {
\t\treturn OnSubmit(sStimulusCode+'_form');
\t});
}
EOF
);
    }
}
 public function GetObjectCreationDlg(WebPage $oPage, $sProposedRealClass = '')
 {
     // For security reasons: check that the "proposed" class is actually a subclass of the linked class
     // and that the current user is allowed to create objects of this class
     $sRealClass = '';
     $oPage->add('<div class="wizContainer" style="vertical-align:top;"><div>');
     $aSubClasses = MetaModel::EnumChildClasses($this->sLinkedClass, ENUM_CHILD_CLASSES_ALL);
     // Including the specified class itself
     $aPossibleClasses = array();
     foreach ($aSubClasses as $sCandidateClass) {
         if (!MetaModel::IsAbstract($sCandidateClass) && UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
             if ($sCandidateClass == $sProposedRealClass) {
                 $sRealClass = $sProposedRealClass;
             }
             $aPossibleClasses[$sCandidateClass] = MetaModel::GetName($sCandidateClass);
         }
     }
     // Only one of the subclasses can be instantiated...
     if (count($aPossibleClasses) == 1) {
         $aKeys = array_keys($aPossibleClasses);
         $sRealClass = $aKeys[0];
     }
     if ($sRealClass != '') {
         $oPage->add("<h1>" . MetaModel::GetClassIcon($sRealClass) . "&nbsp;" . Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($sRealClass)) . "</h1>\n");
         $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode);
         $sExtKeyToMe = $oLinksetDef->GetExtKeyToMe();
         $aFieldFlags = array($sExtKeyToMe => OPT_ATT_HIDDEN);
         cmdbAbstractObject::DisplayCreationForm($oPage, $sRealClass, null, array(), array('formPrefix' => $this->sInputid, 'noRelations' => true, 'fieldsFlags' => $aFieldFlags));
     } else {
         $sClassLabel = MetaModel::GetName($this->sLinkedClass);
         $oPage->add('<p>' . Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel));
         $oPage->add('<nobr><select name="class">');
         asort($aPossibleClasses);
         foreach ($aPossibleClasses as $sClassName => $sClassLabel) {
             $oPage->add("<option value=\"{$sClassName}\">{$sClassLabel}</option>");
         }
         $oPage->add('</select>');
         $oPage->add('&nbsp; <button type="button" onclick="$(\'#' . $this->sInputid . '\').directlinks(\'subclassSelected\');">' . Dict::S('UI:Button:Apply') . '</button><span class="indicator" style="display:inline-block;width:16px"></span></nobr></p>');
     }
     $oPage->add('</div></div>');
 }
 function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
 {
     parent::DisplayBareRelations($oPage, $bEditMode);
     if (!$bEditMode) {
         $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
         $this->DoShowGrantSumary($oPage, 'bizmodel');
         // debug
         if (false) {
             $oPage->SetCurrentTab('More on user rigths (dev only)');
             $oPage->add("<h3>User rights</h3>\n");
             $this->DoShowGrantSumary($oPage, 'addon/userrights');
             $oPage->add("<h3>Change log</h3>\n");
             $this->DoShowGrantSumary($oPage, 'core/cmdb');
             $oPage->add("<h3>Application</h3>\n");
             $this->DoShowGrantSumary($oPage, 'application');
             $oPage->add("<h3>GUI</h3>\n");
             $this->DoShowGrantSumary($oPage, 'gui');
         }
     }
 }
Beispiel #15
0
 /**
  * Merge standard menu items with plugin provided menus items
  */
 public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
 {
     // 1st - add standard built-in menu items
     //
     switch ($iMenuId) {
         case iPopupMenuExtension::MENU_OBJLIST_TOOLKIT:
             // $param is a DBObjectSet
             $oAppContext = new ApplicationContext();
             $sContext = $oAppContext->GetForLink();
             $sDataTableId = is_null($sDataTableId) ? '' : $sDataTableId;
             $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($param->GetFilter()->GetClass());
             $sOQL = addslashes($param->GetFilter()->ToOQL(true));
             $sFilter = urlencode($param->GetFilter()->serialize());
             $sUrl = utils::GetAbsoluteUrlAppRoot() . "pages/{$sUIPage}?operation=search&filter=" . $sFilter . "&{$sContext}";
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?body=" . urlencode($sUrl) . ' '));
             if (UserRights::IsActionAllowed($param->GetFilter()->GetClass(), UR_ACTION_BULK_READ, $param) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
                 // Bulk export actions
                 $aResult[] = new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")");
                 $aResult[] = new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")");
                 $aResult[] = new JSPopupMenuItem('UI:Menu:ExportPDF', Dict::S('UI:Menu:ExportPDF'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'pdf', " . json_encode(Dict::S('UI:Menu:ExportPDF')) . ")");
             }
             $aResult[] = new JSPopupMenuItem('UI:Menu:AddToDashboard', Dict::S('UI:Menu:AddToDashboard'), "DashletCreationDlg('{$sOQL}')");
             $aResult[] = new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('{$sOQL}', '{$sDataTableId}', '{$sContext}')");
             break;
         case iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS:
             // $param is a DBObject
             $oObj = $param;
             $sOQL = "SELECT " . get_class($oObj) . " WHERE id=" . $oObj->GetKey();
             $oFilter = DBObjectSearch::FromOQL($sOQL);
             $sFilter = $oFilter->serialize();
             $sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey());
             $sUIPage = cmdbAbstractObject::ComputeStandardUIPage(get_class($oObj));
             $oAppContext = new ApplicationContext();
             $sContext = $oAppContext->GetForLink();
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js');
             $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js');
             $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css');
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?subject=" . urlencode($oObj->GetRawName()) . "&body=" . urlencode($sUrl) . ' '), new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")"), new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")"));
             break;
         case iPopupMenuExtension::MENU_DASHBOARD_ACTIONS:
             // $param is a Dashboard
             $oAppContext = new ApplicationContext();
             $aParams = $oAppContext->GetAsHash();
             $sMenuId = ApplicationMenu::GetActiveNodeId();
             $sDlgTitle = addslashes(Dict::S('UI:ImportDashboardTitle'));
             $sDlgText = addslashes(Dict::S('UI:ImportDashboardText'));
             $sCloseBtn = addslashes(Dict::S('UI:Button:Cancel'));
             $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:ExportDashboard', Dict::S('UI:ExportDashBoard'), utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=export_dashboard&id=' . $sMenuId), new JSPopupMenuItem('UI:ImportDashboard', Dict::S('UI:ImportDashBoard'), "UploadDashboard({dashboard_id: '{$sMenuId}', title: '{$sDlgTitle}', text: '{$sDlgText}', close_btn: '{$sCloseBtn}' })"));
             break;
         default:
             // Unknown type of menu, do nothing
             $aResult = array();
     }
     foreach ($aResult as $oMenuItem) {
         $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem();
     }
     // Invoke the plugins
     //
     foreach (MetaModel::EnumPlugins('iPopupMenuExtension') as $oExtensionInstance) {
         if (is_object($param) && !$param instanceof DBObject) {
             $tmpParam = clone $param;
             // In case the parameter is an DBObjectSet, clone it to prevent alterations
         } else {
             $tmpParam = $param;
         }
         foreach ($oExtensionInstance->EnumItems($iMenuId, $tmpParam) as $oMenuItem) {
             if (is_object($oMenuItem)) {
                 $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem();
                 foreach ($oMenuItem->GetLinkedScripts() as $sLinkedScript) {
                     $oPage->add_linked_script($sLinkedScript);
                 }
             }
         }
     }
 }
Beispiel #16
0
         $oPage->p('');
         // Some space
     }
     // Then the content of the groups (one table per group)
     if (count($aGroups) > 0) {
         $oPage->get_tcpdf()->AddPage();
         $oPage->add('<div class="page_header"><h1>' . Dict::S('UI:RelationGroups') . '</h1></div>');
         foreach ($aGroups as $idx => $aObjects) {
             set_time_limit($iLoopTimeLimit * count($aObjects));
             $sListClass = get_class(current($aObjects));
             $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects);
             $sHtml = "<div class=\"page_header\">\n";
             $sHtml .= "<table class=\"section\"><tr><td>" . MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;') . " " . Dict::Format('UI:RelationGroupNumber_N', 1 + $idx) . "</td></tr></table>\n";
             $sHtml .= "</div>\n";
             $oPage->add($sHtml);
             cmdbAbstractObject::DisplaySet($oPage, $oSet);
             $oPage->p('');
             // Some space
         }
     }
 }
 if ($operation == 'relation_attachment') {
     $sObjClass = utils::ReadParam('obj_class', '', false, 'class');
     $iObjKey = (int) utils::ReadParam('obj_key', 0, false, 'integer');
     // Save the generated PDF as an attachment
     $sPDF = $oPage->get_pdf();
     $oPage = new ajax_page('');
     $oAttachment = new Attachment();
     $oAttachment->Set('item_class', $sObjClass);
     $oAttachment->Set('item_id', $iObjKey);
     $oDoc = new ormDocument($sPDF, 'application/pdf', $sTitle . '.pdf');
Beispiel #17
0
 public function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
 {
     parent::DisplayBareRelations($oPage, $bEditMode);
     if (!$bEditMode) {
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/fraphael.js');
         $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/jquery.contextMenu.css');
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.contextMenu.js');
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/simple_graph.js');
         $oPage->AddAjaxTab(Dict::S('Ticket:ImpactAnalysis'), utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=ticket_impact&class=' . get_class($this) . '&id=' . $this->GetKey(), true);
     }
 }
 protected function AfterDelete()
 {
     $this->DeleteConnectedNetworkDevice();
     parent::AfterDelete();
 }
 public static function GetRelationQueriesEx($sRelCode)
 {
     switch ($sRelCode) {
         case 'impacts':
             $aRels = array('server' => array('_legacy_' => false, 'sDirection' => 'both', 'sDefinedInClass' => 'LogicalVolume', 'sNeighbour' => 'server', 'sQueryDown' => NULL, 'sQueryUp' => NULL, 'sAttribute' => 'servers_list'), 'VirtualDevice' => array('_legacy_' => false, 'sDirection' => 'both', 'sDefinedInClass' => 'LogicalVolume', 'sNeighbour' => 'VirtualDevice', 'sQueryDown' => NULL, 'sQueryUp' => NULL, 'sAttribute' => 'virtualdevices_list'));
             return array_merge($aRels, parent::GetRelationQueriesEx($sRelCode));
         default:
             return parent::GetRelationQueriesEx($sRelCode);
     }
 }
    /**
     * A one-row form for editing a link record
     * @param WebPage $oP Web page used for the ouput
     * @param DBObject $oLinkedObj The object to which all the elements of the linked set refer to
     * @param mixed $linkObjOrId Either the object linked or a unique number for new link records to add
     * @param Hash $aArgs Extra context arguments
     * @return string The HTML fragment of the one-row form
     */
    protected function GetFormRow(WebPage $oP, DBObject $oLinkedObj, $linkObjOrId = null, $aArgs = array(), $oCurrentObj)
    {
        $sPrefix = "{$this->m_sAttCode}{$this->m_sNameSuffix}";
        $aRow = array();
        $aFieldsMap = array();
        if (is_object($linkObjOrId) && !$linkObjOrId->IsNew()) {
            $key = $linkObjOrId->GetKey();
            $iRemoteObjKey = $linkObjOrId->Get($this->m_sExtKeyToRemote);
            $sPrefix .= "[{$key}][";
            $sNameSuffix = "]";
            // To make a tabular form
            $aArgs['prefix'] = $sPrefix;
            $aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}{$key}";
            $aArgs['this'] = $linkObjOrId;
            $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget" . $this->m_iInputId . ".OnSelectChange();\" value=\"{$key}\">";
            $aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"{$key}\">";
            foreach ($this->m_aEditableFields as $sFieldCode) {
                $sFieldId = $this->m_iInputId . '_' . $sFieldCode . '[' . $linkObjOrId->GetKey() . ']';
                $sSafeId = utils::GetSafeId($sFieldId);
                $oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
                $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '', $sSafeId, $sNameSuffix, 0, $aArgs);
                $aFieldsMap[$sFieldCode] = $sSafeId;
            }
            $sState = $linkObjOrId->GetState();
        } else {
            // form for creating a new record
            if (is_object($linkObjOrId)) {
                // New link existing only in memory
                $oNewLinkObj = $linkObjOrId;
                $iRemoteObjKey = $oNewLinkObj->Get($this->m_sExtKeyToRemote);
                $oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, $iRemoteObjKey);
                $oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj);
                // Setting the extkey with the object also fills the related external fields
                $linkObjOrId = -$iRemoteObjKey;
            } else {
                $iRemoteObjKey = -$linkObjOrId;
                $oNewLinkObj = MetaModel::NewObject($this->m_sLinkedClass);
                $oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, -$linkObjOrId);
                $oNewLinkObj->Set($this->m_sExtKeyToRemote, $oRemoteObj);
                // Setting the extkey with the object alsoo fills the related external fields
                $oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj);
                // Setting the extkey with the object also fills the related external fields
            }
            $sPrefix .= "[{$linkObjOrId}][";
            $sNameSuffix = "]";
            // To make a tabular form
            $aArgs['prefix'] = $sPrefix;
            $aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}_" . -$linkObjOrId;
            $aArgs['this'] = $oNewLinkObj;
            $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget" . $this->m_iInputId . ".OnSelectChange();\" value=\"{$linkObjOrId}\">";
            $aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
            foreach ($this->m_aEditableFields as $sFieldCode) {
                $sFieldId = $this->m_iInputId . '_' . $sFieldCode . '[' . $linkObjOrId . ']';
                $sSafeId = utils::GetSafeId($sFieldId);
                $oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
                $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $oNewLinkObj->Get($sFieldCode), '', $sSafeId, $sNameSuffix, 0, $aArgs);
                $aFieldsMap[$sFieldCode] = $sSafeId;
            }
            $sState = '';
            $oP->add_script(<<<EOF
\$(".date-pick").datepicker({
\t\tshowOn: 'button',
\t\tbuttonImage: '../images/calendar.png',
\t\tbuttonImageOnly: true,
\t\tdateFormat: 'yy-mm-dd',
\t\tconstrainInput: false,
\t\tchangeMonth: true,
\t\tchangeYear: true
\t});
\$(".datetime-pick").datepicker({
\t\tshowOn: 'button',
\t\tbuttonImage: '../images/calendar.png',
\t\tbuttonImageOnly: true,
\t\tdateFormat: 'yy-mm-dd 00:00:00',
\t\tconstrainInput: false,
\t\tchangeMonth: true,
\t\tchangeYear: true
});
EOF
);
        }
        $sExtKeyToMeId = utils::GetSafeId($sPrefix . $this->m_sExtKeyToMe);
        $aFieldsMap[$this->m_sExtKeyToMe] = $sExtKeyToMeId;
        $aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"{$sExtKeyToMeId}\" value=\"" . $oCurrentObj->GetKey() . "\">";
        $sExtKeyToRemoteId = utils::GetSafeId($sPrefix . $this->m_sExtKeyToRemote);
        $aFieldsMap[$this->m_sExtKeyToRemote] = $sExtKeyToRemoteId;
        $aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"{$sExtKeyToRemoteId}\" value=\"{$iRemoteObjKey}\">";
        $iFieldsCount = count($aFieldsMap);
        $sJsonFieldsMap = json_encode($aFieldsMap);
        $oP->add_script(<<<EOF
var {$aArgs['wizHelper']} = new WizardHelper('{$this->m_sLinkedClass}', '', '{$sState}');
{$aArgs['wizHelper']}.SetFieldsMap({$sJsonFieldsMap});
{$aArgs['wizHelper']}.SetFieldsCount({$iFieldsCount});
EOF
);
        $aRow['static::key'] = $oLinkedObj->GetHyperLink();
        foreach (MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode) {
            $aRow['static::' . $sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
        }
        return $aRow;
    }
Beispiel #21
0
/**
 * Helper for the trigger
 */
function DisplayTriggers($oPage, $sClass)
{
    $sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
    $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObject WHERE target_class IN ('{$sClassList}')"));
    cmdbAbstractObject::DisplaySet($oPage, $oSet, array('block_id' => 'triggers'));
}
 /**
  * Get the form to create a new object of the 'target' class
  */
 public function GetObjectCreationForm(WebPage $oPage, $oCurrObject)
 {
     // Set all the default values in an object and clone this "default" object
     $oNewObj = MetaModel::NewObject($this->sTargetClass);
     // 1st - set context values
     $oAppContext = new ApplicationContext();
     $oAppContext->InitObjectFromContext($oNewObj);
     // 2nd set the default values from the constraint on the external key... if any
     if ($oCurrObject != null && $this->sAttCode != '') {
         $oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode);
         $aParams = array('this' => $oCurrObject);
         $oSet = $oAttDef->GetAllowedValuesAsObjectSet($aParams);
         $aConsts = $oSet->ListConstantFields();
         $sClassAlias = $oSet->GetFilter()->GetClassAlias();
         if (isset($aConsts[$sClassAlias])) {
             foreach ($aConsts[$sClassAlias] as $sAttCode => $value) {
                 $oNewObj->Set($sAttCode, $value);
             }
         }
     }
     // 3rd - set values from the page argument 'default'
     $oNewObj->UpdateObjectFromArg('default');
     $sDialogTitle = '';
     $oPage->add('<div id="ac_create_' . $this->iId . '"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_' . $this->iId . '">');
     $oPage->add("<h1>" . MetaModel::GetClassIcon($this->sTargetClass) . "&nbsp;" . Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass)) . "</h1>\n");
     cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true));
     $oPage->add('</div></div></div>');
     //		$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
     $oPage->add_ready_script("\$('#ac_create_{$this->iId}').dialog({ width: 'auto', height: 'auto', maxHeight: \$(window).height() - 50, autoOpen: false, modal: true, title: '{$sDialogTitle}'});\n");
     $oPage->add_ready_script("\$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
     $oPage->add_ready_script("\$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);");
 }
 public static function GetRelationQueries($sRelCode)
 {
     switch ($sRelCode) {
         case "impacts":
             $aRels = array("server" => array("sQuery" => "SELECT Server AS s JOIN lnkServerToVolume AS l1 ON l1.server_id=s.id  WHERE l1.volume_id = :this->id", "bPropagate" => true, "iDistance" => 5));
             if (class_exists('VirtualDevice')) {
                 $aRels["virtualdevice"] = array("sQuery" => "SELECT VirtualDevice AS vd JOIN lnkVirtualDeviceToVolume AS l1 ON l1.virtualdevice_id=vd.id  WHERE l1.volume_id = :this->id", "bPropagate" => true, "iDistance" => 5);
             }
             return array_merge($aRels, parent::GetRelationQueries($sRelCode));
             break;
         case 'depends on':
             $aRels = array("sotragesystem" => array("sQuery" => "SELECT StorageSystem AS storage WHERE storage.id = :this->storagesystem_id", "bPropagate" => true, "iDistance" => 5));
             return array_merge($aRels, parent::GetRelationQueries($sRelCode));
             break;
         default:
             return parent::GetRelationQueries($sRelCode);
     }
 }
Beispiel #24
0
             $oPage->add_header("Expires: ");
             // Reset the value set in ajax_page
             $oPage->add_header("Cache-Control: no-transform,public,max-age={$iCacheSec},s-maxage={$iCacheSec}");
         }
     }
     break;
 case 'search_form':
     $oPage->SetContentType('text/html');
     $sClass = utils::ReadParam('className', '', false, 'class');
     $sRootClass = utils::ReadParam('baseClass', '', false, 'class');
     $currentId = utils::ReadParam('currentId', '');
     $sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data');
     $sAction = utils::ReadParam('action', '');
     $oFilter = new DBObjectSearch($sClass);
     $oSet = new CMDBObjectSet($oFilter);
     $sHtml = cmdbAbstractObject::GetSearchForm($oPage, $oSet, array('currentId' => $currentId, 'baseClass' => $sRootClass, 'action' => $sAction, 'table_id' => $sTableId));
     $oPage->add($sHtml);
     break;
 case 'set_pref':
     $sCode = utils::ReadPostedParam('code', '');
     $sValue = utils::ReadPostedParam('value', '', 'raw_data');
     appUserPreferences::SetPref($sCode, $sValue);
     break;
 case 'erase_all_pref':
     // Can be useful in case a user got some corrupted prefs...
     appUserPreferences::ClearPreferences();
     break;
 case 'on_form_cancel':
     // Called when a creation/modification form is cancelled by the end-user
     // Let's take this opportunity to inform the plug-ins so that they can perform some cleanup
     $iTransactionId = utils::ReadParam('transaction_id', 0);
Beispiel #25
0
     break;
 case 'spreadsheet':
     $oP = new WebPage("iTop - Export for spreadsheet");
     // Integration within MS-Excel web queries + HTTPS + IIS:
     // MS-IIS set these header values with no-cache... while Excel fails to do the job if using HTTPS
     // Then the fix is to force the reset of header values Pragma and Cache-control
     header("Pragma:", true);
     header("Cache-control:", true);
     $sFields = implode(',', $aFields);
     $oP->add_style('table br {mso-data-placement:same-cell;}');
     // Trick for Excel: keep line breaks inside the same cell !
     cmdbAbstractObject::DisplaySetAsHTMLSpreadsheet($oP, $oSet, array('fields' => $sFields, 'fields_advanced' => $bFieldsAdvanced, 'localize_values' => $bLocalize));
     break;
 case 'xml':
     $oP = new XMLPage("iTop - Export", true);
     cmdbAbstractObject::DisplaySetAsXML($oP, $oSet, array('localize_values' => $bLocalize));
     break;
 case 'xlsx':
     $oP = new ajax_page('');
     $oExporter = new ExcelExporter();
     $oExporter->SetObjectList($oFilter);
     // Run the export by chunk of 1000 objects to limit memory usage
     $oExporter->SetChunkSize(1000);
     do {
         $aStatus = $oExporter->Run();
         // process one chunk
     } while ($aStatus['code'] != 'done' && $aStatus['code'] != 'error');
     if ($aStatus['code'] == 'done') {
         $oP->SetContentType('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
         $oP->SetContentDisposition('attachment', $oFilter->GetClass() . '.xlsx');
         $oP->add(file_get_contents($oExporter->GetExcelFilePath()));
 /**
  * Displays a list of objects, without any hyperlink (except for the object's details)
  * @param DBObjectSet $oSet The set of objects to display
  * @param Array $aZList The ZList (list of field codes) to use for the tabular display
  * @param String $sEmptyListMessage Message displayed whenever the list is empty
  * @return string The HTML text representing the list
  */
 public function DisplaySet($oSet, $aZList, $sEmptyListMessage = '')
 {
     if ($oSet->Count() > 0) {
         $sClass = $oSet->GetClass();
         if (is_subclass_of($sClass, 'cmdbAbstractObject')) {
             // Home-made and very limited display of an object set
             $sUniqueId = $sClass . $this->GetUniqueId();
             $this->add("<div id=\"{$sUniqueId}\">\n");
             // The id here MUST be the same as currentId, otherwise the pagination will be broken
             cmdbAbstractObject::DisplaySet($this, $oSet, array('currentId' => $sUniqueId, 'menu' => false, 'toolkit_menu' => false, 'zlist' => false, 'extra_fields' => implode(',', $aZList)));
             $this->add("</div>\n");
         } else {
             // Home-made and very limited display of an object set
             $aAttribs = array();
             $aValues = array();
             $aAttribs['key'] = array('label' => MetaModel::GetName($sClass), 'description' => '');
             foreach ($aZList as $sAttCode) {
                 $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
                 $aAttribs[$sAttCode] = array('label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
             }
             while ($oObj = $oSet->Fetch()) {
                 $aRow = array();
                 $aRow['key'] = '<a href="./index.php?operation=details&class=' . get_class($oObj) . '&id=' . $oObj->GetKey() . '">' . $oObj->GetName() . '</a>';
                 $sHilightClass = $oObj->GetHilightClass();
                 if ($sHilightClass != '') {
                     $aRow['@class'] = $sHilightClass;
                 }
                 foreach ($aZList as $sAttCode) {
                     $aRow[$sAttCode] = $oObj->GetAsHTML($sAttCode);
                 }
                 $aValues[$oObj->GetKey()] = $aRow;
             }
             $this->table($aAttribs, $aValues);
         }
     } elseif (strlen($sEmptyListMessage) > 0) {
         $this->add($sEmptyListMessage);
     }
 }
 public function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
 {
     parent::DisplayBareRelations($oPage, $bEditMode);
     // Display the impact analysis for tickets not in 'closed' or 'resolved' status... and not in edition
     if (!$bEditMode && !in_array($this->Get('status'), array('resolved', 'closed'))) {
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/fraphael.js');
         $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/jquery.contextMenu.css');
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.contextMenu.js');
         $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/simple_graph.js');
         $oPage->AddAjaxTab(Dict::S('Ticket:ImpactAnalysis'), utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=ticket_impact&class=' . get_class($this) . '&id=' . $this->GetKey(), true);
     }
 }