Skip to content

Commit

Permalink
calendar MDL-22887 Output is now through a renderer, all pages have n…
Browse files Browse the repository at this point in the history
…avigation, and now uses true pretend blocks.
  • Loading branch information
Sam Hemelryk committed Jun 22, 2010
1 parent de83270 commit 36dc3b7
Show file tree
Hide file tree
Showing 18 changed files with 1,052 additions and 933 deletions.
11 changes: 0 additions & 11 deletions blocks/calendar_month/styles.css

This file was deleted.

Empty file.
23 changes: 23 additions & 0 deletions calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,28 @@ M.core_calendar = {
if (M.core_calendar.showdelayevent !== null) {
M.core_calendar.events[M.core_calendar.showdelayevent].show();
}
},
init_basic_export : function(Y, allowthisweek, allownextweek, allownextmonth, username, authtoken) {
Y.one('#generateurl').on('click', function(){
var presetwhat = 'all';
if (Y.one('#pw_course').get('checked')) {
presetwhat = 'courses';
}

var presettime = 'recentupcoming';
if (allowthisweek && Y.one('#pt_wknow').get('checked')) {
presettime = 'weeknow';
} else if (allownextweek && Y.one('#pt_wknext').get('checked')) {
presettime = 'weeknext';
} else if (allownextmonth && Y.one('#pt_monnext').get('checked')) {
presettime = 'monthnext';
} else if (Y.one('#pt_monnow').get('checked')) {
presettime = 'monthnow';
}

var urlstr = M.cfg.wwwroot+'/calendar/export_execute.php?preset_what='+presetwhat+'&preset_time='+presettime+'&username='+username+'&authtoken='+authtoken;
Y.one('#url').setContent(urlstr);
Y.one('#urlbox').setStyle('display', 'block');
}, this);
}
}
1 change: 0 additions & 1 deletion calendar/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
$PAGE->navbar->add($title);
$PAGE->set_title($site->shortname.': '.$strcalendar.': '.$title);
$PAGE->set_heading($COURSE->fullname);

echo $OUTPUT->header();
echo $OUTPUT->box_start('eventlist');

Expand Down
72 changes: 21 additions & 51 deletions calendar/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
if ($cal_m !== 0) $url->param('cal_m', $cal_m);
if ($cal_d !== 0) $url->param('cal_d', $cal_d);
$PAGE->set_url($url);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_pagelayout('standard');

if ($action === 'delete' && $eventid>0) {
$deleteurl = new moodle_url('/calendar/delete.php', array('id'=>$eventid));
Expand Down Expand Up @@ -121,6 +123,9 @@

require_login($course, false);

$calendar = new calendar_information($cal_d, $cal_m, $cal_y);
$calendar->courseid = $courseid;

$strcalendar = get_string('calendar', 'calendar');
$link = clone($viewcalendarurl);
$link->param('view', 'upcoming');
Expand All @@ -132,16 +137,16 @@
$event = calendar_event::load($eventid);
if (!calendar_edit_event_allowed($event)) {
print_error('nopermissions');
}
}
$event->action = $action;
$event->course = $courseid;
$event->timedurationuntil = $event->timestart + $event->timeduration;
$event->count_repeats();

if (!calendar_add_event_allowed($event)) {
print_error('nopermissions');
}
} else {
}
} else {
$title = get_string('newevent', 'calendar');
calendar_get_allowed_types($formoptions->eventtypes, $USER->id);
$event = new calendar_event();
Expand All @@ -156,22 +161,20 @@
unset($formoptions->eventtypes->courses);
unset($formoptions->eventtypes->groups);
}
}

if($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) {
}
if($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) {
$event->timestart = make_timestamp($cal_y, $cal_m, $cal_d, 0, 0, 0);
} else if($cal_y && $cal_m && checkdate($cal_m, 1, $cal_y)) {
if($cal_y == $now['year'] && $cal_m == $now['mon']) {
if($cal_y == $now['year'] && $cal_m == $now['mon']) {
$event->timestart = make_timestamp($cal_y, $cal_m, $now['mday'], 0, 0, 0);
} else {
$event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0);
}
}

}
}
if (!calendar_add_event_allowed($event)) {
print_error('nopermissions');
}
}
}
}

$properties = $event->properties(true);
$formoptions->event = $event;
Expand Down Expand Up @@ -205,46 +208,13 @@
$PAGE->set_title($site->shortname.': '.$strcalendar.': '.$title);
$PAGE->set_heading($COURSE->fullname);

echo $OUTPUT->header();

calendar_set_filters($calendar->courses, $calendar->groups, $calendar->users);
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer);

echo '<table class="calendarlayout">';
echo '<tr><td class="maincalendar">';
echo $OUTPUT->header();
echo $renderer->start_layout();
echo $OUTPUT->heading($title);
$mform->display();
echo '</td>';

// when adding an event you can not be a guest, so it's reasonalbe to ignore defaultcourses MDL-10353
calendar_set_filters($courses, $groups, $users);
list($prevmon, $prevyr) = calendar_sub_month((int)$now['mon'], (int)$now['year']);
list($nextmon, $nextyr) = calendar_add_month((int)$now['mon'], (int)$now['year']);

echo '<td class="sidecalendar">';

