Browse Source

#936 Tune the default (i.e. implicit) tracking level on link sets (and disable tracking on 1-N links, for fresh installations)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3187 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 years ago
parent
commit
319e479283

+ 2 - 2
core/attributedef.class.inc.php

@@ -621,7 +621,7 @@ class AttributeLinkedSet extends AttributeDefinition
 
 	public function GetTrackingLevel()
 	{
-		return $this->GetOptional('tracking_level', LINKSET_TRACKING_LIST);
+		return $this->GetOptional('tracking_level', MetaModel::GetConfig()->Get('tracking_level_linked_set_default'));
 	}
 
 	public function GetEditMode()
@@ -919,7 +919,7 @@ class AttributeLinkedSetIndirect extends AttributeLinkedSet
 
 	public function GetTrackingLevel()
 	{
-		return $this->GetOptional('tracking_level', LINKSET_TRACKING_ALL);
+		return $this->GetOptional('tracking_level', MetaModel::GetConfig()->Get('tracking_level_linked_set_indirect_default'));
 	}
 }
 

+ 17 - 0
core/config.class.inc.php

@@ -35,6 +35,7 @@ define('ACCESS_READONLY', 0);
  */
 
 require_once('coreexception.class.inc.php');
+require_once('attributedef.class.inc.php'); // For the defines
 
 class ConfigException extends CoreException
 {
@@ -735,6 +736,22 @@ class Config
 			'source_of_value' => '',
 			'show_in_conf_sample' => false,
 		),
+		'tracking_level_linked_set_default' => array(
+			'type' => 'integer',
+			'description' => 'Default tracking level if not explicitely set at the attribute level, for AttributeLinkedSet (defaults to NONE in case of a fresh install, LIST otherwise - this to preserve backward compatibility while upgrading from a version older than 2.0.3 - see TRAC #936)',
+			'default' => LINKSET_TRACKING_LIST,
+			'value' => LINKSET_TRACKING_LIST,
+			'source_of_value' => '',
+			'show_in_conf_sample' => false,
+		),
+		'tracking_level_linked_set_indirect_default' => array(
+			'type' => 'integer',
+			'description' => 'Default tracking level if not explicitely set at the attribute level, for AttributeLinkedSetIndirect',
+			'default' => LINKSET_TRACKING_ALL,
+			'value' => LINKSET_TRACKING_ALL,
+			'source_of_value' => '',
+			'show_in_conf_sample' => false, 
+		),
 	);
 
 	public function IsProperty($sPropCode)

+ 3 - 0
setup/applicationinstaller.class.inc.php

@@ -883,6 +883,9 @@ class ApplicationInstaller
 		else
 		{
 			$oConfig = new Config();
+			// To preserve backward compatibility while upgrading to 2.0.3 (when tracking_level_linked_set_default has been introduced)
+			// the default value on upgrade differs from the default value at first install
+			$oConfig->Set('tracking_level_linked_set_default', LINKSET_TRACKING_NONE, 'first_install');
 		}