mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-32341 calendar: calendar custom date range export
Adding support to export calendar events for a custom date range based on admin settings
This commit is contained in:
parent
ca48fe5f97
commit
af5d990b59
@ -67,6 +67,19 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('calendar_maxevents',new lang_string('configmaxevents','admin'),new lang_string('helpupcomingmaxevents', 'admin'),10,$options));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecalendarexport', new lang_string('enablecalendarexport', 'admin'), new lang_string('configenablecalendarexport','admin'), 1));
|
||||
|
||||
// Calendar custom export settings.
|
||||
$days = array(365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
30 => new lang_string('numdays', '', 30),
|
||||
5 => new lang_string('numdays', '', 5));
|
||||
$temp->add(new admin_setting_configcheckbox('calendar_customexport', new lang_string('configcalendarcustomexport', 'admin'), new lang_string('helpcalendarcustomexport','admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookahead', new lang_string('configexportlookahead','admin'), new lang_string('helpexportlookahead', 'admin'), 365, $days));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookback', new lang_string('configexportlookback','admin'), new lang_string('helpexportlookback', 'admin'), 5, $days));
|
||||
$temp->add(new admin_setting_configtext('calendar_exportsalt', new lang_string('calendarexportsalt','admin'), new lang_string('configcalendarexportsalt', 'admin'), random_string(60)));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
|
@ -37,7 +37,7 @@ $time = optional_param('preset_time', 'weeknow', PARAM_ALPHA);
|
||||
$now = usergetdate(time());
|
||||
// Let's see if we have sufficient and correct data
|
||||
$allowed_what = array('all', 'courses');
|
||||
$allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming');
|
||||
$allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming', 'custom');
|
||||
|
||||
if (!empty($generateurl)) {
|
||||
$authtoken = sha1($user->id . $user->password . $CFG->calendar_exportsalt);
|
||||
@ -127,6 +127,11 @@ if(!empty($what) && !empty($time)) {
|
||||
$timestart = time() - 432000;
|
||||
$timeend = time() + 5184000;
|
||||
break;
|
||||
case 'custom':
|
||||
// Events based on custom date range.
|
||||
$timestart = time() - $CFG->calendar_exportlookback * DAYSECS;
|
||||
$timeend = time() + $CFG->calendar_exportlookahead * DAYSECS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -43,6 +43,7 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
* @return string
|
||||
*/
|
||||
public function basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $userid, $authtoken) {
|
||||
global $CFG;
|
||||
|
||||
$output = html_writer::tag('div', get_string('export', 'calendar'), array('class'=>'header'));
|
||||
$output .= html_writer::start_tag('fieldset');
|
||||
@ -84,8 +85,20 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'preset_time', 'id'=>'pt_recupc', 'value'=>'recentupcoming'));
|
||||
$output .= html_writer::tag('label', get_string('recentupcoming', 'calendar'), array('for'=>'pt_recupc'));
|
||||
$output .= html_writer::empty_tag('br');
|
||||
$output .= html_writer::end_tag('div');
|
||||
|
||||
if ($CFG->calendar_customexport) {
|
||||
$a = new stdClass();
|
||||
$now = time();
|
||||
$time = $now - $CFG->calendar_exportlookback * DAYSECS;
|
||||
$a->timestart = userdate($time, get_string('strftimedatefullshort', 'langconfig'));
|
||||
$time = $now + $CFG->calendar_exportlookahead * DAYSECS;
|
||||
$a->timeend = userdate($time, get_string('strftimedatefullshort', 'langconfig'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'radio', 'name' => 'preset_time', 'id' => 'pt_custom', 'value' => 'custom'));
|
||||
$output .= html_writer::tag('label', get_string('customexport', 'calendar', $a), array('for' => 'pt_custom'));
|
||||
$output .= html_writer::empty_tag('br');
|
||||
}
|
||||
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::start_tag('div', array('class'=>'rightalign'));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'cal_d', 'value'=>''));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'cal_m', 'value'=>''));
|
||||
|
@ -142,6 +142,7 @@ $string['configautolang'] = 'Detect default language from browser setting, if di
|
||||
$string['configautologinguests'] = 'Should visitors be logged in as guests automatically when entering courses with guest access?';
|
||||
$string['configbloglevel'] = 'This setting allows you to restrict the level to which user blogs can be viewed on this site. Note that they specify the maximum context of the VIEWER not the poster or the types of blog posts. Blogs can also be disabled completely if you don\'t want them at all.';
|
||||
$string['configcachetext'] = 'For larger sites or sites that use text filters, this setting can really speed things up. Copies of texts will be retained in their processed form for the time specified here. Setting this too small may actually slow things down slightly, but setting it too large may mean texts take too long to refresh (with new links, for example).';
|
||||
$string['configcalendarcustomexport'] = 'Enable custom date range export of calendar';
|
||||
$string['configcalendarexportsalt'] = 'This random text is used for improving of security of authentication tokens used for exporting of calendars. Please note that all current tokens are invalidated if you change this hash salt.';
|
||||
$string['configclamactlikevirus'] = 'Treat files like viruses';
|
||||
$string['configclamdonothing'] = 'Treat files as OK';
|
||||
@ -209,6 +210,8 @@ $string['configenabletrusttext'] = 'By default Moodle will always thoroughly cle
|
||||
$string['configenablewebservices'] = 'Web services enable other systems to log in to this Moodle and perform operations. For extra security this feature should be disabled unless you are really using it.';
|
||||
$string['configenablewsdocumentation'] = 'Enable auto-generation of web services documentation. A user can access to his own documentation on his security keys page {$a}. It displays the documentation for the enabled protocols only.';
|
||||
$string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.';
|
||||
$string['configexportlookahead'] = 'Days to look ahead during export';
|
||||
$string['configexportlookback'] = 'Days to look back during export';
|
||||
$string['configextendedusernamechars'] = 'Enable this setting to allow students to use any characters in their usernames (note this does not affect their actual names). The default is "false" which restricts usernames to be alphanumeric lowercase characters, underscore (_), hyphen (-), period (.) or at symbol (@).';
|
||||
$string['configextramemorylimit'] = 'Some scripts like search, backup/restore or cron require more memory. Set higher values for large sites.';
|
||||
$string['configfilterall'] = 'Filter all strings, including headings, titles, navigation bar and so on. This is mostly useful when using the multilang filter, otherwise it will just create extra load on your site for little gain.';
|
||||
@ -563,6 +566,9 @@ $string['guestroleid'] = 'Role for guest';
|
||||
$string['guestroleid_help'] = 'This role is automatically assigned to the guest user. It is also temporarily assigned to not enrolled users that enter the course via guest enrolment plugin.';
|
||||
$string['helpadminseesall'] = 'Do admins see all calendar events or just those that apply to themselves?';
|
||||
$string['helpcalendarsettings'] = 'Configure various calendar and date/time-related aspects of Moodle';
|
||||
$string['helpcalendarcustomexport'] = 'Enable custom date range export option in calendar exports. Calendar exports must be enabled before this is effective.';
|
||||
$string['helpexportlookahead'] = 'How many days in the future does the calendar look for events during export for the custom export option?';
|
||||
$string['helpexportlookback'] = 'How many days in the past does the calendar look for events during export for the custom export option?';
|
||||
$string['helpforcetimezone'] = 'You can allow users to individually select their timezone, or force a timezone for everyone.';
|
||||
$string['helpsitemaintenance'] = 'For upgrades and other work';
|
||||
$string['helpstartofweek'] = 'Which day starts the week in the calendar?';
|
||||
|
@ -42,6 +42,7 @@ $string['course'] = 'Course';
|
||||
$string['courseevent'] = 'Course event';
|
||||
$string['courseevents'] = 'Course events';
|
||||
$string['courses'] = 'Courses';
|
||||
$string['customexport'] = 'Custom range ({$a->timestart} - {$a->timeend})';
|
||||
$string['daily'] = 'Daily';
|
||||
$string['dayview'] = 'Day view';
|
||||
$string['dayviewtitle'] = 'Day view: {$a}';
|
||||
|
Loading…
x
Reference in New Issue
Block a user