MDL-21781 protect cohorts created by external systesm - we can not edit them with...
authorPetr Skoda <skodak@moodle.org>
Fri, 23 Apr 2010 09:15:04 +0000 (09:15 +0000)
committerPetr Skoda <skodak@moodle.org>
Fri, 23 Apr 2010 09:15:04 +0000 (09:15 +0000)
cohort/assign.php
cohort/edit.php

index 6258cbe..a4557d3 100644 (file)
@@ -39,8 +39,15 @@ require_capability('moodle/cohort:assign', $context);
 $PAGE->set_url('/cohort/assign.php', array('id'=>$id));
 $PAGE->set_Context($context);
 
+$returnurl = new moodle_url('/cohort/index.php', array('contextid'=>$cohort->contextid));
+
+if (!empty($cohort->component)) {
+    // we can not manually edit cohorts that were created by external systems, sorry
+    redirect($returnurl);
+}
+
 if (optional_param('cancel', false, PARAM_BOOL)) {
-    redirect(new moodle_url('/cohort/index.php', array('contextid'=>$cohort->contextid)));
+    redirect($returnurl);
 }
 
 if ($context->contextlevel == CONTEXT_COURSECAT) {
index fa03108..c1e190e 100644 (file)
@@ -56,6 +56,11 @@ require_capability('moodle/cohort:manage', $context);
 
 $returnurl = new moodle_url('/cohort/index.php', array('contextid'=>$context->id));
 
+if (!empty($cohort->component)) {
+    // we can not manually edit cohorts that were created by external systems, sorry
+    redirect($returnurl);
+}
+
 $PAGE->set_context($context);
 $PAGE->set_url('/cohort/edit.php', array('contextid'=>$context->id, 'id'=>$cohort->id));
 $PAGE->set_context($context);