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

N890.3 Archive mode toggle menu not visible after setup/MTP: the information is cached into the session and needs to be reset

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4870 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 8 година
родитељ
комит
72561298dc

+ 4 - 1
application/utils.inc.php

@@ -155,7 +155,10 @@ class utils
 		}
 		// Read and record the value for switching the archive mode
 		$iCurrent = self::ReadParam('with-archive', $iDefault);
-		$_SESSION['archive_mode'] = $iCurrent;
+		if (isset($_SESSION))
+		{
+			$_SESSION['archive_mode'] = $iCurrent;
+		}
 		// Read and use the value for the current page (web services)
 		$iCurrent = self::ReadParam('with_archive', $iCurrent, true);
 		self::$bPageMode = ($iCurrent == 1);

+ 10 - 4
core/metamodel.class.php

@@ -5261,20 +5261,26 @@ abstract class MetaModel
 
 	public static function ResetCache($sEnvironmentId = null)
 	{
-		if (!function_exists('apc_delete')) return;
 		if (is_null($sEnvironmentId))
 		{
 			$sEnvironmentId = MetaModel::GetEnvironmentId();
 		}
 
 		$sAppIdentity = 'itop-'.$sEnvironmentId;
+		require_once(APPROOT.'/core/dict.class.inc.php');
 		Dict::ResetCache($sAppIdentity);
 
-		foreach(self::GetCacheEntries($sEnvironmentId) as $sKey => $aAPCInfo)
+		if (function_exists('apc_delete'))
 		{
-			$sAPCKey = $aAPCInfo['info'];
-			apc_delete($sAPCKey);
+			foreach (self::GetCacheEntries($sEnvironmentId) as $sKey => $aAPCInfo)
+			{
+				$sAPCKey = $aAPCInfo['info'];
+				apc_delete($sAPCKey);
+			}
 		}
+
+		require_once(APPROOT.'core/userrights.class.inc.php');
+		UserRights::FlushPrivileges();
 	}
 	
 	/**

+ 9 - 1
core/userrights.class.inc.php

@@ -1152,8 +1152,16 @@ class UserRights
 			self::$m_aAdmins = array();
 			self::$m_aPortalUsers = array();
 		}
+		if (!isset($_SESSION))
+		{
+			session_name('itop-'.md5(APPROOT));
+			session_start();
+		}
 		self::_ResetSessionCache();
-		return self::$m_oAddOn->FlushPrivileges();
+		if (self::$m_oAddOn)
+		{
+			self::$m_oAddOn->FlushPrivileges();
+		}
 	}
 
 	static $m_aCacheUsers;

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

@@ -505,7 +505,6 @@ class RunTimeEnvironment
 			SetupUtils::builddir($sCacheDir);
 			SetupUtils::tidydir($sCacheDir);
 
-			require_once(APPROOT.'/core/dict.class.inc.php');
 			MetaModel::ResetCache(md5(APPROOT).'-'.$this->sTargetEnv);
 		}
 	}