diff --git a/datamodels/1.x/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml b/datamodels/1.x/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml index 5b4a89ccb..bc65906f9 100644 --- a/datamodels/1.x/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml +++ b/datamodels/1.x/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml @@ -1,5 +1,22 @@ + + + + + + + + + + + + + + + + + ResponseTicket diff --git a/datamodels/1.x/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php b/datamodels/1.x/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php index 635a65cea..6fd199e66 100644 --- a/datamodels/1.x/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php +++ b/datamodels/1.x/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php @@ -1,43 +1 @@ - -define('PORTAL_POWER_USER_PROFILE', 'Portal power user'); - -define('PORTAL_SERVICECATEGORY_QUERY', 'SELECT Service AS s JOIN SLA AS sla ON sla.service_id=s.id JOIN lnkContractToSLA AS ln ON ln.sla_id=sla.id JOIN CustomerContract AS cc ON ln.contract_id=cc.id WHERE cc.org_id = :org_id'); -define('PORTAL_SERVICE_SUBCATEGORY_QUERY', 'SELECT ServiceSubcategory WHERE service_id = :svc_id'); - -define('PORTAL_VALIDATE_SERVICECATEGORY_QUERY', 'SELECT Service AS s JOIN SLA AS sla ON sla.service_id=s.id JOIN lnkContractToSLA AS ln ON ln.sla_id=sla.id JOIN CustomerContract AS cc ON ln.contract_id=cc.id WHERE cc.org_id = :org_id AND s.id = :id'); -define('PORTAL_VALIDATE_SERVICESUBCATEGORY_QUERY', 'SELECT ServiceSubcategory AS Sub JOIN Service AS Svc ON Sub.service_id = Svc.id WHERE Sub.id=:id'); - -define('PORTAL_ALL_PARAMS', 'from_service_id,org_id,caller_id,service_id,servicesubcategory_id,title,description,impact,urgency,workgroup_id,moreinfo,caller_id,start_date,end_date,duration,impact_duration'); - -define('PORTAL_ATTCODE_LOG', 'ticket_log'); -define('PORTAL_ATTCODE_COMMENT', 'user_commment'); -define('PORTAL_REQUEST_FORM_ATTRIBUTES', 'title,description,impact,urgency,workgroup_id,ticket_log'); - -define('PORTAL_ATTCODE_TYPE', ''); // optional if the type has to be set -define('PORTAL_SET_TYPE_FROM', ''); // The attribute to get the type from (Subcategory) - -define('PORTAL_TICKETS_LIST_ZLIST', 'finalclass,title,start_date,status,servicesubcategory_id,priority,caller_id'); -define('PORTAL_TICKETS_SEARCH_CRITERIA','ref,start_date,close_date,service_id,caller_id'); -define('PORTAL_TICKETS_CLOSED_ZLIST', 'title,start_date,close_date,servicesubcategory_id'); -// json encoded lists for the portal... -define('PORTAL_TICKET_DETAILS_ZLIST', '{"col:left":["ref","caller_id","servicesubcategory_id","title","description","solution"],"col:right":["status","priority","start_date","resolution_date","last_update","agent_id"]}'); - - -?> diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml index 1799bd83b..f270b1e0f 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml +++ b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml @@ -1,5 +1,22 @@ + + + + + + + + + + + + + + + + + Ticket diff --git a/datamodels/2.x/itop-request-mgmt-itil/main.itop-request-mgmt-itil.php b/datamodels/2.x/itop-request-mgmt-itil/main.itop-request-mgmt-itil.php index c1ef23cd1..b3d9bbc7f 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/main.itop-request-mgmt-itil.php +++ b/datamodels/2.x/itop-request-mgmt-itil/main.itop-request-mgmt-itil.php @@ -1,41 +1 @@ - -define('PORTAL_POWER_USER_PROFILE', 'Portal power user'); - -define('PORTAL_SERVICECATEGORY_QUERY', "SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.status != 'obsolete'"); -define('PORTAL_SERVICE_SUBCATEGORY_QUERY', 'SELECT ServiceSubcategory WHERE service_id = :svc_id AND request_type="service_request" AND ServiceSubcategory.status != "obsolete"'); - -define('PORTAL_VALIDATE_SERVICECATEGORY_QUERY', "SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.id = :id AND s.status != 'obsolete'"); -define('PORTAL_VALIDATE_SERVICESUBCATEGORY_QUERY', "SELECT ServiceSubcategory AS Sub JOIN Service AS Svc ON Sub.service_id = Svc.id WHERE Sub.id=:id AND Sub.status != 'obsolete'"); - -define('PORTAL_ALL_PARAMS', 'from_service_id,org_id,caller_id,service_id,servicesubcategory_id,title,description,impact,emergency,moreinfo,caller_id,start_date,end_date,duration,impact_duration'); - -define('PORTAL_ATTCODE_LOG', 'public_log'); -define('PORTAL_ATTCODE_COMMENT', 'user_comment'); -define('PORTAL_REQUEST_FORM_ATTRIBUTES', 'title,description,impact,urgency'); - -define('PORTAL_ATTCODE_TYPE', ''); // optional if the type has to be set -define('PORTAL_SET_TYPE_FROM', ''); // The attribute to get the type from (Subcategory) - -define('PORTAL_TICKETS_LIST_ZLIST', 'finalclass,title,start_date,status,servicesubcategory_id,priority,caller_id'); -define('PORTAL_TICKETS_SEARCH_CRITERIA','ref,start_date,close_date,service_id,caller_id'); -define('PORTAL_TICKETS_CLOSED_ZLIST', 'title,start_date,close_date,servicesubcategory_id'); -// json encoded lists for the portal... -define('PORTAL_TICKET_DETAILS_ZLIST', '{"col:left":["ref","caller_id","servicesubcategory_id","title","description","solution"],"col:right":["status","priority","start_date","resolution_date","last_update","agent_id"]}'); -?> diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index 2b75b68c0..7b1331411 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml @@ -1,5 +1,22 @@ + + + + + + + + + + + + + + + + + Ticket diff --git a/datamodels/2.x/itop-request-mgmt/main.itop-request-mgmt.php b/datamodels/2.x/itop-request-mgmt/main.itop-request-mgmt.php index 62a47268f..b3d9bbc7f 100755 --- a/datamodels/2.x/itop-request-mgmt/main.itop-request-mgmt.php +++ b/datamodels/2.x/itop-request-mgmt/main.itop-request-mgmt.php @@ -1,41 +1 @@ - -define('PORTAL_POWER_USER_PROFILE', 'Portal power user'); - -define('PORTAL_SERVICECATEGORY_QUERY', "SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.status != 'obsolete'"); -define('PORTAL_SERVICE_SUBCATEGORY_QUERY', "SELECT ServiceSubcategory WHERE service_id = :svc_id AND ServiceSubcategory.status != 'obsolete'"); - -define('PORTAL_VALIDATE_SERVICECATEGORY_QUERY', "SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :org_id AND s.id = :id AND s.status != 'obsolete'"); -define('PORTAL_VALIDATE_SERVICESUBCATEGORY_QUERY', "SELECT ServiceSubcategory AS Sub JOIN Service AS Svc ON Sub.service_id = Svc.id WHERE Sub.id=:id AND Sub.status != 'obsolete'"); - -define('PORTAL_ALL_PARAMS', 'from_service_id,org_id,caller_id,service_id,servicesubcategory_id,title,description,impact,emergency,moreinfo,caller_id,start_date,end_date,duration,impact_duration'); - -define('PORTAL_ATTCODE_LOG', 'public_log'); -define('PORTAL_ATTCODE_COMMENT', 'user_comment'); -define('PORTAL_REQUEST_FORM_ATTRIBUTES', 'title,description,impact,urgency,public_log'); - -define('PORTAL_ATTCODE_TYPE', 'request_type'); // optional if the type has to be set -define('PORTAL_SET_TYPE_FROM', 'request_type'); // The attribute to get the type from (Subcategory) - -define('PORTAL_TICKETS_LIST_ZLIST', 'finalclass,title,start_date,status,servicesubcategory_id,priority,caller_id'); -define('PORTAL_TICKETS_SEARCH_CRITERIA','ref,start_date,close_date,service_id,caller_id'); -define('PORTAL_TICKETS_CLOSED_ZLIST', 'title,start_date,close_date,servicesubcategory_id'); -// json encoded lists for the portal... -define('PORTAL_TICKET_DETAILS_ZLIST', '{"col:left":["ref","caller_id","servicesubcategory_id","title","description","solution"],"col:right":["status","priority","start_date","resolution_date","last_update","agent_id"]}'); -?> diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 3c7bf3c16..17491df08 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -153,6 +153,15 @@ class MFCompiler $sCompiledCode = ''; + $oConstants = $this->oFactory->ListConstants($sModuleName); + if ($oConstants->length > 0) + { + foreach($oConstants as $oConstant) + { + $sCompiledCode .= $this->CompileConstant($oConstant)."\n"; + } + } + $oClasses = $this->oFactory->ListClasses($sModuleName); $iClassCount = $oClasses->length; if ($iClassCount == 0) @@ -546,6 +555,58 @@ EOF; return $sRet; } + protected function CompileConstant($oConstant) + { + $sName = $oConstant->getAttribute('id'); + $sType = $oConstant->getAttribute('xsi:type'); + $sText = $oConstant->GetText(null); + + switch ($sType) + { + case 'integer': + if (is_null($sText)) + { + // No data given => null + $sScalar = 'null'; + } + else + { + $sScalar = (string)(int)$sText; + } + break; + + case 'float': + if (is_null($sText)) + { + // No data given => null + $sScalar = 'null'; + } + else + { + $sScalar = (string)(float)$sText; + } + break; + + case 'bool': + if (is_null($sText)) + { + // No data given => null + $sScalar = 'null'; + } + else + { + $sScalar = ($sText == 'true') ? 'true' : 'false'; + } + break; + + case 'string': + default: + $sScalar = $this->QuoteForPHP($sText, true); + } + $sPHPDefine = "define('$sName', $sScalar);"; + return $sPHPDefine; + } + protected function CompileClass($oClass, $sTempTargetDir, $sFinalTargetDir, $sModuleRelativeDir, $oP) { $sClass = $oClass->getAttribute('id'); diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index fb020e6a4..bef6167c2 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -1,5 +1,5 @@ SetAttribute('_created_in', $sModuleName); } } + $oNodeList = $oXPath->query('/itop_design/constants/constant'); + foreach($oNodeList as $oNode) + { + if ($oNode->getAttribute('_created_in') == '') + { + $oNode->SetAttribute('_created_in', $sModuleName); + } + } $oNodeList = $oXPath->query('/itop_design/menus/menu'); foreach($oNodeList as $oNode) { @@ -752,9 +760,26 @@ $sHeader EOF ; } + + /** + * List all constants from the DOM, for a given module + * @param string $sModuleName + * @param bool $bFlattenLayers + * @throws Exception + */ + public function ListConstants($sModuleName, $bFlattenLayers = true) + { + $sXPath = "/itop_design/constants/constant[@_created_in='$sModuleName']"; + if ($bFlattenLayers) + { + $sXPath = "/itop_design/constants/constant[@_created_in='$sModuleName' and (not(@_alteration) or @_alteration!='removed')]"; + } + return $this->GetNodes($sXPath); + } + /** * List all classes from the DOM, for a given module - * @param string $sModuleNale + * @param string $sModuleName * @param bool $bFlattenLayers * @throws Exception */ @@ -1503,7 +1528,7 @@ class MFElement extends DOMElement } /** - * For debugging purposes - but this is currently buggy: the whole document is rendered + * For debugging purposes */ public function Dump($bReturnRes = false) {