Merge branch 'w52_MDL-43367_m24_contextpath' of https://github.com/skodak/moodle into MOODLE_24_STABLE

This commit is contained in:
Sam Hemelryk
2013-12-23 14:31:18 +13:00
+14
View File
@@ -5270,6 +5270,10 @@ abstract class context extends stdClass implements IteratorAggregate {
public function delete() {
global $DB;
if ($this->_contextlevel <= CONTEXT_SYSTEM) {
throw new coding_exception('Cannot delete system context');
}
// double check the context still exists
if (!$DB->record_exists('context', array('id'=>$this->_id))) {
context::cache_remove($this);
@@ -5365,6 +5369,11 @@ abstract class context extends stdClass implements IteratorAggregate {
public function get_child_contexts() {
global $DB;
if (empty($this->_path) or empty($this->_depth)) {
debugging('Can not find child contexts of context '.$this->_id.' try rebuilding of context paths');
return array();
}
$sql = "SELECT ctx.*
FROM {context} ctx
WHERE ctx.path LIKE ?";
@@ -6337,6 +6346,11 @@ class context_coursecat extends context {
public function get_child_contexts() {
global $DB;
if (empty($this->_path) or empty($this->_depth)) {
debugging('Can not find child contexts of context '.$this->_id.' try rebuilding of context paths');
return array();
}
$sql = "SELECT ctx.*
FROM {context} ctx
WHERE ctx.path LIKE ? AND (ctx.depth = ? OR ctx.contextlevel = ?)";