Skip to content

Commit

Permalink
various minor Role UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 19, 2006
1 parent 946cbe7 commit 681729b
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 45 deletions.
4 changes: 2 additions & 2 deletions admin/roles/allowassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

/// get all the roles identifier
foreach ($roles as $role) {
$rolesname[] = $role->name;
$rolesname[] = format_string($role->name);
$roleids[] = $role->id;
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
Expand All @@ -77,7 +77,7 @@

foreach ($roles as $role) {
$beta = get_box_list($role->id, $roleids);
$table->data[] = array_merge(array($role->name), $beta);
$table->data[] = array_merge(array(format_string($role->name)), $beta);
}

print_simple_box(get_string('configallowassign', 'admin'), 'center');
Expand Down
4 changes: 2 additions & 2 deletions admin/roles/allowoverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

/// get all the roles identifier
foreach ($roles as $role) {
$rolesname[] = $role->name;
$rolesname[] = format_string($role->name);
$roleids[] = $role->id;
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
Expand All @@ -75,7 +75,7 @@

foreach ($roles as $role) {
$beta = get_box_list($role->id, $roleids);
$table->data[] = array_merge(array($role->name), $beta);
$table->data[] = array_merge(array(format_string($role->name)), $beta);
}

print_simple_box(get_string('configallowoverride', 'admin'), 'center');
Expand Down
6 changes: 3 additions & 3 deletions admin/roles/assign.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
print ('<input type="hidden" name="courseid" value="'.$courseid.'" />');
}
?>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<input type="hidden" name="contextid" value="<?php echo $contextid ?>" />
<input type="hidden" name="roleid" value="<?php echo $roleid ?>" />
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
echo '<input type="hidden" name="courseid" value="'.$courseid.'" />';
}
echo '<input type="hidden" name="contextid" value="'.$context->id.'" />'.$strroletoassign.': ';
choose_from_menu ($assignableroles, 'roleid', $roleid, 'choose', $script='rolesform.submit()');
choose_from_menu ($assignableroles, 'roleid', $roleid, get_string('listallroles', 'role'), $script='rolesform.submit()');
echo '</div></form>';

print_simple_box_start("center");
Expand Down
47 changes: 28 additions & 19 deletions admin/roles/manage.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<form name="rolesform" action="manage.php" method="post">
<input type="hidden" name="roleid" value="<?php echo $roleid; ?>">
<input type="hidden" name="sesskey" value="<?php print (sesskey()); ?>">
<input type="hidden" name="action" value="<?php echo $action; ?>">
<br/>Role Name: <input type="text" name="name" value="<?php echo $role->name; ?>">
&nbsp;
Role short name (ASCII): <input type="text" name="shortname" value="<?php echo $role->shortname; ?>" />
<br/>Role Description:
<?php //$Id$

<?php print_textarea($CFG->htmleditor, 10, 50, 50, 10, 'description', "$role->description"); ?>
switch ($action) {
case 'add': $submitlabel = get_string('addrole', 'role'); break;
case 'edit':
default: $submitlabel = get_string('savechanges');
}
?>
<form name="rolesform" action="manage.php" method="post">
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
<input type="hidden" name="action" value="<?php p($action) ?>" />
<input type="hidden" name="contextid" value="<?php p($contextid) ?>" />

