Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / roles / manage.html
blob6af4d4a85eba0a4873bbf2aeac80b21fec5518a2
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($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($role->description); $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="20" 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 $strcapabilities = s(get_string('capabilities', 'role'));
118 // prepare legacy defaults
119 if (!empty($role->legacytype)) {
120 $defaultcaps = get_default_capabilities($role->legacytype);
121 } else {
122 $defaultcaps = false;
125 foreach ($capabilities as $capability) {
127 //legacy caps have their own selector
128 if (islegacy($capability->name)) {
129 continue;
132 // prints a breaker if component or name or context level
133 if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
134 echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
135 get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
138 // these 2 are used to see to group same mod/core capabilities together
139 $contextlevel = $capability->contextlevel;
140 $component = $capability->component;
142 if (empty($errors)) {
143 // check the capability override for this cap, this role in this context
144 $localoverride = get_local_override($roleid, $sitecontext->id, $capability->name);
145 } else {
146 $localoverride = new object();
147 $localoverride->permission = $role->{$capability->name};
150 $disabled = ($action != 'edit' and $action != 'add') ? ' disabled="disabled" ' : '';
152 $riskinfo = '<td class="risk managetrust">';
153 $rowclasses = '';
154 if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
155 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskmanagetrust', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
156 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_managetrust.gif" alt="'.get_string('riskmanagetrustshort', 'admin').'" /></a>';
157 $rowclasses .= ' riskmanagetrust';
159 $riskinfo .= '</td><td class="risk config">';
160 if (RISK_CONFIG & (int)$capability->riskbitmask) {
161 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskconfig', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
162 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_config.gif" alt="'.get_string('riskconfigshort', 'admin').'" /></a>';
163 $rowclasses .= ' riskconfig';
165 $riskinfo .= '</td><td class="risk xss">';
166 if (RISK_XSS & (int)$capability->riskbitmask) {
167 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskxss', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
168 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_xss.gif" alt="'.get_string('riskxssshort', 'admin').'" /></a>';
169 $rowclasses .= ' riskxss';
171 $riskinfo .= '</td><td class="risk personal">';
172 if (RISK_PERSONAL & (int)$capability->riskbitmask) {
173 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskpersonal', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
174 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_personal.gif" alt="'.get_string('riskpersonalshort', 'admin').'" /></a>';
175 $rowclasses .= ' riskpersonal';
177 $riskinfo .= '</td><td class="risk spam">';
178 if (RISK_SPAM & (int)$capability->riskbitmask) {
179 $riskinfo .= '<a onclick="this.target=\'docspopup\'" title="'.get_string('riskspam', 'admin').'" href="'.$CFG->docroot.'/'.$lang.'/'.$strrisks.'">';
180 $riskinfo .= '<img src="'.$CFG->pixpath.'/i/risk_spam.gif" alt="'.get_string('riskspamshort', 'admin').'" /></a>';
181 $rowclasses .= ' riskspam';
183 $riskinfo .= '</td>';
185 $isinherit = (!isset($defaultcaps[$capability->name]) or $defaultcaps[$capability->name] == CAP_INHERIT) ? 'capdefault' : '';
186 $isallow = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_ALLOW) ? 'capdefault' : '';
187 $isprevent = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PREVENT) ? 'capdefault' : '';
188 $isprohibit = (isset($defaultcaps[$capability->name]) and $defaultcaps[$capability->name] == CAP_PROHIBIT) ? 'capdefault' : '';
192 <tr class="rolecap <?php echo $rowclasses; ?>">
193 <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>
194 <td class="inherit <?php echo $isinherit ?>">
195 <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>
196 <td class="allow <?php echo $isallow ?>">
197 <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>
198 <td class="prevent <?php echo $isprevent ?>" >
199 <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>
200 <td class="prohibit <?php echo $isprohibit ?>" >
201 <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>
203 <?php echo $riskinfo; ?>
205 </tr>
207 <?php } ?>
208 </table>
210 <?php if ($action != 'view') { ?>
211 <div class="submit buttons">
212 <input type="submit" value="<?php p($submitlabel) ?>" />
213 <input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
214 </div>
215 <?php } ?>
217 </form>