MDL-15310: moving capability checks out of the library + code formatting adjustments
This commit is contained in:
+2
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('locallib.php');
|
||||
require_once('pagelib.php');
|
||||
require_once($CFG->dirroot.'/lib/weblib.php');
|
||||
require_once($CFG->dirroot.'/blog/lib.php');
|
||||
@@ -9,7 +10,7 @@ require_once($CFG->dirroot.'/blog/lib.php');
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->usetags)) {
|
||||
error(get_string('tagsaredisabled', 'tag'));
|
||||
print_error('tagsaredisabled', 'tag');
|
||||
}
|
||||
|
||||
$tagid = optional_param('id', 0, PARAM_INT); // tag id
|
||||
|
||||
@@ -47,9 +47,6 @@ define('TAG_RELATED_ALL', 0);
|
||||
define('TAG_RELATED_MANUAL', 1);
|
||||
define('TAG_RELATED_CORRELATED', 2);
|
||||
|
||||
|
||||
require_once($CFG->dirroot .'/tag/locallib.php');
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
/////////////////// PUBLIC TAG API ////////////////////
|
||||
|
||||
@@ -627,8 +624,6 @@ function tag_find_records($tag, $type, $limitfrom='', $limitnum='') {
|
||||
function tag_add($tags, $type="default") {
|
||||
global $USER, $DB;
|
||||
|
||||
require_capability('moodle/tag:create', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if (!is_array($tags)) {
|
||||
$tags = array($tags);
|
||||
}
|
||||
@@ -672,8 +667,6 @@ function tag_add($tags, $type="default") {
|
||||
function tag_assign($record_type, $record_id, $tagid, $ordering) {
|
||||
global $DB;
|
||||
|
||||
require_capability('moodle/tag:create', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ( $tag_instance_object = $DB->get_record('tag_instance', array('tagid'=>$tagid, 'itemtype'=>$record_type, 'itemid'=>$record_id), 'id')) {
|
||||
$tag_instance_object->ordering = $ordering;
|
||||
$tag_instance_object->timemodified = time();
|
||||
@@ -1011,8 +1004,6 @@ function tag_set_flag($tagids) {
|
||||
function tag_unset_flag($tagids) {
|
||||
global $DB;
|
||||
|
||||
require_capability('moodle/tag:manage', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ( is_array($tagids) ) {
|
||||
$tagids = implode(',', $tagids);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('lib.php');
|
||||
|
||||
/**
|
||||
* locallib.php - moodle tag local library - output functions
|
||||
*
|
||||
|
||||
+1
-1
@@ -19,7 +19,6 @@ if (empty($CFG->usetags)) {
|
||||
print_error('tagsaredisabled', 'tag');
|
||||
}
|
||||
|
||||
//managing tags requires moodle/tag:manage capability
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/tag:manage', $systemcontext);
|
||||
|
||||
@@ -119,6 +118,7 @@ switch($action) {
|
||||
// tag exists, change the type
|
||||
tag_set_type($new_otag_id, 'official');
|
||||
} else {
|
||||
require_capability('moodle/tag:create', get_context_instance(CONTEXT_SYSTEM));
|
||||
tag_add($new_otag, 'official');
|
||||
}
|
||||
$notice .= get_string('addedotag', 'tag', $new_otag) .' ';
|
||||
|
||||
+6
-5
@@ -2,24 +2,25 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('locallib.php');
|
||||
require_once($CFG->dirroot.'/lib/weblib.php');
|
||||
|
||||
global $CFG;
|
||||
require_login();
|
||||
|
||||
if( empty($CFG->usetags)) {
|
||||
error(get_string('tagsaredisabled', 'tag'));
|
||||
print_error('tagsaredisabled', 'tag');
|
||||
}
|
||||
|
||||
$query = optional_param('query', '', PARAM_RAW);
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', 18, PARAM_INT);
|
||||
$query = optional_param('query', '', PARAM_RAW);
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', 18, PARAM_INT);
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$manage_link = ' ';
|
||||
|
||||
print_header_simple(get_string('tags', 'tag'), '', $navigation);
|
||||
|
||||
Reference in New Issue
Block a user