MDL-21781 cohort capabilities
[moodle.git] / lib / db / access.php
1 <?php
2 //
3 // Capability definitions for Moodle core.
4 //
5 // The capabilities are loaded into the database table when the module is
6 // installed or updated. Whenever the capability definitions are updated,
7 // the module version number should be bumped up.
8 //
9 // The system has four possible values for a capability:
10 // CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
11 //
12 //
13 // CAPABILITY NAMING CONVENTION
14 //
15 // It is important that capability names are unique. The naming convention
16 // for capabilities that are specific to modules and blocks is as follows:
17 //   [mod/block]/<plugin_name>:<capabilityname>
18 //
19 // component_name should be the same as the directory name of the mod or block.
20 //
21 // Core moodle capabilities are defined thus:
22 //    moodle/<capabilityclass>:<capabilityname>
23 //
24 // Examples: mod/forum:viewpost
25 //           block/recent_activity:view
26 //           moodle/site:deleteuser
27 //
28 // The variable name for the capability definitions array is $capabilities
31 $capabilities = array(
32     'moodle/site:config' => array(
34         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG | RISK_DATALOSS,
36         'captype' => 'write',
37         'contextlevel' => CONTEXT_SYSTEM,
38         'legacy' => array(
39         )
40     ),
42     'moodle/site:readallmessages' => array(
44         'riskbitmask' => RISK_PERSONAL,
46         'captype' => 'read',
47         'contextlevel' => CONTEXT_SYSTEM,
48         'legacy' => array(
49             'manager' => CAP_ALLOW,
50             'editingteacher' => CAP_ALLOW
51         )
52     ),
54     'moodle/site:sendmessage' => array(
56         'riskbitmask' => RISK_SPAM,
58         'captype' => 'write',
59         'contextlevel' => CONTEXT_SYSTEM,
60         'legacy' => array(
61             'manager' => CAP_ALLOW,
62             'user' => CAP_ALLOW
63         )
64     ),
66     'moodle/site:approvecourse' => array(
68         'riskbitmask' => RISK_XSS,
70         'captype' => 'write',
71         'contextlevel' => CONTEXT_SYSTEM,
72         'legacy' => array(
73             'manager' => CAP_ALLOW
74         )
75     ),
77     'moodle/backup:backupcourse' => array(
79         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
81         'captype' => 'write',
82         'contextlevel' => CONTEXT_COURSE,
83         'legacy' => array(
84             'editingteacher' => CAP_ALLOW,
85             'manager' => CAP_ALLOW
86         ),
88         'clonepermissionsfrom' =>  'moodle/site:backup'
89     ),
91     'moodle/backup:downloadfile' => array(
93         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
95         'captype' => 'write',
96         'contextlevel' => CONTEXT_COURSE,
97         'legacy' => array(
98             'editingteacher' => CAP_ALLOW,
99             'manager' => CAP_ALLOW
100         ),
102         'clonepermissionsfrom' =>  'moodle/site:backupdownload'
103     ),
105     'moodle/backup:userinfo' => array(
107         'riskbitmask' => RISK_PERSONAL,
109         'captype' => 'read',
110         'contextlevel' => CONTEXT_COURSE,
111         'legacy' => array(
112             'manager' => CAP_ALLOW
113         )
114     ),
116     'moodle/restore:restorecourse' => array(
118         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
120         'captype' => 'write',
121         'contextlevel' => CONTEXT_COURSE,
122         'legacy' => array(
123             'editingteacher' => CAP_ALLOW,
124             'manager' => CAP_ALLOW
125         ),
127         'clonepermissionsfrom' =>  'moodle/site:restore'
128     ),
130     'moodle/restore:restoretargetimport' => array(
132         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
134         'captype' => 'write',
135         'contextlevel' => CONTEXT_COURSE,
136         'legacy' => array(
137             'editingteacher' => CAP_ALLOW,
138             'manager' => CAP_ALLOW
139         ),
141         'clonepermissionsfrom' =>  'moodle/site:import'
142     ),
144     'moodle/restore:uploadfile' => array(
146         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
148         'captype' => 'write',
149         'contextlevel' => CONTEXT_COURSE,
150         'legacy' => array(
151             'editingteacher' => CAP_ALLOW,
152             'manager' => CAP_ALLOW
153         ),
155         'clonepermissionsfrom' =>  'moodle/site:backupupload'
156     ),
158     'moodle/restore:userinfo' => array(
160         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG,
162         'captype' => 'write',
163         'contextlevel' => CONTEXT_COURSE,
164         'legacy' => array(
165             'manager' => CAP_ALLOW
166         )
167     ),
169     'moodle/restore:createuser' => array(
171         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
173         'captype' => 'write',
174         'contextlevel' => CONTEXT_SYSTEM,
175         'legacy' => array(
176             'manager' => CAP_ALLOW
177         )
178     ),
180     'moodle/restore:rolldates' => array(
182         'captype' => 'write',
183         'contextlevel' => CONTEXT_COURSE,
184         'legacy' => array(
185             'coursecreator' => CAP_ALLOW,
186             'manager' => CAP_ALLOW
187         )
188     ),
190     'moodle/site:manageblocks' => array(
192         'riskbitmask' => RISK_SPAM | RISK_XSS,
194         'captype' => 'write',
195         'contextlevel' => CONTEXT_BLOCK,
196         'legacy' => array(
197             'editingteacher' => CAP_ALLOW,
198             'manager' => CAP_ALLOW
199         )
200     ),
202     'moodle/site:accessallgroups' => array(
204         'captype' => 'read',
205         'contextlevel' => CONTEXT_COURSE,
206         'legacy' => array(
207             'teacher' => CAP_ALLOW,
208             'editingteacher' => CAP_ALLOW,
209             'manager' => CAP_ALLOW
210         )
211     ),
213     'moodle/site:viewfullnames' => array(
215         'captype' => 'read',
216         'contextlevel' => CONTEXT_COURSE,
217         'legacy' => array(
218             'teacher' => CAP_ALLOW,
219             'editingteacher' => CAP_ALLOW,
220             'manager' => CAP_ALLOW
221         )
222     ),
224     'moodle/site:viewreports' => array(
226         'riskbitmask' => RISK_PERSONAL,
228         'captype' => 'read',
229         'contextlevel' => CONTEXT_COURSE,
230         'legacy' => array(
231             'teacher' => CAP_ALLOW,
232             'editingteacher' => CAP_ALLOW,
233             'manager' => CAP_ALLOW
234         )
235     ),
237     'moodle/site:trustcontent' => array(
239         'riskbitmask' => RISK_XSS,
241         'captype' => 'write',
242         'contextlevel' => CONTEXT_COURSE,
243         'legacy' => array(
244             'editingteacher' => CAP_ALLOW,
245             'manager' => CAP_ALLOW
246         )
247     ),
249     'moodle/site:uploadusers' => array(
251         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
253         'captype' => 'write',
254         'contextlevel' => CONTEXT_SYSTEM,
255         'legacy' => array(
256             'manager' => CAP_ALLOW
257         )
258     ),
260     'moodle/site:langeditmaster' => array(
262         'riskbitmask' => RISK_CONFIG | RISK_XSS,
264         'captype' => 'write',
265         'contextlevel' => CONTEXT_SYSTEM,
266         'legacy' => array(
267         )
268     ),
270     'moodle/site:langeditlocal' => array(
272         'riskbitmask' => RISK_CONFIG | RISK_XSS,
274         'captype' => 'write',
275         'contextlevel' => CONTEXT_SYSTEM,
276         'legacy' => array(
277             'manager' => CAP_ALLOW
278         )
279     ),
281     // Permission to manage filter setting overrides in subcontexts.
282     'moodle/filter:manage' => array(
284         'captype' => 'write',
285         'contextlevel' => CONTEXT_COURSE,
286         'legacy' => array(
287             'editingteacher' => CAP_ALLOW,
288             'coursecreator' => CAP_ALLOW,
289             'manager' => CAP_ALLOW,
290         )
291     ),
293     'moodle/user:create' => array(
295         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
297         'captype' => 'write',
298         'contextlevel' => CONTEXT_SYSTEM,
299         'legacy' => array(
300             'manager' => CAP_ALLOW
301         )
302     ),
304     'moodle/user:delete' => array(
306         'riskbitmask' => RISK_PERSONAL, RISK_DATALOSS,
308         'captype' => 'write',
309         'contextlevel' => CONTEXT_SYSTEM,
310         'legacy' => array(
311             'manager' => CAP_ALLOW
312         )
313     ),
315     'moodle/user:update' => array(
317         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
319         'captype' => 'write',
320         'contextlevel' => CONTEXT_SYSTEM,
321         'legacy' => array(
322             'manager' => CAP_ALLOW
323         )
324     ),
326     'moodle/user:viewdetails' => array(
328         'captype' => 'read',
329         'contextlevel' => CONTEXT_COURSE,
330         'legacy' => array(
331             'guest' => CAP_ALLOW,
332             'student' => CAP_ALLOW,
333             'teacher' => CAP_ALLOW,
334             'editingteacher' => CAP_ALLOW,
335             'manager' => CAP_ALLOW
336         )
337     ),
339     'moodle/user:viewhiddendetails' => array(
341         'riskbitmask' => RISK_PERSONAL,
343         'captype' => 'read',
344         'contextlevel' => CONTEXT_COURSE,
345         'legacy' => array(
346             'teacher' => CAP_ALLOW,
347             'editingteacher' => CAP_ALLOW,
348             'manager' => CAP_ALLOW
349         )
350     ),
352     'moodle/user:loginas' => array(
354         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG,
356         'captype' => 'write',
357         'contextlevel' => CONTEXT_COURSE,
358         'legacy' => array(
359             'manager' => CAP_ALLOW
360         )
361     ),
363     'moodle/role:assign' => array(
365         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
367         'captype' => 'write',
368         'contextlevel' => CONTEXT_COURSE,
369         'legacy' => array(
370             'editingteacher' => CAP_ALLOW,
371             'manager' => CAP_ALLOW
372         )
373     ),
375     'moodle/role:review' => array(
377         'riskbitmask' => RISK_PERSONAL,
379         'captype' => 'read',
380         'contextlevel' => CONTEXT_COURSE,
381         'legacy' => array(
382             'teacher' => CAP_ALLOW,
383             'editingteacher' => CAP_ALLOW,
384             'manager' => CAP_ALLOW
385         )
386     ),
388     'moodle/role:override' => array(
390         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
392         'captype' => 'write',
393         'contextlevel' => CONTEXT_COURSE,
394         'legacy' => array(
395             'manager' => CAP_ALLOW
396         )
397     ),
399     'moodle/role:safeoverride' => array(
401         'riskbitmask' => RISK_SPAM,
403         'captype' => 'write',
404         'contextlevel' => CONTEXT_COURSE,
405         'legacy' => array(
406             'editingteacher' => CAP_ALLOW
407         )
408     ),
410     'moodle/role:manage' => array(
412         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
414         'captype' => 'write',
415         'contextlevel' => CONTEXT_SYSTEM,
416         'legacy' => array(
417             'manager' => CAP_ALLOW
418         )
419     ),
421     'moodle/role:unassignself' => array(
423         'captype' => 'write',
424         'contextlevel' => CONTEXT_COURSE,
425         'legacy' => array(
426             'student' => (empty($CFG->allowunenrol)) ? CAP_INHERIT : CAP_ALLOW,
427             'teacher' => CAP_ALLOW,
428             'editingteacher' => CAP_ALLOW,
429             'coursecreator' => CAP_ALLOW,
430             'manager' => CAP_ALLOW
431         )
432     ),
434     'moodle/role:switchroles' => array(
436         'riskbitmask' => RISK_XSS | RISK_PERSONAL,
438         'captype' => 'read',
439         'contextlevel' => CONTEXT_COURSE,
440         'legacy' => array(
441             'editingteacher' => CAP_ALLOW,
442             'manager' => CAP_ALLOW
443         )
444     ),
446     // Create, update and delete course categories. (Deleting a course category
447     // does not let you delete the courses it contains, unless you also have
448     // moodle/course: delete.) Creating and deleting requires this permission in
449     // the parent category.
450     'moodle/category:manage' => array(
452         'riskbitmask' => RISK_XSS,
454         'captype' => 'write',
455         'contextlevel' => CONTEXT_COURSECAT,
456         'legacy' => array(
457             'manager' => CAP_ALLOW
458         ),
459         'clonepermissionsfrom' => 'moodle/category:update'
460     ),
462     'moodle/category:viewhiddencategories' => array(
464         'captype' => 'read',
465         'contextlevel' => CONTEXT_COURSECAT,
466         'legacy' => array(
467             'coursecreator' => CAP_ALLOW,
468             'manager' => CAP_ALLOW
469         ),
470         'clonepermissionsfrom' => 'moodle/category:visibility'
471     ),
473     // create, delete, move cohorts in system and course categories,
474     // (cohorts with component !== null can be only moved)
475     'moodle/cohort:manage' => array(
477         'captype' => 'write',
478         'contextlevel' => CONTEXT_COURSECAT,
479         'legacy' => array(
480             'manager' => CAP_ALLOW
481         )
482     ),
484     // add and remove cohort members (only for cohorts where component !== null)
485     'moodle/cohort:assign' => array(
487         'captype' => 'write',
488         'contextlevel' => CONTEXT_COURSECAT,
489         'legacy' => array(
490             'manager' => CAP_ALLOW
491         )
492     ),
494     // view members of a cohort, this can be used in course context too,
495     // this also controls the ability to actually use cohort
496     'moodle/cohort:view' => array(
498         'captype' => 'read',
499         'contextlevel' => CONTEXT_COURSE,
500         'legacy' => array(
501             'editingteacher' => CAP_ALLOW,
502             'manager' => CAP_ALLOW
503         )
504     ),
506     'moodle/course:create' => array(
508         'riskbitmask' => RISK_XSS,
510         'captype' => 'write',
511         'contextlevel' => CONTEXT_COURSECAT,
512         'legacy' => array(
513             'coursecreator' => CAP_ALLOW,
514             'manager' => CAP_ALLOW
515         )
516     ),
518     'moodle/course:request' => array(
519         'captype' => 'write',
520         'contextlevel' => CONTEXT_SYSTEM,
521         'legacy' => array(
522             'user' => CAP_ALLOW,
523         )
524     ),
526     'moodle/course:delete' => array(
528         'riskbitmask' => RISK_DATALOSS,
530         'captype' => 'write',
531         'contextlevel' => CONTEXT_COURSE,
532         'legacy' => array(
533             'editingteacher' => CAP_ALLOW,
534             'manager' => CAP_ALLOW
535         )
536     ),
538     'moodle/course:update' => array(
540         'riskbitmask' => RISK_XSS,
542         'captype' => 'write',
543         'contextlevel' => CONTEXT_COURSE,
544         'legacy' => array(
545             'editingteacher' => CAP_ALLOW,
546             'manager' => CAP_ALLOW
547         )
548     ),
550     /* originally this capability was called moodle/course:view,
551      * but since 2.0 it is used for access to course without the enrolment
552      */
553     'moodle/course:participate' => array(
555         'captype' => 'read',
556         'contextlevel' => CONTEXT_COURSE,
557         'legacy' => array(
558             'student' => CAP_ALLOW,
559             'teacher' => CAP_ALLOW,
560             'editingteacher' => CAP_ALLOW
561         )
562     ),
564     'moodle/course:view' => array(
566         'captype' => 'read',
567         'contextlevel' => CONTEXT_COURSE,
568         'legacy' => array(
569             'manager' => CAP_ALLOW,
570         )
571     ),
573     'moodle/course:bulkmessaging' => array(
575         'riskbitmask' => RISK_SPAM,
577         'captype' => 'write',
578         'contextlevel' => CONTEXT_COURSE,
579         'legacy' => array(
580             'teacher' => CAP_ALLOW,
581             'editingteacher' => CAP_ALLOW,
582             'manager' => CAP_ALLOW
583         )
584     ),
586     'moodle/course:viewhiddenuserfields' => array(
588         'riskbitmask' => RISK_PERSONAL,
590         'captype' => 'read',
591         'contextlevel' => CONTEXT_COURSE,
592         'legacy' => array(
593             'teacher' => CAP_ALLOW,
594             'editingteacher' => CAP_ALLOW,
595             'manager' => CAP_ALLOW
596         )
597     ),
599     'moodle/course:viewhiddencourses' => array(
601         'captype' => 'read',
602         'contextlevel' => CONTEXT_COURSE,
603         'legacy' => array(
604             'coursecreator' => CAP_ALLOW,
605             'teacher' => CAP_ALLOW,
606             'editingteacher' => CAP_ALLOW,
607             'manager' => CAP_ALLOW
608         )
609     ),
611     'moodle/course:visibility' => array(
613         'captype' => 'write',
614         'contextlevel' => CONTEXT_COURSE,
615         'legacy' => array(
616             'manager' => CAP_ALLOW
617         )
618     ),
620     'moodle/course:managefiles' => array(
622         'riskbitmask' => RISK_XSS,
624         'captype' => 'write',
625         'contextlevel' => CONTEXT_COURSE,
626         'legacy' => array(
627             'editingteacher' => CAP_ALLOW,
628             'manager' => CAP_ALLOW
629         )
630     ),
632     'moodle/course:manageactivities' => array(
634         'riskbitmask' => RISK_XSS,
636         'captype' => 'write',
637         'contextlevel' => CONTEXT_COURSE,
638         'legacy' => array(
639             'editingteacher' => CAP_ALLOW,
640             'manager' => CAP_ALLOW
641         )
642     ),
644     'moodle/course:managemetacourse' => array(
646         'riskbitmask' => RISK_XSS | RISK_PERSONAL,
648         'captype' => 'write',
649         'contextlevel' => CONTEXT_COURSE,
650         'legacy' => array(
651             'editingteacher' => CAP_ALLOW,
652             'manager' => CAP_ALLOW
653         )
654     ),
656     'moodle/course:activityvisibility' => array(
658         'captype' => 'write',
659         'contextlevel' => CONTEXT_COURSE,
660         'legacy' => array(
661             'editingteacher' => CAP_ALLOW,
662             'manager' => CAP_ALLOW
663         )
664     ),
666     'moodle/course:viewhiddenactivities' => array(
668         'captype' => 'write',
669         'contextlevel' => CONTEXT_COURSE,
670         'legacy' => array(
671             'teacher' => CAP_ALLOW,
672             'editingteacher' => CAP_ALLOW,
673             'manager' => CAP_ALLOW
674         )
675     ),
677     'moodle/course:viewparticipants' => array(
679         'captype' => 'read',
680         'contextlevel' => CONTEXT_COURSE,
681         'legacy' => array(
682             'student' => CAP_ALLOW,
683             'teacher' => CAP_ALLOW,
684             'editingteacher' => CAP_ALLOW,
685             'manager' => CAP_ALLOW
686         )
687     ),
689     'moodle/course:changefullname' => array(
691         'riskbitmask' => RISK_XSS,
693         'captype' => 'write',
694         'contextlevel' => CONTEXT_COURSE,
695         'legacy' => array(
696             'editingteacher' => CAP_ALLOW,
697             'manager' => CAP_ALLOW
698         ),
699         'clonepermissionsfrom' => 'moodle/course:update'
700     ),
702     'moodle/course:changeshortname' => array(
704         'riskbitmask' => RISK_XSS,
706         'captype' => 'write',
707         'contextlevel' => CONTEXT_COURSE,
708         'legacy' => array(
709             'editingteacher' => CAP_ALLOW,
710             'manager' => CAP_ALLOW
711         ),
712         'clonepermissionsfrom' => 'moodle/course:update'
713     ),
715     'moodle/course:changeidnumber' => array(
717         'riskbitmask' => RISK_XSS,
719         'captype' => 'write',
720         'contextlevel' => CONTEXT_COURSE,
721         'legacy' => array(
722             'editingteacher' => CAP_ALLOW,
723             'manager' => CAP_ALLOW
724         ),
725         'clonepermissionsfrom' => 'moodle/course:update'
726     ),
727     'moodle/course:changecategory' => array(
728         'riskbitmask' => RISK_XSS,
730         'captype' => 'write',
731         'contextlevel' => CONTEXT_COURSE,
732         'legacy' => array(
733             'editingteacher' => CAP_ALLOW,
734             'manager' => CAP_ALLOW
735         ),
736         'clonepermissionsfrom' => 'moodle/course:update'
737     ),
739     'moodle/course:changesummary' => array(
740         'riskbitmask' => RISK_XSS,
742         'captype' => 'write',
743         'contextlevel' => CONTEXT_COURSE,
744         'legacy' => array(
745             'editingteacher' => CAP_ALLOW,
746             'manager' => CAP_ALLOW
747         ),
748         'clonepermissionsfrom' => 'moodle/course:update'
749     ),
752     'moodle/site:viewparticipants' => array(
754         'captype' => 'read',
755         'contextlevel' => CONTEXT_SYSTEM,
756         'legacy' => array(
757             'manager' => CAP_ALLOW
758         )
759     ),
761     'moodle/course:viewscales' => array(
763         'captype' => 'read',
764         'contextlevel' => CONTEXT_COURSE,
765         'legacy' => array(
766             'student' => CAP_ALLOW,
767             'teacher' => CAP_ALLOW,
768             'editingteacher' => CAP_ALLOW,
769             'manager' => CAP_ALLOW
770         )
771     ),
773     'moodle/course:managescales' => array(
775         'captype' => 'write',
776         'contextlevel' => CONTEXT_COURSE,
777         'legacy' => array(
778             'editingteacher' => CAP_ALLOW,
779             'manager' => CAP_ALLOW
780         )
781     ),
783     'moodle/course:managegroups' => array(
785         'captype' => 'write',
786         'contextlevel' => CONTEXT_COURSE,
787         'legacy' => array(
788             'editingteacher' => CAP_ALLOW,
789             'manager' => CAP_ALLOW
790         )
791     ),
793     'moodle/course:reset' => array(
795         'riskbitmask' => RISK_DATALOSS,
797         'captype' => 'write',
798         'contextlevel' => CONTEXT_COURSE,
799         'legacy' => array(
800             'editingteacher' => CAP_ALLOW,
801             'manager' => CAP_ALLOW
802         )
803     ),
805     'moodle/blog:view' => array(
807         'captype' => 'read',
808         'contextlevel' => CONTEXT_SYSTEM,
809         'legacy' => array(
810             'guest' => CAP_ALLOW,
811             'user' => CAP_ALLOW,
812             'student' => CAP_ALLOW,
813             'teacher' => CAP_ALLOW,
814             'editingteacher' => CAP_ALLOW,
815             'manager' => CAP_ALLOW
816         )
817     ),
819     'moodle/blog:search' => array(
820         'captype' => 'read',
821         'contextlevel' => CONTEXT_SYSTEM,
822         'legacy' => array(
823             'guest' => CAP_ALLOW,
824             'user' => CAP_ALLOW,
825             'student' => CAP_ALLOW,
826             'teacher' => CAP_ALLOW,
827             'editingteacher' => CAP_ALLOW,
828             'manager' => CAP_ALLOW
829         )
830     ),
832     'moodle/blog:viewdrafts' => array(
834         'riskbitmask' => RISK_PERSONAL,
835         'captype' => 'read',
836         'contextlevel' => CONTEXT_SYSTEM,
837         'legacy' => array(
838             'manager' => CAP_ALLOW
839         )
840     ),
842     'moodle/blog:create' => array( // works in CONTEXT_SYSTEM only
844         'riskbitmask' => RISK_SPAM,
846         'captype' => 'write',
847         'contextlevel' => CONTEXT_SYSTEM,
848         'legacy' => array(
849             'user' => CAP_ALLOW,
850             'manager' => CAP_ALLOW
851         )
852     ),
854     'moodle/blog:manageentries' => array(
856         'riskbitmask' => RISK_SPAM,
858         'captype' => 'write',
859         'contextlevel' => CONTEXT_SYSTEM,
860         'legacy' => array(
861             'teacher' => CAP_ALLOW,
862             'editingteacher' => CAP_ALLOW,
863             'manager' => CAP_ALLOW
864         )
865     ),
867     'moodle/blog:manageexternal' => array(
869         'riskbitmask' => RISK_SPAM,
871         'captype' => 'write',
872         'contextlevel' => CONTEXT_USER,
873         'legacy' => array(
874             'student' => CAP_ALLOW,
875             'user' => CAP_ALLOW,
876             'teacher' => CAP_ALLOW,
877             'editingteacher' => CAP_ALLOW,
878             'manager' => CAP_ALLOW
879         )
880     ),
882     'moodle/blog:associatecourse' => array(
884         'captype' => 'write',
885         'contextlevel' => CONTEXT_COURSE,
886         'legacy' => array(
887             'student' => CAP_ALLOW,
888             'user' => CAP_ALLOW,
889             'teacher' => CAP_ALLOW,
890             'editingteacher' => CAP_ALLOW,
891             'manager' => CAP_ALLOW
892         )
893     ),
895     'moodle/blog:associatemodule' => array(
897         'captype' => 'write',
898         'contextlevel' => CONTEXT_MODULE,
899         'legacy' => array(
900             'student' => CAP_ALLOW,
901             'user' => CAP_ALLOW,
902             'teacher' => CAP_ALLOW,
903             'editingteacher' => CAP_ALLOW,
904             'manager' => CAP_ALLOW
905         )
906     ),
908     'moodle/calendar:manageownentries' => array( // works in CONTEXT_SYSTEM only
910         'riskbitmask' => RISK_SPAM,
912         'captype' => 'write',
913         'contextlevel' => CONTEXT_COURSE,
914         'legacy' => array(
915             'user' => CAP_ALLOW,
916             'manager' => CAP_ALLOW
917         )
918     ),
920     'moodle/calendar:managegroupentries' => array(
922         'riskbitmask' => RISK_SPAM,
924         'captype' => 'write',
925         'contextlevel' => CONTEXT_COURSE,
926         'legacy' => array(
927             'teacher' => CAP_ALLOW,
928             'editingteacher' => CAP_ALLOW,
929             'manager' => CAP_ALLOW
930         )
931     ),
933     'moodle/calendar:manageentries' => array(
935         'riskbitmask' => RISK_SPAM,
937         'captype' => 'write',
938         'contextlevel' => CONTEXT_COURSE,
939         'legacy' => array(
940             'teacher' => CAP_ALLOW,
941             'editingteacher' => CAP_ALLOW,
942             'manager' => CAP_ALLOW
943         )
944     ),
946     'moodle/user:editprofile' => array(
948         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
950         'captype' => 'write',
951         'contextlevel' => CONTEXT_USER,
952         'legacy' => array(
953             'manager' => CAP_ALLOW
954         )
955     ),
957     'moodle/user:editownprofile' => array(
959         'riskbitmask' => RISK_SPAM,
961         'captype' => 'write',
962         'contextlevel' => CONTEXT_SYSTEM,
963         'legacy' => array(
964             'guest' => CAP_PROHIBIT,
965             'user' => CAP_ALLOW,
966             'manager' => CAP_ALLOW
967         )
968     ),
970     'moodle/user:changeownpassword' => array(
972         'captype' => 'write',
973         'contextlevel' => CONTEXT_SYSTEM,
974         'legacy' => array(
975             'guest' => CAP_PROHIBIT,
976             'user' => CAP_ALLOW,
977             'manager' => CAP_ALLOW
978         )
979     ),
981     // The next 3 might make no sense for some roles, e.g teacher, etc.
982     // since the next level up is site. These are more for the parent role
983     'moodle/user:readuserposts' => array(
985         'captype' => 'read',
986         'contextlevel' => CONTEXT_USER,
987         'legacy' => array(
988             'student' => CAP_ALLOW,
989             'teacher' => CAP_ALLOW,
990             'editingteacher' => CAP_ALLOW,
991             'manager' => CAP_ALLOW
992         )
993     ),
995     'moodle/user:readuserblogs' => array(
997         'captype' => 'read',
998         'contextlevel' => CONTEXT_USER,
999         'legacy' => array(
1000             'student' => CAP_ALLOW,
1001             'teacher' => CAP_ALLOW,
1002             'editingteacher' => CAP_ALLOW,
1003             'manager' => CAP_ALLOW
1004         )
1005     ),
1007     // designed for parent role - not used in legacy roles
1008     'moodle/user:viewuseractivitiesreport' => array(
1009         'riskbitmask' => RISK_PERSONAL,
1011         'captype' => 'read',
1012         'contextlevel' => CONTEXT_USER,
1013         'legacy' => array(
1014         )
1015     ),
1017     //capabilities designed for the new message system configuration
1018     'moodle/user:editmessageprofile' => array(
1020          'riskbitmask' => RISK_SPAM,
1022          'captype' => 'write',
1023          'contextlevel' => CONTEXT_USER,
1024          'legacy' => array(
1025              'manager' => CAP_ALLOW
1026          )
1027      ),
1029      'moodle/user:editownmessageprofile' => array(
1031          'captype' => 'write',
1032          'contextlevel' => CONTEXT_SYSTEM,
1033          'legacy' => array(
1034              'guest' => CAP_PROHIBIT,
1035              'user' => CAP_ALLOW,
1036              'manager' => CAP_ALLOW
1037          )
1038      ),
1040     'moodle/question:managecategory' => array(
1041         'riskbitmask' => RISK_SPAM | RISK_XSS,
1042         'captype' => 'write',
1043         'contextlevel' => CONTEXT_COURSE,
1044         'legacy' => array(
1045             'editingteacher' => CAP_ALLOW,
1046             'manager' => CAP_ALLOW
1047         )
1048     ),
1050     //new in moodle 1.9
1051     'moodle/question:add' => array(
1052         'riskbitmask' => RISK_SPAM | RISK_XSS,
1053         'captype' => 'write',
1054         'contextlevel' => CONTEXT_COURSE,
1055         'legacy' => array(
1056             'editingteacher' => CAP_ALLOW,
1057             'manager' => CAP_ALLOW
1058         ),
1059         'clonepermissionsfrom' =>  'moodle/question:manage'
1060     ),
1061     'moodle/question:editmine' => array(
1062         'riskbitmask' => RISK_SPAM | RISK_XSS,
1063         'captype' => 'write',
1064         'contextlevel' => CONTEXT_COURSE,
1065         'legacy' => array(
1066             'editingteacher' => CAP_ALLOW,
1067             'manager' => CAP_ALLOW
1068         ),
1069         'clonepermissionsfrom' =>  'moodle/question:manage'
1070     ),
1071     'moodle/question:editall' => array(
1072         'riskbitmask' => RISK_SPAM | RISK_XSS,
1073         'captype' => 'write',
1074         'contextlevel' => CONTEXT_COURSE,
1075         'legacy' => array(
1076             'editingteacher' => CAP_ALLOW,
1077             'manager' => CAP_ALLOW
1078         ),
1079         'clonepermissionsfrom' =>  'moodle/question:manage'
1080     ),
1081     'moodle/question:viewmine' => array(
1082         'captype' => 'read',
1083         'contextlevel' => CONTEXT_COURSE,
1084         'legacy' => array(
1085             'editingteacher' => CAP_ALLOW,
1086             'manager' => CAP_ALLOW
1087         ),
1088         'clonepermissionsfrom' =>  'moodle/question:manage'
1089     ),
1090     'moodle/question:viewall' => array(
1091         'captype' => 'read',
1092         'contextlevel' => CONTEXT_COURSE,
1093         'legacy' => array(
1094             'editingteacher' => CAP_ALLOW,
1095             'manager' => CAP_ALLOW
1096         ),
1097         'clonepermissionsfrom' =>  'moodle/question:manage'
1098     ),
1099     'moodle/question:usemine' => array(
1100         'captype' => 'read',
1101         'contextlevel' => CONTEXT_COURSE,
1102         'legacy' => array(
1103             'editingteacher' => CAP_ALLOW,
1104             'manager' => CAP_ALLOW
1105         ),
1106         'clonepermissionsfrom' =>  'moodle/question:manage'
1107     ),
1108     'moodle/question:useall' => array(
1109         'captype' => 'read',
1110         'contextlevel' => CONTEXT_COURSE,
1111         'legacy' => array(
1112             'editingteacher' => CAP_ALLOW,
1113             'manager' => CAP_ALLOW
1114         ),
1115         'clonepermissionsfrom' =>  'moodle/question:manage'
1116     ),
1117     'moodle/question:movemine' => array(
1118         'captype' => 'write',
1119         'contextlevel' => CONTEXT_COURSE,
1120         'legacy' => array(
1121             'editingteacher' => CAP_ALLOW,
1122             'manager' => CAP_ALLOW
1123         ),
1124         'clonepermissionsfrom' =>  'moodle/question:manage'
1125     ),
1126     'moodle/question:moveall' => array(
1127         'captype' => 'write',
1128         'contextlevel' => CONTEXT_COURSE,
1129         'legacy' => array(
1130             'editingteacher' => CAP_ALLOW,
1131             'manager' => CAP_ALLOW
1132         ),
1133         'clonepermissionsfrom' =>  'moodle/question:manage'
1134     ),
1135     //END new in moodle 1.9
1137     // Configure the installed question types.
1138     'moodle/question:config' => array(
1139         'riskbitmask' => RISK_CONFIG,
1140         'captype' => 'write',
1141         'contextlevel' => CONTEXT_SYSTEM,
1142         'legacy' => array(
1143             'manager' => CAP_ALLOW
1144         )
1145     ),
1147     // While attempting questions, the ability to flag particular questions for later reference.
1148     'moodle/question:flag' => array(
1149         'captype' => 'write',
1150         'contextlevel' => CONTEXT_COURSE,
1151         'legacy' => array(
1152             'student' => CAP_ALLOW,
1153             'teacher' => CAP_ALLOW,
1154             'editingteacher' => CAP_ALLOW,
1155             'coursecreator' => CAP_ALLOW,
1156             'manager' => CAP_ALLOW
1157         )
1158     ),
1160     'moodle/site:doclinks' => array(
1161         'captype' => 'read',
1162         'contextlevel' => CONTEXT_SYSTEM,
1163         'legacy' => array(
1164             'teacher' => CAP_ALLOW,
1165             'editingteacher' => CAP_ALLOW,
1166             'manager' => CAP_ALLOW
1167         )
1168     ),
1170     'moodle/course:sectionvisibility' => array(
1172         'captype' => 'write',
1173         'contextlevel' => CONTEXT_COURSE,
1174         'legacy' => array(
1175             'editingteacher' => CAP_ALLOW,
1176             'manager' => CAP_ALLOW
1177         )
1178     ),
1180     'moodle/course:useremail' => array(
1182         'captype' => 'write',
1183         'contextlevel' => CONTEXT_COURSE,
1184         'legacy' => array(
1185             'editingteacher' => CAP_ALLOW,
1186             'manager' => CAP_ALLOW
1187         )
1188     ),
1190     'moodle/course:viewhiddensections' => array(
1192         'captype' => 'write',
1193         'contextlevel' => CONTEXT_COURSE,
1194         'legacy' => array(
1195             'editingteacher' => CAP_ALLOW,
1196             'manager' => CAP_ALLOW
1197         )
1198     ),
1200     'moodle/course:setcurrentsection' => array(
1202         'captype' => 'write',
1203         'contextlevel' => CONTEXT_COURSE,
1204         'legacy' => array(
1205             'editingteacher' => CAP_ALLOW,
1206             'manager' => CAP_ALLOW
1207         )
1208     ),
1210     'moodle/site:mnetlogintoremote' => array(
1212         'captype' => 'read',
1213         'contextlevel' => CONTEXT_SYSTEM,
1214         'legacy' => array(
1215             'manager' => CAP_ALLOW
1216         )
1217     ),
1219     'moodle/grade:viewall' => array(
1220         'riskbitmask' => RISK_PERSONAL,
1221         'captype' => 'read',
1222         'contextlevel' => CONTEXT_COURSE, // and CONTEXT_USER
1223         'legacy' => array(
1224             'teacher' => CAP_ALLOW,
1225             'editingteacher' => CAP_ALLOW,
1226             'manager' => CAP_ALLOW
1227         ),
1228         'clonepermissionsfrom' => 'moodle/course:viewcoursegrades'
1229     ),
1231     'moodle/grade:view' => array(
1232         'captype' => 'read',
1233         'contextlevel' => CONTEXT_COURSE,
1234         'legacy' => array(
1235             'student' => CAP_ALLOW
1236         )
1237     ),
1239     'moodle/grade:viewhidden' => array(
1240         'riskbitmask' => RISK_PERSONAL,
1241         'captype' => 'read',
1242         'contextlevel' => CONTEXT_COURSE,
1243         'legacy' => array(
1244             'teacher' => CAP_ALLOW,
1245             'editingteacher' => CAP_ALLOW,
1246             'manager' => CAP_ALLOW
1247         ),
1248         'clonepermissionsfrom' => 'moodle/course:viewcoursegrades'
1249     ),
1251     'moodle/grade:import' => array(
1252         'riskbitmask' => RISK_PERSONAL | RISK_XSS,
1253         'captype' => 'write',
1254         'contextlevel' => CONTEXT_COURSE,
1255         'legacy' => array(
1256             'editingteacher' => CAP_ALLOW,
1257             'manager' => CAP_ALLOW
1258         ),
1259         'clonepermissionsfrom' => 'moodle/course:managegrades'
1260     ),
1262     'moodle/grade:export' => array(
1263         'riskbitmask' => RISK_PERSONAL,
1264         'captype' => 'read',
1265         'contextlevel' => CONTEXT_COURSE,
1266         'legacy' => array(
1267             'teacher' => CAP_ALLOW,
1268             'editingteacher' => CAP_ALLOW,
1269             'manager' => CAP_ALLOW
1270         ),
1271         'clonepermissionsfrom' => 'moodle/course:managegrades'
1272     ),
1274     'moodle/grade:manage' => array(
1275         'riskbitmask' => RISK_PERSONAL | RISK_XSS,
1276         'captype' => 'write',
1277         'contextlevel' => CONTEXT_COURSE,
1278         'legacy' => array(
1279             'editingteacher' => CAP_ALLOW,
1280             'manager' => CAP_ALLOW
1281         ),
1282         'clonepermissionsfrom' => 'moodle/course:managegrades'
1283     ),
1285     'moodle/grade:edit' => array(
1286         'riskbitmask' => RISK_PERSONAL | RISK_XSS,
1287         'captype' => 'write',
1288         'contextlevel' => CONTEXT_COURSE,
1289         'legacy' => array(
1290             'editingteacher' => CAP_ALLOW,
1291             'manager' => CAP_ALLOW
1292         ),
1293         'clonepermissionsfrom' => 'moodle/course:managegrades'
1294     ),
1296     'moodle/grade:manageoutcomes' => array(
1297         'captype' => 'write',
1298         'contextlevel' => CONTEXT_COURSE,
1299         'legacy' => array(
1300             'editingteacher' => CAP_ALLOW,
1301             'manager' => CAP_ALLOW
1302         ),
1303         'clonepermissionsfrom' => 'moodle/course:managegrades'
1304     ),
1306     'moodle/grade:manageletters' => array(
1307         'captype' => 'write',
1308         'contextlevel' => CONTEXT_COURSE,
1309         'legacy' => array(
1310             'editingteacher' => CAP_ALLOW,
1311             'manager' => CAP_ALLOW
1312         ),
1313         'clonepermissionsfrom' => 'moodle/course:managegrades'
1314     ),
1316     'moodle/grade:hide' => array(
1317         'captype' => 'write',
1318         'contextlevel' => CONTEXT_COURSE,
1319         'legacy' => array(
1320             'editingteacher' => CAP_ALLOW,
1321             'manager' => CAP_ALLOW
1322         )
1323     ),
1325     'moodle/grade:lock' => array(
1326         'captype' => 'write',
1327         'contextlevel' => CONTEXT_COURSE,
1328         'legacy' => array(
1329             'editingteacher' => CAP_ALLOW,
1330             'manager' => CAP_ALLOW
1331         )
1332     ),
1334     'moodle/grade:unlock' => array(
1335         'captype' => 'write',
1336         'contextlevel' => CONTEXT_COURSE,
1337         'legacy' => array(
1338             'editingteacher' => CAP_ALLOW,
1339             'manager' => CAP_ALLOW
1340         )
1341     ),
1343     'moodle/my:manageblocks' => array(
1344         'captype' => 'write',
1345         'contextlevel' => CONTEXT_SYSTEM,
1346         'legacy' => array(
1347             'user' => CAP_ALLOW
1348         )
1349     ),
1351     'moodle/notes:view' => array(
1352         'captype' => 'read',
1353         'contextlevel' => CONTEXT_COURSE,
1354         'legacy' => array(
1355             'teacher' => CAP_ALLOW,
1356             'editingteacher' => CAP_ALLOW,
1357             'manager' => CAP_ALLOW
1358         )
1359     ),
1361     'moodle/notes:manage' => array(
1362         'riskbitmask' => RISK_SPAM,
1364         'captype' => 'write',
1365         'contextlevel' => CONTEXT_COURSE,
1366         'legacy' => array(
1367             'teacher' => CAP_ALLOW,
1368             'editingteacher' => CAP_ALLOW,
1369             'manager' => CAP_ALLOW
1370         )
1371     ),
1373     'moodle/tag:manage' => array(
1374         'riskbitmask' => RISK_SPAM,
1376         'captype' => 'write',
1377         'contextlevel' => CONTEXT_SYSTEM,
1378         'legacy' => array(
1379             'teacher' => CAP_ALLOW,
1380             'editingteacher' => CAP_ALLOW,
1381             'manager' => CAP_ALLOW
1382         )
1383     ),
1385     'moodle/tag:create' => array(
1386         'riskbitmask' => RISK_SPAM,
1388         'captype' => 'write',
1389         'contextlevel' => CONTEXT_SYSTEM,
1390         'legacy' => array(
1391             'manager' => CAP_ALLOW,
1392             'user' => CAP_ALLOW
1393         )
1394     ),
1396     'moodle/tag:edit' => array(
1397         'riskbitmask' => RISK_SPAM,
1399         'captype' => 'write',
1400         'contextlevel' => CONTEXT_SYSTEM,
1401         'legacy' => array(
1402             'manager' => CAP_ALLOW,
1403             'user' => CAP_ALLOW
1404         )
1405     ),
1407     'moodle/tag:editblocks' => array(
1408         'captype' => 'write',
1409         'contextlevel' => CONTEXT_SYSTEM,
1410         'legacy' => array(
1411             'teacher' => CAP_ALLOW,
1412             'editingteacher' => CAP_ALLOW,
1413             'manager' => CAP_ALLOW
1414         )
1415     ),
1417     'moodle/block:view' => array(
1418         'captype' => 'read',
1419         'contextlevel' => CONTEXT_BLOCK,
1420         'legacy' => array(
1421             'guest' => CAP_ALLOW,
1422             'user' => CAP_ALLOW,
1423             'student' => CAP_ALLOW,
1424             'teacher' => CAP_ALLOW,
1425             'editingteacher' => CAP_ALLOW,
1426             'coursecreator' => CAP_ALLOW
1427         )
1428     ),
1430     'moodle/block:edit' => array(
1431         'riskbitmask' => RISK_SPAM | RISK_XSS,
1433         'captype' => 'write',
1434         'contextlevel' => CONTEXT_BLOCK,
1435         'legacy' => array(
1436             'editingteacher' => CAP_ALLOW,
1437             'coursecreator' => CAP_ALLOW
1438         )
1439     ),
1441     'moodle/portfolio:export' => array(
1442         'captype' => 'read',
1443         'contextlevel' => CONTEXT_SYSTEM,
1444         'legacy' => array(
1445             'user' => CAP_ALLOW,
1446             'student' => CAP_ALLOW,
1447             'teacher' => CAP_ALLOW,
1448             'editingteacher' => CAP_ALLOW,
1449             'coursecreator' => CAP_ALLOW
1450         )
1451     ),
1452     'moodle/comment:view' => array(
1454         'captype' => 'read',
1455         'contextlevel' => CONTEXT_SYSTEM,
1456         'legacy' => array(
1457             'user' => CAP_ALLOW,
1458             'student' => CAP_ALLOW,
1459             'teacher' => CAP_ALLOW,
1460             'editingteacher' => CAP_ALLOW,
1461             'coursecreator' => CAP_ALLOW,
1462             'manager' => CAP_ALLOW
1463         )
1464     ),
1465     'moodle/comment:post' => array(
1467         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
1468         'captype' => 'write',
1469         'contextlevel' => CONTEXT_SYSTEM,
1470         'legacy' => array(
1471             'user' => CAP_ALLOW,
1472             'student' => CAP_ALLOW,
1473             'teacher' => CAP_ALLOW,
1474             'editingteacher' => CAP_ALLOW,
1475             'coursecreator' => CAP_ALLOW,
1476             'manager' => CAP_ALLOW
1477         )
1478     ),
1479     'moodle/comment:delete' => array(
1481         'riskbitmask' => RISK_DATALOSS,
1482         'captype' => 'write',
1483         'contextlevel' => CONTEXT_SYSTEM,
1484         'legacy' => array(
1485             'editingteacher' => CAP_ALLOW,
1486             'coursecreator' => CAP_ALLOW,
1487             'manager' => CAP_ALLOW
1488         )
1489     ),
1490     'moodle/webservice:createtoken' => array(
1492         'riskbitmask' => RISK_CONFIG | RISK_DATALOSS | RISK_SPAM | RISK_PERSONAL | RISK_XSS,
1493         'captype' => 'write',
1494         'contextlevel' => CONTEXT_SYSTEM,
1495         'legacy' => array(
1496             'manager' => CAP_ALLOW
1497         )
1498     ),
1499     'moodle/rating:view' => array(
1500         'captype' => 'read',
1501         'contextlevel' => CONTEXT_SYSTEM,
1502         'legacy' => array(
1503             'student' => CAP_ALLOW,
1504             'teacher' => CAP_ALLOW,
1505             'editingteacher' => CAP_ALLOW,
1506             'manager' => CAP_ALLOW
1507         )
1508     ),
1509     'moodle/rating:viewany' => array(
1510         'riskbitmask' => RISK_PERSONAL,
1511         'captype' => 'read',
1512         'contextlevel' => CONTEXT_SYSTEM,
1513         'legacy' => array(
1514             'student' => CAP_ALLOW,
1515             'teacher' => CAP_ALLOW,
1516             'editingteacher' => CAP_ALLOW,
1517             'manager' => CAP_ALLOW
1518         )
1519     ),
1520     'moodle/rating:viewall' => array(
1521         'riskbitmask' => RISK_PERSONAL,
1522         'captype' => 'read',
1523         'contextlevel' => CONTEXT_SYSTEM,
1524         'legacy' => array(
1525             'student' => CAP_ALLOW,
1526             'teacher' => CAP_ALLOW,
1527             'editingteacher' => CAP_ALLOW,
1528             'manager' => CAP_ALLOW
1529         )
1530     ),
1531     'moodle/rating:rate' => array(
1532         'captype' => 'write',
1533         'contextlevel' => CONTEXT_SYSTEM,
1534         'legacy' => array(
1535             'student' => CAP_ALLOW,
1536             'teacher' => CAP_ALLOW,
1537             'editingteacher' => CAP_ALLOW,
1538             'manager' => CAP_ALLOW
1539         )
1540     )
1541 );