5 * Functions to make working with address books easier
7 * @copyright © 1999-2006 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @package squirrelmail
11 * @subpackage templates
15 * Display a column header with sort buttons
17 * @param string $field which field to display
21 function addAbookSort ($field) {
22 global $abook_sort_order;
27 $alt = _("sort by nickname");
34 $alt = _("sort by name");
41 $alt = _("sort by email");
48 $alt = _("sort by info");
54 return 'BAD SORT FIELD GIVEN: "'.$field.'"';
57 return $str . ($has_sort ?
show_abook_sort_button($abook_sort_order, $alt, $down, $up) : '');
61 * Create a link to compose an email to the email address given.
63 * @param array $row contact as given to the addressbook_list.tpl template
67 function composeLink ($row) {
68 return makeComposeLink('src/compose.php?send_to=' .
69 rawurlencode($row['FullAddress']),
70 htmlspecialchars($row['Email']));
74 * Format the address book into a format that is easy for template authors
77 * @param array $addresses all contacts as given by calling $abook->list_addr()
82 function formatAddressList ($addresses) {
83 if (!is_array($addresses) ||
count($addresses) == 0)
87 while(list($undef,$row) = each($addresses)) {
89 'FirstName' => htmlspecialchars($row['firstname']),
90 'LastName' => htmlspecialchars($row['lastname']),
91 'FullName' => htmlspecialchars($row['name']),
92 'NickName' => htmlspecialchars($row['nickname']),
93 'Email' => htmlspecialchars($row['email']),
94 'FullAddress' => htmlspecialchars(AddressBook
::full_address($row)),
95 'Info' => htmlspecialchars($row['label']),
96 'Extra' => (isset($row['extra']) ?
$row['extra'] : NULL),
97 'Source' => htmlspecialchars($row['source']),
98 'JSEmail' => htmlspecialchars(addcslashes(AddressBook
::full_address($row), "'"), ENT_QUOTES
),
100 $contacts[] = $contact;
107 * Function to include JavaScript code
110 function insert_javascript() {
112 <script type
="text/javascript"><!--
114 function to_and_close($addr) {
119 function to_address($addr) {
121 var pwintype
= typeof parent
.opener
.document
.compose
;
123 $addr = $addr.replace(/ {1,35}$
/, "");
125 if (pwintype
!= "undefined") {
126 if (parent
.opener
.document
.compose
.send_to
.value
) {
128 parent
.opener
.document
.compose
.send_to
.value
=
129 parent
.opener
.document
.compose
.send_to
.value +
", " +
$addr;
131 parent
.opener
.document
.compose
.send_to
.value
= $addr;
136 function cc_address($addr) {
138 var pwintype
= typeof parent
.opener
.document
.compose
;
140 $addr = $addr.replace(/ {1,35}$
/, "");
142 if (pwintype
!= "undefined") {
143 if (parent
.opener
.document
.compose
.send_to_cc
.value
) {
145 parent
.opener
.document
.compose
.send_to_cc
.value
=
146 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
148 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
153 function bcc_address($addr) {
155 var pwintype
= typeof parent
.opener
.document
.compose
;
157 $addr = $addr.replace(/ {1,35}$
/, "");
159 if (pwintype
!= "undefined") {
160 if (parent
.opener
.document
.compose
.send_to_bcc
.value
) {
162 parent
.opener
.document
.compose
.send_to_bcc
.value
=
163 parent
.opener
.document
.compose
.send_to_bcc
.value +
", " +
$addr;
165 parent
.opener
.document
.compose
.send_to_bcc
.value
= $addr;
172 } /* End of included JavaScript */
175 * Function to build a list of available backends for searching
178 * @author Steve Brown
181 function getBackends () {
185 $backends['-1'] = _("All address books");
186 $ret = $abook->get_backend_list();
187 while (list($undef,$v) = each($ret)) {
188 $backends[$v->bnum
] = $v->sname
;