Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/calendar/view.php
Go to the documentation of this file.
00001 <?php
00002 
00004 //                                                                         //
00005 // NOTICE OF COPYRIGHT                                                     //
00006 //                                                                         //
00007 // Moodle - Calendar extension                                             //
00008 //                                                                         //
00009 // Copyright (C) 2003-2004  Greek School Network            www.sch.gr     //
00010 //                                                                         //
00011 // Designed by:                                                            //
00012 //     Avgoustos Tsinakos (tsinakos@teikav.edu.gr)                         //
00013 //     Jon Papaioannou (pj@moodle.org)                                     //
00014 //                                                                         //
00015 // Programming and development:                                            //
00016 //     Jon Papaioannou (pj@moodle.org)                                     //
00017 //                                                                         //
00018 // For bugs, suggestions, etc contact:                                     //
00019 //     Jon Papaioannou (pj@moodle.org)                                     //
00020 //                                                                         //
00021 // The current module was developed at the University of Macedonia         //
00022 // (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
00023 // The aim of this project is to provide additional and improved           //
00024 // functionality to the Asynchronous Distance Education service that the   //
00025 // Greek School Network deploys.                                           //
00026 //                                                                         //
00027 // This program is free software; you can redistribute it and/or modify    //
00028 // it under the terms of the GNU General Public License as published by    //
00029 // the Free Software Foundation; either version 2 of the License, or       //
00030 // (at your option) any later version.                                     //
00031 //                                                                         //
00032 // This program is distributed in the hope that it will be useful,         //
00033 // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
00034 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
00035 // GNU General Public License for more details:                            //
00036 //                                                                         //
00037 //          http://www.gnu.org/copyleft/gpl.html                           //
00038 //                                                                         //
00040 
00041 //  Display the calendar page.
00042 
00043 require_once('../config.php');
00044 require_once($CFG->dirroot.'/course/lib.php');
00045 require_once($CFG->dirroot.'/calendar/lib.php');
00046 
00047 $courseid = optional_param('course', SITEID, PARAM_INT);
00048 $view = optional_param('view', 'upcoming', PARAM_ALPHA);
00049 $day  = optional_param('cal_d', 0, PARAM_INT);
00050 $mon  = optional_param('cal_m', 0, PARAM_INT);
00051 $yr   = optional_param('cal_y', 0, PARAM_INT);
00052 
00053 $url = new moodle_url('/calendar/view.php');
00054 if ($courseid != SITEID) {
00055     $url->param('course', $courseid);
00056 }
00057 if ($view !== 'upcoming') {
00058     $url->param('view', $view);
00059 }
00060 if ($day !== 0) {
00061     $url->param('cal_d', $day);
00062 }
00063 if ($mon !== 0) {
00064     $url->param('cal_m', $mon);
00065 }
00066 if ($yr !== 0) {
00067     $url->param('cal_y', $yr);
00068 }
00069 $PAGE->set_url($url);
00070 
00071 if ($courseid != SITEID && !empty($courseid)) {
00072     $course = $DB->get_record('course', array('id' => $courseid));
00073     $courses = array($course->id => $course);
00074     $issite = false;
00075     navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
00076 } else {
00077     $course = get_site();
00078     $courses = calendar_get_default_courses();
00079     $issite = true;
00080 }
00081 require_course_login($course);
00082 
00083 $calendar = new calendar_information($day, $mon, $yr);
00084 $calendar->prepare_for_view($course, $courses);
00085 
00086 $now = usergetdate(time());
00087 $pagetitle = '';
00088 
00089 $strcalendar = get_string('calendar', 'calendar');
00090 
00091 if (!checkdate($mon, $day, $yr)) {
00092     $day = intval($now['mday']);
00093     $mon = intval($now['mon']);
00094     $yr = intval($now['year']);
00095 }
00096 $time = make_timestamp($yr, $mon, $day);
00097 
00098 switch($view) {
00099     case 'day':
00100         $PAGE->navbar->add(userdate($time, get_string('strftimedate')));
00101         $pagetitle = get_string('dayview', 'calendar');
00102     break;
00103     case 'month':
00104         $PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
00105         $pagetitle = get_string('detailedmonthview', 'calendar');
00106     break;
00107     case 'upcoming':
00108         $pagetitle = get_string('upcomingevents', 'calendar');
00109     break;
00110 }
00111 
00112 // Print title and header
00113 $PAGE->set_pagelayout('standard');
00114 $PAGE->set_title("$course->shortname: $strcalendar: $pagetitle");
00115 $PAGE->set_heading($COURSE->fullname);
00116 $PAGE->set_button(calendar_preferences_button($course));
00117 
00118 $renderer = $PAGE->get_renderer('core_calendar');
00119 $calendar->add_sidecalendar_blocks($renderer, true, $view);
00120 
00121 echo $OUTPUT->header();
00122 echo $renderer->start_layout();
00123 echo html_writer::start_tag('div', array('class'=>'heightcontainer'));
00124 
00125 switch($view) {
00126     case 'day':
00127         echo $renderer->show_day($calendar);
00128     break;
00129     case 'month':
00130         echo $renderer->show_month_detailed($calendar);
00131     break;
00132     case 'upcoming':
00133         $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
00134         if (isset($CFG->calendar_lookahead)) {
00135             $defaultlookahead = intval($CFG->calendar_lookahead);
00136         }
00137         $lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
00138 
00139         $defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
00140         if (isset($CFG->calendar_maxevents)) {
00141             $defaultmaxevents = intval($CFG->calendar_maxevents);
00142         }
00143         $maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
00144         echo $renderer->show_upcoming_events($calendar, $lookahead, $maxevents);
00145     break;
00146 }
00147 
00148 //Link to calendar export page
00149 echo $OUTPUT->container_start('bottom');
00150 if (!empty($CFG->enablecalendarexport)) {
00151     echo $OUTPUT->single_button(new moodle_url('export.php', array('course'=>$courseid)), get_string('exportcalendar', 'calendar'));
00152     if (isloggedin()) {
00153         $authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
00154         $link = new moodle_url('/calendar/export_execute.php', array('preset_what'=>'all', 'preset_time'=>'recentupcoming', 'userid' => $USER->id, 'authtoken'=>$authtoken));
00155         $icon = html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/ical'), 'height'=>'14', 'width'=>'36', 'alt'=>get_string('ical', 'calendar'), 'title'=>get_string('quickdownloadcalendar', 'calendar')));
00156         echo html_writer::tag('a', $icon, array('href'=>$link));
00157     }
00158 }
00159 
00160 echo $OUTPUT->container_end();
00161 echo html_writer::end_tag('div');
00162 echo $renderer->complete_layout();
00163 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations