mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
tags: part of MDL-19823 - make sure tag pages are in the right context, and set $PAGE->url
This commit is contained in:
parent
4aa31a61f0
commit
0edd65352f
22
tag/edit.php
22
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);
|
||||
|
@ -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>' ;
|
||||
}
|
||||
|
@ -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' => '');
|
||||
|
Loading…
x
Reference in New Issue
Block a user