+ if ($abook_sort_order < 0 or $abook_sort_order > 8)
+ $abook_sort_order=8;
+
+ setPref($data_dir, $username, 'abook_sort_order', $abook_sort_order);
+ } else {
+ /* get previous sorting options. default to unsorted */
+ $abook_sort_order = getPref($data_dir, $username, 'abook_sort_order', 8);
+ }
+
+ return $abook_sort_order;
+}
+
+/**
+ * This function shows the address book sort button.
+ *
+ * @param integer $abook_sort_order Current sort value
+ * @param string $alt_tag The alt tag value (string
+ * visible to text only browsers)
+ * @param integer $Down Sort value when list is sorted
+ * ascending
+ * @param integer $Up Sort value when list is sorted
+ * descending
+ * @param array $uri_extra Any additional parameters to add
+ * to the button's link, as an
+ * associative array of key/value pairs
+ * (OPTIONAL; default none)
+ *
+ * @return string html code with sorting images and urls
+ *
+ */
+function show_abook_sort_button($abook_sort_order, $alt_tag,
+ $Down, $Up, $uri_extra=array() ) {
+
+ global $form_url, $icon_theme_path;
+
+ /* Figure out which image we want to use. */
+ if ($abook_sort_order != $Up && $abook_sort_order != $Down) {
+ $img = 'sort_none.png';
+ $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
+ $which = $Up;
+ } elseif ($abook_sort_order == $Up) {
+ $img = 'up_pointer.png';
+ $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
+ $which = $Down;
+ } else {
+ $img = 'down_pointer.png';
+ $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
+ $which = 8;
+ }
+
+ $uri_extra['abook_sort_order'] = $which;
+ $uri = set_uri_vars($form_url, $uri_extra, FALSE);
+
+ /* Now that we have everything figured out, show the actual button. */
+ return create_hyperlink($uri,
+ getIcon($icon_theme_path, $img, $text_icon, $alt_tag),
+ '', '', '', '', '',
+ array('style' => 'text-decoration:none',
+ 'title' => $alt_tag),
+ FALSE);
+}
+
+
+/**
+ * This is the main address book class that connect all the
+ * backends and provide services to the functions above.
+ * @package squirrelmail
+ * @subpackage addressbook
+ */
+class AddressBook {
+ /**
+ * Enabled address book backends
+ * @var array
+ */