viewforum.php 24 KB

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