Adding template for error box.
[squirrelmail.git] / functions / addressbook.php
index b8d1408e7a50bb0549e22db151b2f8ff1a37223c..863d7d811a9afde643d0dea111b8905229e93d64 100644 (file)
@@ -3,11 +3,10 @@
 /**
  * functions/addressbook.php - Functions and classes for the addressbook system
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * Functions require SM_PATH and support of forms.php functions
  *
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  * @subpackage addressbook
@@ -21,8 +20,9 @@ if (!defined('SM_PATH'))  {
     define('SM_PATH','../');
 }
 
-/* make sure that display_messages.php is loaded */
+/* required includes */
 include_once(SM_PATH . 'functions/display_messages.php');
+include_once(SM_PATH . 'templates/util_global.php');
 
 global $addrbook_dsn, $addrbook_global_dsn;
 
@@ -191,7 +191,7 @@ function abook_create_form($form_url,$name,$title,$button,$defdata=array()) {
 }
 
 
-/*
+/**
  *   Had to move this function outside of the Addressbook Class
  *   PHP 4.0.4 Seemed to be having problems with inline functions.
  *   Note: this can return now since we don't support 4.0.4 anymore.
@@ -386,7 +386,7 @@ function get_abook_sort() {
  * @return string html code with sorting images and urls
  */
 function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
-    global $form_url;
+    global $form_url, $icon_theme_path;
 
      /* Figure out which image we want to use. */
     if ($abook_sort_order != $Up && $abook_sort_order != $Down) {
@@ -400,11 +400,11 @@ function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
         $which = 8;
     }
 
-      /* Now that we have everything figured out, show the actual button. */
-    return ' <a href="' . $form_url .'?abook_sort_order=' . $which
-         . '"><img src="../images/' . $img
-         . '" border="0" width="12" height="10" alt="' . $alt_tag . '" title="'
-         . _("Click here to change the sorting of the address list") .'" /></a>';
+    /* Now that we have everything figured out, show the actual button. */
+    return ' <a href="' . $form_url .'?abook_sort_order=' . $which .
+           '">' .
+           getIcon($icon_theme_path, $img, $alt_tag, _("Click here to change the sorting of the address list")) .
+           '</a>';
 }
 
 
@@ -421,7 +421,6 @@ class AddressBook {
        Errors from the backend are cleaned up in this class because we not always
        have control over it when error output is generated in the backend.
        If this appears to be wrong place then clean it up at the source (the backend)
-       Possible problems, translated strings in utf8?  (stekkel)
     */
 
     /**
@@ -449,6 +448,20 @@ class AddressBook {
      * @var string
      */
     var $localbackendname = '';
+    /**
+     * Controls use of 'extra' field
+     * 
+     * Extra field can be used to add link to form, which allows 
+     * to modify all fields supported by backend. This is the only field 
+     * that is not sanitized with htmlspecialchars. Backends MUST make
+     * sure that field data is sanitized and displayed correctly inside
+     * table cell. Use of html formating in other address book fields is
+     * not allowed. Backends that don't return 'extra' row in address book 
+     * data should not modify this object property.
+     * @var boolean
+     * @since 1.5.1
+     */
+    var $add_extra_field = false;
 
     /**
      * Constructor function.
@@ -609,7 +622,7 @@ class AddressBook {
             if (is_array($res)) {
                return $res;
             } else {
-               $this->error = htmlspecialchars($backend->error);
+               $this->error = htmlspecialchars($this->backends[$bnum]->error);
                return false;
             }
         }
@@ -866,6 +879,10 @@ class addressbook_backend {
 
     /**
      * Search for entries in backend
+     *
+     * Working backend should support use of wildcards. * symbol 
+     * should match one or more symbols. ? symbol should match any
+     * single symbol.  
      * @param string $expression
      * @return bool
      */
@@ -886,6 +903,9 @@ class addressbook_backend {
 
     /**
      * List all entries in backend
+     *
+     * Working backend should provide this function or at least
+     * dummy function that returns empty array.
      * @return bool
      */
     function list_addr() {
@@ -948,4 +968,4 @@ if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
  */
 do_hook('abook_add_class');
 
-?>
\ No newline at end of file
+?>