5 $submitlabel = get_string('addrole', 'role');
9 $submitlabel = get_string('savechanges');
12 if ($action == 'view') {
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); } ?>" />
23 <table
class="roledesc" cellpadding
="9" cellspacing
="0">
24 <?php
if ($action == 'view') { ?>
26 <td align=
"right"><?php print_string('name') ?>:
</td>
27 <td><?php p(format_string($role->name
)); ?></td>
30 <td align=
"right"><?php print_string('shortname') ?>:
</td>
31 <td><?php p($role->shortname
); ?></td>
34 <td align=
"right"><?php print_string('description') ?>:
</td>
35 <td><?php p(format_text($role->description
, FORMAT_HTML
)); $usehtmleditor = false; ?></td>
38 <td align=
"right"><?php print_string('legacytype', 'role') ?>:
</td>
40 $usehtmleditor = false;
41 if (empty($role->legacytype
)) {
44 print_string('legacy:'.$role->legacytype
, 'role');
51 <td align=
"right"><label for=
"name"><?php print_string('name') ?></label></td>
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"]);
59 <td align=
"right"><label for=
"shortname"><?php print_string('shortname') ?></label></td>
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"]);
67 <td align=
"right"><label for=
"edit-description"><?php print_string('description') ?></label></td>
69 print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description
);
74 <td align=
"right"><label for=
"menulegacytype"><?php print_string('legacytype', 'role') ?></label></td>
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
, '');
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">
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>
115 $strrisks = s(get_string('risks', 'role'));
117 $strcapabilities = 'Capabilities';//s(get_string('capabilities', 'role'));
119 // prepare legacy defaults
120 if (!empty($role->legacytype
)) {
121 $defaultcaps = get_default_capabilities($role->legacytype
);
123 $defaultcaps = false;
126 foreach ($capabilities as $capability) {
128 //legacy caps have their own selector
129 if (islegacy($capability->name
)) {
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
);
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">';
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; ?>
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') ?>" />