1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | /** |
||
6 | * This script displays an area where teachers can edit the group properties and member list. |
||
7 | * |
||
8 | * @author various contributors |
||
9 | * @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support |
||
10 | * |
||
11 | * @todo course admin functionality to create groups based on who is in which course (or class). |
||
12 | */ |
||
13 | require_once __DIR__.'/../inc/global.inc.php'; |
||
14 | $this_section = SECTION_COURSES; |
||
15 | $current_course_tool = TOOL_GROUP; |
||
16 | |||
17 | // Notice for unauthorized people. |
||
18 | api_protect_course_script(true); |
||
19 | |||
20 | $group_id = api_get_group_id(); |
||
21 | $current_group = GroupManager::get_group_properties($group_id); |
||
22 | |||
23 | if (empty($current_group)) { |
||
24 | api_not_allowed(true); |
||
25 | } |
||
26 | |||
27 | $nameTools = get_lang('EditGroup'); |
||
28 | $interbreadcrumb[] = ['url' => 'group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')]; |
||
29 | $interbreadcrumb[] = ['url' => 'group_space.php?'.api_get_cidreq(), 'name' => $current_group['name']]; |
||
30 | $groupMember = GroupManager::is_tutor_of_group(api_get_user_id(), $current_group); |
||
31 | |||
32 | if (!$groupMember && !api_is_allowed_to_edit(false, true)) { |
||
33 | api_not_allowed(true); |
||
34 | } |
||
35 | |||
36 | // Build form |
||
37 | $form = new FormValidator('group_edit', 'post', api_get_self().'?'.api_get_cidreq()); |
||
38 | $form->addElement('hidden', 'action'); |
||
39 | $form->addElement('html', '<div class="col-md-12">'); |
||
40 | $form->addElement('header', $nameTools); |
||
41 | $form->addElement('html', '</div>'); |
||
42 | $form->addElement('html', '<div class="col-md-6">'); |
||
43 | |||
44 | // Group name |
||
45 | $form->addElement('text', 'name', get_lang('GroupName')); |
||
46 | |||
47 | if (api_get_setting('allow_group_categories') == 'true') { |
||
48 | $groupCategories = GroupManager::get_categories(); |
||
49 | $categoryList = []; |
||
50 | //$categoryList[] = null; |
||
51 | foreach ($groupCategories as $category) { |
||
52 | $categoryList[$category['id']] = $category['title']; |
||
53 | } |
||
54 | $form->addElement('select', 'category_id', get_lang('Category'), $categoryList); |
||
55 | } else { |
||
56 | $form->addHidden('category_id', 0); |
||
57 | } |
||
58 | $form->addElement('html', '</div>'); |
||
59 | |||
60 | $form->addElement('html', '<div class="col-md-6">'); |
||
61 | $form->addElement('textarea', 'description', get_lang('Description')); |
||
62 | |||
63 | $form->addElement('html', '</div>'); |
||
64 | |||
65 | $form->addElement('html', '<div class="col-md-12">'); |
||
66 | $form->addElement('header', ''); |
||
67 | $form->addElement('html', '</div>'); |
||
68 | |||
69 | $form->addElement('html', '<div class="col-md-6">'); |
||
70 | |||
71 | // Members per group |
||
72 | $group = [ |
||
73 | $form->createElement( |
||
74 | 'radio', |
||
75 | 'max_member_no_limit', |
||
76 | get_lang('GroupLimit'), |
||
77 | get_lang('NoLimit'), |
||
78 | GroupManager::MEMBER_PER_GROUP_NO_LIMIT |
||
79 | ), |
||
80 | $form->createElement( |
||
81 | 'radio', |
||
82 | 'max_member_no_limit', |
||
83 | null, |
||
84 | get_lang('MaximumOfParticipants'), |
||
85 | 1, |
||
86 | ['id' => 'max_member_selected'] |
||
87 | ), |
||
88 | $form->createElement('text', 'max_member', null, ['class' => 'span1', 'id' => 'max_member']), |
||
89 | $form->createElement('static', null, null, ' '.get_lang('GroupPlacesThis')), |
||
90 | ]; |
||
91 | $form->addGroup($group, 'max_member_group', get_lang('GroupLimit'), null, false); |
||
92 | $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members'); |
||
93 | |||
94 | $form->addElement('html', '</div>'); |
||
95 | |||
96 | $form->addElement('html', '<div class="col-md-6">'); |
||
97 | |||
98 | // Self registration |
||
99 | $group = [ |
||
100 | $form->createElement( |
||
101 | 'checkbox', |
||
102 | 'self_registration_allowed', |
||
103 | get_lang('GroupSelfRegistration'), |
||
104 | get_lang('GroupAllowStudentRegistration'), |
||
105 | 1 |
||
106 | ), |
||
107 | $form->createElement( |
||
108 | 'checkbox', |
||
109 | 'self_unregistration_allowed', |
||
110 | null, |
||
111 | get_lang('GroupAllowStudentUnregistration'), |
||
112 | 1 |
||
113 | ), |
||
114 | ]; |
||
115 | $form->addGroup( |
||
116 | $group, |
||
117 | '', |
||
118 | Display::return_icon('user.png', get_lang('GroupSelfRegistration')). |
||
119 | '<span>'.get_lang('GroupSelfRegistration').'</span>', |
||
120 | null, |
||
121 | false |
||
122 | ); |
||
123 | |||
124 | $form->addElement('html', '</div>'); |
||
125 | |||
126 | $form->addElement('html', '<div class="col-md-12">'); |
||
127 | $form->addElement('header', get_lang('DefaultSettingsForNewGroups')); |
||
128 | $form->addElement('html', '</div>'); |
||
129 | |||
130 | $form->addElement('html', '<div class="col-md-6">'); |
||
131 | // Documents settings |
||
132 | $group = [ |
||
133 | $form->createElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
134 | $form->createElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
135 | $form->createElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
136 | ]; |
||
137 | $form->addGroup( |
||
138 | $group, |
||
139 | '', |
||
140 | Display::return_icon('folder.png', get_lang('GroupDocument')).'<span>'.get_lang('GroupDocument').'</span>', |
||
141 | null, |
||
142 | false |
||
143 | ); |
||
144 | |||
145 | $allowDocumentGroupAccess = api_get_configuration_value('group_document_access'); |
||
146 | if ($allowDocumentGroupAccess) { |
||
147 | $form->addElement('html', '</div>'); |
||
148 | $form->addElement('html', '<div class="col-md-6">'); |
||
149 | $group = [ |
||
150 | $form->createElement( |
||
151 | 'radio', |
||
152 | 'document_access', |
||
153 | null, |
||
154 | get_lang('DocumentGroupShareMode'), |
||
155 | GroupManager::DOCUMENT_MODE_SHARE |
||
156 | ), |
||
157 | $form->createElement( |
||
158 | 'radio', |
||
159 | 'document_access', |
||
160 | get_lang('GroupDocument'), |
||
161 | get_lang('DocumentGroupCollaborationMode'), |
||
162 | GroupManager::DOCUMENT_MODE_COLLABORATION |
||
163 | ), |
||
164 | $form->createElement( |
||
165 | 'radio', |
||
166 | 'document_access', |
||
167 | null, |
||
168 | get_lang('DocumentGroupReadOnlyMode'), |
||
169 | GroupManager::DOCUMENT_MODE_READ_ONLY |
||
170 | ), |
||
171 | ]; |
||
172 | $form->addGroup( |
||
173 | $group, |
||
174 | '', |
||
175 | Display::return_icon( |
||
176 | 'folder.png', |
||
177 | get_lang('GroupDocumentAccess') |
||
178 | ).'<span>'.get_lang('GroupDocumentAccess').'</span>', |
||
179 | null, |
||
180 | false |
||
181 | ); |
||
182 | $form->addElement('html', '</div>'); |
||
183 | |||
184 | $form->addElement('html', '<div class="col-md-12">'); |
||
185 | $form->addElement('header', ''); |
||
186 | $form->addElement('html', '</div>'); |
||
187 | |||
188 | $form->addElement('html', '<div class="col-md-6">'); |
||
189 | } |
||
190 | |||
191 | // Work settings |
||
192 | $group = [ |
||
193 | $form->createElement( |
||
194 | 'radio', |
||
195 | 'work_state', |
||
196 | get_lang('GroupWork'), |
||
197 | get_lang('NotAvailable'), |
||
198 | GroupManager::TOOL_NOT_AVAILABLE |
||
199 | ), |
||
200 | $form->createElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
201 | $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
202 | ]; |
||
203 | $form->addElement('html', '</div>'); |
||
204 | |||
205 | $form->addElement('html', '<div class="col-md-12">'); |
||
206 | $form->addElement('html', '</div>'); |
||
207 | |||
208 | $form->addElement('html', '<div class="col-md-6">'); |
||
209 | |||
210 | $form->addGroup( |
||
211 | $group, |
||
212 | '', |
||
213 | Display::return_icon('works.png', get_lang('GroupWork')).'<span>'.get_lang('GroupWork').'</span>', |
||
214 | null, |
||
215 | false |
||
216 | ); |
||
217 | |||
218 | // Calendar settings |
||
219 | $group = [ |
||
220 | $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
221 | $form->createElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
222 | $form->createElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
223 | ]; |
||
224 | |||
225 | $form->addElement('html', '</div>'); |
||
226 | |||
227 | $form->addElement('html', '<div class="col-md-6">'); |
||
228 | $form->addGroup( |
||
229 | $group, |
||
230 | '', |
||
231 | Display::return_icon('agenda.png', get_lang('GroupCalendar')).'<span>'.get_lang('GroupCalendar').'</span>', |
||
232 | null, |
||
233 | false |
||
234 | ); |
||
235 | |||
236 | $form->addElement('html', '</div>'); |
||
237 | |||
238 | $form->addElement('html', '<div class="col-md-12">'); |
||
239 | $form->addElement('header', ''); |
||
240 | $form->addElement('html', '</div>'); |
||
241 | |||
242 | $form->addElement('html', '<div class="col-md-6">'); |
||
243 | |||
244 | // Announcements settings |
||
245 | $group = [ |
||
246 | $form->createElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
247 | $form->createElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
248 | $form->createElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
249 | $form->createElement('radio', 'announcements_state', null, get_lang('PrivateBetweenUsers'), GroupManager::TOOL_PRIVATE_BETWEEN_USERS), |
||
250 | ]; |
||
251 | |||
252 | $form->addGroup( |
||
253 | $group, |
||
254 | '', |
||
255 | Display::return_icon('announce.png', get_lang('GroupAnnouncements')).'<span>'.get_lang('GroupAnnouncements').'</span>', |
||
256 | null, |
||
257 | false |
||
258 | ); |
||
259 | |||
260 | $form->addElement('html', '</div>'); |
||
261 | |||
262 | $form->addElement('html', '<div class="col-md-6">'); |
||
263 | |||
264 | // Forum settings |
||
265 | $group = [ |
||
266 | $form->createElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
267 | $form->createElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
268 | $form->createElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
269 | ]; |
||
270 | $form->addGroup( |
||
271 | $group, |
||
272 | '', |
||
273 | Display::return_icon('forum.png', get_lang('GroupForum')).'<span>'.get_lang('GroupForum').'</span>', |
||
274 | null, |
||
275 | false |
||
276 | ); |
||
277 | |||
278 | $form->addElement('html', '</div>'); |
||
279 | |||
280 | $form->addElement('html', '<div class="col-md-12">'); |
||
281 | $form->addElement('header', ''); |
||
282 | $form->addElement('html', '</div>'); |
||
283 | |||
284 | $form->addElement('html', '<div class="col-md-6">'); |
||
285 | |||
286 | // Wiki settings |
||
287 | $group = [ |
||
288 | $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
289 | $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
290 | $form->createElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
291 | ]; |
||
292 | $form->addGroup( |
||
293 | $group, |
||
294 | '', |
||
295 | Display::return_icon('wiki.png', get_lang('GroupWiki')).'<span>'.get_lang('GroupWiki').'</span>', |
||
296 | '', |
||
297 | false |
||
298 | ); |
||
299 | |||
300 | $form->addElement('html', '</div>'); |
||
301 | $form->addElement('html', '<div class="col-md-6">'); |
||
302 | |||
303 | // Chat settings |
||
304 | $group = [ |
||
305 | $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE), |
||
306 | $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC), |
||
307 | $form->createElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE), |
||
308 | ]; |
||
309 | $form->addGroup( |
||
310 | $group, |
||
311 | '', |
||
312 | Display::return_icon('chat.png', get_lang('Chat')).'<span>'.get_lang('Chat').'</span>', |
||
313 | null, |
||
314 | false |
||
315 | ); |
||
316 | |||
317 | $form->addElement('html', '</div>'); |
||
318 | $form->addElement('html', '<div class="col-md-12">'); |
||
319 | // Submit button |
||
320 | $form->addButtonSave(get_lang('SaveSettings')); |
||
321 | $form->addElement('html', '</div>'); |
||
322 | |||
323 | if ($form->validate()) { |
||
324 | $values = $form->exportValues(); |
||
325 | if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { |
||
326 | $max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; |
||
327 | } else { |
||
328 | $max_member = $values['max_member']; |
||
329 | } |
||
330 | $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0; |
||
331 | $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0; |
||
332 | $categoryId = isset($values['category_id']) ? $values['category_id'] : null; |
||
333 | |||
334 | GroupManager::set_group_properties( |
||
335 | $current_group['id'], |
||
336 | $values['name'], |
||
337 | $values['description'], |
||
338 | $max_member, |
||
339 | $values['doc_state'], |
||
340 | $values['work_state'], |
||
341 | $values['calendar_state'], |
||
342 | $values['announcements_state'], |
||
343 | $values['forum_state'], |
||
344 | $values['wiki_state'], |
||
345 | $values['chat_state'], |
||
346 | $self_registration_allowed, |
||
347 | $self_unregistration_allowed, |
||
348 | $categoryId, |
||
349 | isset($values['document_access']) ? $values['document_access'] : 0 |
||
350 | ); |
||
351 | if (isset($_POST['group_members']) && |
||
352 | count($_POST['group_members']) > $max_member && |
||
353 | $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT |
||
354 | ) { |
||
355 | Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); |
||
356 | header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$categoryId); |
||
357 | } else { |
||
358 | Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); |
||
359 | header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$categoryId); |
||
360 | } |
||
361 | exit; |
||
362 | } |
||
363 | |||
364 | $defaults = $current_group; |
||
365 | $category = GroupManager::get_category_from_group($current_group['iid']); |
||
366 | if (!empty($category)) { |
||
367 | $defaults['category_id'] = $category['id']; |
||
368 | } |
||
369 | |||
370 | $action = isset($_GET['action']) ? $_GET['action'] : ''; |
||
371 | $defaults['action'] = $action; |
||
372 | if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { |
||
373 | $defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; |
||
374 | } else { |
||
375 | $defaults['max_member_no_limit'] = 1; |
||
376 | $defaults['max_member'] = $defaults['maximum_number_of_students']; |
||
377 | } |
||
378 | |||
379 | if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { |
||
380 | $keyword_name = Security::remove_XSS($_GET['keyword']); |
||
381 | echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>'; |
||
382 | } |
||
383 | |||
384 | Display::display_header($nameTools, 'Group'); |
||
385 | |||
386 | $form->setDefaults($defaults); |
||
387 | echo GroupManager::getSettingBar('settings'); |
||
0 ignored issues
–
show
|
|||
388 | echo '<div class="row">'; |
||
389 | $form->display(); |
||
390 | echo '</div>'; |
||
391 | |||
392 | Display::display_footer(); |
||
393 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.