** $Id$
**/
- require_once("DB.php");
+ require_once('DB.php');
class abook_database extends addressbook_backend {
- var $btype = "local";
- var $bname = "database";
+ var $btype = 'local';
+ var $bname = 'database';
- var $dsn = "";
- var $table = "";
- var $owner = "";
+ var $dsn = '';
+ var $table = '';
+ var $owner = '';
var $dbh = false;
var $writeable = true;
// Constructor
function abook_database($param) {
- $this->sname = _('Personal address book');
+ $this->sname = _("Personal address book");
if(is_array($param)) {
if(empty($param['dsn']) ||
$dbh = DB::connect($this->dsn, true);
if(DB::isError($dbh) || DB::isWarning($dbh))
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($dbh)));
$this->dbh = $dbh;
if(is_array($expr)) return;
// Make regexp from glob'ed expression
- $expr = ereg_replace('\?', '_', $expr);
- $expr = ereg_replace('\*'. '%', $expr);
+ $expr = ereg_replace('\\?', '_', $expr);
+ $expr = ereg_replace('\\*'. '%', $expr);
$expr = $this->dbh->quoteString($expr);
$expr = "%$expr%";
$res = $this->dbh->query($query);
if(DB::isError($res))
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($res)));
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
$res = $this->dbh->query($query);
if(DB::isError($res))
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($res)));
if ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
$res = $this->dbh->query($query);
if(DB::isError($res))
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($res)));
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
// Add address
function add($userdata) {
if(!$this->writeable)
- return $this->set_error(_('Addressbook is read-only'));
+ return $this->set_error(_("Addressbook is read-only"));
if(!$this->open())
return false;
// See if user exist already
$ret = $this->lookup($userdata['nickname']);
if(!empty($ret))
- return $this->set_error(sprintf(_('User \'%s\' already exist'),
+ return $this->set_error(sprintf(_("User '%s' already exist"),
$ret['nickname']));
// Create query
if($r == DB_OK) return true;
// Fail
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($r)));
}
// Delete address
function remove($alias) {
if(!$this->writeable)
- return $this->set_error(_('Addressbook is read-only'));
+ return $this->set_error(_("Addressbook is read-only"));
if(!$this->open())
return false;
if($r == DB_OK) return true;
// Fail
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($r)));
}
// Modify address
function modify($alias, $userdata) {
if(!$this->writeable)
- return $this->set_error(_('Addressbook is read-only'));
+ return $this->set_error(_("Addressbook is read-only"));
if(!$this->open())
return false;
// See if user exist
$ret = $this->lookup($alias);
if(empty($ret))
- return $this->set_error(sprintf(_('User \'%s\' does not exist'),
+ return $this->set_error(sprintf(_("User '%s' does not exist"),
$alias));
// Create query
if($r == DB_OK) return true;
// Fail
- return $this->set_error(sprintf(_('Database error: %s'),
+ return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($r)));
}
} // End of class abook_database