1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | use Chamilo\CoreBundle\Entity\UserRelUser; |
||
6 | use Chamilo\UserBundle\Entity\User; |
||
7 | |||
8 | /** |
||
9 | * Script showing information about a user (name, e-mail, courses and sessions). |
||
10 | * |
||
11 | * @author Bart Mollet |
||
12 | */ |
||
13 | $cidReset = true; |
||
14 | require_once __DIR__.'/../inc/global.inc.php'; |
||
15 | $this_section = SECTION_PLATFORM_ADMIN; |
||
16 | require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
||
17 | require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; |
||
18 | |||
19 | $userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0; |
||
20 | |||
21 | if (empty($userId)) { |
||
22 | api_not_allowed(true); |
||
23 | } |
||
24 | $user = api_get_user_info($userId, true); |
||
25 | |||
26 | if (empty($user)) { |
||
27 | api_not_allowed(true); |
||
28 | } |
||
29 | $tpl = new Template(null, false, false, false, false, false, false); |
||
30 | /** @var User $userEntity */ |
||
31 | $userEntity = api_get_user_entity($user['user_id']); |
||
32 | $myUserId = api_get_user_id(); |
||
33 | |||
34 | if (!api_is_student_boss()) { |
||
35 | api_protect_admin_script(true); |
||
36 | } else { |
||
37 | $isBoss = UserManager::userIsBossOfStudent($myUserId, $user['user_id']); |
||
38 | if (!$isBoss) { |
||
39 | api_not_allowed(true); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; |
||
44 | $interbreadcrumb[] = ['url' => 'user_list.php', 'name' => get_lang('UserList')]; |
||
45 | $userId = $user['user_id']; |
||
46 | $currentUrl = api_get_self().'?user_id='.$userId; |
||
47 | $tool_name = UserManager::formatUserFullName($userEntity); |
||
48 | $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
||
49 | $table_course = Database::get_main_table(TABLE_MAIN_COURSE); |
||
50 | $csvContent = []; |
||
51 | |||
52 | // only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) |
||
53 | $actions = [ |
||
54 | Display::url( |
||
55 | Display::return_icon( |
||
56 | 'statistics.png', |
||
57 | get_lang('Reporting'), |
||
58 | [], |
||
59 | ICON_SIZE_MEDIUM |
||
60 | ), |
||
61 | api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?'.http_build_query([ |
||
62 | 'student' => $userId, |
||
63 | ]), |
||
64 | ['title' => get_lang('Reporting')] |
||
65 | ), |
||
66 | ]; |
||
67 | |||
68 | if (api_can_login_as($userId)) { |
||
69 | $actions[] = Display::url( |
||
70 | Display::return_icon( |
||
71 | 'login_as.png', |
||
72 | get_lang('LoginAs'), |
||
73 | [], |
||
74 | ICON_SIZE_MEDIUM |
||
75 | ), |
||
76 | api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$userId.'&sec_token='.Security::getTokenFromSession() |
||
77 | ); |
||
78 | } |
||
79 | |||
80 | if (api_is_platform_admin()) { |
||
81 | $actions[] = Display::url( |
||
82 | Display::return_icon( |
||
83 | 'edit.png', |
||
84 | get_lang('Edit'), |
||
85 | [], |
||
86 | ICON_SIZE_MEDIUM |
||
87 | ), |
||
88 | api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$userId |
||
89 | ); |
||
90 | |||
91 | $actions[] = Display::url( |
||
92 | Display::return_icon( |
||
93 | 'export_csv.png', |
||
94 | get_lang('ExportAsCSV'), |
||
95 | [], |
||
96 | ICON_SIZE_MEDIUM |
||
97 | ), |
||
98 | api_get_self().'?user_id='.$userId.'&action=export' |
||
99 | ); |
||
100 | $actions[] = Display::url( |
||
101 | Display::return_icon( |
||
102 | 'vcard.png', |
||
103 | get_lang('UserInfo'), |
||
104 | [], |
||
105 | ICON_SIZE_MEDIUM |
||
106 | ), |
||
107 | api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.$userId |
||
108 | ); |
||
109 | $actions[] = Display::url( |
||
110 | Display::return_icon('new_group.png', get_lang('AddHrmToUser'), [], ICON_SIZE_MEDIUM), |
||
111 | api_get_path(WEB_CODE_PATH).'admin/add_drh_to_user.php?u='.$userId |
||
112 | ); |
||
113 | |||
114 | if (Skill::isAllowed($userId, false)) { |
||
115 | $actions[] = Display::url( |
||
116 | Display::return_icon( |
||
117 | 'skill-badges.png', |
||
118 | get_lang('AddSkill'), |
||
119 | [], |
||
120 | ICON_SIZE_MEDIUM, |
||
121 | false |
||
122 | ), |
||
123 | api_get_path(WEB_CODE_PATH).'badge/assign.php?user='.$userId |
||
124 | ); |
||
125 | } |
||
126 | } |
||
127 | $userInfo = null; |
||
128 | $studentBossList = UserManager::getStudentBossList($userId); |
||
129 | $studentBossListToString = ''; |
||
130 | if (!empty($studentBossList)) { |
||
131 | $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']); |
||
132 | $table->setHeaderContents(0, 0, get_lang('User')); |
||
133 | $csvContent[] = [get_lang('StudentBoss')]; |
||
134 | |||
135 | $row = 1; |
||
136 | foreach ($studentBossList as $studentBossId) { |
||
137 | $studentBoss = api_get_user_info($studentBossId['boss_id']); |
||
138 | $table->setCellContents($row, 0, $studentBoss['complete_name_with_message_link']); |
||
139 | $csvContent[] = [$studentBoss['complete_name_with_username']]; |
||
140 | $row++; |
||
141 | } |
||
142 | $studentBossListToString = $table->toHtml(); |
||
143 | } |
||
144 | |||
145 | $registrationDate = $user['registration_date']; |
||
146 | |||
147 | $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']); |
||
148 | $table->setHeaderContents(0, 0, get_lang('Information')); |
||
149 | |||
150 | $csvContent[] = [get_lang('Information')]; |
||
151 | $data = [ |
||
152 | get_lang('Name') => $user['complete_name'], |
||
153 | get_lang('Email') => $user['email'], |
||
154 | get_lang('Phone') => $user['phone'], |
||
155 | get_lang('OfficialCode') => $user['official_code'], |
||
156 | get_lang('Online') => !empty($user['user_is_online']) ? Display::return_icon('online.png') : Display::return_icon('offline.png'), |
||
157 | get_lang('Status') => $user['status'] == 1 ? get_lang('Teacher') : get_lang('Student'), |
||
158 | ]; |
||
159 | |||
160 | $userInfo = [ |
||
161 | 'complete_name' => $user['complete_name'], |
||
162 | 'email' => $user['email'], |
||
163 | 'phone' => $user['phone'], |
||
164 | 'official_code' => $user['official_code'], |
||
165 | 'user_is_online' => !empty($user['user_is_online']) ? Display::return_icon('online.png') : Display::return_icon('offline.png'), |
||
166 | 'status' => $user['status'] == 1 ? get_lang('Teacher') : get_lang('Student'), |
||
167 | 'avatar' => $user['avatar'], |
||
168 | ]; |
||
169 | |||
170 | // Show info about who created this user and when |
||
171 | $creatorId = $user['creator_id']; |
||
172 | $creatorInfo = api_get_user_info($creatorId); |
||
173 | if (!empty($creatorId) && !empty($creatorInfo)) { |
||
174 | $userInfo['created'] = sprintf( |
||
175 | get_lang('CreatedByXYOnZ'), |
||
176 | 'user_information.php?user_id='.$creatorId, |
||
177 | $creatorInfo['username'], |
||
178 | api_get_utc_datetime($registrationDate) |
||
179 | ); |
||
180 | } |
||
181 | |||
182 | $row = 1; |
||
183 | foreach ($data as $label => $item) { |
||
184 | if (!empty($label)) { |
||
185 | $label = $label.': '; |
||
186 | } |
||
187 | $table->setCellContents($row, 0, $label.$item); |
||
188 | $csvContent[] = [$label, strip_tags($item)]; |
||
189 | $row++; |
||
190 | } |
||
191 | |||
192 | $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']); |
||
193 | $table->setHeaderContents(0, 0, get_lang('Tracking')); |
||
194 | $csvContent[] = [get_lang('Tracking')]; |
||
195 | $userInfo['first_connection'] = Tracking::get_first_connection_date($userId); |
||
196 | $userInfo['last_connection'] = Tracking::get_last_connection_date($userId, true); |
||
197 | $userInfo['last_connection_in_course'] = api_format_date( |
||
198 | Tracking::getLastConnectionInAnyCourse($userId), |
||
199 | DATE_FORMAT_SHORT |
||
200 | ); |
||
201 | $data = [ |
||
202 | get_lang('FirstLogin') => $userInfo['first_connection'], |
||
203 | get_lang('LatestLogin') => $userInfo['last_connection'], |
||
204 | get_lang('LatestLoginInAnyCourse') => $userInfo['last_connection_in_course'], |
||
205 | ]; |
||
206 | |||
207 | if (api_get_setting('allow_terms_conditions') === 'true') { |
||
208 | $extraFieldValue = new ExtraFieldValue('user'); |
||
209 | $value = $extraFieldValue->get_values_by_handler_and_field_variable( |
||
210 | $userId, |
||
211 | 'legal_accept' |
||
212 | ); |
||
213 | $icon = Display::return_icon('accept_na.png'); |
||
214 | if (!empty($value['value'])) { |
||
215 | list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']); |
||
216 | $icon = Display::return_icon('accept.png'); |
||
217 | $timeLegalAccept = api_get_local_time($legalTime); |
||
218 | $btn = Display::url( |
||
219 | get_lang('DeleteLegal'), |
||
220 | api_get_self().'?action=delete_legal&user_id='.$userId, |
||
221 | ['class' => 'btn btn-danger btn-xs'] |
||
222 | ); |
||
223 | } else { |
||
224 | $btn = Display::url( |
||
225 | get_lang('SendLegal'), |
||
226 | api_get_self().'?action=send_legal&user_id='.$userId, |
||
227 | ['class' => 'btn btn-primary btn-xs'] |
||
228 | ); |
||
229 | $timeLegalAccept = get_lang('NotRegistered'); |
||
230 | } |
||
231 | |||
232 | $data[get_lang('LegalAccepted')] = $icon; |
||
233 | $userInfo['legal'] = [ |
||
234 | 'icon' => $icon, |
||
235 | 'datetime' => $timeLegalAccept, |
||
236 | 'url_send' => $btn, |
||
237 | ]; |
||
238 | } |
||
239 | $row = 1; |
||
240 | foreach ($data as $label => $item) { |
||
241 | if (!empty($label)) { |
||
242 | $label = $label.': '; |
||
243 | } |
||
244 | $table->setCellContents($row, 0, $label.$item); |
||
245 | $csvContent[] = [$label, strip_tags($item)]; |
||
246 | $row++; |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Show social activity. |
||
251 | */ |
||
252 | if (api_get_setting('allow_social_tool') === 'true') { |
||
253 | $userObject = api_get_user_entity($userId); |
||
254 | $data = []; |
||
255 | // Calculate values |
||
256 | if (api_get_setting('allow_message_tool') === 'true') { |
||
257 | $messagesSent = SocialManager::getCountMessagesSent($userId); |
||
258 | $data[] = [get_lang('MessagesSent'), $messagesSent]; |
||
259 | $messagesReceived = SocialManager::getCountMessagesReceived($userId); |
||
260 | $data[] = [get_lang('MessagesReceived'), $messagesReceived]; |
||
261 | } |
||
262 | $wallMessagesPosted = SocialManager::getCountWallPostedMessages($userId); |
||
263 | $data[] = [get_lang('WallMessagesPosted'), $wallMessagesPosted]; |
||
264 | |||
265 | $friends = SocialManager::getCountFriends($userId); |
||
266 | $data[] = [get_lang('Friends'), $friends]; |
||
267 | |||
268 | $countSent = SocialManager::getCountInvitationSent($userId); |
||
269 | $data[] = [get_lang('InvitationSent'), $countSent]; |
||
270 | |||
271 | $countReceived = SocialManager::get_message_number_invitation_by_user_id($userId); |
||
272 | $data[] = [get_lang('InvitationReceived'), $countReceived]; |
||
273 | |||
274 | $userInfo['social'] = [ |
||
275 | 'friends' => $friends, |
||
276 | 'invitation_sent' => $countSent, |
||
277 | 'invitation_received' => $countReceived, |
||
278 | 'messages_posted' => $wallMessagesPosted, |
||
279 | 'message_sent' => $messagesSent, |
||
280 | 'message_received' => $messagesReceived, |
||
281 | ]; |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * Show the sessions in which this user is subscribed. |
||
286 | */ |
||
287 | $sessions = SessionManager::get_sessions_by_user($userId, true); |
||
288 | $personal_course_list = []; |
||
289 | $sessionInformation = ''; |
||
290 | if (count($sessions) > 0) { |
||
291 | $header = [ |
||
292 | [get_lang('Code'), true], |
||
293 | [get_lang('Title'), true], |
||
294 | [get_lang('Status'), true], |
||
295 | [get_lang('TimeSpentInTheCourse'), true], |
||
296 | [get_lang('TotalPostsInAllForums'), true], |
||
297 | ['', false], |
||
298 | ]; |
||
299 | |||
300 | $headerList = []; |
||
301 | foreach ($header as $item) { |
||
302 | $headerList[] = $item[0]; |
||
303 | } |
||
304 | |||
305 | $csvContent[] = []; |
||
306 | $csvContent[] = [get_lang('Sessions')]; |
||
307 | |||
308 | foreach ($sessions as $session_item) { |
||
309 | $data = []; |
||
310 | $personal_course_list = []; |
||
311 | $id_session = $session_item['session_id']; |
||
312 | $csvContent[] = [$session_item['session_name']]; |
||
313 | $csvContent[] = $headerList; |
||
314 | $courseToolInformationTotal = ''; |
||
315 | foreach ($session_item['courses'] as $my_course) { |
||
316 | $courseInfo = api_get_course_info_by_id($my_course['real_id']); |
||
317 | $sessionStatus = SessionManager::get_user_status_in_course_session( |
||
318 | $userId, |
||
319 | $courseInfo['real_id'], |
||
320 | $id_session |
||
321 | ); |
||
322 | $status = null; |
||
323 | switch ($sessionStatus) { |
||
324 | case 0: |
||
325 | case STUDENT: |
||
326 | $status = get_lang('Student'); |
||
327 | break; |
||
328 | case 2: |
||
329 | $status = get_lang('CourseCoach'); |
||
330 | break; |
||
331 | } |
||
332 | |||
333 | $tools = Display::url( |
||
334 | Display::return_icon('statistics.png', get_lang('Stats')), |
||
335 | api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?details=true&student='.$userId.'&id_session='.$id_session.'&course='.$courseInfo['code'] |
||
336 | ); |
||
337 | $tools .= ' <a href="course_information.php?code='.$courseInfo['code'].'&id_session='.$id_session.'">'. |
||
338 | Display::return_icon('info2.png', get_lang('Overview')).'</a>'. |
||
339 | '<a href="'.$courseInfo['course_public_url'].'?id_session='.$id_session.'">'. |
||
340 | Display::return_icon('course_home.png', get_lang('CourseHomepage')).'</a>'; |
||
341 | |||
342 | if (!empty($my_course['status']) && $my_course['status'] == STUDENT) { |
||
343 | $tools .= '<a |
||
344 | href="user_information.php?action=unsubscribe_session_course&course_id='.$courseInfo['real_id'].'&user_id='.$userId.'&id_session='.$id_session.'">'. |
||
345 | Display::return_icon('delete.png', get_lang('Delete')).'</a>'; |
||
346 | } |
||
347 | |||
348 | $timeSpent = api_time_to_hms( |
||
349 | Tracking::get_time_spent_on_the_course( |
||
350 | $userId, |
||
351 | $courseInfo['real_id'], |
||
352 | $id_session |
||
353 | ) |
||
354 | ); |
||
355 | |||
356 | $totalForumMessages = CourseManager::getCountPostInForumPerUser( |
||
357 | $userId, |
||
358 | $courseInfo['real_id'], |
||
359 | $id_session |
||
360 | ); |
||
361 | |||
362 | $row = [ |
||
363 | Display::url( |
||
364 | $courseInfo['code'], |
||
365 | $courseInfo['course_public_url'].'?id_session='.$id_session |
||
366 | ), |
||
367 | $courseInfo['title'], |
||
368 | $status, |
||
369 | $timeSpent, |
||
370 | $totalForumMessages, |
||
371 | $tools, |
||
372 | ]; |
||
373 | |||
374 | $csvContent[] = array_map('strip_tags', $row); |
||
375 | $data[] = $row; |
||
376 | |||
377 | $result = Tracking::getToolInformation( |
||
378 | $userId, |
||
379 | $courseInfo, |
||
380 | $id_session |
||
381 | ); |
||
382 | |||
383 | if (!empty($result['html'])) { |
||
384 | $courseToolInformationTotal .= $result['html']; |
||
385 | $csvContent = array_merge($csvContent, $result['array']); |
||
386 | } |
||
387 | } |
||
388 | |||
389 | $dates = array_filter( |
||
390 | [$session_item['access_start_date'], $session_item['access_end_date']] |
||
391 | ); |
||
392 | $certificateLink = Display::url( |
||
393 | Display::return_icon('pdf.png', get_lang('CertificateOfAchievement'), [], ICON_SIZE_SMALL), |
||
394 | api_get_path(WEB_CODE_PATH).'mySpace/session.php?' |
||
395 | .http_build_query( |
||
396 | [ |
||
397 | 'action' => 'export_to_pdf', |
||
398 | 'type' => 'achievement', |
||
399 | 'session_to_export' => $id_session, |
||
400 | 'student' => $userId, |
||
401 | ] |
||
402 | ), |
||
403 | ['target' => '_blank'] |
||
404 | ); |
||
405 | $sessionInformation .= Display::page_subheader( |
||
406 | '<a href="'.api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$id_session.'">'. |
||
407 | $session_item['session_name'].'</a>', |
||
408 | $certificateLink.' '.implode(' - ', $dates) |
||
409 | ); |
||
410 | $sessionInformation .= Display::return_sortable_table( |
||
411 | $header, |
||
412 | $data, |
||
413 | [], |
||
414 | [], |
||
415 | ['user_id' => $userId] |
||
416 | ); |
||
417 | $sessionInformation .= $courseToolInformationTotal; |
||
418 | } |
||
419 | } else { |
||
420 | $sessionInformation = '<p>'.get_lang('NoSessionsForThisUser').'</p>'; |
||
421 | } |
||
422 | |||
423 | /** |
||
424 | * Show the courses in which this user is subscribed. |
||
425 | */ |
||
426 | $sql = 'SELECT * FROM '.$table_course_user.' cu, '.$table_course.' c |
||
427 | WHERE |
||
428 | cu.user_id = '.$userId.' AND |
||
429 | cu.c_id = c.id AND |
||
430 | cu.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' '; |
||
431 | $res = Database::query($sql); |
||
432 | if (Database::num_rows($res) > 0) { |
||
433 | $header = [ |
||
434 | [get_lang('Code')], |
||
435 | [get_lang('Title')], |
||
436 | [get_lang('Status')], |
||
437 | [get_lang('TimeSpentInTheCourse')], |
||
438 | [get_lang('TotalPostsInAllForums')], |
||
439 | [''], |
||
440 | ]; |
||
441 | |||
442 | $headerList = []; |
||
443 | foreach ($header as $item) { |
||
444 | $headerList[] = $item[0]; |
||
445 | } |
||
446 | $csvContent[] = []; |
||
447 | $csvContent[] = [get_lang('Courses')]; |
||
448 | $csvContent[] = $headerList; |
||
449 | |||
450 | $data = []; |
||
451 | $courseToolInformationTotal = ''; |
||
452 | while ($course = Database::fetch_object($res)) { |
||
453 | $courseInfo = api_get_course_info_by_id($course->c_id); |
||
454 | $courseCode = $courseInfo['code']; |
||
455 | $courseToolInformation = null; |
||
456 | |||
457 | $tools = Display::url( |
||
458 | Display::return_icon('statistics.png', get_lang('Stats')), |
||
459 | api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?details=true&student='.$userId.'&id_session=0&course='.$courseCode |
||
460 | ); |
||
461 | |||
462 | $tools .= ' <a href="course_information.php?code='.$courseCode.'">'. |
||
463 | Display::return_icon('info2.png', get_lang('Overview')).'</a>'. |
||
464 | '<a href="'.$courseInfo['course_public_url'].'">'. |
||
465 | Display::return_icon('course_home.png', get_lang('CourseHomepage')).'</a>'. |
||
466 | '<a href="course_edit.php?id='.$course->c_id.'">'. |
||
467 | Display::return_icon('edit.png', get_lang('Edit')).'</a>'; |
||
468 | if ($course->status == STUDENT) { |
||
469 | $tools .= '<a href="user_information.php?action=unsubscribe&course_id='.$courseInfo['real_id'].'&user_id='.$userId.'">'. |
||
470 | Display::return_icon('delete.png', get_lang('Delete')).'</a>'; |
||
471 | } |
||
472 | |||
473 | $timeSpent = api_time_to_hms( |
||
474 | Tracking::get_time_spent_on_the_course( |
||
475 | $userId, |
||
476 | $courseInfo['real_id'] |
||
477 | ) |
||
478 | ); |
||
479 | |||
480 | $totalForumMessages = CourseManager::getCountPostInForumPerUser( |
||
481 | $userId, |
||
482 | $course->id, |
||
483 | 0 |
||
484 | ); |
||
485 | |||
486 | $row = [ |
||
487 | Display::url($courseCode, $courseInfo['course_public_url']), |
||
488 | $course->title, |
||
489 | $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher'), |
||
490 | $timeSpent, |
||
491 | $totalForumMessages, |
||
492 | $tools, |
||
493 | ]; |
||
494 | |||
495 | $csvContent[] = array_map('strip_tags', $row); |
||
496 | $data[] = $row; |
||
497 | |||
498 | $result = Tracking::getToolInformation( |
||
499 | $userId, |
||
500 | $courseInfo, |
||
501 | 0 |
||
502 | ); |
||
503 | $courseToolInformationTotal .= $result['html']; |
||
504 | $csvContent = array_merge($csvContent, $result['array']); |
||
505 | } |
||
506 | |||
507 | $courseInformation = Display::return_sortable_table( |
||
508 | $header, |
||
509 | $data, |
||
510 | [], |
||
511 | [], |
||
512 | ['user_id' => $userId] |
||
513 | ); |
||
514 | $courseInformation .= $courseToolInformationTotal; |
||
515 | } else { |
||
516 | $courseInformation = '<p>'.get_lang('NoCoursesForThisUser').'</p>'; |
||
517 | } |
||
518 | |||
519 | /** |
||
520 | * Show the URL in which this user is subscribed. |
||
521 | */ |
||
522 | $urlInformation = ''; |
||
523 | if (api_is_multiple_url_enabled()) { |
||
524 | $urlList = UrlManager::get_access_url_from_user($userId); |
||
525 | if (count($urlList) > 0) { |
||
526 | $header = []; |
||
527 | $header[] = ['URL', true]; |
||
528 | $data = []; |
||
529 | |||
530 | $csvContent[] = []; |
||
531 | $csvContent[] = ['Url']; |
||
532 | foreach ($urlList as $url) { |
||
533 | $row = []; |
||
534 | $row[] = Display::url($url['url'], $url['url']); |
||
535 | $csvContent[] = array_map('strip_tags', $row); |
||
536 | $data[] = $row; |
||
537 | } |
||
538 | |||
539 | $urlInformation = Display::page_subheader(get_lang('URLList')); |
||
540 | $urlInformation .= Display::return_sortable_table( |
||
541 | $header, |
||
542 | $data, |
||
543 | [], |
||
544 | [], |
||
545 | ['user_id' => $userId] |
||
546 | ); |
||
547 | } else { |
||
548 | $urlInformation = '<p>'.get_lang('NoUrlForThisUser').'</p>'; |
||
549 | } |
||
550 | } |
||
551 | |||
552 | if (isset($_GET['action'])) { |
||
553 | switch ($_GET['action']) { |
||
554 | case 'send_legal': |
||
555 | $subject = get_lang('SendLegalSubject'); |
||
556 | $content = sprintf( |
||
557 | get_lang('SendLegalDescriptionToUrlX'), |
||
558 | api_get_path(WEB_PATH) |
||
559 | ); |
||
560 | MessageManager::send_message_simple($userId, $subject, $content); |
||
561 | Display::addFlash(Display::return_message(get_lang('Sent'))); |
||
562 | break; |
||
563 | case 'delete_legal': |
||
564 | $extraFieldValue = new ExtraFieldValue('user'); |
||
565 | $value = $extraFieldValue->get_values_by_handler_and_field_variable( |
||
566 | $userId, |
||
567 | 'legal_accept' |
||
568 | ); |
||
569 | $result = $extraFieldValue->delete($value['id']); |
||
570 | if ($result) { |
||
571 | Display::addFlash(Display::return_message(get_lang('Deleted'))); |
||
572 | } |
||
573 | break; |
||
574 | case 'unsubscribe': |
||
575 | $courseId = !empty($_GET['course_id']) ? (int) $_GET['course_id'] : 0; |
||
576 | $sessionId = !empty($_GET['id_session']) ? (int) $_GET['id_session'] : 0; |
||
577 | $courseInfo = api_get_course_info_by_id($courseId); |
||
578 | if (empty($courseInfo)) { |
||
579 | break; |
||
580 | } |
||
581 | |||
582 | if (CourseManager::getUserInCourseStatus($userId, $courseInfo['real_id']) == STUDENT) { |
||
583 | CourseManager::unsubscribe_user($userId, $courseInfo['code'], $sessionId); |
||
584 | Display::addFlash(Display::return_message(get_lang('UserUnsubscribed'))); |
||
585 | } else { |
||
586 | Display::addFlash(Display::return_message( |
||
587 | get_lang('CannotUnsubscribeUserFromCourse'), |
||
588 | 'error', |
||
589 | false |
||
590 | )); |
||
591 | } |
||
592 | header('Location: '.$currentUrl); |
||
593 | exit; |
||
594 | break; |
||
595 | case 'unsubscribe_session_course': |
||
596 | $courseId = !empty($_GET['course_id']) ? (int) $_GET['course_id'] : 0; |
||
597 | $sessionId = !empty($_GET['id_session']) ? (int) $_GET['id_session'] : 0; |
||
598 | |||
599 | SessionManager::removeUsersFromCourseSession( |
||
600 | [$userId], |
||
601 | $sessionId, |
||
602 | api_get_course_info_by_id($courseId) |
||
603 | ); |
||
604 | Display::addFlash(Display::return_message(get_lang('UserUnsubscribed'))); |
||
605 | header('Location: '.$currentUrl); |
||
606 | exit; |
||
607 | break; |
||
608 | case 'export': |
||
609 | Export::arrayToCsv( |
||
610 | $csvContent, |
||
611 | 'user_information_'.$userId |
||
612 | ); |
||
613 | exit; |
||
614 | break; |
||
615 | } |
||
616 | } |
||
617 | |||
618 | Display::display_header($tool_name); |
||
619 | echo Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $actions)]); |
||
620 | |||
621 | $fullUrlBig = UserManager::getUserPicture( |
||
622 | $userId, |
||
623 | USER_IMAGE_SIZE_BIG |
||
624 | ); |
||
625 | |||
626 | $fullUrl = UserManager::getUserPicture( |
||
627 | $userId, |
||
628 | USER_IMAGE_SIZE_ORIGINAL |
||
629 | ); |
||
630 | |||
631 | if ($studentBossList) { |
||
632 | echo Display::page_subheader(get_lang('StudentBossList')); |
||
633 | echo $studentBossListToString; |
||
634 | } |
||
635 | |||
636 | $em = Database::getManager(); |
||
637 | $userRepository = UserManager::getRepository(); |
||
638 | |||
639 | $hrmList = $userRepository->getAssignedHrmUserList( |
||
640 | $userEntity->getId(), |
||
641 | api_get_current_access_url_id() |
||
642 | ); |
||
643 | |||
644 | if ($hrmList) { |
||
0 ignored issues
–
show
|
|||
645 | echo Display::page_subheader(get_lang('HrmList')); |
||
646 | echo '<div class="row">'; |
||
647 | |||
648 | /** @var UserRelUser $hrm */ |
||
649 | foreach ($hrmList as $hrm) { |
||
650 | $hrmInfo = api_get_user_info($hrm->getFriendUserId()); |
||
651 | |||
652 | $userPicture = isset($hrmInfo['avatar_medium']) ? $hrmInfo['avatar_medium'] : $hrmInfo['avatar']; |
||
653 | echo '<div class="col-sm-4 col-md-3">'; |
||
654 | echo '<div class="media">'; |
||
655 | echo '<div class="media-left">'; |
||
656 | echo Display::img($userPicture, $hrmInfo['complete_name'], ['class' => 'media-object'], false); |
||
657 | echo '</div>'; |
||
658 | echo '<div class="media-body">'; |
||
659 | echo '<h4 class="media-heading">'.$hrmInfo['complete_name_with_message_link'].'</h4>'; |
||
660 | echo $hrmInfo['username']; |
||
661 | echo '</div>'; |
||
662 | echo '</div>'; |
||
663 | echo '</div>'; |
||
664 | } |
||
665 | echo '</div>'; |
||
666 | } |
||
667 | |||
668 | if (DRH == $user['status']) { |
||
669 | $usersAssigned = UserManager::get_users_followed_by_drh($userId); |
||
670 | |||
671 | if ($usersAssigned) { |
||
672 | echo Display::page_subheader(get_lang('AssignedUsersListToHumanResourcesManager')); |
||
673 | echo '<div class="row">'; |
||
674 | foreach ($usersAssigned as $userAssigned) { |
||
675 | $userAssigned = api_get_user_info($userAssigned['user_id']); |
||
676 | $userPicture = isset($userAssigned['avatar_medium']) ? $userAssigned['avatar_medium'] : $userAssigned['avatar']; |
||
677 | |||
678 | echo '<div class="col-sm-4 col-md-3">'; |
||
679 | echo '<div class="media">'; |
||
680 | echo '<div class="media-left">'; |
||
681 | echo Display::img($userPicture, $userAssigned['complete_name'], ['class' => 'media-object'], false); |
||
682 | echo '</div>'; |
||
683 | echo '<div class="media-body">'; |
||
684 | echo '<h4 class="media-heading">'.$userAssigned['complete_name_with_message_link'].'</h4>'; |
||
685 | echo $userAssigned['official_code']; |
||
686 | echo '</div>'; |
||
687 | echo '</div>'; |
||
688 | echo '</div>'; |
||
689 | } |
||
690 | echo '</div>'; |
||
691 | } |
||
692 | } |
||
693 | $socialTool = api_get_setting('allow_social_tool'); |
||
694 | $tpl->assign('social_tool', $socialTool); |
||
695 | $tpl->assign('user', $userInfo); |
||
696 | $layoutTemplate = $tpl->get_template('admin/user_information.tpl'); |
||
697 | $content = $tpl->fetch($layoutTemplate); |
||
698 | echo $content; |
||
699 | if (api_get_configuration_value('allow_career_users')) { |
||
700 | if (!empty($sessions)) { |
||
701 | $sessions = array_column($sessions, 'session_id'); |
||
702 | echo SessionManager::getCareerDiagramPerSessionList($sessions, $userId); |
||
703 | } |
||
704 | echo MyStudents::userCareersTable($userId); |
||
705 | } |
||
706 | |||
707 | echo Display::page_subheader(get_lang('SessionList'), null, 'h3', ['class' => 'section-title']); |
||
708 | echo $sessionInformation; |
||
709 | |||
710 | echo Display::page_subheader(get_lang('CourseList'), null, 'h3', ['class' => 'section-title']); |
||
711 | echo $courseInformation; |
||
712 | echo $urlInformation; |
||
713 | |||
714 | echo Tracking::displayUserSkills( |
||
715 | $userId, |
||
716 | 0, |
||
717 | 0 |
||
718 | ); |
||
719 | |||
720 | Display::display_footer(); |
||
721 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.