adding listing controls to file backend
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 20 Mar 2005 10:06:45 +0000 (10:06 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 20 Mar 2005 10:06:45 +0000 (10:06 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9080 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/abook_local_file.php
functions/addressbook.php

index d22114f6c4b0d636eebb5d2ff2bcb1f4e13a85ba..6d6a636b737f86c21e2d5dd22c20a90a0406d4c9 100644 (file)
@@ -26,6 +26,7 @@
  *                checking file permissions.
  * ? writeable => allow writing into address book. Used only when
  *                detect_writeable is set to false.
  *                checking file permissions.
  * ? writeable => allow writing into address book. Used only when
  *                detect_writeable is set to false.
+ * ? listing   => enable/disable listing
  *</pre>
  * NOTE. This class should not be used directly. Use the
  *       "AddressBook" class instead.
  *</pre>
  * NOTE. This class should not be used directly. Use the
  *       "AddressBook" class instead.
@@ -70,6 +71,11 @@ class abook_local_file extends addressbook_backend {
      * @var bool
      */
     var $writeable = false;
      * @var bool
      */
     var $writeable = false;
+    /**
+     * controls listing of address book
+     * @var bool
+     */
+    var $listing = true;
     /**
      * Umask of the file
      * @var string
     /**
      * Umask of the file
      * @var string
@@ -113,6 +119,9 @@ class abook_local_file extends addressbook_backend {
             if(!empty($param['writeable'])) {
                 $this->writeable = $param['writeable'];
             }
             if(!empty($param['writeable'])) {
                 $this->writeable = $param['writeable'];
             }
+            if(isset($param['listing'])) {
+                $this->listing = $param['listing'];
+            }
 
             $this->open(true);
         } else {
 
             $this->open(true);
         } else {
@@ -315,6 +324,11 @@ class abook_local_file extends addressbook_backend {
      */
     function list_addr() {
         $res = array();
      */
     function list_addr() {
         $res = array();
+
+        if(isset($this->listing) && !$this->listing) {
+            return array();
+        }
+
         $this->open();
         @rewind($this->filehandle);
 
         $this->open();
         @rewind($this->filehandle);
 
index af819f15cd56823263605992907c7395db882896..54e16d015ce1585f21312b139ea8bb4028990e93 100644 (file)
@@ -35,7 +35,7 @@ global $addrbook_dsn, $addrbook_global_dsn;
 function addressbook_init($showerr = true, $onlylocal = false) {
     global $data_dir, $username, $color, $ldap_server, $address_book_global_filename;
     global $addrbook_dsn, $addrbook_table;
 function addressbook_init($showerr = true, $onlylocal = false) {
     global $data_dir, $username, $color, $ldap_server, $address_book_global_filename;
     global $addrbook_dsn, $addrbook_table;
-    global $abook_global_file, $abook_global_file_writeable;
+    global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing;
     global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
 
     /* Create a new addressbook object */
     global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
 
     /* Create a new addressbook object */
@@ -72,9 +72,12 @@ function addressbook_init($showerr = true, $onlylocal = false) {
 
     }
 
 
     }
 
-    /* This would be for the global addressbook */
-    if (isset($abook_global_file) && isset($abook_global_file_writeable)
-        && trim($abook_global_file)!=''){
+    /* Global file based addressbook */
+    if (isset($abook_global_file) && 
+        isset($abook_global_file_writeable) &&
+        isset($abook_global_file_listing) &&
+        trim($abook_global_file)!=''){
+
         // Detect place of address book
         if (! preg_match("/[\/\\\]/",$abook_global_file)) {
             /* no path chars, address book stored in data directory
         // Detect place of address book
         if (! preg_match("/[\/\\\]/",$abook_global_file)) {
             /* no path chars, address book stored in data directory
@@ -90,10 +93,12 @@ function addressbook_init($showerr = true, $onlylocal = false) {
         } else {
             $abook_global_filename=SM_PATH . $abook_global_file;
         }
         } else {
             $abook_global_filename=SM_PATH . $abook_global_file;
         }
+
         $r = $abook->add_backend('local_file',array('filename'=>$abook_global_filename,
                                                     'name' => _("Global address book"),
                                                     'detect_writeable' => false,
         $r = $abook->add_backend('local_file',array('filename'=>$abook_global_filename,
                                                     'name' => _("Global address book"),
                                                     'detect_writeable' => false,
-                                                    'writeable'=> $abook_global_file_writeable));
+                                                    'writeable'=> $abook_global_file_writeable,
+                                                    'listing' => $abook_global_file_listing));
 
         /* global abook init error is not fatal. add error message and continue */
         if (!$r && $showerr) {
 
         /* global abook init error is not fatal. add error message and continue */
         if (!$r && $showerr) {