viewforum.php 24 KB

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