]> git.mjollnir.org Git - moodle.git/commitdiff
tags: part of MDL-19823 - make sure tag pages are in the right context, and set ...
authortjhunt <tjhunt>
Tue, 21 Jul 2009 09:16:25 +0000 (09:16 +0000)
committertjhunt <tjhunt>
Tue, 21 Jul 2009 09:16:25 +0000 (09:16 +0000)
tag/edit.php
tag/index.php
tag/manage.php

index e9cad2e20afb1c74be13ba8c3fabdc05fc5f6862..e9e8e83b9f0d5fd1222921037e52227ed8723538 100644 (file)
@@ -4,8 +4,8 @@ require_once('../config.php');
 require_once('lib.php');
 require_once('edit_form.php');
 
-$PAGE->requires->yui_lib('animation');
-$PAGE->requires->yui_lib('autocomplete');
+$tag_id = optional_param('id', 0, PARAM_INT);
+$tag_name = optional_param('tag', '', PARAM_TAG);
 
 require_login();
 
@@ -13,8 +13,9 @@ if (empty($CFG->usetags)) {
     print_error('tagsaredisabled', 'tag');
 }
 
-$tag_id = optional_param('id', 0, PARAM_INT);
-$tag_name = optional_param('tag', '', PARAM_TAG);
+//Editing a tag requires moodle/tag:edit capability
+$systemcontext   = get_context_instance(CONTEXT_SYSTEM);
+require_capability('moodle/tag:edit', $systemcontext);
 
 if ($tag_name) {
     $tag = tag_get('name', $tag_name, '*');
@@ -26,11 +27,16 @@ if (empty($tag)) {
     redirect($CFG->wwwroot.'/tag/search.php');
 }
 
-$tagname = tag_display_name($tag);
+$PAGE->set_url('tag/index.php', array('id' => $tag->id));
+$PAGE->set_subpage($tag->id);
+$PAGE->set_context($systemcontext);
+$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
+$PAGE->set_generaltype('form');
 
-//Editing a tag requires moodle/tag:edit capability
-$systemcontext   = get_context_instance(CONTEXT_SYSTEM);
-require_capability('moodle/tag:edit', $systemcontext);
+$PAGE->requires->yui_lib('animation');
+$PAGE->requires->yui_lib('autocomplete');
+
+$tagname = tag_display_name($tag);
 
 // set the relatedtags field of the $tag object that will be passed to the form
 $tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
index a254f1d64b4b55c115778dba1a981e9dc3bb18c1..80ee643580b19a21390d401ff6f94eb23602d953 100644 (file)
@@ -19,6 +19,7 @@ $edit        = optional_param('edit', -1, PARAM_BOOL);
 $userpage    = optional_param('userpage', 0, PARAM_INT); // which page to show
 $perpage     = optional_param('perpage', 24, PARAM_INT);
 
+$systemcontext   = get_context_instance(CONTEXT_SYSTEM);
 
 if ($tagname) {
     $tag = tag_get('name', $tagname, '*');
@@ -32,6 +33,7 @@ if (empty($tag)) {
 
 $PAGE->set_url('tag/index.php', array('id' => $tag->id));
 $PAGE->set_subpage($tag->id);
+$PAGE->set_context($systemcontext);
 $PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
 
 if (($edit != -1) and $PAGE->user_allowed_editing()) {
@@ -54,8 +56,6 @@ if ($PAGE->user_allowed_editing() ) {
 print_header_simple($title, '', $navigation, '', '', '', $button);
 
 // Manage all tags links
-$systemcontext   = get_context_instance(CONTEXT_SYSTEM);
-
 if (has_capability('moodle/tag:manage', $systemcontext)) {
     echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">'. get_string('managetags', 'tag') .'</a></div>' ;
 }
index 01cc5a693298ca7c3cc6bf5e2610f2d0f375c0d0..0c86b65347352306472edebd2348e34957aa085e 100644 (file)
@@ -19,9 +19,17 @@ if (empty($CFG->usetags)) {
     print_error('tagsaredisabled', 'tag');
 }
 
-$systemcontext   = get_context_instance(CONTEXT_SYSTEM);
+$systemcontext = get_context_instance(CONTEXT_SYSTEM);
 require_capability('moodle/tag:manage', $systemcontext);
 
+$params = array();
+if ($perpage != DEFAULT_PAGE_SIZE) {
+    $params['perpage'] = $perpage;
+}
+$PAGE->set_url('tag/manage.php', $params);
+$PAGE->set_context($systemcontext);
+$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
+
 $navlinks = array();
 $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
 $navlinks[] = array('name' => get_string('managetags', 'tag'), 'link' => '', 'type' => '');