X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=753cd2ca054ac9655f62a37b938ec2aec498eb40;hb=77180a756d97ef3a08d1029eccb8e8ec9e780a35;hp=09a5a41bb85587744bdd393633066fea870b9441;hpb=91e0dccca7b2452d8b450791cae3aa4125e8889e;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index 09a5a41b..753cd2ca 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -3,7 +3,7 @@ /** * 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. @@ -45,10 +45,15 @@ sqgetGlobalVar('doedit', $doedit, SQ_POST); /* Get sorting order */ $abook_sort_order = get_abook_sort(); +/* 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."), @@ -56,7 +61,6 @@ if($abook->localbackend == 0) { exit(); } -displayPageHeader($color, 'None'); $defdata = array(); $formerror = ''; @@ -144,7 +148,6 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P * Update/modify address * ***********************************************/ if (!empty($editaddr)) { - /* Stage one: Copy data into form */ if (isset($sel) && sizeof($sel) > 0) { if(sizeof($sel) > 1) { @@ -163,40 +166,40 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P addHidden('doedit', '1'). ''; } - } else { - + } elseif ($doedit == 1) { /* Stage two: Write new data */ - if ($doedit = 1) { - $newdata = $editaddr; - $r = $abook->modify($oldnick, $newdata, $backend); - - /* Handle error messages */ - if (!$r) { - /* Display error */ - echo html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '' . _("ERROR") . ': ' . $abook->error . '' ."\n", - 'center' ) - ), - 'center', '', 'width="100%"' ); - - /* Display the "new address" form again */ - abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); - echo addHidden('oldnick', $oldnick). - addHidden('backend', $backend). - addHidden('doedit', '1'). - "\n" . ''; - $abortform = true; - } - } else { + $newdata = $editaddr; + $r = $abook->modify($oldnick, $newdata, $backend); - /* Should not get here... */ - plain_error_message(_("Unknown error"), $color); + /* Handle error messages */ + if (!$r) { + /* Display error */ + echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', + "\n". '' . _("ERROR") . ': ' . $abook->error . '' ."\n", + 'center' ) + ), + 'center', '', 'width="100%"' ); + + /* Display the "new address" form again */ + abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); + echo addHidden('oldnick', $oldnick). + addHidden('backend', $backend). + addHidden('doedit', '1'). + "\n" . ''; $abortform = true; } - } + } else { + /** + * $editaddr is set, but $sel (address selection in address listing) + * and $doedit (address edit form) are not set. + * Assume that user clicked on "Edit address" without selecting any address. + */ + $formerror = _("Please select address that you want to edit"); + $showaddrlist = true; + } /* end of edit stage detection */ } /* !empty($editaddr) - Update/modify address */ } /* (!empty($deladdr)) && sizeof($sel) > 0 - Delete address(es) */ } /* !empty($addaddr['nickname']) - Add new address */ @@ -320,9 +323,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) { @@ -336,9 +339,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),