agenda.inc.php 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. <?php //$Id: agenda.inc.php 9414 2006-10-10 12:59:14Z sbil136 $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2005 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. @author: Patrick Cool, patrick.cool@UGent.be
  19. @version: 1.1
  20. @todo: synchronisation with the function in myagenda.php (for instance: using one function for the mini_calendar
  21. ==============================================================================
  22. Large parts of the code are recycled from the old agenda tool, but I
  23. reworked it and cleaned the code to make it more readable. The code for
  24. the small calender on the left is taken from the My Agenda tool.
  25. Reabability is also the reason why I use the if ($is_allowedToEdit)
  26. check for each part of the code. I'm aware that is duplication, but
  27. it makes the code much easier to read.
  28. ==============================================================================
  29. */
  30. /*
  31. -----------------------------------------------------------
  32. Constants and variables
  33. -----------------------------------------------------------
  34. */
  35. // the variables for the days and the months
  36. // Defining the shorts for the days
  37. $DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
  38. // Defining the days of the week to allow translation of the days
  39. $DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
  40. // Defining the months of the year to allow translation of the months
  41. $MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
  42. /*
  43. ==============================================================================
  44. FUNCTIONS
  45. ==============================================================================
  46. */
  47. /**
  48. * Retrieves all the agenda items from the table
  49. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  50. * @param integer $month: the integer value of the month we are viewing
  51. * @param integer $year: the 4-digit year indication e.g. 2005
  52. * @return array
  53. */
  54. function get_kalender_items($month, $year)
  55. {
  56. global $courseTablePrefix, $dbGlu;
  57. global $_uid, $_course;
  58. global $is_allowedToEdit;
  59. // database variables
  60. $TABLEAGENDA=Database::get_course_table(AGENDA_TABLE);
  61. $TABLE_ITEM_PROPERTY=Database::get_course_table(LAST_TOOL_EDIT_TABLE);
  62. $group_memberships=GroupManager::get_group_ids($_course['dbName'], $_uid);
  63. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  64. {
  65. //echo "course admin";
  66. // added GROUP BY `agenda`.`id` to prevent double display of a message that has been sent to two groups
  67. $sql="SELECT
  68. DISTINCT agenda.*, toolitemproperties.*
  69. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  70. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  71. AND MONTH(`agenda`.`start_date`)='".$month."' AND YEAR(`agenda`.`start_date`)='".$year."'
  72. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  73. AND `toolitemproperties`.`visibility`='1'
  74. GROUP BY `agenda`.`id`
  75. ORDER BY start_date ".$sort;
  76. }
  77. // if the user is not an administrator of that course
  78. else
  79. {
  80. //echo "GEEN course admin";
  81. if (is_array($group_memberships))
  82. {
  83. $sql="SELECT
  84. agenda.*, toolitemproperties.*
  85. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  86. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  87. AND MONTH(`agenda`.`start_date`)='".$month."'
  88. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  89. AND ( `toolitemproperties`.`to_user_id`='".$_uid."' OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  90. AND `toolitemproperties`.`visibility`='1'
  91. ORDER BY start_date ".$sort;
  92. }
  93. else
  94. {
  95. $sql="SELECT
  96. agenda.*, toolitemproperties.*
  97. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  98. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  99. AND MONTH(`agenda`.`start_date`)='".$month."'
  100. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  101. AND ( `toolitemproperties`.`to_user_id`='".$_uid."' OR `toolitemproperties`.`to_group_id`='0')
  102. AND `toolitemproperties`.`visibility`='1'
  103. ORDER BY start_date ".$sort;
  104. }
  105. }
  106. $result=api_sql_query($sql,__FILE__,__LINE__);
  107. $data=array();
  108. while ($row=mysql_fetch_array($result))
  109. {
  110. $datum_item=(int)substr($row["start_date"],8,2);
  111. //$dag_item=date("d",strtotime($datum_item));
  112. $data[$datum_item]=intval($datum_item);
  113. }
  114. return $data;
  115. }
  116. /**
  117. * show the mini calender of the given month
  118. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  119. * @param array an array containing all the agenda items for the given month
  120. * @param integer $month: the integer value of the month we are viewing
  121. * @param integer $year: the 4-digit year indication e.g. 2005
  122. * @param string $monthName: the language variable for the mont name
  123. * @return html code
  124. * @todo refactor this so that $monthName is no longer needed as a parameter
  125. */
  126. function display_minimonthcalendar($agendaitems, $month, $year, $monthName)
  127. {
  128. global $DaysShort;
  129. //Handle leap year
  130. $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  131. if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
  132. $numberofdays[2] = 29;
  133. //Get the first day of the month
  134. $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
  135. //Start the week on monday
  136. $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
  137. $backwardsURL = $_SERVER['PHP_SELF']."?coursePath=".$_GET['coursePath']."&amp;courseCode=".$_GET['courseCode']."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
  138. $forewardsURL = $_SERVER['PHP_SELF']."?coursePath=".$_GET['coursePath']."&amp;courseCode=".$_GET['courseCode']."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
  139. echo "<table id=\"smallcalendar\">\n",
  140. "<tr class=\"title\">\n",
  141. "<td width=\"10%\"><a href=\"", $backwardsURL, "\"></a></td>\n",
  142. "<td width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</td>\n",
  143. "<td width=\"10%\"><a href=\"", $forewardsURL, "\"></a></td>\n", "</tr>\n";
  144. echo "<tr>\n";
  145. for ($ii = 1; $ii < 8; $ii ++)
  146. {
  147. echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>\n";
  148. }
  149. echo "</tr>\n";
  150. $curday = -1;
  151. $today = getdate();
  152. while ($curday <= $numberofdays[$month])
  153. {
  154. echo "<tr>\n";
  155. for ($ii = 0; $ii < 7; $ii ++)
  156. {
  157. if (($curday == -1) && ($ii == $startdayofweek))
  158. {
  159. $curday = 1;
  160. }
  161. if (($curday > 0) && ($curday <= $numberofdays[$month]))
  162. {
  163. $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
  164. $dayheader = "$curday";
  165. if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon]))
  166. {
  167. $dayheader = "$curday";
  168. $class = "class=\"days_today\"";
  169. }
  170. echo "\t<td ".$class.">";
  171. if ($agendaitems[$curday] <> "")
  172. {
  173. echo "<a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=day&amp;day=".$curday."&amp;month=".$month."&amp;year=".$year."\">".$dayheader."</a>";
  174. }
  175. else
  176. {
  177. echo $dayheader;
  178. }
  179. // "a".$dayheader." <span class=\"agendaitem\">".$agendaitems[$curday]."</span>\n";
  180. echo "</td>\n";
  181. $curday ++;
  182. }
  183. else
  184. {
  185. echo "<td>&nbsp;</td>\n";
  186. }
  187. }
  188. echo "</tr>\n";
  189. }
  190. echo "</table>\n";
  191. }
  192. /**
  193. * show the calender of the given month
  194. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  195. * @param integer $month: the integer value of the month we are viewing
  196. * @param integer $year: the 4-digit year indication e.g. 2005
  197. * @return html code
  198. */
  199. function display_monthcalendar($month, $year)
  200. {
  201. global $MonthsLong;
  202. global $datakalenderitems;
  203. global $DaysShort;
  204. global $origin;
  205. // grabbing all the kalender items for this year and storing it in a array
  206. $data=get_kalender_items($month,$year);
  207. //Handle leap year
  208. $numberofdays = array(0,31,28,31,30,31,30,31,31,30,31,30,31);
  209. if (($year%400 == 0) or ($year%4==0 and $year%100<>0)) $numberofdays[2] = 29;
  210. //Get the first day of the month
  211. $dayone = getdate(mktime(0,0,0,$month,1,$year));
  212. //Start the week on monday
  213. $startdayofweek = $dayone['wday']<>0 ? ($dayone['wday']-1) : 6;
  214. $backwardsURL = $_SERVER['PHP_SELF']."?origin=$origin&amp;month=".($month==1 ? 12 : $month-1)."&amp;year=".($month==1 ? $year-1 : $year);
  215. $forewardsURL = $_SERVER['PHP_SELF']."?origin=$origin&amp;month=".($month==12 ? 1 : $month+1)."&amp;year=".($month==12 ? $year+1 : $year);
  216. $maand_array_maandnummer=$month-1;
  217. echo "<table id=\"smallcalendar\">\n",
  218. "<tr class=\"title\">\n",
  219. "<td width=\"10%\"><a href=\"",$backwardsURL,"\"></a></td>\n",
  220. "<td width=\"80%\" colspan=\"5\">",$MonthsLong[$maand_array_maandnummer]," ",$year,"</td>\n",
  221. "<td width=\"10%\"><a href=\"",$forewardsURL,"\"></a></td>\n",
  222. "</tr>\n";
  223. echo "<tr>\n";
  224. for ($ii=1;$ii<8; $ii++)
  225. {
  226. echo "<td id=\"weekdays\">",$DaysShort[$ii%7],"</td>\n";
  227. }
  228. echo "</tr>\n";
  229. $curday = -1;
  230. $today = getdate();
  231. while ($curday <=$numberofdays[$month])
  232. {
  233. echo "<tr>\n";
  234. for ($ii=0; $ii<7; $ii++)
  235. {
  236. if (($curday == -1)&&($ii==$startdayofweek))
  237. {
  238. $curday = 1;
  239. }
  240. if (($curday>0)&&($curday<=$numberofdays[$month]))
  241. {
  242. $bgcolor = $ii<5 ? "class=\"alternativeBgLight\"" : "class=\"alternativeBgDark\"";
  243. $dayheader = "$curday";
  244. if (in_array($curday,$data))
  245. { $dayheader="<a href='".$_SERVER['PHP_SELF']."?origin=$origin&amp;month=$month&amp;year=$year&amp;day=$curday#$curday'>".$curday."</a>"; }
  246. if (($curday==$today['mday'])&&($year ==$today['year'])&&($month == $today[mon]))
  247. {
  248. echo "<td id=\"today\" ",$bgcolor,"\">".$dayheader." \n";
  249. }
  250. else
  251. {
  252. echo "<td id=\"days\" ",$bgcolor,"\">".$dayheader." \n";
  253. }
  254. echo "</td>\n";
  255. $curday++;
  256. }
  257. else
  258. {
  259. echo "<td>&nbsp;</td>";
  260. }
  261. }
  262. echo "</tr>";
  263. }
  264. echo "</table>";
  265. }
  266. /**
  267. * returns all the javascript that is required for easily selecting the target people/groups this goes into the $htmlHeadXtra[] array
  268. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  269. * @return javascript code
  270. */
  271. function to_javascript()
  272. {
  273. $Send2All=get_lang("Send2All");
  274. return "<script type=\"text/javascript\" language=\"JavaScript\">
  275. <!-- Begin javascript menu swapper
  276. function move(fbox, tbox)
  277. {
  278. var arrFbox = new Array();
  279. var arrTbox = new Array();
  280. var arrLookup = new Array();
  281. var i;
  282. for (i = 0; i < tbox.options.length; i++)
  283. {
  284. arrLookup[tbox.options[i].text] = tbox.options[i].value;
  285. arrTbox[i] = tbox.options[i].text;
  286. }
  287. var fLength = 0;
  288. var tLength = arrTbox.length;
  289. for(i = 0; i < fbox.options.length; i++)
  290. {
  291. arrLookup[fbox.options[i].text] = fbox.options[i].value;
  292. if (fbox.options[i].selected && fbox.options[i].value != \"\")
  293. {
  294. arrTbox[tLength] = fbox.options[i].text;
  295. tLength++;
  296. }
  297. else
  298. {
  299. arrFbox[fLength] = fbox.options[i].text;
  300. fLength++;
  301. }
  302. }
  303. arrFbox.sort();
  304. arrTbox.sort();
  305. fbox.length = 0;
  306. tbox.length = 0;
  307. var c;
  308. for(c = 0; c < arrFbox.length; c++)
  309. {
  310. var no = new Option();
  311. no.value = arrLookup[arrFbox[c]];
  312. no.text = arrFbox[c];
  313. fbox[c] = no;
  314. }
  315. for(c = 0; c < arrTbox.length; c++)
  316. {
  317. var no = new Option();
  318. no.value = arrLookup[arrTbox[c]];
  319. no.text = arrTbox[c];
  320. tbox[c] = no;
  321. }
  322. }
  323. function validate()
  324. {
  325. var f = document.new_calendar_item;
  326. f.submit();
  327. return true;
  328. }
  329. function selectAll(cbList,bSelect,showwarning)
  330. {
  331. if (cbList.length < 1) {
  332. alert(\"$Send2All\");
  333. return;
  334. }
  335. for (var i=0; i<cbList.length; i++)
  336. cbList[i].selected = cbList[i].checked = bSelect
  337. }
  338. function reverseAll(cbList)
  339. {
  340. for (var i=0; i<cbList.length; i++)
  341. {
  342. cbList[i].checked = !(cbList[i].checked)
  343. cbList[i].selected = !(cbList[i].selected)
  344. }
  345. }
  346. // End -->
  347. </script>";
  348. }
  349. /**
  350. * returns the javascript for setting a filter. This is a jump menu
  351. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  352. * @return javascript code
  353. */
  354. function user_group_filter_javascript()
  355. {
  356. return "<script language=\"JavaScript\" type=\"text/JavaScript\">
  357. <!--
  358. function MM_jumpMenu(targ,selObj,restore){
  359. eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");
  360. if (restore) selObj.selectedIndex=0;
  361. }
  362. //-->
  363. </script>
  364. ";
  365. }
  366. /**
  367. * this function gets all the users of the current course
  368. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  369. * @return array: associative array where the key is the id of the user and the value is an array containing
  370. the first name, the last name, the user id
  371. */
  372. function get_course_users()
  373. {
  374. global $tbl_user;
  375. global $tbl_courseUser, $tbl_session_course_user;
  376. global $_cid;
  377. // not 100% if this is necessary, this however prevents a notice
  378. if (!isset($courseadmin_filter))
  379. {$courseadmin_filter='';}
  380. if(api_get_setting("use_session_mode") != "true")
  381. {
  382. $sql = "SELECT u.lastname lastName, u.firstname firstName, u.user_id uid
  383. FROM ".$tbl_user." u, ".$tbl_courseUser." cu
  384. WHERE cu.course_code = '".$_cid."'
  385. AND cu.user_id = u.user_id $courseadmin_filter
  386. ORDER BY u.lastname, u.firstname";
  387. }
  388. else
  389. {
  390. $sql = "SELECT u.lastname lastName, u.firstName firstName, u.user_id uid
  391. FROM $tbl_session_course_user AS session_course_user
  392. INNER JOIN $tbl_user u
  393. ON u.user_id = session_course_user.id_user
  394. WHERE id_session='".$_SESSION['id_session']."'
  395. AND course_code='$_cid'";
  396. }
  397. $result = api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  398. while ($user_data = mysql_fetch_array($result))
  399. {
  400. $user_list [$user_data['uid']] = $user_data;
  401. }
  402. return $user_list;
  403. }
  404. /**
  405. * this function gets all the groups of the course
  406. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  407. * @return array
  408. */
  409. function get_course_groups()
  410. {
  411. global $tbl_group;
  412. global $tbl_groupUser;
  413. $sql = "SELECT g.id, g.name, COUNT(gu.id) userNb
  414. FROM ".$tbl_group." AS g LEFT JOIN ".$tbl_groupUser." gu
  415. ON g.id = gu.group_id
  416. GROUP BY g.id";
  417. $result = api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  418. while ($group_data = mysql_fetch_array($result))
  419. {
  420. $group_list [$group_data['id']] = $group_data;
  421. }
  422. return $group_list;
  423. }
  424. /**
  425. * this function shows the form for sending a message to a specific group or user.
  426. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  427. * @return html code
  428. */
  429. function show_to_form($to_already_selected)
  430. {
  431. $user_list=get_course_users();
  432. $group_list=get_course_groups();
  433. echo "\n<table>\n";
  434. echo "\t<tr>\n";
  435. // the form containing all the groups and all the users of the course
  436. echo "\t\t<td>\n";
  437. construct_not_selected_select_form($group_list,$user_list,$to_already_selected);
  438. echo "\t\t</td>\n";
  439. // the buttons for adding or removing groups/users
  440. echo "\n\t\t<td valign=\"middle\">\n";
  441. echo "\t\t<input type=\"button\" ",
  442. "onclick=\"move(this.form.elements[3],this.form.elements[6])\" ",
  443. "value=\" &gt;&gt; \" />",
  444. "\n\t\t<p>&nbsp;</p>",
  445. "\n\t\t<input type=\"button\" ",
  446. "onclick=\"move(this.form.elements[6],this.form.elements[3])\" ",
  447. "value=\" &lt;&lt; \" />";
  448. echo "\t\t</td>\n";
  449. echo "\n\t\t<td>\n";
  450. construct_selected_select_form($group_list,$user_list,$to_already_selected);
  451. echo "\t\t</td>\n";
  452. echo "\t</tr>\n";
  453. echo "</table>";
  454. }
  455. /**
  456. * this function shows the form with the user that were not selected
  457. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  458. * @return html code
  459. */
  460. function construct_not_selected_select_form($group_list=null, $user_list=null,$to_already_selected)
  461. {
  462. echo "\t\t<select name=\"not_selected_form[]\" size=\"5\" multiple=\"multiple\" style=\"width:200px\">\n";
  463. // adding the groups to the select form
  464. if (is_array($group_list))
  465. {
  466. foreach($group_list as $this_group)
  467. {
  468. //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
  469. if (!in_array("GROUP:".$this_group['id'],$to_already_selected)) // $to_already_selected is the array containing the groups (and users) that are already selected
  470. {
  471. echo "\t\t<option value=\"GROUP:".$this_group['id']."\">",
  472. "G: ",$this_group['name']," &ndash; " . $this_group['userNb'] . " " . get_lang('Users') .
  473. "</option>\n";
  474. }
  475. }
  476. // a divider
  477. echo "\t\t<option value=\"\">---------------------------------------------------------</option>\n";
  478. }
  479. // adding the individual users to the select form
  480. foreach($user_list as $this_user)
  481. {
  482. if (!in_array("USER:".$this_user['uid'],$to_already_selected)) // $to_already_selected is the array containing the users (and groups) that are already selected
  483. {
  484. echo "\t\t<option value=\"USER:",$this_user['uid'],"\">",
  485. "",$this_user['lastName']," ",$this_user['firstName'],
  486. "</option>\n";
  487. }
  488. }
  489. echo "\t\t</select>\n";
  490. }
  491. /**
  492. * this function shows the form with the user that were selected
  493. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  494. * @return html code
  495. */
  496. function construct_selected_select_form($group_list=null, $user_list=null,$to_already_selected)
  497. {
  498. // we separate the $to_already_selected array (containing groups AND users into
  499. // two separate arrays
  500. if (is_array($groupuser))
  501. {
  502. $groupuser=separate_users_groups($to_already_selected);
  503. }
  504. $groups_to_already_selected=$groupuser['groups'];
  505. $users_to_already_selected=$groupuser['users'];
  506. // we load all the groups and all the users into a reference array that we use to search the name of the group / user
  507. $ref_array_groups=get_course_groups();
  508. $ref_array_users=get_course_users();
  509. // we construct the form of the already selected groups / users
  510. echo "\t\t<select name=\"selectedform[]\" size=\"5\" multiple=\"multiple\" style=\"width:200px\">";
  511. foreach($to_already_selected as $groupuser)
  512. {
  513. list($type,$id)=explode(":",$groupuser);
  514. if ($type=="GROUP")
  515. {
  516. echo "\t\t<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>";
  517. }
  518. else
  519. {
  520. echo "\t\t<option value=\"".$groupuser."\">".$ref_array_users[$id]['lastName']." ".$ref_array_users[$id]['firstName']."</option>";
  521. }
  522. }
  523. echo "</select>\n";
  524. }
  525. /**
  526. * This function stores the Agenda Item in the table calendar_event and updates the item_property table also
  527. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  528. * @return integer the id of the last added agenda item
  529. */
  530. function store_new_agenda_item()
  531. {
  532. global $TABLEAGENDA;
  533. global $_uid;
  534. // some filtering of the input data
  535. $title=strip_tags(trim($_POST['title'])); // no html allowed in the title
  536. $content=trim($_POST['content']);
  537. $start_date=(int)$_POST['fyear']."-".(int)$_POST['fmonth']."-".(int)$_POST['fday']." ".(int)$_POST['fhour'].":".(int)$_POST['fminute'].":00";
  538. $end_date=(int)$_POST['end_fyear']."-".(int)$_POST['end_fmonth']."-".(int)$_POST['end_fday']." ".(int)$_POST['end_fhour'].":".(int)$_POST['end_fminute'].":00";
  539. // store in the table calendar_event
  540. $sql = "INSERT INTO ".$TABLEAGENDA."
  541. (title,content, start_date, end_date)
  542. VALUES
  543. ('".$title."','".$content."', '".$start_date."','".$end_date."')";
  544. $result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  545. $last_id=mysql_insert_id();
  546. // store in last_tooledit (first the groups, then the users
  547. $to=$_POST['selectedform'];
  548. if (($_SESSION['allow_individual_calendar']=="show" and !is_null($to))or (!empty($_SESSION['toolgroup']))) // !is_null($to): when no user is selected we send it to everyone
  549. {
  550. $send_to=separate_users_groups($to);
  551. // storing the selected groups
  552. if (is_array($send_to['groups']))
  553. {
  554. foreach ($send_to['groups'] as $group)
  555. {
  556. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_uid, $group,'',$start_visible, $end_visible);
  557. }
  558. }
  559. // storing the selected users
  560. if (is_array($send_to['users']))
  561. {
  562. foreach ($send_to['users'] as $user)
  563. {
  564. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_uid,'',$user, $start_visible,$end_visible);
  565. }
  566. }
  567. }
  568. else // the message is sent to everyone, so we set the group to 0
  569. {
  570. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_uid, '','',$start_visible,$end_visible);
  571. }
  572. // storing the resources
  573. store_resources($_SESSION['source_type'],$last_id);
  574. return $last_id;
  575. }
  576. /**
  577. * Stores the given agenda item as an announcement (unlinked copy)
  578. * @param integer Agenda item's ID
  579. * @return integer New announcement item's ID
  580. */
  581. function store_agenda_item_as_announcement($item_id){
  582. $table_agenda = Database::get_course_table(AGENDA_TABLE);
  583. $table_ann = Database::get_course_table(ANNOUNCEMENT_TABLE);
  584. //check params
  585. if(empty($item_id) or $item_id != strval(intval($item_id))){return -1;}
  586. //get the agenda item
  587. $sql = "SELECT * FROM $table_agenda WHERE id = '".$item_id."'";
  588. $res = api_sql_query($sql,__FILE__,__LINE__);
  589. if(Database::num_rows($res)>0){
  590. $row = Database::fetch_array($res);
  591. //we have the agenda event, copy it
  592. //get the maximum value for display order in announcement table
  593. $sql_max = "SELECT MAX(display_order) FROM $table_ann";
  594. $res_max = api_sql_query($sql_max,__FILE__,__LINE__);
  595. $row_max = Database::fetch_array($res_max);
  596. $max = $row_max[0]+1;
  597. //build the announcement text
  598. $content = $row['start_date']." - ".$row['end_date']."\n\n".$row['content'];
  599. //insert announcement
  600. $sql_ins = "INSERT INTO $table_ann (title,content,end_date,display_order) " .
  601. "VALUES ('".$row['title']."','$content','".$row['end_date']."','$max')";
  602. $res_ins = api_sql_query($sql_ins,__FILE__,__LINE__);
  603. if($res > 0)
  604. {
  605. $ann_id = Database::get_last_insert_id();
  606. //Now also get the list of item_properties rows for this agenda_item (calendar_event)
  607. //and copy them into announcement item_properties
  608. $table_props = Database::get_course_table(ITEM_PROPERTY_TABLE);
  609. $sql_props = "SELECT * FROM $table_props WHERE tool = 'calendar_event' AND ref='$item_id'";
  610. $res_props = api_sql_query($sql_props,__FILE__,__LINE__);
  611. if(Database::num_rows($res_props)>0)
  612. {
  613. while($row_props = Database::fetch_array($res_props))
  614. {
  615. //insert into announcement item_property
  616. $time = date("Y-m-d H:i:s", time());
  617. $sql_ins_props = "INSERT INTO $table_props " .
  618. "(tool, insert_user_id, insert_date, " .
  619. "lastedit_date, ref, lastedit_type," .
  620. "lastedit_user_id, to_group_id, to_user_id, " .
  621. "visibility, start_visible, end_visible)" .
  622. " VALUES " .
  623. "('announcement','".$row_props['insert_user_id']."','".$time."'," .
  624. "'$time','$ann_id','AnnouncementAdded'," .
  625. "'".$row_props['last_edit_user_id']."','".$row_props['to_group_id']."','".$row_props['to_user_id']."'," .
  626. "'".$row_props['visibility']."','".$row_props['start_visible']."','".$row_props['end_visible']."')";
  627. $res_ins_props = api_sql_query($sql_ins_props,__FILE__,__LINE__);
  628. if($res_ins_props <= 0){
  629. error_log('SQL Error in '.__FILE__.' at line '.__LINE__.': '.$sql_ins_props);
  630. }else{
  631. //copy was a success
  632. return $ann_id;
  633. }
  634. }
  635. }
  636. }else{
  637. return -1;
  638. }
  639. }
  640. return -1;
  641. }
  642. /**
  643. * This function separates the users from the groups
  644. * users have a value USER:XXX (with XXX the dokeos id
  645. * groups have a value GROUP:YYY (with YYY the group id)
  646. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  647. * @return array
  648. */
  649. function separate_users_groups($to)
  650. {
  651. foreach($to as $to_item)
  652. {
  653. list($type, $id) = explode(':', $to_item);
  654. switch($type)
  655. {
  656. case 'GROUP':
  657. $grouplist[] =$id;
  658. break;
  659. case 'USER':
  660. $userlist[] =$id;
  661. break;
  662. }
  663. }
  664. $send_to['groups']=$grouplist;
  665. $send_to['users']=$userlist;
  666. return $send_to;
  667. }
  668. /**
  669. * returns all the users and all the groups a specific Agenda item has been sent to
  670. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  671. * @return array
  672. */
  673. function sent_to($tool, $id)
  674. {
  675. global $_course;
  676. $TABLE_ITEM_PROPERTY = Database::get_course_table(LAST_TOOL_EDIT_TABLE);
  677. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'";
  678. $result=api_sql_query($sql,__FILE__,__LINE__);
  679. while ($row=mysql_fetch_array($result))
  680. {
  681. // if to_group_id is null then it is sent to a specific user
  682. // if to_group_id = 0 then it is sent to everybody
  683. if (!is_null($row['to_group_id']) )
  684. {
  685. $sent_to_group[]=$row['to_group_id'];
  686. //echo $row['to_group_id'];
  687. }
  688. // if to_user_id <> 0 then it is sent to a specific user
  689. if ($row['to_user_id']<>0)
  690. {
  691. $sent_to_user[]=$row['to_user_id'];
  692. }
  693. }
  694. if (isset($sent_to_group))
  695. {
  696. $sent_to['groups']=$sent_to_group;
  697. }
  698. if (isset($sent_to_user))
  699. {
  700. $sent_to['users']=$sent_to_user;
  701. }
  702. return $sent_to;
  703. }
  704. /**
  705. * constructs the form to display all the groups and users the message has been sent to
  706. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  707. * @param array $sent_to_array: a 2 dimensional array containing the groups and the users
  708. * the first level is a distinction between groups and users: $sent_to_array['groups'] and $sent_to_array['users']
  709. * $sent_to_array['groups'] (resp. $sent_to_array['users']) is also an array containing all the id's of the
  710. * groups (resp. users) who have received this message.
  711. * @return html
  712. */
  713. function sent_to_form($sent_to_array)
  714. {
  715. // we find all the names of the groups
  716. $group_names=get_course_groups();
  717. count($sent_to_array);
  718. // we count the number of users and the number of groups
  719. if (isset($sent_to_array['users']))
  720. {
  721. $number_users=count($sent_to_array['users']);
  722. }
  723. else
  724. {
  725. $number_users=0;
  726. }
  727. if (isset($sent_to_array['groups']))
  728. {
  729. $number_groups=count($sent_to_array['groups']);
  730. }
  731. else
  732. {
  733. $number_groups=0;
  734. }
  735. $total_numbers=$number_users+$number_groups;
  736. // starting the form if there is more than one user/group
  737. if ($total_numbers >1)
  738. {
  739. $output="<select name=\"sent to\">\n";
  740. $output.="<option>".get_lang("SentTo")."</option>";
  741. // outputting the name of the groups
  742. if (is_array($sent_to_array['groups']))
  743. {
  744. foreach ($sent_to_array['groups'] as $group_id)
  745. {
  746. $output.="\t<option value=\"\">G: ".$group_names[$group_id]['name']."</option>\n";
  747. }
  748. }
  749. if (isset($sent_to_array['users']))
  750. {
  751. if (is_array($sent_to_array['users']))
  752. {
  753. foreach ($sent_to_array['users'] as $user_id)
  754. {
  755. $user_info=api_get_user_info($user_id);
  756. $output.="\t<option value=\"\">".$user_info['firstName']." ".$user_info['lastName']."</option>\n";
  757. }
  758. }
  759. }
  760. // ending the form
  761. $output.="</select>\n";
  762. }
  763. else // there is only one user/group
  764. {
  765. if (is_array($sent_to_array['users']))
  766. {
  767. $user_info=api_get_user_info($sent_to_array['users'][0]);
  768. echo $user_info['firstName']." ".$user_info['lastName'];
  769. }
  770. if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
  771. {
  772. $group_id=$sent_to_array['groups'][0];
  773. echo $group_names[$group_id]['name'];
  774. }
  775. if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0)
  776. {
  777. echo get_lang("Everybody");
  778. }
  779. //.$sent_to_array['groups'][0];
  780. }
  781. echo $output;
  782. }
  783. /**
  784. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  785. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  786. */
  787. function show_group_filter_form()
  788. {
  789. $group_list=get_course_groups();
  790. echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  791. echo "<option value=\"agenda.php?group=none\">show all groups</option>";
  792. foreach($group_list as $this_group)
  793. {
  794. // echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
  795. echo "<option value=\"agenda.php?group=".$this_group['id']."\" ";
  796. echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
  797. echo ">".$this_group['name']."</option>";
  798. }
  799. echo "</select>";
  800. }
  801. /**
  802. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  803. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  804. */
  805. function show_user_filter_form()
  806. {
  807. $user_list=get_course_users();
  808. echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  809. echo "<option value=\"agenda.php?user=none\">show all users</option>";
  810. foreach($user_list as $this_user)
  811. {
  812. // echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  813. echo "<option value=\"agenda.php?user=".$this_user['uid']."\" ";
  814. echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
  815. echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  816. }
  817. echo "</select>";
  818. }
  819. /**
  820. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  821. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  822. */
  823. function show_user_group_filter_form()
  824. {
  825. echo "\n<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  826. echo "\n\t<option value=\"agenda.php?user=none\">".get_lang("ShowAll")."</option>";
  827. // Groups
  828. echo "\n\t<optgroup label=\"".get_lang("Groups")."\">";
  829. $group_list=get_course_groups();
  830. foreach($group_list as $this_group)
  831. {
  832. // echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
  833. echo "\n\t\t<option value=\"agenda.php?group=".$this_group['id']."\" ";
  834. echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
  835. echo ">".$this_group['name']."</option>";
  836. }
  837. echo "\n\t</optgroup>";
  838. // Users
  839. echo "\n\t<optgroup label=\"".get_lang("Users")."\">";
  840. $user_list=get_course_users();
  841. foreach($user_list as $this_user)
  842. {
  843. // echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  844. echo "\n\t\t<option value=\"agenda.php?user=".$this_user['uid']."\" ";
  845. echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
  846. echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  847. }
  848. echo "\n\t</optgroup>";
  849. echo "</select>";
  850. }
  851. /**
  852. * This tools loads all the users and all the groups who have received a specific item (in this case an agenda item)
  853. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  854. */
  855. function load_edit_users($tool, $id)
  856. {
  857. global $_course;
  858. $TABLE_ITEM_PROPERTY = Database::get_course_table(LAST_TOOL_EDIT_TABLE);
  859. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'";
  860. $result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  861. while ($row=mysql_fetch_array($result))
  862. {
  863. $to_group=$row['to_group_id'];
  864. switch ($to_group)
  865. {
  866. // it was send to one specific user
  867. case null:
  868. $to[]="USER:".$row['to_user_id'];
  869. break;
  870. // it was sent to everyone
  871. case 0:
  872. return "everyone";
  873. exit;
  874. break;
  875. default:
  876. $to[]="GROUP:".$row['to_group_id'];
  877. }
  878. }
  879. return $to;
  880. }
  881. /**
  882. * This functions swithes the visibility a course resource using the visible field in 'last_tooledit' values: 0 = invisible
  883. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  884. */
  885. function change_visibility($tool,$id)
  886. {
  887. global $_course;
  888. $TABLE_ITEM_PROPERTY = Database::get_course_table(LAST_TOOL_EDIT_TABLE);
  889. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'";
  890. $result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  891. $row=mysql_fetch_array($result);
  892. if ($row['visibility']=='1')
  893. {
  894. $sql_visibility="UPDATE $TABLE_ITEM_PROPERTY SET visibility='0' WHERE tool='$tool' AND ref='$id'";
  895. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"invisible");
  896. }
  897. else
  898. {
  899. $sql_visibility="UPDATE $TABLE_ITEM_PROPERTY SET visibility='1' WHERE tool='$tool' AND ref='$id'";
  900. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"visible");
  901. }
  902. }
  903. /**
  904. * The links that allows the course administrator to add a new agenda item, to filter on groups or users
  905. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  906. */
  907. function display_courseadmin_links()
  908. {
  909. echo "<li><a href='".$_SERVER['PHP_SELF']."?action=add&amp;origin=".$_GET['origin']."'><img src=\"../img/calendar_add.gif\" align=\"absmiddle\" border=\"0\" /> ".get_lang("AgendaAdd")."</a><br /></li>";
  910. if (empty ($_SESSION['toolgroup']))
  911. {
  912. echo "<li>".get_lang(UserGroupFilter)."<br/>";
  913. echo "<form name=\"filter\">";
  914. show_user_group_filter_form();
  915. echo "</form>";
  916. }
  917. echo "</li>";
  918. }
  919. /**
  920. * The links that allows the student AND course administrator to show all agenda items and sort up/down
  921. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  922. */
  923. function display_student_links()
  924. {
  925. global $show;
  926. if ($_SESSION['sort'] == 'DESC')
  927. {
  928. echo "<li><a href='".$_SERVER['PHP_SELF']."?sort=asc&amp;origin=".$_GET['origin']."'><img src=\"../img/calendar_up.gif\" border=\"0\" /> ".get_lang("AgendaSortChronologicallyUp")."</a></li>";
  929. }
  930. else
  931. {
  932. echo "<li><a href='".$_SERVER['PHP_SELF']."?sort=desc&amp;origin=".$_GET['origin']."'><img src=\"../img/calendar_down.gif\" border=\"0\" /> ".get_lang("AgendaSortChronologicallyDown")."</a></li>";
  933. }
  934. // showing the link to show all items or only those of the current month
  935. if ($_SESSION['show']=="showcurrent")
  936. {
  937. echo "<li><a href='".$_SERVER['PHP_SELF']."?action=showall&amp;origin=".$_GET['origin']."'><img src=\"../img/calendar_select.gif\" border=\"0\" /> ".get_lang("ShowAll")."</a></li>";
  938. }
  939. else
  940. {
  941. echo "<li><a href='".$_SERVER['PHP_SELF']."?action=showcurrent&amp;origin=".$_GET['origin']."'><img src=\"../img/calendar_month.gif\" border=\"0\" /> ".get_lang("ShowCurrent")."</a></li>";
  942. }
  943. }
  944. /**
  945. * get all the information of the agenda_item from the database
  946. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  947. * @param integer the id of the agenda item we are getting all the information of
  948. * @return an associative array that contains all the information of the agenda item. The keys are the database fields
  949. */
  950. function get_agenda_item($id)
  951. {
  952. global $TABLEAGENDA;
  953. $id=(int)addslashes($_GET['id']);
  954. $sql = "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
  955. $result = api_sql_query($sql,__FILE__,__LINE__);
  956. $entry_to_edit = mysql_fetch_array($result);
  957. $item['title'] = $entry_to_edit["title"];
  958. $item['content'] = $entry_to_edit["content"];
  959. $item['start_date'] = $entry_to_edit["start_date"];
  960. $item['end_date'] = $entry_to_edit["end_date"];
  961. $item['to']=load_edit_users(TOOL_CALENDAR_EVENT, $id);
  962. // if the item has been sent to everybody then we show the compact to form
  963. if ($item['to']=="everyone")
  964. {
  965. $_SESSION['allow_individual_calendar']="hide";
  966. }
  967. else
  968. {
  969. $_SESSION['allow_individual_calendar']="show";
  970. }
  971. //echo "<br />IN get_agenda_item".$_SESSION['allow_individual_calendar'];
  972. return $item;
  973. }
  974. /**
  975. * This is the function that updates an agenda item. It does 3 things
  976. * 1. storethe start_date, end_date, title and message in the calendar_event table
  977. * 2. store the groups/users who this message is meant for in the item_property table
  978. * 3. modify the attachments (if needed)
  979. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  980. */
  981. function store_edited_agenda_item()
  982. {
  983. global $_uid;
  984. // database definitions
  985. $TABLE_ITEM_PROPERTY = Database::get_course_table(LAST_TOOL_EDIT_TABLE);
  986. // STEP 1: editing the calendar_event table
  987. // 1.a. some filtering of the input data
  988. $id=(int)$_POST['id'];
  989. $title=strip_tags(trim($_POST['title'])); // no html allowed in the title
  990. $content=trim($_POST['content']);
  991. $start_date=(int)$_POST['fyear']."-".(int)$_POST['fmonth']."-".(int)$_POST['fday']." ".(int)$_POST['fhour'].":".(int)$_POST['fminute'].":00";
  992. $end_date=(int)$_POST['end_fyear']."-".(int)$_POST['end_fmonth']."-".(int)$_POST['end_fday']." ".(int)$_POST['end_fhour'].":".(int)$_POST['end_fminute'].":00";
  993. $to=$_POST['selectedform'];
  994. // 1.b. the actual saving in calendar_event table
  995. $edit_result=save_edit_agenda_item($id,$title,$content,$start_date,$end_date);
  996. // step 2: editing the item_propery table (=delete all and add the new destination users/groups)
  997. if ($edit_result=true)
  998. {
  999. // 2.a. delete everything for the users
  1000. $sql_delete="DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
  1001. $result = api_sql_query($sql_delete,__FILE__,__LINE__) or die (mysql_error());
  1002. // 2.b. storing the new users/groups
  1003. if ($_SESSION['allow_individual_calendar']=="show" and !is_null($to)) // !is_null($to): when no user is selected we send it to everyone
  1004. {
  1005. $send_to=separate_users_groups($to);
  1006. // storing the selected groups
  1007. if (is_array($send_to['groups']))
  1008. {
  1009. foreach ($send_to['groups'] as $group)
  1010. {
  1011. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid, $group,'',$start_visible, $end_visible);
  1012. }
  1013. }
  1014. // storing the selected users
  1015. if (is_array($send_to['users']))
  1016. {
  1017. foreach ($send_to['users'] as $user)
  1018. {
  1019. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid,'',$user, $start_visible,$end_visible);
  1020. }
  1021. }
  1022. }
  1023. else // the message is sent to everyone, so we set the group to 0
  1024. {
  1025. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_uid, '','',$start_visible,$end_visible);
  1026. }
  1027. } //if ($edit_result=true)
  1028. // step 3: update the attachments (=delete all and add those in the session
  1029. update_added_resources("Agenda", $id);
  1030. // return the message;
  1031. Display::display_normal_message(get_lang("EditSuccess"));
  1032. }
  1033. /**
  1034. * This function stores the Agenda Item in the table calendar_event and updates the item_property table also (after an edit)
  1035. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1036. */
  1037. function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
  1038. {
  1039. $TABLEAGENDA = Database::get_course_table(AGENDA_TABLE);
  1040. // store the modifications in the table calendar_event
  1041. $sql = "UPDATE ".$TABLEAGENDA."
  1042. SET title='".$title."',
  1043. content='".$content."',
  1044. start_date='".$start_date."',
  1045. end_date='".$end_date."'
  1046. WHERE id='".$id."'";
  1047. $result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  1048. return true;
  1049. }
  1050. /**
  1051. * This is the function that deletes an agenda item.
  1052. * The agenda item is no longer fycically deleted but the visibility in the item_property table is set to 2
  1053. * which means that it is invisible for the student AND course admin. Only the platform administrator can see it.
  1054. * This will in a later stage allow the platform administrator to recover resources that were mistakenly deleted
  1055. * by the course administrator
  1056. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1057. * @param integer the id of the agenda item wa are deleting
  1058. */
  1059. function delete_agenda_item($id)
  1060. {
  1061. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1062. {
  1063. if (isset($_GET['id'])&&$_GET['id']&&isset($_GET['action'])&&$_GET['action']=="delete")
  1064. {
  1065. //$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'";
  1066. //$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'";
  1067. //$result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  1068. $id=(int)addslashes($_GET['id']);
  1069. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"delete");
  1070. // delete the resources that were added to this agenda item
  1071. // 2DO: as we no longer fysically delete the agenda item (to make it possible to 'restore'
  1072. // deleted items, we should not delete the added resources either.
  1073. // delete_added_resource("Agenda", $id); // -> this is no longer needed as the message is not really deleted but only visibility=2 (only platform admin can see it)
  1074. //resetting the $id;
  1075. $id=null;
  1076. // displaying the result message in the yellow box
  1077. Display::display_normal_message(get_lang("AgendaDeleteSuccess"));
  1078. } // if (isset($id)&&$id&&isset($action)&&$action=="delete")
  1079. } // if ($is_allowedToEdit)
  1080. }
  1081. /**
  1082. * Makes an agenda item visible or invisible for a student
  1083. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1084. * @param integer id the id of the agenda item we are changing the visibility of
  1085. */
  1086. function showhide_agenda_item($id)
  1087. {
  1088. /*==================================================
  1089. SHOW / HIDE A CALENDAR ITEM
  1090. ==================================================*/
  1091. // and $_GET['isStudentView']<>"false" is added to prevent that the visibility is changed after you do the following:
  1092. // change visibility -> studentview -> course manager view
  1093. if ((is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda')) and $_GET['isStudentView']<>"false")
  1094. {
  1095. if (isset($_GET['id'])&&$_GET['id']&&isset($_GET['action'])&&$_GET['action']=="showhide")
  1096. {
  1097. $id=(int)addslashes($_GET['id']);
  1098. change_visibility($_GLOBAL['nameTools'],$id);
  1099. Display::display_normal_message(get_lang("VisibilityChanged"));
  1100. }
  1101. }
  1102. }
  1103. /**
  1104. * Displays all the agenda items
  1105. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1106. */
  1107. function display_agenda_items()
  1108. {
  1109. global $TABLEAGENDA;
  1110. global $TABLE_ITEM_PROPERTY;
  1111. global $select_month, $select_year;
  1112. global $DaysShort, $DaysLong, $MonthsLong;
  1113. global $is_courseAdmin;
  1114. global $dateFormatLong, $timeNoSecFormat;
  1115. global $_uid;
  1116. // getting the group memberships
  1117. $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_uid);
  1118. // getting the name of the groups
  1119. $group_names=get_course_groups();
  1120. /*--------------------------------------------------
  1121. CONSTRUCT THE SQL STATEMENT
  1122. --------------------------------------------------*/
  1123. // this is to make a difference between showing everything (all months) or only the current month)
  1124. // $show_all_current is a part of the sql statement
  1125. if ($_SESSION['show']!=="showall")
  1126. {
  1127. $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year";
  1128. }
  1129. else
  1130. {
  1131. $show_all_current="";
  1132. }
  1133. // by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter
  1134. $user_id=$_uid;
  1135. if ($_SESSION['user']!==null)
  1136. {
  1137. $user_id=$_SESSION['user'];
  1138. }
  1139. if ($_SESSION['group']!==null)
  1140. {
  1141. $group_id=$_SESSION['group'];
  1142. }
  1143. if ($_SESSION['toolgroup']!==null)
  1144. {
  1145. $group_id=$_SESSION['toolgroup'];
  1146. }
  1147. //echo "user:".$_SESSION['user']."group: ".$_SESSION['group'];
  1148. // A. you are a course admin
  1149. //if ($is_courseAdmin)
  1150. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1151. {
  1152. // A.1. you are a course admin with a USER filter
  1153. // => see only the messages of this specific user + the messages of the group (s)he is member of.
  1154. if ($_SESSION['user']!==null)
  1155. {
  1156. $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_SESSION['user']);
  1157. if (is_array($group_memberships))
  1158. {
  1159. $sql="SELECT
  1160. agenda.*, toolitemproperties.*
  1161. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1162. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1163. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1164. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  1165. AND `toolitemproperties`.`visibility`='1'
  1166. ORDER BY start_date ".$_SESSION['sort'];
  1167. }
  1168. else
  1169. {
  1170. $sql="SELECT
  1171. agenda.*, toolitemproperties.*
  1172. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1173. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1174. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1175. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id`='0')
  1176. AND `toolitemproperties`.`visibility`='1'
  1177. ORDER BY start_date ".$_SESSION['sort'];
  1178. }
  1179. }
  1180. // A.2. you are a course admin with a GROUP filter
  1181. // => see only the messages of this specific group
  1182. elseif ($_SESSION['group']!==null)
  1183. {
  1184. $sql="SELECT
  1185. agenda.*, toolitemproperties.*
  1186. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1187. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1188. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1189. AND ( `toolitemproperties`.`to_group_id`=$group_id OR `toolitemproperties`.`to_group_id`='0')
  1190. AND `toolitemproperties`.`visibility`='1'
  1191. GROUP BY `toolitemproperties`.`ref`
  1192. ORDER BY start_date ".$_SESSION['sort'];
  1193. }
  1194. // A.3 you are a course admin without any group or user filter
  1195. else
  1196. {
  1197. // A.3.a you are a course admin without user or group filter but WITH studentview
  1198. // => see all the messages of all the users and groups without editing possibilities
  1199. if ($isStudentView=="true")
  1200. {
  1201. $sql="SELECT
  1202. agenda.*, toolitemproperties.*
  1203. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1204. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1205. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1206. AND `toolitemproperties`.`visibility`='1'
  1207. GROUP BY `toolitemproperties`.`ref`
  1208. ORDER BY start_date ".$_SESSION['sort'];
  1209. }
  1210. // A.3.b you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
  1211. // => see all the messages of all the users and groups with editing possibilities
  1212. else
  1213. {
  1214. $sql="SELECT
  1215. agenda.*, toolitemproperties.*
  1216. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1217. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1218. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1219. AND ( `toolitemproperties`.`visibility`='0' or `toolitemproperties`.`visibility`='1')
  1220. GROUP BY `toolitemproperties`.`ref`
  1221. ORDER BY start_date ".$_SESSION['sort'];
  1222. }
  1223. }
  1224. } //if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1225. // B. you are a student
  1226. else
  1227. {
  1228. if (is_array($group_memberships))
  1229. {
  1230. $sql="SELECT
  1231. agenda.*, toolitemproperties.*
  1232. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1233. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1234. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1235. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  1236. AND `toolitemproperties`.`visibility`='1'
  1237. ORDER BY start_date ".$_SESSION['sort'];
  1238. }
  1239. else
  1240. {
  1241. if ($_uid)
  1242. {
  1243. $sql="SELECT
  1244. agenda.*, toolitemproperties.*
  1245. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1246. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1247. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1248. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id`='0')
  1249. AND `toolitemproperties`.`visibility`='1'
  1250. ORDER BY start_date ".$_SESSION['sort'];
  1251. }
  1252. else
  1253. {
  1254. $sql="SELECT
  1255. agenda.*, toolitemproperties.*
  1256. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1257. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1258. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1259. AND `toolitemproperties`.`to_group_id`='0'
  1260. AND `toolitemproperties`.`visibility`='1'
  1261. ORDER BY start_date ".$_SESSION['sort'];
  1262. }
  1263. }
  1264. } // you are a student
  1265. //echo "<pre>".$sql."</pre>";
  1266. $result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  1267. $number_items=mysql_num_rows($result);
  1268. /*--------------------------------------------------
  1269. DISPLAY: NO ITEMS
  1270. --------------------------------------------------*/
  1271. if ($number_items==0)
  1272. {
  1273. echo "<table id=\"agenda_list\" ><tr><td>".get_lang("NoAgendaItems")."</td></tr></table>";
  1274. }
  1275. /*--------------------------------------------------
  1276. DISPLAY: THE ITEMS
  1277. --------------------------------------------------*/
  1278. echo "<table id=\"agenda_list\">\n";
  1279. $month_bar="";
  1280. $event_list="";
  1281. while ($myrow=mysql_fetch_array($result))
  1282. {
  1283. /*--------------------------------------------------
  1284. display: the month bar
  1285. --------------------------------------------------*/
  1286. // Make the month bar appear only once.
  1287. if ($month_bar != date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"])))
  1288. {
  1289. $month_bar = date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
  1290. echo "\t<tr>\n\t\t<td class=\"agenda_month_divider\" colspan=\"2\" valign=\"top\">".
  1291. ucfirst(format_locale_date("%B %Y",strtotime($myrow["start_date"]))).
  1292. "</td>\n\t</tr>\n";
  1293. }
  1294. /*--------------------------------------------------
  1295. display: the icon, title, destinees of the item
  1296. --------------------------------------------------*/
  1297. echo "\t<tr>\n";
  1298. // highlight: if a date in the small calendar is clicked we highlight the relevant items
  1299. $db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
  1300. if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
  1301. {
  1302. if ($myrow['visibility']=='0')
  1303. {
  1304. $style="data_hidden";
  1305. $stylenotbold="datanotbold_hidden";
  1306. $text_style="text_hidden";
  1307. }
  1308. else
  1309. {
  1310. $style="data";
  1311. $stylenotbold="datanotbold";
  1312. $text_style="text";
  1313. }
  1314. }
  1315. else
  1316. {
  1317. $style="datanow";
  1318. $stylenotbold="datanotboldnow";
  1319. $text_style="textnow";
  1320. }
  1321. echo "\t\t<td class=\"".$style."\">\n";
  1322. // adding an internal anchor
  1323. echo "\t\t\t<a name=\"".(int)date("d",strtotime($myrow["start_date"]))."\"></a>";
  1324. // the icons. If the message is sent to one or more specific users/groups
  1325. // we add the groups icon
  1326. // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon
  1327. echo "<img src=\"../img/agenda.gif\" border=\"0\" />";
  1328. if ($myrow['to_group_id']!=='0')
  1329. {
  1330. echo "<img src=\"../img/group.gif\" border=\"0\" />";
  1331. }
  1332. echo " ".$myrow['title']."\n";
  1333. echo "\t\t</td>\n";
  1334. // the message has been sent to
  1335. echo "\t\t<td class=\"".$stylenotbold."\">".get_lang("SentTo").": ";
  1336. $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
  1337. $sent_to_form=sent_to_form($sent_to);
  1338. echo $sent_to_form;
  1339. echo "</td>\n\t</tr>\n";
  1340. /*--------------------------------------------------
  1341. display: the title
  1342. --------------------------------------------------*/
  1343. echo "\t<tr class=\"".$stylenotbold."\">\n";
  1344. echo "\t\t<td>".get_lang("StartTimeWindow").": ";
  1345. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
  1346. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
  1347. echo "</td>\n";
  1348. echo "\t\t<td>";
  1349. if ($myrow["end_date"]<>"0000-00-00 00:00:00")
  1350. {
  1351. echo get_lang("EndTimeWindow").": ";
  1352. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
  1353. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
  1354. }
  1355. echo "</td>\n";
  1356. echo "\n\t</tr>\n";
  1357. /*--------------------------------------------------
  1358. display: the content
  1359. --------------------------------------------------*/
  1360. $content = $myrow['content'];
  1361. $content = make_clickable($content);
  1362. $content = text_filter($content);
  1363. echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
  1364. echo '<a href="#" onclick="javascript:win_print=window.open(\'print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;"><img src="../img/print.png" border="0" title="'.htmlentities(get_lang('Print')).'" /></a>&nbsp;';
  1365. echo $content;
  1366. echo "</td></tr>";
  1367. /*--------------------------------------------------
  1368. display: the added resources
  1369. --------------------------------------------------*/
  1370. if (check_added_resources("Agenda", $myrow["id"]))
  1371. {
  1372. echo "<tr><td colspan='2'>";
  1373. echo "<i>".get_lang("AddedResources")."</i><br/>";
  1374. if ($myrow['visibility']==0)
  1375. {
  1376. $addedresource_style="invisible";
  1377. }
  1378. display_added_resources("Agenda", $myrow["id"], $addedresource_style);
  1379. echo "</td></tr>";
  1380. }
  1381. /*--------------------------------------------------
  1382. display: edit delete button (course admin only)
  1383. --------------------------------------------------*/
  1384. $event_list.=$myrow['id'].',';
  1385. echo "<tr><td>";
  1386. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1387. {
  1388. // edit
  1389. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=edit&id=".$myrow['id']."\">",
  1390. "<img src=\"../img/edit.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("ModifyCalendarItem")."\" /></a>",
  1391. "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=delete&id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."')) return false;\">",
  1392. "<img src=\"../img/delete.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("Delete")."\"/></a>";
  1393. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=announce&id=".$myrow['id']."\">".
  1394. "<img src=\"../img/valves_add.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("AddAnnouncement")."\"/></a>";
  1395. if ($myrow['visibility']==1)
  1396. {
  1397. $image_visibility="visible";
  1398. }
  1399. else
  1400. {
  1401. $image_visibility="invisible";
  1402. }
  1403. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=showhide&amp;id=".$myrow['id']."\">",
  1404. "<img src=\"../img/".$image_visibility.".gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("Visible")."\" /></a><br /><br />";
  1405. }
  1406. echo "</td>";
  1407. /*--------------------------------------------------
  1408. display: jump-to-top icon
  1409. --------------------------------------------------*/
  1410. echo "<td><a href=\"#top\"><img src=\"../img/top.gif\" border=\"0\" alt=\"to top\" align=\"right\" /></a></td></tr>";
  1411. } // end while ($myrow=mysql_fetch_array($result))
  1412. echo "</table>";
  1413. if(!empty($event_list))
  1414. {
  1415. $event_list=substr($event_list,0,-1);
  1416. }
  1417. else
  1418. {
  1419. $event_list='0';
  1420. }
  1421. echo "<form name=\"event_list_form\"><input type=\"hidden\" name=\"event_list\" value=\"$event_list\" /></form>";
  1422. // closing the layout table
  1423. echo "</td>",
  1424. "</tr>",
  1425. "</table>";
  1426. }
  1427. /**
  1428. * Displays only 1 agenda item. This is used when an agenda item is added to the learning path.
  1429. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1430. */
  1431. function display_one_agenda_item($agenda_id)
  1432. {
  1433. global $TABLEAGENDA;
  1434. global $TABLE_ITEM_PROPERTY;
  1435. global $select_month, $select_year;
  1436. global $DaysShort, $DaysLong, $MonthsLong;
  1437. global $is_courseAdmin;
  1438. global $dateFormatLong, $timeNoSecFormat;
  1439. global $_uid;
  1440. //echo "displaying agenda items";
  1441. // getting the name of the groups
  1442. $group_names=get_course_groups();
  1443. /*--------------------------------------------------
  1444. CONSTRUCT THE SQL STATEMENT
  1445. --------------------------------------------------*/
  1446. $sql="SELECT agenda.*, toolitemproperties.*
  1447. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1448. WHERE `agenda`.`id` = `toolitemproperties`.`ref`
  1449. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1450. AND `toolitemproperties`.`visibility`='1'
  1451. AND `agenda`.`id`='$agenda_id'";
  1452. $result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  1453. $number_items=mysql_num_rows($result);
  1454. $myrow=mysql_fetch_array($result); // there should be only one item so no need for a while loop
  1455. /*--------------------------------------------------
  1456. DISPLAY: NO ITEMS
  1457. --------------------------------------------------*/
  1458. if ($number_items==0)
  1459. {
  1460. echo "<table id=\"agenda_list\" ><tr><td>".get_lang("NoAgendaItems")."</td></tr></table>";
  1461. }
  1462. /*--------------------------------------------------
  1463. DISPLAY: THE ITEMS
  1464. --------------------------------------------------*/
  1465. echo "<table id=\"agenda_list\">\n";
  1466. /*--------------------------------------------------
  1467. DISPLAY : the icon, title, destinees of the item
  1468. --------------------------------------------------*/
  1469. echo "\t<tr>\n";
  1470. // highlight: if a date in the small calendar is clicked we highlight the relevant items
  1471. $db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
  1472. if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
  1473. {
  1474. if ($myrow['visibility']=='0')
  1475. {
  1476. $style="data_hidden";
  1477. $stylenotbold="datanotbold_hidden";
  1478. $text_style="text_hidden";
  1479. }
  1480. else
  1481. {
  1482. $style="data";
  1483. $stylenotbold="datanotbold";
  1484. $text_style="text";
  1485. }
  1486. }
  1487. else
  1488. {
  1489. $style="datanow";
  1490. $stylenotbold="datanotboldnow";
  1491. $text_style="textnow";
  1492. }
  1493. echo "\t\t<td class=\"".$style."\">\n";
  1494. // adding an internal anchor
  1495. echo "\t\t\t<a name=\"".(int)date("d",strtotime($myrow["start_date"]))."\"></a>";
  1496. // the icons. If the message is sent to one or more specific users/groups
  1497. // we add the groups icon
  1498. // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon
  1499. echo "<img src=\"../img/agenda.gif\" border=\"0\" />";
  1500. if ($myrow['to_group_id']!=='0')
  1501. {
  1502. echo "<img src=\"../img/group.gif\" border=\"0\" />";
  1503. }
  1504. echo " ".$myrow['title']."\n";
  1505. echo "\t\t</td>\n";
  1506. // the message has been sent to
  1507. echo "\t\t<td class=\"".$stylenotbold."\">".get_lang("SentTo").": ";
  1508. $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
  1509. $sent_to_form=sent_to_form($sent_to);
  1510. echo $sent_to_form;
  1511. echo "</td>\n\t</tr>\n";
  1512. /*--------------------------------------------------
  1513. DISPLAY: the title
  1514. --------------------------------------------------*/
  1515. echo "\t<tr class=\"".$stylenotbold."\">\n";
  1516. echo "\t\t<td>".get_lang("StartTime").": ";
  1517. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
  1518. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
  1519. echo "</td>\n";
  1520. echo "\t\t<td>".get_lang("EndTime").": ";
  1521. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
  1522. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
  1523. echo "</td>\n";
  1524. echo "\n\t</tr>\n";
  1525. /*--------------------------------------------------
  1526. DISPLAY: the content
  1527. --------------------------------------------------*/
  1528. $content = $myrow['content'];
  1529. $content = make_clickable($content);
  1530. $content = text_filter($content);
  1531. echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
  1532. echo $content;
  1533. echo "</td></tr>";
  1534. /*--------------------------------------------------
  1535. DISPLAY: the added resources
  1536. --------------------------------------------------*/
  1537. if (check_added_resources("Agenda", $myrow["id"]))
  1538. {
  1539. echo "<tr><td colspan='2'>";
  1540. echo "<i>".get_lang("AddedResources")."</i><br/>";
  1541. if ($myrow['visibility']==0)
  1542. {
  1543. $addedresource_style="invisible";
  1544. }
  1545. display_added_resources("Agenda", $myrow["id"], $addedresource_style);
  1546. echo "</td></tr>";
  1547. }
  1548. /*--------------------------------------------------
  1549. DISPLAY: edit delete button (course admin only)
  1550. --------------------------------------------------*/
  1551. echo "<tr><td>";
  1552. if (is_allowed_to_edit())
  1553. {
  1554. // edit
  1555. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=edit&amp;id=".$myrow['id']."\">",
  1556. "<img src=\"../img/edit.gif\" border=\"0\" alt=\"".get_lang("ModifyCalendarItem")."\" /></a>",
  1557. "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=delete&amp;id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."')) return false;\">",
  1558. "<img src=\"../img/delete.gif\" border=\"0\" alt=\"".get_lang("Delete")."\" /></a>";
  1559. if ($myrow['visibility']==1)
  1560. {
  1561. $image_visibility="visible";
  1562. }
  1563. else
  1564. {
  1565. $image_visibility="invisible";
  1566. }
  1567. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=showhide&amp;id=".$myrow['id']."\">",
  1568. "<img src=\"../img/".$image_visibility.".gif\" border=\"0\" alt=\"".get_lang("Visible")."\" /></a><br /><br />";
  1569. }
  1570. echo "</td>";
  1571. echo "</table>";
  1572. // closing the layout table
  1573. echo "</td>",
  1574. "</tr>",
  1575. "</table>";
  1576. }
  1577. /**
  1578. * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an
  1579. * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and
  1580. * we have to retrieve the information that is in the database and use this information in the forms.
  1581. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1582. * @param integer id, the id of the agenda itme we are editing. By default this is empty which means that we are adding an
  1583. * agenda item.
  1584. */
  1585. function show_add_form($id = '')
  1586. {
  1587. global $MonthsLong;
  1588. // the default values for the forms
  1589. if ($_GET['originalresource'] !== 'no')
  1590. {
  1591. $day = date('d');
  1592. $month = date('m');
  1593. $year = date('Y');
  1594. $hours = date('H');
  1595. $minutes= date('i');
  1596. $end_day = date('d');
  1597. $end_month = date('m');
  1598. $end_year = date('Y');
  1599. $end_hours = date('H');
  1600. $end_minutes= date('i');
  1601. }
  1602. else
  1603. {
  1604. // we are coming from the resource linker so there might already have been some information in the form.
  1605. // When we clicked on the button to add resources we stored every form information into a session and now we
  1606. // are doing the opposite thing: getting the information out of the session and putting it into variables to
  1607. // display it in the forms.
  1608. $form_elements=$_SESSION['formelements'];
  1609. $day=$form_elements['day'];
  1610. $month=$form_elements['month'];
  1611. $year=$form_elements['year'];
  1612. $hours=$form_elements['hour'];
  1613. $minutes=$form_elements['minutes'];
  1614. $end_day=$form_elements['end_day'];
  1615. $end_month=$form_elements['end_month'];
  1616. $end_year=$form_elements['end_year'];
  1617. $end_hours=$form_elements['end_hours'];
  1618. $end_minutes=$form_elements['end_minutes'];
  1619. $title=$form_elements['title'];
  1620. $content=$form_elements['content'];
  1621. $id=$form_elements['id'];
  1622. $to=$form_elements['to'];
  1623. }
  1624. // switching the send to all/send to groups/send to users
  1625. if ($_POST['To'])
  1626. {
  1627. $day = $_POST['fday'];
  1628. $month = $_POST['fmonth'];
  1629. $year = $_POST['fyear'];
  1630. $hours = $_POST['fhour'];
  1631. $minutes = $_POST['fminute'];
  1632. $end_day = $_POST['end_fday'];
  1633. $end_month = $_POST['end_fmonth'];
  1634. $end_year = $_POST['end_fyear'];
  1635. $end_hours = $_POST['end_fhour'];
  1636. $end_minutes = $_POST['end_fminute'];
  1637. $title = $_POST['title'];
  1638. $content = $_POST['content'];
  1639. // the invisible fields
  1640. $action = $_POST['action'];
  1641. $id = $_POST['id'];
  1642. }
  1643. // if the id is set then we are editing an agenda item
  1644. if (is_int($id))
  1645. {
  1646. //echo "before get_agenda_item".$_SESSION['allow_individual_calendar'];
  1647. $item_2_edit=get_agenda_item($id);
  1648. $title = $item_2_edit['title'];
  1649. $content= $item_2_edit['content'];
  1650. // start date
  1651. list($datepart, $timepart) = split(" ", $item_2_edit['start_date']);
  1652. list($year, $month, $day) = explode("-", $datepart);
  1653. list($hours, $minutes, $seconds) = explode(":", $timepart);
  1654. // end date
  1655. list($datepart, $timepart) = split(" ", $item_2_edit['end_date']);
  1656. list($end_year, $end_month, $end_day) = explode("-", $datepart);
  1657. list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart);
  1658. // attachments
  1659. edit_added_resources("Agenda", $id);
  1660. $to=$item_2_edit['to'];
  1661. //echo "<br />after get_agenda_item".$_SESSION['allow_individual_calendar'];
  1662. }
  1663. // we start a completely new item, we do not come from the resource linker
  1664. if ($_GET['originalresource']!=="no" and $_GET['action']=="add")
  1665. {
  1666. $_SESSION["formelements"]=null;
  1667. unset_session_resources();
  1668. }
  1669. ?>
  1670. <!-- START OF THE FORM -->
  1671. <form action="<?php echo $_SERVER['PHP_SELF'].'?origin='.$_GET['origin'].'&amp;action='.$_GET['action']; ?>" method="post" name="new_calendar_item">
  1672. <input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
  1673. <input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
  1674. <table border="0" cellpadding="5" cellspacing="0" width="100%" id="newedit_form">
  1675. <!-- the title -->
  1676. <tr class="title">
  1677. <td colspan="3">
  1678. <h4><?php echo (isset($id) AND $id<>'')?get_lang('ModifyCalendarItem'):get_lang("AddCalendarItem"); ?></h4>
  1679. </td>
  1680. </tr>
  1681. <!-- the select specific users / send to all form -->
  1682. <?php
  1683. if (isset ($_SESSION['toolgroup']))
  1684. {
  1685. echo '<tr id="subtitle">';
  1686. echo '<td colspan="3">';
  1687. echo '<input type="hidden" name="selectedform[0]" value="GROUP:'.$_SESSION['toolgroup'].'"/>' ;
  1688. echo '<input type="hidden" name="To" value="true"/>' ;
  1689. echo '</td>';
  1690. echo '</tr>';
  1691. }else{
  1692. ?>
  1693. <tr class="subtitle">
  1694. <td valign="top" colspan="3">
  1695. <?php
  1696. // this variable defines if the course administrator can send a message to a specific user / group
  1697. // or not
  1698. echo "<input type=\"submit\" name=\"To\" value=\"".get_lang("SelectGroupsUsers")."\" style=\"float:left\">" ;
  1699. //echo "sessiewaarde: ".$_SESSION['allow_individual_calendar'];
  1700. if ($_SESSION['allow_individual_calendar']=="hide")
  1701. {
  1702. echo '<select name="selectedform[]" size="1" multiple="multiple" style="width:200px" width="200px"><option>'.get_lang("Everybody").'</option></select>';
  1703. }
  1704. if ($_SESSION['allow_individual_calendar']=="show")
  1705. {
  1706. show_to_form($to);
  1707. }
  1708. ?>
  1709. <hr noshade="noshade" color="#cccccc" />
  1710. </td>
  1711. </tr>
  1712. <?php
  1713. }
  1714. ?>
  1715. <!-- START date and time -->
  1716. <tr class="subtitle">
  1717. <td>
  1718. <!-- date: 1 -> 31 -->
  1719. <?php echo get_lang('StartDate').": \n"; ?>
  1720. <select name="fday" onchange="javascript:document.new_calendar_item.end_fday.value=this.value;">
  1721. <?php
  1722. // small loop for filling all the dates
  1723. // 2do: the available dates should be those of the selected month => february is from 1 to 28 (or 29) and not to 31
  1724. echo "\n";
  1725. foreach (range(1, 31) as $i)
  1726. {
  1727. // values have to have double digits
  1728. $value = ($i <= 9 ? '0'.$i : $i );
  1729. // the current day is indicated with [] around the date
  1730. if ($value==$day)
  1731. {
  1732. echo "\t\t\t\t <option value=\"".$value."\" selected> ".$i." </option>\n";
  1733. }
  1734. else
  1735. {
  1736. echo "\t\t\t\t<option value=\"$value\">$i</option>\n";
  1737. }
  1738. }
  1739. ?>
  1740. </select>
  1741. <!-- month: january -> december -->
  1742. <select name="fmonth" onchange="javascript:document.new_calendar_item.end_fmonth.value=this.value;">
  1743. <?php
  1744. echo "\n";
  1745. for ($i=1; $i<=12; $i++)
  1746. {
  1747. // values have to have double digits
  1748. if ($i<=9)
  1749. {
  1750. $value="0".$i;
  1751. }
  1752. else
  1753. {
  1754. $value=$i;
  1755. }
  1756. if ($value==$month)
  1757. {
  1758. echo "\t\t\t\t <option value=\"".$value."\" selected>".$MonthsLong[$i-1]."</option>\n";
  1759. }
  1760. else
  1761. {
  1762. echo "\t\t\t\t <option value=\"".$value."\">".$MonthsLong[$i-1]."</option>\n";
  1763. }
  1764. } ?>
  1765. </select>
  1766. <select name="fyear" onchange="javascript:document.new_calendar_item.end_fyear.value=this.value;">
  1767. <option value="<?php echo ($year-1); ?>"><?php echo ($year-1); ?></option>
  1768. <option value="<?php echo $year; ?>" selected="selected"><?php echo $year; ?></option>
  1769. <?php
  1770. echo "\n";
  1771. for ($i=1; $i<=5; $i++)
  1772. {
  1773. $value=$year+$i;
  1774. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1775. } ?>
  1776. </select>
  1777. <a href="javascript:openCalendar('new_calendar_item', 'f')"><img src="../img/calendar_select.gif" border="0" /></a>
  1778. </td>
  1779. <td>
  1780. <?php echo get_lang('StartTime').': '; ?>
  1781. <select name="fhour" onchange="javascript:document.new_calendar_item.end_fhour.value=this.value;">
  1782. <option value="--">--</option>
  1783. <?php
  1784. echo "\n";
  1785. foreach (range(1, 24) as $i)
  1786. {
  1787. // values have to have double digits
  1788. $value = ($i <= 9 ? '0'.$i : $i );
  1789. // the current hour is indicated with [] around the hour
  1790. if ($hours==$value)
  1791. {
  1792. echo "\t\t\t\t<option value=\"".$value."\" selected> ".$value." </option>\n";
  1793. }
  1794. else
  1795. {
  1796. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1797. }
  1798. } ?>
  1799. </select>
  1800. <?php echo get_lang('HourMinuteDivider'); ?>
  1801. <select name="fminute" onchange="javascript:document.new_calendar_item.end_fminute.value=this.value;">
  1802. <option value="<?php echo $minutes ?>"><?php echo $minutes; ?></option>
  1803. <option value="--">--</option>
  1804. <?php
  1805. foreach (range(0, 59) as $i)
  1806. {
  1807. // values have to have double digits
  1808. $value = ($i <= 9 ? '0'.$i : $i );
  1809. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1810. } ?>
  1811. </select>
  1812. </td>
  1813. </tr>
  1814. <!-- END date and time -->
  1815. <tr class="subtitle">
  1816. <td>
  1817. <!-- date: 1 -> 31 -->
  1818. <?php echo get_lang('EndDate').": \n"; ?>
  1819. <select name="end_fday">
  1820. <?php
  1821. // small loop for filling all the dates
  1822. // 2do: the available dates should be those of the selected month => february is from 1 to 28 (or 29) and not to 31
  1823. echo "\n";
  1824. foreach (range(1, 31) as $i)
  1825. {
  1826. // values have to have double digits
  1827. $value = ($i <= 9 ? '0'.$i : $i );
  1828. // the current day is indicated with [] around the date
  1829. if ($value==$end_day)
  1830. { echo "\t\t\t\t <option value=\"".$value."\" selected> ".$i." </option>\n";}
  1831. else
  1832. { echo "\t\t\t\t <option value=\"".$value."\">".$i."</option>\n"; }
  1833. }?>
  1834. </select>
  1835. <!-- month: january -> december -->
  1836. <select name="end_fmonth">
  1837. <?php
  1838. echo "\n";
  1839. foreach (range(1, 12) as $i)
  1840. {
  1841. // values have to have double digits
  1842. $value = ($i <= 9 ? '0'.$i : $i );
  1843. if ($value==$end_month)
  1844. { echo "\t\t\t\t <option value=\"".$value."\" selected>".$MonthsLong[$i-1]."</option>\n"; }
  1845. else
  1846. { echo "\t\t\t\t <option value=\"".$value."\">".$MonthsLong[$i-1]."</option>\n"; }
  1847. }?>
  1848. </select>
  1849. <select name="end_fyear">
  1850. <option value="<?php echo ($end_year-1) ?>"><?php echo ($end_year-1) ?></option>
  1851. <option value="<?php echo $end_year ?>" selected> <?php echo $end_year ?> </option>
  1852. <?php
  1853. echo "\n";
  1854. for ($i=1; $i<=5; $i++)
  1855. {
  1856. $value=$end_year+$i;
  1857. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1858. } ?>
  1859. </select>
  1860. <a href="javascript:openCalendar('new_calendar_item', 'end_f')"><img src="../img/calendar_select.gif" border="0" /></a>
  1861. </td>
  1862. <td>
  1863. <?php echo get_lang('EndTime').': ';?>
  1864. <select name="end_fhour">
  1865. <option value="--">--</option>
  1866. <?php
  1867. echo "\n";
  1868. foreach (range(1, 24) as $i)
  1869. {
  1870. // values have to have double digits
  1871. $value = ($i <= 9 ? '0'.$i : $i );
  1872. // the current hour is indicated with [] around the hour
  1873. if ($end_hours==$value)
  1874. { echo "\t\t\t\t<option value=\"".$value."\" selected> ".$value." </option>\n"; }
  1875. else
  1876. { echo "\t\t\t\t<option value=\"".$value."\"> ".$value." </option>\n"; }
  1877. } ?>
  1878. </select>
  1879. <?php echo get_lang('HourMinuteDivider'); ?>
  1880. <select name="end_fminute">
  1881. <option value="<?php echo $end_minutes; ?>"><?php echo $end_minutes; ?></option>
  1882. <option value="--">--</option>
  1883. <?php
  1884. foreach (range(0, 59) as $i)
  1885. {
  1886. // values have to have double digits
  1887. $value = ($i <= 9 ? '0'.$i : $i );
  1888. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1889. } ?>
  1890. </select>
  1891. </td>
  1892. </tr>
  1893. <tr class="subtitle">
  1894. <td colspan="3" valign="top"><hr noshade="noshade" color="#cccccc" /><?php echo get_lang('ItemTitle'); ?> :
  1895. <textarea name="title" cols="50" rows="2" wrap="virtual" style="vertical-align:top; width:75%; height:50px;"><?php if (isset($title)) echo $title; ?></textarea>
  1896. <!-- <input type="text" size="60" name="title" value="<?php if (isset($title)) echo $title; ?>" /> -->
  1897. </td>
  1898. </tr>
  1899. <tr>
  1900. <td colspan="7"><?php echo get_lang('Detail'); ?> :</td>
  1901. </tr>
  1902. <tr>
  1903. <td colspan="7">
  1904. <?php api_disp_html_area('content',$content,'300px'); ?><br />
  1905. </td>
  1906. </tr>
  1907. <?php /* ADDED BY UGENT, Patrick Cool, march 2004 */ ?>
  1908. <tr>
  1909. <td colspan="7">
  1910. <?php
  1911. //onclick="selectAll(this.form.elements[6],true)"
  1912. if ($_SESSION['allow_individual_calendar']=='show')
  1913. show_addresource_button('onclick="selectAll(this.form.elements[6],true)"');
  1914. else
  1915. show_addresource_button();
  1916. $form_elements=$_SESSION['formelements'];
  1917. ?>
  1918. </td>
  1919. </tr>
  1920. <?php
  1921. //if ($_SESSION['addedresource'])
  1922. echo "\t<tr>\n";
  1923. echo "\t\t<td colspan=\"7\">\n";
  1924. echo display_resources(0);
  1925. $test=$_SESSION['addedresource'];
  1926. echo "\t\t</td>\n\t</tr>\n";
  1927. /* END ADDED BY UGENT, Patrick Cool, march 2004 */
  1928. ?>
  1929. <tr>
  1930. <td colspan="7">
  1931. <input type="submit" name="submit_event" value="<?php echo get_lang('Ok'); ?>" onclick="selectAll(this.form.elements[6],true)" />
  1932. </td>
  1933. </tr>
  1934. </table>
  1935. </form>
  1936. <p>&nbsp;</p>
  1937. <?php
  1938. }
  1939. ?>