mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
New features implemented:
* Configurable defaults for the calendar upcoming events lookahead and maximum upcoming events displayed (bug #1623) * Configurable setting for which days of the week are treated as weekend (bug #1919) * Configurable setting for which day starts the week (the admin can now set this as the default for new users and guests without messing with language packs) (no butracker issue)
This commit is contained in:
parent
54598fb04e
commit
bb4a2e85c0
7 changed files with 106 additions and 14 deletions
|
@ -38,16 +38,26 @@
|
|||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$firstday = get_string('firstdayofweek');
|
||||
if(!is_numeric($firstday)) {
|
||||
define ('CALENDAR_STARTING_WEEKDAY', 1);
|
||||
// These are read by the administration component to provide default values
|
||||
define('CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD', 21);
|
||||
define('CALENDAR_DEFAULT_UPCOMING_MAXEVENTS', 10);
|
||||
define('CALENDAR_DEFAULT_STARTING_WEEKDAY', 1);
|
||||
// This is a packed bitfield: day X is "weekend" if $field & (1 << X) is true
|
||||
// Default value = 65 = 64 + 1 = 2^6 + 2^0 = Saturday & Sunday
|
||||
define('CALENDAR_DEFAULT_WEEKEND', 65);
|
||||
|
||||
// Fetch the correct values from admin settings/lang pack
|
||||
// If no such settings found, use the above defaults
|
||||
$firstday = isset($CFG->calendar_startwday) ? $CFG->calendar_startwday : get_string('firstdayofweek');
|
||||
if(!is_numeric($firstday)) {
|
||||
define ('CALENDAR_STARTING_WEEKDAY', CALENDAR_DEFAULT_STARTING_WEEKDAY);
|
||||
}
|
||||
else {
|
||||
define ('CALENDAR_STARTING_WEEKDAY', intval($firstday) % 7);
|
||||
}
|
||||
|
||||
define ('CALENDAR_UPCOMING_DAYS', 21);
|
||||
define ('CALENDAR_UPCOMING_MAXEVENTS', 10);
|
||||
define ('CALENDAR_UPCOMING_DAYS', isset($CFG->calendar_lookahead) ? intval($CFG->calendar_lookahead) : CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD);
|
||||
define ('CALENDAR_UPCOMING_MAXEVENTS', isset($CFG->calendar_maxevents) ? intval($CFG->calendar_maxevents) : CALENDAR_DEFAULT_UPCOMING_MAXEVENTS);
|
||||
define ('CALENDAR_WEEKEND', isset($CFG->calendar_weekend) ? intval($CFG->calendar_weekend) : CALENDAR_DEFAULT_WEEKEND);
|
||||
define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
|
||||
define ('CALENDAR_TF_24', '%H:%M');
|
||||
define ('CALENDAR_TF_12', '%I:%M %p');
|
||||
|
@ -165,7 +175,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
|||
|
||||
// Reset vars
|
||||
$cell = '';
|
||||
if($dayweek % 7 == 0 || $dayweek % 7 == 6) {
|
||||
if(CALENDAR_WEEKEND & (1 << ($dayweek % 7))) {
|
||||
// Weekend. This is true no matter what the exact range is.
|
||||
$class = 'cal_weekend';
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<td nowrap="nowrap" align="right"><?php print_string('pref_timeformat', 'calendar')?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
$options = NULL;
|
||||
$options = array();
|
||||
$options['0'] = get_string('default', 'calendar');
|
||||
$options[CALENDAR_TF_12] = get_string('timeformat_12', 'calendar');
|
||||
$options[CALENDAR_TF_24] = get_string('timeformat_24', 'calendar');
|
||||
|
@ -53,7 +53,7 @@
|
|||
<td nowrap="nowrap" align="right"><?php print_string('pref_startwday', 'calendar')?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
$options = NULL;
|
||||
$options = array();
|
||||
$options[0] = get_string('sunday', 'calendar');
|
||||
$options[1] = get_string('monday', 'calendar');
|
||||
$options[2] = get_string('tuesday', 'calendar');
|
||||
|
|
|
@ -368,7 +368,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
|||
$cell = '';
|
||||
$dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&', $day, $m, $y);
|
||||
|
||||
if($dayweek % 7 == 0 || $dayweek % 7 == 6) {
|
||||
if(CALENDAR_WEEKEND & (1 << ($dayweek % 7))) {
|
||||
// Weekend. This is true no matter what the exact range is.
|
||||
$class = 'cal_weekend';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue