Skip to content

Commit

Permalink
MDL-15310: moving capability checks out of the library + code formatt…
Browse files Browse the repository at this point in the history
…ing adjustments
  • Loading branch information
scyrma committed Jun 19, 2008
1 parent 47a2c30 commit 48d5652
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
3 changes: 2 additions & 1 deletion tag/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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');

require_login();

if (empty($CFG->usetags)) {
error(get_string('tagsaredisabled', 'tag'));
print_error('tagsaredisabled', 'tag');
}

$tagid = optional_param('id', 0, PARAM_INT); // tag id
Expand Down
9 changes: 0 additions & 9 deletions tag/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
define('TAG_RELATED_MANUAL', 1);
define('TAG_RELATED_CORRELATED', 2);


require_once($CFG->dirroot .'/tag/locallib.php');

///////////////////////////////////////////////////////
/////////////////// PUBLIC TAG API ////////////////////

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions tag/locallib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php // $Id$

require_once('lib.php');

/**
* locallib.php - moodle tag local library - output functions
*
Expand Down
2 changes: 1 addition & 1 deletion tag/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
print_error('tagsaredisabled', 'tag');
}

//managing tags requires moodle/tag:manage capability
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/tag:manage', $systemcontext);

Expand Down Expand Up @@ -119,6 +118,7 @@
// 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) .' ';
Expand Down
11 changes: 6 additions & 5 deletions tag/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '&nbsp;';

print_header_simple(get_string('tags', 'tag'), '', $navigation);
Expand Down

0 comments on commit 48d5652

Please sign in to comment.