myagenda.php 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  15. ==============================================================================
  16. @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
  17. @author: Toon Van Hoecke <toon.vanhoecke@ugent.be>, Ghent University
  18. @author: Eric Remy (initial version)
  19. @version: 2.2 alpha
  20. @description: this file generates a general agenda of all items of the
  21. courses the user is registered for
  22. ==============================================================================
  23. version info:
  24. -------------
  25. -> version 2.2 : Patrick Cool, patrick.cool@ugent.be, november 2004
  26. Personal Agenda added. The user can add personal agenda items. The items
  27. are stored in a dokeos_user database because it is not course or platform
  28. based. A personal agenda view was also added. This lists all the personal
  29. agenda items of that user.
  30. -> version 2.1 : Patrick Cool, patrick.cool@ugent.be, , oktober 2004
  31. This is the version that works with the Group based Agenda tool.
  32. -> version 2.0 (alpha): Patrick Cool, patrick.cool@ugent.be, , oktober 2004
  33. The 2.0 version introduces besides the month view also a week- and day view.
  34. In the 2.5 (final) version it will be possible for the student to add his/her
  35. own agenda items. The platform administrator can however decide if the students
  36. are allowed to do this or not.
  37. The alpha version only contains the three views. The personal agenda feature is
  38. not yet completely finished. There are however already some parts of the code
  39. for adding a personal agenda item present.
  40. this code was not released in an official dokeos but was only used in the offical
  41. server of the Ghent University where it underwent serious testing
  42. -> version 1.5: Toon Van Hoecke, toon.vanhoecke@ugent.be, december 2003
  43. -> version 1.0: Eric Remy, eremy@rmwc.edu, 6 Oct 2003
  44. The tool was initially called master-calendar as it collects all the calendar
  45. items of all the courses one is subscribed to. It was very soon integrated in
  46. Dokeos as this was a really basic and very usefull tool.
  47. /* ==============================================================================
  48. HEADER
  49. ============================================================================== */
  50. // name of the language file that needs to be included
  51. $language_file = 'agenda';
  52. // we are not inside a course, so we reset the course id
  53. $cidReset = true;
  54. // setting the global file that gets the general configuration, the databases, the languages, ...
  55. require ('../inc/global.inc.php');
  56. $this_section = SECTION_MYAGENDA;
  57. require (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  58. // setting the name of the tool
  59. $nameTools = get_lang('MyAgenda');
  60. // if we come from inside a course and click on the 'My Agenda' link we show a link back to the course
  61. // in the breadcrumbs
  62. $course_path = htmlentities(strip_tags($_GET['coursePath']));
  63. if (!empty ($course_path))
  64. {
  65. $interbreadcrumb[] = array ('url' => api_get_path(WEB_COURSE_PATH).urlencode($course_path).'/index.php', 'name' => $_GET['courseCode']);
  66. }
  67. // this loads the javascript that is needed for the date popup selection
  68. $htmlHeadXtra[] = "<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
  69. // showing the header
  70. Display::display_header(get_lang('MyAgenda'));
  71. /* ==============================================================================
  72. SETTING SOME VARIABLES
  73. ============================================================================== */
  74. // setting the database variables
  75. $TABLECOURS = Database :: get_main_table(TABLE_MAIN_COURSE);
  76. $TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  77. $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
  78. $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  79. $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
  80. // the variables for the days and the months
  81. // Defining the shorts for the days
  82. $DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
  83. // Defining the days of the week to allow translation of the days
  84. $DaysLong = array (get_lang("SundayLong"), get_lang("MondayLong"), get_lang("TuesdayLong"), get_lang("WednesdayLong"), get_lang("ThursdayLong"), get_lang("FridayLong"), get_lang("SaturdayLong"));
  85. // Defining the months of the year to allow translation of the months
  86. $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"));
  87. /* ==============================================================================
  88. SANITY CHECK
  89. ============================================================================== */
  90. // You can delete this if you have manually added the new database and tables
  91. // this piece of code was added to avoid having to explain to non sys-admin
  92. // what has to be done in order to get this tool working
  93. if (get_setting("allow_personal_agenda") == "true")
  94. {
  95. // I use a separate database for storing all the information of user driven tools
  96. // as the Personal Agenda tool has the potential to create a large database.
  97. // If you do not want a separate database for the personal agenda tool you can add the table to
  98. // the main dokeos database by changing $DATABASE_USER_TOOLS above to $_configuration['main_database']
  99. $sql_create_database = "CREATE DATABASE IF NOT EXISTS `$DATABASE_USER_TOOLS`";
  100. $result = api_sql_query($sql_create_database);
  101. $sql_create_table = "CREATE TABLE IF NOT EXISTS $tbl_personal_agenda (
  102. `id` int(11) NOT NULL auto_increment,
  103. `user` int(11),
  104. `title` text,
  105. `text` text,
  106. `date` datetime default NULL,
  107. `course` varchar(255),
  108. UNIQUE KEY `id` (`id`))
  109. TYPE=MyISAM AUTO_INCREMENT=1";
  110. $result = api_sql_query($sql_create_table);
  111. }
  112. /*==============================================================================
  113. TREATING THE URL PARAMETERS
  114. 1. The default values
  115. 2. storing it in the session
  116. 3. possible view
  117. 3.a Month view
  118. 3.b Week view
  119. 3.c day view
  120. 3.d personal view (only the personal agenda items)
  121. 4. add personal agenda
  122. 5. edit personal agenda
  123. 6. delete personal agenda
  124. ============================================================================== */
  125. // 1. The default values. if there is no session yet, we have by default the month view
  126. if (!$_SESSION['view'])
  127. {
  128. $_SESSION['view'] = "month";
  129. }
  130. // 2. Storing it in the session. If we change the view by clicking on the links left, we change the session
  131. if ($_GET['view'])
  132. {
  133. $_SESSION['view'] = $_GET['view'];
  134. }
  135. // 3. The views: (month, week, day, personal)
  136. if ($_SESSION['view'])
  137. {
  138. switch ($_SESSION['view'])
  139. {
  140. // 3.a Month view
  141. case "month" :
  142. $proces = "month_view";
  143. break;
  144. // 3.a Week view
  145. case "week" :
  146. $proces = "week_view";
  147. break;
  148. // 3.a Day view
  149. case "day" :
  150. $proces = "day_view";
  151. break;
  152. // 3.a Personal view
  153. case "personal" :
  154. $proces = "personal_view";
  155. break;
  156. }
  157. }
  158. // 4. add personal agenda
  159. if ($_GET['action'] == "add_personal_agenda_item" and !$_POST['Submit'])
  160. {
  161. $proces = "add_personal_agenda_item";
  162. }
  163. if ($_GET['action'] == "add_personal_agenda_item" and $_POST['Submit'])
  164. {
  165. $proces = "store_personal_agenda_item";
  166. }
  167. // 5. edit personal agenda
  168. if ($_GET['action'] == "edit_personal_agenda_item" and !$_POST['Submit'])
  169. {
  170. $proces = "edit_personal_agenda_item";
  171. }
  172. if ($_GET['action'] == "edit_personal_agenda_item" and $_POST['Submit'])
  173. {
  174. $proces = "store_personal_agenda_item";
  175. }
  176. // 6. delete personal agenda
  177. if ($_GET['action'] == "delete" AND $_GET['id'])
  178. {
  179. $proces = "delete_personal_agenda_item";
  180. }
  181. /* ==============================================================================
  182. OUTPUT
  183. ============================================================================== */
  184. if (isset ($_user['user_id']))
  185. {
  186. // getting all the courses that this user is subscribed to
  187. $courses_dbs = get_courses_of_user();
  188. if (!is_array($courses_dbs)) // this is for the special case if the user has no courses (otherwise you get an error)
  189. {
  190. $courses_dbs = array ();
  191. }
  192. // setting and/or getting the year, month, day, week
  193. $today = getdate();
  194. $year = (int)$_GET['year'];
  195. if ($year == NULL)
  196. {
  197. $year = $today['year'];
  198. }
  199. $month = (int)$_GET['month'];
  200. if ($month == NULL)
  201. {
  202. $month = $today['mon'];
  203. }
  204. $day = (int)$_GET['day'];
  205. if ($day == NULL)
  206. {
  207. $day = $today['mday'];
  208. }
  209. $week = (int)$_GET['week'];
  210. if ($week == NULL)
  211. {
  212. $week = date("W");
  213. }
  214. // The name of the current Month
  215. $monthName = $MonthsLong[$month -1];
  216. // Starting the output
  217. echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  218. echo "<tr>";
  219. // output: the small calendar item on the left and the view / add links
  220. echo "<td width=\"220\" valign=\"top\">";
  221. $agendaitems = get_agendaitems($courses_dbs, $month, $year);
  222. if (get_setting('allow_personal_agenda') == 'true')
  223. {
  224. $agendaitems = get_personal_agendaitems($agendaitems, $day, $month, $year, $week, "month_view");
  225. }
  226. display_minimonthcalendar($agendaitems, $month, $year, $monthName);
  227. echo "\n<ul id=\"agenda_select\">\n";
  228. echo "\t<li><a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=month\"><img src=\"../img/calendar_month.gif\" border=\"0\" alt=\"".get_lang('MonthView')."\" /> ".get_lang('MonthView')."</a></li>\n";
  229. echo "\t<li><a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=week\"><img src=\"../img/calendar_week.gif\" border=\"0\" alt=\"".get_lang('WeekView')."\" /> ".get_lang('WeekView')."</a></li>\n";
  230. echo "\t<li><a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=day\"><img src=\"../img/calendar_day.gif\" border=\"0\" alt=\"".get_lang('DayView')."\" /> ".get_lang('DayView')."</a></li>\n";
  231. if (get_setting('allow_personal_agenda') == 'true')
  232. {
  233. echo "\t<li><a href=\"".$_SERVER['PHP_SELF']."?action=add_personal_agenda_item\"><img src=\"../img/calendar_personal_add.gif\" border=\"0\" /> ".get_lang("AddPersonalItem")."</a></li>\n";
  234. echo "\t<li><a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=personal\"><img src=\"../img/calendar_personal.gif\" border=\"0\" /> ".get_lang("ViewPersonalItem")."</a></li>\n";
  235. }
  236. echo "</ul>\n\n";
  237. echo "</td>";
  238. // the divider
  239. // OlivierB : the image has a white background, which causes trouble if the portal has another background color. Image should be transparent. ----> echo "<td width=\"20\" background=\"../img/verticalruler.gif\">&nbsp;</td>";
  240. echo "<td width=\"20\">&nbsp;</td>";
  241. // the main area: day, week, month view
  242. echo "<td valign=\"top\">";
  243. switch ($proces)
  244. {
  245. case "month_view" :
  246. $agendaitems = get_agendaitems($courses_dbs, $month, $year);
  247. if (get_setting("allow_personal_agenda") == "true")
  248. {
  249. $agendaitems = get_personal_agendaitems($agendaitems, $day, $month, $year, $week, "month_view");
  250. }
  251. display_monthcalendar($agendaitems, $month, $year, $langDay_of_weekNames['long'], $monthName);
  252. break;
  253. case "week_view" :
  254. $agendaitems = get_week_agendaitems($courses_dbs, $month, $year, $week);
  255. if (get_setting("allow_personal_agenda") == "true")
  256. {
  257. $agendaitems = get_personal_agendaitems($agendaitems, $day, $month, $year, $week, "week_view");
  258. }
  259. display_weekcalendar($agendaitems, $month, $year, $langDay_of_weekNames['long'], $monthName);
  260. break;
  261. case "day_view" :
  262. $agendaitems = get_day_agendaitems($courses_dbs, $month, $year, $day);
  263. if (get_setting("allow_personal_agenda") == "true")
  264. {
  265. $agendaitems = get_personal_agendaitems($agendaitems, $day, $month, $year, $week, "day_view");
  266. }
  267. display_daycalendar($agendaitems, $day, $month, $year, $langDay_of_weekNames['long'], $monthName);
  268. break;
  269. case "personal_view" :
  270. show_personal_agenda();
  271. break;
  272. case "add_personal_agenda_item" :
  273. show_new_item_form();
  274. break;
  275. case "store_personal_agenda_item" :
  276. store_personal_item($_POST['frm_day'], $_POST['frm_month'], $_POST['frm_year'], $_POST['frm_hour'], $_POST['frm_minute'], $_POST['frm_title'], $_POST['frm_content'], (int)$_GET['id']);
  277. if ($_GET['id'])
  278. {
  279. Display :: display_normal_message(get_lang("PeronalAgendaItemEdited"));
  280. }
  281. else
  282. {
  283. Display :: display_normal_message(get_lang("PeronalAgendaItemAdded"));
  284. }
  285. show_personal_agenda();
  286. break;
  287. case "edit_personal_agenda_item" :
  288. show_new_item_form((int)$_GET['id']);
  289. break;
  290. case "delete_personal_agenda_item" :
  291. delete_personal_agenda((int)$_GET['id']);
  292. Display :: display_normal_message(get_lang('PeronalAgendaItemDeleted'));
  293. show_personal_agenda();
  294. break;
  295. }
  296. }
  297. echo "</td></tr></table>";
  298. Display :: display_footer();
  299. /*============================================================================
  300. get_agendaitems($courses_db, $month, $year)
  301. ============================================================================*/
  302. // This function retrieves all the agenda items of all the course of the user
  303. function get_agendaitems($courses_dbs, $month, $year)
  304. {
  305. global $_user;
  306. global $_configuration;
  307. $items = array ();
  308. // get agenda-items for every course
  309. foreach ($courses_dbs as $key => $array_course_info)
  310. {
  311. //databases of the courses
  312. $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db"]);
  313. $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db"]);
  314. $group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']);
  315. // if the user is administrator of that course we show all the agenda items
  316. if ($array_course_info['status'] == '1')
  317. {
  318. //echo "course admin";
  319. $sqlquery = "SELECT
  320. DISTINCT agenda.*, item_property.*
  321. FROM ".$TABLEAGENDA." agenda,
  322. ".$TABLE_ITEMPROPERTY." item_property
  323. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  324. AND MONTH(`agenda`.`start_date`)='".$month."'
  325. AND YEAR(`agenda`.`start_date`)='".$year."'
  326. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  327. AND `item_property`.`visibility`='1'
  328. ORDER BY start_date ".$sort;
  329. }
  330. // if the user is not an administrator of that course
  331. else
  332. {
  333. //echo "GEEN course admin";
  334. if (is_array($group_memberships))
  335. {
  336. $sqlquery = "SELECT
  337. agenda.*, item_property.*
  338. FROM ".$TABLEAGENDA." agenda,
  339. ".$TABLE_ITEMPROPERTY." item_property
  340. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  341. AND MONTH(`agenda`.`start_date`)='".$month."'
  342. AND YEAR(`agenda`.`start_date`)='".$year."'
  343. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  344. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  345. AND `item_property`.`visibility`='1'
  346. ORDER BY start_date ".$sort;
  347. }
  348. else
  349. {
  350. $sqlquery = "SELECT
  351. agenda.*, item_property.*
  352. FROM ".$TABLEAGENDA." agenda,
  353. ".$TABLE_ITEMPROPERTY." item_property
  354. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  355. AND MONTH(`agenda`.`start_date`)='".$month."'
  356. AND YEAR(`agenda`.`start_date`)='".$year."'
  357. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  358. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id`='0')
  359. AND `item_property`.`visibility`='1'
  360. ORDER BY start_date ".$sort;
  361. }
  362. }
  363. $result = api_sql_query($sqlquery, __FILE__, __LINE__);
  364. while ($item = mysql_fetch_array($result))
  365. {
  366. $agendaday = date("j",strtotime($item['start_date']));
  367. $time= date("H:i",strtotime($item['start_date']));
  368. $URL = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item
  369. $items[$agendaday][$item['start_time']] .= "<i>".$time."</i> <a href=\"$URL\" title=\"".$array_course_info["name"]."\">".$array_course_info["visual_code"]."</a> ".$item['title']."<br />";
  370. }
  371. }
  372. // sorting by hour for every day
  373. $agendaitems = array ();
  374. while (list ($agendaday, $tmpitems) = each($items))
  375. {
  376. sort($tmpitems);
  377. while (list ($key, $val) = each($tmpitems))
  378. {
  379. $agendaitems[$agendaday] .= $val;
  380. }
  381. }
  382. //print_r($agendaitems);
  383. return $agendaitems;
  384. }
  385. /*============================================================================
  386. display_monthcalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
  387. ============================================================================*/
  388. // show the monthcalender of the given month
  389. function display_monthcalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
  390. {
  391. global $DaysShort,$course_path;
  392. //Handle leap year
  393. $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  394. if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
  395. $numberofdays[2] = 29;
  396. //Get the first day of the month
  397. $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
  398. //Start the week on monday
  399. $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
  400. $backwardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".htmlentities($_GET['courseCode'])."&amp;action=view&amp;view=month&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
  401. $forewardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".htmlentities($_GET['courseCode'])."&amp;action=view&amp;view=month&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
  402. echo "<table id=\"agenda_list\">\n", "<tr class=\"title\">\n", "<td width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></td>\n", "<td width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</td>\n", "<td width=\"10%\"><a href=\"", $forewardsURL, "\">»</a></td>\n", "</tr>\n";
  403. echo "<tr>\n";
  404. for ($ii = 1; $ii < 8; $ii ++)
  405. {
  406. echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>\n";
  407. }
  408. echo "</tr>\n";
  409. $curday = -1;
  410. $today = getdate();
  411. while ($curday <= $numberofdays[$month])
  412. {
  413. echo "<tr>\n";
  414. for ($ii = 0; $ii < 7; $ii ++)
  415. {
  416. if (($curday == -1) && ($ii == $startdayofweek))
  417. {
  418. $curday = 1;
  419. }
  420. if (($curday > 0) && ($curday <= $numberofdays[$month]))
  421. {
  422. $bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
  423. $dayheader = "<b>$curday</b>";
  424. if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon]))
  425. {
  426. $dayheader = "$curday - ".get_lang("Today")."<br />";
  427. $class = "class=\"days_today\"";
  428. }
  429. echo "<td ".$class.">", "".$dayheader;
  430. if (!empty($agendaitems[$curday]))
  431. {
  432. echo "<span class=\"agendaitem\">".$agendaitems[$curday]."</span>";
  433. }
  434. echo "</td>\n";
  435. $curday ++;
  436. }
  437. else
  438. {
  439. echo "<td>&nbsp;</td>\n";
  440. }
  441. }
  442. echo "</tr>\n";
  443. }
  444. echo "</table>\n";
  445. }
  446. /*============================================================================
  447. display_minimonthcalendar($agendaitems, $month, $year, $monthName)
  448. ============================================================================*/
  449. // show the mini calender of the given month
  450. function display_minimonthcalendar($agendaitems, $month, $year, $monthName)
  451. {
  452. global $DaysShort,$course_path;
  453. //Handle leap year
  454. $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  455. if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
  456. $numberofdays[2] = 29;
  457. //Get the first day of the month
  458. $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
  459. //Start the week on monday
  460. $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
  461. $backwardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
  462. $forewardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
  463. echo "<table id=\"smallcalendar\">\n", "<tr class=\"title\">\n", "<td width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></td>\n", "<td width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</td>\n", "<td width=\"10%\"><a href=\"", $forewardsURL, "\">»</a></td>\n", "</tr>\n";
  464. echo "<tr>\n";
  465. for ($ii = 1; $ii < 8; $ii ++)
  466. {
  467. echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>\n";
  468. }
  469. echo "</tr>\n";
  470. $curday = -1;
  471. $today = getdate();
  472. while ($curday <= $numberofdays[$month])
  473. {
  474. echo "<tr>\n";
  475. for ($ii = 0; $ii < 7; $ii ++)
  476. {
  477. if (($curday == -1) && ($ii == $startdayofweek))
  478. {
  479. $curday = 1;
  480. }
  481. if (($curday > 0) && ($curday <= $numberofdays[$month]))
  482. {
  483. $bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
  484. $dayheader = "$curday";
  485. if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon]))
  486. {
  487. $dayheader = "$curday";
  488. $class = "class=\"days_today\"";
  489. }
  490. echo "\t<td ".$class.">";
  491. if ($agendaitems[$curday] <> "")
  492. {
  493. echo "<a href=\"".$_SERVER['PHP_SELF']."?action=view&amp;view=day&amp;day=".$curday."&amp;month=".$month."&amp;year=".$year."\">".$dayheader."</a>";
  494. }
  495. else
  496. {
  497. echo $dayheader;
  498. }
  499. // "a".$dayheader." <span class=\"agendaitem\">".$agendaitems[$curday]."</span>\n";
  500. echo "</td>\n";
  501. $curday ++;
  502. }
  503. else
  504. {
  505. echo "<td>&nbsp;</td>\n";
  506. }
  507. }
  508. echo "</tr>\n";
  509. }
  510. echo "</table>\n";
  511. }
  512. /*============================================================================
  513. display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
  514. ============================================================================*/
  515. function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
  516. {
  517. global $DaysShort,$course_path;
  518. global $MonthsLong;
  519. // timestamp of today
  520. $today = mktime();
  521. $day_of_the_week = date("w", $today);
  522. $thisday_of_the_week = date("w", $today);
  523. // the week number of the year
  524. $week_number = date("W", $today);
  525. $thisweek_number = date("W", $today);
  526. // if we moved to the next / previous week we have to recalculate the $today variable
  527. if ($_GET['week'])
  528. {
  529. $today = mktime(0, 0, 0, 1, 1, $year);
  530. $today = $today + (((int)$_GET['week']) * (7 * 24 * 60 * 60));
  531. $week_number = date("W", $today);
  532. }
  533. // calculating the start date of the week
  534. // the date of the monday of this week is the timestamp of today minus
  535. // number of days that have already passed this week * 24 hours * 60 minutes * 60 seconds
  536. $current_day = date("j", $today); // Day of the month without leading zeros (1 to 31) of today
  537. $day_of_the_week = date("w", $today); // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) of today
  538. $timestamp_first_date_of_week = $today - (($day_of_the_week -1) * 24 * 60 * 60); // timestamp of the monday of this week
  539. $timestamp_last_date_of_week = $today + ((7 - $day_of_the_week) * 24 * 60 * 60); // timestamp of the sunday of this week
  540. $backwardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;action=view&amp;view=week&amp;week=". ($week_number -1);
  541. $forewardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;action=view&amp;view=week&amp;week=". ($week_number +1);
  542. echo "<table id=\"agenda_list\">\n";
  543. // The title row containing the the week information (week of the year (startdate of week - enddate of week)
  544. echo "<tr class=\"title\">\n";
  545. echo "<td width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></td>\n";
  546. echo "<td colspan=\"5\">".get_lang("Week")." ".$week_number;
  547. echo " (".$DaysShort['1']." ".date("j", $timestamp_first_date_of_week)." ".$MonthsLong[date("n", $timestamp_first_date_of_week) - 1]." ".date("Y", $timestamp_first_date_of_week)." - ".$DaysShort['0']." ".date("j", $timestamp_last_date_of_week)." ".$MonthsLong[date("n", $timestamp_last_date_of_week) - 1]." ".date("Y", $timestamp_last_date_of_week).')';
  548. echo "</td>";
  549. echo "<td width=\"10%\"><a href=\"", $forewardsURL, "\">»</a></td>\n", "</tr>\n";
  550. // The second row containing the short names of the days of the week
  551. echo "<tr>\n";
  552. // this is the Day of the month without leading zeros (1 to 31) of the monday of this week
  553. $tmp_timestamp = $timestamp_first_date_of_week;
  554. for ($ii = 1; $ii < 8; $ii ++)
  555. {
  556. echo "\t<td class=\"weekdays\">";
  557. if ($ii == $thisday_of_the_week AND (!isset($_GET['week']) OR $_GET['week']==$thisweek_number))
  558. {
  559. echo "<font color=#CC3300>";
  560. }
  561. echo $DaysShort[$ii % 7]." ".date("j", $tmp_timestamp)." ".$MonthsLong[date("n", $tmp_timestamp) - 1];
  562. if ($ii == $thisday_of_the_week AND (!isset($_GET['week']) OR $_GET['week']==$thisweek_number))
  563. {
  564. echo "</font>";
  565. }
  566. echo "</td>\n";
  567. // we 24 hours * 60 minutes * 60 seconds to the $tmp_timestamp
  568. $array_tmp_timestamp[] = $tmp_timestamp;
  569. $tmp_timestamp = $tmp_timestamp + (24 * 60 * 60);
  570. }
  571. echo "</tr>\n";
  572. // the table cells containing all the entries for that day
  573. echo "<tr>\n";
  574. $counter = 0;
  575. foreach ($array_tmp_timestamp as $key => $value)
  576. {
  577. if ($counter < 5)
  578. {
  579. $class = "class=\"days_week\"";
  580. }
  581. else
  582. {
  583. $class = "class=\"days_weekend\"";
  584. }
  585. if ($counter == $thisday_of_the_week -1 AND (!isset($_GET['week']) OR $_GET['week']==$thisweek_number))
  586. {
  587. $class = "class=\"days_today\"";
  588. }
  589. echo "\t<td ".$class.">";
  590. echo "<span class=\"agendaitem\">".$agendaitems[date("j", $value)]."&nbsp;</span> ";
  591. echo "</td>\n";
  592. $counter ++;
  593. }
  594. echo "</tr>\n";
  595. echo "</table>\n";
  596. }
  597. /*============================================================================
  598. display_daycalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
  599. ============================================================================*/
  600. // show the mini calender of the given month
  601. function display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $monthName)
  602. {
  603. global $DaysShort, $DaysLong, $course_path;
  604. global $MonthsLong;
  605. global $query;
  606. // timestamp of today
  607. $today = mktime();
  608. $nextday = $today + (24 * 60 * 60);
  609. $previousday = $today - (24 * 60 * 60);
  610. // the week number of the year
  611. $week_number = date("W", $today);
  612. // if we moved to the next / previous day we have to recalculate the $today variable
  613. if ($_GET['day'])
  614. {
  615. $today = mktime(0, 0, 0, $month, $day, $year);
  616. $nextday = $today + (24 * 60 * 60);
  617. $previousday = $today - (24 * 60 * 60);
  618. $week_number = date("W", $today);
  619. }
  620. // calculating the start date of the week
  621. // the date of the monday of this week is the timestamp of today minus
  622. // number of days that have already passed this week * 24 hours * 60 minutes * 60 seconds
  623. $current_day = date("j", $today); // Day of the month without leading zeros (1 to 31) of today
  624. $day_of_the_week = date("w", $today); // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) of today
  625. //$timestamp_first_date_of_week=$today-(($day_of_the_week-1)*24*60*60); // timestamp of the monday of this week
  626. //$timestamp_last_date_of_week=$today+((7-$day_of_the_week)*24*60*60); // timestamp of the sunday of this week
  627. // we are loading all the calendar items of all the courses for today
  628. echo "<table id=\"agenda_list\">\n";
  629. // the forward and backwards url
  630. $backwardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;action=view&amp;view=day&amp;day=".date("j", $previousday)."&amp;month=".date("n", $previousday)."&amp;year=".date("Y", $previousday);
  631. $forewardsURL = $_SERVER['PHP_SELF']."?coursePath=".urlencode($course_path)."&amp;courseCode=".$_GET['courseCode']."&amp;action=view&amp;view=day&amp;day=".date("j", $nextday)."&amp;month=".date("n", $nextday)."&amp;year=".date("Y", $nextday);
  632. // The title row containing the day
  633. echo "<tr class=\"title\">\n", "<td width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></td>\n", "<td>";
  634. echo $DaysLong[$day_of_the_week]." ".date("j", $today)." ".$MonthsLong[date("n", $today) - 1]." ".date("Y", $today);
  635. echo "</td>";
  636. echo "<td width=\"10%\"><a href=\"", $forewardsURL, "\">»</a></td>\n";
  637. echo "</tr>\n";
  638. // the rows for each half an hour
  639. for ($i = 10; $i < 48; $i ++)
  640. {
  641. echo "<tr>\n";
  642. echo "\t";
  643. if ($i % 2 == 0)
  644. {
  645. $class = "class=\"alternativeBgLight\"";
  646. echo ("<td $class valign=\"top\" width=\"75\">". (($i) / 2)." ".get_lang("HourShort")." 00</td>\n");
  647. }
  648. else
  649. {
  650. $class = "";
  651. echo ("<td valign=\"top\" width=\"75\">". ((($i) / 2) - (1 / 2))." ".get_lang("HourShort")." 30</td>\n");
  652. }
  653. echo "\t<td $class valign=\"top\" colspan=\"2\">\n";
  654. if (is_array($agendaitems[$i]))
  655. {
  656. foreach ($agendaitems[$i] as $key => $value)
  657. {
  658. echo $value;
  659. }
  660. }
  661. else
  662. {
  663. echo $agendaitems[$i];
  664. }
  665. echo "\t</td>\n";
  666. echo "</tr>\n";
  667. }
  668. echo "</table>\n";
  669. }
  670. /*============================================================================
  671. get_day_agendaitems($query, $month, $year)
  672. ============================================================================*/
  673. // show the monthcalender of the given month
  674. function get_day_agendaitems($courses_dbs, $month, $year, $day)
  675. {
  676. global $_user;
  677. global $_configuration;
  678. $items = array ();
  679. // get agenda-items for every course
  680. //$query=api_sql_query($sql_select_courses);
  681. foreach ($courses_dbs as $key => $array_course_info)
  682. {
  683. //databases of the courses
  684. $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db"]);
  685. $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db"]);
  686. // getting all the groups of the user for the current course
  687. $group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']);
  688. // if the user is administrator of that course we show all the agenda items
  689. if ($array_course_info['status'] == '1')
  690. {
  691. //echo "course admin";
  692. $sqlquery = "SELECT
  693. DISTINCT agenda.*, item_property.*
  694. FROM ".$TABLEAGENDA." agenda,
  695. ".$TABLE_ITEMPROPERTY." item_property
  696. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  697. AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
  698. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  699. AND `item_property`.`visibility`='1'
  700. ORDER BY start_date ".$sort;
  701. }
  702. // if the user is not an administrator of that course
  703. else
  704. {
  705. //echo "GEEN course admin";
  706. if (is_array($group_memberships))
  707. {
  708. $sqlquery = "SELECT
  709. agenda.*, item_property.*
  710. FROM ".$TABLEAGENDA." agenda,
  711. ".$TABLE_ITEMPROPERTY." item_property
  712. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  713. AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
  714. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  715. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  716. AND `item_property`.`visibility`='1'
  717. ORDER BY start_date ".$sort;
  718. }
  719. else
  720. {
  721. $sqlquery = "SELECT
  722. agenda.*, item_property.*
  723. FROM ".$TABLEAGENDA." agenda,
  724. ".$TABLE_ITEMPROPERTY." item_property
  725. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  726. AND DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
  727. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  728. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id`='0')
  729. AND `item_property`.`visibility`='1'
  730. ORDER BY start_date ".$sort;
  731. }
  732. }
  733. //$sqlquery = "SELECT * FROM $agendadb WHERE DAYOFMONTH(day)='$day' AND month(day)='$month' AND year(day)='$year'";
  734. //echo "abc";
  735. //echo $sqlquery;
  736. $result = api_sql_query($sqlquery, __FILE__, __LINE__);
  737. //echo mysql_num_rows($result);
  738. while ($item = mysql_fetch_array($result))
  739. {
  740. // in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
  741. // we want to know for each agenda item for this day to wich halfhour it must be assigned
  742. list ($datepart, $timepart) = split(" ", $item['start_date']);
  743. list ($year, $month, $day) = explode("-", $datepart);
  744. list ($hours, $minutes, $seconds) = explode(":", $timepart);
  745. $halfhour = 2 * $hours;
  746. if ($minutes >= '30')
  747. {
  748. $halfhour = $halfhour +1;
  749. }
  750. //$URL = $_configuration['root_web'].$mycours["dir"]."/";
  751. $URL = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$day&amp;month=$month&amp;year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item
  752. $items[$halfhour][] .= "<i>".$hours.":".$minutes."</i> <a href=\"$URL\" title=\"".$array_course_info['name']."\">".$array_course_info['visual_code']."</a> ".$item['title']."<br />";
  753. }
  754. }
  755. // sorting by hour for every day
  756. /*$agendaitems = array();
  757. while (list($agendaday, $tmpitems) = each($items))
  758. {
  759. sort($tmpitems);
  760. while (list($key,$val) = each($tmpitems))
  761. {
  762. $agendaitems[$agendaday].=$val;
  763. }
  764. }*/
  765. $agendaitems = $items;
  766. //print_r($agendaitems);
  767. return $agendaitems;
  768. }
  769. /*============================================================================
  770. function get_week_agendaitems($courses_dbs, $month, $year,$day)
  771. ============================================================================*/
  772. function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
  773. {
  774. global $TABLEAGENDA, $TABLE_ITEMPROPERTY;
  775. global $_user;
  776. global $_configuration;
  777. $items = array ();
  778. // The default value of the week
  779. if ($week == '')
  780. {
  781. $week_number = date("W", mktime());
  782. }
  783. else
  784. {
  785. $week_number = $week;
  786. }
  787. $start_end = calculate_start_end_of_week($week_number, $year);
  788. $start_filter = $start_end['start']['year']."-".$start_end['start']['month']."-".$start_end['start']['day'];
  789. $end_filter = $start_end['end']['year']."-".$start_end['end']['month']."-".$start_end['end']['day'];
  790. /*
  791. // determine the start and end date
  792. // step 1: we calculate a timestamp for a day in this week
  793. $random_day_in_week=mktime(0,0,0,1,1,$year)+($week_number)*(7*24*60*60); // we calculate a random day in this week
  794. // step 2: we which day this is (0=sunday, 1=monday, ...)
  795. $number_day_in_week=date("w",$random_day_in_week);
  796. // step 3: we calculate the timestamp of the monday of the week we are in
  797. $start_timestamp=$random_day_in_week-(($number_day_in_week-1)*24*60*60);
  798. // step 4: we calculate the timestamp of the sunday of the week we are in
  799. $end_timestamp=$random_day_in_week+((7-$number_day_in_week+1)*24*60*60)-3600;
  800. // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year
  801. $start_day=date("j",$start_timestamp);
  802. $start_month=date("n",$start_timestamp);
  803. $start_year=date("Y",$start_timestamp);
  804. $end_day=date("j",$end_timestamp);
  805. $end_month=date("n",$end_timestamp);
  806. $end_year=date("Y",$end_timestamp);
  807. // in sql statements you have to use year-month-day for date calculations
  808. $start_filter=$start_year."-".$start_month."-".$start_day;
  809. $end_filter=$end_year."-".$end_month."-".$end_day;
  810. */
  811. //$start_end_week=calculate_start_end_of_week($week_number, $year);
  812. // a little bit of debug information
  813. //echo "START: ".date("l dS of F Y H:i:s A",$start_timestamp)."<br />";
  814. //echo "END: ".date("l dS of F Y H:i:s A",$end_timestamp)."<br />";
  815. // this date is the xth day in the week
  816. // if we moved to the next / previous week we have to recalculate the $today variable
  817. /*if ($_GET['week'])
  818. {
  819. $today=mktime(0,0,0,1,1,$year);
  820. $today=$today+(($_GET['week']-1)*(7*24*60*60));
  821. $week_number=date("W",$today);
  822. }*/
  823. // get agenda-items for every course
  824. foreach ($courses_dbs as $key => $array_course_info)
  825. {
  826. //databases of the courses
  827. $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db"]);
  828. $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db"]);
  829. // getting all the groups of the user for the current course
  830. $group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']);
  831. // if the user is administrator of that course we show all the agenda items
  832. if ($array_course_info['status'] == '1')
  833. {
  834. //echo "course admin";
  835. $sqlquery = "SELECT
  836. DISTINCT agenda.*, item_property.*
  837. FROM ".$TABLEAGENDA." agenda,
  838. ".$TABLE_ITEMPROPERTY." item_property
  839. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  840. AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
  841. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  842. AND `item_property`.`visibility`='1'
  843. ORDER BY start_date ".$sort;
  844. }
  845. // if the user is not an administrator of that course
  846. else
  847. {
  848. //echo "GEEN course admin";
  849. if (is_array($group_memberships))
  850. {
  851. $sqlquery = "SELECT
  852. agenda.*, item_property.*
  853. FROM ".$TABLEAGENDA." agenda,
  854. ".$TABLE_ITEMPROPERTY." item_property
  855. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  856. AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
  857. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  858. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id` IN (0, ".implode(", ", $group_memberships).") )
  859. AND `item_property`.`visibility`='1'
  860. ORDER BY start_date ".$sort;
  861. }
  862. else
  863. {
  864. $sqlquery = "SELECT
  865. agenda.*, item_property.*
  866. FROM ".$TABLEAGENDA." agenda,
  867. ".$TABLE_ITEMPROPERTY." item_property
  868. WHERE `agenda`.`id` = `item_property`.`ref` ".$show_all_current."
  869. AND start_date>='".$start_filter."' AND start_date<='".$end_filter."'
  870. AND `item_property`.`tool`='".TOOL_CALENDAR_EVENT."'
  871. AND ( `item_property`.`to_user_id`='".$_user['user_id']."' OR `item_property`.`to_group_id`='0')
  872. AND `item_property`.`visibility`='1'
  873. ORDER BY start_date ".$sort;
  874. }
  875. }
  876. //echo "<pre>".$sqlquery."</pre>";
  877. // $sqlquery = "SELECT * FROM $agendadb WHERE (DAYOFMONTH(day)>='$start_day' AND DAYOFMONTH(day)<='$end_day')
  878. // AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month')
  879. // AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')";
  880. $result = api_sql_query($sqlquery, __FILE__, __LINE__);
  881. while ($item = mysql_fetch_array($result))
  882. {
  883. $agendaday = date("j",strtotime($item['start_date']));
  884. $time= date("H:i",strtotime($item['start_date']));
  885. $URL = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item
  886. $items[$agendaday][$item['start_time']] .= "<i>$time</i> <a href=\"$URL\" title=\"".$array_course_info["name"]."\">".$array_course_info["visual_code"]."</a> ".$item['title']."<br />";
  887. }
  888. }
  889. // sorting by hour for every day
  890. $agendaitems = array ();
  891. while (list ($agendaday, $tmpitems) = each($items))
  892. {
  893. sort($tmpitems);
  894. while (list ($key, $val) = each($tmpitems))
  895. {
  896. $agendaitems[$agendaday] .= $val;
  897. }
  898. }
  899. //print_r($agendaitems);
  900. return $agendaitems;
  901. }
  902. /*============================================================================
  903. show_new_item_form()
  904. ============================================================================*/
  905. // This function shows all the forms that are needed form adding /editing a new personal agenda item
  906. // when there is no $id passed in the function we are adding a new agenda item, if there is a $id
  907. // we are editing
  908. // attention: we have to check that the student is editing an item that belongs to him/her
  909. function show_new_item_form($id = "")
  910. {
  911. global $year, $MonthsLong;
  912. global $tbl_personal_agenda;
  913. global $_user;
  914. // we construct the default time and date data (used if we are not editing a personal agenda item)
  915. $today = getdate();
  916. $day = $today['mday'];
  917. $month = $today['mon'];
  918. $year = $today['year'];
  919. $hours = $today['hours'];
  920. $minutes = $today['minutes'];
  921. // if an $id is passed to this function this means we are editing an item
  922. // we are loading the information here (we do this after everything else
  923. // to overwrite the default information)
  924. if ($id <> "")
  925. {
  926. $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";
  927. $result = api_sql_query($sql, __FILE__, __LINE__);
  928. $aantal = mysql_num_rows($result);
  929. if ($aantal <> 0)
  930. {
  931. $row = mysql_fetch_array($result);
  932. $year = substr($row['date'], 0, 4);
  933. $month = substr($row['date'], 5, 2);
  934. $day = substr($row['date'], 8, 2);
  935. $hours = substr($row['date'], 11, 2);
  936. $minutes = substr($row['date'], 14, 2);
  937. $title = $row['title'];
  938. $text = $row['text'];
  939. }
  940. else
  941. {
  942. return false;
  943. }
  944. }
  945. echo "<form method=\"post\" action=\"myagenda.php?action=add_personal_agenda_item&amp;id=$id\" name=\"newedit_form\">\n";
  946. echo "<table width=\"100%\" id=\"newedit_form\">\n";
  947. echo "\t<tr class=\"title\">\n\t\t<td colspan=\"3\"><h4>";
  948. echo ($_GET['action'] == 'edit_personal_agenda_item') ? get_lang("ModifyPersonalCalendarItem") : get_lang("AddPersonalCalendarItem");
  949. echo "</h4></td>\n\t</tr>\n";
  950. echo "\t<tr class=\"subtitle\">\n\t\t<td>\n";
  951. echo "<!-- date: 1 -> 31 -->\n";
  952. echo "\t\t".get_lang("Date").": \n";
  953. // ********** The form containing the days (0->31) ********** \\
  954. echo "<select name=\"frm_day\">\n";
  955. // small loop for filling all the dates
  956. // 2do: the available dates should be those of the selected month => february is from 1 to 28 (or 29) and not to 31
  957. for ($i = 1; $i <= 31; $i ++)
  958. {
  959. // values have to have double digits
  960. if ($i <= 9)
  961. {
  962. $value = "0".$i;
  963. }
  964. else
  965. {
  966. $value = $i;
  967. }
  968. // the current day is indicated with [] around the date
  969. if ($value == $day)
  970. {
  971. echo "\t\t\t\t <option value=\"".$value."\" selected>".$i."</option>\n";
  972. }
  973. else
  974. {
  975. echo "\t\t\t\t <option value=\"".$value."\">".$i."</option>\n";
  976. }
  977. }
  978. echo "</select>\n\n";
  979. // ********** The form containing the months (jan->dec) ********** \\
  980. echo "<!-- month: january -> december -->\n";
  981. echo "<select name=\"frm_month\">\n";
  982. for ($i = 1; $i <= 12; $i ++)
  983. {
  984. // values have to have double digits
  985. if ($i <= 9)
  986. {
  987. $value = "0".$i;
  988. }
  989. else
  990. {
  991. $value = $i;
  992. }
  993. // the current month is indicated with [] around the month name
  994. if ($value == $month)
  995. {
  996. echo "\t<option value=\"".$value."\" selected>".$MonthsLong[$i -1]."</option>\n";
  997. }
  998. else
  999. {
  1000. echo "\t<option value=\"".$value."\">".$MonthsLong[$i -1]."</option>\n";
  1001. }
  1002. }
  1003. echo "</select>\n\n";
  1004. // ********** The form containing the years ********** \\
  1005. echo "<!-- year -->\n";
  1006. echo "<select name=\"frm_year\">";
  1007. echo "<option value=\"". ($year -1)."\">". ($year -1)."</option>\n";
  1008. echo "<option value=\"".$year."\" selected>".$year."</option>\n";
  1009. for ($i = 1; $i <= 5; $i ++)
  1010. {
  1011. $value = $year + $i;
  1012. echo "\t<option value=\"".$value."\">".$value."</option>\n";
  1013. }
  1014. echo "</select>";
  1015. echo "<a title=\"Kalender\" href=\"javascript:openCalendar('newedit_form', 'frm_')\"><img src=\"../img/calendar_select.gif\" border=\"0\" valign=\"absmiddle\"/></a>";
  1016. echo "</td><td width=\"50%\">";
  1017. // ********** The form containing the hours (00->23) ********** \\
  1018. echo "<!-- time: hour -->\n";
  1019. echo get_lang("Time").": \n";
  1020. echo "<select name=\"frm_hour\">\n";
  1021. for ($i = 1; $i <= 24; $i ++)
  1022. {
  1023. // values have to have double digits
  1024. if ($i <= 9)
  1025. {
  1026. $value = "0".$i;
  1027. }
  1028. else
  1029. {
  1030. $value = $i;
  1031. }
  1032. // the current hour is indicated with [] around the hour
  1033. if ($hours == $value)
  1034. {
  1035. echo "\t\t\t\t<option value=\"".$value."\" selected> ".$value." </option>\n";
  1036. }
  1037. else
  1038. {
  1039. echo "\t\t\t\t<option value=\"".$value."\"> ".$value." </option>\n";
  1040. }
  1041. }
  1042. echo "</select>";
  1043. // ********** The form containing the minutes ********** \\
  1044. echo "<select name=\"frm_minute\">";
  1045. echo "<option value=\"".$minutes."\">".$minutes."</option>";
  1046. echo "<option value=\"00\">00</option>";
  1047. echo "<option value=\"05\">05</option>";
  1048. echo "<option value=\"10\">10</option>";
  1049. echo "<option value=\"15\">15</option>";
  1050. echo "<option value=\"20\">20</option>";
  1051. echo "<option value=\"25\">25</option>";
  1052. echo "<option value=\"30\">30</option>";
  1053. echo "<option value=\"35\">35</option>";
  1054. echo "<option value=\"40\">40</option>";
  1055. echo "<option value=\"45\">45</option>";
  1056. echo "<option value=\"50\">50</option>";
  1057. echo "<option value=\"55\">55</option>";
  1058. echo "</select>";
  1059. echo "</td></tr>";
  1060. // ********** The title field ********** \\
  1061. echo "<tr class=\"subtitle\"><td colspan=\"2\">";
  1062. echo get_lang('Title').': <input type="text" name="frm_title" size="50" value="'.$title.'" />';
  1063. echo "</td></tr>";
  1064. // ********** The text field ********** \\
  1065. echo "<tr><td colspan=\"2\">";
  1066. api_disp_html_area('frm_content', $text, '300px');
  1067. echo "</td></tr>";
  1068. // ********** The Submit button********** \\
  1069. echo "<tr><td colspan=\"2\">";
  1070. echo '<input type="submit" name="Submit" value="'.get_lang('Ok').'" />';
  1071. echo "</td></tr>";
  1072. echo "</table>\n</form>\n";
  1073. }
  1074. /*============================================================================
  1075. store_personal_item($day, $month, $year, $hour, $minute, $course, $title, $content, $id="")
  1076. ============================================================================*/
  1077. // This function shows all the forms that are needed form adding a new personal agenda item
  1078. function store_personal_item($day, $month, $year, $hour, $minute, $title, $content, $id = "")
  1079. {
  1080. global $tbl_personal_agenda;
  1081. global $_user;
  1082. //constructing the date
  1083. $date = $year."-".$month."-".$day." ".$hour.":".$minute.":00";
  1084. if ($id <> "")
  1085. { // we are updating
  1086. $sql = "UPDATE ".$tbl_personal_agenda." SET user='".$_user['user_id']."', title='".$title."', text='".$content."', date='".$date."' WHERE id='".$id."'";
  1087. }
  1088. else
  1089. { // we are adding a new item
  1090. $sql = "INSERT INTO $tbl_personal_agenda (user, title, text, date) VALUES ('".$_user['user_id']."','$title', '$content', '$date')";
  1091. }
  1092. $result = api_sql_query($sql, __FILE__, __LINE__);
  1093. }
  1094. /*============================================================================
  1095. get_courses_of_user()
  1096. ============================================================================*/
  1097. // This function finds all the courses of the user and returns an array containing the
  1098. // database name of the courses.
  1099. function get_courses_of_user()
  1100. {
  1101. global $TABLECOURS;
  1102. global $TABLECOURSUSER;
  1103. global $_user;
  1104. $sql_select_courses = "SELECT course.code k, course.visual_code vc,
  1105. course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status
  1106. FROM $TABLECOURS course,
  1107. $TABLECOURSUSER course_rel_user
  1108. WHERE course.code = course_rel_user.course_code
  1109. AND course_rel_user.user_id = '".$_user['user_id']."'";
  1110. $result = api_sql_query($sql_select_courses);
  1111. while ($row = mysql_fetch_array($result))
  1112. {
  1113. // we only need the database name of the course
  1114. $courses[] = array ("db" => $row['db'], "code" => $row['k'], "visual_code" => $row['vc'], "title" => $row['i'], "directory" => $row['dir'], "status" => $row['status']);
  1115. }
  1116. return $courses;
  1117. }
  1118. /*============================================================================
  1119. get_personal_agendaitems($agendaitems, $month, $year, $day, $week, $type);
  1120. ============================================================================*/
  1121. // This function retrieves all the personal agenda items and add them to the agenda items found by the other functions.
  1122. function get_personal_agendaitems($agendaitems, $day = "", $month = "", $year = "", $week = "", $type)
  1123. {
  1124. global $tbl_personal_agenda;
  1125. global $_user;
  1126. global $_configuration;
  1127. // 1. creating the SQL statement for getting the personal agenda items in MONTH view
  1128. if ($type == "month_view" or $type == "") // we are in month view
  1129. {
  1130. $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' and MONTH(date)='".$month."' AND YEAR(date) = '".$year."' ORDER BY date ASC";
  1131. }
  1132. // 2. creating the SQL statement for getting the personal agenda items in WEEK view
  1133. if ($type == "week_view") // we are in week view
  1134. {
  1135. $start_end_day_of_week = calculate_start_end_of_week($week, $year);
  1136. $start_day = $start_end_day_of_week['start']['day'];
  1137. $start_month = $start_end_day_of_week['start']['month'];
  1138. $start_year = $start_end_day_of_week['start']['year'];
  1139. $end_day = $start_end_day_of_week['end']['day'];
  1140. $end_month = $start_end_day_of_week['end']['month'];
  1141. $end_year = $start_end_day_of_week['end']['year'];
  1142. // in sql statements you have to use year-month-day for date calculations
  1143. $start_filter = $start_year."-".$start_month."-".$start_day;
  1144. $end_filter = $end_year."-".$end_month."-".$end_day;
  1145. $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."'
  1146. AND date>='".$start_filter."' AND date<='".$end_filter."'";
  1147. }
  1148. // 3. creating the SQL statement for getting the personal agenda items in DAY view
  1149. if ($type == "day_view") // we are in day view
  1150. {
  1151. // we could use mysql date() function but this is only available from 4.1 and higher
  1152. $start_filter = $year."-".$month."-".$day." 00:00:01";
  1153. $end_filter = $year."-".$month."-".$day." 23:59:59";
  1154. $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
  1155. }
  1156. //echo "day:".$day."/";
  1157. //echo "month:".$month."/";
  1158. //echo "year:".$year."/";
  1159. //echo "week:".$week."/";
  1160. //echo $type."<p>";
  1161. //echo "<pre>".$sql."</pre>";
  1162. $result = api_sql_query($sql, __FILE__, __LINE__);
  1163. while ($item = mysql_fetch_array($result))
  1164. {
  1165. // we break the date field in the database into a date and a time part
  1166. $agenda_db_date = explode(" ", $item[date]);
  1167. $date = $agenda_db_date[0];
  1168. $time = $agenda_db_date[1];
  1169. // we divide the date part into a day, a month and a year
  1170. $agendadate = explode("-", $date);
  1171. $year = intval($agendadate[0]);
  1172. $month = intval($agendadate[1]);
  1173. $day = intval($agendadate[2]);
  1174. // we divide the time part into hour, minutes, seconds
  1175. $agendatime = explode(":", $time);
  1176. $hour = $agendatime[0];
  1177. $minute = $agendatime[1];
  1178. $second = $agendatime[2];
  1179. // if the student has specified a course we a add a link to that course
  1180. if ($item['course'] <> "")
  1181. {
  1182. $url = $_configuration['root_web']."main/calendar/agenda.php?cidReq=".urlencode($item['course'])."&amp;day=$day&amp;month=$month&amp;year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item
  1183. $course_link = "<a href=\"$url\" title=\"".$item['course']."\">".$item['course']."</a>";
  1184. }
  1185. else
  1186. {
  1187. $course_link = "";
  1188. }
  1189. // Creating the array that will be returned. If we have week or month view we have an array with the date as the key
  1190. // if we have a day_view we use a half hour as index => key 33 = 16h30
  1191. if ($type !== "day_view") // This is the array construction for the WEEK or MONTH view
  1192. {
  1193. $agendaitems[$day] .= "<div><i>$hour:$minute</i> $course_link <a href=\"myagenda.php?action=view&amp;view=personal&amp;day=$day&amp;month=$month&amp;year=$year&amp;id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div>";
  1194. }
  1195. else // this is the array construction for the DAY view
  1196. {
  1197. $halfhour = 2 * $agendatime['0'];
  1198. if ($agendatime['1'] >= '30')
  1199. {
  1200. $halfhour = $halfhour +1;
  1201. }
  1202. $agendaitems[$halfhour] .= "<div><i>$hour:$minute</i> $course_link <a href=\"myagenda.php?action=view&amp;view=personal&amp;day=$day&amp;month=$month&amp;year=$year&amp;id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div>";
  1203. }
  1204. }
  1205. //print_r($agendaitems);
  1206. return $agendaitems;
  1207. }
  1208. /*============================================================================
  1209. show_personal_agenda()
  1210. ============================================================================*/
  1211. // This function retrieves all the personal agenda items of the user and shows
  1212. // these items in one list (ordered by date and grouped by month (the month_bar)
  1213. function show_personal_agenda()
  1214. {
  1215. global $tbl_personal_agenda;
  1216. global $MonthsLong;
  1217. global $_user;
  1218. // The SQL statement that retrieves all the personal agenda items of this user
  1219. $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' ORDER BY date DESC";
  1220. $result = api_sql_query($sql, __FILE__, __LINE__);
  1221. // variable initialisation
  1222. $month_bar = "";
  1223. // starting the table output
  1224. echo "<table id=\"agenda_list\">\n";
  1225. // setting the default day, month and year
  1226. if (!$_GET['day'] AND !$_GET['month'] AND !$_GET['year'])
  1227. {
  1228. $today = getdate();
  1229. $year = $today['year'];
  1230. $month = $today['mon'];
  1231. $day = $today['mday'];
  1232. }
  1233. if (mysql_num_rows($result) > 0)
  1234. {
  1235. while ($myrow = mysql_fetch_array($result))
  1236. {
  1237. /*--------------------------------------------------
  1238. display: the month bar
  1239. --------------------------------------------------*/
  1240. if ($month_bar != date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"])))
  1241. {
  1242. $month_bar = date("m", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]));
  1243. echo "<tr><td class=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."</td></tr>\n";
  1244. }
  1245. // highlight: if a date in the small calendar is clicked we highlight the relevant items
  1246. $db_date = (int) date("d", strtotime($myrow["date"])).date("n", strtotime($myrow["date"])).date("Y", strtotime($myrow["date"]));
  1247. if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date)
  1248. {
  1249. $style = "data";
  1250. $text_style = "text";
  1251. }
  1252. else
  1253. {
  1254. $style = "datanow";
  1255. $text_style = "text";
  1256. }
  1257. /*--------------------------------------------------
  1258. display: date and time
  1259. --------------------------------------------------*/
  1260. echo "\t<tr>\n\t\t";
  1261. echo "<td class=\"".$style."\">";
  1262. // adding an internal anchor
  1263. echo "<a name=\"".$myrow["id"]."\"></a>";
  1264. echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."&nbsp;";
  1265. echo ucfirst(strftime(get_lang("timeNoSecFormat"), strtotime($myrow["date"])));
  1266. echo "</td></tr>";
  1267. /*--------------------------------------------------
  1268. display: the title
  1269. --------------------------------------------------*/
  1270. echo "<tr>";
  1271. echo "<td class=\"".$style."\" colspan='2'>";
  1272. echo $myrow['title'];
  1273. echo "\n\t\t</td colspan='2'>\n\t</tr>\n";
  1274. /*--------------------------------------------------
  1275. display: the content
  1276. --------------------------------------------------*/
  1277. $content = $myrow['text'];
  1278. $content = make_clickable($content);
  1279. $content = text_filter($content);
  1280. echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
  1281. echo $content;
  1282. echo "</td></tr>";
  1283. /*--------------------------------------------------
  1284. display: the edit / delete icons
  1285. --------------------------------------------------*/
  1286. echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
  1287. echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&amp;id=".$myrow['id']."\"><img src=\"../img/edit.gif\" border=\"0\" alt=\"".get_lang('Edit')."\" /></a>";
  1288. echo "<a href=\"".$_SERVER['PHP_SELF']."?action=delete&amp;id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."')) return false;\"><img src=\"../img/delete.gif\" border=\"0\" alt=\"".get_lang('Delete')."\" /></a>";
  1289. echo "</td></tr>";
  1290. }
  1291. }
  1292. else
  1293. {
  1294. echo '<tr><td colspan="2">'.get_lang('NoAgendaItems').'</td></tr>';
  1295. }
  1296. echo "</table>\n";
  1297. }
  1298. /*============================================================================
  1299. delete_personal_agenda($id)
  1300. ============================================================================*/
  1301. // This function deletes a personal agenda item
  1302. // There is an additional check to make sure that one cannot delete an item that
  1303. // does not belong to him/her
  1304. function delete_personal_agenda($id)
  1305. {
  1306. global $tbl_personal_agenda;
  1307. global $_user;
  1308. if ($id <> '')
  1309. {
  1310. $sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";
  1311. $result = api_sql_query($sql, __FILE__, __LINE__);
  1312. $aantal = mysql_num_rows($result);
  1313. if ($aantal <> 0)
  1314. {
  1315. $sql = "DELETE FROM ".$tbl_personal_agenda." WHERE user='".$_user['user_id']."' AND id='".$id."'";
  1316. $result = api_sql_query($sql, __FILE__, __LINE__);
  1317. }
  1318. }
  1319. }
  1320. /*============================================================================
  1321. calculate_start_end_of_week($week_number, $year)
  1322. ============================================================================*/
  1323. // This function calculates the startdate of the week (monday)
  1324. // and the enddate of the week (sunday)
  1325. // and returns it as an array
  1326. function calculate_start_end_of_week($week_number, $year)
  1327. {
  1328. // determine the start and end date
  1329. // step 1: we calculate a timestamp for a day in this week
  1330. $random_day_in_week = mktime(0, 0, 0, 1, 1, $year) + ($week_number) * (7 * 24 * 60 * 60); // we calculate a random day in this week
  1331. // step 2: we which day this is (0=sunday, 1=monday, ...)
  1332. $number_day_in_week = date('w', $random_day_in_week);
  1333. // step 3: we calculate the timestamp of the monday of the week we are in
  1334. $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60);
  1335. // step 4: we calculate the timestamp of the sunday of the week we are in
  1336. $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600;
  1337. // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year
  1338. $start_day = date('j', $start_timestamp);
  1339. $start_month = date('n', $start_timestamp);
  1340. $start_year = date('Y', $start_timestamp);
  1341. $end_day = date('j', $end_timestamp);
  1342. $end_month = date('n', $end_timestamp);
  1343. $end_year = date('Y', $end_timestamp);
  1344. $start_end_array['start']['day'] = $start_day;
  1345. $start_end_array['start']['month'] = $start_month;
  1346. $start_end_array['start']['year'] = $start_year;
  1347. $start_end_array['end']['day'] = $end_day;
  1348. $start_end_array['end']['month'] = $end_month;
  1349. $start_end_array['end']['year'] = $end_year;
  1350. return $start_end_array;
  1351. }
  1352. ?>