\n");
-
// Object's details
// template not found display the object using the *old style*
- self::DisplayBareDetails($oPage);
-
- // Related objects
- $oPage->AddTabContainer('Related Objects');
- $oPage->SetCurrentTabContainer('Related Objects');
- foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
- {
- if ((get_class($oAttDef) == 'AttributeLinkedSetIndirect') || (get_class($oAttDef) == 'AttributeLinkedSet'))
- {
- $oPage->SetCurrentTab($oAttDef->GetLabel());
- $oPage->p($oAttDef->GetDescription());
-
- if (get_class($oAttDef) == 'AttributeLinkedSet')
- {
- $sTargetClass = $oAttDef->GetLinkedClass();
- $oFilter = new DBObjectSearch($sTargetClass);
- $oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey()); // @@@ condition has same name as field ??
-
- $oBlock = new DisplayBlock($oFilter, 'list', false);
- $oBlock->Display($oPage, 0);
- }
- else // get_class($oAttDef) == 'AttributeLinkedSetIndirect'
- {
- $sLinkClass = $oAttDef->GetLinkedClass();
- // Transform the DBObjectSet into a CMBDObjectSet !!!
- $aLinkedObjects = $this->Get($sAttCode)->ToArray(false);
- if (count($aLinkedObjects) > 0)
- {
- $oSet = CMDBObjectSet::FromArray($sLinkClass, $aLinkedObjects);
- $this->DisplaySet($oPage, $oSet, $oAttDef->GetExtKeyToMe());
- }
- }
- }
- }
- $oPage->SetCurrentTab('');
+ $this->DisplayBareHeader($oPage);
+ $this->DisplayBareDetails($oPage);
+ $this->DisplayBareRelations($oPage);
}
}
@@ -218,10 +233,10 @@ abstract class cmdbAbstractObject extends CMDBObject
}
// Comment by Rom: this helper may be used to display objects of class DBObject
- // -> I am using this to display the changes history
- public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false, $iObjectId = 0)
+ // -> I am using this to display the changes history
+ public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false, $iObjectId = 0, $sTargetAttribute = '')
{
- $oPage->add(self::GetDisplaySet($oPage, $oSet, array( 'link_attr' => $sLinkageAttribute, 'object_id' => $iObjectId, 'menu' => $bDisplayMenu, 'selection_mode' => $bSelectMode)));
+ $oPage->add(self::GetDisplaySet($oPage, $oSet, array( 'link_attr' => $sLinkageAttribute, 'object_id' => $iObjectId, 'target_attr' => $sTargetAttribute, 'menu' => $bDisplayMenu, 'selection_mode' => $bSelectMode)));
}
//public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false)
@@ -238,7 +253,7 @@ abstract class cmdbAbstractObject extends CMDBObject
{
if($iLinkedObjectId == 0)
{
- // if 'links' mode is requested the d of the object to link to must be specified
+ // if 'links' mode is requested the id of the object to link to must be specified
throw new ApplicationException("Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template.");
}
if($sTargetAttr == '')
@@ -438,9 +453,9 @@ abstract class cmdbAbstractObject extends CMDBObject
$sClassName = $oSet->GetFilter()->GetClass();
$sHtml .= "
Search for ".MetaModel::GetName($sClassName)." Objects
\n";
@@ -487,32 +502,33 @@ abstract class cmdbAbstractObject extends CMDBObject
}
}
}
- $aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, array(), '');
- if ($aAllowedValues != null)
- {
- //Enum field or external key, display a combo
- $sValue = "\n";
- $sHtml .= "
$sValue
\n";
- }
- else
- {
- // Any value is possible, display an input box
- $sHtml .= "
\n";
- }
+ // #@# todo - add context information, otherwise any value will be authorized for external keys
+ $aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, array());
+ if ($aAllowedValues != null)
+ {
+ //Enum field or external key, display a combo
+ $sValue = "\n";
+ $sHtml .= "
$sValue
\n";
+ }
+ else
+ {
+ // Any value is possible, display an input box
+ $sHtml .= "
\n";
+ }
$index++;
}
if (($index % $numCols) != 0)
@@ -577,6 +593,10 @@ abstract class cmdbAbstractObject extends CMDBObject
$sHTMLValue = "";
break;
+ case 'Password':
+ $sHTMLValue = "";
+ break;
+
case 'Text':
$sHTMLValue = "";
break;
@@ -588,39 +608,41 @@ abstract class cmdbAbstractObject extends CMDBObject
case 'String':
default:
- $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array(), '');
- if ($aAllowedValues !== null)
- {
- //Enum field or external key, display a combo
- if (count($aAllowedValues) == 0)
+ // #@# todo - add context information (depending on dimensions)
+ $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array());
+ if ($aAllowedValues !== null)
{
- $sHTMLValue = "";
- }
- else if (count($aAllowedValues) > 50)
- {
- // too many choices, use an autocomplete
- // The input for the auto complete
- $sHTMLValue = "";
- // another hidden input to store & pass the object's Id
- $sHTMLValue .= "\n";
- $oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});");
+ //Enum field or external key, display a combo
+ if (count($aAllowedValues) == 0)
+ {
+ $sHTMLValue = "";
+ }
+ else if (count($aAllowedValues) > 50)
+ {
+ // too many choices, use an autocomplete
+ // The input for the auto complete
+ $sHTMLValue = "";
+ // another hidden input to store & pass the object's Id
+ $sHTMLValue .= "\n";
+ $oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});");
+ }
+ else
+ {
+ // Few choices, use a normal 'select'
+ $sHTMLValue = "\n";
+ }
}
else
{
- // Few choices, use a normal 'select'
- $sHTMLValue = "\n";
+ $sHTMLValue = "";
}
- }
- else
- {
- $sHTMLValue = "";
- }
+ break;
}
}
return $sHTMLValue;
diff --git a/application/iotask.class.inc.php b/application/iotask.class.inc.php
index 32eb33400..f1f62f8c7 100644
--- a/application/iotask.class.inc.php
+++ b/application/iotask.class.inc.php
@@ -31,7 +31,7 @@ class InputOutputTask extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("label"=>"Source Type", "description"=>"Type of data source", "allowed_values"=>new ValueSetEnum('File, Database, Web Service'), "sql"=>"source_type", "default_value"=>"File", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("label"=>"Source Subtype", "description"=>"Subtype of Data Source", "allowed_values"=>new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql"=>"source_subtype", "default_value"=>"CSV", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("source_path", array("label"=>"Source Path", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"source_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeEnum("objects_class", array("label"=>"Objects Class", "description"=>"Class of the objects processed by this task", "allowed_values"=>new ValueSetEnum('bizOrganization, bizContact, bizTeam, bizPerson, bizLocation, bizServer, bizPC, bizNetworkDevice, bizInterface, bizService, bizContract, bizInfraGroup, bizIncidentTicket, bizSoftware, bizApplication, bizPatch, bizWorkgroup, lnkContactRealObject, lnkInterfaces, bizInfraGrouping' ), "sql"=>"objects_class", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
+ MetaModel::Init_AddAttribute(new AttributeEnum("objects_class", array("label"=>"Objects Class", "description"=>"Class of the objects processed by this task", "allowed_values"=>new ValueSetEnumClasses(), "sql"=>"objects_class", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("label"=>"Test Mode", "description"=>"If set to 'Yes' the modifications are not applied", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"test_mode", "default_value"=>'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("label"=>"Verbose Mode", "description"=>"If set to 'Yes' extra debug information is added to the log", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"verbose_mode", "default_value" => 'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("options", array("label"=>"Options", "description"=>"Reconciliation options", "allowed_values"=>new ValueSetEnum('Full, Update Only, Creation Only'), "sql"=>"options", "default_value"=> 'Full', "is_null_allowed"=>true, "depends_on"=>array())));
diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php
index b315d17f4..37590b6a3 100644
--- a/application/itopwebpage.class.inc.php
+++ b/application/itopwebpage.class.inc.php
@@ -158,29 +158,44 @@ EOF
$this->AddToMenu("\n");
$this->AddToMenu("
\n");
$this->AddToMenu("
\n");
- $oAppContext = new ApplicationContext();
- // Display the menu
- // 1) Application defined menus
- $oSearchFilter = $oContext->NewFilter("menuNode");
- $oSearchFilter->AddCondition('parent_id', 0, '=');
- $oSearchFilter->AddCondition('type', 'application', '=');
- // There may be more criteria added later to have a specific menu based on the user's profile
- $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
- while ($oRootMenuNode = $oSet->Fetch())
- {
- $oRootMenuNode->DisplayMenu($this, 'application', $oAppContext->GetAsHash());
- }
- // 2) User defined menus (Bookmarks)
- $oSearchFilter = $oContext->NewFilter("menuNode");
- $oSearchFilter->AddCondition('parent_id', 0, '=');
- $oSearchFilter->AddCondition('type', 'user', '=');
- $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
- // There may be more criteria added later to have a specific menu based on the user's profile
- $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
- while ($oRootMenuNode = $oSet->Fetch())
- {
- $oRootMenuNode->DisplayMenu($this, 'user', $oAppContext->GetAsHash());
- }
+
+ // Display the menu
+ $oAppContext = new ApplicationContext();
+ // 1) Application defined menus
+ $oSearchFilter = $oContext->NewFilter("menuNode");
+ $oSearchFilter->AddCondition('parent_id', 0, '=');
+ $oSearchFilter->AddCondition('type', 'application', '=');
+ // There may be more criteria added later to have a specific menu based on the user's profile
+ $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
+ while ($oRootMenuNode = $oSet->Fetch())
+ {
+ $oRootMenuNode->DisplayMenu($this, 'application', $oAppContext->GetAsHash());
+ }
+ // 2) User defined menus (Bookmarks)
+ $oSearchFilter = $oContext->NewFilter("menuNode");
+ $oSearchFilter->AddCondition('parent_id', 0, '=');
+ $oSearchFilter->AddCondition('type', 'user', '=');
+ $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
+ // There may be more criteria added later to have a specific menu based on the user's profile
+ $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
+ while ($oRootMenuNode = $oSet->Fetch())
+ {
+ $oRootMenuNode->DisplayMenu($this, 'user', $oAppContext->GetAsHash());
+ }
+ // 3) Administrator menu
+ if (userRights::IsAdministrator())
+ {
+ $oSearchFilter = $oContext->NewFilter("menuNode");
+ $oSearchFilter->AddCondition('parent_id', 0, '=');
+ $oSearchFilter->AddCondition('type', 'administrator', '=');
+ // There may be more criteria added later to have a specific menu based on the user's profile
+ $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
+ while ($oRootMenuNode = $oSet->Fetch())
+ {
+ $oRootMenuNode->DisplayMenu($this, 'administrator', $oAppContext->GetAsHash());
+ }
+ }
+
$this->AddToMenu("
\n");
}
diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php
index 72ddfeb23..23cf78ead 100644
--- a/application/menunode.class.inc.php
+++ b/application/menunode.class.inc.php
@@ -42,7 +42,7 @@ class menuNode extends DBObject
MetaModel::Init_AddAttribute(new AttributeString("hyperlink", array("label"=>"Hyperlink", "description"=>"Hyperlink to the page", "allowed_values"=>null, "sql"=>"hyperlink", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("icon_path", array("label"=>"Menu Icon", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"icon_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("template", array("label"=>"Template", "description"=>"HTML template for the view", "allowed_values"=>null, "sql"=>"template", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of menu", "allowed_values"=>new ValueSetEnum('application,user'), "sql"=>"type", "default_value"=>"application", "is_null_allowed"=>false, "depends_on"=>array())));
+ MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of menu", "allowed_values"=>new ValueSetEnum('application,user,administrator'), "sql"=>"type", "default_value"=>"application", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("rank", array("label"=>"Display rank", "description"=>"Sort order for displaying the menu", "allowed_values"=>null, "sql"=>"rank", "default_value" => 999, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "sql"=>"parent_id", "targetclass"=>"menuNode", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "extkey_attcode"=>"parent_id", "target_attcode"=>"name")));
@@ -91,17 +91,25 @@ class menuNode extends DBObject
public function GetChildNodesSet($sType = null)
{
- $oSearchFilter = new DBObjectSearch("menuNode");
- $oSearchFilter->AddCondition('parent_id', $this->GetKey(), '=');
- if ($sType != null)
+ $aParams = array();
+
+ if ($sType == 'user')
{
- $oSearchFilter->AddCondition('type', $sType, '=');
- if ($sType == 'user')
- {
- $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
- }
+ $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type AND m.user_id = :user';
+ $aParams = array('parent' => $this->GetKey(), 'type' => $sType, 'user' => UserRights::GetUserId());
}
- $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
+ elseif ($sType != null)
+ {
+ $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type';
+ $aParams = array('parent' => $this->GetKey(), 'type' => $sType);
+ }
+ else
+ {
+ $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent';
+ $aParams = array('parent' => $this->GetKey());
+ }
+ $oSearchFilter = DBObjectSearch::FromOQL($sSelectChilds);
+ $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true), $aParams);
return $oSet;
}
diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php
index de602bdd0..5c4bd7d6c 100644
--- a/application/ui.linkswidget.class.inc.php
+++ b/application/ui.linkswidget.class.inc.php
@@ -21,6 +21,7 @@ class UILinksWidget
{
$sHTMLValue = '';
$sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode);
+ // #@# todo - add context information, otherwise any value will be authorized for external keys
$aAllowedValues = MetaModel::GetAllowedValues_att($this->m_sClass, $this->m_sAttCode, array(), '');
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
@@ -120,6 +121,7 @@ class UILinksWidget
*/
static public function Autocomplete(web_page $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount)
{
+ // #@# todo - add context information, otherwise any value will be authorized for external keys
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array() /* $aArgs */, $sName);
if ($aAllowedValues != null)
{
@@ -154,12 +156,13 @@ class UILinksWidget
* This static function is called by the Ajax Page display a set of objects being linked
* to the object being created
* @param $oPage web_page The ajax page used for the put^put (sent back to the browser
- * @param $sClass string The name of the class 'linking class' which is the class of the objects to display
- * @param $sAttCode string The name of the attribute is the main object being created
+ * @param $sClass string The name of the 'linking class' which is the class of the objects to display
* @param $sSet JSON serialized set of objects
+ * @param $sExtKeyToMe Name of the attribute in sClass that is pointing to a given object
+ * @param $iObjectId The id of the object $sExtKeyToMe is pointing to
* @return void
*/
- static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe)
+ static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId)
{
$aSet = json_decode($sJSONSet, true); // true means hash array instead of object
$oSet = CMDBObjectSet::FromScratch($sClass);
@@ -182,7 +185,7 @@ class UILinksWidget
}
$oSet->AddObject($oObj);
}
- cmdbAbstractObject::DisplaySet($oPage, $oSet, $sExtKeyToMe);
+ cmdbAbstractObject::DisplaySet($oPage, $oSet, $sExtKeyToMe, true /*menu*/, false /*select*/, $iObjectId, $sExtKeyToRemote);
}
diff --git a/business/incident.business.php b/business/incident.business.php
index 5a130959a..fa275b150 100644
--- a/business/incident.business.php
+++ b/business/incident.business.php
@@ -55,7 +55,9 @@ class bizIncidentTicket extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeDate("next_update", array("label"=>"Next update", "description"=>"next time the Ticket is expected to be modified", "allowed_values"=>null, "sql"=>"next_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("end_date", array("label"=>"Closed Date", "description"=>"Date when the Ticket was closed", "allowed_values"=>null, "sql"=>"closed_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>null, "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array())));
+ //MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>null, "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array())));
+ MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = :this->customer_id'), "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array('customer_id'))));
+ //MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = 1'), "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array('customer_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("caller_mail", array("label"=>"Caller", "description"=>"Person that trigger this incident", "allowed_values"=>null, "extkey_attcode"=> 'caller_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact of the Incident", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index d1af378a4..865da0625 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -178,6 +178,13 @@ abstract class AttributeDefinition
{
return str_replace($sSeparator, $sSepEscape, $sValue);
}
+
+ public function GetAllowedValues($aArgs = array(), $sBeginsWith = '')
+ {
+ $oValSetDef = $this->GetValuesDef();
+ if (!$oValSetDef) return null;
+ return $oValSetDef->GetValues($aArgs, $sBeginsWith);
+ }
}
/**
@@ -490,7 +497,10 @@ class AttributeString extends AttributeDBField
}
public function RealValueToSQLValue($value)
{
- assert(is_string($value));
+ if (!is_string($value))
+ {
+ throw new CoreWarning('Expected the attribute value to be a string', array('found_type' => gettype($value), 'value' => $value, 'class' => $this->GetCode(), 'attribute' => $this->GetHostClass()));
+ }
return $value;
}
public function SQLValueToRealValue($value)
@@ -499,6 +509,29 @@ class AttributeString extends AttributeDBField
}
}
+
+/**
+ * Map a varchar column (size < ?) to an attribute that must never be shown to the user
+ *
+ * @package iTopORM
+ * @author Romain Quetiez
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.itop.com
+ * @since 1.0
+ * @version $itopversion$
+ */
+class AttributePassword extends AttributeString
+{
+ static protected function ListExpectedParams()
+ {
+ return parent::ListExpectedParams();
+ //return array_merge(parent::ListExpectedParams(), array());
+ }
+
+ public function GetEditClass() {return "Password";}
+ public function GetDBFieldType() {return "VARCHAR(64)";}
+}
+
/**
* Map a text column (size > ?) to an attribute
*
@@ -778,7 +811,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
}
// overloaded here so that an ext key always have the answer to
- // "what are you possible values?"
+ // "what are your possible values?"
public function GetValuesDef()
{
$oValSetDef = $this->Get("allowed_values");
@@ -788,7 +821,21 @@ class AttributeExternalKey extends AttributeDBFieldVoid
$oValSetDef = new ValueSetObjects($this->GetTargetClass());
}
return $oValSetDef;
- }
+ }
+
+ public function GetAllowedValues($aArgs = array(), $sBeginsWith = '')
+ {
+ try
+ {
+ return parent::GetAllowedValues($aArgs, $sBeginsWith);
+ }
+ catch (MissingQueryArgument $e)
+ {
+ // Some required arguments could not be found, enlarge to any existing value
+ $oValSetDef = new ValueSetObjects($this->GetTargetClass());
+ return $oValSetDef->GetValues($aArgs, $sBeginsWith);
+ }
+ }
}
/**
diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php
index e30d3a5fa..03020556f 100644
--- a/core/dbobjectsearch.class.php
+++ b/core/dbobjectsearch.class.php
@@ -16,7 +16,6 @@
/**
* Sibusql - value set start
* @package iTopORM
- * @info zis is private
*/
define('VS_START', '{');
/**
@@ -465,7 +464,7 @@ class DBObjectSearch
public function RenderCondition()
{
- return $this->m_oSearchCondition->Render($this->m_aParams);
+ return $this->m_oSearchCondition->Render($this->m_aParams, true);
}
public function serialize()
@@ -507,7 +506,15 @@ class DBObjectSearch
$sRelCode = $aRelatedTo['relcode'];
$iMaxDepth = $aRelatedTo['maxdepth'];
- $sValue .= "T:".$oFilter->serialize().":$sRelCode:$iMaxDepth";
+ $sValue .= "T:".$oFilter->serialize().":$sRelCode:$iMaxDepth\n";
+ }
+ if (count($this->m_aParams) > 0)
+ {
+ foreach($this->m_aParams as $sName => $sArgValue)
+ {
+ // G stands for arGument
+ $sValue .= "G:$sName:$sArgValue\n";
+ }
}
return base64_encode($sValue);
}
@@ -554,6 +561,11 @@ class DBObjectSearch
$sRelCode = $aCondition[2];
$iMaxDepth = $aCondition[3];
$oFilter->AddCondition_RelatedTo($oSubFilter, $sRelCode, $iMaxDepth);
+ break;
+ case "G":
+ $oFilter->m_aParams[$aCondition[1]] = $aCondition[2];
+ break;
+
default:
throw new CoreException("invalid filter definition (cannot unserialize the data, clear text = '$sClearText')");
}
@@ -600,6 +612,22 @@ class DBObjectSearch
public function ToOQL(&$aParams = null)
{
$bRetrofitParams = (!is_null($aParams));
+ if (is_null($aParams))
+ {
+ if (count($this->m_aParams) > 0)
+ {
+ $aParams = $this->m_aParams;
+ }
+ $bRetrofitParams = false;
+ }
+ else
+ {
+ if (count($this->m_aParams) > 0)
+ {
+ $aParams = array_merge($aParams, $this->m_aParams);
+ }
+ $bRetrofitParams = true;
+ }
$sRes = "SELECT ".$this->GetClass().' AS '.$this->GetClassAlias();
$sRes .= $this->ToOQL_Joins();
diff --git a/core/expression.class.inc.php b/core/expression.class.inc.php
index 834ac47b7..82b3e61b3 100644
--- a/core/expression.class.inc.php
+++ b/core/expression.class.inc.php
@@ -11,6 +11,11 @@
* @since 1.0
* @version 1.1.1.1 $
*/
+
+class MissingQueryArgument extends CoreException
+{
+}
+
abstract class Expression
{
// recursive translation of identifiers
@@ -301,7 +306,7 @@ class VariableExpression extends UnaryExpression
// recursive rendering
public function Render(&$aArgs = null, $bRetrofitParams = false)
{
- if (is_null($aArgs) || $bRetrofitParams)
+ if (is_null($aArgs))
{
return ':'.$this->m_sName;
}
@@ -309,9 +314,14 @@ class VariableExpression extends UnaryExpression
{
return CMDBSource::Quote($aArgs[$this->m_sName]);
}
+ elseif ($bRetrofitParams)
+ {
+ //$aArgs[$this->m_sName] = null;
+ return ':'.$this->m_sName;
+ }
else
{
- throw new CoreException('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>$aArgs));
+ throw new MissingQueryArgument('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>$aArgs));
}
}
}
diff --git a/core/filterdef.class.inc.php b/core/filterdef.class.inc.php
index 371eadbd5..8a2d7d096 100644
--- a/core/filterdef.class.inc.php
+++ b/core/filterdef.class.inc.php
@@ -209,7 +209,13 @@ class FilterFromAttribute extends FilterDefinition
{
$oAttDef = $this->Get("refattribute");
return $oAttDef->GetValuesDef();
- }
+ }
+
+ public function GetAllowedValues($aArgs = array(), $sBeginsWith = '')
+ {
+ $oAttDef = $this->Get("refattribute");
+ return $oAttDef->GetAllowedValues($aArgs, $sBeginsWith);
+ }
public function GetOperators()
{
@@ -235,62 +241,4 @@ class FilterFromAttribute extends FilterDefinition
}
}
-/**
- * Match against a given column (experimental -to be cleaned up later)
- *
- * @package iTopORM
- * @author Romain Quetiez
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- * @link www.itop.com
- * @since 1.0
- * @version $itopversion$
- */
-class FilterDBValues extends FilterDefinition
-{
- static protected function ListExpectedParams()
- {
- return array_merge(parent::ListExpectedParams(), array("dbfield"));
- }
-
- public function GetType() {return "Values from DB";}
- public function GetTypeDesc() {return "Match against the existing values in a field";}
-
- public function GetLabel()
- {
- return "enum de valeurs DB";
- }
-
- public function GetValuesDef()
- {
- return null;
- }
-
- public function GetOperators()
- {
- return array(
- "IN"=>"in",
- );
- }
- public function GetLooseOperator()
- {
- return "IN";
- }
-
- public function GetFilterSQLExpr($sOpCode, $value)
- {
- $sFieldName = $this->Get("dbfield");
- if (is_array($value) && !empty($value))
- {
- $sValueList = "'".implode("', '", $value)."'";
- return "$sFieldName IN ($sValueList)";
- }
- return "1=1";
- }
-
- public function TemporaryGetSQLCol()
- {
- return $this->Get("dbfield");
- }
-}
-
?>
diff --git a/core/metamodel.class.php b/core/metamodel.class.php
index 5fe13c140..6d24d113e 100644
--- a/core/metamodel.class.php
+++ b/core/metamodel.class.php
@@ -665,19 +665,13 @@ abstract class MetaModel
public static function GetAllowedValues_att($sClass, $sAttCode, $aArgs = array(), $sBeginsWith = '')
{
$oAttDef = self::GetAttributeDef($sClass, $sAttCode);
- if (!$oAttDef) return null;
- $oValSetDef = $oAttDef->GetValuesDef();
- if (!$oValSetDef) return null;
- return $oValSetDef->GetValues($aArgs, $sBeginsWith);
+ return $oAttDef->GetAllowedValues($aArgs, $sBeginsWith);
}
public static function GetAllowedValues_flt($sClass, $sFltCode, $aArgs = array(), $sBeginsWith = '')
{
$oFltDef = self::GetClassFilterDef($sClass, $sFltCode);
- if (!$oFltDef) return null;
- $oValSetDef = $oFltDef->GetValuesDef();
- if (!$oValSetDef) return null;
- return $oValSetDef->GetValues($aArgs, $sBeginsWith);
+ return $oFltDef->GetAllowedValues($aArgs, $sBeginsWith);
}
//
@@ -820,6 +814,18 @@ abstract class MetaModel
self::$m_aFilterDefs[$sClass][$sClassAttCode] = $oClassFlt;
self::$m_aFilterOrigins[$sClass][$sClassAttCode] = self::GetRootClass($sClass);
}
+
+ // Define defaults values for the standard ZLists
+ //
+ foreach (self::$m_aListInfos as $sListCode => $aListConfig)
+ {
+ if (!isset(self::$m_aListData[$sClass][$sListCode]))
+ {
+ $aAllAttributes = array_keys(self::$m_aAttribDefs[$sClass]);
+ self::$m_aListData[$sClass][$sListCode] = $aAllAttributes;
+ //echo "