From d8ae33a95c5cc69cc13bacac79a51bfe6c82c0fd Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 23 Dec 2009 02:45:22 +0000 Subject: [PATCH] question MDL-21169 removed update_module_button calls from question these are now added by the module extending the navigation if there is a module specified for question pages. Also fixed bug in moodle_url object coding_error to coding_exception --- lib/pagelib.php | 2 +- lib/weblib.php | 6 +++--- question/addquestion.php | 1 - question/category.php | 14 +------------- question/contextmove.php | 12 ------------ question/contextmoveq.php | 13 ------------- question/edit.php | 6 ------ question/export.php | 6 ------ question/import.php | 6 ------ question/question.php | 6 ------ 10 files changed, 5 insertions(+), 67 deletions(-) diff --git a/lib/pagelib.php b/lib/pagelib.php index a7cd74a17a..8f0047dde3 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -1630,7 +1630,7 @@ class page_generic_activity extends page_base { $title = str_replace($search, $replace, $title); } - $buttons = ''; + $buttons = '
'.update_module_button($this->modulerecord->id, $this->course->id, get_string('modulename', $this->activityname)).'
'; if ($this->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { $buttons .= '
'.$OUTPUT->update_module_button($this->modulerecord->id, $this->activityname).'
frametarget.' method="get" action="view.php">
'. ''. diff --git a/lib/weblib.php b/lib/weblib.php index 3b9acbaf01..ef46fa17f9 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -341,13 +341,13 @@ class moodle_url { foreach ($params as $key=>$value) { if (is_int($key)) { - throw new coding_error('Url parameters can not have numeric keys!'); + throw new coding_exception('Url parameters can not have numeric keys!'); } if (is_array($value)) { - throw new coding_error('Url parameters values can not be arrays!'); + throw new coding_exception('Url parameters values can not be arrays!'); } if (is_object($value) and !method_exists($value, '__toString')) { - throw new coding_error('Url parameters values can not be objects, unless __toString() is defined!'); + throw new coding_exception('Url parameters values can not be objects, unless __toString() is defined!'); } $this->params[$key] = (string)$value; } diff --git a/question/addquestion.php b/question/addquestion.php index 7a3ee303af..cc39b46035 100644 --- a/question/addquestion.php +++ b/question/addquestion.php @@ -86,7 +86,6 @@ if ($cm !== null) { } $PAGE->navbar->add($chooseqtype); $PAGE->set_title($chooseqtype); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, $cm->modname)); echo $OUTPUT->header(); } else { $PAGE->navbar->add(get_string('questionbank', 'question'),$returnurl); diff --git a/question/category.php b/question/category.php index 7ac6930e20..c13777bd60 100644 --- a/question/category.php +++ b/question/category.php @@ -34,7 +34,7 @@ $param->moveto = optional_param('moveto', 0, PARAM_INT); $param->edit = optional_param('edit', 0, PARAM_INT); - $url = new moodle_url($thispageurl); + $url = new moodle_url($CFG->wwwroot.$thispageurl); foreach ((array)$param as $key=>$value) { if (($key !== 'cancel' && $value !== 0) || ($key === 'cancel' && $value !== '')) { $url->param($key, $value); @@ -87,17 +87,6 @@ $thispageurl->remove_params('cat', 'category'); redirect($thispageurl); } - if ($cm!==null) { - // Page header - $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); - } else { - // Print basic page layout. - $strupdatemodule = ''; - } if (!$param->edit){ $PAGE->navbar->add($streditingcategories); @@ -107,7 +96,6 @@ } $PAGE->set_title($streditingcategories); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); // print tabs diff --git a/question/contextmove.php b/question/contextmove.php index 5982dee61d..f7bd51583e 100644 --- a/question/contextmove.php +++ b/question/contextmove.php @@ -187,23 +187,11 @@ } $streditingcategories = get_string('editcategories', 'quiz'); - if ($cm!==null) { - // Page header - $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); - } else { - // Print basic page layout. - $strupdatemodule = ''; - } $PAGE->set_url($thispageurl->out()); $PAGE->navbar->add($streditingcategories, $thispageurl->out()); $PAGE->navbar->add(get_string('movingcategory', 'question')); $PAGE->set_title($streditingcategories); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); // print tabs diff --git a/question/contextmoveq.php b/question/contextmoveq.php index f19b80fc5a..9b82b3e59f 100644 --- a/question/contextmoveq.php +++ b/question/contextmoveq.php @@ -169,23 +169,10 @@ if ($contextmoveform->is_cancelled()){ } $streditingcategories = get_string('editcategories', 'quiz'); -if ($cmid) { - // Page header - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - $strupdatemodule = has_capability('moodle/course:manageactivities', $context) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); -} else { - // Print basic page layout. - $strupdatemodule = ''; -} $strmovingquestions = get_string('movingquestions', 'question'); $PAGE->set_url($thispageurl->out()); $PAGE->navbar->add($strmovingquestions); $PAGE->set_title($strmovingquestions); -$PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); // print tabs diff --git a/question/edit.php b/question/edit.php index 53d1a010f0..1d1b42904f 100644 --- a/question/edit.php +++ b/question/edit.php @@ -63,14 +63,8 @@ $context = $contexts->lowest(); $streditingquestions = get_string('editquestions', "quiz"); if ($cm!==null) { - $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); $PAGE->navbar->add($streditingquestions); $PAGE->set_title($streditingquestions); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); $currenttab = 'edit'; diff --git a/question/export.php b/question/export.php index 1e999843cd..7a57c4a362 100644 --- a/question/export.php +++ b/question/export.php @@ -35,13 +35,7 @@ $PAGE->set_url($thispageurl->out()); $PAGE->set_title($strexportquestions); if ($cm!==null) { - $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); $PAGE->navbar->add($strexportquestions); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); $currenttab = 'edit'; $mode = 'export'; diff --git a/question/import.php b/question/import.php index 21a926bc04..bde0415f0b 100644 --- a/question/import.php +++ b/question/import.php @@ -57,14 +57,8 @@ //========== if ($cm!==null) { - $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id)) - ? $OUTPUT->update_module_button($cm->id, $cm->modname) - : ""; - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id))); - $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); $PAGE->navbar->add($txt->importquestions); $PAGE->set_title($txt->importquestions); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); $currenttab = 'edit'; diff --git a/question/question.php b/question/question.php index f430a3325f..c0f59169a2 100644 --- a/question/question.php +++ b/question/question.php @@ -279,12 +279,7 @@ if ($mform->is_cancelled()){ $PAGE->set_title($streditingquestion); if ($cm !== null) { $strmodule = get_string('modulename', $cm->modname); - $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id)) - ? $OUTPUT->update_module_button($cm->id, $strmodule) - : ""; - $streditingmodule = get_string('editinga', 'moodle', $strmodule); - $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$cm->course))); $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); if (stripos($returnurl, "$CFG->wwwroot/mod/{$cm->modname}/view.php")!== 0){ @@ -292,7 +287,6 @@ if ($mform->is_cancelled()){ $PAGE->navbar->add($streditingmodule, $returnurl); } $PAGE->navbar->add($streditingquestion); - $PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); } else { -- 2.39.5