[dev] Re: [imp] whitelist patch...

Amith Varghese amith at xalan.com
Wed Feb 26 14:46:17 PST 2003


> Sorry... i missed this.. will send a patch soon.

Here's the patch to add whitelisting to the mailbox view as well.

One thing that I did notice while testing is that the error handling between imp
and sam doesn't really work.  For example in IMP::blacklistMessage() assumes
automatically that the address was added to the blacklist by pushing something
on the notification stack.  However, if in sam's API the address is already in
the  blacklist, it returns a PEAR_Error.  My question is this:

How is error handling performed between different applications?  

In this situation, if I choose to blacklist 10 addresses and two addresses are
already in my blacklist, I would expect the application to say these 8 have been
added and these 2 are already in the list.  However the way sam is set up is
that it fails immediately and returns a PEAR Error.  I was thinking that it
would make sense if the API returned an array of objects and then you could do
something like

foreach ($results as $address) {
    if (is_a($address,'PEAR_Error') {
        $notification->push($address->getMessage()); // Error message here
    } else {
        $notification->push(sprintf(_("The address %s has been added to your
blacklist."), $address));
    }
}

Is this the best way to do this?  Any suggestions are welcome.

Thanks
Amith
-------------- next part --------------
Index: imp/mailbox.php
===================================================================
RCS file: /repository/imp/mailbox.php,v
retrieving revision 2.476
diff -u -r2.476 mailbox.php
--- imp/mailbox.php	18 Feb 2003 14:14:15 -0000	2.476
+++ imp/mailbox.php	26 Feb 2003 19:06:01 -0000
@@ -100,7 +100,9 @@
 case IMP_BLACKLIST:
     IMP::blacklistMessage($indices);
     break;
-
+case IMP_WHITELIST:
+    IMP::whitelistMessage($indices);
+    break;
 case MESSAGE_MISSING:
     $notification->push(_("There was an error viewing the requested message."), 'horde.error');
     break;
@@ -302,6 +304,14 @@
 
 /* Is this a search mailbox? */
 $search_mbox = ($imp['mailbox'] == SEARCH_MBOX);
+
+/* Show the whitelist link if we have whitelist functionality enabled */
+if ($registry->hasMethod('mail/whitelistFrom') &&
+        $registry->hasMethod('mail/showWhitelist')) {
+    $show_whitelist_link = true;
+} else {
+    $show_whitelist_link = false;
+}
 
 require IMP_TEMPLATES . '/mailbox/header.inc';
 $navform = 1;
Index: imp/templates/mailbox/actions.inc
===================================================================
RCS file: /repository/imp/templates/mailbox/actions.inc,v
retrieving revision 2.52
diff -u -r2.52 actions.inc
--- imp/templates/mailbox/actions.inc	18 Feb 2003 02:22:29 -0000	2.52
+++ imp/templates/mailbox/actions.inc	26 Feb 2003 19:06:22 -0000
@@ -14,6 +14,9 @@
 <?php endif; ?>
 <?php if (!empty($conf['prefs']['driver']) && ($conf['prefs']['driver'] != 'none') && !$prefs->isLocked('filters')): ?>
         | <?php echo Horde::widget('', _("Blacklist"), 'widget', '', 'Submit(' . IMP_BLACKLIST . '); return false;', _("Blacklist")); ?>
+<?php if($show_whitelist_link): ?>
+        | <?php echo Horde::widget('', _("Whitelist"), 'widget', '', 'Submit(' . IMP_WHITELIST . '); return false;', _("Whitelist")); ?>
+<?php endif; ?>
 <?php endif; ?>
     | <?php echo Horde::widget('', _("Forward"), 'widget', '', 'Submit(' . FWD_DIGEST . '); return false;', _("Forward")) ?>
     </td>


More information about the dev mailing list