commit f728e31e6af9d9f7995083f1b941fcc052ed9541
Author: Alan Burke <alan@cycletraffic.com>
Date:   Thu Apr 14 14:32:43 2011 +0100

    Allow users to opt out of Translation Manager emails

diff --git a/modules/contrib-patched/translation_management/icl_core/icl_core.module b/modules/contrib-patched/translation_management/icl_core/icl_core.module
index 7e5cc85..12cca2a 100644
--- a/modules/contrib-patched/translation_management/icl_core/icl_core.module
+++ b/modules/contrib-patched/translation_management/icl_core/icl_core.module
@@ -1686,3 +1686,46 @@ function icl_core_ignore_url_submit($form, &$form_state) {
   variable_set('icl_current_url_ignore', $icl_url_ignore);
   _icl_wrapper_drupal_goto($_GET['q']);
 }
+
+/**
+ * Implementation of hook_user().
+ */
+function icl_core_user($type, $edit, &$user, $category = NULL) {
+  switch ($type) {
+    case 'form':
+      if ((user_access('can do translation jobs'))&& $category == 'account') {
+        $form['icl_core'] = array(
+          '#type'        => 'fieldset',
+          '#title'       => t('Translation Manager settings'),
+          '#weight'      => 5,
+          '#collapsible' => TRUE,
+        );
+        $form['icl_core']['icl_send'] = array(
+          '#type' => 'radios',
+          '#title' => t('Receive Translation Manager notifications'),
+          '#options' => array(
+                          '1' => t('Receive notifications'),
+                          '0' => t('Do not receive notifications')
+                        ),
+          '#default_value' => icl_core_user_setting($user),
+        );
+        return $form;
+      }
+      break;
+  }
+}
+/**
+ * Gets a user setting, defaults to default system setting
+ * 
+ * @param $account
+ *   Optional user account, will default to current user
+ */
+function icl_core_user_setting($account = NULL) {
+  global $user;
+  $account = $account ? $account : $user;
+  if (isset($account->icl_send)) {
+    return $account->icl_send;
+  } else {
+    return 1;
+  }
+}
diff --git a/modules/contrib-patched/translation_management/icl_translate/icl_translate.notifications.inc b/modules/contrib-patched/translation_management/icl_translate/icl_translate.notifications.inc
index 5a83218..c2347bb 100644
--- a/modules/contrib-patched/translation_management/icl_translate/icl_translate.notifications.inc
+++ b/modules/contrib-patched/translation_management/icl_translate/icl_translate.notifications.inc
@@ -194,7 +194,7 @@ function _icl_translate_notify($uid, $key, $rid = 0, $from = '', $to = '') {
     $account = user_load($uid);
   }
   
-  if ($account) {
+  if ($account && !$account->icl_send == 0) {
     $params['account'] = $account;
     $params['rid'] = $rid;
     $params['from'] = $from;
@@ -256,10 +256,12 @@ function _icl_translate_notify_daily_digest_process($time = 86400) {
     $params['account'] = $account;
     // Store all messages in $params
     $params['messages'] = $messages;
-    $result = drupal_mail('icl_translate', 'daily_digest', $account->mail, user_preferred_language($account), $params);
-    // If sent update statuses of all messages
-    if ($result['result']) {
-      _icl_translate_notification_dismiss(array_keys($messages), ICL_NOTIFICATIONS_MAIL_SENT);
+    if(!$account->icl_send == 0){
+      $result = drupal_mail('icl_translate', 'daily_digest', $account->mail, user_preferred_language($account), $params);
+      // If sent update statuses of all messages
+      if ($result['result']) {
+        _icl_translate_notification_dismiss(array_keys($messages), ICL_NOTIFICATIONS_MAIL_SENT);
+      }
     }
   }
   variable_set('icl_notifications_daily_processed', time());
@@ -429,9 +431,11 @@ function _icl_translate_notify_first_available($key, $rid, $from, $to) {
       $params['rid'] = $rid;
       $params['from'] = $from;
       $params['to'] = $to;
-      $result = drupal_mail('icl_translate', $key, $account->mail, user_preferred_language($account), $params);
-      if ($result['result']) {
-        drupal_set_message(t('Notification sent to %name (%mail)', array('%name' => $account->name, '%mail'=> $account->mail)));
+      if(!$account->icl_send == 0){
+        $result = drupal_mail('icl_translate', $key, $account->mail, user_preferred_language($account), $params);
+        if ($result['result']) {
+          drupal_set_message(t('Notification sent to %name (%mail)', array('%name' => $account->name, '%mail'=> $account->mail)));
+        }
       }
       else {
         drupal_set_message(t('Error occurred while notifying %name (%mail)', array('%name' => $account->name, '%mail'=> $account->mail)), 'error');
