X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddressbook.php;h=8fafa44a656a093b1d65dbbdc593e4313235f1fc;hp=994a7de68622ddf98a9aaeda39bf48b0021e4498;hb=703fa6b5750589a850be01a9b934afc4c7e51d63;hpb=056a005c68b0db699d0c81d1870ec3bc25f62835 diff --git a/src/addressbook.php b/src/addressbook.php index 994a7de6..8fafa44a 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -3,13 +3,14 @@ /** * addressbook.php * - * Copyright (c) 1999-2004 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. * * @version $Id$ * @package squirrelmail + * @subpackage addressbook */ /** @@ -20,11 +21,8 @@ define('SM_PATH','../'); /** 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 */ @@ -47,95 +45,13 @@ sqgetGlobalVar('doedit', $doedit, SQ_POST); /* Get sorting order */ $abook_sort_order = get_abook_sort(); -/** - * Make an input field - * @param string $label - * @param string $field - * @param string $name - * @param string $size - * @param array $values - * @param string $add - */ -function addressbook_inp_field($label, $field, $name, $size, $values, $add) { - global $color; - $value = ( isset($values[$field]) ? $values[$field] : ''); - - $td_str = addInput($name.'['.$field.']', $value, $size) - . $add ; - - return html_tag( 'tr' , - html_tag( 'td', $label . ':', 'right', $color[4]) . - html_tag( 'td', $td_str, 'left', $color[4]) - ) - . "\n"; -} - -/** - * 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', - addressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values, - ' ' . _("Must be unique") . '') . - addressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') . - addressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . - addressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') . - addressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') . - list_writable_backends($name) . - html_tag( 'tr', - html_tag( 'td', - addSubmit($submittext, $name.'[SUBMIT]'), - 'center', $color[4], 'colspan="2"') - ) - , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n"; - } else { - echo html_tag( 'table', - addressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values, - ' ' . _("Must be unique") . '') . - addressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') . - addressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') . - addressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . - addressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') . - list_writable_backends($name) . - html_tag( 'tr', - html_tag( 'td', - addSubmit($submittext, $name.'[SUBMIT]') , - 'center', $color[4], 'colspan="2"') - ) - , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n"; - } -} - -function list_writable_backends($name) { - global $color, $abook; - if ( $name != 'addaddr' ) { return; } - if ( $abook->numbackends > 1 ) { - $ret = '"; - return html_tag( 'tr', - html_tag( 'td', _("Add to:"),'right', $color[4] ) . - html_tag( 'td', $ret, 'left', $color[4] )) . "\n"; - } else { - return html_tag( 'tr', - html_tag( 'td', - addHidden('backend', '1'), - 'center', $color[4], 'colspan="2"')) . "\n"; - } -} +/* Create page header before addressbook_init in order to display error messages correctly. */ +displayPageHeader($color, 'None'); -/* Open addressbook, with error messages on but without LDAP (the * - * second "true"). Don't need LDAP here anyway */ -$abook = addressbook_init(true, true); +/* Open addressbook with error messages on. + remote backends (LDAP) are enabled because they can be used. (list_addr function) +*/ +$abook = addressbook_init(true, false); if($abook->localbackend == 0) { plain_error_message( _("No personal address book is defined. Contact administrator."), @@ -143,7 +59,6 @@ if($abook->localbackend == 0) { exit(); } -displayPageHeader($color, 'None'); $defdata = array(); $formerror = ''; @@ -152,7 +67,6 @@ $showaddrlist = true; $defselected = array(); $form_url = 'addressbook.php'; - /* Handle user's actions */ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST') { @@ -245,15 +159,7 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P $olddata = $abook->lookup($enick, $ebackend); /* Display the "new address" form */ - echo addForm($form_url, 'post'). - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '' . _("Update address") . '' ."\n", - 'center', $color[0] ) - ), - 'center', '', 'width="100%" ' ); - address_form("editaddr", _("Update address"), $olddata); + abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$olddata); echo addHidden('oldnick', $olddata['nickname']). addHidden('backend', $olddata['backend']). addHidden('doedit', '1'). @@ -279,17 +185,8 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P 'center', '', 'width="100%"' ); /* Display the "new address" form again */ - echo addForm($form_url, 'post'). - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '' . _("Update address") . '' ."\n", - 'center', $color[0] ) - ), - 'center', '', 'width="100%"' ); - address_form("editaddr", _("Update address"), $newdata); - echo - addHidden('oldnick', $oldnick). + abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); + echo addHidden('oldnick', $oldnick). addHidden('backend', $backend). addHidden('doedit', '1'). "\n" . ''; @@ -373,10 +270,10 @@ if ($showaddrlist) { html_tag( 'th', _("Nickname") . show_abook_sort_button($abook_sort_order, _("sort by nickname"), 0, 1), 'left', '', 'width="1%"' ) . "\n" . - html_tag( 'th', _("Name") . + html_tag( 'th', _("Name") . show_abook_sort_button($abook_sort_order, _("sort by name"), 2, 3), 'left', '', 'width="1%"' ) . "\n" . - html_tag( 'th', _("E-mail") . + html_tag( 'th', _("E-mail") . show_abook_sort_button($abook_sort_order, _("sort by email"), 4, 5), 'left', '', 'width="1%"' ) . "\n" . html_tag( 'th', _("Info") . @@ -425,9 +322,9 @@ if ($showaddrlist) { ' ' , 'center', '', 'valign="top" width="1%"' ); } - echo html_tag( 'td', ' ' . $row['nickname'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . - html_tag( 'td', ' ' . $row['lastname'] . ' ' . $row['firstname'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . - html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . ' '; + echo html_tag( 'td', ' ' . $row['nickname'] . ' ', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . + html_tag( 'td', ' ' . $row['lastname'] . ' ' . $row['firstname'] . ' ', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . + html_tag( 'td', '', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . ' '; } else { echo html_tag( 'tr', '', '', $tr_bgcolor); if ($abook->backends[$row['backend']]->writeable) { @@ -441,9 +338,9 @@ if ($showaddrlist) { ' ' , 'center', '', 'valign="top" width="1%"' ); } - echo html_tag( 'td', ' ' . $row['nickname'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . - html_tag( 'td', ' ' . $row['name'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . - html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . ' '; + echo html_tag( 'td', ' ' . $row['nickname'] . ' ', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . + html_tag( 'td', ' ' . $row['name'] . ' ', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . + html_tag( 'td', '', 'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' ) . ' '; } $email = $abook->full_address($row); echo makeComposeLink('src/compose.php?send_to='.rawurlencode($email), @@ -473,19 +370,13 @@ if ($showaddrlist) { /* Display the "new address" form */ -echo '' . "\n" . - addForm($form_url, 'post', 'f_add'). - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', "\n". '' . _("Add to address book") . '' . "\n", - 'center', $color[0] - ) - ) - , 'center', '', 'width="100%"' ) ."\n"; -address_form('addaddr', _("Add address"), $defdata); +echo '' . "\n"; +abook_create_form($form_url,'addaddr',_("Add to address book"),_("Add address"),$defdata); echo "\n"; /* Add hook for anything that wants on the bottom */ +echo "\n"; do_hook('addressbook_bottom'); +echo "\n\n"; ?> - + \ No newline at end of file