[xoops-cvslog 5462] CVS update: xoops2jp/html/modules/legacy/kernel

Back to archive index

Minahito minah****@users*****
2006年 10月 23日 (月) 18:36:27 JST


Index: xoops2jp/html/modules/legacy/kernel/Legacy_Controller.class.php
diff -u xoops2jp/html/modules/legacy/kernel/Legacy_Controller.class.php:1.1.2.7 xoops2jp/html/modules/legacy/kernel/Legacy_Controller.class.php:1.1.2.8
--- xoops2jp/html/modules/legacy/kernel/Legacy_Controller.class.php:1.1.2.7	Sat Oct 21 20:34:44 2006
+++ xoops2jp/html/modules/legacy/kernel/Legacy_Controller.class.php	Mon Oct 23 18:36:27 2006
@@ -85,6 +85,12 @@
 	var $mSetupDebugger = null;
 	
 	/**
+	 * @var XCube_Delegate
+	 */
+	
+	var $mIsAdmin = null;
+	
+	/**
 	 * @var XoopsLogger
 	 */
 	var $mLogger = null;
@@ -118,6 +124,9 @@
 		
 		$this->mSetupDebugger =& new XCube_Delegate();
 		$this->mSetupDebugger->add('Legacy_DebuggerManager::createInstance');
+		
+		$this->mIsAdmin =& new XCube_Delegate();
+		$this->mIsAdmin->add(array(&$this, '_isAdmin'));
 
 		set_magic_quotes_runtime(0);	// ^^;
 	}
@@ -129,21 +138,11 @@
 		//
 		// Decide status. [TEST]
 		//
-		$urlInfo=$this->_parseUrl();
-		$adminStateFlag=false;
-
-		if(count($urlInfo)>=3) {
-			if(strtolower($urlInfo[0])=="modules" && strtolower($urlInfo[2])=="admin"){
-				$adminStateFlag=true;
-			}
-			elseif($urlInfo[0] == "modules" && $urlInfo[1] == "system" && substr($urlInfo[2], 0, 9) == "admin.php") {
-				$adminStateFlag=true;
-			}
-		}
-		elseif(substr($urlInfo[0], 0, 9) == "admin.php") {
-			$adminStateFlag=true;
-		}
+		$urlInfo = $this->_parseUrl();
+		$adminStateFlag = null;
 		
+		$this->mIsAdmin->call(new XCube_Ref($adminStateFlag), $urlInfo);
+
 		if ($adminStateFlag) {
 			require_once XOOPS_ROOT_PATH . "/modules/legacy/kernel/Legacy_AdminControllerStrategy.class.php";
 			$this->_mStrategy =& new Legacy_AdminControllerStrategy($this);
@@ -152,6 +151,28 @@
 			$this->_mStrategy =& new Legacy_PublicControllerStrategy($this);
 		}
 	}
+	
+	function _isAdmin(&$flag, $urlInfo)
+	{
+		if ($flag !== null) {
+			return;
+		}
+		
+		if (count($urlInfo) >= 3) {
+			if (strtolower($urlInfo[0]) == "modules" && strtolower($urlInfo[2]) == "admin"){
+				$flag = true;
+			}
+			elseif ($urlInfo[0] == "modules" && $urlInfo[1] == "legacy" && $urlInfo[2] == "include") {
+				$flag = true;
+			}
+			elseif ($urlInfo[0] == "modules" && $urlInfo[1] == "system" && substr($urlInfo[2], 0, 9) == "admin.php") {
+				$flag = true;
+			}
+		}
+		elseif (substr($urlInfo[0], 0, 9) == "admin.php") {
+			$flag = true;
+		}
+	}
 
 	/**
 	 * @access public
@@ -385,13 +406,15 @@
 				 * Notify that the current user accesses none-activate module
 				 * controller.
 				 */
-				XCube_DelegateUtils::call('Legacy.Event.ModuleNotActive');
-				$this->executeForward(XOOPS_URL);
+				XCube_DelegateUtils::call('Legacy.Event.Exception.ModuleNotActive', $module);
+				$this->executeForward(XOOPS_URL . '/');
 				die();
 			}
 			
 			if (!$this->_mStrategy->enableAccess()) {
+				XCube_DelegateUtils::call('Legacy.Event.Exception.ModuleSecurity', $module);
 				$this->executeRedirect(XOOPS_URL . '/',1,_NOPERM);	// TODO Depens on const message catalog.
+				die();
 			}
 			
 			$this->_mStrategy->setupModuleLanguage();
@@ -888,7 +911,7 @@
 			}
 		}
 		else {
-			$this->executeForward(XOOPS_URL);
+			$this->executeForward(XOOPS_URL . '/');
 		}
 	}
 	
@@ -916,7 +939,7 @@
 			}
 		}
 		else {
-			$this->executeForward(XOOPS_URL);
+			$this->executeForward(XOOPS_URL . '/');
 		}
 	}
 
@@ -947,7 +970,7 @@
 			// But, There is no other method.
 			//
 			$this->setupModuleContext();
-			$this->_processModuleController();
+			$this->_processModule();
 		}
 	}
 
@@ -1215,6 +1238,10 @@
 
 	/**
 	 * Create some instances for the module process.
+	 * Because Legacy_ModuleContext needs XoopsModule instance, this function
+	 * kills the process if XoopsModule instance can't be found. Plus, in the
+	 * case, raises 'Legacy.Event.Exception.XoopsModuleNotFound'.
+	 * 
 	 * @param Legacy_HttpContext $context
 	 * @param string $dirname
 	 */	
@@ -1224,7 +1251,9 @@
 		$module =& $handler->getByDirname($dirname);
 
 		if (!is_object($module)) {
-			return;
+			XCube_DelegateUtils::call('Legacy.Event.Exception.XoopsModuleNotFound', $dirname);
+			$this->mController->executeRedirect(XOOPS_URL . '/', 1, "You can't access this URL.");	// TODO need message catalog.
+			die();
 		}
 		
 		$context->mModule =& Legacy_Utils::createModule($module);


xoops-cvslog メーリングリストの案内
Back to archive index