From 92059c7ee5797c565306908c8166dce6df1a0c7e Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 23 Dec 2009 01:57:55 +0000 Subject: [PATCH] mod MDL-21169 Removed update this module button and ensured there was a link in the settings block for it. --- lang/en_utf8/folder.php | 1 + lang/en_utf8/imscp.php | 1 + lang/en_utf8/page.php | 1 + lang/en_utf8/url.php | 1 + mod/assignment/lib.php | 2 -- mod/chat/view.php | 8 ++--- mod/choice/report.php | 1 - mod/choice/view.php | 1 - mod/data/edit.php | 1 - mod/data/export.php | 1 - mod/data/lib.php | 1 - mod/data/templates.php | 1 - mod/data/view.php | 9 +++-- mod/feedback/analysis.php | 1 - mod/feedback/analysis_course.php | 1 - mod/feedback/complete.php | 1 - mod/feedback/complete_guest.php | 1 - mod/feedback/delete_completed.php | 1 - mod/feedback/delete_item.php | 1 - mod/feedback/delete_template.php | 1 - mod/feedback/edit.php | 1 - mod/feedback/edit_item.php | 1 - mod/feedback/import.php | 1 - mod/feedback/mapcourse.php | 1 - mod/feedback/print.php | 1 - mod/feedback/show_entries.php | 1 - mod/feedback/show_entries_anonym.php | 1 - mod/feedback/use_templ.php | 1 - mod/feedback/view.php | 1 - mod/folder/lib.php | 51 +++++++++++++++++++++++++++ mod/folder/view.php | 1 - mod/glossary/deleteentry.php | 1 - mod/glossary/editcategories.php | 1 - mod/glossary/export.php | 1 - mod/glossary/import.php | 1 - mod/glossary/view.php | 1 - mod/imscp/lib.php | 51 +++++++++++++++++++++++++++ mod/imscp/view.php | 1 - mod/lesson/locallib.php | 21 +++++------ mod/page/lib.php | 52 ++++++++++++++++++++++++++++ mod/page/view.php | 1 - mod/quiz/addrandom.php | 5 --- mod/quiz/attempt.php | 1 - mod/quiz/attemptlib.php | 15 -------- mod/quiz/edit.php | 6 +--- mod/quiz/report/default.php | 1 - mod/quiz/review.php | 1 - mod/quiz/summary.php | 1 - mod/quiz/view.php | 9 +++-- mod/survey/report.php | 1 - mod/survey/view.php | 1 - mod/url/lib.php | 50 ++++++++++++++++++++++++++ mod/url/locallib.php | 1 - 53 files changed, 228 insertions(+), 92 deletions(-) diff --git a/lang/en_utf8/folder.php b/lang/en_utf8/folder.php index 842a765b1b2..b2a68774375 100644 --- a/lang/en_utf8/folder.php +++ b/lang/en_utf8/folder.php @@ -2,6 +2,7 @@ $string['contentheader'] = 'Content'; $string['foldercontent'] = 'Files and subfolders'; +$string['folderadministration'] = 'Folder administration'; $string['modulename'] = 'Folder'; $string['modulenameplural'] = 'Folders'; $string['neverseen'] = 'Never seen'; diff --git a/lang/en_utf8/imscp.php b/lang/en_utf8/imscp.php index 5d71ccbdd44..414f803d2e7 100644 --- a/lang/en_utf8/imscp.php +++ b/lang/en_utf8/imscp.php @@ -6,6 +6,7 @@ $string['contentheader'] = 'Content'; $string['deploymenterror'] = 'Content package error!'; $string['keepold'] = 'Archive packages'; $string['keepoldexplain'] = 'How many packages should be archived?'; +$string['imscpadministration'] = 'IMSCP Administration'; $string['modulename'] = 'IMS Content Package'; $string['modulenameplural'] = 'IMS Content packages'; $string['navigation'] = 'Navigation'; diff --git a/lang/en_utf8/page.php b/lang/en_utf8/page.php index 983c7c1b267..a300273268c 100644 --- a/lang/en_utf8/page.php +++ b/lang/en_utf8/page.php @@ -13,6 +13,7 @@ $string['legacyfilesactive'] = 'Active'; $string['legacyfilesdone'] = 'Finished'; $string['modulename'] = 'Page'; $string['modulenameplural'] = 'Pages'; +$string['pageadministration'] = 'Page administration'; $string['popupheight'] = 'Popup height (in pixels)'; $string['popupheightexplain'] = 'Specifies default height of popup windows.'; $string['popupwidth'] = 'Popup width (in pixels)'; diff --git a/lang/en_utf8/url.php b/lang/en_utf8/url.php index 48f76ff5a75..0c2507c3a11 100644 --- a/lang/en_utf8/url.php +++ b/lang/en_utf8/url.php @@ -33,3 +33,4 @@ $string['printheadingexplain'] = 'Display URL name above content? Some display t $string['printintro'] = 'Display URL description'; $string['printintroexplain'] = 'Display URL description bellow content? Some display types may not display description even if enabled.'; $string['rolesinparams'] = 'Include role names in parameters'; +$string['urladministration'] = 'URL administration'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 011961182dc..a3eaf7ddc7d 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -186,7 +186,6 @@ class assignment_base { $PAGE->set_title($this->pagetitle); $PAGE->set_heading($this->course->fullname); - $PAGE->set_button($OUTPUT->update_module_button($this->cm->id, 'assignment')); echo $OUTPUT->header(); @@ -1126,7 +1125,6 @@ class assignment_base { add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->cm->id, $this->assignment->id, $this->cm->id); $PAGE->navbar->add($this->strsubmissions); $PAGE->set_title(format_string($this->assignment->name,true)); - $PAGE->set_button( update_module_button($cm->id, $course->id, $this->strassignment)); echo $OUTPUT->header(); $course_context = get_context_instance(CONTEXT_COURSE, $course->id); diff --git a/mod/chat/view.php b/mod/chat/view.php index 2219811c9f5..7ee891e1a06 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -72,18 +72,16 @@ $title = $course->shortname . ': ' . format_string($chat->name); - $buttons = ''; if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { - $buttons .= '
'.$OUTPUT->update_module_button($cm->id, $cm->modname).'
frametarget.' method="get" action="view.php">
'. + $buttons = ''; + '
frametarget.' method="get" action="view.php">
'. ''. ''. - '
'; + $PAGE->set_button($buttons); } - $buttons .= '
'; $PAGE->set_title($title); $PAGE->set_heading($course->fullname); - $PAGE->set_button($buttons); echo $OUTPUT->header(); /// Check to see if groups are being used here diff --git a/mod/choice/report.php b/mod/choice/report.php index 7812ea36673..7428ac58f4a 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -53,7 +53,6 @@ if (!$download) { $PAGE->navbar->add($strresponses); $PAGE->set_title(format_string($choice->name).": $strresponses"); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'choice')); echo $OUTPUT->header(); /// Check to see if groups are being used in this choice $groupmode = groups_get_activity_groupmode($cm); diff --git a/mod/choice/view.php b/mod/choice/view.php index c8ebe40b467..a2ed7ec5577 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -43,7 +43,6 @@ } $PAGE->set_title(format_string($choice->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'choice')); echo $OUTPUT->header(); /// Submit any new data if there is any diff --git a/mod/data/edit.php b/mod/data/edit.php index ffafe10ee9b..b6c91db4a21 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -131,7 +131,6 @@ if ($rid) { } $PAGE->set_title($data->name); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); /// Check to see if groups are being used here diff --git a/mod/data/export.php b/mod/data/export.php index 85a5eddae10..9489d13c385 100644 --- a/mod/data/export.php +++ b/mod/data/export.php @@ -83,7 +83,6 @@ if($mform->is_cancelled()) { } elseif (!$formdata = (array) $mform->get_data()) { // build header to match the rest of the UI $PAGE->set_title($data->name); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name)); diff --git a/mod/data/lib.php b/mod/data/lib.php index d9bc28f9a7d..a9ec74b3bc4 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1984,7 +1984,6 @@ function data_print_header($course, $cm, $data, $currenttab='') { global $CFG, $displaynoticegood, $displaynoticebad, $OUTPUT, $PAGE; $PAGE->set_title($data->name); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name)); diff --git a/mod/data/templates.php b/mod/data/templates.php index 9855a0e2e21..21214c43d78 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -91,7 +91,6 @@ $bodytag .= '" '; $PAGE->navbar->add(get_string($mode,'data')); $PAGE->requires->js('mod/data/data.js'); $PAGE->set_title($data->name); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name)); diff --git a/mod/data/view.php b/mod/data/view.php index d52b72d6075..35b8e8a2c89 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -282,14 +282,13 @@ // The code will be much nicer than this eventually. $title = $course->shortname.': ' . format_string($data->name); - $buttons = ''; if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { - $buttons .= '
'.$OUTPUT->update_module_button($cm->id, $cm->modname).'
frametarget.' method="get" action="view.php">
'. + $buttons = ''; + '
frametarget.' method="get" action="view.php">
'. ''. ''. - '
'; + $PAGE->set_button($buttons); } - $buttons .= '
'; if ($mode == 'asearch') { $PAGE->navbar->add(get_string('search')); @@ -297,7 +296,7 @@ $PAGE->set_title($title); $PAGE->set_heading($course->fullname); - $PAGE->set_button($buttons); + echo $OUTPUT->header(); /// Check to see if groups are being used here diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php index 46ccb985546..4636414d515 100644 --- a/mod/feedback/analysis.php +++ b/mod/feedback/analysis.php @@ -65,7 +65,6 @@ $strfeedback = get_string("modulename", "feedback"); $PAGE->navbar->add(get_string('analysis','feedback')); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// print the tabs diff --git a/mod/feedback/analysis_course.php b/mod/feedback/analysis_course.php index 67b5bbddd4a..5e5f9f30af7 100644 --- a/mod/feedback/analysis_course.php +++ b/mod/feedback/analysis_course.php @@ -73,7 +73,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// print the tabs diff --git a/mod/feedback/complete.php b/mod/feedback/complete.php index bfd24b36a28..4f994c22e37 100644 --- a/mod/feedback/complete.php +++ b/mod/feedback/complete.php @@ -127,7 +127,6 @@ $strfeedback = get_string("modulename", "feedback"); $PAGE->navbar->add(get_string('feedback:complete', 'feedback')); $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/complete.php', array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id))); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); //ishidden check. diff --git a/mod/feedback/complete_guest.php b/mod/feedback/complete_guest.php index 0c07c177b55..43318e8e1c2 100644 --- a/mod/feedback/complete_guest.php +++ b/mod/feedback/complete_guest.php @@ -131,7 +131,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); //ishidden check. hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities diff --git a/mod/feedback/delete_completed.php b/mod/feedback/delete_completed.php index c094887f52a..2b565025e1b 100644 --- a/mod/feedback/delete_completed.php +++ b/mod/feedback/delete_completed.php @@ -70,7 +70,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/delete_item.php b/mod/feedback/delete_item.php index aa975be19a9..eb4ff951033 100644 --- a/mod/feedback/delete_item.php +++ b/mod/feedback/delete_item.php @@ -62,7 +62,6 @@ $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/delete_template.php b/mod/feedback/delete_template.php index 4ebfdfb37a7..fbd6f207e63 100644 --- a/mod/feedback/delete_template.php +++ b/mod/feedback/delete_template.php @@ -87,7 +87,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// print the tabs diff --git a/mod/feedback/edit.php b/mod/feedback/edit.php index 3e081b7bb89..f6c082942f3 100644 --- a/mod/feedback/edit.php +++ b/mod/feedback/edit.php @@ -152,7 +152,6 @@ if ($do_show == 'edit') { } $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show))); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// print the tabs diff --git a/mod/feedback/edit_item.php b/mod/feedback/edit_item.php index 3ac893703d7..25adb1272c9 100644 --- a/mod/feedback/edit_item.php +++ b/mod/feedback/edit_item.php @@ -170,7 +170,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// print the tabs include('tabs.php'); diff --git a/mod/feedback/import.php b/mod/feedback/import.php index 44d3a012aa5..0a9fd2e1f6f 100644 --- a/mod/feedback/import.php +++ b/mod/feedback/import.php @@ -88,7 +88,6 @@ $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/mapcourse.php b/mod/feedback/mapcourse.php index 97c2c23d216..8b413d162e3 100644 --- a/mod/feedback/mapcourse.php +++ b/mod/feedback/mapcourse.php @@ -77,7 +77,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); include('tabs.php'); diff --git a/mod/feedback/print.php b/mod/feedback/print.php index 615eeb682c5..c416f4703dd 100644 --- a/mod/feedback/print.php +++ b/mod/feedback/print.php @@ -46,7 +46,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/show_entries.php b/mod/feedback/show_entries.php index 074db2878cb..75547aa7d55 100644 --- a/mod/feedback/show_entries.php +++ b/mod/feedback/show_entries.php @@ -71,7 +71,6 @@ $strfeedback = get_string("modulename", "feedback"); $PAGE->navbar->add(get_string('show_entries','feedback')); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); include('tabs.php'); diff --git a/mod/feedback/show_entries_anonym.php b/mod/feedback/show_entries_anonym.php index 98257b4b0af..e9a30f0da47 100644 --- a/mod/feedback/show_entries_anonym.php +++ b/mod/feedback/show_entries_anonym.php @@ -72,7 +72,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/use_templ.php b/mod/feedback/use_templ.php index 734ed426836..47fec370a23 100644 --- a/mod/feedback/use_templ.php +++ b/mod/feedback/use_templ.php @@ -73,7 +73,6 @@ $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/in $PAGE->navbar->add(format_string($feedback->name)); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); /// Print the main part of the page diff --git a/mod/feedback/view.php b/mod/feedback/view.php index f8116592c6f..882c0069be5 100644 --- a/mod/feedback/view.php +++ b/mod/feedback/view.php @@ -82,7 +82,6 @@ $strfeedback = get_string("modulename", "feedback"); $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/view.php', array('id'=>$cm->id, 'do_show'=>'view'))); $PAGE->set_title(format_string($feedback->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback')); echo $OUTPUT->header(); //ishidden check. diff --git a/mod/folder/lib.php b/mod/folder/lib.php index 4842edccd01..895417daae6 100644 --- a/mod/folder/lib.php +++ b/mod/folder/lib.php @@ -306,3 +306,54 @@ function folder_pluginfile($course, $cminfo, $context, $filearea, $args, $forced // finally send the file send_stored_file($file, 86400, 0, $forcedownload); } + +/** + * This function extends the global navigaiton for the site. + * It is important to note that you should not rely on PAGE objects within this + * body of code as there is no guarantee that during an AJAX request they are + * available + * + * @param navigation_node $navigation The folder node within the global navigation + * @param stdClass $course The course object returned from the DB + * @param stdClass $module The module object returned from the DB + * @param stdClass $cm The course module isntance returned from the DB + */ +function folder_extend_navigation($navigation, $course, $module, $cm) { + /** + * This is currently just a stub so that it can be easily expanded upon. + * When expanding just remove this comment and the line below and then add + * you content. + */ + $navigation->nodetype = navigation_node::NODETYPE_LEAF; +} + +/** + * This function extends the settings navigation block for the site. + * + * It is safe to rely on PAGE here as we will only ever be within the module + * context when this is called. + * + * @param settings_navigation $settings + * @param stdClass $module + */ +function folder_extend_settings_navigation($settings, $module) { + global $PAGE, $CFG, $DB; + + // Load the folder instance from the database + $folder = $DB->get_record('folder', array('id'=>$PAGE->cm->instance)); + // Add a folder node to the settings navigation. + $foldernavkey = $settings->add(get_string('folderadministration', 'folder')); + $foldernav = $settings->get($foldernavkey); + $foldernav->forceopen = true; + + // If the user has the capability add an update this module link for the folder instance + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $url = new moodle_url($CFG->wwwroot.'/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey())); + $foldernav->add(get_string('updatethis', '', get_string('modulename', 'folder')), $url); + } + + // Check if any children have been added. If not remove the node to save on clutter. + if (count($foldernav->children)<1) { + $settings->remove_child($foldernavkey); + } +} \ No newline at end of file diff --git a/mod/folder/view.php b/mod/folder/view.php index 785981d53cd..b217f6aecb8 100644 --- a/mod/folder/view.php +++ b/mod/folder/view.php @@ -53,7 +53,6 @@ $PAGE->requires->js('mod/folder/functions.js'); $PAGE->set_title($course->shortname.': '.$folder->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($folder); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'folder')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($folder->name), 2); diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 674f017c801..7aaa3af73c7 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -103,7 +103,6 @@ if ($confirm and confirm_sesskey()) { // the operation was confirmed. } else { // the operation has not been confirmed yet so ask the user to do so $PAGE->set_title(format_string($glossary->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'glossary')); echo $OUTPUT->header(); $areyousure = "".format_string($entry->concept)."

