mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Lots of usability improvements and some bugfixes:
Fixed wrong redirection after changing filters for all calendar screens Fixed course selection menu to work without javascript Moved course selection menu to the header, and added it to all screens All screens now conform to the selected course in the menu Small improvements in the way guests are handled
This commit is contained in:
parent
14fcda781a
commit
34bf3ad4f3
3 changed files with 141 additions and 130 deletions
|
@ -556,33 +556,29 @@ function calendar_filter_controls($type, $vars = NULL) {
|
||||||
|
|
||||||
$groupevents = true;
|
$groupevents = true;
|
||||||
|
|
||||||
if($vars === NULL) {
|
switch($type) {
|
||||||
switch($type) {
|
case 'upcoming':
|
||||||
case 'upcoming':
|
$getvars = '&from=upcoming';
|
||||||
$getvars = '';
|
break;
|
||||||
break;
|
case 'prefs':
|
||||||
case 'prefs':
|
$getvars = '&from=prefs&pref='.$_GET['edit'];
|
||||||
$getvars = '&from=prefs&pref='.$_GET['edit'];
|
break;
|
||||||
break;
|
case 'event':
|
||||||
case 'event':
|
$getvars = '&from=event&id='.$_GET['id'];
|
||||||
global $day, $mon, $yr;
|
break;
|
||||||
$getvars = '&from=event&id='.$_GET['id'];
|
case 'day':
|
||||||
break;
|
$getvars = '&from=day';
|
||||||
case 'day':
|
break;
|
||||||
global $day, $mon, $yr;
|
case 'course':
|
||||||
$getvars = '&from=day&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr;
|
$getvars = '&from=course&id='.$_GET['id'];
|
||||||
break;
|
if($course->groupmode == NOGROUPS && $course->groupmodeforce) {
|
||||||
case 'course':
|
$groupevents = false;
|
||||||
global $course;
|
}
|
||||||
$getvars = '&from=course&id='.$course->id;
|
break;
|
||||||
if($course->groupmode == NOGROUPS && $course->groupmodeforce) {
|
|
||||||
$groupevents = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$getvars = '&'.$vars;
|
if(!empty($vars)) {
|
||||||
|
$getvars .= '&'.$vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '<table class="cal_controls" style="width: 98%;">';
|
$content = '<table class="cal_controls" style="width: 98%;">';
|
||||||
|
|
126
calendar/set.php
126
calendar/set.php
|
@ -38,72 +38,72 @@
|
||||||
// //
|
// //
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
require_once('../config.php');
|
require_once('../config.php');
|
||||||
require_once('lib.php');
|
require_once('lib.php');
|
||||||
|
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
require_variable($_GET['from']);
|
require_variable($_GET['from']);
|
||||||
require_variable($_GET['var']);
|
require_variable($_GET['var']);
|
||||||
optional_variable($_GET['value']);
|
optional_variable($_GET['value']);
|
||||||
optional_variable($_GET['id']);
|
optional_variable($_GET['id']);
|
||||||
optional_variable($_GET['cal_d']);
|
optional_variable($_GET['cal_d']);
|
||||||
optional_variable($_GET['cal_m']);
|
optional_variable($_GET['cal_m']);
|
||||||
optional_variable($_GET['cal_y']);
|
optional_variable($_GET['cal_y']);
|
||||||
|
|
||||||
switch($_GET['var']) {
|
switch($_GET['var']) {
|
||||||
case 'setcourse':
|
case 'setcourse':
|
||||||
$id = intval($_GET['id']);
|
$id = intval($_GET['id']);
|
||||||
if($id == 0) {
|
if($id == 0) {
|
||||||
$SESSION->cal_courses_shown = array();
|
$SESSION->cal_courses_shown = array();
|
||||||
}
|
}
|
||||||
else if($id == 1) {
|
else if($id == 1) {
|
||||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We don't check for membership anymore: if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) {
|
// We don't check for membership anymore: if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) {
|
||||||
$SESSION->cal_courses_shown = $id;
|
$SESSION->cal_courses_shown = $id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'showgroups':
|
case 'showgroups':
|
||||||
$SESSION->cal_show_groups = !$SESSION->cal_show_groups;
|
$SESSION->cal_show_groups = !$SESSION->cal_show_groups;
|
||||||
break;
|
break;
|
||||||
case 'showcourses':
|
case 'showcourses':
|
||||||
$SESSION->cal_show_course = !$SESSION->cal_show_course;
|
$SESSION->cal_show_course = !$SESSION->cal_show_course;
|
||||||
break;
|
break;
|
||||||
case 'showglobal':
|
case 'showglobal':
|
||||||
$SESSION->cal_show_global = !$SESSION->cal_show_global;
|
$SESSION->cal_show_global = !$SESSION->cal_show_global;
|
||||||
break;
|
break;
|
||||||
case 'showuser':
|
case 'showuser':
|
||||||
if($SESSION->cal_show_user) {
|
if($SESSION->cal_show_user) {
|
||||||
$SESSION->cal_show_user = false;
|
$SESSION->cal_show_user = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$SESSION->cal_show_user = $USER->id;
|
$SESSION->cal_show_user = $USER->id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($_GET['from']) {
|
switch($_GET['from']) {
|
||||||
case 'prefs':
|
case 'prefs':
|
||||||
redirect($CFG->wwwroot.'/calendar/preferences.php?edit='.$_GET['pref']);
|
redirect($CFG->wwwroot.'/calendar/preferences.php?edit='.$_GET['pref']);
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
redirect($CFG->wwwroot.'/calendar/view.php?view=month&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
redirect($CFG->wwwroot.'/calendar/view.php?view=month&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
||||||
break;
|
break;
|
||||||
case 'upcoming':
|
case 'upcoming':
|
||||||
redirect($CFG->wwwroot.'/calendar/view.php?view=upcoming&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
redirect($CFG->wwwroot.'/calendar/view.php?view=upcoming&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
||||||
break;
|
break;
|
||||||
case 'event':
|
case 'event':
|
||||||
redirect($CFG->wwwroot.'/calendar/view.php?view=event&id='.$_GET['id']);
|
redirect($CFG->wwwroot.'/calendar/view.php?view=event&id='.$_GET['id']);
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
redirect($CFG->wwwroot.'/calendar/view.php?view=day&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
redirect($CFG->wwwroot.'/calendar/view.php?view=day&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
|
||||||
break;
|
break;
|
||||||
case 'course':
|
case 'course':
|
||||||
redirect($CFG->wwwroot.'/course/view.php?id='.intval($_GET['id']));
|
redirect($CFG->wwwroot.'/course/view.php?id='.intval($_GET['id']));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -99,13 +99,7 @@
|
||||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if($_GET['view'] == 'upcoming') {
|
calendar_set_filters($courses, $groups, $users);
|
||||||
$defaultcourses = calendar_get_default_courses();
|
|
||||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses, false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
calendar_set_filters($courses, $groups, $users);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's see if we are supposed to provide a referring course link
|
// Let's see if we are supposed to provide a referring course link
|
||||||
|
@ -165,7 +159,7 @@
|
||||||
print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
|
print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
|
||||||
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
||||||
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
||||||
$getvars = 'from=month&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
|
$getvars = 'cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
|
||||||
echo calendar_filter_controls($_GET['view'], $getvars);
|
echo calendar_filter_controls($_GET['view'], $getvars);
|
||||||
echo '<p>';
|
echo '<p>';
|
||||||
echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
|
echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
|
||||||
|
@ -207,6 +201,8 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||||
list($d, $m, $y) = array(intval($now['mday']), intval($now['mon']), intval($now['year']));
|
list($d, $m, $y) = array(intval($now['mday']), intval($now['mon']), intval($now['year']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$getvars = 'from=day&cal_d='.$d.'&cal_m='.$m.'&cal_y='.$y; // For filtering
|
||||||
|
|
||||||
$starttime = make_timestamp($y, $m, $d);
|
$starttime = make_timestamp($y, $m, $d);
|
||||||
$endtime = $starttime + SECS_IN_DAY - 1;
|
$endtime = $starttime + SECS_IN_DAY - 1;
|
||||||
$whereclause = calendar_sql_where($starttime, $endtime, $users, $groups, $courses);
|
$whereclause = calendar_sql_where($starttime, $endtime, $users, $groups, $courses);
|
||||||
|
@ -220,10 +216,10 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||||
|
|
||||||
// New event button
|
// New event button
|
||||||
if(isguest()) {
|
if(isguest()) {
|
||||||
$text = get_string('dayview', 'calendar');
|
$text = get_string('dayview', 'calendar').': '.calendar_course_filter_selector($getvars);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$text = '<div style="float: left;">'.get_string('dayview', 'calendar').'</div><div style="float: right;">';
|
$text = '<div style="float: left;">'.get_string('dayview', 'calendar').': '.calendar_course_filter_selector($getvars).'</div><div style="float: right;">';
|
||||||
$text.= '<form style="display: inline;" action="'.CALENDAR_URL.'event.php" method="get">';
|
$text.= '<form style="display: inline;" action="'.CALENDAR_URL.'event.php" method="get">';
|
||||||
$text.= '<input type="hidden" name="action" value="new" />';
|
$text.= '<input type="hidden" name="action" value="new" />';
|
||||||
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
|
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
|
||||||
|
@ -337,10 +333,10 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||||
|
|
||||||
// New event button
|
// New event button
|
||||||
if(isguest()) {
|
if(isguest()) {
|
||||||
$text = get_string('detailedmonthview', 'calendar');
|
$text = get_string('detailedmonthview', 'calendar').': '.calendar_course_filter_selector($getvars);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$text = '<div style="float: left;">'.get_string('detailedmonthview', 'calendar').'</div><div style="float: right;">';
|
$text = '<div style="float: left;">'.get_string('detailedmonthview', 'calendar').': '.calendar_course_filter_selector($getvars).'</div><div style="float: right;">';
|
||||||
$text.= '<form style="display: inline;" action="'.CALENDAR_URL.'event.php" method="get">';
|
$text.= '<form style="display: inline;" action="'.CALENDAR_URL.'event.php" method="get">';
|
||||||
$text.= '<input type="hidden" name="action" value="new" />';
|
$text.= '<input type="hidden" name="action" value="new" />';
|
||||||
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
|
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
|
||||||
|
@ -351,33 +347,6 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||||
|
|
||||||
print_side_block_start($text, '', 'mycalendar');
|
print_side_block_start($text, '', 'mycalendar');
|
||||||
|
|
||||||
if(isadmin($USER->id)) {
|
|
||||||
$coursesdata = get_courses('all', 'c.shortname');
|
|
||||||
}
|
|
||||||
elseif(!isguest($USER->id)) {
|
|
||||||
$coursesdata = get_my_courses($USER->id, 'shortname');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$coursesdata = get_record('course', 'id', $SESSION->cal_course_referer);
|
|
||||||
}
|
|
||||||
$coursesdata = array_diff_assoc($coursesdata, array(1 => 1));
|
|
||||||
|
|
||||||
if(!isguest($USER->id)) {
|
|
||||||
echo '<p style="text-align: center; margin: 1em;"><strong>'.get_string('eventsfromcourse', 'calendar').': ';
|
|
||||||
echo '<select name="course" onchange="document.location.href=\''.CALENDAR_URL.'set.php?var=setcourse&'.$getvars.'&id=\' + this.value;">';
|
|
||||||
echo '<option value="1">'.get_string('all')."</option>\n";
|
|
||||||
if($coursesdata !== false) {
|
|
||||||
foreach($coursesdata as $coursedata) {
|
|
||||||
echo "\n<option value='$coursedata->id'";
|
|
||||||
if(is_numeric($SESSION->cal_courses_shown) && $coursedata->id == $SESSION->cal_courses_shown) {
|
|
||||||
echo ' selected';
|
|
||||||
}
|
|
||||||
echo '>'.$coursedata->shortname."</option>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo '</select></strong></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
|
echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
|
||||||
|
|
||||||
// Start calendar display
|
// Start calendar display
|
||||||
|
@ -560,7 +529,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_side_block_start(get_string('upcomingevents', 'calendar'), '', 'mycalendar');
|
print_side_block_start(get_string('upcomingevents', 'calendar').': '.calendar_course_filter_selector('from=upcoming'), '', 'mycalendar');
|
||||||
for($i = 0; $i < $numevents; ++$i) {
|
for($i = 0; $i < $numevents; ++$i) {
|
||||||
echo '<p>';
|
echo '<p>';
|
||||||
if(!empty($events[$i]->icon)) {
|
if(!empty($events[$i]->icon)) {
|
||||||
|
@ -571,7 +540,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||||
}
|
}
|
||||||
echo '<span class="cal_event">'.$events[$i]->name.":</span>\n";
|
echo '<span class="cal_event">'.$events[$i]->name.":</span>\n";
|
||||||
echo '<span class="cal_event_date">'.$events[$i]->time.'</span>';
|
echo '<span class="cal_event_date">'.$events[$i]->time.'</span>';
|
||||||
echo '<br />'.$events[$i]->description.'<br />';
|
echo '<div style="margin-top: -1em; padding-left: 20px;">'.$events[$i]->description.'</div>';
|
||||||
if($i < $numevents - 1) {
|
if($i < $numevents - 1) {
|
||||||
echo '<hr />';
|
echo '<hr />';
|
||||||
}
|
}
|
||||||
|
@ -670,4 +639,50 @@ function calendar_print_event_table($event, $starttime, $endtime, &$coursecache,
|
||||||
echo "</tbody>\n</table>\n";
|
echo "</tbody>\n</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function calendar_course_filter_selector($getvars = '') {
|
||||||
|
global $USER, $SESSION;
|
||||||
|
|
||||||
|
if(isadmin($USER->id)) {
|
||||||
|
$coursesdata = get_courses('all', 'c.shortname');
|
||||||
|
}
|
||||||
|
elseif(!isguest($USER->id)) {
|
||||||
|
$coursesdata = get_my_courses($USER->id, 'shortname');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$coursesdata = get_record('course', 'id', $SESSION->cal_course_referer);
|
||||||
|
}
|
||||||
|
$coursesdata = array_diff_assoc($coursesdata, array(1 => 1));
|
||||||
|
|
||||||
|
$selector = '';
|
||||||
|
|
||||||
|
if(!isguest($USER->id)) {
|
||||||
|
$selector .= '<form method="get" action="set.php" style="display: inline;"><span>';
|
||||||
|
$selector .= '<input type="hidden" name="var" value="setcourse" />';
|
||||||
|
if(!empty($getvars)) {
|
||||||
|
$getarray = explode('&', $getvars);
|
||||||
|
foreach($getarray as $getvar) {
|
||||||
|
$selector .= '<input type="hidden" name="'.strtok($getvar, '=').'" value="'.strtok('=').'" />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$selector .= '<select name="id" onchange="form.submit();">';
|
||||||
|
$selector .= '<option value="1">'.get_string('fulllistofcourses')."</option>\n";
|
||||||
|
if($coursesdata !== false) {
|
||||||
|
foreach($coursesdata as $coursedata) {
|
||||||
|
$selector .= "\n<option value='$coursedata->id'";
|
||||||
|
if(is_numeric($SESSION->cal_courses_shown) && $coursedata->id == $SESSION->cal_courses_shown) {
|
||||||
|
$selector .= ' selected';
|
||||||
|
}
|
||||||
|
$selector .= '>'.$coursedata->shortname."</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$selector .= '</select>';
|
||||||
|
$selector .= '<noscript id="cal_noscript" style="display: inline;"> <input type="submit" value="'.get_string('show').'" /></noscript>';
|
||||||
|
$selector .= '<script type="text/javascript">'."\n<!--\n".'document.getElementById("cal_noscript").style.display = "none";'."\n<!--\n".'</script>';
|
||||||
|
$selector .= '</span></form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $selector;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue