X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=c0ff11ff9b4dec2f14897fc251c18cbefd5890f0;hb=50d5212cd729d067bd9d4243fd66eed39d608207;hp=17528d9ba48b609034aa4a6ab3613e8ff18cdf46;hpb=1e12d1ffb4f54350932a17397d38917db21d64df;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index 17528d9b..c0ff11ff 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -3,26 +3,31 @@ /** * addressbook.php * - * Copyright (c) 1999-2003 The SquirrelMail Project Team + * Copyright (c) 1999-2004 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 */ -/* 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,16 +42,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); +sqgetGlobalVar('doedit', $doedit, SQ_POST); + +/* Get sorting order */ +$abook_sort_order = get_abook_sort(); -/* Make an input field */ -function adressbook_inp_field($label, $field, $name, $size, $values, $add) { +/** + * 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; - $td_str = '' . $add . ''; + $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]) @@ -54,25 +70,71 @@ function adressbook_inp_field($label, $field, $name, $size, $values, $add) { . "\n"; } -/* Output form to add and modify address data */ +/** + * Output form to add and modify address data + */ function address_form($name, $submittext, $values = array()) { - global $color; + 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(_("First name"), 'firstname', $name, 45, $values, '') . - adressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . - adressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') . + 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', - '', + '', + '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', + '', '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"; + } +} /* Open addressbook, with error messages on but without LDAP (the * * second "true"). Don't need LDAP here anyway */ @@ -100,11 +162,12 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P /************************************************** * 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) { @@ -185,7 +248,7 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P $olddata = $abook->lookup($enick, $ebackend); /* Display the "new address" form */ - echo '
'; + echo addHidden('oldnick', $olddata['nickname']). + addHidden('backend', $olddata['backend']). + addHidden('doedit', '1'). + ''; } } else { @@ -215,29 +276,28 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P echo html_tag( 'table', html_tag( 'tr', html_tag( 'td', - "\n". '