From 0df35335ba822fa0c2e697734de4ebf6bd5d52f7 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:48:03 +0000 Subject: [PATCH] moodlelib: isediting() uses $PAGE->user_allowed_editing(), drop editcourseallowed() With this commit, isediting() checks with the page if the user is allowed editing. And as the last caller of editcourseallowed() is gone, remove it. --- lib/moodlelib.php | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index cb55b6e898..7f9701a5da 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2358,40 +2358,18 @@ function isguestuser($user=NULL) { * Determines if the currently logged in user is in editing mode. * Note: originally this function had $userid parameter - it was not usable anyway * - * @uses $USER - * @param int $courseid The id of the course being tested + * @uses $USER, $PAGE * @return bool */ -function isediting($courseid) { - global $USER; +function isediting() { + global $USER, $PAGE; if (empty($USER->editing)) { return false; - - } else { - return editcourseallowed($courseid); + } elseif (is_object($PAGE) && method_exists($PAGE,'user_allowed_editing')) { + return $PAGE->user_allowed_editing(); } -} - -/** - * Verifies if user allowed to edit something in the course page. - * @param int $courseid The id of the course being tested - * @return bool - */ -function editcourseallowed($courseid) { - global $USER; - - // cache the result per course, it is automatically reset when using switchrole or loginas - if (!array_key_exists('courseeditallowed', $USER)) { - $USER->courseeditallowed = array(); - } - - if (!array_key_exists($courseid, $USER->courseeditallowed)) { - $USER->courseeditallowed[$courseid] = has_capability_including_child_contexts(get_context_instance(CONTEXT_COURSE, $courseid), - array('moodle/site:manageblocks', 'moodle/course:manageactivities')); - } - - return $USER->courseeditallowed[$courseid]; + return true;//false; } /** -- 2.39.5