5 * Functions to make working with address books easier
7 * @copyright © 1999-2007 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @package squirrelmail
11 * @subpackage templates
14 //FIXME: the functions in this file should be reviewed and moved to functions/template/abook_util.php and this file should be removed
16 * Create a link to compose an email to the email address given.
18 * @param array $row contact as given to the addressbook_list.tpl template
22 function composeLink ($row) {
23 return makeComposeLink('src/compose.php?send_to=' .
24 rawurlencode($row['FullAddress']),
25 htmlspecialchars($row['Email']));
29 * Format the address book into a format that is easy for template authors
32 * @param array $addresses all contacts as given by calling $abook->list_addr()
37 function formatAddressList ($addresses) {
38 if (!is_array($addresses) ||
count($addresses) == 0)
42 while(list($undef,$row) = each($addresses)) {
44 'FirstName' => htmlspecialchars($row['firstname']),
45 'LastName' => htmlspecialchars($row['lastname']),
46 'FullName' => htmlspecialchars($row['name']),
47 'NickName' => htmlspecialchars($row['nickname']),
48 'Email' => htmlspecialchars($row['email']),
49 'FullAddress' => htmlspecialchars(AddressBook
::full_address($row)),
50 'Info' => htmlspecialchars($row['label']),
51 'Extra' => (isset($row['extra']) ?
$row['extra'] : NULL),
52 'Source' => htmlspecialchars($row['source']),
53 'JSEmail' => htmlspecialchars(addcslashes(AddressBook
::full_address($row), "'"), ENT_QUOTES
),
55 $contacts[] = $contact;
62 * Function to include JavaScript code
65 function insert_javascript() {
67 <script type
="text/javascript"><!--
69 function to_and_close($addr) {
74 function to_address($addr) {
76 var pwintype
= typeof parent
.opener
.document
.compose
;
78 $addr = $addr.replace(/ {1,35}$
/, "");
80 if (pwintype
!= "undefined") {
81 if (parent
.opener
.document
.compose
.send_to
.value
) {
83 parent
.opener
.document
.compose
.send_to
.value
=
84 parent
.opener
.document
.compose
.send_to
.value +
", " +
$addr;
86 parent
.opener
.document
.compose
.send_to
.value
= $addr;
91 function cc_address($addr) {
93 var pwintype
= typeof parent
.opener
.document
.compose
;
95 $addr = $addr.replace(/ {1,35}$
/, "");
97 if (pwintype
!= "undefined") {
98 if (parent
.opener
.document
.compose
.send_to_cc
.value
) {
100 parent
.opener
.document
.compose
.send_to_cc
.value
=
101 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
103 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
108 function bcc_address($addr) {
110 var pwintype
= typeof parent
.opener
.document
.compose
;
112 $addr = $addr.replace(/ {1,35}$
/, "");
114 if (pwintype
!= "undefined") {
115 if (parent
.opener
.document
.compose
.send_to_bcc
.value
) {
117 parent
.opener
.document
.compose
.send_to_bcc
.value
=
118 parent
.opener
.document
.compose
.send_to_bcc
.value +
", " +
$addr;
120 parent
.opener
.document
.compose
.send_to_bcc
.value
= $addr;
127 } /* End of included JavaScript */
130 * Function to build a list of available backends for searching
133 * @author Steve Brown
136 function getBackends () {
140 $backends['-1'] = _("All address books");
141 $ret = $abook->get_backend_list();
142 while (list($undef,$v) = each($ret)) {
143 if ($v->btype
== 'local' && !$v->listing
) {
146 $backends[$v->bnum
] = $v->sname
;