Minahito
minah****@users*****
2005年 12月 25日 (日) 00:03:10 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.3 xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php:1.1.2.4 --- xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php:1.1.2.3 Sat Dec 24 19:10:39 2005 +++ xoops2jp/html/modules/user/admin/actions/UserGroupPermAction.class.php Sun Dec 25 00:03:10 2005 @@ -35,6 +35,7 @@ $root =& XCube_Root::getSingleton(); $root->mLanguageManager->loadModuleAdminLanguage("system"); + $root->mLanguageManager->loadManifestoLanguage("system"); // // Get... @@ -96,6 +97,7 @@ /** * This function don't use actionform, now. + * I (minahito) must remove code-clone. */ function execute(&$controller, &$xoopsUser) { @@ -111,43 +113,70 @@ $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); + 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); - $perm->save(); + $perm->save(); - unset($perm); + 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(); + $modPerms = array(); - unset($perm); + 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); + + if (isset($_POST['module_admin']) && isset($_POST['module_admin'][$mid])) { + $value |= $_POST['module_admin'][$mid]; + } + + $modPerms[$mid]->setValue($value); + + $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); + + $modPerms[$mid]->save(); + } + } } } $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); + + 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(); + + unset($perm); + } } } @@ -169,29 +198,6 @@ $render->setAttribute("modulePermissions",$this->mPermissions); $render->setAttribute("blockPermissions",$this->mBlockPermissions); $render->setAttribute("systemPermissions",$this->mSystemPermissions); - - $moduleOptions = array ( - USER_PERMISSION_NONE => "*NONE*", - USER_PERMISSION_READ => "*READ*", - USER_PERMISSION_ADMIN => "*ADMIN*", - USER_PERMISSION_READ | USER_PERMISSION_ADMIN => "*ADMIN/READ*" - ); - - $render->setAttribute("moduleOptions", $moduleOptions); - - $blockOptions = array ( - USER_PERMISSION_NONE => "*NONE*", - USER_PERMISSION_READ => "*READ*" - ); - - $render->setAttribute("blockOptions", $blockOptions); - - $systemOptions = array ( - USER_PERMISSION_NONE => "*NONE*", - USER_PERMISSION_ADMIN => "*ADMIN*" - ); - - $render->setAttribute("systemOptions", $systemOptions); } function executeViewSuccess(&$controller,&$xoopsUser,&$render)