Преглед на файлове

Predefined objects are now handled by RuntimeEnvironment

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3418 a333f486-631f-4898-b8df-5754b55c2be0
dflaven преди 10 години
родител
ревизия
4e399176ee
променени са 2 файла, в които са добавени 54 реда и са изтрити 46 реда
  1. 1 46
      setup/applicationinstaller.class.inc.php
  2. 53 0
      setup/runtimeenv.class.inc.php

+ 1 - 46
setup/applicationinstaller.class.inc.php

@@ -742,52 +742,7 @@ class ApplicationInstaller
 			}
 		}
 
-		// Constant classes (e.g. User profiles)
-		//
-		foreach (MetaModel::GetClasses() as $sClass)
-		{
-			$aPredefinedObjects = call_user_func(array($sClass, 'GetPredefinedObjects'));
-			if ($aPredefinedObjects != null)
-			{
-				SetupPage::log_info("$sClass::GetPredefinedObjects() returned ".count($aPredefinedObjects)." elements.");
-
-				// Create/Delete/Update objects of this class,
-				// according to the given constant values
-				//
-				$aDBIds = array();
-				$oAll = new DBObjectSet(new DBObjectSearch($sClass));
-				while ($oObj = $oAll->Fetch())
-				{
-					if (array_key_exists($oObj->GetKey(), $aPredefinedObjects))
-					{
-						$aObjValues = $aPredefinedObjects[$oObj->GetKey()];
-						foreach ($aObjValues as $sAttCode => $value)
-						{
-							$oObj->Set($sAttCode, $value);
-						}
-						$oObj->DBUpdate();
-						$aDBIds[$oObj->GetKey()] = true;
-					}
-					else
-					{
-						$oObj->DBDelete();
-					}
-				}
-				foreach ($aPredefinedObjects as $iRefId => $aObjValues)
-				{
-					if (!array_key_exists($iRefId, $aDBIds))
-					{
-						$oNewObj = MetaModel::NewObject($sClass);
-						$oNewObj->SetKey($iRefId);
-						foreach ($aObjValues as $sAttCode => $value)
-						{
-							$oNewObj->Set($sAttCode, $value);
-						}
-						$oNewObj->DBInsert();
-					}
-				}
-			}
-		}
+		$oProductionEnv->UpdatePredefinedObjects();
 		
 		if($sMode == 'install')
 		{

+ 53 - 0
setup/runtimeenv.class.inc.php

@@ -458,6 +458,59 @@ class RunTimeEnvironment
 			}
 		}
 		return true;
+	}
+
+	public function UpdatePredefinedObjects()
+	{
+		// Constant classes (e.g. User profiles)
+		//
+		foreach (MetaModel::GetClasses() as $sClass)
+		{
+			$aPredefinedObjects = call_user_func(array(
+				$sClass,
+				'GetPredefinedObjects'
+			));
+			if ($aPredefinedObjects != null)
+			{
+				$this->log_info("$sClass::GetPredefinedObjects() returned " . count($aPredefinedObjects) . " elements.");
+				
+				// Create/Delete/Update objects of this class,
+				// according to the given constant values
+				//
+				$aDBIds = array();
+				$oAll = new DBObjectSet(new DBObjectSearch($sClass));
+				while ($oObj = $oAll->Fetch())
+				{
+					if (array_key_exists($oObj->GetKey(), $aPredefinedObjects))
+					{
+						$aObjValues = $aPredefinedObjects[$oObj->GetKey()];
+						foreach ($aObjValues as $sAttCode => $value)
+						{
+							$oObj->Set($sAttCode, $value);
+						}
+						$oObj->DBUpdate();
+						$aDBIds[$oObj->GetKey()] = true;
+					}
+					else
+					{
+						$oObj->DBDelete();
+					}
+				}
+				foreach ($aPredefinedObjects as $iRefId => $aObjValues)
+				{
+					if (! array_key_exists($iRefId, $aDBIds))
+					{
+						$oNewObj = MetaModel::NewObject($sClass);
+						$oNewObj->SetKey($iRefId);
+						foreach ($aObjValues as $sAttCode => $value)
+						{
+							$oNewObj->Set($sAttCode, $value);
+						}
+						$oNewObj->DBInsert();
+					}
+				}
+			}
+		}
 	}
 	
 	public function RecordInstallation(Config $oConfig, $sDataModelVersion, $aSelectedModules, $sModulesRelativePath)