MDL-10092:
[moodle-linuxchix.git] / admin / roles / override.html
blobbdab5946a6ec00c483e9610d0121760f17754762
1 <?php
2 $strinherit = get_string('inherit','role');
3 $strallow = get_string('allow','role');
4 $strprevent = get_string('prevent','role');
5 $strprohibit = get_string('prohibit','role');
6 ?>
8 <form id="overrideform" action="override.php" method="post">
9 <fieldset class="invisiblefieldset">
10 <input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
11 <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
12 <input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
13 <input type="hidden" name="userid" value="<?php p($userid) ?>" />
14 <input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
15 </fieldset>
17 <table class="rolecap">
18 <tr>
19 <th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
20 <th class="inherit" scope="col"><?php p($strinherit); ?></th>
21 <th class="allow" scope="col"><?php p($strallow); ?></th>
22 <th class="prevent" scope="col"><?php p($strprevent); ?></th>
23 <th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
24 <th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
25 </tr>
26 <?php
28 // init these 2
29 $contextlevel = 0;
30 $component = '';
32 $strrisks = s(get_string('risks', 'role'));
33 $strcapabilities = s(get_string('capabilities', 'role'));
35 foreach ($capabilities as $capability) {
37 // legacy caps should not be overriden - we must use proper capabilities if needed
38 if (islegacy($capability->name)) {
39 continue;
42 // prints a breaker if component or name or context level
43 //if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
44 if (component_level_changed($capability, $component, $contextlevel)) {
45 echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
48 // these 2 are used to see to group same mod/core capabilities together
49 $contextlevel = $capability->contextlevel;
50 $component = $capability->component;
52 // check the capability override for this cap, this role in this context
53 if (isset($localoverrides[$capability->name])) {
54 $localpermission = $localoverrides[$capability->name]->permission;
55 } else {
56 $localpermission = 0; // Just inherit
59 if (isset($r_caps[$capability->name])) {
60 $isallow = $r_caps[$capability->name] > 0;
61 $isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500;
62 $isprohibit = $r_caps[$capability->name] <= -500;
63 } else {
64 $isallow = 0;
65 $isprevent = 0;
66 $isprohibit = 0;
69 $isdisabled = $isprohibit;
71 $riskinfo = '<td class="risk managetrust">';
72 $rowclasses = '';
73 if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
74 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
75 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
76 $rowclasses .= ' riskmanagetrust';
78 $riskinfo .= '</td><td class="risk config">';
79 if (RISK_CONFIG & (int)$capability->riskbitmask) {
80 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
81 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
82 $rowclasses .= ' riskconfig';
84 $riskinfo .= '</td><td class="risk xss">';
85 if (RISK_XSS & (int)$capability->riskbitmask) {
86 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
87 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
88 $rowclasses .= ' riskxss';
90 $riskinfo .= '</td><td class="risk personal">';
91 if (RISK_PERSONAL & (int)$capability->riskbitmask) {
92 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
93 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
94 $rowclasses .= ' riskpersonal';
96 $riskinfo .= '</td><td class="risk spam">';
97 if (RISK_SPAM & (int)$capability->riskbitmask) {
98 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
99 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
100 $rowclasses .= ' riskspam';
102 $riskinfo .= '</td>';
107 <tr class="rolecap <?php echo $rowclasses; ?>">
108 <td class="name"><span class="cap-desc"><a onclick="this.target='docspopup'" href="<?php echo $CFG->docroot.'/'.$lang.'/'.$strcapabilities.'/'.$capability->name ?>"><?php echo get_capability_string($capability->name); ?></a><span class="cap-name"><?php echo $capability->name ?></span></span></td>
110 <td class="inherit">
111 <input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="0"
112 <?php
113 if ($localpermission == CAP_INHERIT) {echo 'checked="checked" ';}
114 if ($isdisabled) {echo 'disabled="disabled"';}?> />
115 </td>
117 <td class="allow <?php if ($isallow) {echo ' capcurrent';} ?>">
118 <input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>"
119 <?php echo ' value="'.CAP_ALLOW.'"';
120 if ($localpermission == CAP_ALLOW) {echo ' checked="checked" ';}
121 if ($isdisabled) {echo ' disabled="disabled"';}?> />
122 </td>
124 <td class="prevent <?php if ($isprevent) {echo ' capcurrent';} ?>">
125 <input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>"
126 <?php echo ' value="'.CAP_PREVENT.'"';
127 if ($localpermission == CAP_PREVENT) {echo ' checked="checked" ';}
128 if ($isdisabled) {echo ' disabled="disabled"';}?> />
129 </td>
131 <td class="prohibit <?php if ($isprohibit) {echo ' capcurrent';} ?>">
132 <input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>"
133 <?php echo ' value="'.CAP_PROHIBIT.'"';
134 if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked" ';}
135 if ($isdisabled) {echo ' disabled="disabled"';}?> />
136 </td>
137 <?php echo $riskinfo; ?>
138 </tr>
140 <?php } ?>
141 </table>
142 <div class="submit buttons">
143 <input type="submit" value="<?php print_string('savechanges') ?>" />
144 <input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
145 </div>
146 </form>