viewforum.php 24 KB

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