From: tjhunt Date: Tue, 21 Jul 2009 09:16:25 +0000 (+0000) Subject: tags: part of MDL-19823 - make sure tag pages are in the right context, and set ... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0edd65352f6a25e040d0b2cc79c3fbaeaa1ee20d;p=moodle.git tags: part of MDL-19823 - make sure tag pages are in the right context, and set $PAGE->url --- diff --git a/tag/edit.php b/tag/edit.php index e9cad2e20a..e9e8e83b9f 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -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); diff --git a/tag/index.php b/tag/index.php index a254f1d64b..80ee643580 100644 --- a/tag/index.php +++ b/tag/index.php @@ -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 '' ; } diff --git a/tag/manage.php b/tag/manage.php index 01cc5a6932..0c86b65347 100644 --- a/tag/manage.php +++ b/tag/manage.php @@ -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' => '');