From a2438e6d48a367b1a904361f47a56dd210b939a5 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Mon, 4 Oct 2010 21:04:26 +0000
Subject: [PATCH] Instead of giving administrator user all permissions, now
 we're copying the permissions from the root site.

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@222 20a16fea-79d4-4915-8869-1ea9d5ebf173
---
 profiles/unl_profile/unl_profile.install | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/profiles/unl_profile/unl_profile.install b/profiles/unl_profile/unl_profile.install
index 0f19b82f..470d5ae1 100644
--- a/profiles/unl_profile/unl_profile.install
+++ b/profiles/unl_profile/unl_profile.install
@@ -207,6 +207,7 @@ EOF;
     // Update the settings file to use shared database tables (unless this is the default site)
     if (conf_path() != 'sites/default') {
         $shared_prefix = unl_profile_get_default_site_db_prefix();
+        $new_prefix = $GLOBALS['databases']['default']['default']['prefix'];
         $settings['databases'] = array(
             'value'    => $GLOBALS['databases'],
             'required' => TRUE
@@ -214,7 +215,7 @@ EOF;
         $settings['databases']['value']['default']['default']['prefix'] = array(
 
             // Localized tables, prefixed with site name
-            'default'       => $GLOBALS['databases']['default']['default']['prefix'],
+            'default'       => $new_prefix,
 
             // shared tables across all sites
             'authmap'       => $shared_prefix,
@@ -240,12 +241,10 @@ EOF;
         // Only enable CAS on subsites until we get some sort of bootstrap setup.
         module_enable(array('unl_cas'));
         
-        // If the administrator role has changed from the default ID, be sure to grant the new ID all permissions.
-        $results = db_query("SELECT rid FROM ${shared_prefix}role WHERE name LIKE 'administrator'")->fetchCol();
-        if (isset($results[0]) && $results[0] != 3) {
-            user_role_grant_permissions($results[0], array_keys(module_invoke_all('permission')));
-            variable_set('user_admin_role', $results[0]);
-        }
+        // Copy permissions from the parent site to the new site.
+        db_query("TRUNCATE ${new_prefix}role_permission")->execute();
+        // I'm using REPLACE because I keep getting duplicate entry errors, despite inserting into what should be an empty table.
+        db_query("REPLACE INTO ${new_prefix}role_permission (rid, permission, module) SELECT rid, permission, module FROM ${shared_prefix}role_permission")->execute();
     }
     
     
-- 
GitLab