1: <?php
2: 3: 4: 5:
6:
7: if (!defined('XOOPS_ROOT_PATH')) exit();
8:
9: require_once XOOPS_MODULE_PATH."/user/admin/actions/GroupPropertyAction.class.php";
10: require_once XOOPS_MODULE_PATH."/user/admin/forms/GroupPermEditForm.class.php";
11:
12: 13: 14: 15: 16:
17: class User_GroupPermAction extends User_GroupPropertyAction
18: {
19: var $mActionForm = null;
20:
21: function prepare(&$controller, &$xoopsUser, &$moduleConfig)
22: {
23: $this->mActionForm =new User_GroupPermEditForm();
24: $this->mActionForm->prepare();
25: }
26:
27: function execute(&$controller, &$xoopsUser)
28: {
29: $this->_loadGroup();
30:
31: if (!is_object($this->mGroup)) {
32: return USER_FRAME_VIEW_ERROR;
33: }
34:
35: $this->mActionForm->fetch();
36: $this->mActionForm->validate();
37:
38: if ($this->mActionForm->hasError()) {
39: return $this->getDefaultView($controller, $xoopsUser);
40: }
41:
42:
43:
44:
45: $gpermHandler =& xoops_gethandler('groupperm');
46:
47: $criteria =new CriteriaCompo();
48: $criteria->add(new Criteria('gperm_groupid', $this->mGroup->get('groupid')));
49: $criteria->add(new Criteria('gperm_modid', 1));
50: $criteria->add(new Criteria('gperm_name', 'system_admin'));
51: $gpermHandler->deleteAll($criteria);
52:
53: foreach ($this->mActionForm->get('system') as $sid => $value) {
54: $item =new User_PermissionSystemAdminItem($sid, null);
55: $perm =new User_Permission($this->mGroup->get('groupid'), $item);
56:
57: $perm->save();
58:
59: unset($item);
60: unset($perm);
61: }
62:
63: $moduleHandler =& xoops_gethandler('module');
64: $modPerms = array();
65:
66:
67:
68:
69: $this->_loadActiveModules();
70: foreach ($this->_mActiveModules as $module) {
71: $value = $this->mActionForm->get('module', $module->get('mid'));
72: if ($value) {
73: $gpermHandler->addRight('module_read', $module->get('mid'), $this->mGroup->get('groupid'));
74: }
75: else {
76: $gpermHandler->removeRight('module_read', $module->get('mid'), $this->mGroup->get('groupid'));
77: }
78: }
79:
80: foreach ($this->_mActiveModules as $module) {
81: $value = $this->mActionForm->get('module_admin', $module->get('mid'));
82: if ($value) {
83: $gpermHandler->addRight('module_admin', $module->get('mid'), $this->mGroup->get('groupid'));
84: }
85: else {
86: $gpermHandler->removeRight('module_admin', $module->get('mid'), $this->mGroup->get('groupid'));
87: }
88: }
89:
90: $blockHandler =& xoops_gethandler('block');
91:
92: $this->_loadActiveBlocks();
93: foreach ($this->_mActiveBlocks as $side => $blocks) {
94: foreach ($blocks as $block) {
95: $value = $this->mActionForm->get('block', $block->get('bid'));
96: if ($value) {
97: $gpermHandler->addRight('block_read', $block->get('bid'), $this->mGroup->get('groupid'));
98: }
99: elseif (is_object($block) && !$value) {
100: $gpermHandler->removeRight('block_read', $block->get('bid'), $this->mGroup->get('groupid'));
101: }
102: }
103: }
104:
105: return USER_FRAME_VIEW_SUCCESS;
106: }
107:
108: function executeViewIndex(&$controller,&$xoopsUser,&$render)
109: {
110: $render->setTemplateName("group_perm.html");
111: $render->setAttribute("group", $this->mGroup);
112: $render->setAttribute("actionForm", $this->mActionForm);
113: $render->setAttribute("modulePermissions", $this->mPermissions);
114: $render->setAttribute("blockPermissions", $this->mBlockPermissions);
115: $render->setAttribute("systemPermissions", $this->mSystemPermissions);
116: }
117:
118: function executeViewSuccess(&$controller,&$xoopsUser,&$render)
119: {
120: $controller->executeForward("index.php?action=GroupPerm&groupid=" . $this->mGroup->getVar('groupid'));
121: }
122: }
123:
124: ?>
125: