]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: remove validate_context()
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:24:02 +0000 (07:24 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:24:02 +0000 (07:24 +0000)
No longer used anywhere. Not really useful outside of accesslib, so no
point in keeping it.

lib/accesslib.php

index 528e261c9ad3a8cf865d2b75eb71ea725eab299d..f2c58754eb84a99ed9b70ddbda690f68e1101d7c 100755 (executable)
@@ -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.