MDL-39111 check repository instance context instead of repository usage context (following MDL-34346)

This commit is contained in:
Marina Glancy 2013-04-16 12:45:06 +10:00
parent b3661ab272
commit f6812f575f
2 changed files with 12 additions and 2 deletions

View File

@ -1123,7 +1123,7 @@ abstract class repository implements cacheable_object {
* Do not use this function to access repository contents, because it
* does not set the current context
*
* @see rpository::get_repository_by_id()
* @see repository::get_repository_by_id()
*
* @static
* @param integer $id repository instance id
@ -1877,7 +1877,7 @@ abstract class repository implements cacheable_object {
if ($type->get_visible()) {
//if the instance is unique so it's visible, otherwise check if the instance has a enabled context
if (empty($instanceoptions) || $type->get_contextvisibility($this->context)) {
if (empty($instanceoptions) || $type->get_contextvisibility(context::instance_by_id($this->instance->contextid))) {
return true;
}
}

View File

@ -16,6 +16,16 @@ http://docs.moodle.org/dev/Repository_API
* can_be_edited_by_user() encapsulates all the tests to make sure that the current user
has the rights to edit the instance of this repository.
* repository::get_instances() (used by filepicker and texteditor to populate the
list of available repositories) now calls repository constructor specifying the
context where repository will be used.
When checking permissions inside repository class use:
$this->instance->contextid - to find the context where repository was created;
$this->context - to find the current context where repository is used.
This also means that the same repository instance may now have different names when
called from different contexts.
Avoid calling repository::get_instance(), use repository::get_repository_by_id() instead.
=== 2.4 ===
* copy_to_area() can receive a new parameter called $areamaxbytes which controls the maximum