|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This script shows the group space for one specific group, possibly displaying |
|
6
|
|
|
* a list of users in the group, subscribe or unsubscribe option, tutors... |
|
7
|
|
|
* |
|
8
|
|
|
* @todo Display error message if no group ID specified |
|
9
|
|
|
*/ |
|
10
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
11
|
|
|
$current_course_tool = TOOL_GROUP; |
|
12
|
|
|
|
|
13
|
|
|
// Notice for unauthorized people. |
|
14
|
|
|
api_protect_course_script(true, false, 'group'); |
|
15
|
|
|
|
|
16
|
|
|
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
|
17
|
|
|
|
|
18
|
|
|
$group_id = api_get_group_id(); |
|
19
|
|
|
$user_id = api_get_user_id(); |
|
20
|
|
|
$current_group = GroupManager::get_group_properties($group_id); |
|
21
|
|
|
$group_id = $current_group['iid']; |
|
22
|
|
|
if (empty($current_group)) { |
|
23
|
|
|
api_not_allowed(true); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
$this_section = SECTION_COURSES; |
|
27
|
|
|
$nameTools = get_lang('GroupSpace'); |
|
28
|
|
|
$interbreadcrumb[] = [ |
|
29
|
|
|
'url' => 'group.php?'.api_get_cidreq(), |
|
30
|
|
|
'name' => get_lang('Groups'), |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
/* Ensure all private groups // Juan Carlos Raña Trabado */ |
|
34
|
|
|
|
|
35
|
|
|
$forums_of_groups = get_forums_of_group($current_group); |
|
36
|
|
|
if (!GroupManager::userHasAccessToBrowse($user_id, $current_group, api_get_session_id())) { |
|
37
|
|
|
api_not_allowed(true); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/* Actions and Action links */ |
|
41
|
|
|
/* |
|
42
|
|
|
* User wants to register in this group |
|
43
|
|
|
*/ |
|
44
|
|
|
if (!empty($_GET['selfReg']) && |
|
45
|
|
|
GroupManager::is_self_registration_allowed($user_id, $current_group) |
|
46
|
|
|
) { |
|
47
|
|
|
GroupManager::subscribe_users($user_id, $current_group); |
|
48
|
|
|
Display::addFlash(Display::return_message(get_lang('GroupNowMember'))); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/* |
|
52
|
|
|
* User wants to unregister from this group |
|
53
|
|
|
*/ |
|
54
|
|
|
if (!empty($_GET['selfUnReg']) && |
|
55
|
|
|
GroupManager::is_self_unregistration_allowed($user_id, $current_group) |
|
56
|
|
|
) { |
|
57
|
|
|
GroupManager::unsubscribe_users($user_id, $current_group); |
|
58
|
|
|
Display::addFlash( |
|
59
|
|
|
Display::return_message(get_lang('StudentDeletesHimself'), 'normal') |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
Display::display_header( |
|
64
|
|
|
$nameTools.' '.Security::remove_XSS($current_group['name']), |
|
65
|
|
|
'Group' |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
/* Introduction section (editable by course admin) */ |
|
69
|
|
|
Display::display_introduction_section(TOOL_GROUP); |
|
70
|
|
|
|
|
71
|
|
|
echo '<div class="actions">'; |
|
72
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq().'">'. |
|
73
|
|
|
Display::return_icon( |
|
74
|
|
|
'back.png', |
|
75
|
|
|
get_lang('BackToGroupList'), |
|
76
|
|
|
'', |
|
77
|
|
|
ICON_SIZE_MEDIUM |
|
78
|
|
|
). |
|
79
|
|
|
'</a>'; |
|
80
|
|
|
|
|
81
|
|
|
/* |
|
82
|
|
|
* Register to group |
|
83
|
|
|
*/ |
|
84
|
|
|
$subscribe_group = ''; |
|
85
|
|
|
if (GroupManager::is_self_registration_allowed($user_id, $current_group)) { |
|
86
|
|
|
$subscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfReg=1&group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'. |
|
87
|
|
|
get_lang('RegIntoGroup').'</a>'; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/* |
|
91
|
|
|
* Unregister from group |
|
92
|
|
|
*/ |
|
93
|
|
|
$unsubscribe_group = ''; |
|
94
|
|
|
if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group)) { |
|
95
|
|
|
$unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'. |
|
96
|
|
|
get_lang('StudentUnsubscribe').'</a>'; |
|
97
|
|
|
} |
|
98
|
|
|
echo ' </div>'; |
|
99
|
|
|
|
|
100
|
|
|
/* Main Display Area */ |
|
101
|
|
|
|
|
102
|
|
|
$edit_url = ''; |
|
103
|
|
|
if (api_is_allowed_to_edit(false, true) || |
|
104
|
|
|
GroupManager::is_tutor_of_group($user_id, $current_group) |
|
105
|
|
|
) { |
|
106
|
|
|
$edit_url = '<a href="'.api_get_path(WEB_CODE_PATH).'group/settings.php?'.api_get_cidreq().'">'. |
|
107
|
|
|
Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL).'</a>'; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
echo Display::page_header( |
|
111
|
|
|
Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group |
|
112
|
|
|
); |
|
113
|
|
|
|
|
114
|
|
|
if (!empty($current_group['description'])) { |
|
115
|
|
|
echo '<p>'.Security::remove_XSS($current_group['description']).'</p>'; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
// If the user is subscribed to the group or the user is a tutor of the group then |
|
119
|
|
|
if (api_is_allowed_to_edit(false, true) || |
|
120
|
|
|
GroupManager::userHasAccessToBrowse($user_id, $current_group, api_get_session_id()) |
|
121
|
|
|
) { |
|
122
|
|
|
$actions_array = []; |
|
123
|
|
|
if (is_array($forums_of_groups)) { |
|
124
|
|
|
if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
125
|
|
|
foreach ($forums_of_groups as $key => $value) { |
|
126
|
|
|
if ($value['forum_group_public_private'] == 'public' || |
|
127
|
|
|
($value['forum_group_public_private'] == 'private') || |
|
128
|
|
|
!empty($user_is_tutor) || |
|
129
|
|
|
api_is_allowed_to_edit(false, true) |
|
130
|
|
|
) { |
|
131
|
|
|
$actions_array[] = [ |
|
132
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?forum='.$value['forum_id'].'&'.api_get_cidreq().'&origin=group', |
|
133
|
|
|
'content' => Display::return_icon( |
|
134
|
|
|
'forum.png', |
|
135
|
|
|
get_lang('Forum').': '.$value['forum_title'], |
|
136
|
|
|
[], |
|
137
|
|
|
32 |
|
138
|
|
|
), |
|
139
|
|
|
]; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
146
|
|
|
// Link to the documents area of this group |
|
147
|
|
|
$actions_array[] = [ |
|
148
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(), |
|
149
|
|
|
'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), [], 32), |
|
150
|
|
|
]; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
154
|
|
|
$groupFilter = ''; |
|
155
|
|
|
if (!empty($group_id)) { |
|
156
|
|
|
$groupFilter = "&type=course&user_id=GROUP:$group_id"; |
|
157
|
|
|
} |
|
158
|
|
|
// Link to a group-specific part of agenda |
|
159
|
|
|
$actions_array[] = [ |
|
160
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'.api_get_cidreq().$groupFilter, |
|
161
|
|
|
'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), [], 32), |
|
162
|
|
|
]; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
166
|
|
|
// Link to the works area of this group |
|
167
|
|
|
$actions_array[] = [ |
|
168
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), |
|
169
|
|
|
'content' => Display::return_icon('work.png', get_lang('GroupWork'), [], 32), |
|
170
|
|
|
]; |
|
171
|
|
|
} |
|
172
|
|
|
if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
173
|
|
|
// Link to a group-specific part of announcements |
|
174
|
|
|
$actions_array[] = [ |
|
175
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(), |
|
176
|
|
|
'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), [], 32), |
|
177
|
|
|
]; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
181
|
|
|
// Link to the wiki area of this group |
|
182
|
|
|
$actions_array[] = [ |
|
183
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'], |
|
184
|
|
|
'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), [], 32), |
|
185
|
|
|
]; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
189
|
|
|
// Link to the chat area of this group |
|
190
|
|
|
if (api_get_course_setting('allow_open_chat_window')) { |
|
191
|
|
|
$actions_array[] = [ |
|
192
|
|
|
'url' => "javascript: void(0);", |
|
193
|
|
|
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32), |
|
194
|
|
|
'url_attributes' => [ |
|
195
|
|
|
'onclick' => " window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".api_get_course_id()."_".api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')", |
|
196
|
|
|
], |
|
197
|
|
|
]; |
|
198
|
|
|
} else { |
|
199
|
|
|
$actions_array[] = [ |
|
200
|
|
|
'url' => api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'], |
|
201
|
|
|
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32), |
|
202
|
|
|
]; |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
$enabled = api_get_plugin_setting('bbb', 'tool_enable'); |
|
207
|
|
|
if ($enabled === 'true') { |
|
208
|
|
|
$bbb = new bbb(); |
|
209
|
|
|
if ($bbb->hasGroupSupport()) { |
|
210
|
|
|
$actions_array[] = [ |
|
211
|
|
|
'url' => api_get_path(WEB_PLUGIN_PATH)."bbb/start.php?".api_get_cidreq(), |
|
212
|
|
|
'content' => Display::return_icon('bbb.png', get_lang('VideoConference'), [], 32), |
|
213
|
|
|
]; |
|
214
|
|
|
} |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
if (!empty($actions_array)) { |
|
218
|
|
|
echo Display::actions($actions_array); |
|
219
|
|
|
} |
|
220
|
|
|
} else { |
|
221
|
|
|
$actions_array = []; |
|
222
|
|
|
if (is_array($forums_of_groups)) { |
|
223
|
|
|
if ($current_group['forum_state'] == GroupManager::TOOL_PUBLIC) { |
|
224
|
|
|
foreach ($forums_of_groups as $key => $value) { |
|
225
|
|
|
if ($value['forum_group_public_private'] == 'public') { |
|
226
|
|
|
$actions_array[] = [ |
|
227
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&origin=group', |
|
228
|
|
|
'content' => Display::return_icon( |
|
229
|
|
|
'forum.png', |
|
230
|
|
|
get_lang('GroupForum'), |
|
231
|
|
|
[], |
|
232
|
|
|
ICON_SIZE_MEDIUM |
|
233
|
|
|
), |
|
234
|
|
|
]; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
} |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) { |
|
241
|
|
|
// Link to the documents area of this group |
|
242
|
|
|
$actions_array[] = [ |
|
243
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(), |
|
244
|
|
|
'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), [], ICON_SIZE_MEDIUM), |
|
245
|
|
|
]; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) { |
|
249
|
|
|
$groupFilter = ''; |
|
250
|
|
|
if (!empty($group_id)) { |
|
251
|
|
|
$groupFilter = "&type=course&user_id=GROUP:$group_id"; |
|
252
|
|
|
} |
|
253
|
|
|
// Link to a group-specific part of agenda |
|
254
|
|
|
$actions_array[] = [ |
|
255
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'.api_get_cidreq().$groupFilter, |
|
256
|
|
|
'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), [], 32), |
|
257
|
|
|
]; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) { |
|
261
|
|
|
// Link to the works area of this group |
|
262
|
|
|
$actions_array[] = [ |
|
263
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), |
|
264
|
|
|
'content' => Display::return_icon('work.png', get_lang('GroupWork'), [], ICON_SIZE_MEDIUM), |
|
265
|
|
|
]; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) { |
|
269
|
|
|
// Link to a group-specific part of announcements |
|
270
|
|
|
$actions_array[] = [ |
|
271
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(), |
|
272
|
|
|
'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), [], ICON_SIZE_MEDIUM), |
|
273
|
|
|
]; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) { |
|
277
|
|
|
// Link to the wiki area of this group |
|
278
|
|
|
$actions_array[] = [ |
|
279
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'], |
|
280
|
|
|
'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), [], 32), |
|
281
|
|
|
]; |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC) { |
|
285
|
|
|
// Link to the chat area of this group |
|
286
|
|
|
if (api_get_course_setting('allow_open_chat_window')) { |
|
287
|
|
|
$actions_array[] = [ |
|
288
|
|
|
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".api_get_course_id()."_".api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"", |
|
289
|
|
|
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32), |
|
290
|
|
|
]; |
|
291
|
|
|
} else { |
|
292
|
|
|
$actions_array[] = [ |
|
293
|
|
|
'url' => api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'], |
|
294
|
|
|
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32), |
|
295
|
|
|
]; |
|
296
|
|
|
} |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
if (!empty($actions_array)) { |
|
300
|
|
|
echo Display::actions($actions_array); |
|
301
|
|
|
} |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/* |
|
305
|
|
|
* List all the tutors of the current group |
|
306
|
|
|
*/ |
|
307
|
|
|
$tutors = GroupManager::get_subscribed_tutors($current_group); |
|
308
|
|
|
$tutor_info = ''; |
|
309
|
|
|
if (count($tutors) == 0) { |
|
310
|
|
|
$tutor_info = get_lang('GroupNoneMasc'); |
|
311
|
|
|
} else { |
|
312
|
|
|
$tutor_info .= '<ul class="thumbnails">'; |
|
313
|
|
|
foreach ($tutors as $index => $tutor) { |
|
314
|
|
|
$userInfo = api_get_user_info($tutor['user_id']); |
|
315
|
|
|
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userInfo['username']), ENT_QUOTES); |
|
316
|
|
|
$completeName = $userInfo['complete_name']; |
|
317
|
|
|
$photo = '<img src="'.$userInfo['avatar'].'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />'; |
|
318
|
|
|
$tutor_info .= '<li>'; |
|
319
|
|
|
$tutor_info .= $userInfo['complete_name_with_message_link']; |
|
320
|
|
|
$tutor_info .= '</li>'; |
|
321
|
|
|
} |
|
322
|
|
|
$tutor_info .= '</ul>'; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
echo Display::page_subheader(get_lang('GroupTutors')); |
|
326
|
|
|
if (!empty($tutor_info)) { |
|
327
|
|
|
echo $tutor_info; |
|
328
|
|
|
} |
|
329
|
|
|
echo '<br />'; |
|
330
|
|
|
|
|
331
|
|
|
/* |
|
332
|
|
|
* List all the members of the current group |
|
333
|
|
|
*/ |
|
334
|
|
|
echo Display::page_subheader(get_lang('GroupMembers')); |
|
335
|
|
|
|
|
336
|
|
|
$table = new SortableTable( |
|
337
|
|
|
'group_users', |
|
338
|
|
|
'get_number_of_group_users', |
|
339
|
|
|
'get_group_user_data', |
|
340
|
|
|
(api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1 |
|
341
|
|
|
); |
|
342
|
|
|
$origin = api_get_origin(); |
|
343
|
|
|
$my_cidreq = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : ''; |
|
344
|
|
|
$my_gidreq = isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : ''; |
|
345
|
|
|
$parameters = ['cidReq' => $my_cidreq, 'origin' => $origin, 'gidReq' => $my_gidreq]; |
|
346
|
|
|
$table->set_additional_parameters($parameters); |
|
347
|
|
|
$table->set_header(0, ''); |
|
348
|
|
|
|
|
349
|
|
|
if (api_is_western_name_order()) { |
|
350
|
|
|
$table->set_header(1, get_lang('FirstName')); |
|
351
|
|
|
$table->set_header(2, get_lang('LastName')); |
|
352
|
|
|
} else { |
|
353
|
|
|
$table->set_header(1, get_lang('LastName')); |
|
354
|
|
|
$table->set_header(2, get_lang('FirstName')); |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
if (api_get_setting('show_email_addresses') == 'true' || api_is_allowed_to_edit() == 'true') { |
|
358
|
|
|
$table->set_header(3, get_lang('Email')); |
|
359
|
|
|
$table->set_column_filter(3, 'email_filter'); |
|
360
|
|
|
$table->set_header(4, get_lang('Active')); |
|
361
|
|
|
$table->set_column_filter(4, 'activeFilter'); |
|
362
|
|
|
} else { |
|
363
|
|
|
$table->set_header(3, get_lang('Active')); |
|
364
|
|
|
$table->set_column_filter(3, 'activeFilter'); |
|
365
|
|
|
} |
|
366
|
|
|
//the order of these calls is important |
|
367
|
|
|
//$table->set_column_filter(1, 'user_name_filter'); |
|
368
|
|
|
//$table->set_column_filter(2, 'user_name_filter'); |
|
369
|
|
|
$table->set_column_filter(0, 'user_icon_filter'); |
|
370
|
|
|
$table->display(); |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* Get the number of subscribed users to the group. |
|
374
|
|
|
* |
|
375
|
|
|
* @return int |
|
376
|
|
|
* |
|
377
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University, Belgium |
|
378
|
|
|
* |
|
379
|
|
|
* @version April 2008 |
|
380
|
|
|
*/ |
|
381
|
|
|
function get_number_of_group_users() |
|
382
|
|
|
{ |
|
383
|
|
|
$groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
|
384
|
|
|
$course_id = api_get_course_int_id(); |
|
385
|
|
|
|
|
386
|
|
|
if (empty($groupInfo) || empty($course_id)) { |
|
387
|
|
|
return 0; |
|
388
|
|
|
} |
|
389
|
|
|
|
|
390
|
|
|
// Database table definition |
|
391
|
|
|
$table = Database::get_course_table(TABLE_GROUP_USER); |
|
392
|
|
|
|
|
393
|
|
|
// Query |
|
394
|
|
|
$sql = "SELECT count(iid) AS number_of_users |
|
395
|
|
|
FROM $table |
|
396
|
|
|
WHERE |
|
397
|
|
|
c_id = $course_id AND |
|
398
|
|
|
group_id = '".intval($groupInfo['iid'])."'"; |
|
399
|
|
|
$result = Database::query($sql); |
|
400
|
|
|
$return = Database::fetch_array($result, 'ASSOC'); |
|
401
|
|
|
|
|
402
|
|
|
return $return['number_of_users']; |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
/** |
|
406
|
|
|
* Get the details of the users in a group. |
|
407
|
|
|
* |
|
408
|
|
|
* @param int $from starting row |
|
409
|
|
|
* @param int $number_of_items number of items to be displayed |
|
410
|
|
|
* @param int $column sorting colum |
|
411
|
|
|
* @param int $direction sorting direction |
|
412
|
|
|
* |
|
413
|
|
|
* @return array |
|
414
|
|
|
* |
|
415
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University, Belgium |
|
416
|
|
|
* |
|
417
|
|
|
* @version April 2008 |
|
418
|
|
|
*/ |
|
419
|
|
|
function get_group_user_data($from, $number_of_items, $column, $direction) |
|
420
|
|
|
{ |
|
421
|
|
|
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction; |
|
422
|
|
|
$groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
|
423
|
|
|
$course_id = api_get_course_int_id(); |
|
424
|
|
|
$column = (int) $column; |
|
425
|
|
|
|
|
426
|
|
|
if (empty($groupInfo) || empty($course_id)) { |
|
427
|
|
|
return 0; |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
// Database table definition |
|
431
|
|
|
$table_group_user = Database::get_course_table(TABLE_GROUP_USER); |
|
432
|
|
|
$table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
433
|
|
|
$tableGroup = Database::get_course_table(TABLE_GROUP); |
|
434
|
|
|
|
|
435
|
|
|
// Query |
|
436
|
|
|
if (api_get_setting('show_email_addresses') === 'true') { |
|
437
|
|
|
$sql = "SELECT user.id AS col0, |
|
438
|
|
|
".( |
|
439
|
|
|
api_is_western_name_order() ? |
|
440
|
|
|
"user.firstname AS col1, |
|
441
|
|
|
user.lastname AS col2," |
|
442
|
|
|
: |
|
443
|
|
|
"user.lastname AS col1, |
|
444
|
|
|
user.firstname AS col2," |
|
445
|
|
|
)." |
|
446
|
|
|
user.email AS col3 |
|
447
|
|
|
, user.active AS col4 |
|
448
|
|
|
FROM $table_user user |
|
449
|
|
|
INNER JOIN $table_group_user group_rel_user |
|
450
|
|
|
ON (group_rel_user.user_id = user.id) |
|
451
|
|
|
INNER JOIN $tableGroup g |
|
452
|
|
|
ON (group_rel_user.group_id = g.iid) |
|
453
|
|
|
WHERE |
|
454
|
|
|
group_rel_user.c_id = $course_id AND |
|
455
|
|
|
g.iid = '".$groupInfo['iid']."' |
|
456
|
|
|
ORDER BY col$column $direction |
|
457
|
|
|
LIMIT $from, $number_of_items"; |
|
458
|
|
|
} else { |
|
459
|
|
|
if (api_is_allowed_to_edit()) { |
|
460
|
|
|
$sql = "SELECT DISTINCT |
|
461
|
|
|
u.id AS col0, |
|
462
|
|
|
".(api_is_western_name_order() ? |
|
463
|
|
|
"u.firstname AS col1, |
|
464
|
|
|
u.lastname AS col2," |
|
465
|
|
|
: |
|
466
|
|
|
"u.lastname AS col1, |
|
467
|
|
|
u.firstname AS col2,")." |
|
468
|
|
|
u.email AS col3 |
|
469
|
|
|
, u.active AS col4 |
|
470
|
|
|
FROM $table_user u |
|
471
|
|
|
INNER JOIN $table_group_user gu |
|
472
|
|
|
ON (gu.user_id = u.id) |
|
473
|
|
|
INNER JOIN $tableGroup g |
|
474
|
|
|
ON (gu.group_id = g.iid) |
|
475
|
|
|
WHERE |
|
476
|
|
|
g.iid = '".$groupInfo['iid']."' AND |
|
477
|
|
|
gu.c_id = $course_id |
|
478
|
|
|
ORDER BY col$column $direction |
|
479
|
|
|
LIMIT $from, $number_of_items"; |
|
480
|
|
|
} else { |
|
481
|
|
|
$sql = "SELECT DISTINCT |
|
482
|
|
|
user.id AS col0, |
|
483
|
|
|
".( |
|
484
|
|
|
api_is_western_name_order() ? |
|
485
|
|
|
"user.firstname AS col1, |
|
486
|
|
|
user.lastname AS col2 " |
|
487
|
|
|
: |
|
488
|
|
|
"user.lastname AS col1, |
|
489
|
|
|
user.firstname AS col2 " |
|
490
|
|
|
)." |
|
491
|
|
|
, user.active AS col3 |
|
492
|
|
|
FROM $table_user user |
|
493
|
|
|
INNER JOIN $table_group_user group_rel_user |
|
494
|
|
|
ON (group_rel_user.user_id = user.id) |
|
495
|
|
|
INNER JOIN $tableGroup g |
|
496
|
|
|
ON (group_rel_user.group_id = g.iid) |
|
497
|
|
|
WHERE |
|
498
|
|
|
g.iid = '".$groupInfo['iid']."' AND |
|
499
|
|
|
group_rel_user.c_id = $course_id AND |
|
500
|
|
|
group_rel_user.user_id = user.id AND |
|
501
|
|
|
g.iid = '".$groupInfo['iid']."' |
|
502
|
|
|
ORDER BY col$column $direction |
|
503
|
|
|
LIMIT $from, $number_of_items"; |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
$return = []; |
|
508
|
|
|
$result = Database::query($sql); |
|
509
|
|
|
while ($row = Database::fetch_row($result)) { |
|
510
|
|
|
$return[] = $row; |
|
511
|
|
|
} |
|
512
|
|
|
|
|
513
|
|
|
return $return; |
|
514
|
|
|
} |
|
515
|
|
|
|
|
516
|
|
|
/** |
|
517
|
|
|
* Returns a mailto-link. |
|
518
|
|
|
* |
|
519
|
|
|
* @param string $email An email-address |
|
520
|
|
|
* |
|
521
|
|
|
* @return string HTML-code with a mailto-link |
|
522
|
|
|
*/ |
|
523
|
|
|
function email_filter($email) |
|
524
|
|
|
{ |
|
525
|
|
|
return Display::encrypted_mailto_link($email, $email); |
|
526
|
|
|
} |
|
527
|
|
|
|
|
528
|
|
|
function activeFilter($isActive) |
|
529
|
|
|
{ |
|
530
|
|
|
if ($isActive) { |
|
531
|
|
|
return Display::return_icon('accept.png', get_lang('Active'), [], ICON_SIZE_TINY); |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
|
return Display::return_icon('error.png', get_lang('Inactive'), [], ICON_SIZE_TINY); |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* Display a user icon that links to the user page. |
|
539
|
|
|
* |
|
540
|
|
|
* @param int $user_id the id of the user |
|
541
|
|
|
* |
|
542
|
|
|
* @return string code |
|
543
|
|
|
* |
|
544
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University, Belgium |
|
545
|
|
|
* |
|
546
|
|
|
* @version April 2008 |
|
547
|
|
|
*/ |
|
548
|
|
|
function user_icon_filter($user_id) |
|
549
|
|
|
{ |
|
550
|
|
|
$userInfo = api_get_user_info($user_id); |
|
551
|
|
|
$photo = '<img src="'.$userInfo['avatar'].'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
552
|
|
|
|
|
553
|
|
|
return Display::url($photo, $userInfo['profile_url']); |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
/** |
|
557
|
|
|
* Return user profile link around the given user name. |
|
558
|
|
|
* |
|
559
|
|
|
* The parameters use a trick of the sorteable table, where the first param is |
|
560
|
|
|
* the original value of the column |
|
561
|
|
|
* |
|
562
|
|
|
* @param string User name (value of the column at the time of calling) |
|
563
|
|
|
* @param string URL parameters |
|
564
|
|
|
* @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there |
|
565
|
|
|
* |
|
566
|
|
|
* @return string HTML link |
|
567
|
|
|
*/ |
|
568
|
|
|
function user_name_filter($name, $url_params, $row) |
|
569
|
|
|
{ |
|
570
|
|
|
$userInfo = api_get_user_info($row[0]); |
|
571
|
|
|
|
|
572
|
|
|
return UserManager::getUserProfileLink($userInfo); |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
if ($origin != 'learnpath') { |
|
576
|
|
|
Display::display_footer(); |
|
577
|
|
|
} |
|
578
|
|
|
|