From: martinlanghoff Date: Wed, 19 Sep 2007 07:24:02 +0000 (+0000) Subject: accesslib: remove validate_context() X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=03160d776cc4a911e1d3d0abef67daf5c2e5d0ee;p=moodle.git accesslib: remove validate_context() No longer used anywhere. Not really useful outside of accesslib, so no point in keeping it. --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 528e261c9a..f2c58754eb 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2319,46 +2319,6 @@ function cleanup_contexts() { return true; } -/** - * Validate that object with instanceid really exists in given context level. - * - * return if instanceid object exists - */ -function validate_context($contextlevel, $instanceid) { - switch ($contextlevel) { - - case CONTEXT_SYSTEM: - return ($instanceid == 0); - - case CONTEXT_PERSONAL: - return (boolean)count_records('user', 'id', $instanceid); - - case CONTEXT_USER: - return (boolean)count_records('user', 'id', $instanceid); - - case CONTEXT_COURSECAT: - if ($instanceid == 0) { - return true; // site course category - } - return (boolean)count_records('course_categories', 'id', $instanceid); - - case CONTEXT_COURSE: - return (boolean)count_records('course', 'id', $instanceid); - - case CONTEXT_GROUP: - return groups_group_exists($instanceid); - - case CONTEXT_MODULE: - return (boolean)count_records('course_modules', 'id', $instanceid); - - case CONTEXT_BLOCK: - return (boolean)count_records('block_instance', 'id', $instanceid); - - default: - return false; - } -} - /** * Get the context instance as an object. This function will create the * context instance if it does not exist yet.