announcements.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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::displayAnnouncement($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. $form->addButtonAdvancedSettings('choose_recipients', [get_lang('ChooseRecipients'), get_lang('AnnouncementChooseRecipientsDescription')]);
  333. $form->addHtml('<div id="choose_recipients_options" style="display: none;">');
  334. $to = [];
  335. if (empty($group_id)) {
  336. if (isset($_GET['remind_inactive'])) {
  337. $email_ann = '1';
  338. $content_to_modify = sprintf(
  339. get_lang('RemindInactiveLearnersMailContent'),
  340. api_get_setting('siteName'),
  341. 7
  342. );
  343. $title_to_modify = sprintf(
  344. get_lang('RemindInactiveLearnersMailSubject'),
  345. api_get_setting('siteName')
  346. );
  347. } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') {
  348. // we want to remind inactive users. The $_GET['since'] parameter
  349. // determines which users have to be warned (i.e the users who have been inactive for x days or more
  350. $since = isset($_GET['since']) ? intval($_GET['since']) : 6;
  351. // getting the users who have to be reminded
  352. $to = Tracking:: getInactiveStudentsInCourse(
  353. api_get_course_int_id(),
  354. $since,
  355. $sessionId
  356. );
  357. // setting the variables for the form elements: the users who need to receive the message
  358. foreach ($to as &$user) {
  359. $user = 'USER:'.$user;
  360. }
  361. // setting the variables for the form elements: the message has to be sent by email
  362. $email_ann = '1';
  363. // setting the variables for the form elements: the title of the email
  364. $title_to_modify = sprintf(
  365. get_lang('RemindInactiveLearnersMailSubject'),
  366. api_get_setting('siteName')
  367. );
  368. // setting the variables for the form elements: the message of the email
  369. $content_to_modify = sprintf(
  370. get_lang('RemindInactiveLearnersMailContent'),
  371. api_get_setting('siteName'),
  372. $since
  373. );
  374. // when we want to remind the users who have never been active
  375. // then we have a different subject and content for the announcement
  376. if ($_GET['since'] == 'never') {
  377. $title_to_modify = sprintf(
  378. get_lang('RemindInactiveLearnersMailSubject'),
  379. api_get_setting('siteName')
  380. );
  381. $content_to_modify = get_lang(
  382. 'YourAccountIsActiveYouCanLoginAndCheckYourCourses'
  383. );
  384. }
  385. }
  386. $element = CourseManager::addUserGroupMultiSelect($form, array());
  387. } else {
  388. $element = CourseManager::addGroupMultiSelect($form, $group_properties, array());
  389. }
  390. $form->addHtml('</div>');
  391. $form->addCheckBox('email_ann', '', get_lang('EmailOption'));
  392. if (!isset($announcement_to_modify)) {
  393. $announcement_to_modify = '';
  394. }
  395. $announcementInfo = AnnouncementManager::get_by_id($course_id, $id);
  396. if (isset($announcementInfo) && !empty($announcementInfo)) {
  397. $to = AnnouncementManager::load_edit_users("announcement", $id);
  398. $defaults = array(
  399. 'title' => $announcementInfo['title'],
  400. 'content' => $announcementInfo['content'],
  401. 'id' => $announcementInfo['id'],
  402. 'users' => $to,
  403. );
  404. } else {
  405. $defaults = array();
  406. if (!empty($to)) {
  407. $defaults['users'] = $to;
  408. }
  409. }
  410. if (isset($defaults['users'])) {
  411. foreach ($defaults['users'] as $value) {
  412. $parts = explode(':', $value);
  413. if (!isset($parts[1]) || empty($parts[1])) {
  414. continue;
  415. }
  416. $form->addHtml("
  417. <script>
  418. $(document).on('ready', function () {
  419. $('#choose_recipients').click();
  420. });
  421. </script>
  422. ");
  423. break;
  424. }
  425. }
  426. $defaults['email_ann'] = true;
  427. $form->addElement('text', 'title', get_lang('EmailTitle'));
  428. $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
  429. $form->addElement('hidden', 'id');
  430. $htmlTags = "<b>".get_lang('Tags')."</b><br /><br />";
  431. $tags = AnnouncementManager::get_tags();
  432. foreach ($tags as $tag) {
  433. $htmlTags .= "<b>".$tag."</b><br />";
  434. }
  435. $form->addLabel('', "<div class='alert alert-info'>".$htmlTags."</div>");
  436. $form->addHtmlEditor(
  437. 'content',
  438. get_lang('Description'),
  439. true,
  440. false,
  441. array('ToolbarSet' => 'Announcements')
  442. );
  443. $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
  444. $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
  445. $form->addElement('hidden', 'sec_token', $stok);
  446. if (empty($sessionId)) {
  447. $form->addCheckBox('send_to_users_in_session', null, get_lang('SendToUsersInSessions'));
  448. }
  449. $config = api_get_configuration_value('announcements_hide_send_to_hrm_users');
  450. if ($config === false) {
  451. $form->addCheckBox('send_to_hrm_users', null, get_lang('SendAnnouncementCopyToDRH'));
  452. }
  453. $form->addButtonSave(get_lang('ButtonPublishAnnouncement'));
  454. $form->setDefaults($defaults);
  455. if ($form->validate()) {
  456. $data = $form->getSubmitValues();
  457. $data['users'] = isset($data['users']) ? $data['users'] : ['everyone'];
  458. $sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;
  459. if (isset($id) && $id) {
  460. // there is an Id => the announcement already exists => update mode
  461. if ($ctok == $_POST['sec_token']) {
  462. $file_comment = $_POST['file_comment'];
  463. $file = $_FILES['user_upload'];
  464. AnnouncementManager::edit_announcement(
  465. $id,
  466. $data['title'],
  467. $data['content'],
  468. $data['users'],
  469. $file,
  470. $file_comment,
  471. $sendToUsersInSession
  472. );
  473. /* MAIL FUNCTION */
  474. if (isset($_POST['email_ann']) && empty($_POST['onlyThoseMails'])) {
  475. AnnouncementManager::sendEmail(
  476. api_get_course_info(),
  477. api_get_session_id(),
  478. $id,
  479. $sendToUsersInSession,
  480. isset($data['send_to_hrm_users'])
  481. );
  482. }
  483. Display::addFlash(
  484. Display::return_message(
  485. get_lang('AnnouncementModified'),
  486. 'success'
  487. )
  488. );
  489. header('Location: '.$homeUrl);
  490. exit;
  491. }
  492. } else {
  493. // Insert mode
  494. if ($ctok == $_POST['sec_token']) {
  495. $file = $_FILES['user_upload'];
  496. $file_comment = $data['file_comment'];
  497. if (empty($group_id)) {
  498. $insert_id = AnnouncementManager::add_announcement(
  499. api_get_course_info(),
  500. api_get_session_id(),
  501. $data['title'],
  502. $data['content'],
  503. $data['users'],
  504. $file,
  505. $file_comment,
  506. null,
  507. $sendToUsersInSession
  508. );
  509. } else {
  510. $insert_id = AnnouncementManager::add_group_announcement(
  511. $data['title'],
  512. $data['content'],
  513. array('GROUP:'.$group_id),
  514. $data['users'],
  515. $file,
  516. $file_comment,
  517. $sendToUsersInSession
  518. );
  519. }
  520. Display::addFlash(
  521. Display::return_message(
  522. get_lang('AnnouncementAdded'),
  523. 'success'
  524. )
  525. );
  526. /* MAIL FUNCTION */
  527. if (isset($data['email_ann']) && $data['email_ann']) {
  528. AnnouncementManager::sendEmail(
  529. api_get_course_info(),
  530. api_get_session_id(),
  531. $insert_id,
  532. $sendToUsersInSession
  533. );
  534. }
  535. header('Location: '.$homeUrl);
  536. exit;
  537. } // end condition token
  538. }
  539. }
  540. $content = $form->returnForm();
  541. break;
  542. }
  543. if (!empty($_GET['remind_inactive'])) {
  544. $to[] = 'USER:'.intval($_GET['remind_inactive']);
  545. }
  546. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  547. //we are not in the learning path
  548. Display::display_header($nameTools, get_lang('Announcements'));
  549. }
  550. // Tool introduction
  551. if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
  552. Display::display_introduction_section(TOOL_ANNOUNCEMENT);
  553. }
  554. // Actions
  555. $show_actions = false;
  556. $actionsLeft = '';
  557. if ($allowToEdit && (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')
  558. ) {
  559. if (in_array($action, array('add', 'modify', 'view'))) {
  560. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>".
  561. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM)."</a>";
  562. } else {
  563. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>".
  564. Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), '', ICON_SIZE_MEDIUM)."</a>";
  565. }
  566. $show_actions = true;
  567. } else {
  568. if (in_array($action, array('view'))) {
  569. $actionsLeft .= "<a href='".api_get_self()."?".api_get_cidreq()."'>".
  570. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM)."</a>";
  571. }
  572. }
  573. if ($allowToEdit) {
  574. if (api_get_group_id() == 0) {
  575. if (!isset($_GET['action'])) {
  576. $actionsLeft .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".
  577. Display::return_icon(
  578. 'delete_announce.png',
  579. get_lang('AnnouncementDeleteAll'),
  580. '',
  581. ICON_SIZE_MEDIUM
  582. )."</a>";
  583. }
  584. }
  585. }
  586. if ($show_actions) {
  587. echo Display::toolbarAction('toolbar', array($actionsLeft, $searchFormToString));
  588. }
  589. echo $content;
  590. if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
  591. //we are not in learnpath tool
  592. Display::display_footer();
  593. }