From: moodler Date: Thu, 14 Sep 2006 14:49:45 +0000 (+0000) Subject: Tidied up the role assignment pages X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9584965f9c2739e185959d890d16b5190cc0650b;p=moodle.git Tidied up the role assignment pages --- diff --git a/admin/roles/allowassign.php b/admin/roles/allowassign.php index 4e7ccaf9d4..ebdeca7a7f 100755 --- a/admin/roles/allowassign.php +++ b/admin/roles/allowassign.php @@ -10,6 +10,11 @@ require_once('../../config.php'); /// check capabilities here + require_once($CFG->libdir.'/adminlib.php'); + $adminroot = admin_get_root(); + admin_externalpage_setup('defineroles', $adminroot); + + $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); require_capability('moodle/roles:manage', $sitecontext); @@ -49,45 +54,44 @@ } /// displaying form here - print_header("$site->shortname: $strmanageroles", - "$site->fullname", - "$stradministration -> $strmanageroles - "); - + admin_externalpage_print_header($adminroot); + $currenttab='allowassign'; require_once('managetabs.php'); $table->tablealign = "center"; - $table->align = array ("middle", "left"); - $table->wrap = array ("nowrap", "nowrap"); $table->cellpadding = 5; $table->cellspacing = 0; - $table->width = '40%'; + $table->width = '90%'; + $table->align[] = 'right'; /// get all the roles identifier foreach ($roles as $role) { $rolesname[] = $role->name; $roleids[] = $role->id; + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; } - $table->data[] = array_merge(array(''), $rolesname); + $table->head = array_merge(array(''), $rolesname); foreach ($roles as $role) { - $beta = get_box_list($role->id, $roleids); - $table->data[] = array_merge(array($role->name), $beta); } + + print_simple_box(get_string('configallowassign', 'admin'), 'center'); - echo '
'; + echo ''; print_table($table); - echo '
'; + echo '
'; echo ''; // this is needed otherwise we do not know a form has been submitted echo '
'; + + admin_externalpage_print_footer($adminroot); + - print_footer(); -// returns array function get_box_list($roleid, $arraylist){ foreach ($arraylist as $targetid) { @@ -99,4 +103,4 @@ function get_box_list($roleid, $arraylist){ } return $array; } -?> \ No newline at end of file +?> diff --git a/admin/roles/allowoverride.php b/admin/roles/allowoverride.php index f65af9b813..4dcce9dab7 100755 --- a/admin/roles/allowoverride.php +++ b/admin/roles/allowoverride.php @@ -8,6 +8,11 @@ require_once('../../config.php'); /// check capabilities here + require_once($CFG->libdir.'/adminlib.php'); + $adminroot = admin_get_root(); + admin_externalpage_setup('defineroles', $adminroot); + + $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); require_capability('moodle/roles:manage', $sitecontext); @@ -47,43 +52,41 @@ } /// displaying form here - print_header("$site->shortname: $strmanageroles", - "$site->fullname", - "$stradministration -> $strmanageroles - "); + admin_externalpage_print_header($adminroot); $currenttab='allowoverride'; require_once('managetabs.php'); $table->tablealign = "center"; - $table->align = array ("middle", "left"); - $table->wrap = array ("nowrap", "nowrap"); $table->cellpadding = 5; $table->cellspacing = 0; - $table->width = '40%'; + $table->width = '90%'; + $table->align[] = 'right'; /// get all the roles identifier foreach ($roles as $role) { $rolesname[] = $role->name; $roleids[] = $role->id; + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; } - $table->data[] = array_merge(array(''), $rolesname); + $table->head = array_merge(array(''), $rolesname); foreach ($roles as $role) { - $beta = get_box_list($role->id, $roleids); - $table->data[] = array_merge(array($role->name), $beta); } + + print_simple_box(get_string('configallowoverride', 'admin'), 'center'); echo '
'; print_table($table); - echo '
'; + echo '
'; echo ''; // this is needed otherwise we do not know a form has been submitted echo '
'; - print_footer(); + admin_externalpage_print_footer($adminroot); // returns array function get_box_list($roleid, $arraylist){ @@ -97,4 +100,4 @@ function get_box_list($roleid, $arraylist){ } return $array; } -?> \ No newline at end of file +?> diff --git a/admin/roles/manage.php b/admin/roles/manage.php index 00c1e8555c..019fe415de 100755 --- a/admin/roles/manage.php +++ b/admin/roles/manage.php @@ -1,12 +1,11 @@ libdir.'/adminlib.php'); $adminroot = admin_get_root(); + admin_externalpage_setup('defineroles', $adminroot); -// require_login(); $roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role $action = optional_param('action', '', PARAM_ALPHA); @@ -15,34 +14,28 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); - + $stradministration = get_string('administration'); $strmanageroles = get_string('manageroles'); if ($roleid && $action!='delete') { - $role = get_record('role', 'id', $roleid); - + $role = get_record('role', 'id', $roleid); $editingstr = '-> '.get_string('editinga', '', $role->name); } else { $editingstr =''; } - + admin_externalpage_print_header($adminroot); -// print_header("$site->shortname: $strmanageroles", -// "$site->fullname", -// "$stradministration -> $strmanageroles -// $editingstr -// "); $currenttab = 'manage'; include_once('managetabs.php'); // form processing, editing a role, adding a role or deleting a role if ($action && confirm_sesskey()) { - + switch ($action) { case 'add': - + $newrole = create_role($name, $description); $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid'); @@ -57,15 +50,15 @@ assign_capability($capname, $value, $newrole, $sitecontext->id); } - - break; - + + break; + case 'edit': - + $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid'); - + $data = data_submitted(); - + foreach ($data as $capname => $value) { if (in_array($capname, $ignore)) { continue; @@ -73,7 +66,7 @@ // edit default caps $SQL = "select * from {$CFG->prefix}role_capabilities where - roleid = $roleid and capability = '$capname' and contextid = $sitecontext->id"; + roleid = $roleid and capability = '$capname' and contextid = $sitecontext->id"; $localoverride = get_record_sql($SQL); @@ -99,112 +92,117 @@ } } - + // update normal role settings - + $role->id = $roleid; $role->name = $name; $role->description = $description; - + update_record('role', $role); - - break; - + + break; + case 'delete': if ($confirm) { // deletes a role echo ('deleting...'); - + // check for depedencies - - // delete all associated role-assignments? - delete_records('role', 'id', $roleid); - + + // delete all associated role-assignments? + delete_records('role', 'id', $roleid); + } else { - echo ('
'); - echo (''); - echo (''); - echo (''); - echo (''); - echo ('are you sure?'); - echo (''); - admin_externalpage_print_footer($adminroot); -// print_footer($course); - exit; - - // prints confirmation form + echo (''); + echo (''); + echo (''); + echo (''); + echo (''); + echo ('are you sure?'); + echo (''); + admin_externalpage_print_footer($adminroot); + // print_footer($course); + exit; + + // prints confirmation form } - - break; - - /// add possible positioning switch here - + + break; + + /// add possible positioning switch here + default: - break; - + break; + } - + } $roles = get_records('role'); if (($roleid && $action!='delete') || $action=='new') { // load the role if id is present - + if ($roleid) { - $action='edit'; - $role = get_record('role', 'id', $roleid); + $action='edit'; + $role = get_record('role', 'id', $roleid); } else { - $action='add'; + $action='add'; $role->name=''; $role->description=''; } - + foreach ($roles as $rolex) { $roleoptions[$rolex->id] = $rolex->name; } - + // prints a form to swap roles print (''); print ('
'.get_string('selectrole').': '); choose_from_menu ($roleoptions, 'roleid', $roleid, 'choose', $script='rolesform1.submit()'); print ('
'); - + // this is the array holding capabilities of this role sorted till this context $r_caps = role_context_capabilities($roleid, $sitecontext); - + // this is the available capabilities assignable in this context $capabilities = fetch_context_capabilities($sitecontext); - + print_simple_box_start(); include_once('manage.html'); print_simple_box_end(); - + } else { - - $table->tablealign = "center"; - $table->align = array ("middle", "left"); - $table->wrap = array ("nowrap", "nowrap"); + + $table = new object; + + $table->tablealign = 'center'; + $table->align = array('middle', 'left', 'left'); + $table->wrap = array('nowrap', '', 'nowrap'); $table->cellpadding = 5; $table->cellspacing = 0; - $table->width = '40%'; + $table->width = '90%'; + + $table->head = array(get_string('roles', 'role'), + get_string('description'), + get_string('delete')); + /************************* * List all current roles * **************************/ - - $table->data[] = array('roles', 'description', 'delete'); + foreach ($roles as $role) { - - $table->data[] = array(''.$role->name.'', $role->description, 'delete'); - - } - print_table($table); - - echo ('
'); - echo (''); - echo (''); - echo (''); + + $table->data[] = array(''.$role->name.'', $role->description, 'delete'); + + } + print_table($table); + + $options = new object; + $options->sesskey = sesskey(); + $options->action = 'new'; + print_single_button('manage.php', $options, get_string('addrole', 'role'), 'POST'); } - use_html_editor("description"); + use_html_editor('description'); admin_externalpage_print_footer($adminroot); -// print_footer($course); ?> diff --git a/admin/roles/managetabs.php b/admin/roles/managetabs.php index 5cb61ee097..19c19c901d 100755 --- a/admin/roles/managetabs.php +++ b/admin/roles/managetabs.php @@ -1,11 +1,11 @@ wwwroot.'/admin/roles/manage.php', get_string('manage')); + $toprow[] = new tabobject('manage', $CFG->wwwroot.'/admin/roles/manage.php', get_string('manageroles', 'role')); - $toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/admin/roles/allowassign.php', get_string('allowassign')); + $toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/admin/roles/allowassign.php', get_string('allowassign', 'role')); - $toprow[] = new tabobject('allowoverride', $CFG->wwwroot.'/admin/roles/allowoverride.php', get_string('allowoverride')); + $toprow[] = new tabobject('allowoverride', $CFG->wwwroot.'/admin/roles/allowoverride.php', get_string('allowoverride', 'role')); $tabs = array($toprow); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 4d76e57659..b23e7c9bd8 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -82,6 +82,8 @@ $string['componentinstalled'] = 'Component Installed'; $string['configallowcoursethemes'] = 'If you enable this, then courses will be allowed to set their own themes. Course themes override all other theme choices (site, user, or session themes)'; $string['configallowemailaddresses'] = 'If you want to restrict all new email addresses to particular domains, then list them here separated by spaces. All other domains will be rejected. eg ourcollege.edu.au .gov.au'; $string['configallowobjectembed'] = 'As a default security measure, normal users are not allowed to embed multimedia (like Flash) within texts using explicit EMBED and OBJECT tags in their HTML (although it can still be done safely using the mediaplugins filter). If you wish to allow these tags then enable this option.'; +$string['configallowassign'] = 'Allow the roles on the left side to assign the roles in each column'; +$string['configallowoverride'] = 'Allow the roles on the left side to override the roles in each column'; $string['configallowunenroll'] = 'If this is set \'Yes\', then students are allowed to unenroll themselves from courses whenever they like. Otherwise they are not allowed, and this process will be solely controlled by the teachers and administrators.'; $string['configallowuserblockhiding'] = 'Do you want to allow users to hide/show side blocks throughout this site? This feature uses Javascript and cookies to remember the state of each collapsible block, and only affects the user\'s own view.'; $string['configallowusermailcharset'] = 'Enabling this, every user in the site will be able to specify his own charset for email.'; diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index 79cbbd19df..fba358d56a 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -2,13 +2,17 @@ // role.php $string['assignroles'] = 'Assign roles'; +$string['addrole'] = 'Add a new role'; $string['allow'] = 'Allow'; +$string['allowassign'] = 'Allow role assignments'; +$string['allowoverride'] = 'Allow role overrides'; $string['capability'] = 'Capability'; $string['currentrole'] = 'Current role'; $string['currentcontext'] = 'Current context'; $string['defineroles'] = 'Define roles'; $string['existingusers'] = '$a existing users'; $string['inherit'] = 'Inherit'; +$string['manageroles'] = 'Manage roles'; $string['nocapabilitiesincontext'] = 'No capabilities available in this context'; $string['overrideroles'] = 'Override roles'; $string['permissions'] = 'Permissions'; @@ -16,6 +20,7 @@ $string['potentialusers'] = '$a potential users'; $string['prevent'] = 'Prevent'; $string['prohibit'] = 'Prohibit'; $string['roletoassign'] = 'Role to assign'; +$string['roles'] = 'Roles'; $string['site:doanything'] = 'Allowed to do everything'; $string['legacy:guest'] = 'LEGACY ROLE: Guest'; diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 465c902926..a3f5f016a0 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -437,6 +437,13 @@ body#admin-roles-manage table.generalbox { margin-top: 1em; } +#admin-roles-manage .singlebutton, +#admin-roles-allowoverride .singlebutton, +#admin-roles-allowassign .singlebutton { + padding: 10px; + text-align:center; +} + /*** *** Blocks ***/