$block = $OUTPUT->box_start('block');
$block .= $OUTPUT->box($OUTPUT->heading(get_string('eventskey', 'calendar')), 'header');
$block .= $OUTPUT->box(calendar_filter_controls('event', 'action='.$action.'&amp;id='.$event->id), 'filters content');
$block .= $OUTPUT->box_end();
$block .= $OUTPUT->box_start('block');
$block .= $OUTPUT->box($OUTPUT->heading(get_string('monthlyview', 'calendar')), 'header');
$block .= $OUTPUT->box_start('content');
$block .= $OUTPUT->box_start('minicalendarblock minicalendartop');
$block .= calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
$block .= calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
$block .= $OUTPUT->box_end();
$block .= $OUTPUT->box_start('minicalendarblock');
$block .= calendar_top_controls('display', array('id' => $courseid, 'm' => (int)$now['mon'], 'y' => (int)$now['year']));
$block .= calendar_get_mini($courses, $groups, $users, (int)$now['mon'], (int)$now['year']);
$block .= $OUTPUT->box_end();
$block .= $OUTPUT->box_start('minicalendarblock');
$block .= calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
$block .= calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
$block .= $OUTPUT->box_end();
$block .= $OUTPUT->box_end();
$block .= $OUTPUT->box_end();
echo $block;

echo '</td></tr>';
echo '</table>';

echo $renderer->complete_layout();
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion calendar/event_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function definition () {
$mform->addElement('radio', 'duration', get_string('eventduration', 'calendar'), get_string('durationnone', 'calendar'), 0);

$mform->addElement('radio', 'duration', null, get_string('durationuntil', 'calendar'), 1);
$mform->addElement('date_time_selector', 'timedurationuntil', null);
$mform->addElement('date_time_selector', 'timedurationuntil', '&nbsp;');
$mform->disabledIf('timedurationuntil','duration','noteq', 1);

$mform->addElement('radio', 'duration', null, get_string('durationminutes', 'calendar'), 2);
Expand Down
68 changes: 18 additions & 50 deletions calendar/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
if ($yr !== 0) {
$url->param('cal_y', $yr);
}
if ($course !== 0) {
$url->param('course', $course);
if ($course !== NULL) {
$url->param('course', $course->id);
}
$PAGE->set_url($url);

Expand All @@ -98,6 +98,10 @@
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
}

$calendar = new calendar_information($day, $mon, $yr);
$calendar->courseid = $courseid;


if(!checkdate($mon, $day, $yr)) {
$day = intval($now['mday']);
$mon = intval($now['mon']);
Expand All @@ -107,16 +111,16 @@

if (!isloggedin() or isguestuser()) {
$defaultcourses = calendar_get_default_courses();
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
calendar_set_filters($calendar->courses, $calendar->groups, $calendar->users, $defaultcourses, $defaultcourses);
} else {
calendar_set_filters($courses, $groups, $users);
calendar_set_filters($calendar->courses, $calendar->groups, $calendar->users);
}

$strcalendar = get_string('calendar', 'calendar');
$prefsbutton = calendar_preferences_button();

// Print title and header
$link = calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$courseid.'&amp;',
$link = calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$calendar->courseid.'&amp;',
$now['mday'], $now['mon'], $now['year']);
$PAGE->navbar->add(get_string('calendar', 'calendar'), new moodle_url($link));
$PAGE->navbar->add($pagetitle);
Expand All @@ -125,64 +129,28 @@
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_button($prefsbutton);
$PAGE->set_focuscontrol('pw_all');
$PAGE->set_pagelayout('standard');

echo $OUTPUT->header();

// Layout the whole page as three big columns.
echo '<table class="calendarlayout">';
echo '<tr>';

// START: Main column

echo '<td class="maincalendar">';

$username = $USER->username;
$usernameencoded = urlencode($USER->username);
$authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer);

echo $OUTPUT->header();
echo $renderer->start_layout();
switch($action) {
case 'advanced':
break;
case '':
default:
$username = $USER->username;
$authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
// Let's populate some vars to let "common tasks" be somewhat smart...
// If today it's weekend, give the "next week" option
$allownextweek = CALENDAR_WEEKEND & (1 << $now['wday']);
// If it's the last week of the month, give the "next month" option
$allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
// If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
$allowthisweek = !((CALENDAR_WEEKEND & (1 << $now['wday'])) && !(CALENDAR_WEEKEND & (1 << (($now['wday'] + 1) % 7))));
echo '<div class="header">' . get_string('export', 'calendar') . '</div>';
include('export_basic.html');
echo $renderer->basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $username, $authtoken);
}



echo '</td>';

// END: Main column

// START: Last column (3-month display)
echo '<td class="sidecalendar">';
echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';

list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
$getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering

echo '<div class="minicalendarblock">';
echo calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
echo '</div><div class="minicalendarblock">';
echo calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
echo '</div><div class="minicalendarblock">';
echo calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
echo '</div>';

echo '</td>';

echo '</tr></table>';

echo $renderer->complete_layout();
echo $OUTPUT->footer();
66 changes: 0 additions & 66 deletions calendar/export_basic.html

This file was deleted.

Loading

0 comments on commit 36dc3b7

Please sign in to comment.