X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=templates%2Futil_addressbook.php;h=3c2c5d62c881d39a6e58d1ce3ab18751e4a5f386;hp=ca2967b37d414f5ed99561eee2972c35e863bae4;hb=54156b1cfd60ef726191e2209fbd4306a980a03c;hpb=a71b394eb2e5ebd2c2229458d2242088807c5728;ds=inline diff --git a/templates/util_addressbook.php b/templates/util_addressbook.php index ca2967b3..3c2c5d62 100644 --- a/templates/util_addressbook.php +++ b/templates/util_addressbook.php @@ -4,7 +4,7 @@ * * Functions to make working with address books easier * - * @copyright © 1999-2006 The SquirrelMail Project Team + * @copyright © 1999-2007 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -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