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($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($role->description
); $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="20" 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'));
116 $strcapabilities = s(get_string('capabilities', 'role'));
118 // prepare legacy defaults
119 if (!empty($role->legacytype
)) {
120 $defaultcaps = get_default_capabilities($role->legacytype
);
122 $defaultcaps = false;
125 foreach ($capabilities as $capability) {
127 //legacy caps have their own selector
128 if (islegacy($capability->name
)) {
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
);
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">';
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; ?>
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') ?>" />