]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11241, adding logs for roles management
authortoyomoyo <toyomoyo>
Thu, 18 Oct 2007 05:53:14 +0000 (05:53 +0000)
committertoyomoyo <toyomoyo>
Thu, 18 Oct 2007 05:53:14 +0000 (05:53 +0000)
admin/roles/assign.php
admin/roles/manage.php
admin/roles/override.php
lib/accesslib.php

index 39fdf27f17798a192951e535577c53cdff82c9dc..ddeaa054e5b12a977a7b2767d03fe8add275ce43 100755 (executable)
                     }
                 }
             }
-
+            
+            $rolename = get_field('role', 'name', 'id', $roleid);
+            add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
         } else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
 
             $sitecontext = get_context_instance(CONTEXT_SYSTEM);
                     }
                 }
             }
-
+            
+            $rolename = get_field('role', 'name', 'id', $roleid);
+            add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
         } else if ($showall) {
             $searchtext = '';
             $previoussearch = 0;
         }
+        
+        
+    
     }
 
     if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
index 2a7734125e787455baeb30bade054708f7a12398..2c5f6675ec3e3737013fe916a95d80c87e5680c5 100755 (executable)
                 mark_context_dirty($sitecontext->path);
 
                 if (empty($errors)) {
+                    $rolename = get_field('role', 'name', 'id', $newroleid);
+                    add_to_log(SITEID, 'role', 'add', 'admin/roles/manage.php?action=add', $rolename, '', $USER->id);
                     redirect('manage.php');
                 }
             }
+            
             break;
 
         case 'edit':
 
                     // edited a role sitewide...
                     mark_context_dirty($sitecontext->path);
+                    add_to_log(SITEID, 'role', 'edit', 'admin/roles/manage.php?action=edit&roleid='.$role->id, $role->name, '', $USER->id);
 
                     redirect('manage.php');
                 }
                 // edited a role sitewide - with errors, but still...
                 mark_context_dirty($sitecontext->path);
             }
+
             break;
 
         case 'delete':
                 mark_context_dirty($sitecontext->path);
 
             }
+            $rolename = get_field('role', 'name', 'id', $newrole);
+            add_to_log(SITEID, 'role', 'duplicate', 'admin/roles/manage.php?roleid='.$newrole.'&action=duplicate', $rolename, '', $USER->id);
             redirect('manage.php');
             break;
 
                 // reset a role sitewide...
                 mark_context_dirty($sitecontext->path);
 
+                $rolename = get_field('role', 'name', 'id', $roleid);
+                add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?roleid='.$roleid.'&action=reset', $rolename, '', $USER->id);
+
                 redirect('manage.php?action=view&amp;roleid='.$roleid);
 
             } else {
index e7938d8d3e44e831535805f38bff7678a1c36d1f..600895cea3643073fda9d53e16d9ffbbeb9a0b41 100755 (executable)
 
         // force accessinfo refresh for users visiting this context...
         mark_context_dirty($context->path);
-
+        $rolename = get_field('role', 'name', 'id', $roleid);
+        add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
         redirect($baseurl);
     }
 
index ef455bb38e841f42ab9d7af084ca1fa0f95196da..0073b19fb60ac1dc1b5dd17989a300b8b948ce2b 100755 (executable)
@@ -2666,10 +2666,17 @@ function delete_role($roleid) {
     }
 
 // finally delete the role itself
+    // get this before the name is gone for logging
+    $rolename = get_field('role', 'name', 'id', $roleid);
+    
     if ($success and !delete_records('role', 'id', $roleid)) {
         debugging("Could not delete role record with ID $roleid!");
         $success = false;
     }
+    
+    if ($success) {
+        add_to_log(SITEID, 'role', 'delete', 'admin/roles/action=delete&roleid='.$roleid, $rolename, '', $USER->id);
+    }
 
     return $success;
 }