Преглед изворни кода

- Properly deactivate the creation of 1:n links while creating an object, since it is not possible to create such links at this time.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@793 a333f486-631f-4898-b8df-5754b55c2be0
dflaven пре 14 година
родитељ
комит
770eadc43e

+ 27 - 20
application/cmdbabstract.class.inc.php

@@ -162,30 +162,37 @@ abstract class cmdbAbstractObject extends CMDBObject
 				{
 					// 1:n links
 					$sTargetClass = $oAttDef->GetLinkedClass();
-					$oPage->p(MetaModel::GetClassIcon($sTargetClass)." ".$oAttDef->GetDescription());
-
-					$oFilter = new DBObjectSearch($sTargetClass);
-					$oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey(),'=');
-
-					$aDefaults = array($oAttDef->GetExtKeyToMe() => $this->GetKey());
-					$oAppContext = new ApplicationContext();
-					foreach($oAppContext->GetNames() as $sKey)
+					if ($this->IsNew())
 					{
-						// The linked object inherits the parent's value for the context
-						if (MetaModel::IsValidAttCode($sClass, $sKey))
+						$oPage->p(Dict::Format('UI:BeforeAdding_Class_ObjectsSaveThisObject', MetaModel::GetName($sTargetClass)));
+					}
+					else
+					{
+						$oPage->p(MetaModel::GetClassIcon($sTargetClass)." ".$oAttDef->GetDescription());
+	
+						$oFilter = new DBObjectSearch($sTargetClass);
+						$oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey(),'=');
+	
+						$aDefaults = array($oAttDef->GetExtKeyToMe() => $this->GetKey());
+						$oAppContext = new ApplicationContext();
+						foreach($oAppContext->GetNames() as $sKey)
 						{
-							$aDefaults[$sKey] = $this->Get($sKey);
+							// The linked object inherits the parent's value for the context
+							if (MetaModel::IsValidAttCode($sClass, $sKey))
+							{
+								$aDefaults[$sKey] = $this->Get($sKey);
+							}
 						}
+						$aParams = array(
+							'target_attr' => $oAttDef->GetExtKeyToMe(),
+							'object_id' => $this->GetKey(),
+							'menu' => true,
+							'default' => $aDefaults,
+							);
+	
+						$oBlock = new DisplayBlock($oFilter, 'list', false);
+						$oBlock->Display($oPage, $sInputId, $aParams);
 					}
-					$aParams = array(
-						'target_attr' => $oAttDef->GetExtKeyToMe(),
-						'object_id' => $this->GetKey(),
-						'menu' => true,
-						'default' => $aDefaults,
-						);
-
-					$oBlock = new DisplayBlock($oFilter, 'list', false);
-					$oBlock->Display($oPage, $sInputId, $aParams);
 				}
 				else // get_class($oAttDef) == 'AttributeLinkedSetIndirect'
 				{

+ 1 - 0
dictionaries/dictionary.itop.ui.php

@@ -823,6 +823,7 @@ When associated with a trigger, each action is given an "order" number, specifyi
 	'UI:Deadline_Days_Hours_Minutes' => '%1$dd %2$dh %3$dmin',
 	'UI:Help' => 'Help',
 	'UI:PasswordConfirm' => '(Confirm)',
+	'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Before adding more %1$s objects, save this object.',
 ));
 
 

+ 1 - 0
dictionaries/fr.dictionary.itop.ui.php

@@ -834,6 +834,7 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
 	'UI:Deadline_Days_Hours_Minutes' => '%1$dj %2$dh %3$dmin',
 	'UI:Help' => 'Aide',
 	'UI:PasswordConfirm' => '(Confirmer)',
+	'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Enregistrez l\'objet courant avant de créer de nouveaux éléments de type %1$s.',
 ));
 
 ?>