announcements.php 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548
  1. <?php //$Id: announcements.php 2009-11-13 18:56:45Z aportugal $
  2. /* For licensing terms, see /dokeos_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. * @abstract The task of the internship was to integrate the 'send messages to specific users' with the
  7. * Announcements tool and also add the resource linker here. The database also needed refactoring
  8. * as there was no title field (the title was merged into the content field)
  9. * @package dokeos.announcements
  10. * @todo make AWACS out of the configuration settings
  11. * @todo this file is 1200+ lines without any functions -> needs to be split into
  12. * multiple functions
  13. */
  14. /*
  15. ==============================================================================
  16. INIT SECTION
  17. ==============================================================================
  18. */
  19. // name of the language file that needs to be included
  20. $language_file[] = 'announcements';
  21. $language_file[] = 'group';
  22. $language_file[] = 'survey';
  23. // use anonymous mode when accessing this course tool
  24. $use_anonymous = true;
  25. // setting the global file that gets the general configuration, the databases, the languages, ...
  26. require_once '../inc/global.inc.php';
  27. $this_section=SECTION_COURSES;
  28. $nameTools = get_lang('Announcement');
  29. //session
  30. if(isset($_GET['id_session'])) {
  31. $_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']);
  32. }
  33. /* ------------ ACCESS RIGHTS ------------ */
  34. // notice for unauthorized people.
  35. api_protect_course_script();
  36. /*
  37. -----------------------------------------------------------
  38. Constants and variables
  39. -----------------------------------------------------------
  40. */
  41. // Configuration settings
  42. $display_announcement_list = true;
  43. $display_form = false;
  44. $display_title_list = true;
  45. // Maximum title messages to display
  46. $maximum = '12';
  47. // Length of the titles
  48. $length = '36';
  49. // Database Table Definitions
  50. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  51. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  52. $tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
  53. $tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
  54. $tbl_session_course_user= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  55. $tbl_group = Database::get_course_table(TABLE_GROUP);
  56. $tbl_groupUser = Database::get_course_table(TABLE_GROUP_USER);
  57. $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
  58. $tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
  59. $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
  60. /*
  61. -----------------------------------------------------------
  62. Resource linker
  63. -----------------------------------------------------------
  64. */
  65. $_SESSION['source_type']="Ad_Valvas";
  66. include('../resourcelinker/resourcelinker.inc.php');
  67. if (!empty($_POST['addresources'])) // When the "Add Resource" button is clicked we store all the form data into a session
  68. {
  69. include('announcements.inc.php');
  70. $form_elements= array ('emailTitle'=>stripslashes($emailTitle), 'newContent'=>stripslashes($newContent), 'id'=>$id, 'to'=>$selectedform, 'emailoption'=>$email_ann);
  71. $_SESSION['formelements']=$form_elements;
  72. if($id) // this is to correctly handle edits
  73. {
  74. $action="edit";
  75. }else
  76. {
  77. $action="add";
  78. }
  79. // ============== //
  80. // 7 = Ad_Valvas //
  81. // ============== //
  82. if($surveyid)
  83. {
  84. header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no&publish_survey=$surveyid&db_name=$db_name&cidReq=$cidReq");
  85. exit;
  86. }
  87. else
  88. {
  89. header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no");
  90. exit;
  91. }
  92. exit;
  93. }
  94. /*
  95. -----------------------------------------------------------
  96. Tracking
  97. -----------------------------------------------------------
  98. */
  99. event_access_tool(TOOL_ANNOUNCEMENT);
  100. /*
  101. -----------------------------------------------------------
  102. Libraries
  103. -----------------------------------------------------------
  104. */
  105. $lib = api_get_path(LIBRARY_PATH); //avoid useless function calls
  106. require_once($lib.'groupmanager.lib.php');
  107. require_once('announcements.inc.php');
  108. require_once($lib.'mail.lib.inc.php');
  109. require_once($lib.'debug.lib.inc.php');
  110. require_once($lib.'tracking.lib.php');
  111. require_once($lib.'fckeditor/fckeditor.php');
  112. require_once($lib.'fileUpload.lib.php');
  113. /*
  114. -----------------------------------------------------------
  115. POST TO
  116. -----------------------------------------------------------
  117. */
  118. $safe_emailTitle = $_POST['emailTitle'];
  119. $safe_newContent = $_POST['newContent'];
  120. if (!empty($_POST['To']))
  121. {
  122. if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
  123. api_not_allowed();
  124. }
  125. $display_form = true;
  126. $form_elements = array ('emailTitle'=>$safe_emailTitle, 'newContent'=>$safe_newContent, 'id'=>Security::remove_XSS($_POST['id']), 'emailoption'=>Security::remove_XSS($_POST['email_ann']));
  127. $_SESSION['formelements'] = $form_elements;
  128. $form_elements = $_SESSION['formelements'];
  129. $title_to_modify = $form_elements["emailTitle"];
  130. $content_to_modify = $form_elements["newContent"];
  131. $announcement_to_modify = $form_elements["id"];
  132. }
  133. /*
  134. -----------------------------------------------------------
  135. Show/hide user/group form
  136. -----------------------------------------------------------
  137. */
  138. $setting_select_groupusers = true;
  139. if (empty($_POST['To']) and !$_SESSION['select_groupusers'])
  140. {
  141. $_SESSION['select_groupusers'] = "hide";
  142. }
  143. $select_groupusers_status=$_SESSION['select_groupusers'];
  144. if (!empty($_POST['To']) and ($select_groupusers_status=="hide"))
  145. {
  146. $_SESSION['select_groupusers'] = "show";
  147. }
  148. if (!empty($_POST['To']) and ($select_groupusers_status=="show"))
  149. {
  150. $_SESSION['select_groupusers'] = "hide";
  151. }
  152. /*
  153. -----------------------------------------------------------
  154. Action handling
  155. -----------------------------------------------------------
  156. */
  157. // display the form
  158. if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To']))
  159. {
  160. if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
  161. api_not_allowed();
  162. }
  163. $display_form = true;
  164. }
  165. // clear all resources
  166. if ((empty($originalresource) || ($originalresource!=='no')) and (!empty($action) && $action=='add'))
  167. {
  168. $_SESSION['formelements']=null;
  169. //unset($_SESSION['formelements']);
  170. unset_session_resources();
  171. }
  172. /*
  173. -----------------------------------------------------------
  174. Javascript
  175. -----------------------------------------------------------
  176. */
  177. $htmlHeadXtra[] = to_javascript();
  178. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  179. $htmlHeadXtra[] = '<script type="text/javascript">
  180. function setFocus(){
  181. $("#emailTitle").focus();
  182. }
  183. $(document).ready(function () {
  184. setFocus();
  185. });
  186. </script>';
  187. /*
  188. -----------------------------------------------------------
  189. Filter user/group
  190. -----------------------------------------------------------
  191. */
  192. if(!empty($_GET['toolgroup'])){
  193. if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){ //check is integer
  194. $toolgroup = $_GET['toolgroup'];
  195. $_SESSION['select_groupusers'] = 'hide';
  196. }else{
  197. $toolgroup = 0;
  198. }
  199. api_session_register("toolgroup");
  200. }
  201. /*
  202. -----------------------------------------------------------
  203. Sessions
  204. -----------------------------------------------------------
  205. */
  206. $ctok = $_SESSION['sec_token'];
  207. $stok = Security::get_token();
  208. if (!empty($_SESSION['formelements']) and !empty($_GET['originalresource']) and $_GET['originalresource'] == 'no')
  209. {
  210. $form_elements = $_SESSION['formelements'];
  211. $title_to_modify = $form_elements['emailTitle'];
  212. $content_to_modify = $form_elements['newContent'];
  213. $announcement_to_modify = $form_elements['id'];
  214. $to = $form_elements['to'];
  215. //load_edit_users('announcement',$announcement_to_modify);
  216. $email_ann = $form_elements['emailoption'];
  217. }
  218. if(!empty($_GET['remind_inactive']))
  219. {
  220. $to[] = 'USER:'.intval($_GET['remind_inactive']);
  221. }
  222. /*
  223. -----------------------------------------------------------
  224. Survey
  225. -----------------------------------------------------------
  226. */
  227. $surveyid = 0;
  228. if(!empty($_REQUEST['publish_survey']))
  229. {
  230. $surveyid=Database::escape_string(Security::remove_XSS($_REQUEST['publish_survey']));
  231. }
  232. $cidReq=Database::escape_string($_REQUEST['cidReq']);
  233. if($surveyid)
  234. {
  235. $db_name=Database::escape_string($_REQUEST['db_name']);
  236. $sql_temp = "SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
  237. $res_temp = Database::query($sql_temp, __FILE__, __LINE__);
  238. $obj=@Database::fetch_object($res_temp);
  239. $template=$obj->template;
  240. }
  241. if (!empty($_SESSION['toolgroup'])){
  242. $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
  243. $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
  244. $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
  245. $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
  246. } else {
  247. if($surveyid) {
  248. $interbreadcrumb[] = array ("url" => "../survey/survey_list.php?cidReq=$cidReq", "name" => get_lang('Survey'));
  249. $nameTools = get_lang('PublishSurvey');
  250. }else {
  251. $nameTools = get_lang('Announcement');
  252. $nameTools12 = get_lang('PublishSurvey');
  253. }
  254. }
  255. /*
  256. -----------------------------------------------------------
  257. Learning path & css
  258. -----------------------------------------------------------
  259. */
  260. // showing the header if we are not in the learning path, if we are in
  261. // the learning path, we do not include the banner so we have to explicitly
  262. // include the stylesheet, which is normally done in the header
  263. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
  264. {
  265. //we are not in the learning path
  266. Display::Display_header($nameTools,"Announcements");
  267. }
  268. else
  269. {
  270. //we are in the learning path, only display central data and change css
  271. $display_title_list = false;
  272. $display_announcement_list = false;
  273. $display_specific_announcement = true;
  274. $announcement_id = $_REQUEST['ann_id'];
  275. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH).'css/'.$my_style; ?>/default.css">
  276. <!-- css file for announcements -->
  277. <link href="../css/<?php echo $my_style; ?>/announcements.css" rel="stylesheet" type="text/css">
  278. <?php
  279. }
  280. // inserting an anchor (top) so one can jump back to the top of the page
  281. echo "<a name=\"top\"></a>";
  282. /*=============================================
  283. ACTION HANDLING
  284. =============================================*/
  285. if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  286. /*
  287. -----------------------------------------------------------
  288. Change visibility of announcement
  289. -----------------------------------------------------------
  290. */
  291. // $_GET['isStudentView']<>"false" is added to prevent that the visibility
  292. // is changed after you do the following:
  293. // change visibility -> studentview -> course manager view
  294. if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') {
  295. if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") {
  296. if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
  297. api_not_allowed();
  298. }
  299. $id=intval($_GET['id']);
  300. if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
  301. if ($ctok == $_GET['sec_token']) {
  302. change_visibility_announcement(TOOL_ANNOUNCEMENT,$id);
  303. $message = get_lang("VisibilityChanged");
  304. }
  305. }
  306. }
  307. }
  308. /*
  309. -----------------------------------------------------------
  310. Delete announcement
  311. -----------------------------------------------------------
  312. */
  313. if (!empty($_GET['action']) AND $_GET['action']=='delete' AND isset($_GET['id'])) {
  314. //Database::query("DELETE FROM $tbl_announcement WHERE id='$delete'",__FILE__,__LINE__);
  315. $id=intval(addslashes($_GET['id']));
  316. if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
  317. api_not_allowed();
  318. }
  319. if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
  320. // tooledit : visibility = 2 : only visibile for platform administrator
  321. if ($ctok == $_GET['sec_token']) {
  322. Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."' and ref='".$id."'",__FILE__,__LINE__);
  323. delete_added_resource("Ad_Valvas", $delete);
  324. $id = null;
  325. $emailTitle = null;
  326. $newContent = null;
  327. $message = get_lang("AnnouncementDeleted");
  328. }
  329. }
  330. }
  331. /*
  332. -----------------------------------------------------------
  333. Delete all announcements
  334. -----------------------------------------------------------
  335. */
  336. if (!empty($_GET['action']) and $_GET['action']=='delete_all') {
  337. //Database::query("DELETE FROM $tbl_announcement",__FILE__,__LINE__);
  338. if (api_is_allowed_to_edit()) {
  339. Database::query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."'",__FILE__,__LINE__);
  340. delete_all_resources_type("Ad_Valvas");
  341. $id = null;
  342. $emailTitle = null;
  343. $newContent = null;
  344. $message = get_lang("AnnouncementDeletedAll");
  345. }
  346. }
  347. /*
  348. -----------------------------------------------------------
  349. Modify announcement
  350. -----------------------------------------------------------
  351. */
  352. if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) {
  353. if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
  354. api_not_allowed();
  355. }
  356. $display_form = true;
  357. // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
  358. $id = intval(addslashes($_GET['id']));
  359. if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) {
  360. $sql="SELECT * FROM $tbl_announcement WHERE id='$id'";
  361. $result = Database::query($sql,__FILE__,__LINE__);
  362. $myrow = Database::fetch_array($result);
  363. $last_id = $id;
  364. $edit_attachment = edit_announcement_attachment_file($last_id, $_FILES['user_upload'], $file_comment);
  365. if ($myrow) {
  366. $announcement_to_modify = $myrow['id'];
  367. $content_to_modify = $myrow['content'];
  368. $title_to_modify = $myrow['title'];
  369. if ($originalresource!=="no") {
  370. //unset_session_resources();
  371. edit_added_resources("Ad_Valvas", $announcement_to_modify);
  372. $to=load_edit_users("announcement", $announcement_to_modify);
  373. }
  374. $display_announcement_list = false;
  375. }
  376. if ($to=="everyone" OR !empty($_SESSION['toolgroup']))
  377. {
  378. $_SESSION['select_groupusers']="hide";
  379. }
  380. else
  381. {
  382. $_SESSION['select_groupusers']="show";
  383. }
  384. }
  385. }
  386. /*
  387. -----------------------------------------------------------
  388. Move announcement up/down
  389. -----------------------------------------------------------
  390. */
  391. if ($ctok == $_GET['sec_token']) {
  392. if (!empty($_GET['down'])) {
  393. $thisAnnouncementId = intval($_GET['down']);
  394. $sortDirection = "DESC";
  395. }
  396. if (!empty($_GET['up'])) {
  397. $thisAnnouncementId = intval($_GET['up']);
  398. $sortDirection = "ASC";
  399. }
  400. }
  401. if (!empty($sortDirection)) {
  402. if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) {
  403. $sortDirection='ASC';
  404. }
  405. $my_sql = "SELECT announcement.id, announcement.display_order " .
  406. "FROM $tbl_announcement announcement, " .
  407. "$tbl_item_property itemproperty " .
  408. "WHERE itemproperty.ref=announcement.id " .
  409. "AND itemproperty.tool='".TOOL_ANNOUNCEMENT."' " .
  410. "AND itemproperty.visibility<>2 " .
  411. "ORDER BY display_order $sortDirection";
  412. $result = Database::query($my_sql,__FILE__,__LINE__);
  413. while (list ($announcementId, $announcementOrder) = Database::fetch_row($result)) {
  414. // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
  415. // COMMIT ORDER SWAP ON THE DB
  416. if (isset ($thisAnnouncementOrderFound) && $thisAnnouncementOrderFound == true) {
  417. $nextAnnouncementId = $announcementId;
  418. $nextAnnouncementOrder = $announcementOrder;
  419. Database::query("UPDATE $tbl_announcement " .
  420. "SET display_order = '$nextAnnouncementOrder' " .
  421. "WHERE id = '$thisAnnouncementId'",__FILE__,__LINE__);
  422. Database::query("UPDATE $tbl_announcement " .
  423. "SET display_order = '$thisAnnouncementOrder' " .
  424. "WHERE id = '$nextAnnouncementId.'",__FILE__,__LINE__);
  425. break;
  426. }
  427. // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
  428. if ($announcementId == $thisAnnouncementId) {
  429. $thisAnnouncementOrder = $announcementOrder;
  430. $thisAnnouncementOrderFound = true;
  431. }
  432. }
  433. // show message
  434. $message = get_lang('AnnouncementMoved');
  435. }
  436. /*
  437. -----------------------------------------------------------
  438. Submit announcement
  439. -----------------------------------------------------------
  440. */
  441. //if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  442. $emailTitle=(!empty($_POST['emailTitle'])?$safe_emailTitle:'');
  443. $newContent=(!empty($_POST['newContent'])?$safe_newContent:'');
  444. $submitAnnouncement=isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0;
  445. $id = 0;
  446. if (!empty($_POST['id'])) {
  447. $id=intval($_POST['id']);
  448. }
  449. if ($submitAnnouncement && empty($emailTitle)) {
  450. $error_message = get_lang('TitleIsRequired');
  451. $content_to_modify = $newContent;
  452. } else if ($submitAnnouncement) {
  453. if (isset($id)&&$id) {
  454. // there is an Id => the announcement already exists => update mode
  455. if ($ctok == $_POST['sec_token']) {
  456. $file_comment = $_POST['file_comment'];
  457. $file = $_FILES['user_upload'];
  458. $edit_id = edit_advalvas_item($id,$emailTitle,$newContent,$_POST['selectedform'],$file,$file_comment);
  459. if (!$delete) {
  460. update_added_resources("Ad_Valvas", $id);
  461. }
  462. $message = get_lang('AnnouncementModified');
  463. }
  464. } else {
  465. //insert mode
  466. if ($ctok == $_POST['sec_token']) {
  467. if (!$surveyid) {
  468. $result = Database::query("SELECT MAX(display_order) FROM $tbl_announcement WHERE session_id=".intval($_SESSION['id_session'])." OR session_id=0",__FILE__,__LINE__);
  469. list($orderMax) = Database::fetch_row($result);
  470. $order = $orderMax + 1;
  471. $file = $_FILES['user_upload'];
  472. $file_comment = $_POST['file_comment'];
  473. if (!empty($_SESSION['toolgroup'])) {
  474. $insert_id=store_advalvas_group_item($safe_emailTitle,$safe_newContent,$order,array('GROUP:'.$_SESSION['toolgroup']),$_POST['selectedform'],$file,$file_comment);
  475. } else {
  476. $insert_id=store_advalvas_item($safe_emailTitle,$safe_newContent,$order,$_POST['selectedform'],$file,$file_comment);
  477. }
  478. store_resources($_SESSION['source_type'],$insert_id);
  479. $_SESSION['select_groupusers']="hide";
  480. $message = get_lang('AnnouncementAdded');
  481. }
  482. /*============================================================
  483. MAIL WHEN USER COMES FROM SURVEY
  484. ======================================================= */
  485. if ($_POST['emailsAdd']) {
  486. $to_email_address =$_POST['emailsAdd'];
  487. $to_email_to = explode(',', $to_email_address);
  488. $to_email = array_unique($to_email_to);
  489. $db_name = $_REQUEST['db_name'];
  490. for ($i=0;$i<count($to_email);$i++) {
  491. $to= trim($to_email[$i]);
  492. $db_name = $_REQUEST['db_name'];
  493. $newContentone=str_replace("#page#","choose_language.php",$newContent);
  494. $newContenttwo=str_replace("#temp#",$template,$newContentone);
  495. $newContentthree=str_replace("#sid#",$surveyid,$newContenttwo);
  496. $newContentfour=str_replace("#mail#",$to,$newContentthree);
  497. $newContentfive=str_replace("#db_name#",$db_name,$newContentfour);
  498. $newContentsix=str_replace("#uid#","",$newContentfive);
  499. if (eregi('^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,3})$', $to )) {
  500. $subject=stripslashes($emailTitle);
  501. $message=stripslashes($newContentsix);
  502. $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
  503. $email = $_SESSION['_user']['mail'];
  504. $headers="From:$sender_name\r\nReply-to: $email";
  505. //@mail($to,$subject,$message,$headers);
  506. //api_send_mail($to,$subject,$message,$headers);
  507. api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
  508. $sql_date="SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
  509. $res_date=Database::query($sql_date, __FILE__, __LINE__);
  510. $obj_date=Database::fetch_object($res_date);
  511. $end_date=$obj_date->avail_till;
  512. $table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
  513. if ($_REQUEST['reminder']=="1") {
  514. $time=getdate();
  515. $time = $time['yday'];
  516. $time = $time+7;
  517. $sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
  518. Database::query($sql_insert, __FILE__, __LINE__);
  519. } else if ($_REQUEST['reminder']=="2") {
  520. $time=getdate();
  521. $time = $time['yday'];
  522. $time = $time+14;
  523. $sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
  524. Database::query($sql_insert, __FILE__, __LINE__);
  525. } else if($_REQUEST['reminder']=="3") {
  526. $time=getdate();
  527. $time = $time['yday'];
  528. $time = $time+30;
  529. $sql_insert="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','".addslashes($subject)."','".addslashes($message)."','1','$time','$end_date')";
  530. Database::query($sql_insert, __FILE__, __LINE__);
  531. }
  532. }
  533. }
  534. }
  535. /*===================================================================
  536. MAIL FUNCTION
  537. ===================================================================*/
  538. if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) {
  539. $sent_to=sent_to("announcement", $insert_id);
  540. $userlist = $sent_to['users'];
  541. $grouplist = $sent_to['groups'];
  542. // groepen omzetten in users
  543. if ($grouplist) {
  544. $grouplist = "'".implode("', '",$grouplist)."'"; //protect individual elements with surrounding quotes
  545. $sql = "SELECT user_id
  546. FROM $tbl_groupUser gu
  547. WHERE gu.group_id IN (".$grouplist.")";
  548. $groupMemberResult = Database::query($sql,__FILE__,__LINE__);
  549. if ($groupMemberResult) {
  550. while ($u = Database::fetch_array($groupMemberResult)) {
  551. $userlist [] = $u ['user_id']; // complete the user id list ...
  552. }
  553. }
  554. }
  555. if (is_array($userlist)) {
  556. $userlist = "'".implode("', '", array_unique($userlist) )."'";
  557. // send to the created 'userlist'
  558. $sqlmail = "SELECT user_id, lastname, firstname, email
  559. FROM $tbl_user
  560. WHERE user_id IN (".$userlist.")";
  561. } else if (empty($_POST['not_selected_form'])) {
  562. if(empty($_SESSION['id_session']) || api_get_setting('use_session_mode')=='false') {
  563. // send to everybody
  564. $sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
  565. FROM $tbl_course_user, $tbl_user
  566. WHERE course_code='".Database::escape_string($_course['sysCode'])."'
  567. AND course_rel_user.user_id = user.user_id";
  568. } else {
  569. $sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
  570. FROM $tbl_user
  571. INNER JOIN $tbl_session_course_user
  572. ON $tbl_user.user_id = $tbl_session_course_user.id_user
  573. AND $tbl_session_course_user.course_code = '".$_course['id']."'
  574. AND $tbl_session_course_user.id_session = ".intval($_SESSION['id_session']);
  575. }
  576. }
  577. if ($sqlmail != '') {
  578. $result = Database::query($sqlmail,__FILE__,__LINE__);
  579. /*=================================================================================
  580. send email one by one to avoid antispam
  581. =================================================================================*/
  582. $db_name = Database::get_course_table(TABLE_MAIN_SURVEY);
  583. while ($myrow = Database::fetch_array($result)) {
  584. /* Header : Bericht van uw lesgever - GES ($_cid)
  585. Body : John Doe (prenom + nom) <john_doe@hotmail.com> (email)
  586. Morgen geen les!! (emailTitle)
  587. Morgen is er geen les, de les wordt geschrapt wegens vergadering (newContent)
  588. */
  589. $emailSubject = "[" . $_course['official_code'] . "] " . $emailTitle;
  590. if ($surveyid) {
  591. $newContentone=str_replace("#page#","choose_language.php",$newContent);
  592. $newContenttwo=str_replace("#temp#",$template,$newContentone);
  593. $newContentthree=str_replace("#sid#",$surveyid,$newContenttwo);
  594. $newContentfour=str_replace("#mail#",$myrow["email"],$newContentthree);
  595. $newContentfive=str_replace("#db_name#",$db_name,$newContentfour);
  596. $newContentsix=str_replace("#uid#",$myrow["user_id"],$newContentfive);
  597. $message=stripslashes($newContentsix);
  598. $sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
  599. $email = $_SESSION['_user']['mail'];
  600. $headers="From:$sender_name\r\nReply-to: $email";
  601. //@mail($myrow["email"],stripslashes($emailTitle),$message,$headers);
  602. api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
  603. } else {
  604. // intro of the email: receiver name and subject
  605. $mail_body = api_get_person_name($myrow["lastname"], $myrow["firstname"], null, PERSON_NAME_EMAIL_ADDRESS)."<br />\n".stripslashes($emailTitle)."<br />";
  606. // make a change for absolute url
  607. $newContent = str_replace('src=\"../../','src=\"'.api_get_path(WEB_PATH).'', $newContent);
  608. // main part of the email
  609. $mail_body .= trim(stripslashes($newContent));
  610. // signature of email: sender name and course URL after -- line
  611. $mail_body .= "<br />-- <br />";
  612. $mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)." \n";
  613. $mail_body .= "<br /> \n<a href=\"".api_get_path(WEB_COURSE_PATH).$_course['id']."\">";
  614. $mail_body .= $_course['official_code'].' '.$_course['name'] . "</a>";
  615. //set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
  616. //here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
  617. $recipient_name = api_get_person_name($myrow["firstname"], $myrow["lastname"], null, PERSON_NAME_EMAIL_ADDRESS);
  618. $mailid = $myrow["email"];
  619. $sender_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
  620. $sender_email = $_SESSION['_user']['mail'];
  621. $data_file = array();
  622. if (!empty($_FILES['user_upload'])) {
  623. $courseDir = $_course['path'].'/upload/announcements/';
  624. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  625. $sql = 'SELECT path, filename FROM '.$tbl_announcement_attachment.'
  626. WHERE announcement_id = "'.$insert_id.'"';
  627. $result = Database::query($sql, __FILE__, __LINE__);
  628. $row = Database::fetch_array($result);
  629. $data_file = array('path' => $sys_course_path.$courseDir.$row['path'],
  630. 'filename' => $row['filename']);
  631. }
  632. api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file);
  633. }
  634. $sql_date="SELECT * FROM $db_name WHERE survey_id='$surveyid'";
  635. $res_date=Database::query($sql_date, __FILE__, __LINE__);
  636. $obj_date=Database::fetch_object($res_date);
  637. $end_date=$obj_date->avail_till;
  638. $table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
  639. if ($_REQUEST['reminder']=="1") {
  640. $time=getdate();
  641. $time = $time['yday'];
  642. $time = $time+7;
  643. $sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
  644. Database::query($sql, __FILE__, __LINE__);
  645. } else if ($_REQUEST['reminder']=="2") {
  646. $time=getdate();
  647. $time = $time['yday'];
  648. $time = $time+14;
  649. $sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
  650. Database::query($sql, __FILE__, __LINE__);
  651. } else if ($_REQUEST['reminder']=="3") {
  652. $time=getdate();
  653. $time = $time['yday'];
  654. $time = $time+30;
  655. $sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')";
  656. Database::query($sql, __FILE__, __LINE__);
  657. }
  658. }
  659. update_mail_sent($insert_id);
  660. $message = $added_and_sent;
  661. }
  662. } // $email_ann*/
  663. } // end condition token
  664. } // isset
  665. // UNSET VARIABLES
  666. unset_session_resources();
  667. unset($form_elements);
  668. $_SESSION['formelements']=null;
  669. $newContent = null;
  670. $emailTitle = null;
  671. unset($emailTitle);
  672. unset($newContent);
  673. unset($content_to_modify);
  674. unset($title_to_modify);
  675. if($_REQUEST['publish_survey']) {
  676. $surveyid=$_REQUEST['surveyid'];
  677. $cidReq = $_REQUEST['cidReq'];
  678. ?>
  679. <script>
  680. window.location.href="../survey/survey_list.php?<?php echo api_get_cidreq(); ?>&published=published&surveyid=<?php echo Security::remove_XSS($_REQUEST['publish_survey']); ?>";
  681. </script>
  682. <?php
  683. }
  684. } // if $submit Announcement
  685. }
  686. /*====================================================
  687. Tool introduction
  688. ====================================================*/
  689. if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') {
  690. //api_display_tool_title($nameTools);
  691. Display::display_introduction_section(TOOL_ANNOUNCEMENT);
  692. }
  693. /*
  694. ==============================================================================
  695. MAIN SECTION
  696. ==============================================================================
  697. */
  698. /* DISPLAY LEFT COLUMN */
  699. //condition for the session
  700. $session_id = api_get_session_id();
  701. $condition_session = api_get_session_condition($session_id);
  702. if(api_is_allowed_to_edit(false,true)) {
  703. // check teacher status
  704. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  705. $sql="SELECT
  706. announcement.*, toolitemproperties.*
  707. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  708. WHERE announcement.id = toolitemproperties.ref
  709. AND toolitemproperties.tool='announcement'
  710. AND toolitemproperties.visibility<>'2'
  711. $condition_session
  712. GROUP BY toolitemproperties.ref
  713. ORDER BY display_order DESC
  714. LIMIT 0,$maximum";
  715. }
  716. } else {
  717. // students only get to see the visible announcements
  718. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  719. $group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
  720. if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  721. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR ( toolitemproperties.to_user_id='".$_user['user_id']."'" .
  722. "OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
  723. } else {
  724. $cond_user_id = " AND ( toolitemproperties.to_user_id='".$_user['user_id']."'" .
  725. "OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
  726. }
  727. // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
  728. if (is_array($group_memberships) && count($group_memberships)>0) {
  729. $sql="SELECT
  730. announcement.*, toolitemproperties.*
  731. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  732. WHERE announcement.id = toolitemproperties.ref
  733. AND toolitemproperties.tool='announcement'
  734. AND toolitemproperties.visibility='1'
  735. $cond_user_id
  736. $condition_session
  737. GROUP BY toolitemproperties.ref
  738. ORDER BY display_order DESC
  739. LIMIT 0,$maximum";
  740. } else {
  741. // the user is not member of any group
  742. // this is an identified user => show the general announcements AND his personal announcements
  743. if ($_user['user_id']) {
  744. if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  745. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR ( toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0')) ";
  746. } else {
  747. $cond_user_id = " AND ( toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0') ";
  748. }
  749. $sql="SELECT
  750. announcement.*, toolitemproperties.*
  751. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  752. WHERE announcement.id = toolitemproperties.ref
  753. AND toolitemproperties.tool='announcement'
  754. AND toolitemproperties.visibility='1'
  755. $cond_user_id
  756. $condition_session
  757. GROUP BY toolitemproperties.ref
  758. ORDER BY display_order DESC
  759. LIMIT 0,$maximum";
  760. } else {
  761. if (api_get_course_setting('allow_user_edit_announcement')) {
  762. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR toolitemproperties.to_group_id='0') ";
  763. } else {
  764. $cond_user_id = " AND toolitemproperties.to_group_id='0' ";
  765. }
  766. // the user is not identiefied => show only the general announcements
  767. $sql="SELECT
  768. announcement.*, toolitemproperties.*
  769. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  770. WHERE announcement.id = toolitemproperties.ref
  771. AND toolitemproperties.tool='announcement'
  772. AND toolitemproperties.visibility='1'
  773. AND toolitemproperties.to_group_id='0'
  774. $condition_session
  775. GROUP BY toolitemproperties.ref
  776. ORDER BY display_order DESC
  777. LIMIT 0,$maximum";
  778. }
  779. }
  780. }
  781. }
  782. $result = Database::query($sql,__FILE__,__LINE__);
  783. $announcement_number = Database::num_rows($result);
  784. /*----------------------------------------------------
  785. ADD ANNOUNCEMENT / DELETE ALL
  786. ----------------------------------------------------*/
  787. if (!$surveyid) {
  788. $show_actions = false;
  789. if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) {
  790. echo '<div class="actions">';
  791. echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('announce_add.gif',get_lang('AddAnnouncement')).get_lang('AddAnnouncement')."</a>";
  792. $show_actions = true;
  793. }
  794. if (api_is_allowed_to_edit() && $announcement_number > 1) {
  795. if (!$show_actions)
  796. echo '<div class="actions">';
  797. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('valvesdelete.gif',get_lang('AnnouncementDeleteAll')).get_lang('AnnouncementDeleteAll')."</a>\n"; } // if announcementNumber > 1
  798. if ($show_actions)
  799. echo '</div>';
  800. }
  801. if (empty($_GET['origin']) OR $_GET['origin'] !== 'learnpath') {
  802. echo "\n\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  803. echo "\t<tr>\n";
  804. echo "\t\t<td width=\"20%\" valign=\"top\">\n";
  805. }
  806. /*----------------------------------------------------
  807. ANNOUNCEMENTS LIST
  808. ----------------------------------------------------*/
  809. if (!$surveyid) {
  810. if ($display_title_list == true) {
  811. echo "\t\t\t<table>\n";
  812. while ($myrow = Database::fetch_array($result)) {
  813. $title = $myrow['title'];
  814. $title = Security::remove_XSS($title);
  815. echo "\t\t\t\t<tr>\n";
  816. echo "\t\t\t\t\t<td width=\"15%\">\n";
  817. if ($myrow['visibility']==0) {
  818. $class="class=\"invisible\"";
  819. } else {
  820. $class="";
  821. }
  822. //validation when belongs to a session
  823. $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
  824. echo "\t\t\t\t\t\t".Display::return_icon('lp_announcement.png', api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow['end_date']))), array('align' => 'absmiddle', 'Width' => '10', 'Height' => '10'))." <a style=\"text-decoration:none\" href=\"announcements.php?".api_get_cidreq()."#".$myrow['id']."\" ".$class.">" . api_trunc_str($title, $length) . "</a>\n" . $session_img;
  825. echo "\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
  826. }
  827. echo "\t\t\t</table>\n";
  828. } // end $display_title_list == true
  829. }
  830. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  831. echo "\t\t</td>\n";
  832. echo "\t\t<td width=\"20\" background=\"../img/verticalruler.gif\">&nbsp;</td>\n";
  833. // START RIGHT PART
  834. echo "\t\t<td valign=\"top\">\n";
  835. }
  836. /*=======================================
  837. DISPLAY ACTION MESSAGE
  838. =======================================*/
  839. if (isset($message) && $message == true) {
  840. Display::display_confirmation_message($message);
  841. $display_announcement_list = true;
  842. $display_form = false;
  843. }
  844. if (!empty($error_message)) {
  845. Display::display_error_message($error_message);
  846. $display_announcement_list = false;
  847. $display_form = true;
  848. }
  849. /*==================================================================================
  850. DISPLAY FORM
  851. ==================================================================================*/
  852. if ($display_form == true) {
  853. $content_to_modify = stripslashes($content_to_modify);
  854. $title_to_modify = stripslashes($title_to_modify);
  855. // DISPLAY ADD ANNOUNCEMENT COMMAND
  856. echo '<form method="post" name="f1" enctype = "multipart/form-data" action="'.api_get_self().'?publish_survey='.Security::remove_XSS($surveyid).'&id='.Security::remove_XSS($_GET['id']).'&db_name='.$db_name.'&cidReq='.Security::remove_XSS($_GET['cidReq']).'" style="margin:0px;">'."\n";
  857. if (empty($_GET['id'])) {
  858. $form_name = get_lang('AddAnnouncement');
  859. } else {
  860. $form_name = get_lang('ModifyAnnouncement');
  861. }
  862. echo '<div class="row"><div class="form_header">'.$form_name.'</div></div>';
  863. //this variable defines if the course administrator can send a message to a specific user / group or not
  864. if (empty($_SESSION['toolgroup'])) {
  865. echo ' <div class="row">
  866. <div class="label">'.
  867. Display::return_icon('group.gif', get_lang('ModifyRecipientList'), array ('align' => 'absmiddle')).'<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('SentTo').'</a>
  868. </div>
  869. <div class="formw">';
  870. if (isset($_GET['id']) && is_array($to)) {
  871. echo '&nbsp;';
  872. } elseif (isset($_GET['remind_inactive'])) {
  873. $email_ann = '1';
  874. $_SESSION['select_groupusers']="show";
  875. $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'), 7);
  876. $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'));
  877. } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives']=='true') {
  878. // we want to remind inactive users. The $_GET['since'] parameter determines which users have to be warned (i.e the users who have been inactive for x days or more
  879. $since = isset($_GET['since']) ? intval($_GET['since']) : 6;
  880. // getting the users who have to be reminded
  881. $to = Tracking :: get_inactives_students_in_course($_course['id'],$since, $_SESSION['id_session']);
  882. // setting the variables for the form elements: the users who need to receive the message
  883. foreach($to as &$user) {
  884. $user = 'USER:'.$user;
  885. }
  886. // setting the variables for the form elements: the 'visible to' form element has to be expanded
  887. $_SESSION['select_groupusers']="show";
  888. // setting the variables for the form elements: the message has to be sent by email
  889. $email_ann = '1';
  890. // setting the variables for the form elements: the title of the email
  891. $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'),api_get_setting('siteName'),' > ',$_course['name']);
  892. // setting the variables for the form elements: the message of the email
  893. $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),' > ',$_course['name'],$since);
  894. // when we want to remind the users who have never been active then we have a different subject and content for the announcement
  895. if ($_GET['since'] == 'never') {
  896. $title_to_modify = get_lang('NoActivityYetTitle');
  897. $content_to_modify = get_lang('NoActivityYetContent');
  898. }
  899. } else {
  900. echo get_lang("Everybody");
  901. }
  902. show_to_form($to);
  903. echo ' </div>
  904. </div>';
  905. if (!isset($announcement_to_modify) ) $announcement_to_modify ='';
  906. if ($announcement_to_modify=='') {
  907. ($email_ann=='1')?$checked='checked':$checked='';
  908. echo ' <div class="row">
  909. <div class="label">
  910. <input class="checkbox" type="checkbox" value="1" name="email_ann" checked>
  911. </div>
  912. <div class="formw">'.get_lang('EmailOption').'
  913. </div>
  914. </div>';
  915. }
  916. } else {
  917. if (!isset($announcement_to_modify) ) {
  918. $announcement_to_modify ="";
  919. }
  920. if ($announcement_to_modify=='') {
  921. ($email_ann=='1' || !empty($surveyid))?$checked='checked':$checked='';
  922. echo '<div class="row">
  923. <div class="label">
  924. <input class="checkbox" type="checkbox" value="1" name="email_ann" '.$checked.'>
  925. </div>
  926. <div class="formw">'.
  927. get_lang('EmailOption').': '.get_lang('MyGroup').'&nbsp;&nbsp;<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('ModifyRecipientList').'</a>';
  928. show_to_form_group($_SESSION['toolgroup']);
  929. echo '</div></div>';
  930. }
  931. }
  932. if ($surveyid) {
  933. echo ' <div class="row">
  934. <div class="label">
  935. '.get_lang('EmailAddress').'
  936. </div>
  937. <div class="formw">
  938. <input type="text" name="emailsAdd" value="'.Security::remove_XSS($emails_add).'" size="52">(Comma separated for multiple)
  939. </div>
  940. </div>';
  941. echo ' <div class="row">
  942. <div class="label">
  943. '.get_lang('OnlyThoseAddresses').'
  944. </div>
  945. <div class="formw">
  946. <input type="checkbox" name="onlyThoseMails">
  947. </div>
  948. </div>';
  949. }
  950. // the announcement title
  951. echo ' <div class="row">
  952. <div id="msg_error" style="display:none;color:red;margin-left:20%"></div>
  953. <div class="label">
  954. <span class="form_required">*</span> '.get_lang('EmailTitle').'
  955. </div>
  956. <div class="formw">
  957. <input type="text" id="emailTitle" name="emailTitle" value="'.Security::remove_XSS($title_to_modify).'" size="60">
  958. </div>
  959. </div>';
  960. unset($title_to_modify);
  961. $title_to_modify = null;
  962. if (!isset($announcement_to_modify) ) $announcement_to_modify ="";
  963. if (!isset($content_to_modify) ) $content_to_modify ="";
  964. if (!isset($title_to_modify)) $title_to_modify = "";
  965. echo '<input type="hidden" name="id" value="'.$announcement_to_modify.'" />';
  966. if ($surveyid) {
  967. $content_to_modify='<br /><a href="'.api_get_path(WEB_CODE_PATH).'/survey/#page#?temp=#temp#&surveyid=#sid#&uid=#uid#&mail=#mail#&db_name=#db_name">'.get_lang('ClickHereToOpenSurvey').'</a><br />
  968. '.get_lang('OrCopyPasteUrl').' <br />
  969. '.api_get_path(WEB_CODE_PATH).'/survey/#page#?temp=#temp#&surveyid=#sid#&uid=#uid#&mail=#mail#&db_name=#db_name&nbsp;';
  970. }
  971. $oFCKeditor = new FCKeditor('newContent') ;
  972. $oFCKeditor->Width = '100%';
  973. $oFCKeditor->Height = '300';
  974. if(!api_is_allowed_to_edit()) {
  975. $oFCKeditor->ToolbarSet = "AnnouncementsStudent";
  976. } else {
  977. $oFCKeditor->ToolbarSet = "Announcements";
  978. }
  979. $oFCKeditor->Value = $content_to_modify;
  980. echo $oFCKeditor->CreateHtml();
  981. //File attachment
  982. echo ' <div style="float:left; padding:5px 5px;" >
  983. <div class="label">
  984. <a href="javascript://" onclick="return plus_attachment();"><span id="plus"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AddAnAttachment').'</span></a>
  985. </div>
  986. <div class="formw">
  987. <table id="options" style="display: none;">
  988. <tr>
  989. <td colspan="2">
  990. <label for="file_name">'.get_lang('FileName').'&nbsp;</label>
  991. <input type="file" name="user_upload"/>
  992. </td>
  993. </tr>
  994. <tr>
  995. <td colspan="2">
  996. <label for="comment">'.get_lang('FileComment').'</label><br />
  997. <textarea name="file_comment" rows ="4" cols = "34" ></textarea>
  998. </td>
  999. </tr>
  1000. </table>
  1001. </div>
  1002. </div>';
  1003. echo'<br />';
  1004. if (empty($_SESSION['toolgroup'])) {
  1005. echo '<input type="hidden" name="submitAnnouncement" value="OK">';
  1006. echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
  1007. echo '<button class="save" type="button" value="'.' '.get_lang('Send').' '.'" onclick="selectAll(this.form.elements[3],true)" >'.get_lang('ButtonPublishAnnouncement').'</button><br /><br />';
  1008. } else {
  1009. echo '<input type="hidden" name="submitAnnouncement" value="OK">';
  1010. echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
  1011. echo '<button class="save" type="button" value="'.' '.get_lang('Send').' '.'" onclick="selectAll(this.form.elements[4],true)" >'.get_lang('ButtonPublishAnnouncement').'</button><br /><br />';
  1012. }
  1013. echo '</form><br />';
  1014. if ((isset($_GET['action']) && isset($_GET['id']) && is_array($to))||isset($_GET['remindallinactives'])||isset($_GET['remind_inactive'])) {
  1015. echo '<script>document.getElementById(\'recipient_list\').style.display=\'block\';</script>';
  1016. }
  1017. } // displayform
  1018. /*===============================================
  1019. DISPLAY ANNOUNCEMENT LIST
  1020. ===============================================*/
  1021. if ($display_announcement_list && !$surveyid) {
  1022. // by default we use the id of the current user. The course administrator can see the announcement of other users by using the user / group filter
  1023. $user_id=$_user['user_id'];
  1024. if (isset($_SESSION['user'])) {
  1025. $user_id=$_SESSION['user'];
  1026. }
  1027. if (isset($_SESSION['group'])) {
  1028. $group_id=$_SESSION['group'];
  1029. }
  1030. //$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
  1031. $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_user['user_id']);
  1032. if (api_is_allowed_to_edit(false,true)) {
  1033. // A.1. you are a course admin with a USER filter
  1034. // => see only the messages of this specific user + the messages of the group (s)he is member of.
  1035. if (isset($_SESSION['user'])) {
  1036. if (is_array($group_memberships) && count($group_memberships)>0) {
  1037. $sql="SELECT
  1038. announcement.*, toolitemproperties.*
  1039. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1040. WHERE announcement.id = toolitemproperties.ref
  1041. AND toolitemproperties.tool='announcement'
  1042. AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).") )
  1043. $condition_session
  1044. ORDER BY display_order DESC";
  1045. } else {
  1046. $sql="SELECT
  1047. announcement.*, toolitemproperties.*
  1048. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1049. WHERE announcement.id = toolitemproperties.ref
  1050. AND toolitemproperties.tool='announcement'
  1051. AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id='0')
  1052. AND toolitemproperties.visibility='1'
  1053. $condition_session
  1054. ORDER BY display_order DESC";
  1055. }
  1056. } elseif (isset($_SESSION['group'])) {
  1057. // A.2. you are a course admin with a GROUP filter
  1058. // => see only the messages of this specific group
  1059. $sql="SELECT
  1060. announcement.*, toolitemproperties.*
  1061. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1062. WHERE announcement.id = toolitemproperties.ref
  1063. AND toolitemproperties.tool='announcement'
  1064. AND (toolitemproperties.to_group_id=$group_id OR toolitemproperties.to_group_id='0')
  1065. $condition_session
  1066. GROUP BY toolitemproperties.ref
  1067. ORDER BY display_order DESC";
  1068. } else {
  1069. // A.3 you are a course admin without any group or user filter
  1070. // A.3.a you are a course admin without user or group filter but WITH studentview
  1071. // => see all the messages of all the users and groups without editing possibilities
  1072. if (isset($isStudentView) and $isStudentView=="true") {
  1073. $sql="SELECT
  1074. announcement.*, toolitemproperties.*
  1075. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1076. WHERE announcement.id = toolitemproperties.ref
  1077. AND toolitemproperties.tool='announcement'
  1078. AND toolitemproperties.visibility='1'
  1079. $condition_session
  1080. GROUP BY toolitemproperties.ref
  1081. ORDER BY display_order DESC";
  1082. } else {
  1083. // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
  1084. // => see all the messages of all the users and groups with editing possibilities
  1085. $sql="SELECT
  1086. announcement.*, toolitemproperties.*
  1087. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1088. WHERE announcement.id = toolitemproperties.ref
  1089. AND toolitemproperties.tool='announcement'
  1090. AND (toolitemproperties.visibility='0' or toolitemproperties.visibility='1')
  1091. $condition_session
  1092. GROUP BY toolitemproperties.ref
  1093. ORDER BY display_order DESC";
  1094. }
  1095. }
  1096. } else {
  1097. //STUDENT
  1098. if (is_array($group_memberships) && count($group_memberships)>0) {
  1099. if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  1100. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
  1101. } else {
  1102. $cond_user_id = " AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
  1103. }
  1104. $sql="SELECT
  1105. announcement.*, toolitemproperties.*
  1106. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1107. WHERE announcement.id = toolitemproperties.ref
  1108. AND toolitemproperties.tool='announcement'
  1109. $cond_user_id
  1110. $condition_session
  1111. AND toolitemproperties.visibility='1'
  1112. ORDER BY display_order DESC";
  1113. } else {
  1114. if ($_user['user_id']) {
  1115. if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  1116. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR (toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0')) ";
  1117. } else {
  1118. $cond_user_id = " AND (toolitemproperties.to_user_id='".$_user['user_id']."' OR toolitemproperties.to_group_id='0') ";
  1119. }
  1120. $sql="SELECT
  1121. announcement.*, toolitemproperties.*
  1122. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1123. WHERE announcement.id = toolitemproperties.ref
  1124. AND toolitemproperties.tool='announcement'
  1125. $cond_user_id
  1126. $condition_session
  1127. AND toolitemproperties.visibility='1'
  1128. AND announcement.session_id IN(0,".intval($_SESSION['id_session']).")
  1129. ORDER BY display_order DESC";
  1130. } else {
  1131. if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  1132. $cond_user_id = " AND (toolitemproperties.lastedit_user_id = '".api_get_user_id()."' OR toolitemproperties.to_group_id='0' ) ";
  1133. } else {
  1134. $cond_user_id = " AND toolitemproperties.to_group_id='0' ";
  1135. }
  1136. $sql="SELECT
  1137. announcement.*, toolitemproperties.*
  1138. FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
  1139. WHERE announcement.id = toolitemproperties.ref
  1140. AND toolitemproperties.tool='announcement'
  1141. $cond_user_id
  1142. $condition_session
  1143. AND toolitemproperties.visibility='1'
  1144. AND announcement.session_id IN(0,".intval($_SESSION['id_session']).")";
  1145. }
  1146. }
  1147. }
  1148. $result = Database::query($sql,__FILE__,__LINE__);
  1149. $num_rows = Database::num_rows($result);
  1150. /*=================================================
  1151. DISPLAY: NO ITEMS
  1152. =================================================*/
  1153. if ($num_rows == 0) {
  1154. echo get_lang('NoAnnouncements');;
  1155. }
  1156. $iterator = 1;
  1157. $bottomAnnouncement = $announcement_number;
  1158. echo "\t\t\t<table width=\"100%\" class=\"data_table\">\n";
  1159. $displayed=array();
  1160. while ($myrow = Database::fetch_array($result)) {
  1161. if (!in_array($myrow['id'], $displayed)) {
  1162. $title = $myrow['title'];
  1163. $content = $myrow['content'];
  1164. $content = make_clickable($content);
  1165. $content = text_filter($content);
  1166. /* DATE */
  1167. $last_post_datetime = $myrow['end_date'];
  1168. list($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
  1169. list($year, $month, $day) = explode("-", $last_post_date);
  1170. list($hour, $min) = explode(":", $last_post_time);
  1171. $announceDate = mktime((int)$hour, (int)$min, 0, (int)$month, (int)$day, (int)$year);
  1172. // the styles
  1173. if ($myrow['visibility']=='0') {
  1174. $style='invisible';
  1175. } else {
  1176. $style = '';
  1177. }
  1178. echo "\t\t\t\t<tr class=\"".$style."\">";
  1179. /* THE ICONS */
  1180. echo "\t\t\t\t\t<th>\n";
  1181. // anchoring
  1182. echo "<a name=\"".(int)($myrow["id"])."\"></a>\n";
  1183. // User or group icon
  1184. if ($myrow['to_group_id']!== '0' and $myrow['to_group_id']!== 'NULL') {
  1185. echo "\t\t\t\t\t\t".Display::return_icon('group.gif', get_lang('AnnounceSentToUserSelection'))."\n";
  1186. }
  1187. // the email icon
  1188. if ($myrow['email_sent'] == '1') {
  1189. echo "\t\t\t\t\t\t".Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'))."\n";
  1190. }
  1191. echo "\t\t\t\t\t</th>\n";
  1192. /* TITLE */
  1193. echo "\t\t\t\t\t<th>".Security::remove_XSS($title)."</th>\n";
  1194. echo "\t\t\t\t\t<th>" . get_lang("SentTo") . " : &nbsp; ";
  1195. $sent_to=sent_to("announcement", $myrow['id']);
  1196. $sent_to_form=sent_to_form($sent_to);
  1197. $user_info=api_get_user_info($myrow['insert_user_id']);
  1198. echo '&nbsp;&nbsp;&nbsp;'.get_lang('By').' : &nbsp;'.str_replace(' ', '&nbsp;', api_get_person_name($user_info['firstName'], $user_info['lastName']));
  1199. echo "\t\t\t\t\t</th>\n","\t\t\t\t</tr>\n";
  1200. echo "\t\t\t\t<tr class='row_odd'>\n\t\t\t\t\t<td class=\"announcements_datum\" colspan=\"3\">";
  1201. echo get_lang('AnnouncementPublishedOn')," : ",api_ucfirst(format_locale_date($dateFormatLong,strtotime($last_post_date)));
  1202. echo "</td>\n\t\t\t\t</tr>\n";
  1203. /* CONTENT */
  1204. echo "\t\t\t\t<tr class=\"$text_style\">\n\t\t\t\t\t<td colspan=\"3\">\n";
  1205. echo $content."\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
  1206. /* RESOURCES */
  1207. echo "<tr class='row_odd'>\n<td colspan=\"3\">\n";
  1208. if (check_added_resources("Ad_Valvas", $myrow["id"])) {
  1209. echo "<i>".get_lang('AddedResources')."</i><br />";
  1210. display_added_resources("Ad_Valvas", $myrow["id"]);
  1211. }
  1212. // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on
  1213. if (api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
  1214. /* SHOW MOD/DEL/VIS FUNCTIONS */
  1215. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">",
  1216. Display::return_icon('edit.gif', get_lang('Edit')),
  1217. "</a>";
  1218. if (api_is_allowed_to_edit(false,true)) {
  1219. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">",
  1220. Display::return_icon('delete.gif', get_lang('Delete')),
  1221. "</a>";
  1222. }
  1223. if ($myrow['visibility']==1) {
  1224. $image_visibility="visible";
  1225. $alt_visibility=get_lang('Hide');
  1226. } else {
  1227. $image_visibility="invisible";
  1228. $alt_visibility=get_lang('Visible');
  1229. }
  1230. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin'])?Security::remove_XSS($_GET['origin']):'')."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">".
  1231. Display::return_icon($image_visibility.'.gif', $alt_visibility)."</a>";
  1232. // DISPLAY MOVE UP COMMAND only if it is not the top announcement
  1233. if ($iterator != 1) {
  1234. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&up=".$myrow["id"]."&sec_token=".$stok."\">",
  1235. Display::return_icon('up.gif', get_lang('Up'))."</a>";
  1236. }
  1237. if ($iterator < $bottomAnnouncement) {
  1238. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."&sec_token=".$stok."\">".
  1239. Display::return_icon('down.gif', get_lang('Down'))."</a>";
  1240. }
  1241. //delete attachment file
  1242. if($_GET['action'] == 'delete') {
  1243. $id = $_GET['id_attach'];
  1244. delete_announcement_attachment_file($id);
  1245. }
  1246. // show attachment list
  1247. $attachment_list = array();
  1248. $attachment_list = get_attachment($myrow['id']);
  1249. if (count($attachment_list)>0) {
  1250. $realname=$attachment_list['path'];
  1251. $user_filename=$attachment_list['filename'];
  1252. $full_file_name = 'download.php?file='.$realname;
  1253. echo '<br/>';
  1254. echo '<br/>';
  1255. echo Display::return_icon('attachment.gif',get_lang('Attachment'));
  1256. echo '<a href="'.$full_file_name.'';
  1257. echo ' "> '.$user_filename.' </a>';
  1258. echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
  1259. if (api_is_allowed_to_edit()) {
  1260. echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
  1261. }
  1262. }
  1263. echo "</td>\n</tr>\n";
  1264. $iterator ++;
  1265. } else { // end of is_allowed_to_edit
  1266. //students view
  1267. // show attachment list
  1268. $attachment_list = array();
  1269. $attachment_list = get_attachment($myrow['id']);
  1270. if (count($attachment_list)>0) {
  1271. $realname=$attachment_list['path'];
  1272. $user_filename=$attachment_list['filename'];
  1273. $full_file_name = 'download.php?file='.$realname;
  1274. echo '<br/>';
  1275. echo '<br/>';
  1276. echo Display::return_icon('attachment.gif',get_lang('Attachment'));
  1277. echo '<a href="'.$full_file_name.'';
  1278. echo ' "> '.$user_filename.' </a>';
  1279. echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
  1280. }
  1281. }
  1282. echo "<tr><td width=\"100%\" colspan=\"3\"><a href=\"#top\">".Display::return_icon('top.gif', get_lang('Top'))."</a></td></tr>";
  1283. }
  1284. $displayed[]=$myrow['id'];
  1285. } // end while ($myrow = Database::fetch_array($result))
  1286. echo "</table>";
  1287. } // end: if ($displayAnnoucementList)
  1288. echo "</table>";
  1289. if (!empty($display_specific_announcement)) display_announcement($announcement_id);
  1290. /*
  1291. ==============================================================================
  1292. FOOTER
  1293. ==============================================================================
  1294. */
  1295. if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
  1296. //we are not in learnpath tool
  1297. Display::display_footer();
  1298. }
  1299. ?>