mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-12922 'moodle/restore:rolldates' capability - Implement logic on restore. Merged from 19_STABLE
This commit is contained in:
parent
982e45af49
commit
81b06e9b17
3 changed files with 53 additions and 2 deletions
|
@ -9344,6 +9344,28 @@ WHERE
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* true or false function to see if user can roll dates on restore (any course is enough)
|
||||
* @return bool
|
||||
*/
|
||||
function restore_user_can_roll_dates() {
|
||||
global $USER;
|
||||
// if user has moodle/restore:rolldates capability at system or any course cat return true
|
||||
|
||||
if (has_capability('moodle/restore:rolldates', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Non-cached - get accessinfo
|
||||
if (isset($USER->access)) {
|
||||
$accessinfo = $USER->access;
|
||||
} else {
|
||||
$accessinfo = get_user_access_sitewide($USER->id);
|
||||
}
|
||||
$courses = get_user_courses_bycap($USER->id, 'moodle/restore:rolldates', $accessinfo, true);
|
||||
return !empty($courses);
|
||||
}
|
||||
|
||||
//write activity date changes to the html log file, and update date values in the the xml array
|
||||
function restore_log_date_changes($recordtype, &$restore, &$xml, $TAGS, $NAMETAG='NAME') {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue