[xoops-cvslog 3960] CVS update: xoops2jp/html/modules/user/admin/actions

Back to archive index

Minahito minah****@users*****
2006年 8月 5日 (土) 15:22:51 JST


Index: xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php
diff -u xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php:1.1.2.6 xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php:1.1.2.7
--- xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php:1.1.2.6	Wed Jul 19 19:20:53 2006
+++ xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php	Sat Aug  5 15:22:51 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package user
- * @version $Id: GroupPermAction.class.php,v 1.1.2.6 2006/07/19 10:20:53 minahito Exp $
+ * @version $Id: GroupPermAction.class.php,v 1.1.2.7 2006/08/05 06:22:51 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -42,12 +42,16 @@
 		// Reset group permission
 		//
 		$gpermHandler =& xoops_gethandler('groupperm');
-		$gpermHandler->deleteBasicPermission($this->mGroup->getVar('groupid'));
 		
-		foreach ($this->mActionForm->get('system') as $sid => $value)
-		{
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('gperm_groupid', $this->mGroup->get('groupid')));
+		$criteria->add(new Criteria('gperm_modid', 1));
+		$criteria->add(new Criteria('gperm_name', 'system_admin'));
+		$gpermHandler->deleteAll($criteria);
+
+		foreach ($this->mActionForm->get('system') as $sid => $value) {
 			$item =& new User_PermissionSystemAdminItem($sid, null);
-			$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+			$perm =& new User_Permission($this->mGroup->get('groupid'), $item);
 			
 			$perm->save();
 
@@ -60,29 +64,39 @@
 		//
 		// Store module read permission
 		//
-		foreach ($this->mActionForm->get('module') as $mid => $value)
-		{
-			$module =& $moduleHandler->get($mid);
-			if (is_object($module) && $value) {
-				$gpermHandler->addRight('module_read', $mid, $this->mGroup->getVar('groupid'));
+		$this->_loadActiveModules();
+		foreach ($this->_mActiveModules as $module)	{
+			$value = $this->mActionForm->get('module', $module->get('mid'));
+			if ($value) {
+				$gpermHandler->addRight('module_read', $module->get('mid'), $this->mGroup->get('groupid'));
+			}
+			else {
+				$gpermHandler->removeRight('module_read', $module->get('mid'), $this->mGroup->get('groupid'));
 			}
 		}
 
-		foreach ($this->mActionForm->get('module_admin') as $mid => $value)
-		{
-			$module =& $moduleHandler->get($mid);
-			if (is_object($module) && $value) {
-				$gpermHandler->addRight('module_admin', $mid, $this->mGroup->getVar('groupid'));
+		foreach ($this->_mActiveModules as $module)	{
+			$value = $this->mActionForm->get('module_admin', $module->get('mid'));
+			if ($value) {
+				$gpermHandler->addRight('module_admin', $module->get('mid'), $this->mGroup->get('groupid'));
+			}
+			else {
+				$gpermHandler->removeRight('module_admin', $module->get('mid'), $this->mGroup->get('groupid'));
 			}
 		}
 
 		$blockHandler =& xoops_gethandler('block');
 
-		foreach ($this->mActionForm->get('block') as $bid => $value)
-		{
-			$block =& $blockHandler->get($bid);
-			if (is_object($block) && $value) {
-				$gpermHandler->addRight('block_read', $bid, $this->mGroup->getVar('groupid'));
+		$this->_loadActiveBlocks();
+		foreach ($this->_mActiveBlocks as $side => $blocks) {
+			foreach ($blocks as $block) {
+				$value = $this->mActionForm->get('block', $block->get('bid'));
+				if ($value) {
+					$gpermHandler->addRight('block_read', $block->get('bid'), $this->mGroup->get('groupid'));
+				}
+				elseif (is_object($block) && !$value) {
+					$gpermHandler->removeRight('block_read', $block->get('bid'), $this->mGroup->get('groupid'));
+				}
 			}
 		}
 		
Index: xoops2jp/html/modules/user/admin/actions/GroupPropertyAction.class.php
diff -u xoops2jp/html/modules/user/admin/actions/GroupPropertyAction.class.php:1.1.2.8 xoops2jp/html/modules/user/admin/actions/GroupPropertyAction.class.php:1.1.2.9
--- xoops2jp/html/modules/user/admin/actions/GroupPropertyAction.class.php:1.1.2.8	Thu Jul 20 17:14:05 2006
+++ xoops2jp/html/modules/user/admin/actions/GroupPropertyAction.class.php	Sat Aug  5 15:22:51 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package user
- * @version $Id: GroupPropertyAction.class.php,v 1.1.2.8 2006/07/20 08:14:05 minahito Exp $
+ * @version $Id: GroupPropertyAction.class.php,v 1.1.2.9 2006/08/05 06:22:51 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -16,6 +16,11 @@
  */
 class User_GroupPropertyAction extends User_Action
 {
+	var $_mActiveModules = array();
+	var $_mActiveModulesLoadedFlag = false;
+	var $_mActiveBlocks = array();
+	var $_mActiveBlocksLoadedFlag = false;
+	
 	var $mGroup;
 	var $mPermissions;
 	var $mSystemPermissions;
@@ -74,12 +79,15 @@
 		//
 		// Get module list
 		//
-		$moduleHandler =& xoops_gethandler('module');
-		$modules =& $moduleHandler->getObjects();
-		
-		foreach ($modules as $module) {
+		$this->_loadActiveModules();
+
+		$t_activeModuleIDs = array();
+				
+		foreach ($this->_mActiveModules as $module) {
 			$item =& new User_PermissionModuleItem($module);
 			$this->mPermissions[] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+			
+			$t_activeModuleIDs[] = $module->get('mid');
 
 			unset($module);
 			unset($item);
@@ -89,17 +97,15 @@
 		// Get block list
 		//
 		$blockHandler = xoops_gethandler('block');
-		
+		$this->_loadActiveBlocks();
 		$idx = 0;
 		foreach (array(0, 1, 3, 4, 5) as $side) {
 			$this->mBlockPermissions[$idx] = array();
-			$blocks =& $blockHandler->getAllBlocks("object", $side, null);
 
-			foreach ($blocks as $block) {
+			foreach ($this->_mActiveBlocks[$side] as $block) {
 				$item =& new User_PermissionBlockItem($block);
-				$this->mBlockPermissions[$idx][] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
-
-				unset($block);
+				$this->mBlockPermissions[$idx][] =& new User_Permission($this->mGroup->get('groupid'), $item);
+				unset ($block);
 			}
 			
 			$idx++;
@@ -107,6 +113,49 @@
 
 		return USER_FRAME_VIEW_INDEX;
 	}
+	
+	function _loadActiveModules()
+	{
+		if ($this->_mActiveModulesLoadedFlag) {
+			return;
+		}
+		
+		$moduleHandler =& xoops_gethandler('module');
+		$this->_mActiveModules =& $moduleHandler->getObjects(new Criteria('isactive', 1));
+		
+		$this->_mActiveModulesLoadedFlag = true;
+	}
+	
+	function _loadActiveBlocks()
+	{
+		if ($this->_mActiveBlocksLoadedFlag) {
+			return;
+		}
+
+		$this->_loadActiveModules();
+		
+		$t_activeModuleIDs = array();
+		foreach ($this->_mActiveModules as $module) {
+			$t_activeModuleIDs[] = $module->get('mid');
+		}
+
+		$blockHandler = xoops_gethandler('block');
+		foreach (array(0, 1, 3, 4, 5) as $side) {
+			$this->_mActiveBlocks[$side] = array();
+			$blockArr =& $blockHandler->getAllBlocks("object", $side, null);
+
+			foreach ($blockArr as $block) {
+				if ($block->get('visible') && in_array($block->get('mid'), $t_activeModuleIDs)) {
+					$this->_mActiveBlocks[$side][] =& $block;
+				}
+				unset ($block);
+			}
+			
+			unset($blockArr);
+		}
+		
+		$this->_mActiveBlocksLoadedFlag = true;
+	}
 
 	function _loadGroup()
 	{


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