<input type="hidden" name="contextid" value="<?php echo $contextid; ?>">
<br />
<?php print_string('rolename', 'role'); ?>: <input type="text" name="name" value="<?php p($role->name) ?>" />&nbsp;
<?php print_string('roleshortname', 'role'); ?>: <input type="text" name="shortname" value="<?php p($role->shortname) ?>" />
<br />
<?php print_string('roledescription', 'role'); ?>:
<?php print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description); ?>
<p>
<table>
<tr>
Expand All @@ -30,8 +38,8 @@
foreach ($capabilities as $capability) {
// prints a breaker if component or name or context level
if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
echo ('<tr><td colspan="4"><b>'.
get_component_string($capability->component, $capability->contextlevel).'</b></td></tr>');
echo ('<tr><td colspan="4"><strong>'.
get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
}

// these 2 are used to see to group same mod/core capabilities together
Expand All @@ -47,10 +55,10 @@

<tr>
<td><span title="<?php echo $capability->name ?>"><?php echo get_capability_string($capability->name); ?></span></td>
<td><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="0" <?php if (!isset($localoverride->permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?>></td>
<td><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="1" <?php if (isset($localoverride->permission) && $localoverride->permission==1){ echo 'checked="checked"'; }?>></td>
<td ><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="-1" <?php if (isset($localoverride->permission) && $localoverride->permission==-1){ echo 'checked="checked"'; }?>></td>
<td ><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="-1000" <?php if (isset($localoverride->permission) && $localoverride->permission==-1000){ echo 'checked="checked"'; }?>></td>
<td><input TYPE="radio" name="<?php echo $capability->name; ?>" value="0" <?php if (!isset($localoverride->permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?> /></td>
<td><input TYPE="radio" name="<?php echo $capability->name; ?>" value="1" <?php if (isset($localoverride->permission) && $localoverride->permission==1){ echo 'checked="checked"'; }?> /></td>
<td ><input TYPE="radio" name="<?php echo $capability->name; ?>" value="-1" <?php if (isset($localoverride->permission) && $localoverride->permission==-1){ echo 'checked="checked"'; }?> /></td>
<td ><input TYPE="radio" name="<?php echo $capability->name; ?>" value="-1000" <?php if (isset($localoverride->permission) && $localoverride->permission==-1000){ echo 'checked="checked"'; }?> /></td>
<td><?php
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
echo "T";
Expand All @@ -70,8 +78,9 @@
?></td>
</tr>

<?php } ?>
</table>
<?php } ?>
</table>
</p>
<br/><input type="submit" value="<?php print_string($action);?>">
<br />
<input type="submit" value="<?php p($submitlabel); ?>" />
</form>
16 changes: 10 additions & 6 deletions admin/roles/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role
$name = optional_param('name', '', PARAM_MULTILANG); // new role name
$shortname = optional_param('shortname', '', PARAM_SAFEDIR); // new role shortname
$description = optional_param('description', '', PARAM_MULTILANG); // new role desc
$description = optional_param('description', '', PARAM_CLEAN); // new role desc
$action = optional_param('action', '', PARAM_ALPHA);
$confirm = optional_param('confirm', 0, PARAM_BOOL);

Expand Down Expand Up @@ -148,13 +148,13 @@
}

foreach ($roles as $rolex) {
$roleoptions[$rolex->id] = $rolex->name;
$roleoptions[$rolex->id] = format_string($rolex->name);
}

// prints a form to swap roles
print ('<form name="rolesform1" action="manage.php" method="post">');
print ('<div align="center">'.get_string('selectrole').': ');
choose_from_menu ($roleoptions, 'roleid', $roleid, 'choose', $script='rolesform1.submit()');
print ('<div align="center">'.get_string('selectrole', 'role').': ');
choose_from_menu ($roleoptions, 'roleid', $roleid, get_string('listallroles', 'role'), $script='rolesform1.submit()');
print ('</div></form>');

// this is the array holding capabilities of this role sorted till this context
Expand All @@ -163,10 +163,15 @@
// this is the available capabilities assignable in this context
$capabilities = fetch_context_capabilities($sitecontext);

$usehtmleditor = can_use_html_editor();
print_simple_box_start();
include_once('manage.html');
print_simple_box_end();

if ($usehtmleditor) {
use_html_editor('description');
}

} else {

$table = new object;
Expand All @@ -188,7 +193,7 @@

foreach ($roles as $role) {

$table->data[] = array('<a href="manage.php?roleid='.$role->id.'&amp;sesskey='.sesskey().'">'.$role->name.'</a>', $role->description, '<a href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>');
$table->data[] = array('<a href="manage.php?roleid='.$role->id.'&amp;sesskey='.sesskey().'">'.format_string($role->name).'</a>', format_text($role->description, FORMAT_HTML), '<a href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>');

}
print_table($table);
Expand All @@ -199,6 +204,5 @@
print_single_button('manage.php', $options, get_string('addrole', 'role'), 'POST');
}

use_html_editor('description');
admin_externalpage_print_footer($adminroot);
?>
14 changes: 7 additions & 7 deletions admin/roles/override.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form action="override.php" method="post">
<input type="hidden" name="contextid" value="<?php echo $contextid; ?>">
<input type="hidden" name="roleid" value="<?php echo $roleid; ?>">
<input type="hidden" name="contextid" value="<?php p($contextid) ?>">
<input type="hidden" name="roleid" value="<?php p($roleid) ?>">
<?php
if ($userid) {
print ('<input type="hidden" name="userid" value="'.$userid.'"/>');
Expand Down Expand Up @@ -61,28 +61,28 @@
<input type="radio" name="<?php echo $capability->name; ?>" value="0"
<?php
if ($localpermission == 0) {echo 'checked="checked"';}
if ($isdisabled) {echo 'disabled="disabled"';}?>>
if ($isdisabled) {echo 'disabled="disabled"';}?> />
</td>

<td align="center" <?php if ($isallow) {echo 'class="capcurrent"';} ?>>
<input type="radio" name="<?php echo $capability->name; ?>"
<?php echo ' value="'.CAP_ALLOW.'"';
if ($localpermission == CAP_ALLOW) {echo ' checked="checked"';}
if ($isdisabled) {echo ' disabled="disabled"';}?>>
if ($isdisabled) {echo ' disabled="disabled"';}?> />
</td>

<td align="center" <?php if ($isprevent) {echo 'class="capcurrent"';} ?>>
<input type="radio" name="<?php echo $capability->name; ?>"
<?php echo ' value="'.CAP_PREVENT.'"';
if ($localpermission == CAP_PREVENT) {echo ' checked="checked"';}
if ($isdisabled) {echo ' disabled="disabled"';}?>>
if ($isdisabled) {echo ' disabled="disabled"';}?> />
</td>

<td align="center" <?php if ($isprohibit) {echo 'class="capcurrent"';} ?>>
<input type="radio" name="<?php echo $capability->name; ?>"
<?php echo ' value="'.CAP_PROHIBIT.'"';
if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked"';}
if ($isdisabled) {echo ' disabled="disabled"';}?>>
if ($isdisabled) {echo ' disabled="disabled"';}?> />
</td>
<td><?php
if (RISK_MANAGETRUST & (int)$capability->riskbitmask) {
Expand All @@ -106,5 +106,5 @@
<?php } ?>
</table>
<br />
<div align="center"><input type="submit" value="<?php print_string('savechanges') ?>"></div>
<div align="center"><input type="submit" value="<?php print_string('savechanges') ?>" /></div>
</form>
4 changes: 2 additions & 2 deletions admin/roles/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
echo '<input type="hidden" name="courseid" value="'.$courseid.'" />';
}
echo '<input type="hidden" name="contextid" value="'.$context->id.'" />'.$strroletooverride.': ';
choose_from_menu ($overridableroles, 'roleid', $roleid, 'choose', $script='rolesform.submit()');
choose_from_menu ($overridableroles, 'roleid', $roleid, get_string('listallroles', 'role'), $script='rolesform.submit()');
echo '</div></form>';

$r_caps = role_context_capabilities($roleid, $context);
Expand All @@ -145,7 +145,7 @@
print_simple_box_end();
} else {
notice(get_string('nocapabilitiesincontext', 'role'),
$CFG->wwwroot.'/admin/roles/override.php?contextid='.$contextid);
$CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$contextid);
}

} else { // Print overview table
Expand Down
2 changes: 1 addition & 1 deletion course/groups-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
</form>
<form name="rolesform1" action="groups.php" method="get">
<input type="hidden" name="id" value="<?php echo $courseid ?>">
<div align="center"><?php echo get_string('selectrole') ?>:
<div align="center"><?php echo get_string('selectrole', 'role') ?>:
<?php choose_from_menu ($roleoptions, 'roleid', $roleid, 'choose', $script='rolesform1.submit()') ?>
</div></form>
</td>
Expand Down
1 change: 0 additions & 1 deletion lang/en_utf8/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,6 @@
$string['selectamodule'] = 'Please select an activity module';
$string['selectednowmove'] = '$a files selected for moving. Now go to the destination and press \'Move files to here\'';
$string['selectnos'] = 'Select all \'no\'';
$string['selectrole'] = 'Select a Role';
$string['senddetails'] = 'Send my details via email';
$string['separateandconnected'] = 'Separate and Connected ways of knowing';
$string['serverlocaltime'] = 'Server\'s local time';
Expand Down
8 changes: 7 additions & 1 deletion lang/en_utf8/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$string['defineroles'] = 'Define roles';
$string['existingusers'] = '$a existing users';
$string['inherit'] = 'Inherit';
$string['listallroles'] = 'List all roles...';
$string['manageroles'] = 'Manage roles';
$string['nocapabilitiesincontext'] = 'No capabilities available in this context';
$string['overrideroles'] = 'Override roles';
Expand All @@ -21,9 +22,14 @@
$string['potentialusers'] = '$a potential users';
$string['prevent'] = 'Prevent';
$string['prohibit'] = 'Prohibit';
$string['risks'] = 'Risks';
$string['roledescription'] = 'Role description';
$string['rolename'] = 'Role name';
$string['roleshortname'] = 'Role short name (ASCII)';
$string['roletoassign'] = 'Role to assign';
$string['roletooverride'] = 'Role to override';
$string['roles'] = 'Roles';
$string['selectrole'] = 'Select a role';

$string['site:doanything'] = 'Allowed to do everything';
$string['legacy:guest'] = 'LEGACY ROLE: Guest';
Expand All @@ -39,7 +45,7 @@
$string['site:manageblocks'] = 'Manage site-level blocks';
$string['site:accessallgroups'] = 'Access all groups';
$string['site:viewfullnames'] = 'Always see full names of users';
$string['site:trustcontent'] = 'Trust content is safe';
$string['site:trustcontent'] = 'Trust submitted content';
$string['site:doclinks'] = 'Show links to offsite docs';
$string['site:viewreports'] = 'View reports';
$string['user:create'] = 'Create users';
Expand Down

0 comments on commit 681729b

Please sign in to comment.