$strareyousuredelete

"; $linkyes = 'deleteentry.php'; diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index a2bfa24269c..4a2dcae7460 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -73,7 +73,6 @@ $PAGE->navbar->add($strglossaries, new moodle_url($CFG->wwwroot.'/mod/glossary/i $PAGE->navbar->add(format_string($glossary->name), new moodle_url($CFG->wwwroot.'/mod/glossary/view.php', array('id'=>$cm->id,'tab'=>'GLOSSARY_CATEGORY_VIEW'))); $PAGE->navbar->add(get_string("categories","glossary")); $PAGE->set_title(format_string($glossary->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'glossary')); echo $OUTPUT->header(); if ( $hook >0 ) { diff --git a/mod/glossary/export.php b/mod/glossary/export.php index bb1f46840e5..decac245fb4 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -52,7 +52,6 @@ $strexportentries = get_string('exportentriestoxml', 'glossary'); $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/glossary/export.php', array('id'=>$cm->id))); $PAGE->navbar->add($strexportentries); $PAGE->set_title(format_string($glossary->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'glossary')); echo $OUTPUT->header(); echo $OUTPUT->heading($strexportentries); diff --git a/mod/glossary/import.php b/mod/glossary/import.php index c93c54a5c01..9080713b45d 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -68,7 +68,6 @@ $strimportentries = get_string('importentriesfromxml', 'glossary'); $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/glossary/import.php', array('id'=>$cm->id, 'mode'=>$mode, 'hook'=>$hook))); $PAGE->navbar->add($strimportentries); $PAGE->set_title(format_string($glossary->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'glossary')); echo $OUTPUT->header(); echo $OUTPUT->heading($strimportentries); diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 1467818fa7f..ca056867f3a 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -230,7 +230,6 @@ $strwaitingapproval = get_string('waitingapproval', 'glossary'); /// If we are in approval mode, prit special header $PAGE->set_title(format_string($glossary->name)); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'glossary')); $url = new moodle_url($CFG->wwwroot.'/mod/glossary/view.php', array('id'=>$cm->id)); if (isset($mode)) { $url->param('mode', $mode); diff --git a/mod/imscp/lib.php b/mod/imscp/lib.php index 1ab3519e0d5..25f5173b509 100644 --- a/mod/imscp/lib.php +++ b/mod/imscp/lib.php @@ -373,3 +373,54 @@ function imscp_pluginfile($course, $cminfo, $context, $filearea, $args, $forcedo return false; } } + +/** + * This function extends the global navigaiton for the site. + * It is important to note that you should not rely on PAGE objects within this + * body of code as there is no guarantee that during an AJAX request they are + * available + * + * @param navigation_node $navigation The imscp node within the global navigation + * @param stdClass $course The course object returned from the DB + * @param stdClass $module The module object returned from the DB + * @param stdClass $cm The course module isntance returned from the DB + */ +function imscp_extend_navigation($navigation, $course, $module, $cm) { + /** + * This is currently just a stub so that it can be easily expanded upon. + * When expanding just remove this comment and the line below and then add + * you content. + */ + $navigation->nodetype = navigation_node::NODETYPE_LEAF; +} + +/** + * This function extends the settings navigation block for the site. + * + * It is safe to rely on PAGE here as we will only ever be within the module + * context when this is called. + * + * @param settings_navigation $settings + * @param stdClass $module + */ +function imscp_extend_settings_navigation($settings, $module) { + global $PAGE, $CFG, $DB; + + // Load the imscp instance from the database + $imscp = $DB->get_record('imscp', array('id'=>$PAGE->cm->instance)); + // Add a imscp node to the settings navigation. + $imscpnavkey = $settings->add(get_string('imscpadministration', 'imscp')); + $imscpnav = $settings->get($imscpnavkey); + $imscpnav->forceopen = true; + + // If the user has the capability add an update this module link for the imscp instance + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $imscp = new moodle_imscp($CFG->wwwroot.'/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey())); + $imscpnav->add(get_string('updatethis', '', get_string('modulename', 'imscp')), $imscp); + } + + // Check if any children have been added. If not remove the node to save on clutter. + if (count($imscpnav->children)<1) { + $settings->remove_child($imscpnavkey); + } +} \ No newline at end of file diff --git a/mod/imscp/view.php b/mod/imscp/view.php index 92f57e76860..4cb7f941382 100644 --- a/mod/imscp/view.php +++ b/mod/imscp/view.php @@ -67,7 +67,6 @@ $PAGE->requires->string_for_js('show', 'moodle'); $PAGE->set_title($course->shortname.': '.$imscp->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($imscp); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'imscp')); echo $OUTPUT->header(); // verify imsmanifest was parsed properly diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 90ad679cd3f..e02d9601a9a 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -562,19 +562,14 @@ function lesson_menu_block_contents($cmid, $lesson) { */ function lesson_add_header_buttons($cm, $context, $extraeditbuttons=false, $lessonpageid=null) { global $CFG, $PAGE, $OUTPUT; - if (has_capability('mod/lesson:edit', $context)) { - $buttons = $OUTPUT->update_module_button($cm->id, 'lesson'); - if ($extraeditbuttons) { - if ($lessonpageid === null) { - print_error('invalidpageid', 'lesson'); - } - if (!empty($lessonpageid) && $lessonpageid != LESSON_EOL) { - $options = array('id'=>$cm->id, 'redirect'=>'navigation', 'pageid'=>$lessonpageid); - $buttonform = html_form::make_button($CFG->wwwroot.'/mod/lesson/lesson.php', $options, get_string('editpagecontent', 'lesson')); - $buttons .= $OUTPUT->button($buttonform); - } - $buttons = $OUTPUT->box($buttons, 'edit_buttons'); + if (has_capability('mod/lesson:edit', $context) && $extraeditbuttons) { + if ($lessonpageid === null) { + print_error('invalidpageid', 'lesson'); + } + if (!empty($lessonpageid) && $lessonpageid != LESSON_EOL) { + $options = array('id'=>$cm->id, 'redirect'=>'navigation', 'pageid'=>$lessonpageid); + $buttonform = html_form::make_button($CFG->wwwroot.'/mod/lesson/lesson.php', $options, get_string('editpagecontent', 'lesson')); + $PAGE->set_button($OUTPUT->button($buttonform)); } - $PAGE->set_button($buttons); } } \ No newline at end of file diff --git a/mod/page/lib.php b/mod/page/lib.php index 01fb5a68897..5507f00386c 100644 --- a/mod/page/lib.php +++ b/mod/page/lib.php @@ -378,3 +378,55 @@ function page_pluginfile($course, $cminfo, $context, $filearea, $args, $forcedow // finally send the file send_stored_file($file, 86400, 0, $forcedownload); } + + +/** + * This function extends the global navigaiton for the site. + * It is important to note that you should not rely on PAGE objects within this + * body of code as there is no guarantee that during an AJAX request they are + * available + * + * @param navigation_node $navigation The page node within the global navigation + * @param stdClass $course The course object returned from the DB + * @param stdClass $module The module object returned from the DB + * @param stdClass $cm The course module isntance returned from the DB + */ +function page_extend_navigation($navigation, $course, $module, $cm) { + /** + * This is currently just a stub so that it can be easily expanded upon. + * When expanding just remove this comment and the line below and then add + * you content. + */ + $navigation->nodetype = navigation_node::NODETYPE_LEAF; +} + +/** + * This function extends the settings navigation block for the site. + * + * It is safe to rely on PAGE here as we will only ever be within the module + * context when this is called. + * + * @param settings_navigation $settings + * @param stdClass $module + */ +function page_extend_settings_navigation($settings, $module) { + global $PAGE, $CFG, $DB; + + // Load the page instance from the database + $page = $DB->get_record('page', array('id'=>$PAGE->cm->instance)); + // Add a page node to the settings navigation. + $pagenavkey = $settings->add(get_string('pageadministration', 'page')); + $pagenav = $settings->get($pagenavkey); + $pagenav->forceopen = true; + + // If the user has the capability add an update this module link for the page instance + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $url = new moodle_url($CFG->wwwroot.'/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey())); + $pagenav->add(get_string('updatethis', '', get_string('modulename', 'page')), $url); + } + + // Check if any children have been added. If not remove the node to save on clutter. + if (count($pagenav->children)<1) { + $settings->remove_child($pagenavkey); + } +} \ No newline at end of file diff --git a/mod/page/view.php b/mod/page/view.php index c0fd27976b2..e995639426f 100644 --- a/mod/page/view.php +++ b/mod/page/view.php @@ -70,7 +70,6 @@ if ($inpopup and $page->display == RESOURCELIB_DISPLAY_POPUP) { $PAGE->set_title($course->shortname.': '.$page->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($page); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'page')); echo $OUTPUT->header(); if (!empty($options['printheading'])) { diff --git a/mod/quiz/addrandom.php b/mod/quiz/addrandom.php index a1e6db45285..e477a4bf4be 100644 --- a/mod/quiz/addrandom.php +++ b/mod/quiz/addrandom.php @@ -76,13 +76,8 @@ if (! $course = $DB->get_record('course', array('id' => $quiz->course))) { require_capability('mod/quiz:manage', $contexts->lowest()); // Print basic page layout. -$strupdatemodule = ''; -if (has_capability('moodle/course:manageactivities', $contexts->lowest())) { - $strupdatemodule = $OUTPUT->update_module_button($cm->id, 'quiz'); -} $PAGE->navbar->add($streditingquiz); $PAGE->set_title($streditingquiz); -$PAGE->set_button($strupdatemodule); echo $OUTPUT->header(); if (!$quizname = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance))) { diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 9242b15db4c..1a88d0ebc9f 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -105,7 +105,6 @@ echo $OUTPUT->header(); } else { $PAGE->set_title(format_string($attemptobj->get_quiz_name())); - $PAGE->set_button($attemptobj->update_module_button()); echo $OUTPUT->header(); } echo ''; // for overlib diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 7209f507f03..4d8631a4cb2 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -315,21 +315,6 @@ class quiz { } // Bits of content ===================================================================== - /** - * @return string the HTML snipped that needs to be supplied to print_header_simple - * as the $button parameter. - */ - public function update_module_button() { - global $OUTPUT ; - if (has_capability('moodle/course:manageactivities', - get_context_instance(CONTEXT_COURSE, $this->course->id))) { - - - return $OUTPUT->update_module_button($this->cm->id, 'quiz'); - } else { - return ''; - } - } /** * @param string $title the name of this particular quiz page. diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 0f98ab10ae3..1b1576ba1bc 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -438,17 +438,13 @@ $questionbank->process_actions($thispageurl, $cm); $questionbankmanagement = ''. get_string('questionbankmanagement', 'quiz').' '; -$strupdatemodule = has_capability('moodle/course:manageactivities', - $contexts->lowest()) ? - $OUTPUT->update_module_button($cm->id, 'quiz') : - ""; $PAGE->navbar->add($pagetitle); $PAGE->requires->skip_link_to('questionbank', get_string('skipto', 'access', get_string('questionbank', 'question'))); $PAGE->requires->skip_link_to('quizcontentsblock', get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz'))); $PAGE->set_title($pagetitle); -$PAGE->set_button($questionbankmanagement.$strupdatemodule); +$PAGE->set_button($questionbankmanagement); echo $OUTPUT->header(); // Initialise the JavaScript. diff --git a/mod/quiz/report/default.php b/mod/quiz/report/default.php index 52d6e921de0..dd75cf94774 100644 --- a/mod/quiz/report/default.php +++ b/mod/quiz/report/default.php @@ -28,7 +28,6 @@ class quiz_default_report { $strquiz = get_string("modulename", "quiz"); /// Print the page header $PAGE->set_title(format_string($quiz->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'quiz')); echo $OUTPUT->header(); /// Print the tabs $currenttab = 'reports'; diff --git a/mod/quiz/review.php b/mod/quiz/review.php index bbc77a60862..015697d8760 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -99,7 +99,6 @@ } else { $attemptobj->navigation($strreviewtitle); $PAGE->set_title(format_string($attemptobj->get_quiz_name())); - $PAGE->set_button($attemptobj->update_module_button()); echo $OUTPUT->header(); } echo ''; // for overlib diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 8780cb38be6..0f918e4ee49 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -59,7 +59,6 @@ if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { } else { $attemptobj->navigation($title); $PAGE->set_title(format_string($attemptobj->get_quiz_name())); - $PAGE->set_button($attemptobj->update_module_button()); echo $OUTPUT->header(); } diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 14ac628a6ce..7cd5df7e9ea 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -72,18 +72,17 @@ // The code will be much nicer than this eventually. $title = $course->shortname . ': ' . format_string($quiz->name); - $buttons = ''; if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { - $buttons .= '
'.$OUTPUT->update_module_button($cm->id, $cm->modname).'
frametarget.' method="get" action="view.php">
'. + $buttons = ''; + '
frametarget.' method="get" action="view.php">
'. ''. ''. - '
'; + $PAGE->set_button($buttons); } - $buttons .= '
'; $PAGE->set_title($title); $PAGE->set_heading($course->fullname); - $PAGE->set_button($buttons); + echo $OUTPUT->header(); /// Print heading and tabs (if there is more than one). diff --git a/mod/survey/report.php b/mod/survey/report.php index 8763493b4e5..c7b300f0df0 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -119,7 +119,6 @@ $PAGE->set_title("$course->shortname: ".format_string($survey->name)); $PAGE->set_heading($course->fullname); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'survey')); echo $OUTPUT->header(); /// Check to see if groups are being used in this survey diff --git a/mod/survey/view.php b/mod/survey/view.php index 6b84b6b0659..ae0418bf1b6 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -59,7 +59,6 @@ $strsurvey = get_string("modulename", "survey"); $PAGE->set_title(format_string($survey->name)); - $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'survey')); echo $OUTPUT->header(); /// Check to see if groups are being used in this survey diff --git a/mod/url/lib.php b/mod/url/lib.php index 304903fa9e8..7bcdbcc1cc9 100644 --- a/mod/url/lib.php +++ b/mod/url/lib.php @@ -286,3 +286,53 @@ function url_get_coursemodule_info($coursemodule) { return $info; } +/** + * This function extends the global navigaiton for the site. + * It is important to note that you should not rely on PAGE objects within this + * body of code as there is no guarantee that during an AJAX request they are + * available + * + * @param navigation_node $navigation The url node within the global navigation + * @param stdClass $course The course object returned from the DB + * @param stdClass $module The module object returned from the DB + * @param stdClass $cm The course module isntance returned from the DB + */ +function url_extend_navigation($navigation, $course, $module, $cm) { + /** + * This is currently just a stub so that it can be easily expanded upon. + * When expanding just remove this comment and the line below and then add + * you content. + */ + $navigation->nodetype = navigation_node::NODETYPE_LEAF; +} + +/** + * This function extends the settings navigation block for the site. + * + * It is safe to rely on PAGE here as we will only ever be within the module + * context when this is called. + * + * @param settings_navigation $settings + * @param stdClass $module + */ +function url_extend_settings_navigation($settings, $module) { + global $PAGE, $CFG, $DB; + + // Load the url instance from the database + $url = $DB->get_record('url', array('id'=>$PAGE->cm->instance)); + // Add a url node to the settings navigation. + $urlnavkey = $settings->add(get_string('urladministration', 'url')); + $urlnav = $settings->get($urlnavkey); + $urlnav->forceopen = true; + + // If the user has the capability add an update this module link for the url instance + if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) { + $url = new moodle_url($CFG->wwwroot.'/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey())); + $urlnav->add(get_string('updatethis', '', get_string('modulename', 'url')), $url); + } + + // Check if any children have been added. If not remove the node to save on clutter. + if (count($urlnav->children)<1) { + $settings->remove_child($urlnavkey); + } +} \ No newline at end of file diff --git a/mod/url/locallib.php b/mod/url/locallib.php index 4e7ae7a0592..ca7dffc520e 100644 --- a/mod/url/locallib.php +++ b/mod/url/locallib.php @@ -83,7 +83,6 @@ function url_print_header($url, $cm, $course) { $PAGE->set_title($course->shortname.': '.$url->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($url); - $PAGE->set_button(update_module_button($cm->id, '', get_string('modulename', 'url'))); echo $OUTPUT->header(); }