file SafeParam.php was added on branch MOODLE_19_STABLE on 2010-05-21 11:39:40 +0000
[moodle.git] / admin / roles / manage.html
blob188907e509a115f1bcb8cbaf878b1fb882fb3487
1 <?php //$Id$
3 switch ($action) {
4 case 'add':
5 $submitlabel = get_string('addrole', 'role');
6 break;
7 case 'edit':
8 default:
9 $submitlabel = get_string('savechanges');
12 if ($action == 'view') {
14 <?php
17 <form id="rolesform" action="manage.php" method="post">
18 <fieldset class="invisiblefieldset">
19 <input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
20 <input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
21 <input type="hidden" name="action" value="<?php if ($action != 'view') { echo p($action); } ?>" />
22 </fieldset>
23 <table class="roledesc" cellpadding="9" cellspacing="0">
24 <?php if ($action == 'view') { ?>
25 <tr valign="top">
26 <td align="right"><?php print_string('name') ?>:</td>
27 <td><?php p(format_string($role->name)); ?></td>
28 </tr>
29 <tr valign="top">
30 <td align="right"><?php print_string('shortname') ?>:</td>
31 <td><?php p($role->shortname); ?></td>
32 </tr>
33 <tr valign="top">
34 <td align="right"><?php print_string('description') ?>:</td>
35 <td><?php p(format_text($role->description, FORMAT_HTML)); $usehtmleditor = false; ?></td>
36 </tr>
37 <tr valign="top">
38 <td align="right"><?php print_string('legacytype', 'role') ?>:</td>
39 <td><?php
40 $usehtmleditor = false;
41 if (empty($role->legacytype)) {
42 print_string('none');
43 } else {
44 print_string('legacy:'.$role->legacytype, 'role');
47 </td>
48 </tr>
49 <?php } else { ?>
50 <tr valign="top">
51 <td align="right"><label for="name"><?php print_string('name') ?></label></td>
52 <td><?php
53 echo '<input type="text" id="name" name="name" maxlength="254" size="50" value="'.s($role->name).'" />';
54 if (isset($errors["name"])) formerr($errors["name"]);
56 </td>
57 </tr>
58 <tr valign="top">
59 <td align="right"><label for="shortname"><?php print_string('shortname') ?></label></td>
60 <td><?php
61 echo '<input type="text" id="shortname" name="shortname" maxlength="100" size="15" value="'.s($role->shortname).'" />';
62 if (isset($errors["shortname"])) formerr($errors["shortname"]);
64 </td>
65 </tr>
66 <tr valign="top">
67 <td align="right"><label for="edit-description"><?php print_string('description') ?></label></td>
68 <td><?php
69 print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description);
71 </td>
72 </tr>
73 <tr valign="top">
74 <td align="right"><label for="menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
75 <td><?php
76 $options = array();
77 $options[''] = get_string('none');
78 $legacyroles = get_legacy_roles();
79 foreach($legacyroles as $ltype=>$lcap) {
80 $options[$ltype] = get_string('legacy:'.$ltype, 'role');
82 choose_from_menu($options, 'legacytype', $role->legacytype, '');
84 </td>
85 </tr>
86 <?php } ?>
87 </table>
89 <?php
90 print_heading_with_help(get_string('permissions','role'), 'permissions');
92 $strinherit = get_string('notset','role');
93 $strallow = get_string('allow','role');
94 $strprevent = get_string('prevent','role');
95 $strprohibit = get_string('prohibit','role');
98 <table class="rolecap">
100 <tr>
101 <th class="name" align="left" scope="col"><?php print_string('capability','role') ?></th>
102 <th class="inherit" scope="col"><?php p($strinherit); ?></th>
103 <th class="allow" scope="col"><?php p($strallow); ?></th>
104 <th class="prevent" scope="col"><?php p($strprevent); ?></th>
105 <th class="prohibit" scope="col"><?php p($strprohibit); ?></th>
106 <th class="risk" colspan="5" scope="col"><?php print_string('risks','role') ?></th>
107 </tr>
109 <?php
111 // init these 2
112 $contextlevel = 0;
113 $component = '';
115 $strrisks = s(get_string('risks', 'role'));
116 // MDL-11687
117 $strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
119 // prepare legacy defaults
120 if (!empty($role->legacytype)) {
121 $defaultcaps = get_default_capabilities($role->legacytype);
122 } else {
123 $defaultcaps = false;
126 foreach ($capabilities as $capability) {
128 //legacy caps have their own selector
129 if (islegacy($capability->name)) {
130 continue;
133 // prints a breaker if component or name or context level
134 if (component_level_changed($capability, $component, $contextlevel)) {
135 //if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
136 echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
137 get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
140 // these 2 are used to see to group same mod/core capabilities together
141 $contextlevel = $capability->contextlevel;
142 $component = $capability->component;
144 if (empty($errors)) {
145 // check the capability override for this cap, this role in this context
146 $localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
147 } else {
148 $localoverride = new object();
149 $localoverride->permission = $role->{$capability->name};
152 $disabled = ($action != 'edit' and $action != 'add') ? ' disabled="disabled" ' : '';
154 $riskinfo = '<td class="risk managetrust">';
155 $rowclasses = '';
156 if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
157 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
158 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
159 $rowclasses .= ' riskmanagetrust';
161 $riskinfo .= '</td><td class="risk config">';
162 if (RISK_CONFIG & (int)$capability->riskbitmask) {
163 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
164 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
165 $rowclasses .= ' riskconfig';
167 $riskinfo .= '</td><td class="risk xss">';
168 if (RISK_XSS & (int)$capability->riskbitmask) {
169 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
170 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
171 $rowclasses .= ' riskxss';
173 $riskinfo .= '</td><td class="risk personal">';
174 if (RISK_PERSONAL & (int)$capability->riskbitmask) {
175 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
176 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
177 $rowclasses .= ' riskpersonal';
179 $riskinfo .= '</td><td class="risk spam">';
180 if (RISK_SPAM & (int)$capability->riskbitmask) {
181 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
182 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
183 $rowclasses .= ' riskspam';
185 $riskinfo .= '</td>';
187 $isinherit = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
188 $isallow = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
189 $isprevent = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
190 $isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
194 <tr class="rolecap <?php echo $rowclasses; ?>">
195 <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>
196 <td class="inherit <?php echo $isinherit ?>">
197 <input type="radio" title="<?php p($strinherit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_INHERIT ?>" <?php if (!isset($localoverride->permission) || $localoverride->permission==CAP_INHERIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
198 <td class="allow <?php echo $isallow ?>">
199 <input type="radio" title="<?php p($strallow); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_ALLOW ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_ALLOW){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
200 <td class="prevent <?php echo $isprevent ?>" >
201 <input type="radio" title="<?php p($strprevent); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PREVENT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PREVENT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
202 <td class="prohibit <?php echo $isprohibit ?>" >
203 <input type="radio" title="<?php p($strprohibit); ?>" name="<?php echo $capability->name; ?>" value="<?php echo CAP_PROHIBIT ?>" <?php if (isset($localoverride->permission) && $localoverride->permission==CAP_PROHIBIT){ echo 'checked="checked"'; }?> <?php echo $disabled; ?>/></td>
205 <?php echo $riskinfo; ?>
207 </tr>
209 <?php } ?>
210 </table>
212 <?php if ($action != 'view') { ?>
213 <div class="submit buttons">
214 <input type="submit" value="<?php p($submitlabel) ?>" />
215 <input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
216 </div>
217 <?php } ?>
219 </form>