viewforum.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. // The section (tabs).
  29. $this_section = SECTION_COURSES;
  30. $nameTools = get_lang('ToolForum');
  31. // Are we in a lp ?
  32. $origin = api_get_origin();
  33. /* Including necessary files */
  34. require 'forumconfig.inc.php';
  35. require_once 'forumfunction.inc.php';
  36. $userId = api_get_user_id();
  37. $sessionId = api_get_session_id();
  38. $groupId = api_get_group_id();
  39. $courseId = api_get_course_int_id();
  40. $groupInfo = GroupManager::get_group_properties($groupId);
  41. $isTutor = GroupManager::is_tutor_of_group($userId, $groupInfo, $courseId);
  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) {
  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. //User has access in the group?
  63. $user_has_access_in_group = GroupManager::user_has_access(
  64. $userId,
  65. $group_properties['iid'],
  66. GroupManager::GROUP_TOOL_FORUM
  67. );
  68. $is_group_tutor = GroupManager::is_tutor_of_group(
  69. api_get_user_id(),
  70. $group_properties
  71. );
  72. // Course
  73. if (!api_is_allowed_to_edit(false, true) && //is a student
  74. (($current_forum_category && $current_forum_category['visibility'] == 0) ||
  75. $current_forum['visibility'] == 0 || !$user_has_access_in_group)
  76. ) {
  77. api_not_allowed(true);
  78. }
  79. } else {
  80. //Course
  81. if (!api_is_allowed_to_edit(false, true) && (
  82. ($current_forum_category && $current_forum_category['visibility'] == 0) ||
  83. $current_forum['visibility'] == 0
  84. ) //forum category or forum visibility is false
  85. ) {
  86. api_not_allowed();
  87. }
  88. }
  89. /* Header and Breadcrumbs */
  90. $my_search = isset($_GET['search']) ? $_GET['search'] : '';
  91. $my_action = isset($_GET['action']) ? $_GET['action'] : '';
  92. if (api_is_in_gradebook()) {
  93. $interbreadcrumb[] = array(
  94. 'url' => Category::getUrl(),
  95. 'name' => get_lang('ToolGradebook')
  96. );
  97. }
  98. $forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
  99. if (!empty($groupId)) {
  100. $interbreadcrumb[] = array(
  101. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  102. 'name' => get_lang('Groups')
  103. );
  104. $interbreadcrumb[] = array(
  105. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  106. 'name' => get_lang('GroupSpace').' '.$group_properties['name']
  107. );
  108. $interbreadcrumb[] = array(
  109. 'url' => '#',
  110. 'name' => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title'])
  111. );
  112. } else {
  113. $interbreadcrumb[] = array(
  114. 'url' => $forumUrl.'index.php?search='.Security::remove_XSS($my_search),
  115. 'name' => get_lang('ForumCategories')
  116. );
  117. $interbreadcrumb[] = array(
  118. 'url' => $forumUrl.'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id']
  119. . '&search='.Security::remove_XSS(urlencode($my_search)),
  120. 'name' => prepare4display($current_forum_category['cat_title'])
  121. );
  122. $interbreadcrumb[] = array(
  123. 'url' => '#',
  124. 'name' => Security::remove_XSS($current_forum['forum_title'])
  125. );
  126. }
  127. if ($origin == 'learnpath') {
  128. Display::display_reduced_header();
  129. } else {
  130. // The last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string.
  131. Display::display_header('');
  132. }
  133. /* Actions */
  134. // Change visibility of a forum or a forum category.
  135. if (($my_action == 'invisible' || $my_action == 'visible') &&
  136. isset($_GET['content']) &&
  137. isset($_GET['id']) &&
  138. api_is_allowed_to_edit(false, true) &&
  139. api_is_allowed_to_session_edit(false, true)
  140. ) {
  141. $message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']);
  142. }
  143. // Locking and unlocking.
  144. if (($my_action == 'lock' || $my_action == 'unlock') &&
  145. isset($_GET['content']) && isset($_GET['id']) &&
  146. api_is_allowed_to_edit(false, true) &&
  147. api_is_allowed_to_session_edit(false, true)
  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. 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::isResourceInCourseGradebook(
  163. api_get_course_int_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 ($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 = array(
  221. array(
  222. 'content' => get_lang('AllStudents'),
  223. 'url' => $forumUrl.'viewforum.php?'.$url.'&list=all'
  224. ),
  225. array(
  226. 'content' => get_lang('StudentsQualified'),
  227. 'url' => $forumUrl.'viewforum.php?'.$url.'&list=qualify'
  228. ),
  229. array(
  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. array(
  358. 'class' => 'title-forum')
  359. );
  360. if (!empty($descriptionForum)) {
  361. $html .= Display::tag(
  362. 'p',
  363. Security::remove_XSS($descriptionForum),
  364. array(
  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. if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
  390. $newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
  391. } else {
  392. $newPost = '';
  393. }
  394. $name = api_get_person_name($row['firstname'], $row['lastname']);
  395. $linkPostForum = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.$my_forum
  396. . "&thread={$row['thread_id']}&search="
  397. . Security::remove_XSS(urlencode($my_search)).'">'
  398. . $row['thread_title'].'</a>';
  399. $html = '';
  400. $html .= '<div class="panel panel-default forum '.($row['thread_sticky'] ? 'sticky' : '').'">';
  401. $html .= '<div class="panel-body">';
  402. $html .= '<div class="row">';
  403. $html .= '<div class="col-md-6">';
  404. $html .= '<div class="row">';
  405. $html .= '<div class="col-md-2">';
  406. // display the author name
  407. $tab_poster_info = api_get_user_info($row['user_id']);
  408. $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
  409. $authorName = '';
  410. if ($origin != 'learnpath') {
  411. $authorName = display_user_link(
  412. $row['user_id'],
  413. api_get_person_name($row['firstname'], $row['lastname']),
  414. '',
  415. $poster_username
  416. );
  417. } else {
  418. $authorName = Display::tag(
  419. 'span',
  420. api_get_person_name(
  421. $row['firstname'],
  422. $row['lastname']
  423. ),
  424. array(
  425. 'title' => api_htmlentities($poster_username, ENT_QUOTES)
  426. )
  427. );
  428. }
  429. $html .= '<div class="thumbnail">'.display_user_image($row['user_id'], $name, $origin).'</div>';
  430. $html .= '</div>';
  431. $html .= '<div class="col-md-10">';
  432. $html .= Display::tag(
  433. 'h3',
  434. $linkPostForum,
  435. array(
  436. 'class' => 'title'
  437. )
  438. );
  439. $html .= '<p>'.get_lang('By').' '.$authorName.'</p>';
  440. $html .= '<p>'.api_convert_and_format_date($row['insert_date']).'</p>';
  441. if ($current_forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) {
  442. $waitingCount = getCountPostsWithStatus(
  443. CForumPost::STATUS_WAITING_MODERATION,
  444. $current_forum,
  445. $row['thread_id']
  446. );
  447. if (!empty($waitingCount)) {
  448. $html .= Display::label(
  449. get_lang('PostsPendingModeration').': '.$waitingCount,
  450. 'warning'
  451. );
  452. }
  453. }
  454. $html .= '</div>';
  455. $html .= '</div>';
  456. $html .= '</div>';
  457. $html .= '<div class="col-md-6">';
  458. $html .= '<div class="row">';
  459. $html .= '<div class="col-md-4">'
  460. . Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL)
  461. . " {$row['thread_replies']} ".get_lang('Replies').'<br>';
  462. $html .= Display::return_icon(
  463. 'post-forum.png',
  464. null,
  465. null,
  466. ICON_SIZE_SMALL
  467. ).' '.$row['thread_views'].' '.get_lang('Views').'<br>'.$newPost;
  468. $html .= '</div>';
  469. $last_post_info = get_last_post_by_thread(
  470. $row['c_id'],
  471. $row['thread_id'],
  472. $row['forum_id'],
  473. api_is_allowed_to_edit()
  474. );
  475. $last_post = null;
  476. if ($last_post_info) {
  477. $poster_info = api_get_user_info($last_post_info['poster_id']);
  478. $post_date = api_convert_and_format_date($last_post_info['post_date']);
  479. $last_post = $post_date.'<br>'.get_lang('By').' '.display_user_link(
  480. $last_post_info['poster_id'],
  481. $poster_info['complete_name'],
  482. '',
  483. $poster_info['username']
  484. );
  485. }
  486. $html .= '<div class="col-md-5">'
  487. . Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY)
  488. . ' '.$last_post;
  489. $html .= '</div>';
  490. $html .= '<div class="col-md-3">';
  491. $cidreq = api_get_cidreq();
  492. // Get attachment id.
  493. if (isset($row['post_id'])) {
  494. $attachment_list = get_attachment($row['post_id']);
  495. }
  496. $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
  497. $iconsEdit = '';
  498. if ($origin != 'learnpath') {
  499. if (api_is_allowed_to_edit(false, true) &&
  500. !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)
  501. ) {
  502. $iconsEdit .= '<a href="'.$forumUrl.'editthread.php?'.$cidreq
  503. . '&forum='.$my_forum.'&thread='
  504. . intval($row['thread_id'])
  505. . '&id_attach='.$id_attach.'">'
  506. . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
  507. if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) {
  508. $iconsEdit .= Display::return_icon(
  509. 'delete_na.png',
  510. get_lang('ResourceLockedByGradebook'),
  511. array(),
  512. ICON_SIZE_SMALL
  513. );
  514. } else {
  515. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  516. . $my_forum.'&action=delete&content=thread&id='
  517. . $row['thread_id']."\" onclick=\"javascript:if(!confirm('"
  518. . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))
  519. . "')) return false;\">"
  520. . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
  521. }
  522. $iconsEdit .= return_visible_invisible_icon(
  523. 'thread',
  524. $row['thread_id'],
  525. $row['visibility'],
  526. array(
  527. 'forum' => $my_forum,
  528. 'gidReq' => $groupId
  529. )
  530. );
  531. $iconsEdit .= return_lock_unlock_icon(
  532. 'thread',
  533. $row['thread_id'],
  534. $row['locked'],
  535. array(
  536. 'forum' => $my_forum,
  537. 'gidReq' => api_get_group_id()
  538. )
  539. );
  540. $iconsEdit .= '<a href="viewforum.php?'.$cidreq.'&forum='
  541. . $my_forum
  542. . '&action=move&thread='.$row['thread_id'].'">'
  543. . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL)
  544. . '</a>';
  545. }
  546. }
  547. $iconnotify = 'notification_mail_na.png';
  548. if (is_array(
  549. isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null
  550. )
  551. ) {
  552. if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
  553. $iconnotify = 'notification_mail.png';
  554. }
  555. }
  556. $icon_liststd = 'user.png';
  557. if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
  558. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  559. . $my_forum
  560. . "&action=notify&content=thread&id={$row['thread_id']}"
  561. . '">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
  562. }
  563. if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
  564. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  565. . $my_forum
  566. . "&action=liststd&content=thread&id={$row['thread_id']}"
  567. . '">'.Display::return_icon($icon_liststd, get_lang('StudentList'), array(), ICON_SIZE_SMALL)
  568. . '</a>';
  569. }
  570. $html .= $iconsEdit;
  571. $html .= '</div>';
  572. $html .= '</div>';
  573. $html .= '</div>';
  574. $html .= '</div>';
  575. $html .= '</div>';
  576. $html .= '</div>';
  577. echo $html;
  578. }
  579. $count++;
  580. }
  581. }
  582. echo '</div>';
  583. echo isset($table_list) ? $table_list : '';
  584. if ($origin != 'learnpath') {
  585. Display::display_footer();
  586. }