From 69a8d27b5401ac68022bdcadad2a094e3c5ae9a2 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 29 Apr 2010 16:51:56 +0000 Subject: [PATCH] Obsoleted the SibusQL and the keyword pkey (still allowed as a placeholder in the templates) SVN:trunk[372] --- .../userrights/userrightsmatrix.class.inc.php | 2 +- application/audit.rule.class.inc.php | 2 +- application/cmdbabstract.class.inc.php | 6 +- application/displayblock.class.inc.php | 4 - application/template.class.inc.php | 28 +- application/templates/audit_category.html | 8 +- application/usercontext.class.inc.php | 2 +- business/business_test.class.inc.php | 6 +- business/templates/application.html | 18 +- business/templates/change.html | 10 +- business/templates/circuit.html | 14 +- business/templates/contract.html | 12 +- business/templates/default.html | 6 +- business/templates/document.html | 6 +- business/templates/group.html | 10 +- business/templates/interface.html | 8 +- business/templates/knownError.html | 8 +- business/templates/location.html | 16 +- business/templates/network.device.html | 18 +- business/templates/pc.html | 20 +- business/templates/person.html | 14 +- business/templates/server.html | 22 +- business/templates/service.html | 8 +- business/templates/serviceCall.html | 10 +- business/templates/serviceRequest.html | 8 +- business/templates/software.html | 8 +- business/templates/team.html | 14 +- business/templates/ticket.html | 14 +- core/action.class.inc.php | 2 +- core/attributedef.class.inc.php | 4 +- core/cmdbobject.class.inc.php | 2 +- core/data.generator.class.inc.php | 2 +- core/dbobjectsearch.class.php | 197 -- core/dbobjectset.class.php | 2 +- core/metamodel.class.php | 6 +- core/oql/oqlinterpreter.class.inc.php | 4 +- core/test.class.inc.php | 16 +- core/valuesetdef.class.inc.php | 10 +- dictionaries/dictionary.itop.ui.php | 4 +- js/wizard.utils.js | 4 +- pages/UI.php | 6 +- pages/advanced_search.php | 2 +- pages/ajax.render.php | 10 +- pages/audit.php | 18 +- pages/incident.php | 761 ------- pages/index.php | 667 ------ pages/schema.php | 2 +- pages/testlist.inc.php | 43 +- setup/data/60.group.xml | 4 +- setup/data/structure/1.menus.xml | 1896 ++++++++--------- setup/data/structure/21.auditcategories.xml | 4 +- setup/data/structure/22.auditrules.xml | 6 +- webservices/import.php | 2 +- 53 files changed, 1171 insertions(+), 2805 deletions(-) delete mode 100644 pages/incident.php delete mode 100644 pages/index.php diff --git a/addons/userrights/userrightsmatrix.class.inc.php b/addons/userrights/userrightsmatrix.class.inc.php index 5343a5fe7..8dc336764 100644 --- a/addons/userrights/userrightsmatrix.class.inc.php +++ b/addons/userrights/userrightsmatrix.class.inc.php @@ -187,7 +187,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI { // Users must be added manually // This procedure will then update the matrix when a new user is found or a new class/attribute appears - $oUserSet = new DBObjectSet(DBObjectSearch::FromSibuSQL("UserRightsMatrixUsers")); + $oUserSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixUsers")); while ($oUser = $oUserSet->Fetch()) { $this->SetupUser($oUser->GetKey()); diff --git a/application/audit.rule.class.inc.php b/application/audit.rule.class.inc.php index 92230ce7d..1e66d0a0d 100644 --- a/application/audit.rule.class.inc.php +++ b/application/audit.rule.class.inc.php @@ -3,7 +3,7 @@ require_once('../application/audit.category.class.inc.php'); /** * This class manages the audit "rule" linked to a given audit category. - * Each rule is based ona SibusQL expression that returns either the "good" objects + * Each rule is based on an OQL expression that returns either the "good" objects * or the "bad" ones. The core audit engines computes the complement to the definition * set when needed to obtain either the valid objects, or the ones with an error */ diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index ee42bf9dc..236c9e49b 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -85,7 +85,7 @@ abstract class cmdbAbstractObject extends CMDBObject // action menu $oSingletonFilter = new DBObjectSearch(get_class($this)); - $oSingletonFilter->AddCondition('pkey', array($this->GetKey())); + $oSingletonFilter->AddCondition('id', array($this->GetKey())); $oBlock = new MenuBlock($oSingletonFilter, 'popup', false); $oBlock->Display($oPage, -1); @@ -211,7 +211,9 @@ abstract class cmdbAbstractObject extends CMDBObject { $oTemplate = new DisplayTemplate($sTemplate); $sNameAttCode = MetaModel::GetNameAttributeCode(get_class($this)); - $oTemplate->Render($oPage, array('class_name'=> MetaModel::GetName(get_class($this)),'class'=> get_class($this),'pkey'=> $this->GetKey(), 'name' => $this->Get($sNameAttCode))); + // Note: to preserve backward compatibility with home-made templates, the placeholder '$pkey$' has been preserved + // but the preferred method is to use '$id$' + $oTemplate->Render($oPage, array('class_name'=> MetaModel::GetName(get_class($this)),'class'=> get_class($this), 'pkey'=> $this->GetKey(), 'id'=> $this->GetKey(), 'name' => $this->Get($sNameAttCode))); } else { diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index dd313d9ce..5cb3db539 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -138,10 +138,6 @@ class DisplayBlock $oFilter = CMDBSearchFilter::unserialize($sITopData); break; - case 'text/sibusql': - $oFilter = CMDBSearchFilter::FromSibusQL($sITopData); - break; - case 'text/oql': $oFilter = CMDBSearchFilter::FromOQL($sITopData); break; diff --git a/application/template.class.inc.php b/application/template.class.inc.php index b39371591..5fb74476f 100644 --- a/application/template.class.inc.php +++ b/application/template.class.inc.php @@ -31,11 +31,23 @@ class DisplayTemplate $oPage->add(substr($this->m_sTemplate, $iBeforeTagPos, $iStart - $iBeforeTagPos)); if ($sTag == DisplayBlock::TAG_BLOCK) { - $oBlock = DisplayBlock::FromTemplate($sOuterTag); - if (is_object($oBlock)) + try { - $oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams); + $oBlock = DisplayBlock::FromTemplate($sOuterTag); + if (is_object($oBlock)) + { + $oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams); + } } + catch(OQLException $e) + { + $oPage->p('Error in template (please contact your administrator) - Invalid query'); + } + catch(Exception $e) + { + $oPage->p('Error in template (please contact your administrator)'); + } + self::$iBlockCount++; } else @@ -175,19 +187,19 @@ class DisplayTemplate $sTemplate = ' - bizNetworkDevice: pkey = $pkey$ + SELECT bizNetworkDevice AS d WHERE d.id = $id$ - bizInterface: device_id = $pkey$ + SELECT bizInterface AS i WHERE i.device_id = $id$ - bizContact: PKEY IS contact_id IN (ContactsLinks: object_id = $pkey$) + SELECT bizContact AS c JOIN ContactsLinks AS l ON l.contact_id = c.id WHERE l.object_id = $id$ - bizDocument: PKEY IS doc_id IN (lnkDocumentRealObject: object_id = $pkey$) + SELECT bizDocument AS d JOIN lnkDocumentRealObject as l ON l.document_id = d.id WHERE l.object_id = $id$) '; diff --git a/application/templates/audit_category.html b/application/templates/audit_category.html index 0ac638131..415555402 100644 --- a/application/templates/audit_category.html +++ b/application/templates/audit_category.html @@ -1,12 +1,12 @@ -$class$: pkey = $pkey$ +SELECT $class$ WHERE id = $id$ - AuditRule: category_id = $pkey$ + SELECT AuditRule WHERE category_id = $id$ diff --git a/application/usercontext.class.inc.php b/application/usercontext.class.inc.php index 21451feee..89b89b93d 100644 --- a/application/usercontext.class.inc.php +++ b/application/usercontext.class.inc.php @@ -64,7 +64,7 @@ class UserContext { $oObject = null; $oFilter = $this->NewFilter($sClass); - $oFilter->AddCondition('pkey', $sKey, '='); + $oFilter->AddCondition('id', $sKey, '='); $oSet = new CMDBObjectSet($oFilter); if ($oSet->Count() > 0) { diff --git a/business/business_test.class.inc.php b/business/business_test.class.inc.php index 3d1e0db7c..ff38a9d54 100644 --- a/business/business_test.class.inc.php +++ b/business/business_test.class.inc.php @@ -63,7 +63,7 @@ class cmdbObjectHomeMade extends cmdbObject switch ($sRelCode) { case "Potes": - $aRels = array("xxxx" => array("sQuery"=>"cmdbContact: pkey = 40", "bPropagate"=>true, "iDistance"=>3)); + $aRels = array("xxxx" => array("sQuery"=>"SELECT cmdbContact AS c WHERE c.id = 40", "bPropagate"=>true, "iDistance"=>3)); return $aRels; } } @@ -134,8 +134,8 @@ class cmdbContact extends cmdbObjectHomeMade { case "Potes": $aRels = array( - "zz1" => array("sQuery"=>"cmdbContact: name Begins with '\$[this.name::]' AND pkey != \$[this.pkey::]", "bPropagate"=>false, "iDistance"=>3), - "zz2" => array("sQuery"=>"cmdbContact: owner = \$[this.owner::] AND owner != 2", "bPropagate"=>false, "iDistance"=>3), + "zz1" => array("sQuery"=>"SELECT cmdbContact AS c WHERE c.name = '\$[this.name::]'", "bPropagate"=>false, "iDistance"=>3), + "zz2" => array("sQuery"=>"SELECT cmdbContact AS c WHERE c.owner = \$[this.owner::] AND c.owner != 2", "bPropagate"=>false, "iDistance"=>3), ); return array_merge($aRels, parent::GetRelationQueries($sRelCode)); } diff --git a/business/templates/application.html b/business/templates/application.html index a48915c12..368bc2b1d 100644 --- a/business/templates/application.html +++ b/business/templates/application.html @@ -1,29 +1,29 @@ -SELECT bizApplication WHERE id = $pkey$ +SELECT bizApplication WHERE id = $id$ - SELECT lnkClientServer WHERE server_id = $pkey$ + SELECT lnkClientServer WHERE server_id = $id$ - SELECT lnkClientServer WHERE client_id = $pkey$ + SELECT lnkClientServer WHERE client_id = $id$ - lnkInfraTicket: infra_id = $pkey$ + SELECT lnkInfraTicket WHERE infra_id = $id$ - bizChangeTicket: PKEY IS ticket_id IN (lnkInfraChangeTicket: infra_id = $pkey$) + SELECT bizChangeTicket AS c JOIN lnkInfraChangeTicket AS l ON l.ticket_id = c.id WHERE l.infra_id = $id$ - SELECT lnkInfraContract WHERE infra_id = $pkey$ + SELECT lnkInfraContract WHERE infra_id = $id$ - SELECT lnkInfraGrouping WHERE infra_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_id = $id$ diff --git a/business/templates/change.html b/business/templates/change.html index 714cd71e0..8bb8b135d 100644 --- a/business/templates/change.html +++ b/business/templates/change.html @@ -1,16 +1,16 @@ -SELECT $class$ WHERE id = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT lnkInfraChangeTicket WHERE ticket_id = $pkey$ + SELECT lnkInfraChangeTicket WHERE ticket_id = $id$ - SELECT lnkContactChange WHERE change_id = $pkey$ + SELECT lnkContactChange WHERE change_id = $id$ diff --git a/business/templates/circuit.html b/business/templates/circuit.html index 2c2102c44..d217dbe22 100644 --- a/business/templates/circuit.html +++ b/business/templates/circuit.html @@ -1,21 +1,21 @@ -$class$: pkey = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT lnkContactRealObject WHERE object_id = $pkey$ + SELECT lnkContactRealObject WHERE object_id = $id$ - SELECT lnkInfraTicket WHERE infra_id = $pkey$ + SELECT lnkInfraTicket WHERE infra_id = $id$ - SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $pkey$ + SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/contract.html b/business/templates/contract.html index 594a4c9d4..4f4e8dc22 100644 --- a/business/templates/contract.html +++ b/business/templates/contract.html @@ -1,18 +1,18 @@ -SELECT bizContract WHERE id = $pkey$ +SELECT bizContract WHERE id = $id$ - SELECT lnkInfraContract WHERE contract_id = $pkey$ + SELECT lnkInfraContract WHERE contract_id = $id$ - SELECT lnkContactContract WHERE contract_id = $pkey$ + SELECT lnkContactContract WHERE contract_id = $id$ - SELECT lnkDocumentContract WHERE contract_id = $pkey$ + SELECT lnkDocumentContract WHERE contract_id = $id$ diff --git a/business/templates/default.html b/business/templates/default.html index 541b31cdb..591490411 100644 --- a/business/templates/default.html +++ b/business/templates/default.html @@ -1,8 +1,8 @@ -$class$: pkey = $pkey$ +SELECT $class$ WHERE id = $id$ diff --git a/business/templates/document.html b/business/templates/document.html index 72c723746..e112a5341 100644 --- a/business/templates/document.html +++ b/business/templates/document.html @@ -1,7 +1,7 @@ -SELECT $class$ WHERE id = $pkey$ +SELECT $class$ WHERE id = $id$ diff --git a/business/templates/group.html b/business/templates/group.html index a45401ced..f2bec11da 100644 --- a/business/templates/group.html +++ b/business/templates/group.html @@ -1,16 +1,16 @@ -SELECT bizInfraGroup WHERE id = $pkey$ +SELECT bizInfraGroup WHERE id = $id$ - SELECT lnkInfraGrouping WHERE infra_group_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_group_id = $id$ - SELECT lnkContactRealObject WHERE object_id = $pkey$ + SELECT lnkContactRealObject WHERE object_id = $id$ diff --git a/business/templates/interface.html b/business/templates/interface.html index 7b2a95fc3..0a2d21dc3 100644 --- a/business/templates/interface.html +++ b/business/templates/interface.html @@ -1,13 +1,13 @@ -SELECT bizInterface WHERE id = $pkey$ +SELECT bizInterface WHERE id = $id$ - SELECT lnkInfraGrouping WHERE infra_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_id = $id$ diff --git a/business/templates/knownError.html b/business/templates/knownError.html index 4b2ab68ce..8c05dff96 100644 --- a/business/templates/knownError.html +++ b/business/templates/knownError.html @@ -1,11 +1,11 @@ -SELECT bizKnownError WHERE id = $pkey$ +SELECT bizKnownError WHERE id = $id$ - SELECT lnkInfraError WHERE error_id = $pkey$ + SELECT lnkInfraError WHERE error_id = $id$ diff --git a/business/templates/location.html b/business/templates/location.html index 2e3e67591..f2d9ba697 100644 --- a/business/templates/location.html +++ b/business/templates/location.html @@ -1,25 +1,25 @@ -SELECT bizLocation WHERE id = $pkey$ +SELECT bizLocation WHERE id = $id$ - SELECT bizContact WHERE location_id = $pkey$ + SELECT bizContact WHERE location_id = $id$ - SELECT bizServer WHERE location_id = $pkey$ + SELECT bizServer WHERE location_id = $id$ - SELECT bizPC WHERE location_id = $pkey$ + SELECT bizPC WHERE location_id = $id$ - SELECT bizNetworkDevice WHERE location_id = $pkey$ + SELECT bizNetworkDevice WHERE location_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/network.device.html b/business/templates/network.device.html index 182cf984d..47d1dc623 100644 --- a/business/templates/network.device.html +++ b/business/templates/network.device.html @@ -1,28 +1,28 @@ -SELECT bizNetworkDevice WHERE id = $pkey$ +SELECT bizNetworkDevice WHERE id = $id$ - SELECT bizInterface WHERE device_id = $pkey$ + SELECT bizInterface WHERE device_id = $id$ - SELECT lnkContactInfra WHERE infra_id = $pkey$ + SELECT lnkContactInfra WHERE infra_id = $id$ - SELECT lnkInfraTicket WHERE infra_id = $pkey$ + SELECT lnkInfraTicket WHERE infra_id = $id$ - bizChangeTicket: PKEY IS ticket_id IN (lnkInfraChangeTicket: infra_id = $pkey$) + SELECT bizChangeTicket AS c JOIN lnkInfraChangeTicket AS l ON l.ticket_id = c.id WHERE l.infra_id = $id$ - SELECT lnkInfraGrouping WHERE infra_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/pc.html b/business/templates/pc.html index 077b9cba1..afe5fe2ef 100644 --- a/business/templates/pc.html +++ b/business/templates/pc.html @@ -1,30 +1,30 @@ -SELECT bizPC WHERE id = $pkey$ +SELECT bizPC WHERE id = $id$ - SELECT bizApplication WHERE device_id = $pkey$ + SELECT bizApplication WHERE device_id = $id$ - SELECT bizPatch WHERE device_id = $pkey$ + SELECT bizPatch WHERE device_id = $id$ - SELECT bizInterface WHERE device_id = $pkey$ + SELECT bizInterface WHERE device_id = $id$ - SELECT lnkContactRealObject WHERE object_id = $pkey$ + SELECT lnkContactRealObject WHERE object_id = $id$ - SELECT lnkInfraTicket WHERE infra_id = $pkey$ + SELECT lnkInfraTicket WHERE infra_id = $id$ - SELECT lnkInfraGrouping WHERE infra_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/person.html b/business/templates/person.html index c59073aef..f90961ad9 100644 --- a/business/templates/person.html +++ b/business/templates/person.html @@ -1,22 +1,22 @@ -SELECT bizPerson WHERE id = $pkey$ +SELECT bizPerson WHERE id = $id$ - SELECT lnkContactTeam WHERE contact_id = $pkey$ + SELECT lnkContactTeam WHERE contact_id = $id$ - SELECT lnkContactRealObject WHERE contact_id = $pkey$ + SELECT lnkContactRealObject WHERE contact_id = $id$ - SELECT bizServiceCall WHERE caller_id = $pkey$ + SELECT bizServiceCall WHERE caller_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/server.html b/business/templates/server.html index edd68d515..f0a93c518 100644 --- a/business/templates/server.html +++ b/business/templates/server.html @@ -1,34 +1,34 @@ -SELECT bizServer WHERE id = $pkey$ +SELECT bizServer WHERE id = $id$ - SELECT bizApplication WHERE device_id = $pkey$ + SELECT bizApplication WHERE device_id = $id$ - SELECT bizPatch WHERE device_id = $pkey$ + SELECT bizPatch WHERE device_id = $id$ - SELECT bizInterface WHERE device_id = $pkey$ + SELECT bizInterface WHERE device_id = $id$ - SELECT lnkContactRealObject WHERE object_id = $pkey$ + SELECT lnkContactRealObject WHERE object_id = $id$ - SELECT lnkInfraTicket WHERE infra_id = $pkey$ + SELECT lnkInfraTicket WHERE infra_id = $id$ - SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $pkey$ + SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $id$ - SELECT lnkInfraGrouping WHERE infra_id = $pkey$ + SELECT lnkInfraGrouping WHERE infra_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/service.html b/business/templates/service.html index f26268d80..00fa62b7e 100644 --- a/business/templates/service.html +++ b/business/templates/service.html @@ -1,13 +1,13 @@ -SELECT bizService WHERE id=$pkey$ +SELECT bizService WHERE id=$id$ - SELECT bizContract WHERE service_id = $pkey$ + SELECT bizContract WHERE service_id = $id$ diff --git a/business/templates/serviceCall.html b/business/templates/serviceCall.html index 38ed4e2c1..ae9a374bf 100644 --- a/business/templates/serviceCall.html +++ b/business/templates/serviceCall.html @@ -1,16 +1,16 @@ -SELECT $class$ WHERE id = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT lnkInfraCall WHERE call_id = $pkey$ + SELECT lnkInfraCall WHERE call_id = $id$ - SELECT lnkCallTicket WHERE call_id = $pkey$ + SELECT lnkCallTicket WHERE call_id = $id$ diff --git a/business/templates/serviceRequest.html b/business/templates/serviceRequest.html index 4e95b7b51..7de7c26cb 100644 --- a/business/templates/serviceRequest.html +++ b/business/templates/serviceRequest.html @@ -1,12 +1,12 @@ -SELECT $class$ WHERE id = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT bizServiceItem WHERE request_id = $pkey$ + SELECT bizServiceItem WHERE request_id = $id$ diff --git a/business/templates/software.html b/business/templates/software.html index 12663e9e2..ac5f4dea2 100644 --- a/business/templates/software.html +++ b/business/templates/software.html @@ -1,13 +1,13 @@ -bizSoftware: pkey = $pkey$ +SELECT bizSoftware WHERE id = $id$ - bizApplication: soft_id = $pkey$ + SELECT bizApplication WHERE soft_id = $id$ diff --git a/business/templates/team.html b/business/templates/team.html index d38eea2f6..c1af81e4a 100644 --- a/business/templates/team.html +++ b/business/templates/team.html @@ -1,22 +1,22 @@ -SELECT $class$ WHERE id = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT lnkContactTeam WHERE team_id=$pkey$ + SELECT lnkContactTeam WHERE team_id=$id$ - SELECT lnkContactInfra WHERE contact_id = $pkey$ + SELECT lnkContactInfra WHERE contact_id = $id$ - SELECT bizWorkgroup WHERE team_id = $pkey$ + SELECT bizWorkgroup WHERE team_id = $id$ - SELECT lnkDocumentRealObject WHERE object_id = $pkey$ + SELECT lnkDocumentRealObject WHERE object_id = $id$ diff --git a/business/templates/ticket.html b/business/templates/ticket.html index 10df94386..743987493 100644 --- a/business/templates/ticket.html +++ b/business/templates/ticket.html @@ -1,22 +1,22 @@ -$class$: pkey = $pkey$ +SELECT $class$ WHERE id = $id$ - SELECT lnkInfraTicket WHERE ticket_id = $pkey$ + SELECT lnkInfraTicket WHERE ticket_id = $id$ - SELECT lnkRelatedTicket WHERE ticket_id = $pkey$ + SELECT lnkRelatedTicket WHERE ticket_id = $id$ - SELECT lnkContactTicket WHERE ticket_id = $pkey$ + SELECT lnkContactTicket WHERE ticket_id = $id$ - SELECT EventNotificationEmail AS Ev JOIN TriggerOnObject AS T ON Ev.trigger_id = T.id WHERE T.target_class = 'bizIncidentTicket' AND Ev.object_id = $pkey$ + SELECT EventNotificationEmail AS Ev JOIN TriggerOnObject AS T ON Ev.trigger_id = T.id WHERE T.target_class = 'bizIncidentTicket' AND Ev.object_id = $id$ diff --git a/core/action.class.inc.php b/core/action.class.inc.php index d17424503..259972f0b 100644 --- a/core/action.class.inc.php +++ b/core/action.class.inc.php @@ -188,7 +188,7 @@ class ActionEmail extends ActionNotification { $oSearch = DBObjectSearch::FromOQL($sOQL); } - catch (OqlException $e) + catch (OQLException $e) { $this->m_aMailErrors[] = "query syntax error for recipient '$sRecipAttCode'"; return $e->getMessage(); diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 6bf2072a5..1a7bdb7b6 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -1085,7 +1085,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid if (!$oValSetDef) { // Let's propose every existing value - $oValSetDef = new ValueSetObjects($this->GetTargetClass()); + $oValSetDef = new ValueSetObjects('SELECT '.$this->GetTargetClass()); } return $oValSetDef; } @@ -1099,7 +1099,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid catch (MissingQueryArgument $e) { // Some required arguments could not be found, enlarge to any existing value - $oValSetDef = new ValueSetObjects($this->GetTargetClass()); + $oValSetDef = new ValueSetObjects('SELECT '.$this->GetTargetClass()); return $oValSetDef->GetValues($aArgs, $sBeginsWith); } } diff --git a/core/cmdbobject.class.inc.php b/core/cmdbobject.class.inc.php index 70f24506b..64485a4e8 100644 --- a/core/cmdbobject.class.inc.php +++ b/core/cmdbobject.class.inc.php @@ -383,7 +383,7 @@ abstract class CMDBObject extends DBObject // Get the list of objects to delete (and record data before deleting the DB records) $oObjSet = new CMDBObjectSet($oFilter); - $aObjAndKeys = array(); // array of pkey=>object + $aObjAndKeys = array(); // array of id=>object while ($oItem = $oObjSet->Fetch()) { $aObjAndKeys[$oItem->GetKey()] = $oItem; diff --git a/core/data.generator.class.inc.php b/core/data.generator.class.inc.php index 03cb9db64..f113a89e3 100644 --- a/core/data.generator.class.inc.php +++ b/core/data.generator.class.inc.php @@ -350,7 +350,7 @@ class cmdbDataGenerator { $oOrg = null; $oFilter = new CMDBSearchFilter('bizOrganization'); - $oFilter->AddCondition('pkey', $sId, '='); + $oFilter->AddCondition('id', $sId, '='); $oSet = new CMDBObjectSet($oFilter); if ($oSet->Count() > 0) { diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index d66d22dad..4d7c3ed21 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -13,22 +13,6 @@ */ -/** - * Sibusql - value set start - * @package iTopORM - */ -define('VS_START', '{'); -/** - * Sibusql - value set end - * @package iTopORM - */ -define('VS_END', '}'); - - -define('SIBUSQLPARAMREGEXP', "/\\$\\[(.*)\\:(.*)\\:(.*)\\]/U"); -define('SIBUSQLTHISREGEXP', "/this\\.(.*)/U"); - - /** * Define filters for a given class of objects (formerly named "filter") * @@ -241,11 +225,6 @@ class DBObjectSearch public function AddCondition($sFilterCode, $value, $sOpCode = null) { - // #@# backward compatibility for pkey/id - if (strtolower(trim($sFilterCode)) == 'pkey') $sFilterCode = 'id'; -// #@# todo - obsolete smoothly, first send exceptions -// throw new CoreException('SibusQL has been obsoleted, please update your queries', array('sibusql'=>$sQuery, 'oql'=>$oFilter->ToOQL())); - MyHelpers::CheckKeyInArray('filter code', $sFilterCode, MetaModel::GetClassFilterDefs($this->GetClass())); $oFilterDef = MetaModel::GetClassFilterDef($this->GetClass(), $sFilterCode); @@ -719,77 +698,6 @@ class DBObjectSearch return $sRes; } - public function ToSibusQL() - { - return "NONONO"; - } - - static private function privProcessParams($sQuery, array $aParams, $oDbObject) - { - $iPlaceHoldersCount = preg_match_all(SIBUSQLPARAMREGEXP, $sQuery, $aMatches, PREG_SET_ORDER); - if ($iPlaceHoldersCount > 0) - { - foreach($aMatches as $aMatch) - { - $sStringToSearch = $aMatch[0]; - $sParameterName = $aMatch[1]; - $sDefaultValue = $aMatch[2]; - $sDescription = $aMatch[3]; - - $sValue = $sDefaultValue; - if (array_key_exists($sParameterName, $aParams)) - { - $sValue = $aParams[$sParameterName]; - unset($aParams[$sParameterName]); - } - else if (is_object($oDbObject)) - { - if (strpos($sParameterName, "this.") === 0) - { - $sAttCode = substr($sParameterName, strlen("this.")); - if ($sAttCode == 'id') - { - $sValue = $oDbObject->GetKey(); - } - else if ($sAttCode == 'class') - { - $sValue = get_class($oDbObject); - } - else if (MetaModel::IsValidAttCode(get_class($oDbObject), $sAttCode)) - { - $sValue = $oDbObject->Get($sAttCode); - } - } - } - $sQuery = str_replace($sStringToSearch, $sValue, $sQuery); - } - } - if (count($aParams) > 0) - { -// throw new CoreException("Unused parameter(s) for this SibusQL expression: (".implode(', ', array_keys($aParams)).")"); - } - return $sQuery; - } - - static public function ListSibusQLParams($sQuery) - { - $aRet = array(); - $iPlaceHoldersCount = preg_match_all(SIBUSQLPARAMREGEXP, $sQuery, $aMatches, PREG_SET_ORDER); - if ($iPlaceHoldersCount > 0) - { - foreach($aMatches as $aMatch) - { - $sStringToSearch = $aMatch[0]; - $sParameterName = $aMatch[1]; - $sDefaultValue = $aMatch[2]; - $sDescription = $aMatch[3]; - $aRet[$sParameterName]["description"] = $sDescription; - $aRet[$sParameterName]["default"] = $sDefaultValue; - } - } - return $aRet; - } - protected function OQLExpressionToCondition($sQuery, $oExpression, $aClassAliases) { if ($oExpression instanceof BinaryOqlExpression) @@ -991,111 +899,6 @@ class DBObjectSearch return $oResultFilter; } - static public function FromSibusQL($sQuery, array $aParams = array(), $oObject = null) - { - if (empty($sQuery)) return null; - $sQuery = self::privProcessParams($sQuery, $aParams, $oObject); - - if (preg_match('@^\\s*SELECT@', $sQuery)) - { - return self::FromOQL($sQuery); - } - - $iSepPos = strpos($sQuery, ":"); - if ($iSepPos === false) - { - // Only the class was specified -> all rows are required - $sClass = trim($sQuery); - $oFilter = new DBObjectSearch($sClass); - } - else - { - $sClass = trim(substr($sQuery, 0, $iSepPos)); - $sConds = trim(substr($sQuery, $iSepPos + 1)); - $aValues = explode(" AND ", $sConds); - - $oFilter = new DBObjectSearch($sClass); - - foreach ($aValues as $sCond) - { - $sCond = trim($sCond); - - if (strpos($sCond, "* HAS ") === 0) - { - $sValue = self::Expression2Value(substr($sCond, strlen("* HAS "))); - $oFilter->AddCondition_FullText($sValue); - } - else if (preg_match("@^(\S+) IN \\((.+)\\)$@", $sCond, $aMatches)) - { - $sExtKeyAttCode = $aMatches[1]; - $sFilterExp = $aMatches[2]; - - $oSubFilter = self::FromSibuSQL($sFilterExp); - $oFilter->AddCondition_PointingTo($oSubFilter, $sExtKeyAttCode); - } - else if (strpos($sCond, "PKEY IS ") === 0) - { - if (preg_match("@^PKEY IS (\S+) IN \\((.+)\\)$@", $sCond, $aMatches)) - { - $sExtKeyAttCodeToMe = $aMatches[1]; - $sFilterExp = $aMatches[2]; - $oRemoteFilter = self::FromSibuSQL($sFilterExp); - $oFilter->AddCondition_ReferencedBy($oRemoteFilter, $sExtKeyAttCodeToMe); - } - } - else if (strpos($sCond, "RELATED") === 0) - { - if (preg_match("@^RELATED\s*\\((.+)\\)\s*TO\s*\\((.+)\\)@", trim($sCond), $aMatches)) - { - $aRelation = explode(',', trim($aMatches[1])); - $sRelCode = trim($aRelation[0]); - $iMaxDepth = intval(trim($aRelation[1])); - $sFilterExp = trim($aMatches[2]); - - $oSubFilter = self::FromSibuSQL($sFilterExp); - $oFilter->AddCondition_RelatedTo($oSubFilter, $sRelCode, $iMaxDepth); - } - } - else - { - $sOperandExpr = "'.*'|\d+|-\d+|".VS_START.".+".VS_END; - if (preg_match("@^(\S+)\s+(.*)\s+($sOperandExpr)$@", $sCond, $aMatches)) - { - $sFltCode = trim($aMatches[1]); - $sOpCode = trim($aMatches[2]); - $value = self::Expression2Value($aMatches[3]); - $oFilter->AddCondition($sFltCode, $value, $sOpCode); - } - else - { - throw new CoreException("Wrong format for filter definition: '$sQuery'"); - } - } - } - } - -// #@# todo - obsolete smoothly, first give the OQL version ! -// throw new CoreException('SibusQL has been obsoleted, please update your queries', array('sibusql'=>$sQuery, 'oql'=>$oFilter->ToOQL())); - - return $oFilter; - } - - // Sexy display of a SibuSQL expression - static public function SibuSQLAsHtml($sQuery) - { - $sQuery = htmlentities($sQuery); - $aParams = self::ListSibusQLParams($sQuery); - $aParamValues = array(); - foreach ($aParams as $sParamName => $aParamInfo) - { - $sDescription = $aParamInfo["description"]; - $sDefaultValue = $aParamInfo["default"]; - $aParamValues[$sParamName] = "$sParamName"; - } - $sQuery = self::privProcessParams($sQuery, $aParamValues, null); - return $sQuery; - } - public function toxpath() { // #@# a voir... diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index a8ae635d9..14ac3fbff 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -41,7 +41,7 @@ class DBObjectSet { $sRet = ''; $this->Rewind(); - $sRet .= "Set (".$this->m_oFilter->ToSibuSQL().")
\n"; + $sRet .= "Set (".$this->m_oFilter->ToOQL().")
\n"; $sRet .= "Query:
".MetaModel::MakeSelectQuery($this->m_oFilter, array()).")
\n"; $sRet .= $this->Count()." records
\n"; diff --git a/core/metamodel.class.php b/core/metamodel.class.php index deca1f5ee..ca5660238 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -1432,7 +1432,7 @@ abstract class MetaModel $aClassAliases = array_merge($aClassAliases, $oFilter->GetJoinedClasses()); } - self::DbgTrace("Entering: ".$oFilter->ToSibuSQL().", ".($bIsOnQueriedClass ? "MAIN" : "SECONDARY").", expectedatts=".count($aExpectedAtts).": ".implode(",", array_keys($aExpectedAtts))); + self::DbgTrace("Entering: ".$oFilter->ToOQL().", ".($bIsOnQueriedClass ? "MAIN" : "SECONDARY").", expectedatts=".count($aExpectedAtts).": ".implode(",", array_keys($aExpectedAtts))); $sRootClass = self::GetRootClass($sClass); $sKeyField = self::DBGetKey($sClass); @@ -1515,7 +1515,7 @@ abstract class MetaModel self::DbgTrace("Referenced by foreign key: $sForeignKeyAttCode... let's call MakeQuery()"); //self::DbgTrace($oForeignFilter); - //self::DbgTrace($oForeignFilter->ToSibuSQL()); + //self::DbgTrace($oForeignFilter->ToOQL()); //self::DbgTrace($oSelectForeign); //self::DbgTrace($oSelectForeign->RenderSelect(array())); $oSelectForeign = self::MakeQuery($aSelectedClasses, $oConditionTree, $aClassAliases, $aTableAliases, $aTranslation, $oForeignFilter, $aExpAtts); @@ -1589,7 +1589,7 @@ abstract class MetaModel $bIsOnQueriedClass = array_key_exists($sTargetAlias, $aSelectedClasses); - self::DbgTrace("Entering: tableclass=$sTableClass, filter=".$oFilter->ToSibuSQL().", ".($bIsOnQueriedClass ? "MAIN" : "SECONDARY").", expectedatts=".count($aExpectedAtts).": ".implode(",", array_keys($aExpectedAtts))); + self::DbgTrace("Entering: tableclass=$sTableClass, filter=".$oFilter->ToOQL().", ".($bIsOnQueriedClass ? "MAIN" : "SECONDARY").", expectedatts=".count($aExpectedAtts).": ".implode(",", array_keys($aExpectedAtts))); // 1 - SELECT and UPDATE // diff --git a/core/oql/oqlinterpreter.class.inc.php b/core/oql/oqlinterpreter.class.inc.php index 2a8ffe359..90fd60c1f 100644 --- a/core/oql/oqlinterpreter.class.inc.php +++ b/core/oql/oqlinterpreter.class.inc.php @@ -41,7 +41,7 @@ class OqlInterpreter $oRes = $this->Parse(); if (!$oRes instanceof OqlObjectQuery) { - throw new OqlException('Expecting an OQL query', $this->m_sQuery, 0, 0, get_class($oRes), array('OqlObjectQuery')); + throw new OQLException('Expecting an OQL query', $this->m_sQuery, 0, 0, get_class($oRes)); } return $oRes; } @@ -51,7 +51,7 @@ class OqlInterpreter $oRes = $this->Parse(); if (!$oRes instanceof Expression) { - throw new OqlException('Expecting an OQL expression', $this->m_sQuery, 0, 0, get_class($oRes), array('Expression')); + throw new OQLException('Expecting an OQL expression', $this->m_sQuery, 0, 0, get_class($oRes), array('Expression')); } return $oRes; } diff --git a/core/test.class.inc.php b/core/test.class.inc.php index 1b1a6cdf0..9924b11f9 100644 --- a/core/test.class.inc.php +++ b/core/test.class.inc.php @@ -492,10 +492,10 @@ abstract class TestBizModel extends TestHandler self::show_list($oObjSet); } - static protected function search_and_show_list_from_sibusql($sSibuSQL) + static protected function search_and_show_list_from_oql($sOQL) { - echo $sSibuSQL."...
\n"; - $oNewFilter = DBObjectSearch::FromSibuSQL($sSibuSQL); + echo $sOQL."...
\n"; + $oNewFilter = DBObjectSearch::FromOQL($sOQL); self::search_and_show_list($oNewFilter); } } @@ -544,14 +544,14 @@ abstract class TestBizModelGeneric extends TestBizModel $oBaby = new $sClassName; $oFilter = new DBObjectSearch($sClassName); - // Challenge reversibility of SibusQL / filter object + // Challenge reversibility of OQL / filter object // - $sExpr1 = $oFilter->ToSibuSQL(); - $oNewFilter = DBObjectSearch::FromSibuSQL($sExpr1); - $sExpr2 = $oNewFilter->ToSibuSQL(); + $sExpr1 = $oFilter->ToOQL(); + $oNewFilter = DBObjectSearch::FromOQL($sExpr1); + $sExpr2 = $oNewFilter->ToOQL(); if ($sExpr1 != $sExpr2) { - $this->ReportError("Found two different SibuSQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); + $this->ReportError("Found two different OQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); } // Use the filter (perform the query) diff --git a/core/valuesetdef.class.inc.php b/core/valuesetdef.class.inc.php index a96ffaeae..1d7868763 100644 --- a/core/valuesetdef.class.inc.php +++ b/core/valuesetdef.class.inc.php @@ -78,7 +78,7 @@ abstract class ValueSetDefinition */ class ValueSetObjects extends ValueSetDefinition { - protected $m_sFilterExpr; // in SibuSQL + protected $m_sFilterExpr; // in OQL protected $m_sValueAttCode; protected $m_aOrderBy; @@ -93,7 +93,7 @@ class ValueSetObjects extends ValueSetDefinition { $this->m_aValues = array(); - $oFilter = DBObjectSearch::FromSibusQL($this->m_sFilterExpr, $aArgs); + $oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr, $aArgs); if (!$oFilter) return false; $oObjects = new DBObjectSet($oFilter, $this->m_aOrderBy, $aArgs); @@ -102,9 +102,9 @@ class ValueSetObjects extends ValueSetDefinition if (empty($this->m_sValueAttCode)) { $this->m_aValues[$oObject->GetKey()] = $oObject->GetName(); - } - else - { + } + else + { $this->m_aValues[$oObject->GetKey()] = $oObject->GetAsHTML($this->m_sValueAttCode); } } diff --git a/dictionaries/dictionary.itop.ui.php b/dictionaries/dictionary.itop.ui.php index 5b66f7388..f35517eb0 100644 --- a/dictionaries/dictionary.itop.ui.php +++ b/dictionaries/dictionary.itop.ui.php @@ -57,7 +57,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:AuditCategory/Attribute:description' => 'Audit Category Description', 'Class:AuditCategory/Attribute:description+' => 'Long description for this audit category', 'Class:AuditCategory/Attribute:definition_set' => 'Definition Set', - 'Class:AuditCategory/Attribute:definition_set+' => 'SibusQL expression defining the set of objects to audit', + 'Class:AuditCategory/Attribute:definition_set+' => 'OQL expression defining the set of objects to audit', )); // @@ -72,7 +72,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:AuditRule/Attribute:description' => 'Audit Rule Description', 'Class:AuditRule/Attribute:description+' => 'Long description for this audit rule', 'Class:AuditRule/Attribute:query' => 'Query to Run', - 'Class:AuditRule/Attribute:query+' => 'The SibusQL expression to run', + 'Class:AuditRule/Attribute:query+' => 'The OQL expression to run', 'Class:AuditRule/Attribute:valid_flag' => 'Valid objects?', 'Class:AuditRule/Attribute:valid_flag+' => 'True if the rule returns the valid objects, false otherwise', 'Class:AuditRule/Attribute:valid_flag/Value:true' => 'true', diff --git a/js/wizard.utils.js b/js/wizard.utils.js index 02a7d00c4..70cdf4cbb 100644 --- a/js/wizard.utils.js +++ b/js/wizard.utils.js @@ -8,8 +8,8 @@ function UpdateObjectList(sClass, sId, sExtKeyToRemote) { aRelatedObjectIds[0] = 0; } - var sibusql = sClass+": pkey IN {" + aRelatedObjectIds.join(", ") + "}"; - $.get("ajax.render.php?filter=" + sibusql + "&style=list&encoding=sibusql", + var oql = "SELECT "+sClass+" AS c WHERE c.id IN (" + aRelatedObjectIds.join(", ") + ")"; + $.get("ajax.render.php?filter=" + oql + "&style=list&encoding=oql", { operation: "ajax" }, function(data){ $("#related_objects_"+sId).empty(); diff --git a/pages/UI.php b/pages/UI.php index 967e6c8fb..23ccf0124 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -230,7 +230,7 @@ try $oP->add("
\n"); $oP->add("

".Metamodel::GetName($sClassName).": ".count($aLeafs)." object(s) found.

\n"); $oP->add("
\n"); - $oLeafsFilter->AddCondition('pkey', $aLeafs, 'IN'); + $oLeafsFilter->AddCondition('id', $aLeafs, 'IN'); $oBlock = new DisplayBlock($oLeafsFilter, 'list', false); $oBlock->Display($oP, $iBlock++); } @@ -261,7 +261,7 @@ try { // Check if the user can modify this object $oSearch = new DBObjectSearch($sClass); - $oSearch->AddCondition('pkey', $id, '='); + $oSearch->AddCondition('id', $id, '='); $oSet = new CMDBObjectSet($oSearch); if ($oSet->Count() > 0) { @@ -301,7 +301,7 @@ try { // Check if the user can modify this object $oSearch = new DBObjectSearch($sClass); - $oSearch->AddCondition('pkey', $id, '='); + $oSearch->AddCondition('id', $id, '='); $oSet = new CMDBObjectSet($oSearch); if ($oSet->Count() > 0) { diff --git a/pages/advanced_search.php b/pages/advanced_search.php index 5629973d8..cb2a4ec6b 100644 --- a/pages/advanced_search.php +++ b/pages/advanced_search.php @@ -68,7 +68,7 @@ function Page2_ConfigFilters($oPage, $oFilter) $sValue = ""; foreach($oFilter->GetCriteria() as $aCritInfo) { - if ($aCritInfo["filtercode"] == "pkey") + if ($aCritInfo["filtercode"] == "id") { // ??? } diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 665377360..ba95c5ea1 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -107,9 +107,9 @@ switch($operation) { $aExtraParams = json_decode(str_replace("'", '"', $sExtraParams), true /* associative array */); } - if ($sEncoding == 'sibusql') + if ($sEncoding == 'oql') { - $oFilter = CMDBSearchFilter::FromSibusQL($sFilter); + $oFilter = CMDBSearchFilter::FromOQL($sFilter); } else { @@ -127,7 +127,7 @@ switch($operation) case 'details': $key = utils::ReadParam('id', 0); $oFilter = $oContext->NewFilter($sClass); - $oFilter->AddCondition('pkey', $key, '='); + $oFilter->AddCondition('id', $key, '='); $oDisplayBlock = new DisplayBlock($oFilter, 'details', false); $oDisplayBlock->RenderContent($oPage); break; @@ -135,7 +135,7 @@ switch($operation) case 'preview': $key = utils::ReadParam('id', 0); $oFilter = $oContext->NewFilter($sClass); - $oFilter->AddCondition('pkey', $key, '='); + $oFilter->AddCondition('id', $key, '='); $oDisplayBlock = new DisplayBlock($oFilter, 'preview', false); $oDisplayBlock->RenderContent($oPage); break; @@ -187,7 +187,7 @@ switch($operation) case 'modal_details': $key = utils::ReadParam('id', 0); $oFilter = $oContext->NewFilter($sClass); - $oFilter->AddCondition('pkey', $key, '='); + $oFilter->AddCondition('id', $key, '='); $oPage->Add("

Object Details

\n"); $oDisplayBlock = new DisplayBlock($oFilter, 'details', false); $oDisplayBlock->RenderContent($oPage); diff --git a/pages/audit.php b/pages/audit.php index 5219c4d3b..aadc4f8f3 100644 --- a/pages/audit.php +++ b/pages/audit.php @@ -17,8 +17,8 @@ function GetRuleResultSet($iRuleId, $oDefinitionFilter) $oContext = new UserContext(); $oRule = $oContext->GetObject('AuditRule', $iRuleId); - $sSibusql = $oRule->Get('query'); - $oRuleFilter = DBObjectSearch::FromSibusQL($sSibusql); + $sOql = $oRule->Get('query'); + $oRuleFilter = DBObjectSearch::FromOQL($sOql); if ($oRule->Get('valid_flag') == 'false') { // The query returns directly the invalid elements @@ -37,7 +37,7 @@ function GetRuleResultSet($iRuleId, $oDefinitionFilter) $aValidIds[] = $oObj->GetKey(); } $oFilter = $oDefinitionFilter; - $oFilter->AddCondition('pkey', $aValidIds, 'NOTIN'); + $oFilter->AddCondition('id', $aValidIds, 'NOTIN'); $oErrorObjectSet = new CMDBObjectSet($oFilter); } return $oErrorObjectSet; @@ -65,7 +65,7 @@ switch($operation) $oContext = new UserContext(); $oAuditCategory = $oContext->GetObject('AuditCategory', $iCategory); - $oDefinitionFilter = DBObjectSearch::FromSibusQL($oAuditCategory->Get('definition_set')); + $oDefinitionFilter = DBObjectSearch::FromOQL($oAuditCategory->Get('definition_set')); if (!empty($currentOrganization)) { $oDefinitionFilter->AddCondition('org_id', $currentOrganization); @@ -94,13 +94,13 @@ switch($operation) $oP->add("\n"); while($oAuditCategory = $oCategoriesSet->fetch()) { - $oDefinitionFilter = DBObjectSearch::FromSibusQL($oAuditCategory->Get('definition_set')); + $oDefinitionFilter = DBObjectSearch::FromOQL($oAuditCategory->Get('definition_set')); $aObjectsWithErrors = array(); if (!empty($currentOrganization)) - { - if (MetaModel::IsValidFilterCode($oDefinitionFilter->GetClass(), 'org_id')) + { + if (MetaModel::IsValidFilterCode($oDefinitionFilter->GetClass(), 'org_id')) { - $oDefinitionFilter->AddCondition('org_id', $currentOrganization); + $oDefinitionFilter->AddCondition('org_id', $currentOrganization); } } $aResults = array(); @@ -122,7 +122,7 @@ switch($operation) } else { - $oRuleFilter = DBObjectSearch::FromSibusQL($oAuditRule->Get('query')); + $oRuleFilter = DBObjectSearch::FromOQL($oAuditRule->Get('query')); $oErrorObjectSet = GetRuleResultSet($oAuditRule->GetKey(), $oDefinitionFilter); $iErrorsCount = $oErrorObjectSet->Count(); while($oObj = $oErrorObjectSet->Fetch()) diff --git a/pages/incident.php b/pages/incident.php deleted file mode 100644 index 8024cd77b..000000000 --- a/pages/incident.php +++ /dev/null @@ -1,761 +0,0 @@ -m_sCurrentStep = $sStep; - } - - protected function GetFields($sStep = '') - { - if ($sStep == '') - { - $sStep = $this->m_sCurrentStep; - } - return $this->m_aSteps[$sStep]; - } - - protected function AddContextToForm(WebPage $oPage) - { - // Store as hidden fields in the page all the variables from the previous steps - foreach($this->m_aSteps as $sStep => $aFields) - { - if ($sStep == $this->m_sCurrentStep) continue; - foreach($aFields as $sAttName => $sFieldName) - { - $oPage->add("\n"); - } - } - } - - function GetObjectPicker(WebPage $oPage, $sTitle, $sFieldName, $sClass) - { - $sScript = -<< 0) - { - aRelatedObjectIds = sRelatedObjectIds.split(' '); - } - else - { - aRelatedObjectIds = new Array(); - aRelatedObjectIds[0] = 0; - } - var sibusql = sClass+": pkey IN {" + aRelatedObjectIds.join(", ") + "}"; - $.get("ajax.render.php?filter=" + sibusql + "&style=list&encoding=sibusql", - { operation: "ajax" }, - function(data){ - $("#related_objects").empty(); - $("#related_objects").append(data); - $("#related_objects").removeClass("loading"); - }); - } - - function AddObject(sClass) - { - var sRelatedObjectIds = new String($('#related_object_ids').val()); - var sCurrentObjectId = new String($('#ac_current_object_id').val()); - if (sRelatedObjectIds.length > 0) - { - aRelatedObjectIds = sRelatedObjectIds.split(' '); - } - else - { - aRelatedObjectIds = new Array(); - } - // To do: check if the ID is not already in the list... - aRelatedObjectIds[aRelatedObjectIds.length] = sCurrentObjectId; - // Update the form & reload the list - $('#related_object_ids').val(aRelatedObjectIds.join(' ')); - UpdateObjectList(sClass); - } - - function ManageObjects(sTitle, sClass, sInputId) - { - $('#Manage_DlgTitle').text(sTitle); - sObjList = new String($('#'+sInputId).val()); - if (sObjList == '') - { - sObjList = new String('0'); - } - var aObjList = sObjList.split(' '); - Manage_LoadSelect('selected_objects', sClass+': pkey IN {' + aObjList.join(', ') + '}'); - Manage_LoadSelect('available_objects', sClass); - $('#ManageObjectsDlg').jqmShow(); - } - - function Manage_LoadSelect(sSelectedId, sFilter) - { - $('#'+sSelectedId).addClass('loading'); - $.get('ajax.render.php?filter=' + sFilter, - { operation: 'combo_options' }, - function(data){ - $('#'+sSelectedId).empty(); - $('#'+sSelectedId).append(data); - $('#'+sSelectedId).removeClass('loading'); - } - ); - } - - function Manage_SwapSelectedObjects(oSourceSelect, oDestinationSelect) - { - for (i=oSourceSelect.length-1;i>=0;i--) // Count down because we are removing the indexes from the combo - { - if (oSourceSelect.options[i].selected) - { - var newOption = document.createElement('option'); - newOption.text = oSourceSelect.options[i].text; - newOption.value = oSourceSelect.options[i].value; - oDestinationSelect.add(newOption, null); - oSourceSelect.remove(i); - } - } - Manage_UpdateButtons(); - } - - function Manage_UpdateButtons() - { - var oSrc = document.getElementById('available_objects'); - var oAddBtn = document.getElementById('btn_add_objects') - var oDst = document.getElementById('selected_objects'); - var oRemoveBtn = document.getElementById('btn_remove_objects') - if (oSrc.selectedIndex == -1) - { - oAddBtn.disabled = true; - } - else - { - oAddBtn.disabled = false; - } - if (oDst.selectedIndex == -1) - { - oRemoveBtn.disabled = true; - } - else - { - oRemoveBtn.disabled = false; - } - } - - function Manage_AddObjects() - { - var oSrc = document.getElementById('available_objects'); - var oDst = document.getElementById('selected_objects'); - Manage_SwapSelectedObjects(oSrc, oDst); - } - - function Manage_RemoveObjects() - { - var oSrc = document.getElementById('selected_objects'); - var oDst = document.getElementById('available_objects'); - Manage_SwapSelectedObjects(oSrc, oDst); - } - - function Manage_Ok(sClass) - { - var objectsToAdd = document.getElementById('selected_objects'); - var aSelectedObjects = new Array(); - for (i=0; i

Selected Objects

- - - - - - - - - -
-

Selected objects:

- -

-
-

-

-
-

Available objects:

- -

-
-       -
-EOF; - $sHTML = ' - -   -  '; - $sHTML .= ''; - $sHTML .= '
'.$sManageObjectsDlg.'
'; - $oPage->add_script($sScript); - $oPage->add_ready_script("\$('#current_object_id').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#ac_current_object_id', extraParams:{operation:'link', sclass:'$sClass', attCode:'name'}});"); - $oPage->add_ready_script("$('#ManageObjectsDlg').jqm({overlay:70, modal:true, toTop:true});"); // jqModal Window - $oPage->add_ready_script("UpdateObjectList('$sClass');"); - return $sHTML; - } - - function DisplayObjectPickerList(WebPage $oPage, $sClass) - { - $oFilter = new CMDBSearchFilter($sClass); - $oFilter->AddCondition('pkey', array(0), 'IN'); - //$oPage->p($oFilter->__DescribeHTML()); - $oBlock = new DisplayBlock($oFilter, 'list', true /* Asynchronous */); - $oBlock->Display($oPage, 'related_objects'); - } -} - -class IncidentCreationWizard extends DialogWizard -{ - public function __construct($sStep) - { - parent::__construct($sStep); - $this->m_aSteps = - array( - '1' => array('title' => 'attr_title', 'customer_id' => 'attr_customer_id', 'initial_situation' => 'attr_initial_situation', 'severity' => 'attr_severity', 'impact' => 'attr_impact', 'workgroup_id' => 'attr_workgroup_id', 'action_log' => 'attr_action_log'), - '2' => array('impacted_infra_ids' => 'impacted_infra_ids'), - '3' => array('additional_impacted_object_ids' => 'additional_impacted_object_ids'), - '4' => array('related_incident_ids' => 'related_incident_ids'), - '5' => array('contact_ids' => 'contact_ids'), - ); - } - - protected function AddContextToForm($oPage) - { - parent::AddContextToForm($oPage); - $oPage->add("\n"); - $oPage->add("m_sNextStep."\" />\n"); - } - - public function DisplayNewTicketForm(WebPage $oPage) - { - assert($this->m_sCurrentStep == '1'); - $this->m_sNextStep = '2'; - $aFields = $this->GetFields(); - - $oPage->add('
'); - $aDetails = array(); - $aAttributesDef = MetaModel::ListAttributeDefs('bizIncidentTicket'); - foreach($aFields as $sAttCode => $sFieldName) - { - $oAttDef = $aAttributesDef[$sAttCode]; - $sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, 'bizIncidentTicket', $sAttCode, $oAttDef); - $aDetails[] = array('label' => $oAttDef->GetLabel().' *', 'value' => $sHTMLValue); - } - $oPage->details($aDetails); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - public function DisplayImpactedInfraForm(WebPage $oPage) - { - assert($this->m_sCurrentStep == '2'); - $this->m_sNextStep = '3'; - $oPage->add('
'); - $aDetails = array(); - $sHTML = $this->GetObjectPicker($oPage, 'Impacted Infrastructure', 'impacted_infra_ids', 'logInfra'); - $aDetails[] = array('label' => 'Impacted element:', 'value' => $sHTML); - $oPage->details($aDetails); - $this->DisplayObjectPickerList($oPage, 'logInfra'); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - public function DisplayAdditionalImpactedObjectForm(WebPage $oPage) - { - assert($this->m_sCurrentStep == '3'); - $this->m_sNextStep = '4'; - $sImpactedInfraIds = Utils::ReadParam('impacted_infra_ids'); - - $sImpactedInfraIds = Utils::ReadParam('impacted_infra_ids', ''); - if (!empty($sImpactedInfraIds)) - { - $oPage->p('Impacted Infrastructure:'); - $oFilter = new CMDBSearchFilter('logRealObject'); - $oFilter->AddCondition('pkey', explode(' ', $sImpactedInfraIds), 'IN'); - $oBlock = new DisplayBlock($oFilter, 'list', false /* Synchronous */); - $oBlock->Display($oPage, 'impacted_infra'); - } - - $aImpactedInfraIds = explode(' ', $sImpactedInfraIds); - $oInfraSet = CMDBObjectSet::FromScratch('logRealObject'); - foreach($aImpactedInfraIds as $id) - { - $oObj = MetaModel::GetObject('logRealObject', $id); - $oInfraSet->AddObject($oObj); - } - $aImpactedObject = $oInfraSet->GetRelatedObjects('impacts'); - $aAdditionalIds = array(); - foreach($aImpactedObject as $sRootClass => $aObjects) - { - foreach($aObjects as $oObj) - { - $aAdditionalIds[] = $oObj->GetKey(); - } - } - $sAdditionalIds = implode(' ', $aAdditionalIds); - $oPage->add_ready_script('$("#related_object_ids").val("'.$sAdditionalIds.'");'); - - $oPage->p('Additional Impact Computed:'); - $this->DisplayObjectPickerList($oPage, 'logRealObject'); - $oPage->add('
'); - $aDetails = array(); - $sHTML = $this->GetObjectPicker($oPage, 'Additional Impacted Infrastructure', 'additional_impacted_object_ids', 'logRealObject'); - $aDetails[] = array('label' => 'Impacted element:', 'value' => $sHTML); - $oPage->details($aDetails); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - public function DisplayRelatedTicketsForm(WebPage $oPage) - { - assert($this->m_sCurrentStep == '4'); - $this->m_sNextStep = '5'; - $oRelatedTicketsFilter = new DBObjectSearch('bizIncidentTicket'); - $sImpactedInfraIds = Utils::ReadParam('impacted_infra_ids', ''); - $sAdditionalImpactedObjectIds = Utils::ReadParam('additional_impacted_object_ids', ''); - $sIds = trim($sImpactedInfraIds.' '.$sAdditionalImpactedObjectIds); - $aTicketIds = array(); - if (!empty($sIds)) - { - $aIds = explode(' ', $sIds); - $sSibusQL = "bizIncidentTicket: PKEY IS ticket_id IN (lnkInfraTicket: infra_id IN (logRealObject: pkey IN {".implode(',', $aIds)."}))"; - $oTicketSearch = DBObjectSearch::FromSibusQL($sSibusQL); - $oRelatedTicketSet = new DBObjectSet($oTicketSearch); - while ($oTicket = $oRelatedTicketSet->Fetch()) - { - $aTicketIds[] = $oTicket->GetKey(); - } - } - - $sTicketIds = implode(' ', $aTicketIds); - $oPage->add_ready_script('$("#related_object_ids").val("'.$sTicketIds.'");'); - $oPage->p('Potentially related incidents:'); - $this->DisplayObjectPickerList($oPage, 'bizIncidentTicket'); - - $oPage->add('
'); - $sHTML = $this->GetObjectPicker($oPage, 'Related Incidents', 'related_incident_ids', 'bizIncidentTicket'); - $aDetails[] = array('label' => 'Related Incident:', 'value' => $sHTML); - $oPage->details($aDetails); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - public function DisplayContactsToNotifyForm(WebPage $oPage) - { - assert($this->m_sCurrentStep == '5'); - $this->m_sNextStep = '6'; - $oPage->add('
'); - $sHTML = $this->GetObjectPicker($oPage, 'Contacts to notify', 'contact_ids', 'bizContact'); - $aDetails[] = array('label' => 'Additional contact:', 'value' => $sHTML); - $oPage->details($aDetails); - $this->DisplayObjectPickerList($oPage, 'bizContact'); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - function DisplayFinalForm(WebPage $oPage) - { - $oAppContext = new ApplicationContext(); - assert($this->m_sCurrentStep == '6'); - $this->m_sNextStep = '7'; - - $aDetails = array(); - $aAttributesDef = MetaModel::ListAttributeDefs('bizIncidentTicket'); - $aFields = $this->GetFields('1'); - foreach($aFields as $sAttCode => $sFieldName) - { - $oAttDef = $aAttributesDef[$sAttCode]; - $sValue = Utils::ReadParam($sFieldName, ''); - if ($oAttDef->IsExternalKey() && isset($sValue) && ($sValue != 0)) - { - $oTargetObj = MetaModel::GetObject($oAttDef->GetTargetClass(), $sValue); - if (!is_object($oTargetObj)) - { - trigger_error("Houston: could not find ".$oAttDef->GetTargetClass()."::$sValue"); - } - $sPage = cmdbAbstractObject::ComputeUIPage($oAttDef->GetTargetClass()); - $sHint = htmlentities($oAttDef->GetTargetClass()."::".$sValue); - $sHTMLValue = "GetTargetClass()."&id=$sValue&".$oAppContext->GetForLink()."\" title=\"$sHint\">".$oTargetObj->GetName().""; - } - else - { - $sHTMLValue = $oAttDef->GetAsHTML($sValue); - } - $aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue); - } - $oPage->details($aDetails); - - $oPage->AddTabContainer('LinkedObjects'); - $oPage->SetCurrentTabContainer('LinkedObjects'); - - $sImpactedInfraIds = Utils::ReadParam('impacted_infra_ids', ''); - $sImpactedInfraIds .= ' '.Utils::ReadParam('additional_impacted_object_ids', ''); - $sImpactedInfraIds = trim($sImpactedInfraIds); - $oPage->SetCurrentTab("Infrastructure impacted"); - if (!empty($sImpactedInfraIds)) - { - $oFilter = new CMDBSearchFilter('logRealObject'); - $oFilter->AddCondition('pkey', explode(' ', $sImpactedInfraIds), 'IN'); - $oBlock = new DisplayBlock($oFilter, 'list', false /* Synchronous */); - $oBlock->Display($oPage, 'related_objects'); - } - else - { - $oPage->p("There is no infrastructure impacted by this incident"); - } - - $sRelatedIncidentIds = Utils::ReadParam('related_incident_ids', ''); - $oPage->SetCurrentTab("Related tickets"); - if (!empty($sRelatedIncidentIds)) - { - $oFilter = new CMDBSearchFilter('bizIncidentTicket'); - $oFilter->AddCondition('pkey', explode(' ', $sRelatedIncidentIds), 'IN'); - $oBlock = new DisplayBlock($oFilter, 'list', false /* Synchronous */); - $oBlock->Display($oPage, 'related_incidents'); - } - else - { - $oPage->p("There is no other incident related to this one"); - } - - $oPage->SetCurrentTab("Contacts to notify"); - $sContactIds = Utils::ReadParam('contact_ids', ''); - if (!empty($sContactIds)) - { - $oFilter = new CMDBSearchFilter('bizContact'); - $oFilter->AddCondition('pkey', explode(' ', $sContactIds), 'IN'); - $oBlock = new DisplayBlock($oFilter, 'list', false /* Synchronous */); - $oBlock->Display($oPage, 'contacts'); - } - else - { - $oPage->p("There is no contact to notify"); - } - $oPage->SetCurrentTab(); - - $oPage->add('
'); - $this->AddContextToForm($oPage); - $oPage->add("    \n"); - $oPage->add("    \n"); - $oPage->add("\n"); - $oPage->add('
'); - } - - public function CreateIncident(WebPage $oPage) - { - $oAppContext = new ApplicationContext(); - assert($this->m_sCurrentStep == '7'); - $this->m_sNextStep = '1'; - - $oIncident = MetaModel::NewObject('bizIncidentTicket'); - $oPage->p("Creation of Incident Ticket."); - - $aFields = $this->GetFields('1'); - foreach($aFields as $sAttCode => $sFieldName) - { - $sValue = Utils::ReadPostedParam($sFieldName, ''); - $oIncident->Set($sAttCode, $sValue); - } - $oIncident->Set('ticket_status', 'New'); - $oIncident->Set('start_date', time()); - $oIncident->Set('name', 'ID not set'); - - if ($oIncident->CheckToInsert()) - { - // Create the ticket itself - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Administrator"); - $iChangeId = $oMyChange->DBInsert(); - $oIncident->DBInsertTracked($oMyChange); - - $sName = sprintf('I-%06d', $oIncident->GetKey()); - $oIncident->Set('name', $sName); - $oIncident->DBUpdateTracked($oMyChange); - $oPage->p("Incident $sName created.\n"); - - // Now link the objects to the Incident: - // 1) the impacted infra - $sImpactedInfraIds = Utils::ReadParam('impacted_infra_ids', ''); - $sImpactedInfraIds .= ' '.Utils::ReadParam('additional_impacted_object_ids', ''); - $sImpactedInfraIds = trim($sImpactedInfraIds); - if (!empty($sImpactedInfraIds)) - { - $aImpactedInfra = explode(' ', $sImpactedInfraIds); - foreach($aImpactedInfra as $iInfraId) - { - $oLink = MetaModel::NewObject('lnkInfraTicket'); - $oLink->Set('infra_id', $iInfraId); - $oLink->Set('ticket_id', $oIncident->GetKey()); - $oLink->Set('impact', 'automatic'); - $oLink->DBInsertTracked($oMyChange); - } - } - // 2) the related incidents - $sRelatedIncidentsIds = Utils::ReadPostedParam('related_incident_ids'); - if (!empty($sRelatedIncidentsIds)) - { - $aRelatedIncidents = explode(' ', $sRelatedIncidentsIds); - foreach($aRelatedIncidents as $iIncidentId) - { - $oLink = MetaModel::NewObject('lnkRelatedTicket'); - $oLink->Set('rel_ticket_id', $iIncidentId); - $oLink->Set('ticket_id', $oIncident->GetKey()); - $oLink->Set('impact', 'automatic'); - $oLink->DBInsertTracked($oMyChange); - } - } - // 3) the contacts to notify - $sContactsIds = Utils::ReadPostedParam('contact_ids'); - if (!empty($sContactsIds)) - { - $aContactsToNotify = explode(' ', $sContactsIds); - foreach($aContactsToNotify as $iContactId) - { - $oLink = MetaModel::NewObject('lnkContactRealObject'); - $oLink->Set('contact_id', $iContactId); - $oLink->Set('object_id', $oIncident->GetKey()); - $oLink->Set('role', 'notification'); - $oLink->DBInsertTracked($oMyChange); - } - } - $oIncident->DisplayDetails($oPage, 'bizIncidentTicket', $oIncident->GetKey()); - } - else - { - $oPage->p("Error: object can not be created!\n"); - } - } -} - - -$oContext = new UserContext(); -$oAppContext = new ApplicationContext(); -$currentOrganization = utils::ReadParam('org_id', ''); -$operation = utils::ReadParam('operation', ''); -$oP = new iTopWebPage("ITop - Incident Management", $currentOrganization); - -switch($operation) -{ - case 'details': - $sClass = utils::ReadParam('class', ''); - $id = utils::ReadParam('id', ''); - if ( empty($sClass) || empty($id)) // TO DO: check that the class name is valid ! - { - $oP->add("

'class' and 'id' parameters must be specifed for this operation.

\n"); - } - else - { - $oObj = $oContext->GetObject($sClass, $id); - if ($oObj != null) - { - $oP->set_title("iTop - ".$oObj->GetName()." - $sClass details"); - $oObj->DisplayDetails($oP); - } - else - { - $oP->set_title("iTop - Error"); - $oP->add("

Sorry this object does not exist (or you are not allowed to view it).

\n"); - } - } - break; - - case 'new': - $step = utils::ReadParam('step', '1'); - $aSteps = array( - 'Ticket Information', - 'Impacted Infrastructure', - 'Additional Impact', - 'Related Tickets', - 'Contacts to Notify', - 'Confirmation', - 'Ticket Creation' - ); - $oWizard = new IncidentCreationWizard($step); - $oP = new iTopWizardWebPage("ITop - Incident Management", $currentOrganization, $step, $aSteps); - - switch($step) - { - case 1: - default: - //$oP->add(''); - $oWizard->DisplayNewTicketForm($oP); - break; - - case 2: - //$oP->add(''); - $oWizard->DisplayImpactedInfraForm($oP); - break; - - case 3: - //$oP->add(''); - $oWizard->DisplayAdditionalImpactedObjectForm($oP); - break; - - case 4: - //$oP->add(''); - $oWizard->DisplayRelatedTicketsForm($oP); - break; - - case 5: - //$oP->add(''); - $oWizard->DisplayContactsToNotifyForm($oP); - break; - - case 6: - //$oP->add(''); - $oWizard->DisplayFinalForm($oP); - break; - - case 7: - $oWizard->CreateIncident($oP); - break; - } - break; - - case 'modify': - $oP->add_linked_script("../js/json.js"); - $oP->add_linked_script("../js/forms-json-utils.js"); - $oP->add_linked_script("../js/wizardhelper.js"); - $oP->add_linked_script("../js/wizard.utils.js"); - $oP->add_linked_script("../js/linkswidget.js"); - $oP->add_linked_script("../js/jquery.blockUI.js"); - $sClass = utils::ReadParam('class', ''); - $id = utils::ReadParam('id', ''); - if ( empty($sClass) || empty($id)) // TO DO: check that the class name is valid ! - { - $oP->add("

'class' and 'id' parameters must be specifed for this operation.

\n"); - } - else - { - $oObj = $oContext->GetObject($sClass, $id); - if ($oObj != null) - { - $oP->set_title("iTop - ".$oObj->GetName()." - $sClass modification"); - $oP->add("

".$oObj->GetName()." - $sClass modification

\n"); - $oObj->DisplayModifyForm($oP); - } - else - { - $oP->set_title("iTop - Error"); - $oP->add("

Sorry this object does not exist (or you are not allowed to view it).

\n"); - } - } - break; - - case 'apply_modify': - $sClass = utils::ReadPostedParam('class', ''); - $id = utils::ReadPostedParam('id', ''); - $sTransactionId = utils::ReadPostedParam('transaction_id', ''); - if ( empty($sClass) || empty($id)) // TO DO: check that the class name is valid ! - { - $oP->add("

'class' and 'id' parameters must be specifed for this operation.

\n"); - } - else if (!utils::IsTransactionValid($sTransactionId)) - { - $oP->p("Error: object has already be updated!\n"); - } - else - { - $oObj = $oContext->GetObject($sClass, $id); - if ($oObj != null) - { - $oP->set_title("iTop - ".$oObj->GetName()." - $sClass modification"); - $oP->add("

".$oObj->GetName()." - $sClass modification

\n"); - $bObjectModified = false; - foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef) - { - $iFlags = $oObj->GetAttributeFlags($sAttCode); - if ($iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) - { - // Non-visible, or read-only attribute, do nothing - } - else if ($sAttCode == 'finalclass') - { - // This very specific field is read-only - } - else if (!$oAttDef->IsExternalField()) - { - $aAttributes[$sAttCode] = trim(utils::ReadPostedParam("attr_$sAttCode", null)); - $previousValue = $oObj->Get($sAttCode); - if (!is_null($aAttributes[$sAttCode]) && ($previousValue != $aAttributes[$sAttCode])) - { - $oObj->Set($sAttCode, $aAttributes[$sAttCode]); - $bObjectModified = true; - } - } - } - if (!$bObjectModified) - { - $oP->p("No modification detected. ".get_class($oObj)." has not been updated.\n"); - } - else if ($oObj->CheckToUpdate()) - { - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Made by somebody"); // TO DO put the correct user info here - $iChangeId = $oMyChange->DBInsert(); - $oObj->DBUpdateTracked($oMyChange); - - $oP->p(get_class($oObj)." updated.\n"); - } - else - { - $oP->p("Error: object can not be updated!\n"); - //$oObj->Reload(); // restore default values! - } - } - else - { - $oP->set_title("iTop - Error"); - $oP->add("

