Skip to content

Commit

Permalink
MDL-30482 - Glossary - Adding capability to other areas using glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnfwlr committed Dec 12, 2011
1 parent b92ac8c commit d79de19
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions blocks/glossary_random/block_glossary_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ function instance_allow_multiple() {
function get_content() {
global $USER, $CFG, $DB;

if (!has_capability('mod/glossary:read', $this->context)) {
return "";
}

if (empty($this->config->glossary)) {
$this->content->text = get_string('notyetconfigured','block_glossary_random');
$this->content->footer = '';
Expand Down
2 changes: 1 addition & 1 deletion filter/glossary/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function filter($text, array $options = array()) {
$nothingtodo = false;
}

if ($nothingtodo === true) {
if (($nothingtodo === true) || (!has_capability('mod/glossary:read', $this->context))) {
return $text;
}

Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
),


'mod/glossary:write' => array(
Expand Down
7 changes: 5 additions & 2 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function glossary_user_complete($course, $user, $mod, $glossary) {
* @return bool
*/
function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
global $CFG, $USER, $DB, $OUTPUT;
global $CFG, $USER, $DB, $OUTPUT, $PAGE;

//TODO: use timestamp in approved field instead of changing timemodified when approving in 2.0
if (!defined('GLOSSARY_RECENT_ACTIVITY_LIMIT')) {
Expand Down Expand Up @@ -351,6 +351,9 @@ function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
$approvals = array();
foreach ($ids as $glinstanceid => $glcmid) {
$context = get_context_instance(CONTEXT_MODULE, $glcmid);
if (!has_capability('mod/glossary:read', $context)) {
continue;
}
// get records glossary entries that are approved if user has no capability to approve entries.
if (has_capability('mod/glossary:approve', $context)) {
$approvals[] = ' ge.glossaryid = :glsid'.$glinstanceid.' ';
Expand Down Expand Up @@ -2771,7 +2774,7 @@ function glossary_extend_settings_navigation(settings_navigation $settings, navi

$glossary = $DB->get_record('glossary', array("id" => $PAGE->cm->instance));

if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles && can_access_course($PAGE->course, $USER)) {
if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles && has_capability('mod/glossary:read', $PAGE->cm->context)) {
require_once("$CFG->libdir/rsslib.php");

$string = get_string('rsstype','forum');
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

defined('MOODLE_INTERNAL') || die();

$module->version = 2011112900; // The current module version (Date: YYYYMMDDXX)
$module->version = 2011120200; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011112900; // Requires this Moodle version
$module->component = 'mod_glossary'; // Full name of the plugin (used for diagnostics)
$module->cron = 0;

0 comments on commit d79de19

Please sign in to comment.