Source for file addressbook.php
Documentation is available at addressbook.php
* Manage personal address book.
* @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: addressbook.php,v 1.111 2006/08/15 21:31:48 stevetruckstuff Exp $
* @subpackage addressbook
* Include the SquirrelMail initialization file.
include('../include/init.php');
/** SquirrelMail required files. */
/* address book functions */
require_once(SM_PATH .
'functions/addressbook.php');
include_once(SM_PATH .
'templates/util_addressbook.php');
include_once(SM_PATH .
'templates/util_global.php');
require_once(SM_PATH .
'functions/forms.php');
/** lets get the global vars we may need */
/* From the address form */
/* Create page header before addressbook_init in order to display error messages correctly. */
/* Open addressbook with error messages on.
remote backends (LDAP) are enabled because they can be used. (list_addr function)
// FIXME: do we have to stop use of address book, when localbackend is not present.
if($abook->localbackend ==
0) {
$current_backend =
$abook->localbackend;
$current_backend = (int)
$new_backend;
$abook_selection =
' ';
$list_backends =
array();
if (count($abook->backends) >
1) {
foreach($abook->get_backend_list() as $oBackend) {
if ($oBackend->listing) {
$list_backends[$oBackend->bnum]=
$oBackend->sname;
if (count($list_backends)>
1) {
$abook_selection =
addSelect('new_bnum',$list_backends,$current_backend,true)
$form_url =
'addressbook.php';
/* Handle user's actions */
/************************************************
**************************************************/
$r =
$abook->add($addaddr, $backend);
$r =
$abook->add($addaddr, $abook->localbackend);
/* Handle error messages */
/* Remove backend name from error string */
/**********************************************
************************************************/
if ((!empty($deladdr)) &&
sizeof($sel) >
0) {
/* The selected addresses are identidied by "nickname_backend". *
* Sort the list and process one backend at the time */
for ($i =
0 ; (($i <
sizeof($sel)) &&
!$delfailed) ; $i++
) {
list
($snick, $sbackend) =
explode('_', $sel[$i]);
/* When we get to a new backend, process addresses in *
if ($prevback !=
$sbackend &&
$prevback != -
1) {
$r =
$abook->remove($subsel, $prevback);
$formerror =
$abook->error;
/* Queue for processing */
$r =
$abook->remove($subsel, $prevback);
if (!$r) { /* Handle errors */
$formerror =
$abook->error;
$defselected =
$orig_sel;
/*********************************************
* Update/modify address *
***********************************************/
/* Stage one: Copy data into form */
if (isset
($sel) &&
sizeof($sel) >
0) {
$formerror =
_("You can only edit one address at the time");
$olddata =
$abook->lookup($enick, $ebackend);
// Test if $olddata really contains anything and return an error message if it doesn't
/* Display the "new address" form */
echo
addHidden('oldnick', $olddata['nickname']).
} elseif ($doedit ==
1) {
/* Stage two: Write new data */
$r =
$abook->modify($oldnick, $newdata, $backend);
/* Handle error messages */
/* Display the "new address" form again */
* $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");
} /* end of edit stage detection */
} /* !empty($editaddr) - Update/modify address */
} /* (!empty($deladdr)) && sizeof($sel) > 0 - Delete address(es) */
} /* !empty($addaddr['nickname']) - Add new address */
// Some times we end output before forms are printed
/* =================================================================== *
* The following is only executed on a GET request, or on a POST when *
* a user is added, or when "delete" or "modify" was successful. *
* =================================================================== */
/* Display error messages */
if (!empty($formerror)) {
/* Display the address management part */
while (list
($k, $backend) =
each ($abook->backends)) {
$a['BackendID'] =
$backend->bnum;
$a['BackendSource'] =
$backend->sname;
$a['BackendWritable'] =
$backend->writeable;
$a['Addresses'] =
array();
$alist =
$abook->list_addr($backend->bnum);
/* check return (array with data or boolean false) */
usort($alist,'alistcmp');
$addresses[$backend->bnum] =
$a;
// list_addr() returns boolean
$oTemplate->assign('addresses', $addresses);
$oTemplate->assign('current_backend', $current_backend);
$oTemplate->assign('backends', $list_backends);
$oTemplate->assign('abook_has_extra_field', $abook->add_extra_field);
$oTemplate->display('addressbook_list.tpl');
/* Display the "new address" form */
echo
'<a name="AddAddress"></a>' .
"\n";
/* Hook for extra address book blocks */
echo
"<!-- start of addressbook_bottom hook-->\n";
echo
"\n<!-- end of addressbook_bottom hook-->\n";
$oTemplate->display('footer.tpl');
Documentation generated on Sat, 07 Oct 2006 16:08:43 +0300 by phpDocumentor 1.3.0RC6