? subuser.use_policy.patch
Index: sharedemail.api.php
===================================================================
RCS file: sharedemail.api.php
diff -N sharedemail.api.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sharedemail.api.php	28 Aug 2010 06:21:09 -0000
@@ -0,0 +1,22 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ *  Definition of API functions for Sharedemail module.
+ */
+
+/**
+ * Implementation of hook_sharedemail_policy_info().
+ *
+ * @param $account
+ *  The user account which is going to be allowed or denied the ability to use
+ *  an existing email address.
+ * @return
+ *  Boolean. FALSE to deny shared email, TRUE to allow it.
+ */
+function hook_sharedemail_policy_info($account) {
+  // In this example, we limit shared emails to accounts without user
+  // administration permission.
+  return !user_perm('administer users', $account);
+}
Index: sharedemail.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sharedemail/sharedemail.module,v
retrieving revision 1.1.2.2.2.6
diff -u -p -r1.1.2.2.2.6 sharedemail.module
--- sharedemail.module	23 Jun 2009 18:54:08 -0000	1.1.2.2.2.6
+++ sharedemail.module	28 Aug 2010 06:21:10 -0000
@@ -75,7 +75,7 @@ function sharedemail_user($type, &$edit,
   switch ($type) {
     case 'validate':
       // If no problems with validation, do nothing
-      if (user_validate_mail($mail)) {
+      if (user_validate_mail($mail) || !sharedemail_valid_account($user)) {
         return;
       }
 
@@ -116,6 +116,27 @@ function sharedemail_user($type, &$edit,
 }
 
 /**
+ * Identify if the account is allowed to use an existing email address.
+ *
+ * @param $account
+ *  The user account being created or updated.
+ * @return
+ *  Boolean. TRUE to allow sharedemail, FALSE to deny it.
+ */
+function sharedemail_valid_account($account = NULL) {
+  if ($account == NULL) {
+    $account = $GLOBALS['user'];
+  }
+  $policies = module_invoke_all('sharedemail_policy_info', $account);
+  foreach ($policies as $policy) {
+    if ($policy === FALSE) {
+      return FALSE;
+    }
+  }
+  return TRUE;
+}
+
+/**
  *  Implementation of hook_simpletest().
  */
 function sharedemail_simpletest() {
