viewforum.php 24 KB

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