Bläddra i källkod

Read-only mode relying successively on a DB property, and an application setting

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@972 a333f486-631f-4898-b8df-5754b55c2be0
romainq 14 år sedan
förälder
incheckning
31f302d87d
2 ändrade filer med 23 tillägg och 3 borttagningar
  1. 1 1
      core/config.class.inc.php
  2. 22 2
      core/metamodel.class.php

+ 1 - 1
core/config.class.inc.php

@@ -135,7 +135,7 @@ class Config
 			'source_of_value' => '',
 			'show_in_conf_sample' => false,
 		),
-		'read_only' => array(
+		'database_read_only' => array(
 			'type' => 'bool',
 			'description' => 'Freeze the data for administration purposes - administrators can still do anything... in appearance!',
 			'default' => false,

+ 22 - 2
core/metamodel.class.php

@@ -2536,10 +2536,30 @@ abstract class MetaModel
 		return $aDataDump;
 	}
 
-	// Temporary - investigate the cost of such a limitation
+	/*
+	* Determines wether the target DB is frozen or not
+	* 1 - consider the DB property 'status'
+	* 2 - check the setting 'database_read_only'	
+	*/		
 	public static function DBIsReadOnly()
 	{
-		return self::$m_oConfig->Get('read_only');
+		$sStatus = DBProperty::GetProperty('status', null);
+		if (!is_null($sStatus))
+		{
+			switch (strtolower(trim($sStatus)))
+			{
+			case 'fullaccess':
+				$ret = false;
+				break;
+			default:
+				$ret = true;
+			}
+		}
+		else
+		{
+			$ret = self::$m_oConfig->Get('database_read_only');
+		}
+		return $ret;
 	}
 
 	protected static function MakeDictEntry($sKey, $sValueFromOldSystem, $sDefaultValue, &$bNotInDico)