Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37673

[Moodle 2.5] Adding new capabilities to an Individual or All modules and setting them

$
0
0
by Pranoy Agrawal.  

Hello Guys,
I want to hide a label from guest while show them to authorized users while show another label to guest but hide it from authorized user... So I followed the steps that are suggested in http://docs.moodle.org/dev/NEWMODULE_Adding_capabilities and https://moodle.org/mod/forum/discuss.php?d=195395 to add new capability for View..
But it wasn't successful.. I also tried adding this capability to label module only..but again was not successful.. on the contrary the hiding facility of the label became buggy...
I am a bit new to moodle and hence I think I am making mistake in putting up the code at right place.. Can anyone please help me out ? I am using Moodle 2.5(20130501)

Steps I Followed which were Unsuccessful:

1. Added new core capability 'moodle/mod:view' in lib/db/access.php.

'moodle/mod:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'user' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
)
),

2. A respective string in lang/en/role.php

$string['mod:view'] = 'View mod';

3. A condition in course/lib.php

if (!has_capability('moodle/mod:view',
get_context_instance(CONTEXT_MODULE, $mod->id))) {
continue;
}

4.Upgraded

I think I made mistake in placing the step 3 code line...


Viewing all articles
Browse latest Browse all 37673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>