From: stevetruckstuff Date: Tue, 15 Aug 2006 15:43:55 +0000 (+0000) Subject: Add more functions for address book templating X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=abced421cdc854a9286098d1f7c927442d9068c8;p=squirrelmail.git Add more functions for address book templating git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11591 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/templates/util_addressbook.php b/templates/util_addressbook.php index ca2967b3..09cde519 100644 --- a/templates/util_addressbook.php +++ b/templates/util_addressbook.php @@ -69,4 +69,125 @@ function composeLink ($row) { rawurlencode($row['FullAddress']), htmlspecialchars($row['Email'])); } + +/** + * Format the address book into a format that is easy for template authors + * to use + * + * @param array $addresses all contacts as given by calling $abook->list_addr() + * @return array + * @author Steve Brown + * @since 1.5.2 + */ +function formatAddressList ($addresses) { + if (!is_array($addresses) || count($addresses) == 0) + return array(); + + $contacts = array(); + while(list($undef,$row) = each($addresses)) { + $contact = array ( + 'FirstName' => htmlspecialchars($row['firstname']), + 'LastName' => htmlspecialchars($row['lastname']), + 'FullName' => htmlspecialchars($row['name']), + 'NickName' => htmlspecialchars($row['nickname']), + 'Email' => htmlspecialchars($row['email']), + 'FullAddress' => htmlspecialchars(AddressBook::full_address($row)), + 'Info' => htmlspecialchars($row['label']), + 'Extra' => (isset($row['extra']) ? $row['extra'] : NULL), + 'Source' => htmlspecialchars($row['source']), + 'JSEmail' => htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES), + ); + $contacts[] = $contact; + } + + return $contacts; +} + +/** + * Function to include JavaScript code + * @return void + */ +function insert_javascript() { + ?> + +get_backend_list(); + while (list($undef,$v) = each($ret)) { + $backends[$v->bnum] = $v->sname; + } + + return $backends; +} ?> \ No newline at end of file