[imp] Address Book feature

Eric J Rostetter eric.rostetter@physics.utexas.edu
Wed, 27 Feb 2002 10:26:59 -0600


Quoting Virgil Kyle <virg@custom-tech.net>:

> Anyone have an address book feature that works from inside the compose
> window.  

Michael Cochrane has a nice patch for this, that conceptually is *very*
nice.  You can get the address of his patches off the horde.org web
site from the IMP page.

However, it does have some problems.  I've been meaning to
contact Mike for several days about the problems, but just haven't
done so (been a killer week at work).

His IMP templates/compose/compose.inc patch reads (wrapped for email):

<?= Menu::createItem('', _("Addressbook"), 'turba.gif',
$registry->getGraphicsPath('turba'), NULL, "window.open('" .
$registry->getWebRoot('turba') . "/search.php?addresspopup=true', '" .
_("Addressbook") . "'
,'scrollbars=yes,toolbar=no,location=no,menubar=no,status=no,
resizable=yes,width=500,height=500,left=0,top=0'); return false;", 
'item', 'widget'); ?>

There are two problems here.  First, while it will work well with
cookie session management, it doesn't pass the session parameters
on the command line so it won't work in url session management (instead
you'll get a login screen, since the session info wasn't passed).

I modified it (rather poorly) as the following (two lines, wrapped
for email):

<?php $popupurl = Horde::url($registry->getWebRoot('turba') .
"/index.php?addresspopup=true', '"); ?>

<?= Menu::createItem('', _("Addressbook"), 'turba.gif',
$registry->getGraphicsPath('turba'), NULL, "window.open('" . $popupurl .
_("Addressbook") . "'
,'scrollbars=yes,toolbar=no,location=no,menubar=no,status=no,resizable=yes,width=500,height=500,left=0,top=0');
return false;", 'item', 'widget'); ?>

This passes the url session code (if present) to turba.  Actually, you
may notice I changed the url to index.php rather than search.php -- it 
will work either way.  Using index.php gives it a chance to do some checks
like if turba is configured, etc.  Not needed, but maybe nice.  A small
detail, and it should work with either url.

The second problem (which I've not fixed yet) is that it uses "'" quotes
and doesn't call addslashes.  This isn't a problem for English, but as
soon as you try to use another language that uses "'" characters in
the language strings, it fails.  For instance, it fails in French
were Addressbook becomes "Carnet d'address" and the "'" ends the previous
quote...

Other than that, it is a wonderful patch.  My users complained no-end
about the new IMP until I added it.  The patch, as modified by me, is
in our production server, and no complaints have come in (I guess no one
is using it in French ;)  I plan to clean up my patch and add the
addslashes calls when I get time, unless Mike beats me to it and
releases a new version :)

Big thanks to Mike for this really nice patch!

Eric Jon Rostetter
The Department of Physics
The University of Texas at Austin
Austin, Texas 78712-1081

Office:    RLM 7.126
Telephone: 512-471-5821
Email:	   eric.rostetter@physics.utexas.edu

------------------------------------------------------------
"I like driving around with my two cats, especially on the 
freeway.  I make them wear little hats so that I can use the 
carpool lane.  Way too much time on your hands too?  Call me. 
SWF, 42, 5'10", brown/blue."  -- from the book "Plain Fat 
Chick Seeks Guy Who Likes Broccoli" (Gibbs Smith)