From c5070d06d7add15cfd7b6660dc8bf7579e3116dd Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 23 Apr 2010 09:11:48 +0000 Subject: [PATCH 1/1] MDL-21781 fixed some more cohort assign issues --- cohort/assign.php | 62 ++++++++++++++++++++++++---------------------- lang/en/cohort.php | 1 + 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/cohort/assign.php b/cohort/assign.php index 488fb9a032c..6258cbef0d3 100644 --- a/cohort/assign.php +++ b/cohort/assign.php @@ -39,6 +39,10 @@ require_capability('moodle/cohort:assign', $context); $PAGE->set_url('/cohort/assign.php', array('id'=>$id)); $PAGE->set_Context($context); +if (optional_param('cancel', false, PARAM_BOOL)) { + redirect(new moodle_url('/cohort/index.php', array('contextid'=>$cohort->contextid))); +} + if ($context->contextlevel == CONTEXT_COURSECAT) { $category = $DB->get_record('course_categories', array('id'=>$context->instanceid), '*', MUST_EXIST); $PAGE->navbar->add($category->name, new moodle_url('/course/index.php', array('categoryedit'=>'1'))); @@ -49,43 +53,41 @@ $PAGE->navbar->add(get_string('assign', 'cohort')); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('assignto', 'cohort', format_string($cohort->name))); -/// Get the user_selector we will need. +// Get the user_selector we will need. $potentialuserselector = new cohort_candidate_selector('addselect', array('cohortid'=>$cohort->id)); $existinguserselector = new cohort_existing_selector('removeselect', array('cohortid'=>$cohort->id)); -/// Process incoming user assignments to cohorts - if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) { - $userstoassign = $potentialuserselector->get_selected_users(); - if (!empty($userstoassign)) { +// Process incoming user assignments to the cohort - foreach ($userstoassign as $adduser) { - // no duplicates please - if (!$DB->record_exists('cohort_members', array('cohortid'=>$cohort->id, 'userid'=>$adduser->id))) { - cohort_add_member($cohort->id, $adduser->id); - } - } +if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) { + $userstoassign = $potentialuserselector->get_selected_users(); + if (!empty($userstoassign)) { - $potentialuserselector->invalidate_selected_users(); - $existinguserselector->invalidate_selected_users(); + foreach ($userstoassign as $adduser) { + // no duplicates please + if (!$DB->record_exists('cohort_members', array('cohortid'=>$cohort->id, 'userid'=>$adduser->id))) { + cohort_add_member($cohort->id, $adduser->id); } } -/// Process removing user assignments to the service - if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { - $userstoremove = $existinguserselector->get_selected_users(); - if (!empty($userstoremove)) { - - foreach ($userstoremove as $removeuser) { - cohort_remove_member($cohort->id, $removeuser->id); - } + $potentialuserselector->invalidate_selected_users(); + $existinguserselector->invalidate_selected_users(); + } +} - $potentialuserselector->invalidate_selected_users(); - $existinguserselector->invalidate_selected_users(); - } +// Process removing user assignments to the cohort +if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { + $userstoremove = $existinguserselector->get_selected_users(); + if (!empty($userstoremove)) { + foreach ($userstoremove as $removeuser) { + cohort_remove_member($cohort->id, $removeuser->id); } -/// Print the form. -/// display the UI + $potentialuserselector->invalidate_selected_users(); + $existinguserselector->invalidate_selected_users(); + } +} +// Print the form. ?>
@@ -98,11 +100,11 @@ $existinguserselector = new cohort_existing_selector('removeselect', array('coho
-
+
- +
@@ -110,10 +112,12 @@ $existinguserselector = new cohort_existing_selector('removeselect', array('coho display() ?> + + +
footer(); diff --git a/lang/en/cohort.php b/lang/en/cohort.php index e673550c1fc..eaed0e5a118 100644 --- a/lang/en/cohort.php +++ b/lang/en/cohort.php @@ -27,6 +27,7 @@ $string['addcohort'] = 'Add new cohort'; $string['assign'] = 'Assign'; $string['assignto'] = 'Cohort \'{$a}\' members'; +$string['backtocohorts'] = 'Back to cohorts'; $string['cohort'] = 'Cohort'; $string['cohorts'] = 'Cohorts'; $string['cohortsin'] = '{$a}: available cohorts'; -- 2.43.0