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

Back to archive index

Minahito minah****@users*****
2006年 2月 4日 (土) 17:37:42 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.2 xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php:1.1.2.3
--- xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php:1.1.2.2	Fri Feb  3 15:05:06 2006
+++ xoops2jp/html/modules/user/admin/actions/GroupPermAction.class.php	Sat Feb  4 17:37:41 2006
@@ -1,6 +1,7 @@
 <?php
 
 require_once XOOPS_MODULE_PATH."/user/admin/actions/GroupPropertyAction.class.php";
+require_once XOOPS_MODULE_PATH."/user/admin/forms/GroupPermEditForm.class.php";
 
 /**
  *
@@ -8,6 +9,14 @@
  */
 class User_GroupPermAction extends User_GroupPropertyAction
 {
+	var $mActionForm = null;
+	
+	function prepare(&$controller, &$xoopsUser, &$moduleConfig)
+	{
+		$this->mActionForm =& new User_GroupPermEditForm();
+		$this->mActionForm->prepare();
+	}
+	
 	/**
 	 * This function don't use actionform, now.
 	 * I (minahito) must remove code-clone.
@@ -15,81 +24,80 @@
 	function execute(&$controller, &$xoopsUser)
 	{
 		$this->_loadGroup();
-
+		
 		if (!is_object($this->mGroup)) {
 			return USER_FRAME_VIEW_ERROR;
 		}
-
+		
+		$this->mActionForm->fetch();
+		$this->mActionForm->validate();
+		
+		if ($this->mActionForm->hasError()) {
+			return $this->getDefaultView($controller, $xoopsUser);
+		}
+		
 		//
 		// Reset group permission
 		//
 		$gpermHandler =& xoops_gethandler('groupperm');
 		$gpermHandler->deleteBasicPermission($this->mGroup->getVar('groupid'));
 		
-		if (isset($_POST['system']) && is_array($_POST['system'])) {
-			foreach ($_POST['system'] as $sid => $value)
-			{
-				$item =& new User_PermissionSystemAdminItem($sid, null);
-				$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+		foreach ($this->mActionForm->get('system') as $sid => $value)
+		{
+			$item =& new User_PermissionSystemAdminItem($sid, null);
+			$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
 			
-				$perm->save();
+			$perm->save();
 
-				unset($perm);
-			}
+			unset($perm);
 		}
 		
 		$moduleHandler =& xoops_gethandler('module');
 		$modPerms = array();
 
-		if (isset($_POST['module']) && is_array($_POST['module'])) {
-			foreach ($_POST['module'] as $mid => $value)
-			{
-				$module =& $moduleHandler->get($mid);
-				if (is_object($module)) {
-					$item =& new User_PermissionModuleItem($module);
-					$modPerms[$mid] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+		foreach ($this->mActionForm->get('module') as $mid => $value)
+		{
+			$module =& $moduleHandler->get($mid);
+			if (is_object($module)) {
+				$item =& new User_PermissionModuleItem($module);
+				$modPerms[$mid] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
 
-					if (isset($_POST['module_admin']) && isset($_POST['module_admin'][$mid])) {
-						$value |= $_POST['module_admin'][$mid];
-					}
+				if (isset($_POST['module_admin']) && isset($_POST['module_admin'][$mid])) {
+					$value |= $_POST['module_admin'][$mid];
+				}
 
-					$modPerms[$mid]->setValue($value);
+				$modPerms[$mid]->setValue($value);
 					
-					$modPerms[$mid]->save();
-				}
+				$modPerms[$mid]->save();
 			}
 		}
 
-		if (isset($_POST['module_admin']) && is_array($_POST['module_admin'])) {
-			foreach ($_POST['module_admin'] as $mid => $value)
-			{
-				$module =& $moduleHandler->get($mid);
-				if (is_object($module)) {
-					if (!isset($modPerms[$mid])) {
-						$item =& new User_PermissionModuleItem($module);
-						$modPerms[$mid] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
-						$modPerms[$mid]->setValue($value);
+		foreach ($this->mActionForm->get('module_admin') as $mid => $value)
+		{
+			$module =& $moduleHandler->get($mid);
+			if (is_object($module)) {
+				if (!isset($modPerms[$mid])) {
+					$item =& new User_PermissionModuleItem($module);
+					$modPerms[$mid] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+					$modPerms[$mid]->setValue($value);
 
-						$modPerms[$mid]->save();
-					}
+					$modPerms[$mid]->save();
 				}
 			}
 		}
 
 		$blockHandler =& xoops_gethandler('block');
 
-		if (isset($_POST['block']) && is_array($_POST['block'])) {
-			foreach ($_POST['block'] as $bid => $value)
-			{
-				$block =& $blockHandler->get($bid);
-				if (is_object($block)) {
-					$item =& new User_PermissionBlockItem($block);
-					$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
-					$perm->setValue($value);
-					$perm->save();
+		foreach ($this->mActionForm->get('block') as $bid => $value)
+		{
+			$block =& $blockHandler->get($bid);
+			if (is_object($block)) {
+				$item =& new User_PermissionBlockItem($block);
+				$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+				$perm->setValue($value);
+				$perm->save();
 					
-					unset($perm);
-				}
+				unset($perm);
 			}
 		}
 		
@@ -100,6 +108,7 @@
 	{
 		$render->setTemplateName("group_perm.html");
 		$render->setAttribute("group",$this->mGroup);
+		$render->setAttribute("actionForm",$this->mActionForm);
 		$render->setAttribute("modulePermissions",$this->mPermissions);
 		$render->setAttribute("blockPermissions",$this->mBlockPermissions);
 		$render->setAttribute("systemPermissions",$this->mSystemPermissions);
@@ -107,7 +116,7 @@
 
 	function executeViewSuccess(&$controller,&$xoopsUser,&$render)
 	{
-		$controller->executeForward("index.php?action=GroupPerm&amp;groupid=" . $this->mGroup->getVar('groupid'));
+		$controller->executeForward("index.php?action=GroupPerm&groupid=" . $this->mGroup->getVar('groupid'));
 	}
 }
 


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