示例#1
0
function organizer_add_calendar()
{
    global $PAGE, $DB;
    $courseid = optional_param('course', SITEID, PARAM_INT);
    if ($courseid != SITEID && !empty($courseid)) {
        $course = $DB->get_record('course', array('id' => $courseid));
        $courses = array($course->id => $course);
        $issite = false;
    } else {
        $course = get_site();
        $courses = calendar_get_default_courses();
        $issite = true;
    }
    $now = usergetdate(time());
    $calendar = new calendar_information($now['mday'], $now['mon'], $now['year']);
    $calendar->prepare_for_view($course, $courses);
    $renderer = $PAGE->get_renderer('core_calendar');
    $calendar->add_sidecalendar_blocks($renderer, true, 'month');
    $PAGE->requires->js_init_call('M.mod_organizer.fix_calendar_styles');
}
示例#2
0
        break;
    case 'month':
        $PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
        $pagetitle = get_string('detailedmonthview', 'calendar');
        break;
    case 'upcoming':
        $pagetitle = get_string('upcomingevents', 'calendar');
        break;
}
// Print title and header
$PAGE->set_pagelayout('standard');
$PAGE->set_title("{$course->shortname}: {$strcalendar}: {$pagetitle}");
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_button(calendar_preferences_button($course));
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer, true, $view);
echo $OUTPUT->header();
echo $renderer->start_layout();
echo html_writer::start_tag('div', array('class' => 'heightcontainer'));
switch ($view) {
    case 'day':
        echo $renderer->show_day($calendar);
        break;
    case 'month':
        echo $renderer->show_month_detailed($calendar);
        break;
    case 'upcoming':
        $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
        if (isset($CFG->calendar_lookahead)) {
            $defaultlookahead = intval($CFG->calendar_lookahead);
        }
示例#3
0
$PAGE->set_url($url);
$calendar = new calendar_information(0, 0, 0, $time);
$calendar->prepare_for_view($course, $courses);
$pagetitle = get_string('export', 'calendar');
// Print title and header
if ($issite) {
    $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)));
}
$link = new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'upcoming', 'course' => $calendar->courseid));
$PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, 0, 0, 0, $time));
$PAGE->navbar->add($pagetitle);
$PAGE->set_title($course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $pagetitle);
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('standard');
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer);
// Get the calendar type we are using.
$calendartype = \core_calendar\type_factory::get_calendar_instance();
$now = $calendartype->timestamp_to_date_array($time);
$weekend = CALENDAR_DEFAULT_WEEKEND;
if (isset($CFG->calendar_weekend)) {
    $weekend = intval($CFG->calendar_weekend);
}
$numberofdaysinweek = $calendartype->get_num_weekdays();
$formdata = array('allownextweek' => $weekend & 1 << $now['wday'], 'allownextmonth' => calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < $numberofdaysinweek, 'allowthisweek' => !($weekend & 1 << $now['wday'] && !($weekend & 1 << ($now['wday'] + 1) % $numberofdaysinweek)));
$exportform = new core_calendar_export_form(null, $formdata);
$calendarurl = '';
if ($data = $exportform->get_data()) {
    $password = $DB->get_record('user', array('id' => $USER->id), 'password');
    $params = array();
    $params['userid'] = $USER->id;