announcements.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Frederik Vermeire <frederik.vermeire@pandora.be>, UGent Internship
  5. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: code cleaning
  6. * @author Julio Montoya <gugli100@gmail.com>, MORE code cleaning 2011
  7. *
  8. * @abstract The task of the internship was to integrate the 'send messages to specific users' with the
  9. * Announcements tool and also add the resource linker here. The database also needed refactoring
  10. * as there was no title field (the title was merged into the content field)
  11. * @package chamilo.announcements
  12. * multiple functions
  13. */
  14. // use anonymous mode when accessing this course tool
  15. $use_anonymous = true;
  16. // setting the global file that gets the general configuration, the databases, the languages, ...
  17. require_once __DIR__.'/../inc/global.inc.php';
  18. /* Sessions */
  19. $ctok = Security::get_existing_token();
  20. $stok = Security::get_token();
  21. $current_course_tool = TOOL_ANNOUNCEMENT;
  22. $this_section = SECTION_COURSES;
  23. $nameTools = get_lang('ToolAnnouncement');
  24. $allowToEdit = (
  25. api_is_allowed_to_edit(false, true) ||
  26. (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())
  27. );
  28. $sessionId = api_get_session_id();
  29. $drhHasAccessToSessionContent = api_get_configuration_value('drh_can_access_all_session_content');
  30. if (!empty($sessionId) && $drhHasAccessToSessionContent) {
  31. $allowToEdit = $allowToEdit || api_is_drh();
  32. }
  33. /* ACCESS RIGHTS */
  34. api_protect_course_script(true);
  35. // Configuration settings
  36. $display_announcement_list = true;
  37. $display_form = false;
  38. $display_title_list = true;
  39. // Maximum title messages to display
  40. $maximum = '12';
  41. // Length of the titles
  42. $length = '36';
  43. // Database Table Definitions
  44. $tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
  45. $tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
  46. $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
  47. $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
  48. $course_id = api_get_course_int_id();
  49. $_course = api_get_course_info_by_id($course_id);
  50. $group_id = api_get_group_id();
  51. $sessionId = api_get_session_id();
  52. if (!empty($group_id)) {
  53. $group_properties = GroupManager:: get_group_properties($group_id);
  54. $interbreadcrumb[] = array(
  55. "url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
  56. "name" => get_lang('Groups'),
  57. );
  58. $interbreadcrumb[] = array(
  59. "url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
  60. "name" => get_lang('GroupSpace').' '.$group_properties['name']
  61. );
  62. }
  63. api_protect_course_group(GroupManager::GROUP_TOOL_ANNOUNCEMENT);
  64. /* Tracking */
  65. Event::event_access_tool(TOOL_ANNOUNCEMENT);
  66. $announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
  67. $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'list';
  68. $announcement_number = AnnouncementManager::getNumberAnnouncements();
  69. $homeUrl = api_get_self().'?action=list&'.api_get_cidreq();
  70. $content = '';
  71. $searchFormToString = '';
  72. switch ($action) {
  73. case 'move':
  74. /* Move announcement up/down */
  75. if (!empty($_GET['down'])) {
  76. $thisAnnouncementId = intval($_GET['down']);
  77. $sortDirection = "DESC";
  78. }
  79. if (!empty($_GET['up'])) {
  80. $thisAnnouncementId = intval($_GET['up']);
  81. $sortDirection = "ASC";
  82. }
  83. if (!empty($sortDirection)) {
  84. if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) {
  85. $sortDirection = 'ASC';
  86. }
  87. $announcementInfo = AnnouncementManager::get_by_id($course_id, $thisAnnouncementId);
  88. $sql = "SELECT DISTINCT announcement.id, announcement.display_order
  89. FROM $tbl_announcement announcement,
  90. $tbl_item_property itemproperty
  91. WHERE
  92. announcement.c_id = $course_id AND
  93. itemproperty.c_id = $course_id AND
  94. itemproperty.ref = announcement.id AND
  95. itemproperty.tool = '".TOOL_ANNOUNCEMENT."' AND
  96. itemproperty.visibility <> 2
  97. ORDER BY display_order $sortDirection";
  98. $result = Database::query($sql);
  99. $thisAnnouncementOrderFound = false;
  100. $thisAnnouncementOrder = null;
  101. while (list($announcementId, $announcementOrder) = Database::fetch_row($result)) {
  102. if ($thisAnnouncementOrderFound) {
  103. $nextAnnouncementId = $announcementId;
  104. $nextAnnouncementOrder = $announcementOrder;
  105. $sql = "UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder'
  106. WHERE c_id = $course_id AND id = $thisAnnouncementId";
  107. Database::query($sql);
  108. $sql = "UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder'
  109. WHERE c_id = $course_id AND id = $nextAnnouncementId";
  110. Database::query($sql);
  111. break;
  112. }
  113. // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
  114. if ($announcementId == $thisAnnouncementId) {
  115. $thisAnnouncementOrder = $announcementOrder;
  116. $thisAnnouncementOrderFound = true;
  117. }
  118. }
  119. Display::addFlash(Display::return_message(get_lang('AnnouncementMoved')));
  120. header('Location: '.$homeUrl);
  121. exit;
  122. }
  123. break;
  124. case 'view':
  125. $interbreadcrumb[] = array(
  126. "url" => api_get_path(WEB_CODE_PATH)."announcements/announcements.php?".api_get_cidreq(),
  127. "name" => $nameTools,
  128. );
  129. $nameTools = get_lang('View');
  130. $content = AnnouncementManager::display_announcement($announcement_id);
  131. break;
  132. case 'list':
  133. $htmlHeadXtra[] = api_get_jqgrid_js();
  134. $searchForm = new FormValidator(
  135. 'search_simple',
  136. 'post',
  137. api_get_self().'?'.api_get_cidreq(),
  138. '',
  139. array(),
  140. FormValidator::LAYOUT_INLINE
  141. );
  142. $searchForm->addElement('text', 'keyword', get_lang('Title'));
  143. $users = CourseManager::get_user_list_from_course_code(api_get_course_id(), $sessionId);
  144. $userList = array('' => '');
  145. if (!empty($users)) {
  146. foreach ($users as $user) {
  147. $userList[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
  148. }
  149. }
  150. $users = [];
  151. $searchForm->addElement('select', 'user_id', get_lang('Users'), $userList);
  152. $searchForm->addButtonSearch(get_lang('Search'));
  153. $filterData = array();
  154. $keyword = '';
  155. $userIdToSearch = 0;
  156. if ($searchForm->validate()) {
  157. $filterData = $searchForm->getSubmitValues();
  158. $keyword = $filterData['keyword'];
  159. $userIdToSearch = $filterData['user_id'];
  160. }
  161. // jqgrid will use this URL to do the selects
  162. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_course_announcements&'.api_get_cidreq().'&title_to_search='.$keyword.'&user_id_to_search='.$userIdToSearch;
  163. $deleteUrl = api_get_path(WEB_AJAX_PATH).'announcement.ajax.php?a=delete_item&'.api_get_cidreq();
  164. $columns = array(get_lang('Title'), get_lang('By'), get_lang('LastUpdateDate'), get_lang('Actions'));
  165. // Column config
  166. $columnModel = array(
  167. array(
  168. 'name' => 'title',
  169. 'index' => 'title',
  170. 'width' => '300',
  171. 'align' => 'left',
  172. 'sortable' => 'false',
  173. ),
  174. array(
  175. 'name' => 'username',
  176. 'index' => 'username',
  177. 'width' => '100',
  178. 'align' => 'left',
  179. 'sortable' => 'false',
  180. ),
  181. array(
  182. 'name' => 'insert_date',
  183. 'index' => 'insert_date',
  184. 'width' => '200',
  185. 'align' => 'left',
  186. 'sortable' => 'false',
  187. ),
  188. array(
  189. 'name' => 'actions',
  190. 'index' => 'actions',
  191. 'width' => '150',
  192. 'align' => 'left',
  193. //'formatter' => 'action_formatter',
  194. 'sortable' => 'false'
  195. )
  196. );
  197. // Autowidth
  198. $extra_params['autowidth'] = 'true';
  199. // height auto
  200. $extra_params['height'] = 'auto';
  201. $editOptions = '';
  202. if (api_is_allowed_to_edit()) {
  203. $extra_params['multiselect'] = true;
  204. $editOptions = '
  205. $("#announcements").jqGrid(
  206. "navGrid",
  207. "#announcements_pager",
  208. { edit: false, add: false, del: true },
  209. { height:280, reloadAfterSubmit:false }, // edit options
  210. { height:280, reloadAfterSubmit:false }, // add options
  211. { reloadAfterSubmit:false, url: "'.$deleteUrl.'" }, // del options
  212. { width:500 } // search options
  213. );
  214. ';
  215. }
  216. $content = '<script>
  217. $(function() {'.
  218. Display::grid_js(
  219. 'announcements',
  220. $url,
  221. $columns,
  222. $columnModel,
  223. $extra_params,
  224. array(),
  225. '',
  226. true
  227. ).$editOptions.'
  228. });
  229. </script>';
  230. $count = AnnouncementManager::getAnnouncements($stok, $announcement_number, true);
  231. if (empty($count)) {
  232. $html = '';
  233. if ($allowToEdit && (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
  234. $html .= '<div id="no-data-view">';
  235. $html .= '<h3>'.get_lang('Announcements').'</h3>';
  236. $html .= Display::return_icon('valves.png', '', array(), 64);
  237. $html .= '<div class="controls">';
  238. $html .= Display::url(
  239. get_lang('AddAnnouncement'),
  240. api_get_self()."?".api_get_cidreq()."&action=add",
  241. array('class' => 'btn btn-primary')
  242. );
  243. $html .= '</div>';
  244. $html .= '</div>';
  245. } else {
  246. $html = Display::return_message(get_lang('NoAnnouncements'), 'warning');
  247. }
  248. $content = $html;
  249. } else {
  250. $content .= Display::grid_html('announcements');
  251. }
  252. break;
  253. case 'delete':
  254. /* Delete announcement */
  255. $id = intval($_GET['id']);
  256. if ($sessionId != 0 && api_is_allowed_to_session_edit(false, true) == false) {
  257. api_not_allowed();
  258. }
  259. if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
  260. AnnouncementManager::delete_announcement($_course, $id);
  261. Display::addFlash(Display::return_message(get_lang('AnnouncementDeleted')));
  262. }
  263. header('Location: '.$homeUrl);
  264. exit;
  265. break;
  266. case 'delete_all':
  267. if (api_is_allowed_to_edit()) {
  268. AnnouncementManager::delete_all_announcements($_course);
  269. Display::addFlash(Display::return_message(get_lang('AnnouncementDeletedAll')));
  270. header('Location: '.$homeUrl);
  271. exit;
  272. }
  273. break;
  274. case 'delete_attachment':
  275. $id = $_GET['id_attach'];
  276. if (api_is_allowed_to_edit()) {
  277. AnnouncementManager::delete_announcement_attachment_file($id);
  278. }
  279. header('Location: '.$homeUrl);
  280. exit;
  281. break;
  282. case 'showhide':
  283. if (!isset($_GET['isStudentView']) || $_GET['isStudentView'] != 'false') {
  284. if (isset($_GET['id']) && $_GET['id']) {
  285. if ($sessionId != 0 &&
  286. api_is_allowed_to_session_edit(false, true) == false
  287. ) {
  288. api_not_allowed();
  289. }
  290. if (!api_is_course_coach() ||
  291. api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])
  292. ) {
  293. AnnouncementManager::change_visibility_announcement(
  294. $_course,
  295. $_GET['id']
  296. );
  297. Display::addFlash(Display::return_message(get_lang('VisibilityChanged')));
  298. header('Location: '.$homeUrl);
  299. exit;
  300. }
  301. }
  302. }
  303. break;
  304. case 'add':
  305. case 'modify':
  306. if ($sessionId != 0 &&
  307. api_is_allowed_to_session_edit(false, true) == false
  308. ) {
  309. api_not_allowed(true);
  310. }
  311. // DISPLAY ADD ANNOUNCEMENT COMMAND
  312. $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  313. $url = api_get_self().'?action='.$action.'&id='.$id.'&'.api_get_cidreq();
  314. $form = new FormValidator(
  315. 'f1',
  316. 'post',
  317. $url,
  318. null,
  319. array('enctype' => 'multipart/form-data')
  320. );
  321. if (empty($id)) {
  322. $form_name = get_lang('AddAnnouncement');
  323. } else {
  324. $form_name = get_lang('ModifyAnnouncement');
  325. }
  326. $interbreadcrumb[] = array(
  327. "url" => api_get_path(WEB_CODE_PATH)."announcements/announcements.php?".api_get_cidreq(),
  328. "name" => $nameTools,
  329. );
  330. $nameTools = $form_name;
  331. $form->addElement('header', $form_name);
  332. $to = [];
  333. if (empty($group_id)) {
  334. if (isset($_GET['remind_inactive'])) {
  335. $email_ann = '1';
  336. $content_to_modify = sprintf(
  337. get_lang('RemindInactiveLearnersMailContent'),
  338. api_get_setting('siteName'),
  339. 7
  340. );
  341. $title_to_modify = sprintf(
  342. get_lang('RemindInactiveLearnersMailSubject'),
  343. api_get_setting('siteName')
  344. );
  345. } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') {
  346. // we want to remind inactive users. The $_GET['since'] parameter
  347. // determines which users have to be warned (i.e the users who have been inactive for x days or more
  348. $since = isset($_GET['since']) ? intval($_GET['since']) : 6;
  349. // getting the users who have to be reminded
  350. $to = Tracking:: getInactiveStudentsInCourse(
  351. api_get_course_int_id(),
  352. $since,
  353. $sessionId
  354. );
  355. // setting the variables for the form elements: the users who need to receive the message
  356. foreach ($to as &$user) {
  357. $user = 'USER:'.$user;
  358. }
  359. // setting the variables for the form elements: the message has to be sent by email
  360. $email_ann = '1';
  361. // setting the variables for the form elements: the title of the email
  362. $title_to_modify = sprintf(
  363. get_lang('RemindInactiveLearnersMailSubject'),
  364. api_get_setting('siteName')
  365. );
  366. // setting the variables for the form elements: the message of the email
  367. $content_to_modify = sprintf(
  368. get_lang('RemindInactiveLearnersMailContent'),
  369. api_get_setting('siteName'),
  370. $since
  371. );
  372. // when we want to remind the users who have never been active
  373. // then we have a different subject and content for the announcement
  374. if ($_GET['since'] == 'never') {
  375. $title_to_modify = sprintf(
  376. get_lang('RemindInactiveLearnersMailSubject'),
  377. api_get_setting('siteName')
  378. );
  379. $content_to_modify = get_lang(
  380. 'YourAccountIsActiveYouCanLoginAndCheckYourCourses'
  381. );
  382. }
  383. }
  384. $element = CourseManager::addUserGroupMultiSelect($form, array());
  385. $form->setRequired($element);
  386. if (!isset($announcement_to_modify)) {
  387. $announcement_to_modify = '';
  388. }
  389. $form->addCheckBox('email_ann', '', get_lang('EmailOption'));
  390. } else {
  391. if (!isset($announcement_to_modify)) {
  392. $announcement_to_modify = '';
  393. }
  394. $element = CourseManager::addGroupMultiSelect($form, $group_properties['iid'], array());
  395. $form->setRequired($element);
  396. $form->addCheckBox('email_ann', '', get_lang('EmailOption'));
  397. }
  398. $announcementInfo = AnnouncementManager::get_by_id($course_id, $id);
  399. if (isset($announcementInfo) && !empty($announcementInfo)) {
  400. $to = AnnouncementManager::load_edit_users("announcement", $id);
  401. $defaults = array(
  402. 'title' => $announcementInfo['title'],
  403. 'content' => $announcementInfo['content'],
  404. 'id' => $announcementInfo['id'],
  405. 'users' => $to,
  406. );
  407. } else {
  408. $defaults = array();
  409. if (!empty($to)) {
  410. $defaults['users'] = $to;
  411. }
  412. }
  413. $defaults['email_ann'] = true;
  414. $form->addElement('text', 'title', get_lang('EmailTitle'));
  415. $form->addElement('hidden', 'id');
  416. $htmlTags = "<b>".get_lang('Tags')."</b><br /><br />";
  417. $tags = AnnouncementManager::get_tags();
  418. foreach ($tags as $tag) {
  419. $htmlTags .= "<b>".$tag."</b><br />";
  420. }
  421. $form->addLabel('', "<div class='alert alert-info'>".$htmlTags."</div>");
  422. $form->addHtmlEditor(
  423. 'content',
  424. get_lang('Description'),
  425. false,
  426. false,
  427. array('ToolbarSet' => 'Announcements')
  428. );
  429. $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
  430. $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
  431. $form->addElement('hidden', 'sec_token', $stok);
  432. if (empty($sessionId)) {
  433. $form->addCheckBox('send_to_users_in_session', null, get_lang('SendToUsersInSessions'));
  434. }
  435. $config = api_get_configuration_value('announcements_hide_send_to_hrm_users');
  436. if ($config === false) {
  437. $form->addCheckBox('send_to_hrm_users', null, get_lang('SendAnnouncementCopyToDRH'));
  438. }
  439. $form->addButtonSave(get_lang('ButtonPublishAnnouncement'));
  440. $form->setDefaults($defaults);
  441. if ($form->validate()) {
  442. $data = $form->getSubmitValues();
  443. $sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;
  444. if (isset($id) && $id) {
  445. // there is an Id => the announcement already exists => update mode
  446. if ($ctok == $_POST['sec_token']) {
  447. $file_comment = $_POST['file_comment'];
  448. $file = $_FILES['user_upload'];
  449. AnnouncementManager::edit_announcement(
  450. $id,
  451. $data['title'],
  452. $data['content'],
  453. $data['users'],
  454. $file,
  455. $file_comment,
  456. $sendToUsersInSession
  457. );
  458. /* MAIL FUNCTION */
  459. if (isset($_POST['email_ann']) && empty($_POST['onlyThoseMails'])) {
  460. AnnouncementManager::sendEmail(
  461. api_get_course_info(),
  462. api_get_session_id(),
  463. $id,
  464. $sendToUsersInSession,
  465. isset($data['send_to_hrm_users'])
  466. );
  467. }
  468. Display::addFlash(
  469. Display::return_message(
  470. get_lang('AnnouncementModified'),
  471. 'success'
  472. )
  473. );
  474. header('Location: '.$homeUrl);
  475. exit;
  476. }
  477. } else {
  478. // Insert mode
  479. if ($ctok == $_POST['sec_token']) {
  480. $file = $_FILES['user_upload'];
  481. $file_comment = $data['file_comment'];
  482. if (empty($group_id)) {
  483. $insert_id = AnnouncementManager::add_announcement(
  484. api_get_course_info(),
  485. api_get_session_id(),
  486. $data['title'],
  487. $data['content'],
  488. $data['users'],
  489. $file,
  490. $file_comment,
  491. null,
  492. $sendToUsersInSession
  493. );
  494. } else {
  495. $insert_id = AnnouncementManager::add_group_announcement(
  496. $data['title'],
  497. $data['content'],
  498. array('GROUP:'.$group_id),
  499. $data['users'],
  500. $file,
  501. $file_comment,
  502. $sendToUsersInSession
  503. );
  504. }
  505. Display::addFlash(
  506. Display::return_message(
  507. get_lang('AnnouncementAdded'),
  508. 'success'
  509. )
  510. );
  511. /* MAIL FUNCTION */
  512. if (isset($data['email_ann']) && $data['email_ann']) {
  513. AnnouncementManager::sendEmail(
  514. api_get_course_info(),
  515. api_get_session_id(),
  516. $insert_id,
  517. $sendToUsersInSession
  518. );
  519. }
  520. header('Location: '.$homeUrl);
  521. exit;
  522. } // end condition token
  523. }
  524. }
  525. $content = $form->returnForm();
  526. break;
  527. }
  528. if (!empty($_GET['remind_inactive'])) {
  529. $to[] = 'USER:'.intval($_GET['remind_inactive']);
  530. }
  531. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  532. //we are not in the learning path
  533. Display::display_header($nameTools, get_lang('Announcements'));
  534. }
  535. // Tool introduction
  536. if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
  537. Display::display_introduction_section(TOOL_ANNOUNCEMENT);
  538. }
  539. // Actions
  540. $show_actions = false;
  541. $actionsLeft = '';
  542. if ($allowToEdit && (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')
  543. ) {
  544. if (in_array($action, array('add', 'modify', 'view'))) {
  545. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>".
  546. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM)."</a>";
  547. } else {
  548. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>".
  549. Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), '', ICON_SIZE_MEDIUM)."</a>";
  550. }
  551. $show_actions = true;
  552. } else {
  553. if (in_array($action, array('view'))) {
  554. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>".
  555. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM)."</a>";
  556. }
  557. }
  558. if ($allowToEdit) {
  559. if (api_get_group_id() == 0) {
  560. if (!isset($_GET['action'])) {
  561. $actionsLeft .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".
  562. Display::return_icon(
  563. 'delete_announce.png',
  564. get_lang('AnnouncementDeleteAll'),
  565. '',
  566. ICON_SIZE_MEDIUM
  567. )."</a>";
  568. }
  569. }
  570. }
  571. if ($show_actions) {
  572. echo Display::toolbarAction('toolbar', array($actionsLeft, $searchFormToString), 2, false);
  573. }
  574. echo $content;
  575. if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
  576. //we are not in learnpath tool
  577. Display::display_footer();
  578. }