Index: domain.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.admin.inc,v
retrieving revision 1.41
diff -u -p -r1.41 domain.admin.inc
--- domain.admin.inc   1 Nov 2009 18:20:19 -0000   1.41
+++ domain.admin.inc   17 Dec 2009 17:42:16 -0000
@@ -17,8 +17,16 @@
  */
 function domain_view() {
   global $_domain;
-  $output = t('<p>The following domains have been created for your site.  The currently active domain <b>is shown in boldface</b>.  You
+  // Output appropriate message, depending on permission
+  if (user_access('administer own domains') && !user_access('administer domains')) {
+    $output = t('<p>You have administrative access to the following domains.  The currently active domain <b>is shown in boldface</b>.  You
+                    may click on a domain to change the currently active domain.');
+  }
+  else {
+    $output = t('<p>The following domains have been created for your site.  The currently active domain <b>is shown in boldface</b>.  You
                     may click on a domain to change the currently active domain.  Your default domain has an ID of zero (0).</p>');
+  }
+
   $header = array(
     array('data' => t('Id'), 'field' => 'd.domain_id'),
     array('data' => t('Domain'), 'field' => 'd.subdomain'),
@@ -36,14 +44,28 @@ function domain_view() {
   $actions = array();
   // Get any select sql from other modules.
   $select = module_invoke_all('domainview', 'select');
-  $select_sql = '';
+  // Add {domain_editor}, if needed
+  if (user_access('administer own domains') && !user_access('administer domains')) {
+    $select_sql = ', de.*';
+  }
+  else {
+    $select_sql = '';
+  }
+
   if (!empty($select)) {
-    $select_sql = ', '. implode(', ', $select);
+    $select_sql = $select_sql .', '. implode(', ', $select);
     $select_sql = rtrim($select_sql, ',');
   }
 
   // Get any tablesort sql from other modules.
   $join = module_invoke_all('domainview', 'join');
+
+  // Filter by own domains, if needed
+  if (user_access('administer own domains') && !user_access('administer domains')) {
+    global $user;
+    $join[] = ' LEFT JOIN {domain_editor} de ON d.domain_id = de.domain_id WHERE uid = '. $user->uid .' AND d.domain_id != 0';
+  }
+
   $join_sql = '';
   if (!empty($join)) {
     $join_sql = ' '. implode(' ', $join);
@@ -74,7 +96,10 @@ function domain_view() {
     else {
       $actions = array();
       $actions[] = l(t('edit'), 'admin/build/domain/edit/'. $domain['domain_id']);
-      $actions[] = l(t('delete'), 'admin/build/domain/delete/'. $domain['domain_id']);
+      // Only show 'delete' link for 'administer domains' permission
+      if (user_access('administer domains')) {
+        $actions[] = l(t('delete'), 'admin/build/domain/delete/'. $domain['domain_id']);
+      }
     }
       // Add advanced settings from other modules.
       $items = array();
Index: domain.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.module,v
retrieving revision 1.137
diff -u -p -r1.137 domain.module
--- domain.module   8 Dec 2009 16:59:03 -0000   1.137
+++ domain.module   18 Dec 2009 16:02:54 -0000
@@ -119,14 +119,14 @@ function domain_menu() {
   $admin = user_access('administer domains');
   $items['admin/build/domain'] = array(
     'title' => 'Domains',
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_admin_access',
     'page callback' => 'domain_view',
     'file' => 'domain.admin.inc',
     'description' => 'Settings for the Domain Access module.',
   );
   $items['admin/build/domain/view'] = array(
     'title' => 'Domain list',
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_admin_access',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'page callback' => 'domain_view',
     'file' => 'domain.admin.inc',
@@ -193,10 +193,11 @@ function domain_menu() {
   );
   $items['admin/build/domain/edit/%domain'] = array(
     'title' => 'Edit domain record',
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_admin_access',
+    'access arguments' => array(4),
     'type' => MENU_CALLBACK,
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('domain_form', 4),
+    'page arguments' => array('domain_form', 4, array('ignore_domain_status_check' => TRUE)),
     'file' => 'domain.admin.inc',
   );
   $items['admin/build/domain/delete/%domain'] = array(
@@ -217,6 +218,7 @@ function domain_perm() {
   $perms = array(
     'access inactive domains',
     'administer domains',
+    'administer own domains',
     'assign domain editors',
     'delete domain nodes',
     'edit domain nodes',
@@ -2357,3 +2359,44 @@ function domain_db_rewrite_sql($query, $
   );
   return $return;
 }
+/**
+ * Access callback to allow multiple permissions to access domain_view() and domain sub-module functions
+ *
+ * @param $domain
+ *   An array containing the record from the {domain} table, passed from the menu item path.
+ 
+ * @return
+ *   TRUE if user has:
+ *     -'administer domains' permission; OR
+ *     -if user has 'administer own domains' permissions, AND either:
+ *       -no $domain was passed from the menu (i.e., /admin/build/domain), OR
+ *       -the user is an editor for $domain.
+ */
+function domain_admin_access($domain = NULL) {
+  return user_access('administer domains') || 
+  (user_access('administer own domains') &&
+  (!isset($domain) || domain_is_own_domain($domain)));
+}
+
+/**
+ * Function to check if a domain is among the domains of which the current user is an editor
+ * 
+ * @param $domain
+ *   An array containing the record from the {domain} table, passed from the menu item path.
+ *
+ * @return
+ *   TRUE if the current user is an assigned editor of the domain passed by $domain, excluding domain 0.
+ */
+function domain_is_own_domain($domain = array()) {
+  global $user;
+  $own_domains = domain_get_user_domains($user);
+  // Exclude primary domain
+  if (!($domain['domain_id'] > 0)) {
+    return FALSE;
+  }
+  foreach ($own_domains as $own_domain) {
+    if ($own_domain['domain_id'] == $domain['domain_id']) {
+      return TRUE;
+    };
+  }
+}
Index: domain_alias/domain_alias.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_alias/domain_alias.module,v
retrieving revision 1.17
diff -u -p -r1.17 domain_alias.module
--- domain_alias/domain_alias.module   24 Oct 2009 16:18:52 -0000   1.17
+++ domain_alias/domain_alias.module   18 Dec 2009 16:36:58 -0000
@@ -75,7 +75,8 @@ function domain_alias_menu() {
   $items = array();
   $items['admin/build/domain/alias/%domain'] = array(
     'title' => 'Edit domain aliases',
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_alias_access',
+    'access arguments' => array(4),
     'type' => MENU_CALLBACK,
     'page callback' => 'domain_alias',
     'page arguments' => array(4),
@@ -85,6 +86,33 @@ function domain_alias_menu() {
 }
 
 /**
+ * Implement hook_perm()
+ */
+function domain_alias_perm() {
+  $perms = array(
+    'configure domain aliases',
+  );
+  return $perms;
+}
+
+/**
+ * Access callback to check multiple permissions for configuration functions
+ *
+ * @param $domain
+ *   An array containing the record from the {domain} table, passed from the
+ *   menu item path.
+ 
+ * @return
+ *   TRUE if user has:
+ *     -'configure domain aliases' permission, AND
+       -domain_admin_access($domain) returns TRUE.
+ */
+
+function domain_alias_access($domain = NULL) {
+  return user_access('configure domain aliases') && domain_admin_access($domain);
+}
+
+/**
  * Implement hook_theme().
  */
 function domain_alias_theme() {
@@ -314,30 +342,32 @@ function domain_alias_domainupdate($op, 
  * Implement hook_domainview().
  */
 function domain_alias_domainview($op, $domain = array()) {
-  switch ($op) {
-    case 'header':
-      return array(array('data' => t('Aliases')));
-      break;
-    case 'data':
-      if (empty($domain)) {
-        return;
-      }
-      $aliases = domain_alias_list($domain['domain_id']);
-      $pieces = array();
-      foreach ($aliases as $alias) {
-        if (strpos($alias['pattern'], '*') === FALSE) {
-          $link = str_replace($domain['subdomain'], $domain['aliases'][$alias['alias_id']]['pattern'], domain_get_uri($domain));
-          $pieces[] = ' - '. l($alias['pattern'], $link, array('absolute' => TRUE));
+  if (user_access('configure domain aliases')) {
+    switch ($op) {
+      case 'header':
+        return array(array('data' => t('Aliases')));
+        break;
+      case 'data':
+        if (empty($domain)) {
+          return;
         }
-        else {
-          $pieces[] = ' - '. $alias['pattern'];
+        $aliases = domain_alias_list($domain['domain_id']);
+        $pieces = array();
+        foreach ($aliases as $alias) {
+          if (strpos($alias['pattern'], '*') === FALSE) {
+            $link = str_replace($domain['subdomain'], $domain['aliases'][$alias['alias_id']]['pattern'], domain_get_uri($domain));
+            $pieces[] = ' - '. l($alias['pattern'], $link, array('absolute' => TRUE));
+          }
+          else {
+            $pieces[] = ' - '. $alias['pattern'];
+          }
         }
-      }
-      $linktext = empty($pieces) ? 'add alias' : 'edit aliases';
-      $action[] = l($linktext, 'admin/build/domain/alias/'. $domain['domain_id']);
-      $pieces = array_merge($action, $pieces);
-      return implode('<br /> ', $pieces);
-      break;
+        $linktext = empty($pieces) ? 'add alias' : 'edit aliases';
+        $action[] = l($linktext, 'admin/build/domain/alias/'. $domain['domain_id']);
+        $pieces = array_merge($action, $pieces);
+        return implode('<br /> ', $pieces);
+        break;
+    }
   }
 }
 
@@ -345,11 +375,14 @@ function domain_alias_domainview($op, $d
  * Implement hook_domainlinks()
  */
 function domain_alias_domainlinks($domain) {
-  $links[] = array(
-    'title' => t('aliases'),
-    'path' => 'admin/build/domain/alias/'. $domain['domain_id']
-  );
-  return $links;
+  if (user_access('configure domain aliases')) {
+    $links[] = array(
+      'title' => t('aliases'),
+      'path' => 'admin/build/domain/alias/'. $domain['domain_id']
+    );
+    return $links;
+  }
+  return FALSE;
 }
 
 /**
Index: domain_conf/domain_conf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_conf/domain_conf.module,v
retrieving revision 1.53
diff -u -p -r1.53 domain_conf.module
--- domain_conf/domain_conf.module   1 Nov 2009 18:20:19 -0000   1.53
+++ domain_conf/domain_conf.module   18 Dec 2009 16:30:50 -0000
@@ -79,7 +79,8 @@ function domain_conf_menu() {
   $items['admin/build/domain/conf/%domain'] = array(
     'title' => 'Domain site settings',
     'type' => MENU_CALLBACK,
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_conf_access',
+    'access arguments' => array(4),
     'page callback' => 'domain_conf_page',
     'page arguments' => array(4),
     'file' => 'domain_conf.admin.inc',
@@ -87,7 +88,8 @@ function domain_conf_menu() {
   $items['admin/build/domain/conf-reset/%domain'] = array(
     'title' => 'Domain site settings',
     'type' => MENU_CALLBACK,
-    'access arguments' => array('administer domains'),
+    'access callback' => 'domain_conf_access',
+    'access arguments' => array(4),
     'page callback' => 'domain_conf_reset',
     'page arguments' => array(4),
     'file' => 'domain_conf.admin.inc',
@@ -96,6 +98,33 @@ function domain_conf_menu() {
 }
 
 /**
+ * Implement hook_perm()
+ */
+function domain_conf_perm() {
+  $perms = array(
+    'configure domain settings',
+  );
+  return $perms;
+}
+
+/**
+ * Access callback to check multiple permissions for configuration functions
+ *
+ * @param $domain
+ *   An array containing the record from the {domain} table, passed from the
+ *   menu item path.
+ 
+ * @return
+ *   TRUE if user has:
+ *     -'configure domains' permission, AND
+       -domain_admin_access($domain) returns TRUE.
+ */
+
+function domain_conf_access($domain = NULL) {
+  return user_access('configure domain settings') && domain_admin_access($domain);
+}
+
+/**
  * Implement hook_theme()
  */
 function domain_conf_theme() {
@@ -132,7 +161,7 @@ function domain_conf_domainlinks($domain
   if (!isset($extra)) {
     $extra = domain_conf_api();
   }
-  if ($domain['domain_id'] > 0 || !empty($extra)) {
+  if (($domain['domain_id'] > 0 || !empty($extra)) && user_access('configure domain settings')) {
     $links[] = array(
       'title' => t('settings'),
       'path' => 'admin/build/domain/conf/'. $domain['domain_id']
Index: domain_content/domain_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_content/domain_content.module,v
retrieving revision 1.30
diff -u -p -r1.30 domain_content.module
--- domain_content/domain_content.module   31 Oct 2009 19:29:50 -0000   1.30
+++ domain_content/domain_content.module   18 Dec 2009 17:02:52 -0000
@@ -191,10 +191,12 @@ function domain_content_form_alter(&$for
  * Implement hook_domainlinks()
  */
 function domain_content_domainlinks($domain) {
-  $links[] = array(
-    'title' => t('content'),
-    'path' => 'admin/domain/content/'. $domain['domain_id']
-  );
+  if (user_access('configure domain content')) {
+    $links[] = array(
+      'title' => t('content'),
+      'path' => 'admin/domain/content/'. $domain['domain_id']
+    );
+  }
   return $links;
 
 }

