agenda.inc.php 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240
  1. <?php //$Id: agenda.inc.php 11607 2007-03-16 13:18:47Z elixir_julian $
  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. $sql = "SELECT u.user_id uid, u.lastname lastName, u.firstname firstName
  380. FROM $tbl_user as u, $tbl_courseUser as cu
  381. WHERE cu.course_code = '".$_cid."'
  382. AND cu.user_id = u.user_id $courseadmin_filter
  383. ORDER BY u.lastname, u.firstname";
  384. $result = api_sql_query($sql,__FILE__,__LINE__);
  385. while($user=mysql_fetch_array($result)){
  386. $users[$user[0]] = $user;
  387. }
  388. if(!empty($_SESSION['id_session'])){
  389. $sql = "SELECT u.user_id uid, u.lastname lastName, u.firstName firstName
  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. $result = api_sql_query($sql,__FILE__,__LINE__);
  396. while($user=mysql_fetch_array($result)){
  397. $users[$user[0]] = $user;
  398. }
  399. }
  400. return $users;
  401. }
  402. /**
  403. * this function gets all the groups of the course
  404. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  405. * @return array
  406. */
  407. function get_course_groups()
  408. {
  409. global $tbl_group;
  410. global $tbl_groupUser;
  411. $sql = "SELECT g.id, g.name, COUNT(gu.id) userNb
  412. FROM ".$tbl_group." AS g LEFT JOIN ".$tbl_groupUser." gu
  413. ON g.id = gu.group_id
  414. GROUP BY g.id";
  415. $result = api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  416. while ($group_data = mysql_fetch_array($result))
  417. {
  418. $group_list [$group_data['id']] = $group_data;
  419. }
  420. return $group_list;
  421. }
  422. /**
  423. * this function shows the form for sending a message to a specific group or user.
  424. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  425. * @return html code
  426. */
  427. function show_to_form($to_already_selected)
  428. {
  429. $user_list=get_course_users();
  430. $group_list=get_course_groups();
  431. echo "\n<table id=\"recipient_list\" style=\"display: none;\">\n";
  432. echo "\t<tr>\n";
  433. // the form containing all the groups and all the users of the course
  434. echo "\t\t<td>\n";
  435. construct_not_selected_select_form($group_list,$user_list,$to_already_selected);
  436. echo "\t\t</td>\n";
  437. // the buttons for adding or removing groups/users
  438. echo "\n\t\t<td valign=\"middle\">\n";
  439. echo "\t\t<input type=\"button\" ",
  440. "onclick=\"move(this.form.elements[2],this.form.elements[5])\" ",
  441. "value=\" &gt;&gt; \" />",
  442. "\n\t\t<p>&nbsp;</p>",
  443. "\n\t\t<input type=\"button\" ",
  444. "onclick=\"move(this.form.elements[5],this.form.elements[2])\" ",
  445. "value=\" &lt;&lt; \" />";
  446. echo "\t\t</td>\n";
  447. echo "\n\t\t<td>\n";
  448. construct_selected_select_form($group_list,$user_list,$to_already_selected);
  449. echo "\t\t</td>\n";
  450. echo "\t</tr>\n";
  451. echo "</table>";
  452. }
  453. /**
  454. * this function shows the form with the user that were not selected
  455. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  456. * @return html code
  457. */
  458. function construct_not_selected_select_form($group_list=null, $user_list=null,$to_already_selected)
  459. {
  460. echo "\t\t<select name=\"not_selected_form[]\" size=\"5\" multiple=\"multiple\" style=\"width:200px\">\n";
  461. // adding the groups to the select form
  462. if (is_array($group_list))
  463. {
  464. foreach($group_list as $this_group)
  465. {
  466. //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]);
  467. 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
  468. {
  469. echo "\t\t<option value=\"GROUP:".$this_group['id']."\">",
  470. "G: ",$this_group['name']," &ndash; " . $this_group['userNb'] . " " . get_lang('Users') .
  471. "</option>\n";
  472. }
  473. }
  474. // a divider
  475. echo "\t\t<option value=\"\">---------------------------------------------------------</option>\n";
  476. }
  477. // adding the individual users to the select form
  478. foreach($user_list as $this_user)
  479. {
  480. 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
  481. {
  482. echo "\t\t<option value=\"USER:",$this_user['uid'],"\">",
  483. "",$this_user['lastName']," ",$this_user['firstName'],
  484. "</option>\n";
  485. }
  486. }
  487. echo "\t\t</select>\n";
  488. }
  489. /**
  490. * this function shows the form with the user that were selected
  491. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  492. * @return html code
  493. */
  494. function construct_selected_select_form($group_list=null, $user_list=null,$to_already_selected)
  495. {
  496. // we separate the $to_already_selected array (containing groups AND users into
  497. // two separate arrays
  498. if (is_array($groupuser))
  499. {
  500. $groupuser=separate_users_groups($to_already_selected);
  501. }
  502. $groups_to_already_selected=$groupuser['groups'];
  503. $users_to_already_selected=$groupuser['users'];
  504. // we load all the groups and all the users into a reference array that we use to search the name of the group / user
  505. $ref_array_groups=get_course_groups();
  506. $ref_array_users=get_course_users();
  507. // we construct the form of the already selected groups / users
  508. echo "\t\t<select name=\"selectedform[]\" size=\"5\" multiple=\"multiple\" style=\"width:200px\">";
  509. foreach($to_already_selected as $groupuser)
  510. {
  511. list($type,$id)=explode(":",$groupuser);
  512. if ($type=="GROUP")
  513. {
  514. echo "\t\t<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>";
  515. }
  516. else
  517. {
  518. echo "\t\t<option value=\"".$groupuser."\">".$ref_array_users[$id]['lastName']." ".$ref_array_users[$id]['firstName']."</option>";
  519. }
  520. }
  521. echo "</select>\n";
  522. }
  523. /**
  524. * This function stores the Agenda Item in the table calendar_event and updates the item_property table also
  525. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  526. * @return integer the id of the last added agenda item
  527. */
  528. function store_new_agenda_item()
  529. {
  530. global $TABLEAGENDA;
  531. global $_user;
  532. // some filtering of the input data
  533. $title=strip_tags(trim($_POST['title'])); // no html allowed in the title
  534. $content=trim($_POST['content']);
  535. $start_date=(int)$_POST['fyear']."-".(int)$_POST['fmonth']."-".(int)$_POST['fday']." ".(int)$_POST['fhour'].":".(int)$_POST['fminute'].":00";
  536. $end_date=(int)$_POST['end_fyear']."-".(int)$_POST['end_fmonth']."-".(int)$_POST['end_fday']." ".(int)$_POST['end_fhour'].":".(int)$_POST['end_fminute'].":00";
  537. // store in the table calendar_event
  538. $sql = "INSERT INTO ".$TABLEAGENDA."
  539. (title,content, start_date, end_date)
  540. VALUES
  541. ('".$title."','".$content."', '".$start_date."','".$end_date."')";
  542. $result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  543. $last_id=mysql_insert_id();
  544. // store in last_tooledit (first the groups, then the users
  545. $to=$_POST['selectedform'];
  546. if ((!is_null($to))or (!empty($_SESSION['toolgroup']))) // !is_null($to): when no user is selected we send it to everyone
  547. {
  548. $send_to=separate_users_groups($to);
  549. // storing the selected groups
  550. if (is_array($send_to['groups']))
  551. {
  552. foreach ($send_to['groups'] as $group)
  553. {
  554. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], $group,'',$start_visible, $end_visible);
  555. }
  556. }
  557. // storing the selected users
  558. if (is_array($send_to['users']))
  559. {
  560. foreach ($send_to['users'] as $user)
  561. {
  562. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'],'',$user, $start_visible,$end_visible);
  563. }
  564. }
  565. }
  566. else // the message is sent to everyone, so we set the group to 0
  567. {
  568. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $last_id,"AgendaAdded", $_user['user_id'], '','',$start_visible,$end_visible);
  569. }
  570. // storing the resources
  571. store_resources($_SESSION['source_type'],$last_id);
  572. return $last_id;
  573. }
  574. /**
  575. * Stores the given agenda item as an announcement (unlinked copy)
  576. * @param integer Agenda item's ID
  577. * @return integer New announcement item's ID
  578. */
  579. function store_agenda_item_as_announcement($item_id){
  580. $table_agenda = Database::get_course_table(TABLE_AGENDA);
  581. $table_ann = Database::get_course_table(TABLE_ANNOUNCEMENT);
  582. //check params
  583. if(empty($item_id) or $item_id != strval(intval($item_id))){return -1;}
  584. //get the agenda item
  585. $sql = "SELECT * FROM $table_agenda WHERE id = '".$item_id."'";
  586. $res = api_sql_query($sql,__FILE__,__LINE__);
  587. if(Database::num_rows($res)>0){
  588. $row = Database::fetch_array($res);
  589. //we have the agenda event, copy it
  590. //get the maximum value for display order in announcement table
  591. $sql_max = "SELECT MAX(display_order) FROM $table_ann";
  592. $res_max = api_sql_query($sql_max,__FILE__,__LINE__);
  593. $row_max = Database::fetch_array($res_max);
  594. $max = $row_max[0]+1;
  595. //build the announcement text
  596. $content = $row['start_date']." - ".$row['end_date']."\n\n".$row['content'];
  597. //insert announcement
  598. $sql_ins = "INSERT INTO $table_ann (title,content,end_date,display_order) " .
  599. "VALUES ('".$row['title']."','$content','".$row['end_date']."','$max')";
  600. $res_ins = api_sql_query($sql_ins,__FILE__,__LINE__);
  601. if($res > 0)
  602. {
  603. $ann_id = Database::get_last_insert_id();
  604. //Now also get the list of item_properties rows for this agenda_item (calendar_event)
  605. //and copy them into announcement item_properties
  606. $table_props = Database::get_course_table(TABLE_ITEM_PROPERTY);
  607. $sql_props = "SELECT * FROM $table_props WHERE tool = 'calendar_event' AND ref='$item_id'";
  608. $res_props = api_sql_query($sql_props,__FILE__,__LINE__);
  609. if(Database::num_rows($res_props)>0)
  610. {
  611. while($row_props = Database::fetch_array($res_props))
  612. {
  613. //insert into announcement item_property
  614. $time = date("Y-m-d H:i:s", time());
  615. $sql_ins_props = "INSERT INTO $table_props " .
  616. "(tool, insert_user_id, insert_date, " .
  617. "lastedit_date, ref, lastedit_type," .
  618. "lastedit_user_id, to_group_id, to_user_id, " .
  619. "visibility, start_visible, end_visible)" .
  620. " VALUES " .
  621. "('announcement','".$row_props['insert_user_id']."','".$time."'," .
  622. "'$time','$ann_id','AnnouncementAdded'," .
  623. "'".$row_props['last_edit_user_id']."','".$row_props['to_group_id']."','".$row_props['to_user_id']."'," .
  624. "'".$row_props['visibility']."','".$row_props['start_visible']."','".$row_props['end_visible']."')";
  625. $res_ins_props = api_sql_query($sql_ins_props,__FILE__,__LINE__);
  626. if($res_ins_props <= 0){
  627. error_log('SQL Error in '.__FILE__.' at line '.__LINE__.': '.$sql_ins_props);
  628. }else{
  629. //copy was a success
  630. return $ann_id;
  631. }
  632. }
  633. }
  634. }else{
  635. return -1;
  636. }
  637. }
  638. return -1;
  639. }
  640. /**
  641. * This function separates the users from the groups
  642. * users have a value USER:XXX (with XXX the dokeos id
  643. * groups have a value GROUP:YYY (with YYY the group id)
  644. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  645. * @return array
  646. */
  647. function separate_users_groups($to)
  648. {
  649. foreach($to as $to_item)
  650. {
  651. list($type, $id) = explode(':', $to_item);
  652. switch($type)
  653. {
  654. case 'GROUP':
  655. $grouplist[] =$id;
  656. break;
  657. case 'USER':
  658. $userlist[] =$id;
  659. break;
  660. }
  661. }
  662. $send_to['groups']=$grouplist;
  663. $send_to['users']=$userlist;
  664. return $send_to;
  665. }
  666. /**
  667. * returns all the users and all the groups a specific Agenda item has been sent to
  668. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  669. * @return array
  670. */
  671. function sent_to($tool, $id)
  672. {
  673. global $_course;
  674. $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
  675. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".$tool."' AND ref='".$id."'";
  676. $result=api_sql_query($sql,__FILE__,__LINE__);
  677. while ($row=mysql_fetch_array($result))
  678. {
  679. // if to_group_id is null then it is sent to a specific user
  680. // if to_group_id = 0 then it is sent to everybody
  681. if (!is_null($row['to_group_id']) )
  682. {
  683. $sent_to_group[]=$row['to_group_id'];
  684. //echo $row['to_group_id'];
  685. }
  686. // if to_user_id <> 0 then it is sent to a specific user
  687. if ($row['to_user_id']<>0)
  688. {
  689. $sent_to_user[]=$row['to_user_id'];
  690. }
  691. }
  692. if (isset($sent_to_group))
  693. {
  694. $sent_to['groups']=$sent_to_group;
  695. }
  696. if (isset($sent_to_user))
  697. {
  698. $sent_to['users']=$sent_to_user;
  699. }
  700. return $sent_to;
  701. }
  702. /**
  703. * constructs the form to display all the groups and users the message has been sent to
  704. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  705. * @param array $sent_to_array: a 2 dimensional array containing the groups and the users
  706. * the first level is a distinction between groups and users: $sent_to_array['groups'] and $sent_to_array['users']
  707. * $sent_to_array['groups'] (resp. $sent_to_array['users']) is also an array containing all the id's of the
  708. * groups (resp. users) who have received this message.
  709. * @return html
  710. */
  711. function sent_to_form($sent_to_array)
  712. {
  713. // we find all the names of the groups
  714. $group_names=get_course_groups();
  715. count($sent_to_array);
  716. // we count the number of users and the number of groups
  717. if (isset($sent_to_array['users']))
  718. {
  719. $number_users=count($sent_to_array['users']);
  720. }
  721. else
  722. {
  723. $number_users=0;
  724. }
  725. if (isset($sent_to_array['groups']))
  726. {
  727. $number_groups=count($sent_to_array['groups']);
  728. }
  729. else
  730. {
  731. $number_groups=0;
  732. }
  733. $total_numbers=$number_users+$number_groups;
  734. // starting the form if there is more than one user/group
  735. if ($total_numbers >1)
  736. {
  737. $output="<select name=\"sent to\">\n";
  738. $output.="<option>".get_lang("SentTo")."</option>";
  739. // outputting the name of the groups
  740. if (is_array($sent_to_array['groups']))
  741. {
  742. foreach ($sent_to_array['groups'] as $group_id)
  743. {
  744. $output.="\t<option value=\"\">G: ".$group_names[$group_id]['name']."</option>\n";
  745. }
  746. }
  747. if (isset($sent_to_array['users']))
  748. {
  749. if (is_array($sent_to_array['users']))
  750. {
  751. foreach ($sent_to_array['users'] as $user_id)
  752. {
  753. $user_info=api_get_user_info($user_id);
  754. $output.="\t<option value=\"\">".$user_info['firstName']." ".$user_info['lastName']."</option>\n";
  755. }
  756. }
  757. }
  758. // ending the form
  759. $output.="</select>\n";
  760. }
  761. else // there is only one user/group
  762. {
  763. if (is_array($sent_to_array['users']))
  764. {
  765. $user_info=api_get_user_info($sent_to_array['users'][0]);
  766. echo $user_info['firstName']." ".$user_info['lastName'];
  767. }
  768. if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0)
  769. {
  770. $group_id=$sent_to_array['groups'][0];
  771. echo $group_names[$group_id]['name'];
  772. }
  773. if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0)
  774. {
  775. echo get_lang("Everybody");
  776. }
  777. //.$sent_to_array['groups'][0];
  778. }
  779. echo $output;
  780. }
  781. /**
  782. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  783. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  784. */
  785. function show_group_filter_form()
  786. {
  787. $group_list=get_course_groups();
  788. echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  789. echo "<option value=\"agenda.php?group=none\">show all groups</option>";
  790. foreach($group_list as $this_group)
  791. {
  792. // echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
  793. echo "<option value=\"agenda.php?group=".$this_group['id']."\" ";
  794. echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
  795. echo ">".$this_group['name']."</option>";
  796. }
  797. echo "</select>";
  798. }
  799. /**
  800. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  801. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  802. */
  803. function show_user_filter_form()
  804. {
  805. $user_list=get_course_users();
  806. echo "<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  807. echo "<option value=\"agenda.php?user=none\">show all users</option>";
  808. foreach($user_list as $this_user)
  809. {
  810. // echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  811. echo "<option value=\"agenda.php?user=".$this_user['uid']."\" ";
  812. echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
  813. echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  814. }
  815. echo "</select>";
  816. }
  817. /**
  818. * This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
  819. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  820. */
  821. function show_user_group_filter_form()
  822. {
  823. echo "\n<select name=\"select\" onchange=\"MM_jumpMenu('parent',this,0)\">";
  824. echo "\n\t<option value=\"agenda.php?user=none\">".get_lang("ShowAll")."</option>";
  825. // Groups
  826. echo "\n\t<optgroup label=\"".get_lang("Groups")."\">";
  827. $group_list=get_course_groups();
  828. foreach($group_list as $this_group)
  829. {
  830. // echo "<option value=\"agenda.php?isStudentView=true&amp;group=".$this_group['id']."\">".$this_group['name']."</option>";
  831. echo "\n\t\t<option value=\"agenda.php?group=".$this_group['id']."\" ";
  832. echo ($this_group['id']==$_SESSION['group'])? " selected":"" ;
  833. echo ">".$this_group['name']."</option>";
  834. }
  835. echo "\n\t</optgroup>";
  836. // Users
  837. echo "\n\t<optgroup label=\"".get_lang("Users")."\">";
  838. $user_list=get_course_users();
  839. foreach($user_list as $this_user)
  840. {
  841. // echo "<option value=\"agenda.php?isStudentView=true&amp;user=".$this_user['uid']."\">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  842. echo "\n\t\t<option value=\"agenda.php?user=".$this_user['uid']."\" ";
  843. echo ($this_user['uid']==$_SESSION['user'])? " selected":"" ;
  844. echo ">".$this_user['lastName']." ".$this_user['firstName']."</option>";
  845. }
  846. echo "\n\t</optgroup>";
  847. echo "</select>";
  848. }
  849. /**
  850. * This tools loads all the users and all the groups who have received a specific item (in this case an agenda item)
  851. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  852. */
  853. function load_edit_users($tool, $id)
  854. {
  855. global $_course;
  856. $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
  857. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'";
  858. $result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  859. while ($row=mysql_fetch_array($result))
  860. {
  861. $to_group=$row['to_group_id'];
  862. switch ($to_group)
  863. {
  864. // it was send to one specific user
  865. case null:
  866. $to[]="USER:".$row['to_user_id'];
  867. break;
  868. // it was sent to everyone
  869. case 0:
  870. return "everyone";
  871. exit;
  872. break;
  873. default:
  874. $to[]="GROUP:".$row['to_group_id'];
  875. }
  876. }
  877. return $to;
  878. }
  879. /**
  880. * This functions swithes the visibility a course resource using the visible field in 'last_tooledit' values: 0 = invisible
  881. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  882. */
  883. function change_visibility($tool,$id)
  884. {
  885. global $_course;
  886. $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
  887. $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='".TOOL_CALENDAR_EVENT."' AND ref='$id'";
  888. $result=api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  889. $row=mysql_fetch_array($result);
  890. if ($row['visibility']=='1')
  891. {
  892. $sql_visibility="UPDATE $TABLE_ITEM_PROPERTY SET visibility='0' WHERE tool='$tool' AND ref='$id'";
  893. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"invisible");
  894. }
  895. else
  896. {
  897. $sql_visibility="UPDATE $TABLE_ITEM_PROPERTY SET visibility='1' WHERE tool='$tool' AND ref='$id'";
  898. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"visible");
  899. }
  900. }
  901. /**
  902. * The links that allows the course administrator to add a new agenda item, to filter on groups or users
  903. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  904. */
  905. function display_courseadmin_links()
  906. {
  907. echo "<li><a href='".$_SERVER['PHP_SELF']."?action=add&amp;origin=".$_GET['origin']."'><img src=\"../img/view_more_stats.gif\" align=\"absmiddle\" border=\"0\" /> ".get_lang("AgendaAdd")."</a><br /></li>";
  908. if (empty ($_SESSION['toolgroup']))
  909. {
  910. echo "<li>".get_lang(UserGroupFilter)."<br/>";
  911. echo "<form name=\"filter\">";
  912. show_user_group_filter_form();
  913. echo "</form>";
  914. }
  915. echo "</li>";
  916. }
  917. /**
  918. * The links that allows the student AND course administrator to show all agenda items and sort up/down
  919. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  920. */
  921. function display_student_links()
  922. {
  923. global $show;
  924. if ($_SESSION['sort'] == 'DESC')
  925. {
  926. 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>";
  927. }
  928. else
  929. {
  930. 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>";
  931. }
  932. // showing the link to show all items or only those of the current month
  933. if ($_SESSION['show']=="showcurrent")
  934. {
  935. 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>";
  936. }
  937. else
  938. {
  939. 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>";
  940. }
  941. }
  942. /**
  943. * get all the information of the agenda_item from the database
  944. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  945. * @param integer the id of the agenda item we are getting all the information of
  946. * @return an associative array that contains all the information of the agenda item. The keys are the database fields
  947. */
  948. function get_agenda_item($id)
  949. {
  950. global $TABLEAGENDA;
  951. $id=(int)addslashes($_GET['id']);
  952. $sql = "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
  953. $result = api_sql_query($sql,__FILE__,__LINE__);
  954. $entry_to_edit = mysql_fetch_array($result);
  955. $item['title'] = $entry_to_edit["title"];
  956. $item['content'] = $entry_to_edit["content"];
  957. $item['start_date'] = $entry_to_edit["start_date"];
  958. $item['end_date'] = $entry_to_edit["end_date"];
  959. $item['to']=load_edit_users(TOOL_CALENDAR_EVENT, $id);
  960. // if the item has been sent to everybody then we show the compact to form
  961. if ($item['to']=="everyone")
  962. {
  963. $_SESSION['allow_individual_calendar']="hide";
  964. }
  965. else
  966. {
  967. $_SESSION['allow_individual_calendar']="show";
  968. }
  969. //echo "<br />IN get_agenda_item".$_SESSION['allow_individual_calendar'];
  970. return $item;
  971. }
  972. /**
  973. * This is the function that updates an agenda item. It does 3 things
  974. * 1. storethe start_date, end_date, title and message in the calendar_event table
  975. * 2. store the groups/users who this message is meant for in the item_property table
  976. * 3. modify the attachments (if needed)
  977. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  978. */
  979. function store_edited_agenda_item()
  980. {
  981. global $_user;
  982. // database definitions
  983. $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
  984. // STEP 1: editing the calendar_event table
  985. // 1.a. some filtering of the input data
  986. $id=(int)$_POST['id'];
  987. $title=strip_tags(trim($_POST['title'])); // no html allowed in the title
  988. $content=trim($_POST['content']);
  989. $start_date=(int)$_POST['fyear']."-".(int)$_POST['fmonth']."-".(int)$_POST['fday']." ".(int)$_POST['fhour'].":".(int)$_POST['fminute'].":00";
  990. $end_date=(int)$_POST['end_fyear']."-".(int)$_POST['end_fmonth']."-".(int)$_POST['end_fday']." ".(int)$_POST['end_fhour'].":".(int)$_POST['end_fminute'].":00";
  991. $to=$_POST['selectedform'];
  992. // 1.b. the actual saving in calendar_event table
  993. $edit_result=save_edit_agenda_item($id,$title,$content,$start_date,$end_date);
  994. // step 2: editing the item_propery table (=delete all and add the new destination users/groups)
  995. if ($edit_result=true)
  996. {
  997. // 2.a. delete everything for the users
  998. $sql_delete="DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
  999. $result = api_sql_query($sql_delete,__FILE__,__LINE__) or die (mysql_error());
  1000. // 2.b. storing the new users/groups
  1001. if (!is_null($to)) // !is_null($to): when no user is selected we send it to everyone
  1002. {
  1003. $send_to=separate_users_groups($to);
  1004. // storing the selected groups
  1005. if (is_array($send_to['groups']))
  1006. {
  1007. foreach ($send_to['groups'] as $group)
  1008. {
  1009. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'], $group,'',$start_visible, $end_visible);
  1010. }
  1011. }
  1012. // storing the selected users
  1013. if (is_array($send_to['users']))
  1014. {
  1015. foreach ($send_to['users'] as $user)
  1016. {
  1017. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'],'',$user, $start_visible,$end_visible);
  1018. }
  1019. }
  1020. }
  1021. else // the message is sent to everyone, so we set the group to 0
  1022. {
  1023. api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id,"AgendaModified", $_user['user_id'], '','',$start_visible,$end_visible);
  1024. }
  1025. } //if ($edit_result=true)
  1026. // step 3: update the attachments (=delete all and add those in the session
  1027. update_added_resources("Agenda", $id);
  1028. // return the message;
  1029. Display::display_normal_message(get_lang("EditSuccess"));
  1030. }
  1031. /**
  1032. * This function stores the Agenda Item in the table calendar_event and updates the item_property table also (after an edit)
  1033. * @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1034. */
  1035. function save_edit_agenda_item($id,$title,$content,$start_date,$end_date)
  1036. {
  1037. $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
  1038. // store the modifications in the table calendar_event
  1039. $sql = "UPDATE ".$TABLEAGENDA."
  1040. SET title='".$title."',
  1041. content='".$content."',
  1042. start_date='".$start_date."',
  1043. end_date='".$end_date."'
  1044. WHERE id='".$id."'";
  1045. $result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  1046. return true;
  1047. }
  1048. /**
  1049. * This is the function that deletes an agenda item.
  1050. * The agenda item is no longer fycically deleted but the visibility in the item_property table is set to 2
  1051. * which means that it is invisible for the student AND course admin. Only the platform administrator can see it.
  1052. * This will in a later stage allow the platform administrator to recover resources that were mistakenly deleted
  1053. * by the course administrator
  1054. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1055. * @param integer the id of the agenda item wa are deleting
  1056. */
  1057. function delete_agenda_item($id)
  1058. {
  1059. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1060. {
  1061. if (isset($_GET['id'])&&$_GET['id']&&isset($_GET['action'])&&$_GET['action']=="delete")
  1062. {
  1063. //$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'";
  1064. //$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'";
  1065. //$result = api_sql_query($sql,__FILE__,__LINE__) or die (mysql_error());
  1066. $id=(int)addslashes($_GET['id']);
  1067. api_item_property_update($_course,TOOL_CALENDAR_EVENT,$id,"delete");
  1068. // delete the resources that were added to this agenda item
  1069. // 2DO: as we no longer fysically delete the agenda item (to make it possible to 'restore'
  1070. // deleted items, we should not delete the added resources either.
  1071. // 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)
  1072. //resetting the $id;
  1073. $id=null;
  1074. // displaying the result message in the yellow box
  1075. Display::display_normal_message(get_lang("AgendaDeleteSuccess"));
  1076. } // if (isset($id)&&$id&&isset($action)&&$action=="delete")
  1077. } // if ($is_allowedToEdit)
  1078. }
  1079. /**
  1080. * Makes an agenda item visible or invisible for a student
  1081. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1082. * @param integer id the id of the agenda item we are changing the visibility of
  1083. */
  1084. function showhide_agenda_item($id)
  1085. {
  1086. /*==================================================
  1087. SHOW / HIDE A CALENDAR ITEM
  1088. ==================================================*/
  1089. // and $_GET['isStudentView']<>"false" is added to prevent that the visibility is changed after you do the following:
  1090. // change visibility -> studentview -> course manager view
  1091. if ((is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda')) and $_GET['isStudentView']<>"false")
  1092. {
  1093. if (isset($_GET['id'])&&$_GET['id']&&isset($_GET['action'])&&$_GET['action']=="showhide")
  1094. {
  1095. $id=(int)addslashes($_GET['id']);
  1096. change_visibility($_GLOBAL['nameTools'],$id);
  1097. Display::display_normal_message(get_lang("VisibilityChanged"));
  1098. }
  1099. }
  1100. }
  1101. /**
  1102. * Displays all the agenda items
  1103. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1104. */
  1105. function display_agenda_items()
  1106. {
  1107. global $TABLEAGENDA;
  1108. global $TABLE_ITEM_PROPERTY;
  1109. global $select_month, $select_year;
  1110. global $DaysShort, $DaysLong, $MonthsLong;
  1111. global $is_courseAdmin;
  1112. global $dateFormatLong, $timeNoSecFormat;
  1113. global $_user;
  1114. // getting the group memberships
  1115. $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_user['user_id']);
  1116. // getting the name of the groups
  1117. $group_names=get_course_groups();
  1118. /*--------------------------------------------------
  1119. CONSTRUCT THE SQL STATEMENT
  1120. --------------------------------------------------*/
  1121. // this is to make a difference between showing everything (all months) or only the current month)
  1122. // $show_all_current is a part of the sql statement
  1123. if ($_SESSION['show']!=="showall")
  1124. {
  1125. $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year";
  1126. }
  1127. else
  1128. {
  1129. $show_all_current="";
  1130. }
  1131. // 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
  1132. $user_id=$_user['user_id'];
  1133. if ($_SESSION['user']!==null)
  1134. {
  1135. $user_id=$_SESSION['user'];
  1136. }
  1137. if ($_SESSION['group']!==null)
  1138. {
  1139. $group_id=$_SESSION['group'];
  1140. }
  1141. if ($_SESSION['toolgroup']!==null)
  1142. {
  1143. $group_id=$_SESSION['toolgroup'];
  1144. }
  1145. //echo "user:".$_SESSION['user']."group: ".$_SESSION['group'];
  1146. // A. you are a course admin
  1147. //if ($is_courseAdmin)
  1148. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1149. {
  1150. // A.1. you are a course admin with a USER filter
  1151. // => see only the messages of this specific user + the messages of the group (s)he is member of.
  1152. if ($_SESSION['user']!==null)
  1153. {
  1154. $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_SESSION['user']);
  1155. if (is_array($group_memberships))
  1156. {
  1157. $sql="SELECT
  1158. agenda.*, toolitemproperties.*
  1159. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1160. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1161. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1162. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  1163. AND `toolitemproperties`.`visibility`='1'
  1164. ORDER BY start_date ".$_SESSION['sort'];
  1165. }
  1166. else
  1167. {
  1168. $sql="SELECT
  1169. agenda.*, toolitemproperties.*
  1170. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1171. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1172. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1173. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id`='0')
  1174. AND `toolitemproperties`.`visibility`='1'
  1175. ORDER BY start_date ".$_SESSION['sort'];
  1176. }
  1177. }
  1178. // A.2. you are a course admin with a GROUP filter
  1179. // => see only the messages of this specific group
  1180. elseif ($_SESSION['group']!==null)
  1181. {
  1182. $sql="SELECT
  1183. agenda.*, toolitemproperties.*
  1184. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1185. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1186. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1187. AND ( `toolitemproperties`.`to_group_id`=$group_id OR `toolitemproperties`.`to_group_id`='0')
  1188. AND `toolitemproperties`.`visibility`='1'
  1189. GROUP BY `toolitemproperties`.`ref`
  1190. ORDER BY start_date ".$_SESSION['sort'];
  1191. }
  1192. // A.3 you are a course admin without any group or user filter
  1193. else
  1194. {
  1195. // A.3.a you are a course admin without user or group filter but WITH studentview
  1196. // => see all the messages of all the users and groups without editing possibilities
  1197. if ($isStudentView=="true")
  1198. {
  1199. $sql="SELECT
  1200. agenda.*, toolitemproperties.*
  1201. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1202. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1203. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1204. AND `toolitemproperties`.`visibility`='1'
  1205. GROUP BY `toolitemproperties`.`ref`
  1206. ORDER BY start_date ".$_SESSION['sort'];
  1207. }
  1208. // A.3.b you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
  1209. // => see all the messages of all the users and groups with editing possibilities
  1210. else
  1211. {
  1212. $sql="SELECT
  1213. agenda.*, toolitemproperties.*
  1214. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1215. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1216. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1217. AND ( `toolitemproperties`.`visibility`='0' or `toolitemproperties`.`visibility`='1')
  1218. GROUP BY `toolitemproperties`.`ref`
  1219. ORDER BY start_date ".$_SESSION['sort'];
  1220. }
  1221. }
  1222. } //if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1223. // B. you are a student
  1224. else
  1225. {
  1226. if (is_array($group_memberships))
  1227. {
  1228. $sql="SELECT
  1229. agenda.*, toolitemproperties.*
  1230. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1231. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1232. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1233. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  1234. AND `toolitemproperties`.`visibility`='1'
  1235. ORDER BY start_date ".$_SESSION['sort'];
  1236. }
  1237. else
  1238. {
  1239. if ($_user['user_id'])
  1240. {
  1241. $sql="SELECT
  1242. agenda.*, toolitemproperties.*
  1243. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1244. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1245. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1246. AND ( `toolitemproperties`.`to_user_id`=$user_id OR `toolitemproperties`.`to_group_id`='0')
  1247. AND `toolitemproperties`.`visibility`='1'
  1248. ORDER BY start_date ".$_SESSION['sort'];
  1249. }
  1250. else
  1251. {
  1252. $sql="SELECT
  1253. agenda.*, toolitemproperties.*
  1254. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1255. WHERE `agenda`.`id` = `toolitemproperties`.`ref` ".$show_all_current."
  1256. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1257. AND `toolitemproperties`.`to_group_id`='0'
  1258. AND `toolitemproperties`.`visibility`='1'
  1259. ORDER BY start_date ".$_SESSION['sort'];
  1260. }
  1261. }
  1262. } // you are a student
  1263. //echo "<pre>".$sql."</pre>";
  1264. $result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  1265. $number_items=mysql_num_rows($result);
  1266. /*--------------------------------------------------
  1267. DISPLAY: NO ITEMS
  1268. --------------------------------------------------*/
  1269. if ($number_items==0)
  1270. {
  1271. echo "<table id=\"agenda_list\" ><tr><td>".get_lang("NoAgendaItems")."</td></tr></table>";
  1272. }
  1273. /*--------------------------------------------------
  1274. DISPLAY: THE ITEMS
  1275. --------------------------------------------------*/
  1276. $month_bar="";
  1277. $event_list="";
  1278. $counter=0;
  1279. while ($myrow=mysql_fetch_array($result))
  1280. {
  1281. echo "<table class=\"data_table\">\n";
  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<th>\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\" align=\"absbottom\" 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<th>".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 "<tr class='row_odd'>";
  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 "<tr class='row_even'>";
  1363. echo "<td colspan='2'>";
  1364. echo '<a href="#" onclick="javascript:win_print=window.open(\'print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;"><img src="../img/print.gif" border="0" title="'.htmlentities(get_lang('Print')).'" /></a>&nbsp;';
  1365. echo $content;
  1366. echo "</td></tr>";
  1367. /*--------------------------------------------------
  1368. display: the added resources
  1369. --------------------------------------------------*/
  1370. if (check_added_resources("Agenda", $myrow["id"]))
  1371. {
  1372. echo "<tr><td colspan='2'>";
  1373. echo "<i>".get_lang("AddedResources")."</i><br/>";
  1374. if ($myrow['visibility']==0)
  1375. {
  1376. $addedresource_style="invisible";
  1377. }
  1378. display_added_resources("Agenda", $myrow["id"], $addedresource_style);
  1379. echo "</td></tr>";
  1380. }
  1381. /*--------------------------------------------------
  1382. display: edit delete button (course admin only)
  1383. --------------------------------------------------*/
  1384. $event_list.=$myrow['id'].',';
  1385. echo "<tr class='row_odd'><td>";
  1386. if (is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_agenda'))
  1387. {
  1388. // edit
  1389. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=edit&id=".$myrow['id']."\">",
  1390. "<img src=\"../img/edit.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("ModifyCalendarItem")."\" /></a>",
  1391. "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=delete&id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."')) return false;\">",
  1392. "<img src=\"../img/delete.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("Delete")."\"/></a>";
  1393. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&action=announce&id=".$myrow['id']."\">".
  1394. "<img src=\"../img/announce_add.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("AddAnnouncement")."\"/></a>";
  1395. if ($myrow['visibility']==1)
  1396. {
  1397. $image_visibility="visible";
  1398. }
  1399. else
  1400. {
  1401. $image_visibility="invisible";
  1402. }
  1403. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=showhide&amp;id=".$myrow['id']."\">",
  1404. "<img src=\"../img/".$image_visibility.".gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang("Visible")."\" /></a>";
  1405. }
  1406. echo "</td>";
  1407. $counter++;
  1408. /*--------------------------------------------------
  1409. display: jump-to-top icon
  1410. --------------------------------------------------*/
  1411. echo "<td><a href=\"#top\"><img src=\"../img/top.gif\" border=\"0\" alt=\"to top\" align=\"right\" /></a></td></tr>";
  1412. echo "</table><br><br>";
  1413. } // end while ($myrow=mysql_fetch_array($result))
  1414. if(!empty($event_list))
  1415. {
  1416. $event_list=substr($event_list,0,-1);
  1417. }
  1418. else
  1419. {
  1420. $event_list='0';
  1421. }
  1422. echo "<form name=\"event_list_form\"><input type=\"hidden\" name=\"event_list\" value=\"$event_list\" /></form>";
  1423. // closing the layout table
  1424. echo "</td>",
  1425. "</tr>",
  1426. "</table>";
  1427. }
  1428. /**
  1429. * Displays only 1 agenda item. This is used when an agenda item is added to the learning path.
  1430. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1431. */
  1432. function display_one_agenda_item($agenda_id)
  1433. {
  1434. global $TABLEAGENDA;
  1435. global $TABLE_ITEM_PROPERTY;
  1436. global $select_month, $select_year;
  1437. global $DaysShort, $DaysLong, $MonthsLong;
  1438. global $is_courseAdmin;
  1439. global $dateFormatLong, $timeNoSecFormat;
  1440. global $_user;
  1441. //echo "displaying agenda items";
  1442. // getting the name of the groups
  1443. $group_names=get_course_groups();
  1444. /*--------------------------------------------------
  1445. CONSTRUCT THE SQL STATEMENT
  1446. --------------------------------------------------*/
  1447. $sql="SELECT agenda.*, toolitemproperties.*
  1448. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  1449. WHERE `agenda`.`id` = `toolitemproperties`.`ref`
  1450. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  1451. AND `toolitemproperties`.`visibility`='1'
  1452. AND `agenda`.`id`='$agenda_id'";
  1453. $result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
  1454. $number_items=mysql_num_rows($result);
  1455. $myrow=mysql_fetch_array($result); // there should be only one item so no need for a while loop
  1456. /*--------------------------------------------------
  1457. DISPLAY: NO ITEMS
  1458. --------------------------------------------------*/
  1459. if ($number_items==0)
  1460. {
  1461. echo "<table id=\"agenda_list\" ><tr><td>".get_lang("NoAgendaItems")."</td></tr></table>";
  1462. }
  1463. /*--------------------------------------------------
  1464. DISPLAY: THE ITEMS
  1465. --------------------------------------------------*/
  1466. echo "<table id=\"agenda_list\">\n";
  1467. /*--------------------------------------------------
  1468. DISPLAY : the icon, title, destinees of the item
  1469. --------------------------------------------------*/
  1470. echo "\t<tr>\n";
  1471. // highlight: if a date in the small calendar is clicked we highlight the relevant items
  1472. $db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
  1473. if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
  1474. {
  1475. if ($myrow['visibility']=='0')
  1476. {
  1477. $style="data_hidden";
  1478. $stylenotbold="datanotbold_hidden";
  1479. $text_style="text_hidden";
  1480. }
  1481. else
  1482. {
  1483. $style="data";
  1484. $stylenotbold="datanotbold";
  1485. $text_style="text";
  1486. }
  1487. }
  1488. else
  1489. {
  1490. $style="datanow";
  1491. $stylenotbold="datanotboldnow";
  1492. $text_style="textnow";
  1493. }
  1494. echo "\t\t<td class=\"".$style."\">\n";
  1495. // adding an internal anchor
  1496. echo "\t\t\t<a name=\"".(int)date("d",strtotime($myrow["start_date"]))."\"></a>";
  1497. // the icons. If the message is sent to one or more specific users/groups
  1498. // we add the groups icon
  1499. // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon
  1500. echo "<img src=\"../img/agenda.gif\" border=\"0\" />";
  1501. if ($myrow['to_group_id']!=='0')
  1502. {
  1503. echo "<img src=\"../img/group.gif\" border=\"0\" />";
  1504. }
  1505. echo " ".$myrow['title']."\n";
  1506. echo "\t\t</td>\n";
  1507. // the message has been sent to
  1508. echo "\t\t<td class=\"".$stylenotbold."\">".get_lang("SentTo").": ";
  1509. $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
  1510. $sent_to_form=sent_to_form($sent_to);
  1511. echo $sent_to_form;
  1512. echo "</td>\n\t</tr>\n";
  1513. /*--------------------------------------------------
  1514. DISPLAY: the title
  1515. --------------------------------------------------*/
  1516. echo "\t<tr class=\"".$stylenotbold."\">\n";
  1517. echo "\t\t<td>".get_lang("StartTime").": ";
  1518. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
  1519. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
  1520. echo "</td>\n";
  1521. echo "\t\t<td>".get_lang("EndTime").": ";
  1522. echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
  1523. echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
  1524. echo "</td>\n";
  1525. echo "\n\t</tr>\n";
  1526. /*--------------------------------------------------
  1527. DISPLAY: the content
  1528. --------------------------------------------------*/
  1529. $content = $myrow['content'];
  1530. $content = make_clickable($content);
  1531. $content = text_filter($content);
  1532. echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
  1533. echo $content;
  1534. echo "</td></tr>";
  1535. /*--------------------------------------------------
  1536. DISPLAY: the added resources
  1537. --------------------------------------------------*/
  1538. if (check_added_resources("Agenda", $myrow["id"]))
  1539. {
  1540. echo "<tr><td colspan='2'>";
  1541. echo "<i>".get_lang("AddedResources")."</i><br/>";
  1542. if ($myrow['visibility']==0)
  1543. {
  1544. $addedresource_style="invisible";
  1545. }
  1546. display_added_resources("Agenda", $myrow["id"], $addedresource_style);
  1547. echo "</td></tr>";
  1548. }
  1549. /*--------------------------------------------------
  1550. DISPLAY: edit delete button (course admin only)
  1551. --------------------------------------------------*/
  1552. echo "<tr><td>";
  1553. if (is_allowed_to_edit())
  1554. {
  1555. // edit
  1556. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=edit&amp;id=".$myrow['id']."\">",
  1557. "<img src=\"../img/edit.gif\" border=\"0\" alt=\"".get_lang("ModifyCalendarItem")."\" /></a>",
  1558. "<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;\">",
  1559. "<img src=\"../img/delete.gif\" border=\"0\" alt=\"".get_lang("Delete")."\" /></a>";
  1560. if ($myrow['visibility']==1)
  1561. {
  1562. $image_visibility="visible";
  1563. }
  1564. else
  1565. {
  1566. $image_visibility="invisible";
  1567. }
  1568. echo "<a href=\"".$_SERVER['PHP_SELF']."?origin=".$_GET['origin']."&amp;action=showhide&amp;id=".$myrow['id']."\">",
  1569. "<img src=\"../img/".$image_visibility.".gif\" border=\"0\" alt=\"".get_lang("Visible")."\" /></a><br /><br />";
  1570. }
  1571. echo "</td>";
  1572. echo "</table>";
  1573. // closing the layout table
  1574. echo "</td>",
  1575. "</tr>",
  1576. "</table>";
  1577. }
  1578. /**
  1579. * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an
  1580. * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and
  1581. * we have to retrieve the information that is in the database and use this information in the forms.
  1582. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1583. * @param integer id, the id of the agenda item we are editing. By default this is empty which means that we are adding an
  1584. * agenda item.
  1585. */
  1586. function show_add_form($id = '')
  1587. {
  1588. global $MonthsLong;
  1589. // the default values for the forms
  1590. if ($_GET['originalresource'] !== 'no')
  1591. {
  1592. $day = date('d');
  1593. $month = date('m');
  1594. $year = date('Y');
  1595. $hours = date('H');
  1596. $minutes= date('i');
  1597. $end_day = date('d');
  1598. $end_month = date('m');
  1599. $end_year = date('Y');
  1600. $end_hours = date('H');
  1601. $end_minutes= date('i');
  1602. }
  1603. else
  1604. {
  1605. // we are coming from the resource linker so there might already have been some information in the form.
  1606. // When we clicked on the button to add resources we stored every form information into a session and now we
  1607. // are doing the opposite thing: getting the information out of the session and putting it into variables to
  1608. // display it in the forms.
  1609. $form_elements=$_SESSION['formelements'];
  1610. $day=$form_elements['day'];
  1611. $month=$form_elements['month'];
  1612. $year=$form_elements['year'];
  1613. $hours=$form_elements['hour'];
  1614. $minutes=$form_elements['minutes'];
  1615. $end_day=$form_elements['end_day'];
  1616. $end_month=$form_elements['end_month'];
  1617. $end_year=$form_elements['end_year'];
  1618. $end_hours=$form_elements['end_hours'];
  1619. $end_minutes=$form_elements['end_minutes'];
  1620. $title=$form_elements['title'];
  1621. $content=$form_elements['content'];
  1622. $id=$form_elements['id'];
  1623. $to=$form_elements['to'];
  1624. }
  1625. // switching the send to all/send to groups/send to users
  1626. if ($_POST['To'])
  1627. {
  1628. $day = $_POST['fday'];
  1629. $month = $_POST['fmonth'];
  1630. $year = $_POST['fyear'];
  1631. $hours = $_POST['fhour'];
  1632. $minutes = $_POST['fminute'];
  1633. $end_day = $_POST['end_fday'];
  1634. $end_month = $_POST['end_fmonth'];
  1635. $end_year = $_POST['end_fyear'];
  1636. $end_hours = $_POST['end_fhour'];
  1637. $end_minutes = $_POST['end_fminute'];
  1638. $title = $_POST['title'];
  1639. $content = $_POST['content'];
  1640. // the invisible fields
  1641. $action = $_POST['action'];
  1642. $id = $_POST['id'];
  1643. }
  1644. // if the id is set then we are editing an agenda item
  1645. if (is_int($id))
  1646. {
  1647. //echo "before get_agenda_item".$_SESSION['allow_individual_calendar'];
  1648. $item_2_edit=get_agenda_item($id);
  1649. $title = $item_2_edit['title'];
  1650. $content= $item_2_edit['content'];
  1651. // start date
  1652. list($datepart, $timepart) = split(" ", $item_2_edit['start_date']);
  1653. list($year, $month, $day) = explode("-", $datepart);
  1654. list($hours, $minutes, $seconds) = explode(":", $timepart);
  1655. // end date
  1656. list($datepart, $timepart) = split(" ", $item_2_edit['end_date']);
  1657. list($end_year, $end_month, $end_day) = explode("-", $datepart);
  1658. list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart);
  1659. // attachments
  1660. edit_added_resources("Agenda", $id);
  1661. $to=$item_2_edit['to'];
  1662. //echo "<br />after get_agenda_item".$_SESSION['allow_individual_calendar'];
  1663. }
  1664. $content=stripslashes($content);
  1665. $title=stripslashes($title);
  1666. // we start a completely new item, we do not come from the resource linker
  1667. if ($_GET['originalresource']!=="no" and $_GET['action']=="add")
  1668. {
  1669. $_SESSION["formelements"]=null;
  1670. unset_session_resources();
  1671. }
  1672. ?>
  1673. <!-- START OF THE FORM -->
  1674. <form action="<?php echo $_SERVER['PHP_SELF'].'?origin='.$_GET['origin'].'&amp;action='.$_GET['action']; ?>" method="post" name="new_calendar_item">
  1675. <input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
  1676. <input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
  1677. <table border="0" cellpadding="5" cellspacing="0" width="100%" id="newedit_form">
  1678. <!-- the title -->
  1679. <tr class="title">
  1680. <td colspan="3">
  1681. <span style="font-weight: bold;"><?php echo (isset($id) AND $id<>'')?get_lang('ModifyCalendarItem'):get_lang("AddCalendarItem"); ?></span>
  1682. </td>
  1683. </tr>
  1684. <!-- the select specific users / send to all form -->
  1685. <?php
  1686. if (isset ($_SESSION['toolgroup']))
  1687. {
  1688. echo '<tr id="subtitle">';
  1689. echo '<td colspan="3">';
  1690. echo '<input type="hidden" name="selectedform[0]" value="GROUP:'.$_SESSION['toolgroup'].'"/>' ;
  1691. echo '<input type="hidden" name="To" value="true"/>' ;
  1692. echo '</td>';
  1693. echo '</tr>';
  1694. }else{
  1695. ?>
  1696. <tr class="subtitle">
  1697. <td valign="top" colspan="3">
  1698. <?php
  1699. // this variable defines if the course administrator can send a message to a specific user / group
  1700. // or not
  1701. //echo "<input type=\"submit\" name=\"To\" value=\"".get_lang("SelectGroupsUsers")."\" style=\"float:left\">" ;
  1702. //echo "sessiewaarde: ".$_SESSION['allow_individual_calendar'];
  1703. echo get_lang("SentTo").": ";
  1704. if ((isset($_GET['id']) && $to=='everyone') || !isset($_GET['id'])){
  1705. echo get_lang("Everybody").'&nbsp;';
  1706. }
  1707. echo '<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('ModifyRecipientList').'</a>';
  1708. show_to_form($to);
  1709. if (isset($_GET['id']) && $to!='everyone'){
  1710. echo '<script>document.getElementById(\'recipient_list\').style.display=\'block\';</script>';
  1711. }
  1712. ?>
  1713. <hr noshade="noshade" color="#cccccc" />
  1714. </td>
  1715. </tr>
  1716. <?php
  1717. }
  1718. ?>
  1719. <!-- START date and time -->
  1720. <tr class="subtitle">
  1721. <td>
  1722. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  1723. <tr><td width="110">
  1724. <!-- date: 1 -> 31 -->
  1725. <?php echo get_lang('StartDate').": \n"; ?>
  1726. </td>
  1727. <td>
  1728. <select name="fday" onchange="javascript:document.new_calendar_item.end_fday.value=this.value;">
  1729. <?php
  1730. // small loop for filling all the dates
  1731. // 2do: the available dates should be those of the selected month => february is from 1 to 28 (or 29) and not to 31
  1732. echo "\n";
  1733. foreach (range(1, 31) as $i)
  1734. {
  1735. // values have to have double digits
  1736. $value = ($i <= 9 ? '0'.$i : $i );
  1737. // the current day is indicated with [] around the date
  1738. if ($value==$day)
  1739. {
  1740. echo "\t\t\t\t <option value=\"".$value."\" selected> ".$i." </option>\n";
  1741. }
  1742. else
  1743. {
  1744. echo "\t\t\t\t<option value=\"$value\">$i</option>\n";
  1745. }
  1746. }
  1747. ?>
  1748. </select>
  1749. <!-- month: january -> december -->
  1750. <select name="fmonth" onchange="javascript:document.new_calendar_item.end_fmonth.value=this.value;">
  1751. <?php
  1752. echo "\n";
  1753. for ($i=1; $i<=12; $i++)
  1754. {
  1755. // values have to have double digits
  1756. if ($i<=9)
  1757. {
  1758. $value="0".$i;
  1759. }
  1760. else
  1761. {
  1762. $value=$i;
  1763. }
  1764. if ($value==$month)
  1765. {
  1766. echo "\t\t\t\t <option value=\"".$value."\" selected>".$MonthsLong[$i-1]."</option>\n";
  1767. }
  1768. else
  1769. {
  1770. echo "\t\t\t\t <option value=\"".$value."\">".$MonthsLong[$i-1]."</option>\n";
  1771. }
  1772. } ?>
  1773. </select>
  1774. <select name="fyear" onchange="javascript:document.new_calendar_item.end_fyear.value=this.value;">
  1775. <option value="<?php echo ($year-1); ?>"><?php echo ($year-1); ?></option>
  1776. <option value="<?php echo $year; ?>" selected="selected"><?php echo $year; ?></option>
  1777. <?php
  1778. echo "\n";
  1779. for ($i=1; $i<=5; $i++)
  1780. {
  1781. $value=$year+$i;
  1782. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1783. } ?>
  1784. </select>
  1785. <a href="javascript:openCalendar('new_calendar_item', 'f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle" /></a>
  1786. </td></tr></table>
  1787. </td>
  1788. <td>
  1789. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  1790. <tr><td width="110">
  1791. <!-- date: 1 -> 31 -->
  1792. <?php echo get_lang('StartTime').": \n"; ?>
  1793. </td>
  1794. <td>
  1795. <select name="fhour" onchange="javascript:document.new_calendar_item.end_fhour.value=this.value;">
  1796. <option value="--">--</option>
  1797. <?php
  1798. echo "\n";
  1799. foreach (range(1, 24) as $i)
  1800. {
  1801. // values have to have double digits
  1802. $value = ($i <= 9 ? '0'.$i : $i );
  1803. // the current hour is indicated with [] around the hour
  1804. if ($hours==$value)
  1805. {
  1806. echo "\t\t\t\t<option value=\"".$value."\" selected> ".$value." </option>\n";
  1807. }
  1808. else
  1809. {
  1810. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1811. }
  1812. } ?>
  1813. </select>
  1814. <?php echo get_lang('HourMinuteDivider'); ?>
  1815. <select name="fminute" onchange="javascript:document.new_calendar_item.end_fminute.value=this.value;">
  1816. <option value="<?php echo $minutes ?>"><?php echo $minutes; ?></option>
  1817. <option value="--">--</option>
  1818. <?php
  1819. foreach (range(0, 59) as $i)
  1820. {
  1821. // values have to have double digits
  1822. $value = ($i <= 9 ? '0'.$i : $i );
  1823. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1824. } ?>
  1825. </select>
  1826. </td></tr></table>
  1827. </td>
  1828. </tr>
  1829. <!-- END date and time -->
  1830. <tr class="subtitle">
  1831. <td>
  1832. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  1833. <tr><td width="110">
  1834. <!-- date: 1 -> 31 -->
  1835. <?php echo get_lang('EndDate').": \n"; ?>
  1836. </td>
  1837. <td>
  1838. <select name="end_fday">
  1839. <?php
  1840. // small loop for filling all the dates
  1841. // 2do: the available dates should be those of the selected month => february is from 1 to 28 (or 29) and not to 31
  1842. echo "\n";
  1843. foreach (range(1, 31) as $i)
  1844. {
  1845. // values have to have double digits
  1846. $value = ($i <= 9 ? '0'.$i : $i );
  1847. // the current day is indicated with [] around the date
  1848. if ($value==$end_day)
  1849. { echo "\t\t\t\t <option value=\"".$value."\" selected> ".$i." </option>\n";}
  1850. else
  1851. { echo "\t\t\t\t <option value=\"".$value."\">".$i."</option>\n"; }
  1852. }?>
  1853. </select>
  1854. <!-- month: january -> december -->
  1855. <select name="end_fmonth">
  1856. <?php
  1857. echo "\n";
  1858. foreach (range(1, 12) as $i)
  1859. {
  1860. // values have to have double digits
  1861. $value = ($i <= 9 ? '0'.$i : $i );
  1862. if ($value==$end_month)
  1863. { echo "\t\t\t\t <option value=\"".$value."\" selected>".$MonthsLong[$i-1]."</option>\n"; }
  1864. else
  1865. { echo "\t\t\t\t <option value=\"".$value."\">".$MonthsLong[$i-1]."</option>\n"; }
  1866. }?>
  1867. </select>
  1868. <select name="end_fyear">
  1869. <option value="<?php echo ($end_year-1) ?>"><?php echo ($end_year-1) ?></option>
  1870. <option value="<?php echo $end_year ?>" selected> <?php echo $end_year ?> </option>
  1871. <?php
  1872. echo "\n";
  1873. for ($i=1; $i<=5; $i++)
  1874. {
  1875. $value=$end_year+$i;
  1876. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1877. } ?>
  1878. </select>
  1879. <a href="javascript:openCalendar('new_calendar_item', 'end_f')"><img src="../img/calendar_select.gif" border="0" align="absmiddle" /></a>
  1880. </td></tr></table>
  1881. </td>
  1882. <td>
  1883. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  1884. <tr><td width="110">
  1885. <!-- date: 1 -> 31 -->
  1886. <?php echo get_lang('EndTime').": \n"; ?>
  1887. </td>
  1888. <td>
  1889. <select name="end_fhour">
  1890. <option value="--">--</option>
  1891. <?php
  1892. echo "\n";
  1893. foreach (range(1, 24) as $i)
  1894. {
  1895. // values have to have double digits
  1896. $value = ($i <= 9 ? '0'.$i : $i );
  1897. // the current hour is indicated with [] around the hour
  1898. if ($end_hours==$value)
  1899. { echo "\t\t\t\t<option value=\"".$value."\" selected> ".$value." </option>\n"; }
  1900. else
  1901. { echo "\t\t\t\t<option value=\"".$value."\"> ".$value." </option>\n"; }
  1902. } ?>
  1903. </select>
  1904. <?php echo get_lang('HourMinuteDivider'); ?>
  1905. <select name="end_fminute">
  1906. <option value="<?php echo $end_minutes; ?>"><?php echo $end_minutes; ?></option>
  1907. <option value="--">--</option>
  1908. <?php
  1909. foreach (range(0, 59) as $i)
  1910. {
  1911. // values have to have double digits
  1912. $value = ($i <= 9 ? '0'.$i : $i );
  1913. echo "\t\t\t\t<option value=\"$value\">$value</option>\n";
  1914. } ?>
  1915. </select>
  1916. </td></tr></table>
  1917. </td>
  1918. </tr>
  1919. <tr class="subtitle">
  1920. <td colspan="3" valign="top"><hr noshade="noshade" color="#cccccc" /><?php echo get_lang('ItemTitle'); ?> :
  1921. <!--<div style='margin-left: 80px'><textarea name="title" cols="50" rows="2" wrap="virtual" style="vertical-align:top; width:75%; height:50px;"><?php if (isset($title)) echo $title; ?></textarea></div>-->
  1922. <input type="text" size="60" name="title" value="<?php if (isset($title)) echo $title; ?>" />
  1923. </td>
  1924. </tr>
  1925. <tr>
  1926. <td colspan="7">
  1927. <?php
  1928. require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
  1929. $oFCKeditor = new FCKeditor('content') ;
  1930. $oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ;
  1931. $oFCKeditor->Height = '175';
  1932. $oFCKeditor->Width = '100%';
  1933. $oFCKeditor->Value = $content;
  1934. $oFCKeditor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js";
  1935. $oFCKeditor->ToolbarSet = "Middle";
  1936. $TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE);
  1937. $sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'";
  1938. $result_sql=api_sql_query($sql);
  1939. $isocode_language=mysql_result($result_sql,0,0);
  1940. $oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
  1941. $return = $oFCKeditor->CreateHtml();
  1942. echo $return;
  1943. ?>
  1944. </td>
  1945. </tr>
  1946. <!--<?php /* ADDED BY UGENT, Patrick Cool, march 2004 */ ?>
  1947. <tr>
  1948. <td colspan="7">
  1949. <?php
  1950. //onclick="selectAll(this.form.elements[6],true)"
  1951. if ($_SESSION['allow_individual_calendar']=='show')
  1952. show_addresource_button('onclick="selectAll(this.form.elements[6],true)"');
  1953. else
  1954. show_addresource_button();
  1955. $form_elements=$_SESSION['formelements'];
  1956. ?>
  1957. </td>
  1958. </tr>-->
  1959. <?php
  1960. //if ($_SESSION['addedresource'])
  1961. echo "\t<tr>\n";
  1962. echo "\t\t<td colspan=\"7\">\n";
  1963. echo display_resources(0);
  1964. $test=$_SESSION['addedresource'];
  1965. echo "\t\t</td>\n\t</tr>\n";
  1966. /* END ADDED BY UGENT, Patrick Cool, march 2004 */
  1967. ?>
  1968. <tr>
  1969. <td colspan="7">
  1970. <input type="submit" name="submit_event" value="<?php echo get_lang('Ok'); ?>" onclick="selectAll(this.form.elements[5],true)" />
  1971. </td>
  1972. </tr>
  1973. </table>
  1974. </form>
  1975. <p>&nbsp;</p>
  1976. <?php
  1977. }
  1978. ?>