From 6ed89094d5aefd80663e892ee159b32ef529743d Mon Sep 17 00:00:00 2001
From: Thomas Bosviel <thomas@bosviel.org>
Date: Thu, 17 Mar 2011 20:33:37 +0100
Subject: [PATCH] Issue #1096498 by tbosviel: Give access to all sites, tasks and clients for role with specific administer permissions.

---
 modules/hosting/client/hosting_client.access.inc |    4 +++-
 modules/hosting/site/hosting_site.form.inc       |    2 +-
 modules/hosting/site/hosting_site.module         |    2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/hosting/client/hosting_client.access.inc b/modules/hosting/client/hosting_client.access.inc
index 5b06130..455f840 100644
--- a/modules/hosting/client/hosting_client.access.inc
+++ b/modules/hosting/client/hosting_client.access.inc
@@ -160,7 +160,9 @@ function hosting_node_grants($account, $op) {
   $account->client_id = hosting_get_client_from_user($account->uid);
   $types = array_merge(hosting_feature_node_types(), array('site', 'task', 'package', 'client')); 
   foreach ($types as $type) {
-    if (user_access("$op $type")) {
+    if (user_access("administer {$type}s")) {
+      $grants["hosting {$type}"] = array(1);
+    } else if (user_access("$op $type")) {
       // TODO: restrict access to certain op-type based on the user relationship to this client - see content of $client_relations
       $grants['hosting ' . $type] = array_keys($account->client_id); 
     }
diff --git a/modules/hosting/site/hosting_site.form.inc b/modules/hosting/site/hosting_site.form.inc
index 5ba7e54..b510c2d 100644
--- a/modules/hosting/site/hosting_site.form.inc
+++ b/modules/hosting/site/hosting_site.form.inc
@@ -196,7 +196,7 @@ function hosting_site_form($node) {
       '#weight' => -10
     ));
 
-  $editable = ((!$node->client || $node->nid) || user_access('administer site')) && hosting_feature('client');
+  $editable = ((!$node->client || $node->nid) || user_access('administer sites')) && hosting_feature('client');
   _hosting_site_field($form, $node, 'client', array(
     '#type' => 'textfield',
     '#required' => TRUE,
diff --git a/modules/hosting/site/hosting_site.module b/modules/hosting/site/hosting_site.module
index 58abbbc..5f666c6 100644
--- a/modules/hosting/site/hosting_site.module
+++ b/modules/hosting/site/hosting_site.module
@@ -244,7 +244,7 @@ function hosting_site_hosting_tasks() {
  * Implementation of hook_perm
  */
 function hosting_site_perm() {
-  return array('create site', 'view site', 'edit site', 'delete site', 'administer site');
+  return array('create site', 'view site', 'edit site', 'delete site', 'administer sites');
 }
 
 /**
-- 
1.7.0.4

