Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-32245_23' of git://github.com/timhunt/moodle into M…

…OODLE_23_STABLE
  • Loading branch information...
commit 20da16bb775d9264b78271b2d62a7bb2e2c675d2 2 parents f6a3850 + c49b83b
@samhemelryk samhemelryk authored
Showing with 29 additions and 14 deletions.
  1. +29 −14 question/category.php
View
43 question/category.php
@@ -31,7 +31,7 @@
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
question_edit_setup('categories', '/question/category.php');
-// get values from form for actions on this page
+// Get values from form for actions on this page.
$param = new stdClass();
$param->moveup = optional_param('moveup', 0, PARAM_INT);
$param->movedown = optional_param('movedown', 0, PARAM_INT);
@@ -55,19 +55,33 @@
}
$PAGE->set_url($url);
-$qcobject = new question_category_object($pagevars['cpage'], $thispageurl, $contexts->having_one_edit_tab_cap('categories'), $param->edit, $pagevars['cat'], $param->delete,
- $contexts->having_cap('moodle/question:add'));
+$qcobject = new question_category_object($pagevars['cpage'], $thispageurl,
+ $contexts->having_one_edit_tab_cap('categories'), $param->edit,
+ $pagevars['cat'], $param->delete, $contexts->having_cap('moodle/question:add'));
-$streditingcategories = get_string('editcategories', 'question');
-if ($param->left || $param->right || $param->moveup || $param->movedown|| $param->moveupcontext || $param->movedowncontext){
+if ($param->left || $param->right || $param->moveup || $param->movedown) {
require_sesskey();
- foreach ($qcobject->editlists as $list){
- //processing of these actions is handled in the method where appropriate and page redirects.
- $list->process_actions($param->left, $param->right, $param->moveup, $param->movedown,
- $param->moveupcontext, $param->movedowncontext, $param->tocontext);
+
+ foreach ($qcobject->editlists as $list) {
+ // Processing of these actions is handled in the method where appropriate and page redirects.
+ $list->process_actions($param->left, $param->right, $param->moveup, $param->movedown);
}
}
-if ($param->delete && ($questionstomove = $DB->count_records("question", array("category" => $param->delete)))){
+
+if ($param->moveupcontext || $param->movedowncontext) {
+ require_sesskey();
+
+ if ($param->moveupcontext) {
+ $catid = $param->moveupcontext;
+ } else {
+ $catid = $param->movedowncontext;
+ }
+ $oldcat = $DB->get_record('question_categories', array('id' => $catid), '*', MUST_EXIST);
+ $qcobject->update_category($catid, '0,'.$param->tocontext, $oldcat->name, $oldcat->info);
+ // The previous line does a redirect().
+}
+
+if ($param->delete && ($questionstomove = $DB->count_records("question", array("category" => $param->delete)))) {
if (!$category = $DB->get_record("question_categories", array("id" => $param->delete))) { // security
print_error('nocate', 'question', $thispageurl->out(), $param->delete);
}
@@ -86,6 +100,7 @@
} else {
$questionstomove = 0;
}
+
if ($qcobject->catform->is_cancelled()) {
redirect($thispageurl);
} else if ($catformdata = $qcobject->catform->get_data()) {
@@ -101,21 +116,21 @@
redirect($thispageurl);
}
-if ($param->edit){
+if ($param->edit) {
$PAGE->navbar->add(get_string('editingcategory', 'question'));
}
-$PAGE->set_title($streditingcategories);
+$PAGE->set_title(get_string('editcategories', 'question'));
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();
-// display UI
+// Display the UI.
if (!empty($param->edit)) {
$qcobject->edit_single_category($param->edit);
} else if ($questionstomove){
$qcobject->display_move_form($questionstomove, $category);
} else {
- // display the user interface
+ // Display the user interface.
$qcobject->display_user_interface();
}
echo $OUTPUT->footer();
Please sign in to comment.
Something went wrong with that request. Please try again.