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

Back to archive index

Minahito minah****@users*****
2005年 12月 24日 (土) 19:10:39 JST


Index: xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php
diff -u xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php:1.1.2.2 xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php:1.1.2.3
--- xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php:1.1.2.2	Sat Dec 24 15:46:24 2005
+++ xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php	Sat Dec 24 19:10:39 2005
@@ -3,10 +3,15 @@
 require_once XOOPS_ROOT_PATH."/class/XCube_PageNavigator.class.php";
 require_once XOOPS_MODULE_PATH."/user/admin/class/Permission.class.php";
 
+/**
+ *
+ * This function keeps difficult problems that this depens on the column's block of X2 theme format.
+ */
 class UserGroupPermAction extends UserAction
 {
 	var $mGroup;
 	var $mPermissions;
+	var $mSystemPermissions;
 	var $mBlockPermissions;
 
 	function isSecure()
@@ -14,12 +19,9 @@
 		return true;
 	}
 
-	function getDefaultView(&$controller,&$xoopsUser)
+	function getDefaultView(&$controller, &$xoopsUser)
 	{
-		$groupId = isset($_REQUEST['groupid']) ? intval($_REQUEST['groupid']) : 0;
-
-		$groupHandler =& xoops_gethandler('group');
-		$this->mGroup =& $groupHandler->get($groupId);
+		$this->_loadGroup();
 
 		if (!is_object($this->mGroup)) {
 			return USER_FRAME_VIEW_ERROR;
@@ -31,6 +33,28 @@
 		$criteria->add(new Criteria('gperm_modid', 1));
 //		$this->mPermissions =& $gpermHandler->getObjects($criteria);
 
+		$root =& XCube_Root::getSingleton();
+		$root->mLanguageManager->loadModuleAdminLanguage("system");
+
+		//
+		// Get...
+		//
+		require_once XOOPS_ROOT_PATH . "/modules/system/constants.php";
+		$fileHandler = opendir(XOOPS_ROOT_PATH . "/modules/system/admin");
+		while ($file = readdir($fileHandler)) {
+			$infoFile = XOOPS_ROOT_PATH . "/modules/system/admin/" . $file . "/xoops_version.php";
+			if (file_exists($infoFile)) {
+				require_once $infoFile;
+				if (!empty($modversion['category'])) {
+					$item =& new User_PermissionSystemAdminItem($modversion['category'], $modversion['name']);
+					$this->mSystemPermissions[] =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+
+					unset($item);
+				}
+				unset($modversion);
+			}
+		}
+
 		//
 		// Get module list
 		//
@@ -55,7 +79,7 @@
 		$idx = 0;
 		foreach (array(0, 1, 3, 4, 5) as $side) {
 			$this->mBlockPermissions[$idx] = array();
-			$blocks =& $blockHandler->getAllBlocksByGroup($this->mGroup->getVar('groupid'), true, $side, null);
+			$blocks =& $blockHandler->getAllBlocks("object", $side, null);
 
 			foreach ($blocks as $block) {
 				$item =& new User_PermissionBlockItem($block);
@@ -70,12 +94,81 @@
 		return USER_FRAME_VIEW_INDEX;
 	}
 
+	/**
+	 * This function don't use actionform, now.
+	 */
+	function execute(&$controller, &$xoopsUser)
+	{
+		$this->_loadGroup();
+
+		if (!is_object($this->mGroup)) {
+			return USER_FRAME_VIEW_ERROR;
+		}
+
+		//
+		// Reset group permission
+		//
+		$gpermHandler =& xoops_gethandler('groupperm');
+		$gpermHandler->deleteBasicPermission($this->mGroup->getVar('groupid'));
+		
+		foreach ($_POST['system'] as $sid => $value)
+		{
+			$item =& new User_PermissionSystemAdminItem($sid, null);
+			$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+			$perm->setValue($value);
+			
+			$perm->save();
+
+			unset($perm);
+		}
+		
+		$moduleHandler =& xoops_gethandler('module');
+		foreach ($_POST['module'] as $mid => $value)
+		{
+			$module =& $moduleHandler->get($mid);
+			if (is_object($module)) {
+				$item =& new User_PermissionModuleItem($module);
+				$perm =& new User_Permission($this->mGroup->getVar('groupid'), $item);
+				$perm->setValue($value);
+			
+				$perm->save();
+
+				unset($perm);
+			}
+		}
+
+		$blockHandler =& xoops_gethandler('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();
+				
+				unset($perm);
+			}
+		}
+		
+		return USER_FRAME_VIEW_SUCCESS;
+	}
+	
+	function _loadGroup()
+	{
+		$groupId = isset($_REQUEST['groupid']) ? intval($_REQUEST['groupid']) : 0;
+
+		$groupHandler =& xoops_gethandler('group');
+		$this->mGroup =& $groupHandler->get($groupId);
+	}
+
 	function executeViewIndex(&$controller,&$xoopsUser,&$render)
 	{
 		$render->setTemplateName("group_perm.html");
 		$render->setAttribute("group",$this->mGroup);
 		$render->setAttribute("modulePermissions",$this->mPermissions);
 		$render->setAttribute("blockPermissions",$this->mBlockPermissions);
+		$render->setAttribute("systemPermissions",$this->mSystemPermissions);
 
 		$moduleOptions = array (
 		    USER_PERMISSION_NONE  => "*NONE*",
@@ -92,6 +185,18 @@
 		);
 
 		$render->setAttribute("blockOptions", $blockOptions);
+
+		$systemOptions = array (
+		    USER_PERMISSION_NONE  => "*NONE*",
+		    USER_PERMISSION_ADMIN => "*ADMIN*"
+		);
+
+		$render->setAttribute("systemOptions", $systemOptions);
+	}
+
+	function executeViewSuccess(&$controller,&$xoopsUser,&$render)
+	{
+		XCube_Utils::redirectHeader("index.php?action=GroupPerm&groupid=" . $this->mGroup->getVar('groupid'), 1, "*SUCCESS*");
 	}
 }
 


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