--- coherent_access.module.bak	2008-10-29 17:45:26.000000000 +0100
+++ coherent_access.module	2008-10-30 10:52:38.000000000 +0100
@@ -145,13 +145,13 @@
   $form['coherent_access_subject'] = array(
     '#type' => 'textarea',
     '#title' => t('Email notification subject'),
-    '#default_value' => variable_get('coherent_access_subject', 'You have been added as a %role  for %nodetitle by %sender'),
+    '#default_value' => variable_get('coherent_access_subject', 'You have been added as a %role for %nodetitle by %sender'),
   );
   
   $form['coherent_access_body'] = array(
     '#type' => 'textarea',
     '#title' => t('Email notification body'),
-    '#default_value' => variable_get('coherent_access_body', 'You have been added as a %role for %nodetitle by %sender. You can access this by going to %nodeurl'),
+    '#default_value' => variable_get('coherent_access_body', 'Dear %recipient, You have been added as a %role for %nodetitle by %sender. You can access this by going to %nodeurl'),
   );
 
   return system_settings_form($form);
@@ -466,7 +466,7 @@
         $inserts = array();
         if (!empty($editors)) {
           foreach ($editors as $uid => $username) {
-            $inserts[$uid] = COHERENT_ACCESS_VIEW | COHERENT_ACCESS_EDIT;
+            $inserts[$uid] = COHERENT_ACCESS_EDIT;
           }
         }
         if (!empty($viewers)) {
@@ -495,15 +495,14 @@
           foreach ($inserts as $uid => $mode) {
             if (empty($existing) || !array_key_exists($uid, $existing)) {
               $params['recipient'] = user_load(array('uid' => $uid));
-              if ($mode == COHERENT_ACCESS_EDIT | COHERENT_ACCESS_VIEW) {
+              if ($mode == COHERENT_ACCESS_EDIT) {
                 $params['role'] = 'editor';
               }
               else {
                 $params['role'] = 'viewer';
               }
               $mailkey = 'coherent_access'. $node->nid .'_'. $uid;
-              coherent_access_mail($key, $message, $params);
-              drupal_mail($mailkey, $params['recipient']->mail, $message['subject'], $message['body']);
+              drupal_mail('coherent_access', $mailkey, $params['recipient']->mail, user_preferred_language($params['recipient']), $params, $params['sender']->name);
             }
           }
         }
@@ -678,7 +677,7 @@
   $node = $params['node'];
   
   $subject = variable_get('coherent_access_subject', 'You have been added as a %role for %nodetitle by %sender. You can access this by going to %nodeurl');
-  $body = variable_get('coherent_access_body', 'You have been added as a %role for %nodetitle by %sender. You can access this by going to %nodeurl');
+  $body = variable_get('coherent_access_body', 'Dear %recipient, You have been added as a %role for %nodetitle by %sender. You can access this by going to %nodeurl');
   
   $urlpath = 'node/'. $node->nid;
   
