\n";
while (list($undef, $row) = each($res)) {
$email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES);
if ($line % 2) {
$tr_bgcolor = $color[12];
} else {
$tr_bgcolor = $color[4];
}
echo html_tag( 'tr', '', '', $tr_bgcolor, 'style="white-space: nowrap;"' ) .
html_tag( 'td',
'"._("To")." | " .
'"._("Cc")." | " .
'"._("Bcc")."",
'center', '', 'valign="top" width="5%" style="white-space: nowrap;"' ) .
html_tag( 'td', ' ' . htmlspecialchars($row['name']), 'left', '', 'valign="top" style="white-space: nowrap;"' ) .
html_tag( 'td', ' ' .
'" . htmlspecialchars($row['email']) . ''
, 'left', '', 'valign="top"' ) .
html_tag( 'td', htmlspecialchars($row['label']), 'left', '', 'valign="top" style="white-space: nowrap;"' );
if ($includesource) {
echo html_tag( 'td', ' ' . $row['source'], 'left', '', 'valign="top" style="white-space: nowrap;"' );
}
echo "\n";
$line++;
}
echo '';
}
/* ================= End of functions ================= */
/** lets get the global vars we may need */
if (! sqgetGlobalVar('show' , $show)) {
$show = '';
}
if (! sqgetGlobalVar('query', $query, SQ_POST)) {
$query = '';
}
if (! sqgetGlobalVar('listall', $listall, SQ_POST)) {
unset($listall);
}
if (! sqgetGlobalVar('backend', $backend, SQ_POST)) {
$backend = '';
}
displayHtmlHeader();
/** set correct value of $default_charset */
global $default_charset;
set_my_charset();
/* Choose correct colors for top and bottom frame */
if ($show == 'form' && !isset($listall)) {
echo '
';
} else {
echo '\n";
}
/* Empty search */
if (empty($query) && empty($show) && !isset($listall)) {
echo html_tag( 'p', '
' .
_("No persons matching your search were found"),
'center' ) .
"\n\n";
exit;
}
/* Initialize addressbook, show init errors only in bottom frame */
$showerr=($show=='form' ? false : true);
$abook = addressbook_init($showerr);
/* Create search form (top frame) */
if ($show == 'form' && ! isset($listall)) {
echo '' . "\n";
} else {
/**
* List addresses (bottom frame)
* If listall is set, list all entries in selected backend.
* If $show is 'blank' (initial call of address book popup) - list
* personal address book.
*/
if ($show == 'blank' || isset($listall)) {
if($backend != -1 || $show == 'blank') {
if ($show == 'blank') {
$backend = $abook->localbackend;
}
$res = $abook->list_addr($backend);
if(is_array($res)) {
usort($res,'alistcmp');
display_result($res, false);
} else {
echo html_tag( 'p', '' .
sprintf(_("Unable to list addresses from %s"),
$abook->backends[$backend]->sname) . '' ,
'center' ) . "\n";
}
} else {
$res = $abook->list_addr();
usort($res,'alistcmp');
display_result($res, true);
}
} elseif (!empty($query)) {
/* Do the search (listall is not set. query is set.)*/
if($backend == -1) {
$res = $abook->s_search($query);
} else {
$res = $abook->s_search($query, $backend);
}
if (!is_array($res)) {
echo html_tag( 'p', '
' .
_("Your search failed with the following error(s)") .
':
' . nl2br(htmlspecialchars($abook->error)) . "\n" ,
'center' );
} elseif (sizeof($res) == 0) {
echo html_tag( 'p', '
' .
_("No persons matching your search were found") . "\n" ,
'center' );
} else {
display_result($res);
}
} else {
/**
* listall is not set, query is not set or empty.
* User hit search button without entering search expression.
*/
echo html_tag( 'p', '
' . _("Nothing to search") . "\n",'center' );
}
}
$oTemplate->display('footer.tpl');
?>