X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=de712e846d9665d98e4a0a612ac4c0dce4b2584c;hb=d34a07260930aec480964deae79c1fcd35c1b04a;hp=b37701f19ae5264d0925efebbf9c0ddc2d7d68fd;hpb=e842b215cc74203501fe50e52497f9f0329e721b;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index b37701f1..de712e84 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -3,26 +3,29 @@ /** * addressbook.php * - * Copyright (c) 1999-2003 The SquirrelMail Project Team + * Copyright (c) 1999-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * Manage personal address book. * - * $Id$ + * @version $Id$ + * @package squirrelmail + * @subpackage addressbook */ -/* Path for SquirrelMail required files. */ +/** + * Path for SquirrelMail required files. + * @ignore + */ define('SM_PATH','../'); -/* SquirrelMail required files. */ +/** SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/global.php'); require_once(SM_PATH . 'functions/display_messages.php'); require_once(SM_PATH . 'functions/addressbook.php'); -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); -/* lets get the global vars we may need */ +/** lets get the global vars we may need */ sqgetGlobalVar('key', $key, SQ_COOKIE); sqgetGlobalVar('username', $username, SQ_SESSION); @@ -37,72 +40,27 @@ sqgetGlobalVar('deladdr', $deladdr, SQ_POST); sqgetGlobalVar('sel', $sel, SQ_POST); sqgetGlobalVar('oldnick', $oldnick, SQ_POST); sqgetGlobalVar('backend', $backend, SQ_POST); -sqgetGlobalVar('doedit', $doedit, SQ_POST); - -/* Make an input field */ -function adressbook_inp_field($label, $field, $name, $size, $values, $add) { - global $color; - $td_str = '' . $add . ''; - return html_tag( 'tr' , - html_tag( 'td', $label . ':', 'right', $color[4]) . - html_tag( 'td', $td_str, 'left', $color[4]) - ) - . "\n"; -} +sqgetGlobalVar('doedit', $doedit, SQ_POST); -/* Output form to add and modify address data */ -function address_form($name, $submittext, $values = array()) { - global $color, $squirrelmail_language; - - if ($squirrelmail_language == 'ja_JP') - { - echo html_tag( 'table', - adressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values, - ' ' . _("Must be unique") . '') . - adressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') . - adressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . - adressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') . - adressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') . - html_tag( 'tr', - html_tag( 'td', - '', - 'center', $color[4], 'colspan="2"') - ) - , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n"; - } else { - echo html_tag( 'table', - adressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values, - ' ' . _("Must be unique") . '') . - adressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') . - adressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') . - adressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . - adressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') . - html_tag( 'tr', - html_tag( 'td', - '', - 'center', $color[4], 'colspan="2"') - ) - , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n"; -} -} +/* Get sorting order */ +$abook_sort_order = get_abook_sort(); -/* Open addressbook, with error messages on but without LDAP (the * - * second "true"). Don't need LDAP here anyway */ -$abook = addressbook_init(true, true); +/* Create page header before addressbook_init in order to display error messages correctly. */ +displayPageHeader($color, 'None'); + +/* Open addressbook with error messages on. + remote backends (LDAP) are enabled because they can be used. (list_addr function) +*/ +$abook = addressbook_init(true, false); + +// FIXME: do we have to stop use of address book, when localbackend is not present. if($abook->localbackend == 0) { plain_error_message( - _("No personal address book is defined. Contact administrator."), - $color); + _("No personal address book is defined. Contact administrator."), + $color); exit(); } -displayPageHeader($color, 'None'); $defdata = array(); $formerror = ''; @@ -111,18 +69,18 @@ $showaddrlist = true; $defselected = array(); $form_url = 'addressbook.php'; - /* Handle user's actions */ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST') { /************************************************** * Add new address * **************************************************/ - if (!empty($addaddr['nickname'])) { - foreach( $addaddr as $k => $adr ) { - $addaddr[$k] = strip_tags( $adr ); + if (isset($addaddr)) { + if (isset($backend)) { + $r = $abook->add($addaddr, $backend); + } else { + $r = $abook->add($addaddr, $abook->localbackend); } - $r = $abook->add($addaddr, $abook->localbackend); /* Handle error messages */ if (!$r) { @@ -203,22 +161,11 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P $olddata = $abook->lookup($enick, $ebackend); /* Display the "new address" form */ - echo '
'; + abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$olddata); + echo addHidden('oldnick', $olddata['nickname']). + addHidden('backend', $olddata['backend']). + addHidden('doedit', '1'). + ''; } } else { @@ -230,32 +177,21 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P /* Handle error messages */ if (!$r) { /* Display error */ - echo html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '