agenda.inc.php 73 KB

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