/**
* abook_local_file.php
*
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @version $Id$
* filename => path to addressbook file
* ? create => if true: file is created if it does not exist.
* ? umask => umask set before opening file.
- * ? name => name of address book
+ * ? name => name of address book.
+ * ? detect_writeable => detect address book access permissions by
+ * 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.
class abook_local_file extends addressbook_backend {
/**
* Backend type
- * @var string
+ * @var string
*/
var $btype = 'local';
/**
* @var bool
*/
var $writeable = false;
+ /**
+ * controls listing of address book
+ * @var bool
+ */
+ var $listing = true;
/**
* Umask of the file
* @var string
if(!empty($param['writeable'])) {
$this->writeable = $param['writeable'];
}
+ if(isset($param['listing'])) {
+ $this->listing = $param['listing'];
+ }
$this->open(true);
} else {
$this->error = '';
$file = $this->filename;
$create = $this->create;
- $fopenmode = ($this->writeable ? 'a+' : 'r');
+ $fopenmode = (($this->writeable && is_writable($file)) ? 'a+' : 'r');
/* Return true is file is open and $new is unset */
if($this->filehandle && !$new) {
*/
function list_addr() {
$res = array();
+
+ if(isset($this->listing) && !$this->listing) {
+ return array();
+ }
+
$this->open();
@rewind($this->filehandle);