Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/calendar/export.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 
00049 require_once('../config.php');
00050 require_once($CFG->dirroot.'/course/lib.php');
00051 require_once($CFG->dirroot.'/calendar/lib.php');
00052 
00053 if (empty($CFG->enablecalendarexport)) {
00054     die('no export');
00055 }
00056 
00057 $courseid = optional_param('course', SITEID, PARAM_INT);
00058 $action = optional_param('action', '', PARAM_ALPHA);
00059 $day  = optional_param('cal_d', 0, PARAM_INT);
00060 $mon  = optional_param('cal_m', 0, PARAM_INT);
00061 $yr   = optional_param('cal_y', 0, PARAM_INT);
00062 $generateurl = optional_param('generateurl', 0, PARAM_BOOL);
00063 
00064 if ($courseid != SITEID && !empty($courseid)) {
00065     $course = $DB->get_record('course', array('id' => $courseid));
00066     $courses = array($course->id => $course);
00067     $issite = false;
00068 } else {
00069     $course = get_site();
00070     $courses = calendar_get_default_courses();
00071     $issite = true;
00072 }
00073 require_course_login($course);
00074 
00075 $url = new moodle_url('/calendar/export.php');
00076 if ($action !== '') {
00077     $url->param('action', $action);
00078 }
00079 if ($day !== 0) {
00080     $url->param('cal_d', $day);
00081 }
00082 if ($mon !== 0) {
00083     $url->param('cal_m', $mon);
00084 }
00085 if ($yr !== 0) {
00086     $url->param('cal_y', $yr);
00087 }
00088 if ($course !== NULL) {
00089     $url->param('course', $course->id);
00090 }
00091 $PAGE->set_url($url);
00092 
00093 $calendar = new calendar_information($day, $mon, $yr);
00094 $calendar->prepare_for_view($course, $courses);
00095 
00096 $pagetitle = get_string('export', 'calendar');
00097 $now = usergetdate(time());
00098 
00099 // Print title and header
00100 if ($issite) {
00101     $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
00102 }
00103 $link = new moodle_url(CALENDAR_URL.'view.php', array('view'=>'upcoming', 'course'=>$calendar->courseid));
00104 $PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, $now['mday'], $now['mon'], $now['year']));
00105 $PAGE->navbar->add($pagetitle);
00106 
00107 $PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle);
00108 $PAGE->set_heading($course->fullname);
00109 $PAGE->set_button(calendar_preferences_button($course));
00110 $PAGE->set_pagelayout('standard');
00111 
00112 $renderer = $PAGE->get_renderer('core_calendar');
00113 $calendar->add_sidecalendar_blocks($renderer);
00114 
00115 echo $OUTPUT->header();
00116 echo $renderer->start_layout();
00117 switch($action) {
00118     case 'advanced':
00119         // Why nothing?
00120         break;
00121     case '':
00122     default:
00123         $weekend = CALENDAR_DEFAULT_WEEKEND;
00124         if (isset($CFG->calendar_weekend)) {
00125             $weekend = intval($CFG->calendar_weekend);
00126         }
00127 
00128         $authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
00129         // Let's populate some vars to let "common tasks" be somewhat smart...
00130         // If today it's weekend, give the "next week" option
00131         $allownextweek  = $weekend & (1 << $now['wday']);
00132         // If it's the last week of the month, give the "next month" option
00133         $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
00134         // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
00135         $allowthisweek  = !(($weekend & (1 << $now['wday'])) && !($weekend & (1 << (($now['wday'] + 1) % 7))));
00136         echo $renderer->basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $USER->id, $authtoken);
00137         break;
00138 }
00139 
00140 if (!empty($generateurl)) {
00141     $params['userid']      = optional_param('userid', 0, PARAM_INT);
00142     $params['authtoken']   = optional_param('authtoken', '', PARAM_ALPHANUM);
00143     $params['preset_what'] = optional_param('preset_what', 'all', PARAM_ALPHA);
00144     $params['preset_time'] = optional_param('preset_time', 'weeknow', PARAM_ALPHA);
00145 
00146     $link = new moodle_url('/calendar/export_execute.php', $params);
00147     print html_writer::tag('div', get_string('calendarurl', 'calendar', $link->out()), array('class' => 'generalbox calendarurl'));
00148 }
00149 
00150 echo $renderer->complete_layout();
00151 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations