3 // Capability definitions for Moodle core.
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.
9 // The system has four possible values for a capability:
10 // CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
13 // CAPABILITY NAMING CONVENTION
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]/<component_name>:<capabilityname>
19 // component_name should be the same as the directory name of the mod or block.
21 // Core moodle capabilities are defined thus:
22 // moodle/<capabilityclass>:<capabilityname>
24 // Examples: mod/forum:viewpost
25 // block/recent_activity:view
26 // moodle/site:deleteuser
28 // The variable name for the capability definitions array follows the format
29 // $<componenttype>_<component_name>_capabilities
31 // For the core capabilities, the variable is $moodle_capabilities.
34 $moodle_capabilities = array(
36 'moodle/site:doanything' => array(
38 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG
,
41 'contextlevel' => CONTEXT_SYSTEM
44 'moodle/legacy:guest' => array(
46 'captype' => 'legacy',
47 'contextlevel' => CONTEXT_SYSTEM
50 'moodle/legacy:user' => array(
52 'captype' => 'legacy',
53 'contextlevel' => CONTEXT_SYSTEM
56 'moodle/legacy:student' => array(
58 'riskbitmask' => RISK_SPAM
,
60 'captype' => 'legacy',
61 'contextlevel' => CONTEXT_SYSTEM
65 'moodle/legacy:teacher' => array(
67 'riskbitmask' => RISK_SPAM | RISK_PERSONAL
,
69 'captype' => 'legacy',
70 'contextlevel' => CONTEXT_SYSTEM
74 'moodle/legacy:editingteacher' => array(
76 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
78 'captype' => 'legacy',
79 'contextlevel' => CONTEXT_SYSTEM
83 'moodle/legacy:coursecreator' => array(
85 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
87 'captype' => 'legacy',
88 'contextlevel' => CONTEXT_SYSTEM
92 'moodle/legacy:admin' => array(
94 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG
,
96 'captype' => 'legacy',
97 'contextlevel' => CONTEXT_SYSTEM
101 'moodle/site:config' => array(
103 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG
,
105 'captype' => 'write',
106 'contextlevel' => CONTEXT_SYSTEM
,
112 'moodle/site:readallmessages' => array(
114 'riskbitmask' => RISK_PERSONAL
,
117 'contextlevel' => CONTEXT_SYSTEM
,
119 'admin' => CAP_ALLOW
,
120 'editingteacher' => CAP_ALLOW
124 'moodle/site:approvecourse' => array(
126 'riskbitmask' => RISK_XSS
,
128 'captype' => 'write',
129 'contextlevel' => CONTEXT_SYSTEM
,
135 'moodle/site:import' => array(
137 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
139 'captype' => 'write',
140 'contextlevel' => CONTEXT_SYSTEM
,
142 'editingteacher' => CAP_ALLOW
,
147 'moodle/site:backup' => array(
149 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
151 'captype' => 'write',
152 'contextlevel' => CONTEXT_SYSTEM
,
154 'editingteacher' => CAP_ALLOW
,
159 'moodle/site:restore' => array(
161 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
163 'captype' => 'write',
164 'contextlevel' => CONTEXT_SYSTEM
,
166 'editingteacher' => CAP_ALLOW
,
171 'moodle/site:manageblocks' => array(
173 'riskbitmask' => RISK_SPAM | RISK_XSS
,
175 'captype' => 'write',
176 'contextlevel' => CONTEXT_SYSTEM
,
178 'editingteacher' => CAP_ALLOW
,
183 'moodle/site:accessallgroups' => array(
186 'contextlevel' => CONTEXT_SYSTEM
,
188 'teacher' => CAP_ALLOW
,
189 'editingteacher' => CAP_ALLOW
,
194 'moodle/site:viewfullnames' => array(
197 'contextlevel' => CONTEXT_SYSTEM
,
199 'teacher' => CAP_ALLOW
,
200 'editingteacher' => CAP_ALLOW
,
205 'moodle/site:viewreports' => array(
207 'riskbitmask' => RISK_PERSONAL
,
210 'contextlevel' => CONTEXT_SYSTEM
,
212 'teacher' => CAP_ALLOW
,
213 'editingteacher' => CAP_ALLOW
,
218 'moodle/site:trustcontent' => array(
220 'riskbitmask' => RISK_XSS
,
222 'captype' => 'write',
223 'contextlevel' => CONTEXT_SYSTEM
,
225 'editingteacher' => CAP_ALLOW
,
230 'moodle/site:uploadusers' => array(
232 'riskbitmask' => RISK_SPAM | RISK_PERSONAL
,
234 'captype' => 'write',
235 'contextlevel' => CONTEXT_SYSTEM
,
241 'moodle/site:langeditmaster' => array(
243 'riskbitmask' => RISK_CONFIG | RISK_XSS
,
245 'captype' => 'write',
246 'contextlevel' => CONTEXT_SYSTEM
,
248 'admin' => CAP_PREVENT
252 'moodle/site:langeditlocal' => array(
254 'riskbitmask' => RISK_CONFIG | RISK_XSS
,
256 'captype' => 'write',
257 'contextlevel' => CONTEXT_SYSTEM
,
264 'moodle/user:create' => array(
266 'riskbitmask' => RISK_SPAM | RISK_PERSONAL
,
268 'captype' => 'write',
269 'contextlevel' => CONTEXT_SYSTEM
,
275 'moodle/user:delete' => array(
277 'riskbitmask' => RISK_PERSONAL
,
279 'captype' => 'write',
280 'contextlevel' => CONTEXT_SYSTEM
,
286 'moodle/user:update' => array(
288 'riskbitmask' => RISK_SPAM | RISK_PERSONAL
,
290 'captype' => 'write',
291 'contextlevel' => CONTEXT_SYSTEM
,
297 'moodle/user:viewdetails' => array(
300 'contextlevel' => CONTEXT_SYSTEM
,
302 'guest' => CAP_ALLOW
,
303 'student' => CAP_ALLOW
,
304 'teacher' => CAP_ALLOW
,
305 'editingteacher' => CAP_ALLOW
,
310 'moodle/user:viewhiddendetails' => array(
312 'riskbitmask' => RISK_PERSONAL
,
315 'contextlevel' => CONTEXT_SYSTEM
,
317 'teacher' => CAP_ALLOW
,
318 'editingteacher' => CAP_ALLOW
,
323 'moodle/user:loginas' => array(
325 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG
,
327 'captype' => 'write',
328 'contextlevel' => CONTEXT_COURSE
,
334 'moodle/role:assign' => array(
336 'captype' => 'write',
337 'contextlevel' => CONTEXT_SYSTEM
,
339 'editingteacher' => CAP_ALLOW
,
344 'moodle/role:override' => array(
346 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
348 'captype' => 'write',
349 'contextlevel' => CONTEXT_SYSTEM
,
355 'moodle/role:manage' => array(
357 'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS
,
359 'captype' => 'write',
360 'contextlevel' => CONTEXT_SYSTEM
,
366 'moodle/role:unassignself' => array(
368 'captype' => 'write',
369 'contextlevel' => CONTEXT_SYSTEM
,
371 'student' => (empty($CFG->allowunenrol
)) ? CAP_INHERIT
: CAP_ALLOW
,
372 'teacher' => CAP_ALLOW
,
373 'editingteacher' => CAP_ALLOW
,
374 'coursecreator' => CAP_ALLOW
,
379 'moodle/role:viewhiddenassigns' => array(
382 'contextlevel' => CONTEXT_SYSTEM
,
384 'teacher' => CAP_ALLOW
,
385 'editingteacher' => CAP_ALLOW
,
390 'moodle/role:switchroles' => array(
392 'riskbitmask' => RISK_XSS
,
395 'contextlevel' => CONTEXT_SYSTEM
,
397 'editingteacher' => CAP_ALLOW
,
402 'moodle/category:create' => array(
404 'riskbitmask' => RISK_XSS
,
406 'captype' => 'write',
407 'contextlevel' => CONTEXT_COURSECAT
,
413 'moodle/category:delete' => array(
415 'captype' => 'write',
416 'contextlevel' => CONTEXT_COURSECAT
,
422 'moodle/category:update' => array(
424 'riskbitmask' => RISK_XSS
,
426 'captype' => 'write',
427 'contextlevel' => CONTEXT_COURSECAT
,
433 'moodle/category:visibility' => array(
435 'captype' => 'write',
436 'contextlevel' => CONTEXT_COURSECAT
,
442 'moodle/course:create' => array(
444 'riskbitmask' => RISK_XSS
,
446 'captype' => 'write',
447 'contextlevel' => CONTEXT_COURSECAT
,
449 'coursecreator' => CAP_ALLOW
,
454 'moodle/course:delete' => array(
456 'captype' => 'write',
457 'contextlevel' => CONTEXT_COURSE
,
463 'moodle/course:update' => array(
465 'riskbitmask' => RISK_XSS
,
467 'captype' => 'write',
468 'contextlevel' => CONTEXT_COURSE
,
470 'editingteacher' => CAP_ALLOW
,
475 'moodle/course:view' => array(
478 'contextlevel' => CONTEXT_COURSE
,
480 'guest' => CAP_ALLOW
,
481 'student' => CAP_ALLOW
,
482 'teacher' => CAP_ALLOW
,
483 'editingteacher' => CAP_ALLOW
487 'moodle/course:bulkmessaging' => array(
489 'riskbitmask' => RISK_SPAM
,
491 'captype' => 'write',
492 'contextlevel' => CONTEXT_COURSE
,
494 'teacher' => CAP_ALLOW
,
495 'editingteacher' => CAP_ALLOW
,
500 'moodle/course:viewhiddenuserfields' => array(
502 'riskbitmask' => RISK_PERSONAL
,
505 'contextlevel' => CONTEXT_COURSE
,
507 'teacher' => CAP_ALLOW
,
508 'editingteacher' => CAP_ALLOW
,
513 'moodle/course:viewhiddencourses' => array(
516 'contextlevel' => CONTEXT_COURSE
,
518 'coursecreator' => CAP_ALLOW
,
519 'teacher' => CAP_ALLOW
,
520 'editingteacher' => CAP_ALLOW
,
525 'moodle/course:visibility' => array(
527 'captype' => 'write',
528 'contextlevel' => CONTEXT_COURSE
,
534 'moodle/course:managefiles' => array(
536 'riskbitmask' => RISK_XSS
,
538 'captype' => 'write',
539 'contextlevel' => CONTEXT_COURSE
,
541 'editingteacher' => CAP_ALLOW
,
546 'moodle/course:manageactivities' => array(
548 'riskbitmask' => RISK_XSS
,
550 'captype' => 'write',
551 'contextlevel' => CONTEXT_COURSE
,
553 'editingteacher' => CAP_ALLOW
,
558 'moodle/course:managemetacourse' => array(
560 'captype' => 'write',
561 'contextlevel' => CONTEXT_COURSE
,
563 'editingteacher' => CAP_ALLOW
,
568 'moodle/course:activityvisibility' => array(
570 'captype' => 'write',
571 'contextlevel' => CONTEXT_COURSE
,
573 'editingteacher' => CAP_ALLOW
,
578 'moodle/course:viewhiddenactivities' => array(
580 'captype' => 'write',
581 'contextlevel' => CONTEXT_COURSE
,
583 'teacher' => CAP_ALLOW
,
584 'editingteacher' => CAP_ALLOW
,
589 'moodle/course:viewparticipants' => array(
592 'contextlevel' => CONTEXT_COURSE
,
594 'student' => CAP_ALLOW
,
595 'teacher' => CAP_ALLOW
,
596 'editingteacher' => CAP_ALLOW
,
601 'moodle/course:viewscales' => array(
604 'contextlevel' => CONTEXT_COURSE
,
606 'student' => CAP_ALLOW
,
607 'teacher' => CAP_ALLOW
,
608 'editingteacher' => CAP_ALLOW
,
613 'moodle/course:managescales' => array(
615 'captype' => 'write',
616 'contextlevel' => CONTEXT_COURSE
,
618 'editingteacher' => CAP_ALLOW
,
623 'moodle/course:managegroups' => array(
625 'captype' => 'write',
626 'contextlevel' => CONTEXT_COURSE
,
628 'editingteacher' => CAP_ALLOW
,
633 'moodle/course:reset' => array(
635 'captype' => 'write',
636 'contextlevel' => CONTEXT_COURSE
,
638 'editingteacher' => CAP_ALLOW
,
643 'moodle/blog:view' => array(
646 'contextlevel' => CONTEXT_SYSTEM
,
648 'guest' => CAP_ALLOW
,
650 'student' => CAP_ALLOW
,
651 'teacher' => CAP_ALLOW
,
652 'editingteacher' => CAP_ALLOW
,
657 'moodle/blog:create' => array( // works in CONTEXT_SYSTEM only
659 'riskbitmask' => RISK_SPAM
,
661 'captype' => 'write',
662 'contextlevel' => CONTEXT_SYSTEM
,
669 'moodle/blog:manageofficialtags' => array(
671 'riskbitmask' => RISK_SPAM
,
673 'captype' => 'write',
674 'contextlevel' => CONTEXT_SYSTEM
,
680 'moodle/blog:managepersonaltags' => array(
682 'riskbitmask' => RISK_SPAM
,
684 'captype' => 'write',
685 'contextlevel' => CONTEXT_SYSTEM
,
687 'student' => CAP_ALLOW
,
688 'teacher' => CAP_ALLOW
,
689 'editingteacher' => CAP_ALLOW
,
694 'moodle/blog:manageentries' => array(
696 'riskbitmask' => RISK_SPAM
,
698 'captype' => 'write',
699 'contextlevel' => CONTEXT_SYSTEM
,
701 'teacher' => CAP_ALLOW
,
702 'editingteacher' => CAP_ALLOW
,
707 'moodle/calendar:manageownentries' => array( // works in CONTEXT_SYSTEM only
709 'riskbitmask' => RISK_SPAM
,
711 'captype' => 'write',
712 'contextlevel' => CONTEXT_SYSTEM
,
719 'moodle/calendar:manageentries' => array(
721 'riskbitmask' => RISK_SPAM
,
723 'captype' => 'write',
724 'contextlevel' => CONTEXT_SYSTEM
,
726 'teacher' => CAP_ALLOW
,
727 'editingteacher' => CAP_ALLOW
,
732 'moodle/user:editprofile' => array(
734 'riskbitmask' => RISK_SPAM
,
736 'captype' => 'write',
737 'contextlevel' => CONTEXT_USER
,
743 'moodle/user:editownprofile' => array(
745 'captype' => 'write',
746 'contextlevel' => CONTEXT_SYSTEM
,
748 'guest' => CAP_PROHIBIT
,
754 'moodle/user:changeownpassword' => array(
756 'captype' => 'write',
757 'contextlevel' => CONTEXT_SYSTEM
,
759 'guest' => CAP_PROHIBIT
,
765 // The next 3 might make no sense for some roles, e.g teacher, etc.
766 // since the next level up is site. These are more for the parent role
767 'moodle/user:readuserposts' => array(
770 'contextlevel' => CONTEXT_USER
,
772 'student' => CAP_ALLOW
,
773 'teacher' => CAP_ALLOW
,
774 'editingteacher' => CAP_ALLOW
,
779 'moodle/user:readuserblogs' => array(
782 'contextlevel' => CONTEXT_USER
,
784 'student' => CAP_ALLOW
,
785 'teacher' => CAP_ALLOW
,
786 'editingteacher' => CAP_ALLOW
,
791 'moodle/user:viewuseractivitiesreport' => array(
794 'contextlevel' => CONTEXT_USER
,
796 'teacher' => CAP_ALLOW
,
797 'editingteacher' => CAP_ALLOW
,
802 'moodle/question:import' => array(
804 'riskbitmask' => RISK_XSS
,
806 'captype' => 'write',
807 'contextlevel' => CONTEXT_COURSE
,
809 'editingteacher' => CAP_ALLOW
,
814 'moodle/question:export' => array(
817 'contextlevel' => CONTEXT_COURSE
,
819 'editingteacher' => CAP_ALLOW
,
824 'moodle/question:managecategory' => array(
826 'captype' => 'write',
827 'contextlevel' => CONTEXT_COURSE
,
829 'editingteacher' => CAP_ALLOW
,
834 'moodle/question:manage' => array(
836 'riskbitmask' => RISK_XSS
,
838 'captype' => 'write',
839 'contextlevel' => CONTEXT_COURSE
,
841 'editingteacher' => CAP_ALLOW
,
846 // Configure the installed question types.
847 'moodle/question:config' => array(
849 'riskbitmask' => RISK_CONFIG
,
851 'captype' => 'write',
852 'contextlevel' => CONTEXT_SYSTEM
,
858 'moodle/site:doclinks' => array(
861 'contextlevel' => CONTEXT_SYSTEM
,
863 'teacher' => CAP_ALLOW
,
864 'editingteacher' => CAP_ALLOW
,
869 'moodle/course:sectionvisibility' => array(
871 'captype' => 'write',
872 'contextlevel' => CONTEXT_COURSE
,
874 'editingteacher' => CAP_ALLOW
,
879 'moodle/course:useremail' => array(
881 'captype' => 'write',
882 'contextlevel' => CONTEXT_COURSE
,
884 'editingteacher' => CAP_ALLOW
,
889 'moodle/course:viewhiddensections' => array(
891 'captype' => 'write',
892 'contextlevel' => CONTEXT_COURSE
,
894 'editingteacher' => CAP_ALLOW
,
899 'moodle/course:setcurrentsection' => array(
901 'captype' => 'write',
902 'contextlevel' => CONTEXT_COURSE
,
904 'editingteacher' => CAP_ALLOW
,
909 'moodle/site:mnetlogintoremote' => array(
910 'riskbitmask' => RISK_PERSONAL | RISK_XSS
,
912 'contextlevel' => CONTEXT_SYSTEM
,
918 'moodle/grade:viewall' => array(
919 'riskbitmask' => RISK_PERSONAL
,
921 'contextlevel' => CONTEXT_COURSE
,
923 'teacher' => CAP_ALLOW
,
924 'editingteacher' => CAP_ALLOW
,
927 'clonepermissionsfrom' => 'moodle/course:viewcoursegrades'
930 'moodle/grade:view' => array(
932 'contextlevel' => CONTEXT_COURSE
, // and CONTEXT_PERSONAL too
934 'student' => CAP_ALLOW
938 'moodle/grade:viewhidden' => array(
939 'riskbitmask' => RISK_PERSONAL
,
941 'contextlevel' => CONTEXT_COURSE
, // and CONTEXT_PERSONAL too
944 'clonepermissionsfrom' => 'moodle/course:viewcoursegrades'
947 'moodle/grade:import' => array(
948 'riskbitmask' => RISK_PERSONAL
,
949 'captype' => 'write',
950 'contextlevel' => CONTEXT_COURSE
,
952 'editingteacher' => CAP_ALLOW
,
955 'clonepermissionsfrom' => 'moodle/course:managegrades'
958 'moodle/grade:export' => array(
959 'riskbitmask' => RISK_PERSONAL
,
961 'contextlevel' => CONTEXT_COURSE
,
963 'teacher' => CAP_ALLOW
,
964 'editingteacher' => CAP_ALLOW
,
967 'clonepermissionsfrom' => 'moodle/course:managegrades'
970 'moodle/grade:manage' => array(
971 'riskbitmask' => RISK_PERSONAL
,
972 'captype' => 'write',
973 'contextlevel' => CONTEXT_COURSE
,
975 'editingteacher' => CAP_ALLOW
,
978 'clonepermissionsfrom' => 'moodle/course:managegrades'
981 'moodle/grade:hide' => array(
982 'captype' => 'write',
983 'contextlevel' => CONTEXT_COURSE
,
985 'editingteacher' => CAP_ALLOW
,
990 'moodle/grade:lock' => array(
991 'captype' => 'write',
992 'contextlevel' => CONTEXT_COURSE
,
994 'editingteacher' => CAP_ALLOW
,
999 'moodle/grade:unlock' => array(
1000 'captype' => 'write',
1001 'contextlevel' => CONTEXT_COURSE
,
1003 'editingteacher' => CAP_ALLOW
,
1004 'admin' => CAP_ALLOW
1008 'moodle/grade:override' => array(
1009 'captype' => 'write',
1010 'contextlevel' => CONTEXT_COURSE
,
1012 'editingteacher' => CAP_ALLOW
,
1013 'admin' => CAP_ALLOW
1017 'moodle/my:manageblocks' => array(
1018 'captype' => 'write',
1019 'contextlevel' => CONTEXT_SYSTEM
,
1025 'moodle/notes:view' => array(
1026 'captype' => 'read',
1027 'contextlevel' => CONTEXT_SYSTEM
,
1029 'teacher' => CAP_ALLOW
,
1030 'editingteacher' => CAP_ALLOW
,
1031 'admin' => CAP_ALLOW
1035 'moodle/notes:manage' => array(
1036 'captype' => 'write',
1037 'contextlevel' => CONTEXT_SYSTEM
,
1039 'teacher' => CAP_ALLOW
,
1040 'editingteacher' => CAP_ALLOW
,
1041 'admin' => CAP_ALLOW