viewforum.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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 (
  74. !api_is_allowed_to_edit(false, true) && //is a student
  75. (($current_forum_category && $current_forum_category['visibility'] == 0) ||
  76. $current_forum['visibility'] == 0 || !$user_has_access_in_group)
  77. ) {
  78. api_not_allowed(true);
  79. }
  80. } else {
  81. //Course
  82. if (
  83. !api_is_allowed_to_edit(false, true) && //is a student
  84. (
  85. ($current_forum_category && $current_forum_category['visibility'] == 0) ||
  86. $current_forum['visibility'] == 0
  87. ) //forum category or forum visibility is false
  88. ) {
  89. api_not_allowed();
  90. }
  91. }
  92. /* Header and Breadcrumbs */
  93. $my_search = isset($_GET['search']) ? $_GET['search'] : '';
  94. $my_action = isset($_GET['action']) ? $_GET['action'] : '';
  95. $gradebook = null;
  96. if (isset($_SESSION['gradebook'])) {
  97. $gradebook = $_SESSION['gradebook'];
  98. }
  99. if (!empty($gradebook) && $gradebook == 'view') {
  100. $interbreadcrumb[] = array(
  101. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  102. 'name' => get_lang('ToolGradebook')
  103. );
  104. }
  105. $forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
  106. if (!empty($groupId)) {
  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. echo Display::return_message($return_message, 'confirm', 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='.$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.'&list=all'
  236. ),
  237. array(
  238. 'content' => get_lang('StudentsQualified'),
  239. 'url' => $forumUrl.'viewforum.php?'.$url.'&list=qualify'
  240. ),
  241. array(
  242. 'content' => get_lang('StudentsNotQualified'),
  243. 'url' => $forumUrl.'viewforum.php?'.$url.'&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. echo Display::return_message($message, 'confirm');
  310. }
  311. /* Action links */
  312. echo '<div class="actions">';
  313. if ($origin != 'learnpath') {
  314. if (!empty($groupId)) {
  315. echo '<a href="'.api_get_path(WEB_CODE_PATH).'group/group_space.php?'
  316. . api_get_cidreq().'&gradebook='.$gradebook.'">'
  317. . Display::return_icon('back.png', get_lang('BackTo')
  318. . ' '.get_lang('Groups'), '', ICON_SIZE_MEDIUM).'</a>';
  319. } else {
  320. echo '<span style="float:right;">'.search_link().'</span>';
  321. echo '<a href="'.$forumUrl.'index.php?'.api_get_cidreq().'">'
  322. . Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM)
  323. . '</a>';
  324. }
  325. }
  326. // The link should appear when
  327. // 1. the course admin is here
  328. // 2. the course member is here and new threads are allowed
  329. // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed
  330. if (
  331. api_is_allowed_to_edit(false, true) ||
  332. ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) ||
  333. ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)
  334. ) {
  335. if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
  336. if (!api_is_anonymous() && !api_is_invitee()) {
  337. if ($my_forum == strval(intval($my_forum))) {
  338. echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq().'&forum='
  339. . Security::remove_XSS($my_forum).'">'
  340. . Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM)
  341. . '</a>';
  342. } else {
  343. $my_forum = strval(intval($my_forum));
  344. echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq()
  345. . '&forum='.$my_forum.'">'
  346. . Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM)
  347. . '</a>';
  348. }
  349. }
  350. } else {
  351. echo get_lang('ForumLocked');
  352. }
  353. }
  354. echo '</div>';
  355. /* Display */
  356. $titleForum = $current_forum['forum_title'];
  357. $descriptionForum = $current_forum['forum_comment'];
  358. $iconForum = Display::return_icon(
  359. 'forum_yellow.png',
  360. get_lang('Forum'),
  361. null,
  362. ICON_SIZE_MEDIUM
  363. );
  364. $html = '';
  365. $html .= '<div class="topic-forum">';
  366. // The current forum
  367. if ($origin != 'learnpath') {
  368. $html .= Display::tag(
  369. 'h3',
  370. $iconForum.' '.$titleForum,
  371. array(
  372. 'class' => 'title-forum')
  373. );
  374. if (!empty($descriptionForum)) {
  375. $html .= Display::tag(
  376. 'p',
  377. Security::remove_XSS($descriptionForum),
  378. array(
  379. 'class' => 'description',
  380. )
  381. );
  382. }
  383. }
  384. $html .= '</div>';
  385. echo $html;
  386. // Getting al the threads
  387. $threads = get_threads($my_forum);
  388. $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null;
  389. $course_id = api_get_course_int_id();
  390. echo '<div class="forum_display">';
  391. if (is_array($threads)) {
  392. $html = '';
  393. $count = 1;
  394. foreach ($threads as $row) {
  395. // Thread who have no replies yet and the only post is invisible should not be displayed to students.
  396. if (api_is_allowed_to_edit(false, true) ||
  397. !($row['thread_replies'] == '0' && $row['visibility'] == '0')
  398. ) {
  399. $my_whatsnew_post_info = null;
  400. if (isset($whatsnew_post_info[$my_forum][$row['thread_id']])) {
  401. $my_whatsnew_post_info = $whatsnew_post_info[$my_forum][$row['thread_id']];
  402. }
  403. if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
  404. $newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
  405. } else {
  406. $newPost = '';
  407. }
  408. $name = api_get_person_name($row['firstname'], $row['lastname']);
  409. $linkPostForum = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.$my_forum
  410. . "&thread={$row['thread_id']}&search="
  411. . Security::remove_XSS(urlencode($my_search)).'">'
  412. . $row['thread_title'].'</a>';
  413. $html = '';
  414. $html .= '<div class="panel panel-default forum '.($row['thread_sticky'] ? 'sticky' : '').'">';
  415. $html .= '<div class="panel-body">';
  416. $html .= '<div class="row">';
  417. $html .= '<div class="col-md-6">';
  418. $html .= '<div class="row">';
  419. $html .= '<div class="col-md-2">';
  420. // display the author name
  421. $tab_poster_info = api_get_user_info($row['user_id']);
  422. $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
  423. $authorName = '';
  424. if ($origin != 'learnpath') {
  425. $authorName = display_user_link(
  426. $row['user_id'],
  427. api_get_person_name($row['firstname'], $row['lastname']),
  428. '',
  429. $poster_username
  430. );
  431. } else {
  432. $authorName = Display::tag(
  433. 'span',
  434. api_get_person_name(
  435. $row['firstname'],
  436. $row['lastname']
  437. ),
  438. array(
  439. "title" => api_htmlentities($poster_username, ENT_QUOTES)
  440. )
  441. );
  442. }
  443. $html .= '<div class="thumbnail">'.display_user_image($row['user_id'], $name, $origin).'</div>';
  444. $html .= '</div>';
  445. $html .= '<div class="col-md-10">';
  446. $html .= Display::tag(
  447. 'h3',
  448. $linkPostForum,
  449. array(
  450. 'class' => 'title'
  451. )
  452. );
  453. $html .= '<p>'.get_lang('By').' '.$authorName.'</p>';
  454. $html .= '<p>'.api_convert_and_format_date($row['insert_date']).'</p>';
  455. if ($current_forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) {
  456. $waitingCount = getCountPostsWithStatus(
  457. CForumPost::STATUS_WAITING_MODERATION,
  458. $current_forum,
  459. $row['thread_id']
  460. );
  461. if (!empty($waitingCount)) {
  462. $html .= Display::label(
  463. get_lang('PostsPendingModeration').': '.$waitingCount,
  464. 'warning'
  465. );
  466. }
  467. }
  468. $html .= '</div>';
  469. $html .= '</div>';
  470. $html .= '</div>';
  471. $html .= '<div class="col-md-6">';
  472. $html .= '<div class="row">';
  473. $html .= '<div class="col-md-4">'
  474. . Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL)
  475. . " {$row['thread_replies']} ".get_lang('Replies').'<br>';
  476. $html .= Display::return_icon(
  477. 'post-forum.png',
  478. null,
  479. null,
  480. ICON_SIZE_SMALL
  481. ).' '.$row['thread_views'].' '.get_lang('Views').'<br>'.$newPost;
  482. $html .= '</div>';
  483. $last_post_info = get_last_post_by_thread(
  484. $row['c_id'],
  485. $row['thread_id'],
  486. $row['forum_id'],
  487. api_is_allowed_to_edit()
  488. );
  489. $last_post = null;
  490. if ($last_post_info) {
  491. $poster_info = api_get_user_info($last_post_info['poster_id']);
  492. $post_date = api_convert_and_format_date($last_post_info['post_date']);
  493. $last_post = $post_date.'<br>'.get_lang('By').' '.display_user_link(
  494. $last_post_info['poster_id'],
  495. $poster_info['complete_name'],
  496. '',
  497. $poster_info['username']
  498. );
  499. }
  500. $html .= '<div class="col-md-5">'
  501. . Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY)
  502. . ' '.$last_post;
  503. $html .= '</div>';
  504. $html .= '<div class="col-md-3">';
  505. $cidreq = api_get_cidreq();
  506. // Get attachment id.
  507. if (isset($row['post_id'])) {
  508. $attachment_list = get_attachment($row['post_id']);
  509. }
  510. $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
  511. $iconsEdit = '';
  512. if ($origin != 'learnpath') {
  513. if (api_is_allowed_to_edit(false, true) &&
  514. !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)
  515. ) {
  516. $iconsEdit .= '<a href="'.$forumUrl.'editthread.php?'.$cidreq
  517. . '&forum='.$my_forum.'&thread='
  518. . intval($row['thread_id'])
  519. . '&id_attach='.$id_attach.'">'
  520. . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
  521. if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) {
  522. $iconsEdit .= Display::return_icon(
  523. 'delete_na.png',
  524. get_lang('ResourceLockedByGradebook'),
  525. array(),
  526. ICON_SIZE_SMALL
  527. );
  528. } else {
  529. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  530. . $my_forum.'&action=delete&content=thread&id='
  531. . $row['thread_id']."\" onclick=\"javascript:if(!confirm('"
  532. . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))
  533. . "')) return false;\">"
  534. . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
  535. }
  536. $iconsEdit .= return_visible_invisible_icon(
  537. 'thread',
  538. $row['thread_id'],
  539. $row['visibility'],
  540. array(
  541. 'forum' => $my_forum,
  542. 'gidReq' => $groupId
  543. )
  544. );
  545. $iconsEdit .= return_lock_unlock_icon(
  546. 'thread',
  547. $row['thread_id'],
  548. $row['locked'],
  549. array(
  550. 'forum' => $my_forum,
  551. 'gidReq' => api_get_group_id()
  552. )
  553. );
  554. $iconsEdit .= '<a href="viewforum.php?'.$cidreq.'&forum='
  555. . $my_forum
  556. . '&action=move&thread='.$row['thread_id'].'">'
  557. . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL)
  558. . '</a>';
  559. }
  560. }
  561. $iconnotify = 'notification_mail_na.png';
  562. if (
  563. is_array(
  564. isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null
  565. )
  566. ) {
  567. if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
  568. $iconnotify = 'notification_mail.png';
  569. }
  570. }
  571. $icon_liststd = 'user.png';
  572. if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
  573. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  574. . $my_forum
  575. . "&action=notify&content=thread&id={$row['thread_id']}"
  576. . '">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
  577. }
  578. if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
  579. $iconsEdit .= '<a href="'.api_get_self().'?'.$cidreq.'&forum='
  580. . $my_forum
  581. . "&action=liststd&content=thread&id={$row['thread_id']}"
  582. . '">'.Display::return_icon($icon_liststd, get_lang('StudentList'), array(), ICON_SIZE_SMALL)
  583. . '</a>';
  584. }
  585. $html .= $iconsEdit;
  586. $html .= '</div>';
  587. $html .= '</div>';
  588. $html .= '</div>';
  589. $html .= '</div>';
  590. $html .= '</div>';
  591. $html .= '</div>';
  592. echo $html;
  593. }
  594. $count++;
  595. }
  596. }
  597. echo '</div>';
  598. echo isset($table_list) ? $table_list : '';
  599. if ($origin != 'learnpath') {
  600. Display::display_footer();
  601. }