[Svn] r2450 - in trunk/roundcubemail/program/steps: addressbook mail

trac at roundcube.net trac at roundcube.net
Mon May 4 08:53:56 CEST 2009


Author: alec
Date: 2009-05-04 01:53:56 -0500 (Mon, 04 May 2009)
New Revision: 2450

Modified:
   trunk/roundcubemail/program/steps/addressbook/copy.inc
   trunk/roundcubemail/program/steps/addressbook/import.inc
   trunk/roundcubemail/program/steps/mail/addcontact.inc
Log:
- more addressbooks hooks (#1485829)


Modified: trunk/roundcubemail/program/steps/addressbook/copy.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/copy.inc	2009-05-02 20:11:45 UTC (rev 2449)
+++ trunk/roundcubemail/program/steps/addressbook/copy.inc	2009-05-04 06:53:56 UTC (rev 2450)
@@ -26,9 +26,14 @@
   $success = false;
   $TARGET = $RCMAIL->get_address_book($target);
 
-  if ($TARGET && $TARGET->ready && !$TARGET->readonly)
-    $success = $TARGET->insert($CONTACTS->search($CONTACTS->primary_key, $cid), true);
+  if ($TARGET && $TARGET->ready && !$TARGET->readonly) {
+    $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $CONTACTS->search($CONTACTS->primary_key, $cid), 'source' => $target));
+    $a_record = $plugin['record'];
 
+    if (!$plugin['abort'])
+      $success = $TARGET->insert($CONTACTS->search($a_record, true);
+  }
+
   if (empty($success))
     $OUTPUT->show_message('copyerror', 'error');
   else
@@ -41,4 +46,4 @@
 // send response
 $OUTPUT->send();
 
-?>
\ No newline at end of file
+?>

Modified: trunk/roundcubemail/program/steps/addressbook/import.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/import.inc	2009-05-02 20:11:45 UTC (rev 2449)
+++ trunk/roundcubemail/program/steps/addressbook/import.inc	2009-05-04 06:53:56 UTC (rev 2450)
@@ -75,18 +75,18 @@
 {
   global $IMPORT_STATS, $OUTPUT;
   
-  $attrib += array('type' => "input");
+  $attrib += array('type' => 'input');
   unset($attrib['name']);
   
   if (is_object($IMPORT_STATS)) {
     $attrib['class'] = trim($attrib['class'] . ' mainaction');
-    $out = $OUTPUT->button(array('command' => "list", 'label' => "done") + $attrib);
+    $out = $OUTPUT->button(array('command' => 'list', 'label' => 'done') + $attrib);
   }
   else {
-    $out = $OUTPUT->button(array('command' => "list", 'label' => "cancel") + $attrib);
+    $out = $OUTPUT->button(array('command' => 'list', 'label' => 'cancel') + $attrib);
     $out .= ' ';
     $attrib['class'] = trim($attrib['class'] . ' mainaction');
-    $out .= $OUTPUT->button(array('command' => "import", 'label' => "import") + $attrib);
+    $out .= $OUTPUT->button(array('command' => 'import', 'label' => 'import') + $attrib);
   }
   
   return $out;
@@ -142,19 +142,22 @@
         }
       }
       
-      $success = $CONTACTS->insert(array(
+      $a_record = array(
         'name' => $vcard->displayname,
         'firstname' => $vcard->firstname,
         'surname' => $vcard->surname,
         'email' => $email,
         'vcard' => $vcard->export(),
-      ));
+      );
       
-      if ($success) {
+      $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $a_record, 'source' => null));
+      $a_record = $plugin['record'];
+
+      // insert record and send response
+      if (!$plugin['abort'] && ($success = $CONTACTS->insert($a_record))) {
         $IMPORT_STATS->inserted++;
         $IMPORT_STATS->names[] = $vcard->displayname;
-      }
-      else {
+      } else {
         $IMPORT_STATS->errors++;
       }
     }
@@ -165,8 +168,7 @@
 else if ($err = $_FILES['_file']['error']) {
   if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
     $OUTPUT->show_message('filesizeerror', 'error', array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize')))));
-  }
-  else {
+  } else {
     $OUTPUT->show_message('fileuploaderror', 'error');
   }
 }

Modified: trunk/roundcubemail/program/steps/mail/addcontact.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/addcontact.inc	2009-05-02 20:11:45 UTC (rev 2449)
+++ trunk/roundcubemail/program/steps/mail/addcontact.inc	2009-05-04 06:53:56 UTC (rev 2450)
@@ -43,7 +43,7 @@
       $OUTPUT->show_message('contactexists', 'warning');
     else
     {
-      $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $contact, 'source' => get_input_value('_source', RCUBE_INPUT_GPC)));
+      $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $contact, 'source' => null));
       $contact = $plugin['record'];
 
       if (!$plugin['abort'] && ($done = $CONTACTS->insert($contact)))

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list