[dev] [framework-patch] fixes vcard import

Francois Marier francois at nit.ca
Fri Jul 30 12:31:16 PDT 2004


This patch modifies the vcard display page to fix the support that was
already there for having multiple contacts in the same vcard.

It does 3 things:

- fixes a typo in the for loop condition that prevented the loop from
looping more than once
- moves the </table> out of the for loop to prevent premature closing
of the table
- cleans up the error message since the Driver does not return the
list of contacts that were added anymore

Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/framework/MIME/MIME/Viewer/vcard.php framework/MIME/MIME/Viewer/vcard.php
--- ../build/framework/MIME/MIME/Viewer/vcard.php	Fri Jul 30 15:24:49 2004
+++ framework/MIME/MIME/Viewer/vcard.php	Fri Jul 30 15:23:03 2004
@@ -48,13 +48,10 @@ class MIME_Viewer_vcard extends MIME_Vie
             if (is_a($contacts, 'PEAR_Error')) {
                 $import_msg = _("There was an error importing the contact data.");
             } else {
-                $import_msg = _("This contact data has been successfully added to your address book. Click below to view:");
-                $import_msg .= '</td></tr>';
-                foreach ($contacts as $contactID => $name) {
-                    $url = Horde::url($registry->link('contacts/show', array('source' => $source, 'key' => $contactID)));
-                    $import_msg .= '<tr><td class="item" colspan="2">';
-                    $import_msg .= Horde::link($url, $name, null, '_blank') . Horde::img('mime/vcard.gif', $name, null, $registry->getParam('graphics', 'horde')) . '&nbsp;' . $name . '</a><br />';
-                    $import_msg .= '</td></tr>';
+                if ($vc->count() == 1) {
+                    $import_msg = _("The contact was successfully added to your address book.");
+                } else {
+                    $import_msg = _("Contacts were successfully added to your address book.");
                 }
             }
         }
@@ -87,7 +84,7 @@ class MIME_Viewer_vcard extends MIME_Vie
             $html .= '</form></td></tr><tr><td>&nbsp;</td></tr>';
         }
 
-        for ($i = 0; $i < count($vc->count()); $i++) {
+        for ($i = 0; $i < $vc->count(); $i++) {
             if ($i > 0) {
                 $html .= '<tr><td>&nbsp;</td></tr>';
             }
@@ -225,10 +222,9 @@ class MIME_Viewer_vcard extends MIME_Vie
             if (count($url)) {
                 $html .= $this->_row(_("URL"), '<a href="' . $url[0]['value'] . '" target="_blank">' . $url[0]['value'] . '</a>');
             }
-
-            $html .= '</table>';
         }
 
+        $html .= '</table>';
         $html .= Util::bufferOutput('include', $registry->getParam('templates', 'horde') . '/common-footer.inc');
 
         return $html;


More information about the dev mailing list