mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 11:56:40 +02:00
MDL-68845 calendar: Move duplicated code to function
This commit is contained in:
parent
5486b031ee
commit
ea9c822fc3
4 changed files with 49 additions and 7 deletions
|
@ -3667,11 +3667,10 @@ function calendar_get_timestamp($d, $m, $y, $time = 0) {
|
|||
* @return array The data for template and template name.
|
||||
*/
|
||||
function calendar_get_footer_options($calendar) {
|
||||
global $CFG, $USER, $DB, $PAGE;
|
||||
global $CFG, $USER, $PAGE;
|
||||
|
||||
// Generate hash for iCal link.
|
||||
$rawhash = $USER->id . $DB->get_field('user', 'password', ['id' => $USER->id]) . $CFG->calendar_exportsalt;
|
||||
$authtoken = sha1($rawhash);
|
||||
$authtoken = calendar_get_export_token($USER);
|
||||
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
$footer = new \core_calendar\external\footer_options_exporter($calendar, $USER->id, $authtoken);
|
||||
|
@ -3905,3 +3904,15 @@ function calendar_internal_update_course_and_group_permission(int $courseid, con
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auth token for exporting the given user calendar.
|
||||
* @param stdClass $user The user to export the calendar for
|
||||
*
|
||||
* @return string The export token.
|
||||
*/
|
||||
function calendar_get_export_token(stdClass $user): string {
|
||||
global $CFG, $DB;
|
||||
|
||||
return sha1($user->id . $DB->get_field('user', 'password', ['id' => $user->id]) . $CFG->calendar_exportsalt);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue