accesslib: remove validate_context()

No longer used anywhere. Not really useful outside of accesslib, so no
point in keeping it.
This commit is contained in:
martinlanghoff
2007-09-19 07:24:02 +00:00
parent 56743fabc9
commit 03160d776c
-40
View File
@@ -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.