Total Complexity | 38 |
Total Lines | 360 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class GroupsController extends BaseController |
||
17 | { |
||
18 | public $controller_name = 'GroupsController'; |
||
19 | |||
20 | /** |
||
21 | * Default method to render the controller according to the action parameter. |
||
22 | */ |
||
23 | public function render() |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Show default list of groups in the database. |
||
92 | * |
||
93 | * @param mixed $msg |
||
94 | */ |
||
95 | public function doDefault($msg = '') |
||
96 | { |
||
97 | $data = $this->misc->getDatabaseAccessor(); |
||
98 | |||
99 | $this->printTrail('server'); |
||
100 | $this->printTabs('server', 'groups'); |
||
101 | $this->printMsg($msg); |
||
102 | |||
103 | $groups = $data->getGroups(); |
||
104 | |||
105 | $columns = [ |
||
106 | 'group' => [ |
||
107 | 'title' => $this->lang['strgroup'], |
||
108 | 'field' => Decorator::field('groname'), |
||
109 | 'url' => "groups?action=properties&{$this->misc->href}&", |
||
110 | 'vars' => ['group' => 'groname'], |
||
111 | ], |
||
112 | 'actions' => [ |
||
113 | 'title' => $this->lang['stractions'], |
||
114 | ], |
||
115 | ]; |
||
116 | |||
117 | $actions = [ |
||
118 | 'drop' => [ |
||
119 | 'content' => $this->lang['strdrop'], |
||
120 | 'attr' => [ |
||
121 | 'href' => [ |
||
122 | 'url' => 'groups', |
||
123 | 'urlvars' => [ |
||
124 | 'action' => 'confirm_drop', |
||
125 | 'group' => Decorator::field('groname'), |
||
126 | ], |
||
127 | ], |
||
128 | ], |
||
129 | ], |
||
130 | ]; |
||
131 | |||
132 | echo $this->printTable($groups, $columns, $actions, 'groups-properties', $this->lang['strnogroups']); |
||
133 | |||
134 | $this->printNavLinks(['create' => [ |
||
1 ignored issue
–
show
|
|||
135 | 'attr' => [ |
||
136 | 'href' => [ |
||
137 | 'url' => 'groups', |
||
138 | 'urlvars' => [ |
||
139 | 'action' => 'create', |
||
140 | 'server' => $_REQUEST['server'], |
||
141 | ], |
||
142 | ], |
||
143 | ], |
||
144 | 'content' => $this->lang['strcreategroup'], |
||
145 | ]], 'groups-groups', get_defined_vars()); |
||
1 ignored issue
–
show
|
|||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Add user to a group. |
||
150 | */ |
||
151 | public function doAddMember() |
||
152 | { |
||
153 | $data = $this->misc->getDatabaseAccessor(); |
||
154 | |||
155 | $status = $data->addGroupMember($_REQUEST['group'], $_REQUEST['user']); |
||
156 | if (0 == $status) { |
||
157 | $this->doProperties($this->lang['strmemberadded']); |
||
158 | } else { |
||
159 | $this->doProperties($this->lang['strmemberaddedbad']); |
||
160 | } |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Show confirmation of drop user from group and perform actual drop. |
||
165 | * |
||
166 | * @param mixed $confirm |
||
167 | */ |
||
168 | public function doDropMember($confirm) |
||
169 | { |
||
170 | $data = $this->misc->getDatabaseAccessor(); |
||
171 | |||
172 | if ($confirm) { |
||
173 | $this->printTrail('group'); |
||
174 | $this->printTitle($this->lang['strdropmember'], 'pg.group.alter'); |
||
175 | |||
176 | echo '<p>', sprintf($this->lang['strconfdropmember'], $this->misc->printVal($_REQUEST['user']), $this->misc->printVal($_REQUEST['group'])), "</p>\n"; |
||
177 | |||
178 | echo '<form action="'.\SUBFOLDER."/src/views/groups\" method=\"post\">\n"; |
||
179 | echo $this->misc->form; |
||
180 | echo "<input type=\"hidden\" name=\"action\" value=\"drop_member\" />\n"; |
||
181 | echo '<input type="hidden" name="group" value="', htmlspecialchars($_REQUEST['group']), "\" />\n"; |
||
182 | echo '<input type="hidden" name="user" value="', htmlspecialchars($_REQUEST['user']), "\" />\n"; |
||
183 | echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />\n"; |
||
184 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />\n"; |
||
185 | echo "</form>\n"; |
||
186 | } else { |
||
187 | $status = $data->dropGroupMember($_REQUEST['group'], $_REQUEST['user']); |
||
188 | if (0 == $status) { |
||
189 | $this->doProperties($this->lang['strmemberdropped']); |
||
190 | } else { |
||
191 | $this->doDropMember(true, $this->lang['strmemberdroppedbad']); |
||
192 | } |
||
193 | } |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Show read only properties for a group. |
||
198 | * |
||
199 | * @param mixed $msg |
||
200 | */ |
||
201 | public function doProperties($msg = '') |
||
202 | { |
||
203 | $data = $this->misc->getDatabaseAccessor(); |
||
204 | |||
205 | if (!isset($_POST['user'])) { |
||
206 | $_POST['user'] = ''; |
||
207 | } |
||
208 | |||
209 | $this->printTrail('group'); |
||
210 | $this->printTitle($this->lang['strproperties'], 'pg.group'); |
||
211 | $this->printMsg($msg); |
||
212 | |||
213 | $groupdata = $data->getGroup($_REQUEST['group']); |
||
214 | $users = $data->getUsers(); |
||
215 | |||
216 | if ($groupdata->recordCount() > 0) { |
||
217 | $columns = [ |
||
218 | 'members' => [ |
||
219 | 'title' => $this->lang['strmembers'], |
||
220 | 'field' => Decorator::field('usename'), |
||
221 | ], |
||
222 | 'actions' => [ |
||
223 | 'title' => $this->lang['stractions'], |
||
224 | ], |
||
225 | ]; |
||
226 | |||
227 | $actions = [ |
||
228 | 'drop' => [ |
||
229 | 'content' => $this->lang['strdrop'], |
||
230 | 'attr' => [ |
||
231 | 'href' => [ |
||
232 | 'url' => 'groups', |
||
233 | 'urlvars' => [ |
||
234 | 'action' => 'confirm_drop_member', |
||
235 | 'group' => $_REQUEST['group'], |
||
236 | 'user' => Decorator::field('usename'), |
||
237 | ], |
||
238 | ], |
||
239 | ], |
||
240 | ], |
||
241 | ]; |
||
242 | |||
243 | echo $this->printTable($groupdata, $columns, $actions, 'groups-members', $this->lang['strnousers']); |
||
244 | } |
||
245 | |||
246 | // Display form for adding a user to the group |
||
247 | echo '<form action="'.\SUBFOLDER."/src/views/groups\" method=\"post\">\n"; |
||
248 | echo '<select name="user">'; |
||
249 | while (!$users->EOF) { |
||
250 | $uname = $this->misc->printVal($users->fields['usename']); |
||
251 | echo "<option value=\"{$uname}\"", |
||
252 | ($uname == $_POST['user']) ? ' selected="selected"' : '', ">{$uname}</option>\n"; |
||
253 | $users->moveNext(); |
||
254 | } |
||
255 | echo "</select>\n"; |
||
256 | echo "<input type=\"submit\" value=\"{$this->lang['straddmember']}\" />\n"; |
||
257 | echo $this->misc->form; |
||
258 | echo '<input type="hidden" name="group" value="', htmlspecialchars($_REQUEST['group']), "\" />\n"; |
||
259 | echo "<input type=\"hidden\" name=\"action\" value=\"add_member\" />\n"; |
||
260 | echo "</form>\n"; |
||
261 | |||
262 | $this->printNavLinks(['showall' => [ |
||
1 ignored issue
–
show
|
|||
263 | 'attr' => [ |
||
264 | 'href' => [ |
||
265 | 'url' => 'groups', |
||
266 | 'urlvars' => [ |
||
267 | 'server' => $_REQUEST['server'], |
||
268 | ], |
||
269 | ], |
||
270 | ], |
||
271 | 'content' => $this->lang['strshowallgroups'], |
||
272 | ]], 'groups-properties', get_defined_vars()); |
||
1 ignored issue
–
show
|
|||
273 | } |
||
274 | |||
275 | /** |
||
276 | * Show confirmation of drop and perform actual drop. |
||
277 | * |
||
278 | * @param mixed $confirm |
||
279 | */ |
||
280 | public function doDrop($confirm) |
||
303 | } |
||
304 | } |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * Displays a screen where they can enter a new group. |
||
309 | * |
||
310 | * @param mixed $msg |
||
311 | */ |
||
312 | public function doCreate($msg = '') |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * Actually creates the new group in the database. |
||
358 | */ |
||
359 | public function doSaveCreate() |
||
376 | } |
||
377 | } |
||
378 | } |
||
380 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.