Sorry this object does not exist (or you are not allowed to edit it).

\n"); - } - } - $oP->add("

Alors ça roule ?

"); - $oObj->DisplayDetails($oP); - break; -} -$oP->output(); -?> diff --git a/pages/index.php b/pages/index.php deleted file mode 100644 index 01297ed74..000000000 --- a/pages/index.php +++ /dev/null @@ -1,667 +0,0 @@ -no_cache(); - - - -MetaModel::CheckDefinitions(); -// new API - MetaModel::DBCheckFormat(); -// not necessary, and time consuming! -// MetaModel::DBCheckIntegrity(); - - -// Comment by Rom: MetaModel::GetSubclasses("logRealObject") retourne la totale -// utiliser IsRootClass pour savoir si une classe obtenue est une classe feuille ou non -$aTopLevelClasses = array('bizService', 'bizLocation', 'bizContact', 'logInfra', 'bizDocument', 'bizObject'); - -function ReadParam($sName, $defaultValue = "") -{ - return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue; -} - -function DisplaySelectOrg($oPage, $sCurrentOrganization, $iContext) -{ - global $oContext; - - //$oSearchFilter = new CMDBSearchFilter("bizOrganization"); - $oSearchFilter = $oContext->NewFilter("bizOrganization"); - $oPage->p($oSearchFilter->serialize()); - $oSet = new CMDBObjectSet($oSearchFilter); - if ($oSet->Count() == 0) - { - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->p("No organization found.\n"); - $oPage->p($oSearchFilter->__DescribeHTML()); - $oPage->add("
\n"); - $oPage->add("
\n"); - } - else - { - $oCurrentOrganization = null; - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->add("Select the context:\n"); - $oPage->add("\n"); - $oPage->p(""); - $oPage->add("Select an organization: \n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("
\n"); - if ($oCurrentOrganization != null) - { - $oCurrentOrganization->DisplayDetails($oPage); - } - $oPage->add("
\n"); - $oPage->add("
\n"); - } -} - -function DisplayDetails(WebPage $oPage, $sClassName, $sKey) -{ - global $oContext; - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - $oPage->p("Details of ".MetaModel::GetName($sClassName)." - $sKey"); - - $oObj->DisplayDetails($oPage); - - // Modified by rom - $aLinks = array(); - $aLinks[] = "View changes log"; - $aLinks[] = "Edit this object"; - $aLinks[] = "Delete this object (no confirmation!)"; - // By rom - foreach (MetaModel::EnumLinkingClasses($sClassName) as $sLinkClass => $aRemoteClasses) - { - foreach($aRemoteClasses as $sExtKeyAttCode => $sRemoteClass) - { - // #@# quick and dirty: guess the extkey attcode from link to current class - // later, this information should be part of the biz model - $sExtKeyToMe = ""; - foreach(MetaModel::ListAttributeDefs($sLinkClass) as $sAttCode=>$oAttDef) - { - if ($oAttDef->IsExternalKey() && $oAttDef->GetTargetClass() == $sClassName) - { - $sExtKeyToMe = $sAttCode; - break; - } - } - if (empty($sExtKeyToMe)) - { - $oPage->p("Houston... could not find the external key for $sClassName in $sLinkClass"); - } - else - { - $oFilter = new CMDBSearchFilter($sRemoteClass); // just a dummy empty one for edition - - $sButton = "
\n"; - $sButton .= "
\n"; - $aOnOKArgs = array("operation"=>"addlinks", "linkclass"=>$sLinkClass, "extkeytome"=>$sExtKeyToMe, "extkeytopartner"=>$sExtKeyAttCode); - $sButton .= dialogstack::RenderEditableField("Add links with $sRemoteClass", "filter", $oFilter->serialize(), true, "", $aOnOKArgs); - $sButton .= "
\n"; - $sButton .= "
\n"; - $aLinks[] = $sButton; - } - } - } - $sLinks = implode(" / ", $aLinks); - $oPage->p($sLinks); -} - -// By Rom -function DisplayChangesLog(WebPage $oPage, $sClassName, $sKey) -{ - global $oContext; - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - $oPage->p("Changes log for ".MetaModel::GetName($sClassName)." - $sKey"); - - $oObj->DisplayChangesLog($oPage); - - $oPage->p("View details"); - $oPage->p("Edit this object"); - $oPage->p("Delete this object (no confirmation!)"); -} - -function DumpObjects(WebPage $oPage, $sClassName, CMDBSearchFilter $oSearchFilter = null) -{ - global $oContext; - - if ($oSearchFilter == null) - { - //$oSearchFilter = new CMDBSearchFilter($sClassName); - $oSearchFilter = $oContext->NewFilter($sClassName); - } - $aAttribs = array(); - foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode=>$oAttDef) - { - $aAttribs['key'] = array('label' => 'key', 'description' => 'Primary Key'); - $aAttribs[$sAttCode] = array('label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription()); - } - $oObjectSet = new CMDBObjectSet($oSearchFilter); - - $aValues = array(); - while ($oObj = $oObjectSet->Fetch()) - { - $aRow['key'] = "GetKey()."\">".$oObj->GetKey().""; - foreach($oObj->GetAttributesList($sClassName) as $sAttCode) - { - $aRow[$sAttCode] = $oObj->GetAsHTML($sAttCode); - } - $aValues[] = $aRow; - } - $oPage->table($aAttribs, $aValues); -} - -function DisplayEditForm(WebPage $oPage, $sClassName, $sKey) -{ - global $oContext; - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - if ($oObj == null) - { - $oPage->p("You are not allowed to edit this object."); - return; - } - $oPage->p("Edition of ".MetaModel::GetName($sClassName)." - $sKey\n"); - - $aDetails = array(); - $oPage->add("
\n"); - foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef) - { - if (!$oAttDef->IsExternalField()) - { - if ($oAttDef->IsExternalKey()) - { - //External key, display a combo - $sTargetClass = $oAttDef->GetTargetClass(); - //$oFilter = new CMDBSearchFilter($sTargetClass); - $oFilter = $oContext->NewFilter($sTargetClass); - $oSet = new CMDBObjectSet($oFilter); - $sValue = "\n"; - } - else - { - $sValue = "Get($sAttCode))."\">"; - } - $aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sValue); - } - } - $oPage->details($aDetails); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); -} - -function DisplayCreationForm(WebPage $oPage, $sClassName) -{ - global $oContext; - $oPage->p("New $sClassName\n"); - - $aDetails = array(); - $oPage->add("\n"); - foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode=>$oAttDef) - { - if (!$oAttDef->IsExternalField()) - { - if ($oAttDef->IsExternalKey()) - { - //External key, display a combo - $sTargetClass = $oAttDef->GetTargetClass(); - //$oFilter = new CMDBSearchFilter($sTargetClass); - $oFilter = $oContext->NewFilter($sTargetClass); - $oSet = new CMDBObjectSet($oFilter); - $sValue = "\n"; - } - else - { - $sValue = "GetDefaultValue()."\">"; - } - $aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sValue); - } - } - $oPage->details($aDetails); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); -} - -function UpdateObject(WebPage $oPage, $sClassName, $sKey, $aAttributes) -{ - global $oContext; - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - if ($oObj == null) - { - $oPage->p("You are not allowed to edit this object."); - return; - } - $oPage->p("Update of $sClassName - $sKey"); - - foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef) - { - if (isset($aAttributes[$sAttCode])) - { - $oObj->Set($sAttCode, $aAttributes[$sAttCode]); - } - } - if ($oObj->CheckToUpdate()) - { - // By rom - // $oObj->DBUpdate(); - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Made by somebody"); - $iChangeId = $oMyChange->DBInsert(); - $oObj->DBUpdateTracked($oMyChange); - - $oPage->p(MetaModel::GetName($sClassName)." updated\n"); - } - else - { - $oPage->p("Error: object can not be updated!\n"); - $oObj->DBRevert(); // restore default values! - } - // By Rom - // $oObj->DisplayDetails($oPage); - // replaced by... - DisplayDetails($oPage, $sClassName, $sKey); - $oPage->p("Return to main page"); -} - -function DeleteObject(WebPage $oPage, $sClassName, $sKey) -{ - global $oContext; - $sClassLabel = MetaModel::GetName($sClassName); - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - if ($oObj == null) - { - $oPage->p("You are not allowed to delete this object."); - return; - } - $oPage->p("Deletion of $sClassLabel - $sKey"); - - if ($oObj->CheckToDelete()) - { - // By Rom - //$oObj->DBDelete(); - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Made by somebody"); - $iChangeId = $oMyChange->DBInsert(); - $oObj->DBDeleteTracked($oMyChange); - - $oPage->p("$sClassLabel deleted\n"); - } - else - { - $oPage->p("Error: object can not be deleted!\n"); - // By Rom - DisplayDetails($oPage, $sClassName, $sKey); - } - $oPage->p("Return to main page"); -} - -function CreateObject(WebPage $oPage, $sClassName, $aAttributes) -{ - $oObj = MetaModel::NewObject($sClassName); - $sClassLabel = MetaModel::GetName(get_class($oObj)); - $oPage->p("Creation of $sClassLabel object."); - - foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef) - { - if (isset($aAttributes[$sAttCode])) - { - $oObj->Set($sAttCode, $aAttributes[$sAttCode]); - } - } - list($bRes, $aIssues) = $oObj->CheckToInsert(); - if ($bRes) - { - // By rom - // $oObj->DBInsert(); - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Made by somebody"); - $iChangeId = $oMyChange->DBInsert(); - $oObj->DBInsertTracked($oMyChange); - - $oPage->p($sClassLabel." created\n"); - - // By Rom - // $oObj->DisplayDetails($oPage); - // replaced by... - DisplayDetails($oPage, get_class($oObj), $oObj->GetKey()); - } - else - { - $oPage->p("Error: object can not be created!\n"); - $oPage->add("
    Issues:"); - foreach($aIssues as $sErrorMsg) - { - $oPage->add("
  • $sErrorMsg
  • "); - } - $oPage->add("
"); - } - $oPage->p("Return to main page"); -} - -// By Rom -function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKeyToPartner, $sFilter) -{ - global $oContext; - $sClassLabel = MetaModel::GetName($sClassName); - //$oObj = MetaModel::GetObject($sClassName, $sKey); - $oObj = $oContext->GetObject($sClassName, $sKey); - if ($oObj == null) - { - $oPage->p("You are not allowed to modify (create links on) this object."); - return; - } - $oPage->p("Creating links for $sClassLabel - $sKey"); - - $oFilter = CMDBSearchFilter::unserialize($sFilter); - $oPage->p("Linking to ".$oFilter->__DescribeHTML()); - - $oObjSet = new CMDBObjectSet($oFilter); - if ($oObjSet->Count() != 0) - { - while($oPartnerObj = $oObjSet->Fetch()) - { - $oNewLink = MetaModel::NewObject($sLinkClass); - $oNewLink->Set($sExtKeyToMe, $sKey); - $oNewLink->Set($sExtKeyToPartner, $oPartnerObj->GetKey()); - list($bRes, $aIssues) = $oNewLink->CheckToInsert(); - if ($bRes) - { - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "Made by somebody"); - $iChangeId = $oMyChange->DBInsert(); - $oNewLink->DBInsertTracked($oMyChange); - - $oPage->p(MetaModel::GetName($sLinkClass)." created\n"); - } - else - { - $oPage->p("Error: link can not be created!\n"); - $oPage->add("
    Issues:"); - foreach($aIssues as $sErrorMsg) - { - $oPage->add("
  • $sErrorMsg
  • "); - } - $oPage->add("
"); - } - } - } - else - {} - -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// -// M a i n P r o g r a m -// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -$operation = ReadParam('operation', ''); -$iContext = ReadParam('ctx', 1); - -$oContext = new UserContext(); - -switch($iContext) -{ - case 2: // See only the organization 'ITOP' - $oContext->AddCondition('bizOrganization', 'pkey', 'ITOP', '='); - $oContext->AddCondition('logRealObject', 'organization', 'ITOP', '='); - break; - - case 3: // See only the organization containing 'o' and contacts containing +33 - $oContext->AddCondition('Organization', 'name', 'o', 'Contains'); - //$oContext->AddCondition('Object', 'orgname', 'o', 'Contains'); - $oContext->AddCondition('Contact', 'phone', '+33', 'Contains'); - break; - - case 1: // No limitation - default: - // nothing to do -} - -dialogstack::DeclareCaller("Main navigation menu"); - -switch($operation) -{ - case 'details': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - DisplayDetails($oPage, $sClass, $sKey); - break; - - // By rom - case 'changeslog': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - DisplayChangesLog($oPage, $sClass, $sKey); - break; - - case 'edit': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - DisplayEditForm($oPage, $sClass, $sKey); - break; - - case 'update': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - $aAttributes = ReadParam('attr', array()); - UpdateObject($oPage, $sClass, $sKey, $aAttributes); - break; - - case 'new': - $sClass = ReadParam('class'); - DisplayCreationForm($oPage, $sClass); - break; - - case 'create': - $sClass = ReadParam('class'); - $aAttributes = ReadParam('attr', array()); - CreateObject($oPage, $sClass, $aAttributes); - break; - - case 'delete': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - DeleteObject($oPage, $sClass, $sKey); - break; - - case 'addlinks': - $sClass = ReadParam('class'); - $sKey = ReadParam('key'); - $sLinkClass = ReadParam('linkclass'); - $sExtKeyToMe = ReadParam('extkeytome'); - $sExtKeyToPartner = ReadParam('extkeytopartner'); - $sFilter = ReadParam('filter'); - AddLinks($oPage, $sClass, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKeyToPartner, $sFilter); - break; - - default: - $sCurrentOrganization = ReadParam('org', ''); - $sActiveTab = ReadParam('classname', ''); - DisplaySelectOrg($oPage, $sCurrentOrganization, $iContext); - if ($sCurrentOrganization != "") - { - $oPage->add("
\n"); - $oPage->add("
    \n"); - $index = 1; - $iActiveTabIndex = 1; // By default the first tab is the active one - foreach( $aTopLevelClasses as $sClassName) - { - if ($sClassName == $sActiveTab) - { - $iActiveTabIndex = $index; - } - $oPage->add("\t
  • $sClassName
  • \n"); - $index++; - } - $oPage->add("
\n"); - foreach( $aTopLevelClasses as $sClassName) - { - $sClassLabel = MetaModel::GetName($sClassName); - $oPage->add("
"); - if (count(MetaModel::GetSubclasses($sClassName)) > 0) - { - $sActiveSubclass = ReadParam('subclassname', ''); - foreach(MetaModel::GetSubclasses($sClassName) as $sSubclassName) - { - $sSubclassLabel = MetaModel::GetName($sSubclassName); - //$oSearchFilter = new CMDBSearchFilter($sSubclassName); - $oSearchFilter = $oContext->NewFilter($sSubclassName); - $oSearchFilter ->AddCondition('org_id', $sCurrentOrganization, '='); - - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->p("$sSubclassLabel - ".MetaModel::GetClassDescription($sSubclassName)); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - foreach( MetaModel::GetClassFilterDefs($sSubclassName) as $sFilterCode=>$oFilterDef) - { - $sFilterValue = ""; - if (($sActiveTab == $sClassName) && ($sActiveSubclass == $sSubclassName)) - { - $sFilterValue = ReadParam($sFilterCode, ''); - if (!empty($sFilterValue)) - { - $oSearchFilter->AddCondition($sFilterCode, $sFilterValue, 'Contains'); - } - } - $oPage->add($oFilterDef->GetLabel().":  \n"); - } - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("
\n"); - - $oSet = new CMDBObjectSet($oSearchFilter); - $iMatchesCount = $oSet->Count(); - if ($iMatchesCount == 0) - { - $oPage->p("No $sSubclassLabel matches these criteria."); - $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); - } - else - { - $oPage->p("$iMatchesCount item(s) found."); - cmdbAbstractObject::DisplaySet($oPage, $oSet); - } - $oPage->p("Create a new $sSubclassLabel\n"); - $oPage->add("
\n"); - } - } - else - { - // No subclasses, list the form directly - //$oSearchFilter = new CMDBSearchFilter($sClassName); - $oSearchFilter = $oContext->NewFilter($sClassName); - $oSearchFilter ->AddCondition('org_id', $sCurrentOrganization, '='); - - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->p("$sClassLabel - ".MetaModel::GetClassDescription($sClassName)); - $oPage->add("
\n"); - $oPage->add("\n"); - $oPage->add("\n"); - $oPage->add("\n"); - foreach( MetaModel::GetClassFilterDefs($sClassName) as $sFilterCode=>$oFilterDef) - { - $sFilterValue = ""; - if ($sActiveTab == $sClassName) - { - $sFilterValue = ReadParam($sFilterCode, ''); - if (!empty($sFilterValue)) - { - $oSearchFilter->AddCondition($sFilterCode, $sFilterValue, 'Contains'); - } - } - $oPage->add($oFilterDef->GetLabel().":  \n"); - } - $oPage->add("\n"); - $oPage->add("
\n"); - $oPage->add("
\n"); - $oPage->add("
\n"); - $oSet = new CMDBObjectSet($oSearchFilter); - $iMatchesCount = $oSet->Count(); - if ($iMatchesCount == 0) - { - $oPage->p("No $sClassLabel matches these criteria."); - $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); - } - else - { - $oPage->p("$iMatchesCount item(s) found."); - cmdbAbstractObject::DisplaySet($oPage, $oSet); - $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); - } - $oPage->p("Create a new $sClassLabel\n"); - $oPage->add("
\n"); - $oPage->add("
\n"); - } - $oPage->add("
\n"); - } - $oPage->add("
\n"); - $oPage->add_script('$(function() {$("#classesTabs > ul").tabs( '.$iActiveTabIndex.', { fxFade: true, fxSpeed: \'fast\' } );});'); - } -} -$oPage->output(); -?> diff --git a/pages/schema.php b/pages/schema.php index bbc973820..a49a68eeb 100644 --- a/pages/schema.php +++ b/pages/schema.php @@ -446,7 +446,7 @@ function DisplayRelationDetails($oPage, $sRelCode) $bPropagate = $aQuery['bPropagate'] ? "Propagate" : "Do not propagate"; $iDistance = $aQuery['iDistance']; - $oPage->add("
  • $sRelKey: $bPropagate ($iDistance) ".DBObjectSearch::SibuSQLAsHtml($sQuery)."
  • \n"); + $oPage->add("
  • $sRelKey: $bPropagate ($iDistance) ".$sQuery."
  • \n"); } $oPage->add("\n"); $oPage->add("\n"); diff --git a/pages/testlist.inc.php b/pages/testlist.inc.php index 463dd9267..56b0e0d57 100644 --- a/pages/testlist.inc.php +++ b/pages/testlist.inc.php @@ -537,35 +537,17 @@ class TestMyBizModel extends TestBizModel } - function test_SibuSQL() - { - echo "

    Simple But Structured Query Language

    "; - - $oMyFilter = new DBObjectSearch("cmdbContact"); - echo "Tous les contacts: ".$oMyFilter->ToSibuSQL()."
    \n"; - $oNewFilter = DBObjectSearch::FromSibuSQL($oMyFilter->ToSibuSQL()); - echo "En passant par un filtre, ca revient en : ".$oNewFilter->ToSibuSQL()."
    \n"; - $this->search_and_show_list($oNewFilter); - - $sFilterDesc = "cmdbContact: name Begins with '$[debutnom:as:debut du nom]' AND ownername NotLike $[ddd::]"; - echo "Construction d'un filtre a partir de sa description en SibuSQL: $sFilterDesc
    \n"; - - MyHelpers::var_dump_html(DBObjectSearch::ListSibusQLParams($sFilterDesc)); - $oNewFilter = DBObjectSearch::FromSibuSQL($sFilterDesc, array('ddd'=>123)); - echo "Ca revient en: ".$oNewFilter->ToSibuSQL(); - } - function test_pkey() { echo "

    Test search on pkey

    "; - $sExpr1 = "cmdbContact: pkey IN {40, 42}"; - $sExpr2 = "cmdbContact: pkey NOTIN {40, 42}"; - $this->search_and_show_list_from_sibusql($sExpr1); - $this->search_and_show_list_from_sibusql($sExpr2); + $sExpr1 = "SELECT cmdbContact WHERE id IN (40, 42)"; + $sExpr2 = "SELECT cmdbContact WHERE IN NOT IN (40, 42)"; + $this->search_and_show_list_from_oql($sExpr1); + $this->search_and_show_list_from_oql($sExpr2); echo "Et maintenant, on fusionne....
    \n"; - $oSet1 = new CMDBObjectSet(DBObjectSearch::FromSibuSQL($sExpr1)); - $oSet2 = new CMDBObjectSet(DBObjectSearch::FromSibuSQL($sExpr2)); + $oSet1 = new CMDBObjectSet(DBObjectSearch::FromOQL($sExpr1)); + $oSet2 = new CMDBObjectSet(DBObjectSearch::FromOQL($sExpr2)); $oIntersect = $oSet1->CreateIntersect($oSet2); $oDelta = $oSet1->CreateDelta($oSet2); @@ -601,8 +583,8 @@ class TestMyBizModel extends TestBizModel $this->show_list($oObjectSet); } - echo "

    Test relations - same results, by the mean of a SibuSQL

    "; - $this->search_and_show_list_from_sibusql("cmdbContact: RELATED (Potes, $iMaxDepth) TO (cmdbContact: pkey = 18)"); + echo "

    Test relations - same results, by the mean of a OQL

    "; + $this->search_and_show_list_from_oql("cmdbContact: RELATED (Potes, $iMaxDepth) TO (cmdbContact: pkey = 18)"); } @@ -670,7 +652,7 @@ class TestMyBizModel extends TestBizModel protected function DoExecute() { -// $this->ReportError("Found two different SibuSQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); +// $this->ReportError("Found two different OQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); // $this->ReportSuccess('Found '.$oSet->Count()." objects of class $sClassName"); //$this->test_linksinfo(); //$this->test_list_attributes(); @@ -682,7 +664,7 @@ class TestMyBizModel extends TestBizModel //$this->test_error(); //$this->test_changetracking(); $this->test_zlist(); - $this->test_SibuSQL(); + $this->test_OQL(); //$this->test_pkey(); $this->test_relations(); $this->test_linkedset(); @@ -848,7 +830,7 @@ class TestQueriesOnFarm extends MyFarm protected function DoExecute() { -// $this->ReportError("Found two different SibuSQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); +// $this->ReportError("Found two different OQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); // $this->ReportSuccess('Found '.$oSet->Count()." objects of class $sClassName"); echo "

    Create protagonists...

    "; @@ -917,7 +899,6 @@ class TestQueriesOnFarm extends MyFarm 'SELECT Animal AS A JOIN Group AS G ON FooClass.leader = A.id' => false, 'SELECT Animal AS A JOIN Group AS G ON G.leader = FooClass.id' => false, 'SELECT Animal AS A JOIN Group AS G ON G.masterchief = A.id' => false, - 'SELECT Animal AS A JOIN Group AS G ON G.leader = A.pkey' => false, 'SELECT Animal AS A JOIN Group AS G ON A.id = G.leader' => false, 'SELECT Animal AS A JOIN Group AS G ON G.leader = A.id WHERE A.sex=\'male\' OR G.qwerty = 123' => false, 'SELECT Animal AS A JOIN Group AS G ON G.leader = A.id WHERE A.sex=\'male\' OR G.name LIKE "a%"' => true, @@ -990,7 +971,7 @@ class TestBulkChangeOnFarm extends TestBizModel protected function DoExecute() { -// $this->ReportError("Found two different SibuSQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); +// $this->ReportError("Found two different OQL expression out of the (same?) filter: $sExpr1 != $sExpr2"); // $this->ReportSuccess('Found '.$oSet->Count()." objects of class $sClassName"); $oParser = new CSVParser("denomination,hauteur,age diff --git a/setup/data/60.group.xml b/setup/data/60.group.xml index 2a45bfbfa..35ec90c86 100644 --- a/setup/data/60.group.xml +++ b/setup/data/60.group.xml @@ -1,7 +1,7 @@ -Monitroing Nagios server1 +Monitoring Nagios server1 production 2 low @@ -9,4 +9,4 @@ regroupe les CI monitorer par nagios 0 - \ No newline at end of file + diff --git a/setup/data/structure/1.menus.xml b/setup/data/structure/1.menus.xml index c1e725471..3b5ffef57 100644 --- a/setup/data/structure/1.menus.xml +++ b/setup/data/structure/1.menus.xml @@ -1,306 +1,306 @@ - - - -Admin tools - -UI.php - - -administrator -1000 -0 -0 - - -All Applications - -UI.php - - -application -999 -16 -0 - - -All Circuits - -UI.php - - -application -999 -16 -0 - - -All Contracts - -./UI.php - - -application -2 -38 -0 - - -All Interfaces - -UI.php - - -application -999 -16 -0 - - -All Network devices - -UI.php - - -application -999 -16 -0 - - -All Patches - -UI.php - - -application -999 -16 -0 - - -All PCs - -UI.php - - -application -999 -16 -0 - - -All Servers - -UI.php - - -application -999 -16 -0 - - -All Services - -UI.php - - -application -1 -38 -0 - - -All Subnets - -UI.php - - -application -999 -16 -0 - - -Application log - -UI.php -../images/std_view.gif - -administrator -2 -1 -0 - - -Audit - -./audit.php - - -application -4 -17 -0 - - -Change Management - -./UI.php - - -application -7 -0 -0 - - -Closed Changes - -UI.php - - -application -5 -13 -0 - - -Closed Incident - -./UI.php - - -application -5 -24 -0 - - -Configuration Items - -UI.php - + + + +Admin tools + +UI.php + + +administrator +1000 +0 +0 + + +All Applications + +UI.php + + +application +999 +16 +0 + + +All Circuits + +UI.php + + +application +999 +16 +0 + + +All Contracts + +./UI.php + + +application +2 +38 +0 + + +All Interfaces + +UI.php + + +application +999 +16 +0 + + +All Network devices + +UI.php + + +application +999 +16 +0 + + +All Patches + +UI.php + + +application +999 +16 +0 + + +All PCs + +UI.php + + +application +999 +16 +0 + + +All Servers + +UI.php + + +application +999 +16 +0 + + +All Services + +UI.php + + +application +1 +38 +0 + + +All Subnets + +UI.php + + +application +999 +16 +0 + + +Application log + +UI.php +../images/std_view.gif + +administrator +2 +1 +0 + + +Audit + +./audit.php + + +application +4 +17 +0 + + +Change Management + +./UI.php + + +application +7 +0 +0 + + +Closed Changes + +UI.php + + +application +5 +13 +0 + + +Closed Incident + +./UI.php + + +application +5 +24 +0 + + +Configuration Items + +UI.php + -application -2 -17 -0 - - -Configuration Management - -UI.php - - -application -2 -0 -0 - - -Contacts - -UI.php - +</table> +application +2 +17 +0 + + +Configuration Management + +UI.php + + +application +2 +0 +0 + + +Contacts + +UI.php + -application -1 -17 -0 - - -CSV import - -csvimport.php - - -application -999 -40 -0 - - -Data Model - -schema.php - - -administrator -1500 -1 -0 - - -Document - -UI.php - - -application -6 -17 -0 - - -Export - -../webservices/export.php - - -administrator -1001 -1 -0 - - -Grouping - -UI.php - - -application -3 -17 -0 - - -Incident Management - -./UI.php - - -application -5 -0 -0 - - -Known Errors - -./UI.php - - -application -999 -24 -0 - - -Locations - -UI.php - - -application -5 -17 -0 - - -My Changes - -UI.php - - -application -1 -13 -0 - - -My Incidents - -UI.php - - -application -1 -24 -0 - - -My Service calls - -UI.php - - -application -1 -37 -0 - - -Notifications - -UI.php - - -administrator -2 -1 -0 - - -Open Changes - -./UI.php - - -application -3 -13 -0 - - -Open Incidents - -UI.php - - -application -3 -24 -0 - - -Open Service calls - -UI.php - - -application -2 -37 -0 - - -Persons - -UI.php - - -application -7 -18 -0 - - -Profiles - -UI.php -../images/std_view.gif - -administrator -11 -43 -0 - - -Run queries - -./run_query.php - - -administrator -1002 -1 -0 - - -Scheduled Outages - -./UI.php - - -application -7 -13 -0 - - -Service Desk - -UI.php - - -application -3 -0 -0 - - -Service Management - -./UI.php - +</table> +application +1 +17 +0 + + +CSV import + +csvimport.php + + +application +999 +40 +0 + + +Data Model + +schema.php + + +administrator +1500 +1 +0 + + +Document + +UI.php + + +application +6 +17 +0 + + +Export + +../webservices/export.php + + +administrator +1001 +1 +0 + + +Grouping + +UI.php + + +application +3 +17 +0 + + +Incident Management + +./UI.php + + +application +5 +0 +0 + + +Known Errors + +./UI.php + + +application +999 +24 +0 + + +Locations + +UI.php + + +application +5 +17 +0 + + +My Changes + +UI.php + + +application +1 +13 +0 + + +My Incidents + +UI.php + + +application +1 +24 +0 + + +My Service calls + +UI.php + + +application +1 +37 +0 + + +Notifications + +UI.php + + +administrator +2 +1 +0 + + +Open Changes + +./UI.php + + +application +3 +13 +0 + + +Open Incidents + +UI.php + + +application +3 +24 +0 + + +Open Service calls + +UI.php + + +application +2 +37 +0 + + +Persons + +UI.php + + +application +7 +18 +0 + + +Profiles + +UI.php +../images/std_view.gif + +administrator +11 +43 +0 + + +Run queries + +./run_query.php + + +administrator +1002 +1 +0 + + +Scheduled Outages + +./UI.php + + +application +7 +13 +0 + + +Service Desk + +UI.php + + +application +3 +0 +0 + + +Service Management + +./UI.php + -application -8 -0 -0 - - -Teams - -UI.php - - -application -8 -18 -0 - - -Tools - -UI.php - - -application -9 -0 -0 - - -Universal Search - -UniversalSearch.php - - -administrator -1600 -1 -0 - - -User logins - -UI.php -../images/std_view.gif - -administrator -10 -43 -0 - - -User management - -UI.php - - -administrator -1 -1 -0 - - -Welcome - -./UI.php - - -application -1 -0 -0 - - + +application +8 +0 +0 + + +Teams + +UI.php + + +application +8 +18 +0 + + +Tools + +UI.php + + +application +9 +0 +0 + + +Universal Search + +UniversalSearch.php + + +administrator +1600 +1 +0 + + +User logins + +UI.php +../images/std_view.gif + +administrator +10 +43 +0 + + +User management + +UI.php + + +administrator +1 +1 +0 + + +Welcome + +./UI.php + + +application +1 +0 +0 + + diff --git a/setup/data/structure/21.auditcategories.xml b/setup/data/structure/21.auditcategories.xml index ae806c855..d7b4a9c20 100644 --- a/setup/data/structure/21.auditcategories.xml +++ b/setup/data/structure/21.auditcategories.xml @@ -3,6 +3,6 @@ Devices in production Checking all devices in production -bizDevice: status = 'production' +SELECT bizDevice AS d WHERE d.status = 'production' - \ No newline at end of file + diff --git a/setup/data/structure/22.auditrules.xml b/setup/data/structure/22.auditrules.xml index 8298ae182..39926f347 100644 --- a/setup/data/structure/22.auditrules.xml +++ b/setup/data/structure/22.auditrules.xml @@ -3,15 +3,15 @@ Devices in production on a Location not in production -bizDevice: location_id IN (bizLocation: status != 'production') +SELECT bizDevice AS d JOIN bizLocation AS l ON d.location_id = l.id WHERE l.status != 'production' false 1 Devices not attached to a monitoring group -bizDevice: PKEY IS infra_id IN (lnkInfraGrouping: infra_group_id IN (bizInfraGroup: type = 'Monitoring')) +SELECT bizDevice AS d JOIN lnkInfraGrouping AS l ON l.infra_id = d.id JOIN bizInfraGroup AS g ON l.infra_group_id = g.id WHERE g.type = 'Monitoring' true 1 - \ No newline at end of file + diff --git a/webservices/import.php b/webservices/import.php index 12c0facd3..ddf4b0deb 100644 --- a/webservices/import.php +++ b/webservices/import.php @@ -123,7 +123,7 @@ try $aDisplayConfig["__STATUS__"] = array("label"=>"Status", "description"=>""); if (isset($iPKeyId)) { - $aDisplayConfig["col$iPKeyId"] = array("label"=>"pkey", "description"=>""); + $aDisplayConfig["col$iPKeyId"] = array("label"=>"id", "description"=>""); } foreach($aReconcilKeys as $iCol => $sAttCode) {