Skip to content

Commit

Permalink
Merge branch 'MDL-56870-master-v2' of https://github.com/snake/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Nov 17, 2016
2 parents 76acac8 + a428cf4 commit 9ecf067
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['activityisscheduledfordeletion'] = 'Activity deletion in progress...';
$string['authnotexisting'] = 'The autorization plugin doesn\'t exist';
$string['backupcontainexternal'] = 'This backup file contains external Moodle Network Hosts that are not configured locally';
$string['backuptablefail'] = 'Backup tables could NOT be set up successfully!';
Expand Down
14 changes: 12 additions & 2 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,7 @@ function get_login_url() {
* @return mixed Void, exit, and die depending on path
* @throws coding_exception
* @throws require_login_exception
* @throws moodle_exception
*/
function require_login($courseorid = null, $autologinguest = true, $cm = null, $setwantsurltome = true, $preventredirect = false) {
global $CFG, $SESSION, $USER, $PAGE, $SITE, $DB, $OUTPUT;
Expand Down Expand Up @@ -2684,8 +2685,8 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
// Make sure the USER has a sesskey set up. Used for CSRF protection.
sesskey();

// Do not bother admins with any formalities.
if (is_siteadmin()) {
// Do not bother admins with any formalities, except for activities pending deletion.
if (is_siteadmin() && !($cm && $cm->deletioninprogress)) {
// Set the global $COURSE.
if ($cm) {
$PAGE->set_cm($cm, $course);
Expand Down Expand Up @@ -2873,6 +2874,15 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
}
}

// Check whether the activity has been scheduled for deletion. If so, then deny access, even for admins.
if ($cm && $cm->deletioninprogress) {
if ($preventredirect) {
throw new moodle_exception('activityisscheduledfordeletion');
}
require_once($CFG->dirroot . '/course/lib.php');
redirect(course_get_url($course), get_string('activityisscheduledfordeletion', 'error'));
}

// Check visibility of activity to current user; includes visible flag, conditional availability, etc.
if ($cm && !$cm->uservisible) {
if ($preventredirect) {
Expand Down

0 comments on commit 9ecf067

Please sign in to comment.