XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
GroupPropertyAction.class.php
1<?php
6
7if (!defined('XOOPS_ROOT_PATH')) {
8 exit();
9}
10
11require_once XOOPS_ROOT_PATH . '/core/XCube_PageNavigator.class.php';
12require_once XOOPS_MODULE_PATH . '/user/admin/class/Permission.class.php';
13
14/***
15 * @internal
16 * This function keeps difficult problems that this depens on the column's
17 * block of X2 theme format.
18 */
19class User_GroupPropertyAction extends User_Action
20{
21 public $_mActiveModules = [];
22 public $_mActiveModulesLoadedFlag = false;
23 public $_mActiveBlocks = [];
24 public $_mActiveBlocksLoadedFlag = false;
25
26 public $mGroup;
27 public $mPermissions;
28 public $mSystemPermissions;
29 public $mBlockPermissions;
30
31 public $mUsers;
32 public $mPageNavi;
33
34 public function getDefaultView(&$controller, &$xoopsUser)
35 {
36 $modversion = [];
37 $this->_loadGroup();
38
39 if (!is_object($this->mGroup)) {
40 return USER_FRAME_VIEW_ERROR;
41 }
42
43 $root =& XCube_Root::getSingleton();
44 $root->mLanguageManager->loadModuleAdminMessageCatalog('system');
45 $root->mLanguageManager->loadModinfoMessageCatalog('system');
46
47 //
48 // Get member list
49 //
50 $memberHandler =& xoops_gethandler('member');
51
52 $total = $memberHandler->getUserCountByGroup($this->mGroup->getVar('groupid'));
53 $this->mPageNavi =new XCube_PageNavigator('./index.php?action=GroupProperty', XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE); // TODO get controller->getUrl() ?
54 $this->mPageNavi->setTotalItems($total);
55 $this->mPageNavi->addExtra('groupid', $this->mGroup->get('groupid'));
56
57 $this->mPageNavi->fetch();
58
59 $this->mUsers =& $memberHandler->getUsersByGroup($this->mGroup->getVar('groupid'), true, $this->mPageNavi->getPerPage(), $this->mPageNavi->getStart());
60
61 $moduleHandler =& xoops_gethandler('module');
62 //
63 // Get...
64 //
65 if (file_exists(XOOPS_ROOT_PATH . '/modules/system/constants.php')) {
66 if ($moduleHandler->getByDirname('system')) {
67 require_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
68 $fileHandler = opendir(XOOPS_ROOT_PATH . '/modules/system/admin');
69 while ($file = readdir($fileHandler)) {
70 $infoFile = XOOPS_ROOT_PATH . '/modules/system/admin/' . $file . '/xoops_version.php';
71 if (file_exists($infoFile)) {
72 require_once $infoFile;
73 if (!empty($modversion['category'])) {
74 $item =new User_PermissionSystemAdminItem($modversion['category'], $modversion['name']);
75 $this->mSystemPermissions[] =new User_Permission($this->mGroup->getVar('groupid'), $item);
76
77 unset($item);
78 }
79 unset($modversion);
80 }
81 }
82 }
83 }
84 //
85 // Get module list
86 //
87 $this->_loadActiveModules();
88
89 $t_activeModuleIDs = [];
90
91 foreach ($this->_mActiveModules as $module) {
92 $item =new User_PermissionModuleItem($module);
93 $this->mPermissions[] =new User_Permission($this->mGroup->getVar('groupid'), $item);
94
95 $t_activeModuleIDs[] = $module->get('mid');
96
97 unset($module);
98 unset($item);
99 }
100
101 //
102 // Get block list
103 //
104 $blockHandler = xoops_gethandler('block');
105 $this->_loadActiveBlocks();
106 $idx = 0;
107 foreach ([0, 1, 3, 4, 5] as $side) {
108 $this->mBlockPermissions[$idx] = [];
109
110 foreach ($this->_mActiveBlocks[$side] as $block) {
111 $item =new User_PermissionBlockItem($block);
112 $this->mBlockPermissions[$idx][] =new User_Permission($this->mGroup->get('groupid'), $item);
113 unset($item);
114 unset($block);
115 }
116
117 $idx++;
118 }
119
120 return USER_FRAME_VIEW_INDEX;
121 }
122
123 public function _loadActiveModules()
124 {
125 if ($this->_mActiveModulesLoadedFlag) {
126 return;
127 }
128
129 $moduleHandler =& xoops_gethandler('module');
130 $this->_mActiveModules =& $moduleHandler->getObjects(new Criteria('isactive', 1));
131
132 $this->_mActiveModulesLoadedFlag = true;
133 }
134
135 public function _loadActiveBlocks()
136 {
137 if ($this->_mActiveBlocksLoadedFlag) {
138 return;
139 }
140
141 $this->_loadActiveModules();
142
143 $t_activeModuleIDs = [];
144 foreach ($this->_mActiveModules as $module) {
145 $t_activeModuleIDs[] = $module->get('mid');
146 }
147 $t_activeModuleIDs[] = 0;
148
149 $blockHandler = xoops_gethandler('block');
150 foreach ([0, 1, 3, 4, 5] as $side) {
151 $this->_mActiveBlocks[$side] = [];
152 $blockArr =& $blockHandler->getAllBlocks('object', $side, null);
153
154 foreach ($blockArr as $block) {
155 if ($block->get('visible') && in_array($block->get('mid'), $t_activeModuleIDs)) {
156 $this->_mActiveBlocks[$side][] =& $block;
157 }
158 unset($block);
159 }
160
161 unset($blockArr);
162 }
163
164 $this->_mActiveBlocksLoadedFlag = true;
165 }
166
167 public function _loadGroup()
168 {
169 $id = xoops_getrequest('groupid');
170
171 $handler =& xoops_getmodulehandler('groups');
172 $this->mGroup =& $handler->get($id);
173 }
174
175 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
176 {
177 $render->setTemplateName('group_property.html');
178 $render->setAttribute('group', $this->mGroup);
179 $render->setAttribute('modulePermissions', $this->mPermissions);
180 $render->setAttribute('blockPermissions', $this->mBlockPermissions);
181 $render->setAttribute('systemPermissions', $this->mSystemPermissions);
182 $render->setAttribute('users', $this->mUsers);
183 $render->setAttribute('pageNavi', $this->mPageNavi);
184 }
185}