[xoops-cvslog 4760] CVS update: xoops2jp/html/modules/base/kernel

Back to archive index

Minahito minah****@users*****
2006年 10月 3日 (火) 18:30:38 JST


Index: xoops2jp/html/modules/base/kernel/Legacy_AdminModuleController.class.php
diff -u xoops2jp/html/modules/base/kernel/Legacy_AdminModuleController.class.php:1.1.2.5 xoops2jp/html/modules/base/kernel/Legacy_AdminModuleController.class.php:1.1.2.5.2.1
--- xoops2jp/html/modules/base/kernel/Legacy_AdminModuleController.class.php:1.1.2.5	Mon Sep 25 10:27:04 2006
+++ xoops2jp/html/modules/base/kernel/Legacy_AdminModuleController.class.php	Tue Oct  3 18:30:38 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package Legacy
- * @version $Id: Legacy_AdminModuleController.class.php,v 1.1.2.5 2006/09/25 01:27:04 nobunobu Exp $
+ * @version $Id: Legacy_AdminModuleController.class.php,v 1.1.2.5.2.1 2006/10/03 09:30:38 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -48,27 +48,32 @@
 	 */
 	function hasPermission()
 	{
-		$xoopsUser =& $this->mController->getXoopsUser();
-
-		//
-		// The guest user is never administrator.
-		//
-		if (!is_object($xoopsUser))
+		if (!is_object($this->mController->mXoopsUser)) {
 			return false;
-
-		//
-		// Decide $mid as a argument for checkRight() by current module's dirname.
-		//
-		$mid = 0;
-		if ($this->mModuleObject->get('dirname') == 'base' || $this->mModuleObject->get('dirname') == 'system') {
-			$mid = -1;
 		}
-		else {
-			$mid = $this->mModuleObject->get('mid');
+		
+		$this->_loadRole();
+		$t_prefix = 'Module.' . $this->mModuleObject->get('name');
+		
+		if (!$this->mController->mRoot->mContext->mUser->isInRole($t_prefix . '.Admin')) {
+			//
+			// Decide $mid as a argument for checkRight() by current module's dirname.
+			//
+			$mid = 0;
+			if ($this->mModuleObject->get('dirname') == 'base' || $this->mModuleObject->get('dirname') == 'system') {
+				$mid = -1;
+			}
+			else {
+				$mid = $this->mModuleObject->get('mid');
+			}
+		
+			$modPermHandler =& xoops_gethandler('groupperm');
+			return $modPermHandler->checkRight('module_admin', $mid, $this->mController->mXoopsUser->getGroups());
 		}
 		
-        $modPermHandler =& xoops_gethandler('groupperm');
-		return $modPermHandler->checkRight('module_admin', $mid, $xoopsUser->getGroups());
+		$GLOBALS['xoopsUserIsAdmin'] = true;
+		
+		return true;
 	}
 
 	/**
Index: xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php
diff -u xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.13 xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.13.2.1
--- xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.13	Mon Sep 25 18:37:07 2006
+++ xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php	Tue Oct  3 18:30:38 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package legacy
- * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.13 2006/09/25 09:37:07 minahito Exp $
+ * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.13.2.1 2006/10/03 09:30:38 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -158,20 +158,39 @@
 	 */
 	function hasPermission()
 	{
-		$xoopsUser =& $this->mController->mXoopsUser;
-		$xoopsModule=&$this->mModuleObject;
-        $modPermHandler =& xoops_gethandler('groupperm');
+		$this->_loadRole();
+		$t_prefix = 'Module.' . $this->mModuleObject->get('name');
+		
+		if (!$this->mController->mRoot->mContext->mUser->isInRole($t_prefix . '.Visitor')) {
+			return false;
+		}
+		
+		$GLOBALS['xoopsUserIsAdmin'] = $this->mController->mRoot->mContext->mUser->isInRole($t_prefix . '.Admin');
 
-		if(is_object($xoopsUser)) {
-			if (!$modPermHandler->checkRight('module_read', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
-				return false;
-			}
-			$GLOBALS['xoopsUserIsAdmin']=$xoopsUser->isAdmin($xoopsModule->getVar('mid'));
-			return true;
+		return true;
+	}
+	
+	/**
+	 * Loads permission of this module and set the information as roles to the
+	 * current user.
+	 * 
+	 * [Note] Anonymous user can't get the admin permission, even if he is
+	 * allowed to it.
+	 */
+	function _loadRole()
+	{
+		$xoopsUser =& $this->mController->mXoopsUser;
+		$module =& $this->mModuleObject;
+		
+		$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
+		
+		$handler =& xoops_gethandler('groupperm');
+		if ($handler->checkRight('module_read', $module->get('mid'), $groups)) {
+			$this->mController->mRoot->mContext->mUser->addRole('Module.' . $module->get('name') . '.Visitor');
 		}
-		else {
-			$GLOBALS['xoopsUserIsAdmin'] = false;
-			return $modPermHandler->checkRight('module_read', $xoopsModule->getVar('mid'), XOOPS_GROUP_ANONYMOUS);
+		
+		if (is_object($xoopsUser) && $handler->checkRight('module_admin', $module->get('mid'), $groups)) {
+			$this->mController->mRoot->mContext->mUser->addRole('Module.' . $module->get('name') . '.Admin');
 		}
 	}
 


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