Can any one please exlplain has_capability to me?

Can any one please exlplain has_capability to me?

by Deborah Barnett -
Number of replies: 1

I am trying to make a variation of manage.php that shows assessments(I know there is a grade section already but I plan to make statistical graphs). My problem is that I don't quiet understand the following lines:

$allowtake = has_capability('mod/attforblock:takeattendances', $context);
$allowchange = has_capability('mod/attforblock:changeattendances', $context);
$allowmanage = has_capability('mod/attforblock:manageattendances', $context);

Am I right in saying that the capabilities are defined in access.php and that they only give defined users permission to take,change and manage attendance? And if so would you agree that the same permissions should be given for grading student's assessments?

Any help would really be appreciated.

As a little side note, I have not been using the get_string method when I am using a new word, i.e I just write the word in single quotation marks. What are the implications of this?

Thanks,

Deborah

Average of ratings: -
In reply to Deborah Barnett

Re: Can any one please exlplain has_capability to me?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you really want to understand, you need to read the Roles documentation.

Users have roles. Roles give (or don't) certain capabilities. Code should be written in terms of has_capability, so that administrators have maximum flexibility to control who does what by assigning and defining roles.


If you hard-code strings, then your code cannot be translated into other languages, and administrators cannot customise the text using the language editing interface.