[Svn] r3922 - trunk/plugins/vcard_attachments

trac at roundcube.net trac at roundcube.net
Mon Aug 30 11:52:48 CEST 2010


Author: alec
Date: 2010-08-30 04:52:48 -0500 (Mon, 30 Aug 2010)
New Revision: 3922

Modified:
   trunk/plugins/vcard_attachments/package.xml
   trunk/plugins/vcard_attachments/vcard_attachments.php
Log:
- Exec contact_create hook when adding contact via vcard_attachment (#1486964)


Modified: trunk/plugins/vcard_attachments/package.xml
===================================================================
--- trunk/plugins/vcard_attachments/package.xml	2010-08-30 09:12:57 UTC (rev 3921)
+++ trunk/plugins/vcard_attachments/package.xml	2010-08-30 09:52:48 UTC (rev 3922)
@@ -19,10 +19,10 @@
 		<email>alec at alec.pl</email>
 		<active>yes</active>
 	</lead>
-	<date>2010-04-28</date>
-	<time>12:00:00</time>
+	<date></date>
+	<time></time>
 	<version>
-		<release>2.0</release>
+		<release></release>
 		<api>2.0</api>
 	</version>
 	<stability>
@@ -31,11 +31,7 @@
 	</stability>
 	<license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license>
 	<notes>
-- Added support for Content-Type: text/directory; profile=vCard
-- Added handler for message bodies of type vCard (#1486683)
-- Added support for more than one vCard attachment/body
-- Added support for more than one contact in one vCard file
-- Created package.xml
+- Exec contact_create hook when adding contact (#1486964)
     </notes>
 	<contents>
 		<dir baseinstalldir="/" name="/">
@@ -68,4 +64,26 @@
 		</required>
 	</dependencies>
 	<phprelease/>
+	<changelog>
+	    <release>
+        	<date>2010-04-28</date>
+        	<time>12:00:00</time>
+            <version>
+        		<release>2.0</release>
+		        <api>2.0</api>
+        	</version>
+        	<stability>
+		        <release>stable</release>
+        		<api>stable</api>
+	        </stability>
+        	<license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license>
+	        <notes>
+- Added support for Content-Type: text/directory; profile=vCard
+- Added handler for message bodies of type vCard (#1486683)
+- Added support for more than one vCard attachment/body
+- Added support for more than one contact in one vCard file
+- Created package.xml
+            </notes>
+        </release>
+	</changelog>
 </package>

Modified: trunk/plugins/vcard_attachments/vcard_attachments.php
===================================================================
--- trunk/plugins/vcard_attachments/vcard_attachments.php	2010-08-30 09:12:57 UTC (rev 3921)
+++ trunk/plugins/vcard_attachments/vcard_attachments.php	2010-08-30 09:52:48 UTC (rev 3922)
@@ -31,7 +31,7 @@
     function message_load($p)
     {
         $this->message = $p['object'];
-    
+
         // handle attachments vcard attachments
         foreach ((array)$this->message->attachments as $attachment) {
             if ($this->is_vcard($attachment)) {
@@ -45,7 +45,7 @@
                 $this->vcard_bodies[] = $part->mime_id;
             }
         }
-                                        
+
         if ($this->vcard_parts)
             $this->add_texts('localization');
     }
@@ -69,13 +69,16 @@
             if (in_array($part, $this->vcard_bodies))
                 $p['content'] = '';
 
+            $style = 'margin:0.5em 1em; padding:0.2em 0.5em; border:1px solid #999; '
+                .'border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; width: auto';
+
             foreach ($vcards as $idx => $vcard) {
                 $display = $vcard->displayname;
                 if ($vcard->email[0])
                     $display .= ' <'.$vcard->email[0].'>';
 
                 // add box below messsage body
-                $p['content'] .= html::p(array('style' => "margin:0.5em 1em; padding:0.2em 0.5em; border:1px solid #999; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; width: auto"),
+                $p['content'] .= html::p(array('style' => $style),
                     html::a(array(
                         'href' => "#",
                         'onclick' => "return plugin_vcard_save_contact('".JQ($part.':'.$idx)."')",
@@ -113,12 +116,12 @@
         }
 
         $error_msg = $this->gettext('vcardsavefailed');
-    
+
         if ($part && ($vcards = rcube_vcard::import($part))
             && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email) {
 
             $contacts = $rcmail->get_address_book(null, true);
-      
+
             // check for existing contacts
             $existing = $contacts->search('email', $vcard->email[0], true, false);
             if ($existing->count) {
@@ -126,23 +129,26 @@
             }
             else {
                 // add contact
-                $success = $contacts->insert(array(
+                $contact = array(
                     'name'      => $vcard->displayname,
                     'firstname' => $vcard->firstname,
                     'surname'   => $vcard->surname,
                     'email'     => $vcard->email[0],
                     'vcard'     => $vcard->export(),
-                ));
+                );
 
-                if ($success)
+                $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null));
+                $contact = $plugin['record'];
+
+                if (!$plugin['abort'] && ($done = $contacts->insert($contact)))
                     $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation');
                 else
                     $rcmail->output->command('display_message', $error_msg, 'error');
             }
-        }       
+        }
         else
             $rcmail->output->command('display_message', $error_msg, 'error');
-    
+
         $rcmail->output->send();
     }
 

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



More information about the Svn mailing list