1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | use Chamilo\CourseBundle\Entity\CForumPost; |
||
5 | |||
6 | /** |
||
7 | * These files are a complete rework of the forum. The database structure is |
||
8 | * based on phpBB but all the code is rewritten. A lot of new functionalities |
||
9 | * are added: |
||
10 | * - forum categories and forums can be sorted up or down, locked or made invisible |
||
11 | * - consistent and integrated forum administration |
||
12 | * - forum options: are students allowed to edit their post? |
||
13 | * moderation of posts (approval) |
||
14 | * reply only forums (students cannot create new threads) |
||
15 | * multiple forums per group |
||
16 | * - sticky messages |
||
17 | * - new view option: nested view |
||
18 | * - quoting a message. |
||
19 | * |
||
20 | * @Author Patrick Cool <[email protected]>, Ghent University |
||
21 | * @Copyright Ghent University |
||
22 | * @Copyright Patrick Cool |
||
23 | * |
||
24 | * @package chamilo.forum |
||
25 | */ |
||
26 | require_once __DIR__.'/../inc/global.inc.php'; |
||
27 | $current_course_tool = TOOL_FORUM; |
||
28 | |||
29 | // Notification for unauthorized people. |
||
30 | api_protect_course_script(true); |
||
31 | api_protect_course_group(GroupManager::GROUP_TOOL_FORUM); |
||
32 | |||
33 | // The section (tabs). |
||
34 | $this_section = SECTION_COURSES; |
||
35 | $nameTools = get_lang('ToolForum'); |
||
36 | |||
37 | // Are we in a lp ? |
||
38 | $origin = api_get_origin(); |
||
39 | |||
40 | require_once 'forumfunction.inc.php'; |
||
41 | |||
42 | $userId = api_get_user_id(); |
||
43 | $sessionId = api_get_session_id(); |
||
44 | $groupId = api_get_group_id(); |
||
45 | $courseId = api_get_course_int_id(); |
||
46 | $groupInfo = GroupManager::get_group_properties($groupId); |
||
47 | $isTutor = GroupManager::is_tutor_of_group($userId, $groupInfo, $courseId); |
||
48 | $isAllowedToEdit = api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true); |
||
49 | |||
50 | /* MAIN DISPLAY SECTION */ |
||
51 | |||
52 | $my_forum = isset($_GET['forum']) ? (int) $_GET['forum'] : ''; |
||
53 | // Note: This has to be validated that it is an existing forum. |
||
54 | $current_forum = get_forum_information($my_forum); |
||
55 | $isForumOpenByDateAccess = api_is_date_in_date_range($current_forum['start_time'], $current_forum['end_time']); |
||
56 | |||
57 | if (!$isForumOpenByDateAccess && !$isAllowedToEdit) { |
||
58 | if ($origin) { |
||
59 | api_not_allowed(true); |
||
60 | } else { |
||
61 | api_not_allowed(true); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | if (empty($current_forum)) { |
||
66 | api_not_allowed(); |
||
67 | } |
||
68 | |||
69 | $current_forum_category = get_forumcategory_information($current_forum['forum_category']); |
||
70 | $is_group_tutor = false; |
||
71 | |||
72 | if (!empty($groupId)) { |
||
73 | //Group info & group category info |
||
74 | $group_properties = GroupManager::get_group_properties($groupId); |
||
75 | $is_group_tutor = GroupManager::is_tutor_of_group( |
||
76 | api_get_user_id(), |
||
77 | $group_properties |
||
78 | ); |
||
79 | |||
80 | // Course |
||
81 | if (!api_is_allowed_to_edit(false, true) && //is a student |
||
82 | ( |
||
83 | ($current_forum_category && $current_forum_category['visibility'] == 0) || |
||
84 | $current_forum['visibility'] == 0 |
||
85 | ) |
||
86 | ) { |
||
87 | api_not_allowed(true); |
||
88 | } |
||
89 | } else { |
||
90 | // Course |
||
91 | if (!api_is_allowed_to_edit(false, true) && ( |
||
92 | ($current_forum_category && $current_forum_category['visibility'] == 0) || |
||
93 | $current_forum['visibility'] == 0 |
||
94 | ) //forum category or forum visibility is false |
||
95 | ) { |
||
96 | api_not_allowed(true); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | /* Header and Breadcrumbs */ |
||
101 | $my_search = isset($_GET['search']) ? $_GET['search'] : ''; |
||
102 | $my_action = isset($_GET['action']) ? $_GET['action'] : ''; |
||
103 | |||
104 | $logInfo = [ |
||
105 | 'tool' => TOOL_FORUM, |
||
106 | 'tool_id' => $my_forum, |
||
107 | 'tool_id_detail' => 0, |
||
108 | 'action' => !empty($my_action) ? $my_action : 'list-threads', |
||
109 | 'action_details' => isset($_GET['content']) ? $_GET['content'] : '', |
||
110 | ]; |
||
111 | Event::registerLog($logInfo); |
||
112 | |||
113 | if (api_is_in_gradebook()) { |
||
114 | $interbreadcrumb[] = [ |
||
115 | 'url' => Category::getUrl(), |
||
116 | 'name' => get_lang('ToolGradebook'), |
||
117 | ]; |
||
118 | } |
||
119 | |||
120 | $forumUrl = api_get_path(WEB_CODE_PATH).'forum/'; |
||
121 | |||
122 | if (!empty($groupId)) { |
||
123 | $interbreadcrumb[] = [ |
||
124 | 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), |
||
125 | 'name' => get_lang('Groups'), |
||
126 | ]; |
||
127 | $interbreadcrumb[] = [ |
||
128 | 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
||
129 | 'name' => get_lang('GroupSpace').' '.$group_properties['name'], |
||
130 | ]; |
||
131 | $interbreadcrumb[] = [ |
||
132 | 'url' => '#', |
||
133 | 'name' => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title']), |
||
134 | ]; |
||
135 | } else { |
||
136 | $interbreadcrumb[] = [ |
||
137 | 'url' => $forumUrl.'index.php?search='.Security::remove_XSS($my_search), |
||
138 | 'name' => get_lang('ForumCategories'), |
||
139 | ]; |
||
140 | $interbreadcrumb[] = [ |
||
141 | 'url' => $forumUrl.'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'] |
||
142 | .'&search='.Security::remove_XSS(urlencode($my_search)), |
||
143 | 'name' => Security::remove_XSS(prepare4display($current_forum_category['cat_title'])), |
||
144 | ]; |
||
145 | $interbreadcrumb[] = [ |
||
146 | 'url' => '#', |
||
147 | 'name' => Security::remove_XSS($current_forum['forum_title']), |
||
148 | ]; |
||
149 | } |
||
150 | |||
151 | if ($origin == 'learnpath') { |
||
152 | Display::display_reduced_header(); |
||
153 | } else { |
||
154 | // The last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string. |
||
155 | Display::display_header(); |
||
156 | } |
||
157 | |||
158 | /* Actions */ |
||
159 | // Change visibility of a forum or a forum category. |
||
160 | if (($my_action == 'invisible' || $my_action == 'visible') && |
||
161 | isset($_GET['content']) && |
||
162 | isset($_GET['id']) && |
||
163 | $isAllowedToEdit |
||
164 | ) { |
||
165 | $message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']); |
||
166 | } |
||
167 | // Locking and unlocking. |
||
168 | if (($my_action == 'lock' || $my_action == 'unlock') && |
||
169 | isset($_GET['content']) && isset($_GET['id']) && |
||
170 | $isAllowedToEdit |
||
171 | ) { |
||
172 | $message = change_lock_status($_GET['content'], $_GET['id'], $my_action); |
||
173 | } |
||
174 | // Deleting. |
||
175 | if ($my_action == 'delete' && |
||
176 | isset($_GET['content']) && |
||
177 | isset($_GET['id']) && |
||
178 | $isAllowedToEdit |
||
179 | ) { |
||
180 | $locked = api_resource_is_locked_by_gradebook($_GET['id'], LINK_FORUM_THREAD); |
||
181 | if ($locked == false) { |
||
182 | $message = deleteForumCategoryThread($_GET['content'], $_GET['id']); |
||
183 | |||
184 | // Delete link |
||
185 | $link_info = GradebookUtils::isResourceInCourseGradebook( |
||
186 | api_get_course_id(), |
||
187 | 5, |
||
188 | $_GET['id'], |
||
189 | api_get_session_id() |
||
190 | ); |
||
191 | $link_id = $link_info['id']; |
||
192 | if ($link_info !== false) { |
||
193 | GradebookUtils::remove_resource_from_course_gradebook($link_id); |
||
194 | } |
||
195 | } |
||
196 | } |
||
197 | // Moving. |
||
198 | if ($my_action == 'move' && isset($_GET['thread']) && |
||
199 | $isAllowedToEdit |
||
200 | ) { |
||
201 | $message = move_thread_form(); |
||
0 ignored issues
–
show
|
|||
202 | } |
||
203 | // Notification. |
||
204 | if ($my_action == 'notify' && |
||
205 | isset($_GET['content']) && |
||
206 | isset($_GET['id']) && |
||
207 | api_is_allowed_to_session_edit(false, true) |
||
208 | ) { |
||
209 | $return_message = set_notification($_GET['content'], $_GET['id']); |
||
210 | echo Display::return_message($return_message, 'confirm', false); |
||
211 | } |
||
212 | |||
213 | // Student list |
||
214 | if ($my_action == 'liststd' && |
||
215 | isset($_GET['content']) && |
||
216 | isset($_GET['id']) && |
||
217 | (api_is_allowed_to_edit(null, true) || $is_group_tutor) |
||
218 | ) { |
||
219 | $active = null; |
||
220 | $listType = isset($_GET['list']) ? $_GET['list'] : null; |
||
221 | |||
222 | switch ($listType) { |
||
223 | case 'qualify': |
||
224 | $student_list = get_thread_users_qualify($_GET['id']); |
||
225 | $nrorow3 = -2; |
||
226 | $active = 2; |
||
227 | break; |
||
228 | case 'notqualify': |
||
229 | $student_list = get_thread_users_not_qualify($_GET['id']); |
||
230 | $nrorow3 = -2; |
||
231 | $active = 3; |
||
232 | break; |
||
233 | default: |
||
234 | $student_list = get_thread_users_details($_GET['id']); |
||
235 | $nrorow3 = Database::num_rows($student_list); |
||
236 | $active = 1; |
||
237 | break; |
||
238 | } |
||
239 | |||
240 | $table_list = Display::page_subheader(get_lang('ThreadUsersList').': '.get_name_thread_by_id($_GET['id'])); |
||
241 | |||
242 | if ($nrorow3 > 0 || $nrorow3 == -2) { |
||
243 | $url = api_get_cidreq().'&forum='.$my_forum.'&action=' |
||
244 | .Security::remove_XSS($_GET['action']).'&content=' |
||
245 | .Security::remove_XSS($_GET['content'], STUDENT).'&id='.intval($_GET['id']); |
||
246 | $tabs = [ |
||
247 | [ |
||
248 | 'content' => get_lang('AllStudents'), |
||
249 | 'url' => $forumUrl.'viewforum.php?'.$url.'&list=all', |
||
250 | ], |
||
251 | [ |
||
252 | 'content' => get_lang('StudentsQualified'), |
||
253 | 'url' => $forumUrl.'viewforum.php?'.$url.'&list=qualify', |
||
254 | ], |
||
255 | [ |
||
256 | 'content' => get_lang('StudentsNotQualified'), |
||
257 | 'url' => $forumUrl.'viewforum.php?'.$url.'&list=notqualify', |
||
258 | ], |
||
259 | ]; |
||
260 | $table_list .= Display::tabsOnlyLink($tabs, $active); |
||
261 | |||
262 | $icon_qualify = 'quiz.png'; |
||
263 | $table_list .= '<center><br /><table class="table table-hover table-striped data_table" style="width:50%">'; |
||
264 | // The column headers (TODO: Make this sortable). |
||
265 | $table_list .= '<tr >'; |
||
266 | $table_list .= '<th height="24">'.get_lang('NamesAndLastNames').'</th>'; |
||
267 | |||
268 | if ($listType == 'qualify') { |
||
269 | $table_list .= '<th>'.get_lang('Qualification').'</th>'; |
||
270 | } |
||
271 | if (api_is_allowed_to_edit(null, true)) { |
||
272 | $table_list .= '<th>'.get_lang('Qualify').'</th>'; |
||
273 | } |
||
274 | $table_list .= '</tr>'; |
||
275 | $max_qualify = showQualify('2', $userId, $_GET['id']); |
||
276 | $counter_stdlist = 0; |
||
277 | |||
278 | if (Database::num_rows($student_list) > 0) { |
||
279 | while ($row_student_list = Database::fetch_array($student_list)) { |
||
280 | $userInfo = api_get_user_info($row_student_list['id']); |
||
281 | if ($counter_stdlist % 2 == 0) { |
||
282 | $class_stdlist = 'row_odd'; |
||
283 | } else { |
||
284 | $class_stdlist = 'row_even'; |
||
285 | } |
||
286 | $table_list .= '<tr class="'.$class_stdlist.'"><td>'; |
||
287 | $table_list .= UserManager::getUserProfileLink($userInfo); |
||
288 | |||
289 | $table_list .= '</td>'; |
||
290 | if ($listType == 'qualify') { |
||
291 | $table_list .= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>'; |
||
292 | } |
||
293 | if (api_is_allowed_to_edit(null, true)) { |
||
294 | $current_qualify_thread = showQualify( |
||
295 | '1', |
||
296 | $row_student_list['id'], |
||
297 | $_GET['id'] |
||
298 | ); |
||
299 | $table_list .= '<td> |
||
300 | <a href="'.$forumUrl.'forumqualify.php?'.api_get_cidreq() |
||
301 | .'&forum='.intval($my_forum).'&thread=' |
||
302 | .intval($_GET['id']).'&user='.$row_student_list['id'] |
||
303 | .'&user_id='.$row_student_list['id'].'&idtextqualify=' |
||
304 | .$current_qualify_thread.'">' |
||
305 | .Display::return_icon($icon_qualify, get_lang('Qualify')).'</a></td></tr>'; |
||
306 | } |
||
307 | $counter_stdlist++; |
||
308 | } |
||
309 | } else { |
||
310 | if ($listType === 'qualify') { |
||
311 | $table_list .= '<tr><td colspan="2">'.get_lang('ThereIsNotQualifiedLearners').'</td></tr>'; |
||
312 | } else { |
||
313 | $table_list .= '<tr><td colspan="2">'.get_lang('ThereIsNotUnqualifiedLearners').'</td></tr>'; |
||
314 | } |
||
315 | } |
||
316 | |||
317 | $table_list .= '</table></center>'; |
||
318 | $table_list .= '<br />'; |
||
319 | } else { |
||
320 | $table_list .= Display::return_message(get_lang('NoParticipation'), 'warning'); |
||
321 | } |
||
322 | } |
||
323 | |||
324 | if ($origin == 'learnpath') { |
||
325 | echo '<div style="height:15px"> </div>'; |
||
326 | } |
||
327 | |||
328 | /* Display the action messages */ |
||
329 | if (!empty($message)) { |
||
330 | echo Display::return_message($message, 'confirm'); |
||
331 | } |
||
332 | |||
333 | /* Action links */ |
||
334 | echo '<div class="actions">'; |
||
335 | if ($origin != 'learnpath') { |
||
336 | if (!empty($groupId)) { |
||
337 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq().'">' |
||
338 | .Display::return_icon('back.png', get_lang('BackTo') |
||
339 | .' '.get_lang('Groups'), '', ICON_SIZE_MEDIUM).'</a>'; |
||
340 | } else { |
||
341 | echo '<span style="float:right;">'.search_link().'</span>'; |
||
342 | echo '<a href="'.$forumUrl.'index.php?'.api_get_cidreq().'">' |
||
343 | .Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM) |
||
344 | .'</a>'; |
||
345 | } |
||
346 | } |
||
347 | |||
348 | // The link should appear when |
||
349 | // 1. the course admin is here |
||
350 | // 2. the course member is here and new threads are allowed |
||
351 | // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed |
||
352 | if (api_is_allowed_to_edit(false, true) || |
||
353 | ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) || |
||
354 | ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1) |
||
355 | ) { |
||
356 | if ($current_forum['locked'] != 1 && $current_forum['locked'] != 1) { |
||
357 | if (!api_is_anonymous() && !api_is_invitee()) { |
||
358 | if ($my_forum == strval(intval($my_forum))) { |
||
359 | echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq().'&forum=' |
||
360 | .Security::remove_XSS($my_forum).'">' |
||
361 | .Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM) |
||
362 | .'</a>'; |
||
363 | } else { |
||
364 | $my_forum = strval(intval($my_forum)); |
||
365 | echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq() |
||
366 | .'&forum='.$my_forum.'">' |
||
367 | .Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM) |
||
368 | .'</a>'; |
||
369 | } |
||
370 | } |
||
371 | } else { |
||
372 | echo get_lang('ForumLocked'); |
||
373 | } |
||
374 | } |
||
375 | echo '</div>'; |
||
376 | |||
377 | /* Display */ |
||
378 | $titleForum = Security::remove_XSS($current_forum['forum_title']); |
||
379 | $descriptionForum = $current_forum['forum_comment']; |
||
380 | $iconForum = Display::return_icon( |
||
381 | 'forum_yellow.png', |
||
382 | get_lang('Forum'), |
||
383 | null, |
||
384 | ICON_SIZE_MEDIUM |
||
385 | ); |
||
386 | $html = ''; |
||
387 | $html .= '<div class="topic-forum">'; |
||
388 | // The current forum |
||
389 | if ($origin != 'learnpath') { |
||
390 | $html .= Display::tag( |
||
391 | 'h3', |
||
392 | $iconForum.' '.$titleForum, |
||
393 | [ |
||
394 | 'class' => 'title-forum', ] |
||
395 | ); |
||
396 | |||
397 | if (!empty($descriptionForum)) { |
||
398 | $html .= Display::tag( |
||
399 | 'p', |
||
400 | Security::remove_XSS($descriptionForum), |
||
401 | [ |
||
402 | 'class' => 'description', |
||
403 | ] |
||
404 | ); |
||
405 | } |
||
406 | } |
||
407 | |||
408 | $html .= '</div>'; |
||
409 | echo $html; |
||
410 | |||
411 | // Getting al the threads |
||
412 | $threads = get_threads($my_forum); |
||
413 | $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null; |
||
414 | $course_id = api_get_course_int_id(); |
||
415 | |||
416 | $hideNotifications = api_get_course_setting('hide_forum_notifications') == 1; |
||
417 | |||
418 | echo '<div class="forum_display">'; |
||
419 | if (is_array($threads)) { |
||
420 | $html = ''; |
||
421 | $count = 1; |
||
422 | foreach ($threads as $row) { |
||
423 | // Thread who have no replies yet and the only post is invisible should not be displayed to students. |
||
424 | if (api_is_allowed_to_edit(false, true) || |
||
425 | !($row['thread_replies'] == '0' && $row['visibility'] == '0') |
||
426 | ) { |
||
427 | $my_whatsnew_post_info = null; |
||
428 | |||
429 | if (isset($whatsnew_post_info[$my_forum][$row['thread_id']])) { |
||
430 | $my_whatsnew_post_info = $whatsnew_post_info[$my_forum][$row['thread_id']]; |
||
431 | } |
||
432 | |||
433 | $newPost = ''; |
||
434 | if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) { |
||
435 | $newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL); |
||
436 | } |
||
437 | |||
438 | $name = api_get_person_name($row['firstname'], $row['lastname']); |
||
439 | |||
440 | $linkPostForum = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.$my_forum |
||
441 | ."&thread={$row['thread_id']}&search=" |
||
442 | .Security::remove_XSS(urlencode($my_search)).'">' |
||
443 | .Security::remove_XSS($row['thread_title']).'</a>'; |
||
444 | $html = ''; |
||
445 | $html .= '<div class="panel panel-default forum '.($row['thread_sticky'] ? 'sticky' : '').'">'; |
||
446 | $html .= '<div class="panel-body">'; |
||
447 | $html .= '<div class="row">'; |
||
448 | $html .= '<div class="col-md-6">'; |
||
449 | $html .= '<div class="row">'; |
||
450 | $html .= '<div class="col-md-2">'; |
||
451 | |||
452 | // display the author name |
||
453 | $tab_poster_info = api_get_user_info($row['user_id']); |
||
454 | $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']); |
||
455 | $authorName = ''; |
||
456 | |||
457 | if ($origin != 'learnpath') { |
||
458 | $authorName = display_user_link( |
||
459 | $row['user_id'], |
||
460 | api_get_person_name($row['firstname'], $row['lastname']), |
||
461 | '', |
||
462 | $poster_username |
||
463 | ); |
||
464 | } else { |
||
465 | $authorName = Display::tag( |
||
466 | 'span', |
||
467 | api_get_person_name( |
||
468 | $row['firstname'], |
||
469 | $row['lastname'] |
||
470 | ), |
||
471 | [ |
||
472 | 'title' => api_htmlentities($poster_username, ENT_QUOTES), |
||
473 | ] |
||
474 | ); |
||
475 | } |
||
476 | |||
477 | $_user = api_get_user_info($row['user_id']); |
||
478 | $iconStatus = $_user['icon_status']; |
||
479 | $last_post_info = get_last_post_by_thread( |
||
480 | $row['c_id'], |
||
481 | $row['thread_id'], |
||
482 | $row['forum_id'], |
||
483 | api_is_allowed_to_edit() |
||
484 | ); |
||
485 | $last_post = null; |
||
486 | if ($last_post_info) { |
||
487 | $poster_info = api_get_user_info($last_post_info['poster_id']); |
||
488 | $post_date = api_convert_and_format_date($last_post_info['post_date']); |
||
489 | $last_post = $post_date.'<br>'.get_lang('By').' '.display_user_link( |
||
490 | $last_post_info['poster_id'], |
||
491 | $poster_info['complete_name'], |
||
492 | '', |
||
493 | $poster_info['username'] |
||
494 | ); |
||
495 | } |
||
496 | |||
497 | $html .= '<div class="thumbnail">'.display_user_image($row['user_id'], $name, $origin).'</div>'; |
||
498 | $html .= '</div>'; |
||
499 | $html .= '<div class="col-md-10">'; |
||
500 | $html .= Display::tag( |
||
501 | 'h3', |
||
502 | $linkPostForum, |
||
503 | [ |
||
504 | 'class' => 'title', |
||
505 | ] |
||
506 | ); |
||
507 | $html .= '<p>'.get_lang('By').' '.$iconStatus.' '.$authorName.'</p>'; |
||
508 | |||
509 | if ($last_post_info) { |
||
510 | $html .= '<p>'.Security::remove_XSS(cut($last_post_info['post_text'], 140)).'</p>'; |
||
511 | } |
||
512 | |||
513 | $html .= '<p>'.Display::dateToStringAgoAndLongDate($row['insert_date']).'</p>'; |
||
514 | |||
515 | if ($current_forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) { |
||
516 | $waitingCount = getCountPostsWithStatus( |
||
517 | CForumPost::STATUS_WAITING_MODERATION, |
||
518 | $current_forum, |
||
519 | $row['thread_id'] |
||
520 | ); |
||
521 | if (!empty($waitingCount)) { |
||
522 | $html .= Display::label( |
||
523 | get_lang('PostsPendingModeration').': '.$waitingCount, |
||
524 | 'warning' |
||
525 | ); |
||
526 | } |
||
527 | } |
||
528 | |||
529 | $html .= '</div>'; |
||
530 | $html .= '</div>'; |
||
531 | |||
532 | $html .= '</div>'; |
||
533 | |||
534 | $html .= '<div class="col-md-6">'; |
||
535 | $html .= '<div class="row">'; |
||
536 | $html .= '<div class="col-md-4">' |
||
537 | .Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL) |
||
538 | ." {$row['thread_replies']} ".get_lang('Replies').'<br>'; |
||
539 | $html .= Display::return_icon( |
||
540 | 'post-forum.png', |
||
541 | null, |
||
542 | null, |
||
543 | ICON_SIZE_SMALL |
||
544 | ).' '.$row['thread_views'].' '.get_lang('Views').'<br>'.$newPost; |
||
545 | $html .= '</div>'; |
||
546 | |||
547 | $last_post_info = get_last_post_by_thread( |
||
548 | $row['c_id'], |
||
549 | $row['thread_id'], |
||
550 | $row['forum_id'], |
||
551 | api_is_allowed_to_edit() |
||
552 | ); |
||
553 | $last_post = null; |
||
554 | |||
555 | if ($last_post_info) { |
||
556 | $poster_info = api_get_user_info($last_post_info['poster_id']); |
||
557 | $post_date = Display::dateToStringAgoAndLongDate($last_post_info['post_date']); |
||
558 | $last_post = $post_date.'<br>'.get_lang('By').' '.display_user_link( |
||
559 | $last_post_info['poster_id'], |
||
560 | $poster_info['complete_name'], |
||
561 | '', |
||
562 | $poster_info['username'] |
||
563 | ); |
||
564 | } |
||
565 | |||
566 | $html .= '<div class="col-md-5">' |
||
567 | .Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) |
||
568 | .' '.$last_post; |
||
569 | $html .= '</div>'; |
||
570 | $html .= '<div class="col-md-3">'; |
||
571 | $cidreq = api_get_cidreq(); |
||
572 | |||
573 | // Get attachment id. |
||
574 | if (isset($row['post_id'])) { |
||
575 | $attachment_list = get_attachment($row['post_id']); |
||
576 | } |
||
577 | $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; |
||
578 | $iconsEdit = ''; |
||
579 | if ($origin != 'learnpath') { |
||
580 | if (api_is_allowed_to_edit(false, true) && |
||
581 | !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId) |
||
582 | ) { |
||
583 | $iconsEdit .= '<a href="'.$forumUrl.'editthread.php?'.$cidreq |
||
584 | .'&forum='.$my_forum.'&thread=' |
||
585 | .intval($row['thread_id']) |
||
586 | .'&id_attach='.$id_attach.'">' |
||
587 | .Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>'; |
||
588 | if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) { |
||
589 | $iconsEdit .= Display::return_icon( |
||
590 | 'delete_na.png', |
||
591 | get_lang('ResourceLockedByGradebook'), |
||
592 | [], |
||
593 | ICON_SIZE_SMALL |
||
594 | ); |
||
595 | } else { |
||
596 | $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum=' |
||
597 | .$my_forum.'&action=delete&content=thread&id=' |
||
598 | .$row['thread_id']."\" onclick=\"javascript:if(!confirm('" |
||
599 | .addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) |
||
600 | ."')) return false;\">" |
||
601 | .Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>'; |
||
602 | } |
||
603 | |||
604 | $iconsEdit .= return_visible_invisible_icon( |
||
605 | 'thread', |
||
606 | $row['thread_id'], |
||
607 | $row['visibility'], |
||
608 | [ |
||
609 | 'forum' => $my_forum, |
||
610 | 'gidReq' => $groupId, |
||
611 | ] |
||
612 | ); |
||
613 | $iconsEdit .= return_lock_unlock_icon( |
||
614 | 'thread', |
||
615 | $row['thread_id'], |
||
616 | $row['locked'], |
||
617 | [ |
||
618 | 'forum' => $my_forum, |
||
619 | 'gidReq' => api_get_group_id(), |
||
620 | ] |
||
621 | ); |
||
622 | $iconsEdit .= '<a href="viewforum.php?'.$cidreq.'&forum=' |
||
623 | .$my_forum |
||
624 | .'&action=move&thread='.$row['thread_id'].'">' |
||
625 | .Display::return_icon('move.png', get_lang('MoveThread'), [], ICON_SIZE_SMALL) |
||
626 | .'</a>'; |
||
627 | } |
||
628 | } |
||
629 | $iconnotify = 'notification_mail_na.png'; |
||
630 | if (is_array( |
||
631 | isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null |
||
632 | ) |
||
633 | ) { |
||
634 | if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) { |
||
635 | $iconnotify = 'notification_mail.png'; |
||
636 | } |
||
637 | } |
||
638 | $icon_liststd = 'user.png'; |
||
639 | if (!api_is_anonymous() && |
||
640 | api_is_allowed_to_session_edit(false, true) && |
||
641 | !$hideNotifications |
||
642 | ) { |
||
643 | $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum=' |
||
644 | .$my_forum |
||
645 | ."&action=notify&content=thread&id={$row['thread_id']}" |
||
646 | .'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>'; |
||
647 | } |
||
648 | |||
649 | if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') { |
||
650 | $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum=' |
||
651 | .$my_forum |
||
652 | ."&action=liststd&content=thread&id={$row['thread_id']}" |
||
653 | .'">'.Display::return_icon($icon_liststd, get_lang('StudentList'), [], ICON_SIZE_SMALL) |
||
654 | .'</a>'; |
||
655 | } |
||
656 | $html .= $iconsEdit; |
||
657 | $html .= '</div>'; |
||
658 | $html .= '</div>'; |
||
659 | $html .= '</div>'; |
||
660 | |||
661 | $html .= '</div>'; |
||
662 | $html .= '</div>'; |
||
663 | $html .= '</div>'; |
||
664 | |||
665 | echo $html; |
||
666 | } |
||
667 | $count++; |
||
668 | } |
||
669 | } |
||
670 | |||
671 | echo '</div>'; |
||
672 | echo isset($table_list) ? $table_list : ''; |
||
673 | |||
674 | if ($origin != 'learnpath') { |
||
675 | Display::display_footer(); |
||
676 | } |
||
677 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.