]> git.mjollnir.org Git - moodle.git/commitdiff
Tidied up the role assignment pages
authormoodler <moodler>
Thu, 14 Sep 2006 14:49:45 +0000 (14:49 +0000)
committermoodler <moodler>
Thu, 14 Sep 2006 14:49:45 +0000 (14:49 +0000)
admin/roles/allowassign.php
admin/roles/allowoverride.php
admin/roles/manage.php
admin/roles/managetabs.php
lang/en_utf8/admin.php
lang/en_utf8/role.php
theme/standard/styles_layout.css

index 4e7ccaf9d49876adce22eb44ac5af32f862bce45..ebdeca7a7f2d0ae4390ccb83f8f85ad9618d7ca1 100755 (executable)
     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);
 
     }
 /// displaying form here
 
-    print_header("$site->shortname: $strmanageroles", 
-                 "$site->fullname", 
-                 "<a href=\"../index.php\">$stradministration</a> -> <a href=\"manage.php\">$strmanageroles</a>
-                 ");
-                 
+    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 '<form action="allowassign.php" method="post">';
+    echo '<form action="allowoverride.php" method="post">';
     print_table($table);
-    echo '<div align="center"><input type="submit" value="submit"/></div>';
+    echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
     echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
     echo '</form>';
+    
+    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
+?>
index f65af9b81384f0e01863680540a2da51dfb84bf6..4dcce9dab7482da3dbea7f8a86010c9763f412c2 100755 (executable)
@@ -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);
 
     }
 /// displaying form here
 
-    print_header("$site->shortname: $strmanageroles", 
-                 "$site->fullname", 
-                 "<a href=\"../index.php\">$stradministration</a> -> <a href=\"manage.php\">$strmanageroles</a>
-                 ");
+    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 '<form action="allowoverride.php" method="post">';
     print_table($table);
-    echo '<div align="center"><input type="submit" value="submit"/></div>';
+    echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
     echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
     echo '</form>';
 
-    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
+?>
index 00c1e8555cd5d212d927720a80696444c11ea428..019fe415de7847ecf29ab812347980de0503f08f 100755 (executable)
@@ -1,12 +1,11 @@
 <?php //$Id$
-///dummy field names are used to help adding and dropping indexes. There's only 1 case now, in scorm_scoes_track
-//testing
+
     require_once('../../config.php');
 
     require_once($CFG->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);
     $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", 
-//                 "<a href=\"../index.php\">$stradministration</a> -> <a href=\"manage.php\">$strmanageroles</a>
-//                 $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');
                     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);
 
                     }
 
                 }
-            
+
                 // 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 ('<form action="manage.php" method="POST">');
-                      echo ('<input type="hidden" name="action" value="delete">');
-                      echo ('<input type="hidden" name="roleid" value="'.$roleid.'">');
-                      echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
-                      echo ('<input type="hidden" name="confirm" value="1">');
-                      echo ('are you sure?');
-                      echo ('<input type="submit" value="yes">');
-                      admin_externalpage_print_footer($adminroot);
-//                      print_footer($course);
-                      exit;
-                      
-                      // prints confirmation form
+                    echo ('<form action="manage.php" method="POST">');
+                    echo ('<input type="hidden" name="action" value="delete">');
+                    echo ('<input type="hidden" name="roleid" value="'.$roleid.'">');
+                    echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
+                    echo ('<input type="hidden" name="confirm" value="1">');
+                    echo ('are you sure?');
+                    echo ('<input type="submit" value="yes">');
+                    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 ('<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></form>');
-              
+
         // 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('<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().'">delete</a>');
-      
-        }    
-          print_table($table);
-          
-          echo ('<form action="manage.php" method="POST">');
-          echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
-          echo ('<input type="hidden" name="action" value="new">');
-          echo ('<input type="submit" value="add new 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().'">delete</a>');
+
+        } 
+        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);
 ?>
index 5cb61ee097de5f27f62450d8257baabf0251c7eb..19c19c901dcd19914b1f1b2d65e5e208c033bf20 100755 (executable)
@@ -1,11 +1,11 @@
 <?php
 // this page deals with the 2 tabs for manage.php and grant.php
 
-    $toprow[] = new tabobject('manage', $CFG->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);
     
index 4d76e576594dcb2ee9b569a6328f1c1edfc054be..b23e7c9bd8ee3ea5b0083d710c672220358f3dd8 100644 (file)
@@ -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 <strong>ourcollege.edu.au .gov.au</strong>';
 $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.';
index 79cbbd19df427b8581b1bca4c29bf49065bda5a1..fba358d56af2638a9df5fe9bee6b7b33e3521c29 100644 (file)
@@ -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';
index 465c902926f38a46620ffad1c38a028f28ba7a9b..a3f5f016a00dc1415eda015d2c071c87d67935a4 100644 (file)
@@ -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
  ***/