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

Jan Schneider jan at horde.org
Fri Mar 7 11:14:05 PST 2003


Quoting Jan Schneider <jan at horde.org>:

> Quoting Amith Varghese <amith at xalan.com>:
> 
> > > Pass back the general success/failure message in $message, the
> overall
> > > success/failure code in $code, and all the extra information you need
> > in
> > > $userinfo (which addresses failed, which were duplicates, etc.).
> >
> > $message is a mixed type (either a string or another PEAR_Error
> object).
> 
> No, as proposed by Chuck it should (and can) always be a PEAR_Error.
> 
> > The problem with a general success/failure message is that it is
> possible
> > when
> > adding an address to a blacklist that the address could either exist or
> > not
> > exist in the blacklist.  If the address is in the list I would like to
> > print
> >
> > "amith at xalan.com is already in your blacklist"
> >
> > If the address is not in the list I would like to print
> >
> > "amith at xalan.com has been added to your blacklist"
> 
> The possible return types, as defined by the Notification backend are
> 'horde.message', 'horde.success', 'horde.warning' and 'horde.error'.
> In this case you might want to use success and warning.
> 
> > So what would be the general success/failure message in this case?  I
> > would like
> > to pass back both but I can't pass an array here without serializing
> the
> > array
> > or imploding it.  I didn't think that was a good idea because I looked
> > through
> > some of the code and it seems like serialize is only used to put arrays
> > within
> > sessions or write them to the backend.
> 
> Why do you think you need to serialize anything? Serializing is only
> necessary if you want to store complex types in a string context. You
> don't
> leave PHP here, so there's no need to serialize anything. That is as long
> as
> you know what the called method will return.
> 
> > The last problem I'm having with this solution is that i want to pass
> > back a
> > list of addresses that were added successfully and a list that already
> > existed
> > in the blacklist.  However $userinfo is a string and the only way i can
> > think of
> > again is to pass information back using serialize()
> 
> I would recommend you to take a closer look at the notification backend.
> The
> notify() method take an optional PEAR_Error as the parameter, using its

I meant push() of course.

> error code as the notification level and its error message as the
> notification message.
> 
> So why don't you just create a PEAR_Error with the error code
> 'horde.success' if all addresses have been added, 'horde.warning' if only
> some addresses have been added and, if you like, 'horde.error' if no
> addresses have been added. The latter is not necessary imo as I still
> wouldn't call it an 'error'.
> 
> As the error message you tell the user what actually happened. Like
> "address
> A and B have been added" or "address A has been added. address B already
> exists." You get the idea.
> 
> You can then pass this object unmodified and unchecked to the
> notification
> backend that cares about the correct notification type and spits out the
> result of the action as a clear text message.

Jan.

--
http://www.horde.org - The Horde Project
http://www.ammma.de - discover your knowledge
http://www.tip4all.de - Deine private Tippgemeinschaft


More information about the dev mailing list