From b3dc845cab9f0de01befc0f595aeda272253c31a Mon Sep 17 00:00:00 2001
From: martinlanghoff <martinlanghoff>
Date: Wed, 19 Sep 2007 07:10:37 +0000
Subject: [PATCH] admin/roles: sitewide role changes mark site context as dirty

And will force a reload of $USER->access for all logged-in users
on their next request.

We will have to tell admins of large sites to avoid making role changes
at busy times, as it does generate extra load.
---
 admin/roles/allowassign.php   |  2 ++
 admin/roles/allowoverride.php |  2 ++
 admin/roles/manage.php        | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/admin/roles/allowassign.php b/admin/roles/allowassign.php
index a17796c80f..0827a6a1b4 100755
--- a/admin/roles/allowassign.php
+++ b/admin/roles/allowassign.php
@@ -45,6 +45,8 @@
                 }
             }
         }
+        // updated allowassigns sitewide...
+        mark_context_dirty($sitecontext->path);
     }
 /// displaying form here
 
diff --git a/admin/roles/allowoverride.php b/admin/roles/allowoverride.php
index 87a4ec0473..17c28c68c6 100755
--- a/admin/roles/allowoverride.php
+++ b/admin/roles/allowoverride.php
@@ -43,6 +43,8 @@
                 }
             }
         }
+        // updated allowoverride sitewide...
+        mark_context_dirty($sitecontext->path);
     }
 /// displaying form here
 
diff --git a/admin/roles/manage.php b/admin/roles/manage.php
index 09f647fef7..2a7734125e 100755
--- a/admin/roles/manage.php
+++ b/admin/roles/manage.php
@@ -117,6 +117,9 @@
                     }
                 }
 
+                // added a role sitewide...
+                mark_context_dirty($sitecontext->path);
+
                 if (empty($errors)) {
                     redirect('manage.php');
                 }
@@ -228,8 +231,14 @@
                         } 
                     }                    
 
+                    // edited a role sitewide...
+                    mark_context_dirty($sitecontext->path);
+
                     redirect('manage.php');
                 }
+
+                // edited a role sitewide - with errors, but still...
+                mark_context_dirty($sitecontext->path);
             }
             break;
 
@@ -239,8 +248,14 @@
             }
             if ($confirm and data_submitted() and confirm_sesskey()) {
                 if (!delete_role($roleid)) {
+
+                    // partially deleted a role sitewide...?
+                    mark_context_dirty($sitecontext->path);
+
                     error('Could not delete role with ID '.$roleid);
                 }
+                // deleted a role sitewide...
+                mark_context_dirty($sitecontext->path);
 
             } else if (confirm_sesskey()){
                 // show confirmation
@@ -340,6 +355,10 @@
             if ($newrole = create_role($currentfullname, $currentshortname, $description)) {
                 // dupilcate all the capabilities
                 role_cap_duplicate($sourcerole, $newrole);
+
+                // dup'ed a role sitewide...
+                mark_context_dirty($sitecontext->path);
+
             }
             redirect('manage.php');
             break;
@@ -351,6 +370,10 @@
 
             if ($confirm and data_submitted() and confirm_sesskey()) {
                 reset_role_capabilities($roleid);
+
+                // reset a role sitewide...
+                mark_context_dirty($sitecontext->path);
+
                 redirect('manage.php?action=view&amp;roleid='.$roleid);
 
             } else {
-- 
2.39.5