5 * Functions to make working with address books easier
7 * @copyright 1999-2022 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['RawFullAddress']),
25 sm_encode_html_special_chars($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 foreach($addresses as $row) {
44 'FirstName' => sm_encode_html_special_chars($row['firstname']),
45 'LastName' => sm_encode_html_special_chars($row['lastname']),
46 'FullName' => sm_encode_html_special_chars($row['name']),
47 'NickName' => sm_encode_html_special_chars($row['nickname']),
48 'Email' => sm_encode_html_special_chars($row['email']),
49 'FullAddress' => sm_encode_html_special_chars(AddressBook
::full_address($row)),
50 'RawFullAddress' => AddressBook
::full_address($row),
51 'Info' => sm_encode_html_special_chars($row['label']),
52 'Extra' => (isset($row['extra']) ?
$row['extra'] : NULL),
53 'Source' => sm_encode_html_special_chars($row['source']),
54 'JSEmail' => sm_encode_html_special_chars(addcslashes(AddressBook
::full_address($row), "'"), ENT_QUOTES
),
56 $contacts[] = $contact;
63 * Function to include JavaScript code
66 function insert_javascript() {
68 <script type
="text/javascript"><!--
70 function to_and_close($addr) {
75 function to_address($addr) {
77 var pwintype
= typeof parent
.opener
.document
.compose
;
79 $addr = $addr.replace(/ {1,35}$
/, "");
81 if (pwintype
!= "undefined") {
82 if (parent
.opener
.document
.compose
.send_to
.value
) {
84 parent
.opener
.document
.compose
.send_to
.value
=
85 parent
.opener
.document
.compose
.send_to
.value +
", " +
$addr;
87 parent
.opener
.document
.compose
.send_to
.value
= $addr;
92 function cc_address($addr) {
94 var pwintype
= typeof parent
.opener
.document
.compose
;
96 $addr = $addr.replace(/ {1,35}$
/, "");
98 if (pwintype
!= "undefined") {
99 if (parent
.opener
.document
.compose
.send_to_cc
.value
) {
101 parent
.opener
.document
.compose
.send_to_cc
.value
=
102 parent
.opener
.document
.compose
.send_to_cc
.value +
", " +
$addr;
104 parent
.opener
.document
.compose
.send_to_cc
.value
= $addr;
109 function bcc_address($addr) {
111 var pwintype
= typeof parent
.opener
.document
.compose
;
113 $addr = $addr.replace(/ {1,35}$
/, "");
115 if (pwintype
!= "undefined") {
116 if (parent
.opener
.document
.compose
.send_to_bcc
.value
) {
118 parent
.opener
.document
.compose
.send_to_bcc
.value
=
119 parent
.opener
.document
.compose
.send_to_bcc
.value +
", " +
$addr;
121 parent
.opener
.document
.compose
.send_to_bcc
.value
= $addr;
126 function CheckAll(ch
) {
128 for (var i
= 0; i
< document
.addressbook
.elements
.length
; i++
) {
129 chkObj
= document
.addressbook
.elements
[i
];
130 if (chkObj
.type
== "checkbox" && chkObj
.name
.substr(0,16) == "send_to_search[" + ch
) {
131 chkObj
.checked
= !(chkObj
.checked
);
138 } /* End of included JavaScript */
141 * Function to build a list of available backends for searching
144 * @author Steve Brown
147 function getBackends () {
151 $backends['-1'] = _("All address books");
152 $ret = $abook->get_backend_list();
153 foreach ($ret as $v) {
154 if ($v->btype
== 'local' && !$v->listing
) {
157 $backends[$v->bnum
] = $v->sname
;