mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-54751 core_availability: Module restrictions exclude deletions
To make sure users can't add an access restriction based on a course module scheduled for deletion, or its respective grade items.
This commit is contained in:
parent
45bd824e59
commit
2f6e0d92b7
@ -64,7 +64,7 @@ class frontend extends \core_availability\frontend {
|
||||
foreach ($modinfo->cms as $id => $othercm) {
|
||||
// Add each course-module if it has completion turned on and is not
|
||||
// the one currently being edited.
|
||||
if ($othercm->completion && (empty($cm) || $cm->id != $id)) {
|
||||
if ($othercm->completion && (empty($cm) || $cm->id != $id) && !$othercm->deletioninprogress) {
|
||||
$cms[] = (object)array('id' => $id, 'name' =>
|
||||
format_string($othercm->name, true, array('context' => $context)));
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class frontend extends \core_availability\frontend {
|
||||
\section_info $section = null) {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
|
||||
// Get grades as basic associative array.
|
||||
$gradeoptions = array();
|
||||
@ -49,6 +50,10 @@ class frontend extends \core_availability\frontend {
|
||||
// For some reason the fetch_all things return null if none.
|
||||
$items = $items ? $items : array();
|
||||
foreach ($items as $id => $item) {
|
||||
// Don't include the grade item if it's linked with a module that is being deleted.
|
||||
if (course_module_instance_pending_deletion($item->courseid, $item->itemmodule, $item->iteminstance)) {
|
||||
continue;
|
||||
}
|
||||
// Do not include grades for current item.
|
||||
if ($cm && $cm->instance == $item->iteminstance
|
||||
&& $cm->modname == $item->itemmodule
|
||||
|
Loading…
x
Reference in New Issue
Block a user