dokeos
[ class tree: dokeos ] [ index: dokeos ] [ all elements ]

Source for file agenda.php

Documentation is available at agenda.php

  1. <?php //$Id: agenda.php 15372 2008-05-23 10:29:42Z yannoo $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004-2008 Dokeos SPRL
  7.     Copyright (c) 2003-2005 Ghent University (UGent)
  8.     Copyright (c) various contributors
  9.  
  10.     For a full list of contributors, see "credits.txt".
  11.     The full license can be read in "license.txt".
  12.  
  13.     This program is free software; you can redistribute it and/or
  14.     modify it under the terms of the GNU General Public License
  15.     as published by the Free Software Foundation; either version 2
  16.     of the License, or (at your option) any later version.
  17.  
  18.     See the GNU General Public License for more details.
  19.  
  20.     Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  21.     Mail: info@dokeos.com
  22. ==============================================================================
  23. */
  24. /*
  25. ==============================================================================
  26.        INIT SECTION
  27. ==============================================================================
  28. */
  29. // name of the language file that needs to be included
  30. $language_file array('agenda','resourcelinker');
  31.  
  32. // use anonymous mode when accessing this course tool
  33. $use_anonymous true;
  34.  
  35. // setting the global file that gets the general configuration, the databases, the languages, ...
  36. include('../inc/global.inc.php');
  37.  
  38. //session
  39. if(isset($_GET['id_session']))
  40. {
  41.     $_SESSION['id_session'$_GET['id_session'];
  42. }
  43.  
  44. $this_section=SECTION_COURSES;
  45.  
  46. //error_reporting(E_ALL);
  47. require (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  48.  
  49. /* ==============================================================================
  50.               ACCESS RIGHTS
  51. ============================================================================== */
  52. // notice for unauthorized people.
  53.  
  54. /*
  55. -----------------------------------------------------------
  56.     Resource linker (Patrick Cool, march 2004)
  57. -----------------------------------------------------------
  58. */
  59. $_SESSION['source_type''Agenda';
  60. include('../resourcelinker/resourcelinker.inc.php');
  61. if (!empty($addresources)) // When the "Add Resource" button is clicked we store all the form data into a session
  62. {
  63. $form_elementsarray ('day'=>$_POST['fday']'month'=>$_POST['fmonth']'year'=>$_POST['fyear']'hour'=>$_POST['fhour']'minutes'=>$_POST['fminute'],
  64.                         'end_day'=>$_POST['end_fday']'end_month'=>$_POST['end_fmonth']'end_year'=>$_POST['end_fyear']'end_hours'=>$_POST['end_fhour']'end_minutes'=>$_POST['end_fminute'],
  65.                         'title'=>stripslashes($_POST['title'])'content'=>stripslashes($_POST['content'])'id'=>$_POST['id']'action'=>$_POST['action']'to'=>$_POST['selectedform']);
  66. $_SESSION['formelements']=$form_elements;
  67. if($id// this is to correctly handle edits
  68.     {$action="edit";}
  69. //print_r($form_elements);
  70. header('Location: '.api_get_path(WEB_CODE_PATH)."resourcelinker/resourcelinker.php?source_id=1&action=$action&id=$id&originalresource=no");
  71. exit;
  72. }
  73.  
  74. if (!empty($_GET['view']))
  75. {
  76.     $_SESSION['view'$_GET['view'];
  77. }
  78.  
  79. /*
  80. -----------------------------------------------------------
  81.     Libraries
  82. -----------------------------------------------------------
  83. */
  84. // containing the functions for the agenda tool
  85. include "agenda.inc.php";
  86. // some debug functions
  87. include($includePath."/lib/debug.lib.inc.php");
  88.  
  89. /*==============================================================================
  90.               TREATING THE PARAMETERS
  91.             1. viewing month only or everything
  92.             2. sort ascending or descending
  93.             3. showing or hiding the send-to-specific-groups-or-users form
  94.             4. filter user or group
  95.   ============================================================================== */
  96. // 1. show all or show current month?
  97. if (!$_SESSION['show'])
  98. {
  99.     $_SESSION['show']="showall";
  100. }
  101. if (!empty($_GET['action']and $_GET['action']=="showcurrent")
  102. {
  103.     $_SESSION['show']="showcurrent";
  104. }
  105. if (!empty($_GET['action']and $_GET['action']=="showall")
  106. {
  107.     $_SESSION['show']="showall";
  108. }
  109. //echo $_SESSION['show'];
  110.  
  111. // 2. sorting order (ASC or DESC)
  112. if (empty($_GET['sort']and empty($_SESSION['sort']))
  113. {
  114.     $_SESSION['sort']="DESC";
  115. }
  116. if (!empty($_GET['sort']and $_GET['sort']=="asc")
  117. {
  118.     $_SESSION['sort']="ASC";
  119. }
  120. if (!empty($_GET['sort']and $_GET['sort']=="desc")
  121. {
  122.     $_SESSION['sort']="DESC";
  123. }
  124.  
  125. // 3. showing or hiding the send-to-specific-groups-or-users form
  126. $setting_allow_individual_calendar=true;
  127. if (empty($_POST['To']and empty($_SESSION['allow_individual_calendar']))
  128. {
  129.     $_SESSION['allow_individual_calendar']="hide";
  130. }
  131. $allow_individual_calendar_status=$_SESSION['allow_individual_calendar'];
  132. if (!empty($_POST['To']and ($allow_individual_calendar_status=="hide"))
  133. {
  134.     $_SESSION['allow_individual_calendar']="show";
  135. }
  136. if (!empty($_GET['sort']and ($allow_individual_calendar_status=="show"))
  137. {
  138.     $_SESSION['allow_individual_calendar']="hide";
  139. }
  140.  
  141. // 4. filter user or group
  142. if (!empty($_GET['user']or !empty($_GET['group']))
  143. {
  144.     $_SESSION['user']=(int)$_GET['user'];
  145.     $_SESSION['group']=(int)$_GET['group'];
  146. }
  147. if ((!empty($_GET['user']and $_GET['user']=="none"or (!empty($_GET['group']and $_GET['group']=="none"))
  148. {
  149.     api_session_unregister("user");
  150.     api_session_unregister("group");
  151.     }
  152. if (!$is_courseAdmin){
  153.     if (!empty($_GET['toolgroup'])){
  154.         //$_SESSION['toolgroup']=$_GET['toolgroup'];
  155.         $toolgroup=$_GET['toolgroup'];
  156.         api_session_register('toolgroup');
  157.         }
  158.     }
  159.     //It comes from the group tools. If it's define it overwrites $_SESSION['group']
  160. if (!empty($_GET['isStudentView']and $_GET['isStudentView']=="false")
  161. {
  162.     api_session_unregister("user");
  163.     api_session_unregister("group");
  164. }
  165.  
  166. $htmlHeadXtra[to_javascript();
  167.  
  168. $htmlHeadXtra[user_group_filter_javascript();
  169. // this loads the javascript that is needed for the date popup selection
  170. $htmlHeadXtra["<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
  171.  
  172. // setting the name of the tool
  173. $nameTools get_lang('Agenda')// language variable in trad4all.inc.php
  174.  
  175. // showing the header if we are not in the learning path, if we are in
  176. // the learning path, we do not include the banner so we have to explicitly
  177. // include the stylesheet, which is normally done in the header
  178. if (empty($_GET['origin']or $_GET['origin'!= 'learnpath')
  179. {
  180.     Display::display_header($nameTools,'Agenda');
  181. }
  182. else
  183. {
  184.     echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$clarolineRepositoryWeb."css/default.css\"/>";
  185.     }
  186.  
  187. /* ==============================================================================
  188.               TRACKING
  189. ==============================================================================  */
  190. include('../inc/lib/events.lib.inc.php');
  191.  
  192. /* ==============================================================================
  193.               SETTING SOME VARIABLES
  194. ============================================================================== */
  195. // Variable definitions
  196. $dateNow             format_locale_date($dateTimeFormatLong);
  197. // Defining the shorts for the days. We use camelcase because these are arrays of language variables
  198. $DaysShort array (get_lang("SundayShort")get_lang("MondayShort")get_lang("TuesdayShort")get_lang("WednesdayShort")get_lang("ThursdayShort")get_lang("FridayShort")get_lang("SaturdayShort"));
  199. // Defining the days of the week to allow translation of the days. We use camelcase because these are arrays of language variables
  200. $DaysLong array (get_lang("SundayLong")get_lang("MondayLong")get_lang("TuesdayLong")get_lang("WednesdayLong")get_lang("ThursdayLong")get_lang("FridayLong")get_lang("SaturdayLong"));
  201. // Defining the months of the year to allow translation of the months. We use camelcase because these are arrays of language variables
  202. $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"));
  203.  
  204. // Database table definitions
  205. $TABLEAGENDA             Database::get_course_table(TABLE_AGENDA);
  206. $TABLE_ITEM_PROPERTY     Database::get_course_table(TABLE_ITEM_PROPERTY);
  207. $tbl_user               Database::get_main_table(TABLE_MAIN_USER);
  208. $tbl_courseUser         Database::get_main_table(TABLE_MAIN_COURSE_USER);
  209. $tbl_group              Database::get_course_table(TABLE_GROUP);
  210. $tbl_groupUser          Database::get_course_table(TABLE_GROUP_USER);
  211.  
  212.  
  213.  
  214. /* ==============================================================================
  215.               ACCESS RIGHTS
  216. ============================================================================== */
  217. // permission stuff - also used by loading from global in agenda.inc.php
  218. $is_allowed_to_edit is_allowed_to_edit(OR (api_get_course_setting('allow_user_edit_agenda'&& !api_is_anonymous());
  219.  
  220. /* ==============================================================================
  221.               TITLE
  222. ============================================================================== */
  223. // Displaying the title of the tool
  224. //api_display_tool_title($nameTools);
  225.  
  226. // tool introduction
  227.  
  228. // insert an anchor (top) so one can jump back to the top of the page
  229. echo "<a name=\"top\"></a>";
  230.  
  231. /*
  232. ==============================================================================
  233.         MAIN SECTION
  234. ==============================================================================
  235. */
  236.  
  237. //setting the default year and month
  238. $select_year '';
  239. $select_month '';
  240. if(!empty($_GET['year']))
  241. {
  242.     $select_year = (int)$_GET['year'];
  243. }
  244. if(!empty($_GET['month']))
  245. {
  246.     $select_month = (int)$_GET['month'];
  247. }
  248. if (empty($select_year&& empty($select_month))
  249. {
  250.     $today getdate();
  251.     $select_year $today['year'];
  252.     $select_month $today['mon'];
  253. }
  254.  
  255. echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
  256.         . '<tr>';
  257.  
  258. // THE LEFT PART
  259. if (empty($_GET['origin']or $_GET['origin']!='learnpath')
  260. {
  261.     echo '<td width="220" height="19" valign="top">';
  262.     // the small calendar
  263.     $MonthName $MonthsLong[$select_month -1];
  264.     $agenda_items=get_calendar_items($select_month,$select_year);
  265.     if (api_get_setting('display_mini_month_calendar'== 'true')
  266.     {
  267.         display_minimonthcalendar($agenda_items$select_month,$select_year$MonthName);
  268.     }
  269.     if (api_get_setting('display_upcoming_events'== 'true')
  270.     {
  271.         display_upcoming_events();
  272.     }
  273.     // the links for adding, filtering, showall, ...
  274.     echo '<ul id="agenda_select">';
  275.     if (is_allowed_to_edit(OR (api_get_course_setting('allow_user_edit_agenda'&& !api_is_anonymous()))
  276.     {
  277.         display_courseadmin_links();
  278.     }
  279.     echo '</ul>';
  280.     echo '</td>';
  281.     echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>';
  282. }
  283.  
  284. $fck_attribute['Width''600';
  285. $fck_attribute['Height''400';
  286. $fck_attribute['ToolbarSet''Middle';
  287.  
  288.  
  289. // THE RIGHT PART
  290. echo "<td valign=\"top\">";
  291.  
  292. if (is_allowed_to_edit(OR (api_get_course_setting('allow_user_edit_agenda'&& !api_is_anonymous()))
  293. {
  294.     switch ($_GET['action'])
  295.     {
  296.         case 'add':
  297.             if(!empty($_POST['ical_submit']))
  298.             {
  299.                 $course_info api_get_course_info();
  300.                 agenda_import_ical($course_info,$_FILES['ical_import']);                
  301.                 display_agenda_items();
  302.             }
  303.             elseif ($_POST['submit_event'])
  304.             {
  305.              $course_info api_get_course_info();
  306.                 $event_start    = (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00';
  307.                 $event_stop     = (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00';
  308.                 $id agenda_add_item($course_info,$_POST['title'],$_POST['content'],$event_start,$event_stop,$_POST['selectedform']);
  309.                 if(!empty($_POST['repeat']))
  310.                 {
  311.                     $end_y intval($_POST['repeat_end_year']);
  312.                     $end_m intval($_POST['repeat_end_month']);
  313.                     $end_d intval($_POST['repeat_end_day']);
  314.                     $end   mktime(235959$end_m$end_d$end_y);
  315.                     $res agenda_add_repeat_item($course_info,$id,$_POST['repeat_type'],$end,$event_start,$event_stop,$_POST['selectedform']);
  316.                 }
  317.                 display_agenda_items();
  318.             }
  319.             else
  320.             {
  321.                 show_add_form();
  322.             }
  323.             break;
  324.  
  325.         case "edit":
  326.             if ($_POST['submit_event'])
  327.             {
  328.                     store_edited_agenda_item();
  329.                     display_agenda_items();
  330.             }
  331.             else
  332.             {
  333.                     $id=(int)$_GET['id'];
  334.                     show_add_form($id);
  335.             }
  336.             break;
  337.  
  338.         case "delete":
  339.             $id=(int)$_GET['id'];
  340.             delete_agenda_item($id);
  341.             display_agenda_items();
  342.             break;
  343.  
  344.         case "showhide":
  345.             $id=(int)$_GET['id'];
  346.             showhide_agenda_item($id);
  347.             display_agenda_items();
  348.             break;
  349.         case "announce"//copying the agenda item into an announcement
  350.             $id=(int)$_GET['id'];
  351.             $ann_id store_agenda_item_as_announcement($id);
  352.             $tool_group_link (isset($_SESSION['toolgroup'])?'&toolgroup='.$_SESSION['toolgroup']:'');
  353.             Display::display_normal_message(get_lang('CopiedAsAnnouncement').'<a href="../announcements/announcements.php?id='.$ann_id.$tool_group_link.'">'.get_lang('NewAnnouncement').'</a>'false);
  354.             display_agenda_items();
  355.     }
  356. }
  357.  
  358. // this is for students and whenever the courseaministrator has not chosen any action. It is in fact the default behaviour
  359. if (!$_GET['action'OR $_GET['action']=="showall"  OR $_GET['action']=="showcurrent" OR $_GET['action']=="view")
  360. {
  361.     if ($_GET['origin'!= 'learnpath')
  362.     {
  363.         if (!$_SESSION['view'OR $_SESSION['view'<> 'month')
  364.         {
  365.             if(!empty($_GET['agenda_id']))
  366.             {
  367.                  display_one_agenda_item((int)$_GET['agenda_id']);   
  368.             }
  369.             else
  370.             {
  371.                  display_agenda_items();
  372.             }
  373.         }
  374.         else
  375.         {
  376.             display_monthcalendar($select_month$select_year);
  377.         }
  378.     }
  379.     else
  380.     {
  381.         display_one_agenda_item((int)$_GET['agenda_id']);
  382.     }
  383. }
  384. echo "&nbsp;</td></tr></table>";
  385.  
  386. /*
  387. ==============================================================================
  388.         FOOTER
  389. ==============================================================================
  390. */
  391. // The footer is displayed only if we are not in the learnpath
  392. if ($_GET['origin'!= 'learnpath')
  393. {
  394. }
  395. ?>

Documentation generated on Thu, 12 Jun 2008 12:56:36 -0500 by phpDocumentor 1.4.1