MDL-12922 'moodle/restore:rolldates' capability - Implement logic on restore. Merged from 19_STABLE

This commit is contained in:
stronk7 2009-10-06 01:27:37 +00:00
parent 982e45af49
commit 81b06e9b17
3 changed files with 53 additions and 2 deletions

View file

@ -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') {