From e59a9c4148c8ab83f9a4bc9b7aef7a3a5de385ea Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 20 Mar 2005 10:06:45 +0000 Subject: [PATCH] adding listing controls to file backend git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9080 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/abook_local_file.php | 14 ++++++++++++++ functions/addressbook.php | 15 ++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/functions/abook_local_file.php b/functions/abook_local_file.php index d22114f6..6d6a636b 100644 --- a/functions/abook_local_file.php +++ b/functions/abook_local_file.php @@ -26,6 +26,7 @@ * checking file permissions. * ? writeable => allow writing into address book. Used only when * detect_writeable is set to false. + * ? listing => enable/disable listing * * 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; + /** + * controls listing of address book + * @var bool + */ + var $listing = true; /** * 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(isset($param['listing'])) { + $this->listing = $param['listing']; + } $this->open(true); } else { @@ -315,6 +324,11 @@ class abook_local_file extends addressbook_backend { */ function list_addr() { $res = array(); + + if(isset($this->listing) && !$this->listing) { + return array(); + } + $this->open(); @rewind($this->filehandle); diff --git a/functions/addressbook.php b/functions/addressbook.php index af819f15..54e16d01 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -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; - 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 */ @@ -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 @@ -90,10 +93,12 @@ function addressbook_init($showerr = true, $onlylocal = false) { } 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, - '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) { -- 2.25.1