X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddressbook.php;h=4a0706f0e134b6fdb30a7826adda687d9e862438;hp=994a7de68622ddf98a9aaeda39bf48b0021e4498;hb=c1ac62d49abbb7ff0389dfc50d400edecaded03f;hpb=beca2d2dce2bee811766328ff66519a2f192d68b
diff --git a/src/addressbook.php b/src/addressbook.php
index 994a7de6..4a0706f0 100644
--- a/src/addressbook.php
+++ b/src/addressbook.php
@@ -20,11 +20,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,92 +44,6 @@ 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";
- }
-}
-
/* Open addressbook, with error messages on but without LDAP (the *
* second "true"). Don't need LDAP here anyway */
$abook = addressbook_init(true, true);
@@ -245,15 +156,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 +182,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" . '';
@@ -473,16 +367,8 @@ 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 */