6 * Supported database schema
8 * owner varchar(128) NOT NULL
9 * nickname varchar(16) NOT NULL
10 * firstname varchar(128)
11 * lastname varchar(128)
12 * email varchar(128) NOT NULL
14 * PRIMARY KEY (owner,nickname)
17 * @copyright 1999-2016 The SquirrelMail Project Team
18 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
20 * @package squirrelmail
21 * @subpackage addressbook
25 * Needs either PDO or the DB functions
26 * Don't display errors here. Error will be set in class constructor function.
28 global $use_pdo, $disable_pdo;
29 if (empty($disable_pdo) && class_exists('PDO'))
35 @include_once
('DB.php');
38 * Address book in a database backend
40 * Backend for personal/shared address book stored in a database,
41 * accessed using the DB-classes in PEAR or PDO, the latter taking
42 * precedence if available..
44 * IMPORTANT: If PDO is not available (it should be installed by
45 * default since PHP 5.1), then the PEAR modules must
46 * be in the include path for this class to work.
48 * An array with the following elements must be passed to
49 * the class constructor (elements marked ? are optional):
51 * dsn => database DNS (see PEAR for syntax, but more or
52 * less it is: mysql://user:pass@hostname/dbname)
53 * table => table to store addresses in (must exist)
54 * owner => current user (owner of address data)
55 * ? name => name of address book
56 * ? writeable => set writeable flag (true/false)
57 * ? listing => enable/disable listing
59 * The table used should have the following columns:
60 * owner, nickname, firstname, lastname, email, label
61 * The pair (owner,nickname) should be unique (primary key).
63 * NOTE. This class should not be used directly. Use the
64 * "AddressBook" class instead.
66 * Three settings that control PDO behavior can be specified in
67 * config/config_local.php if needed:
68 * boolean $disable_pdo SquirrelMail uses PDO by default to access the
69 * user preferences and address book databases, but
70 * setting this to TRUE will cause SquirrelMail to
71 * fall back to using Pear DB instead.
72 * boolean $pdo_show_sql_errors When database errors are encountered,
73 * setting this to TRUE causes the actual
74 * database error to be displayed, otherwise
75 * generic errors are displayed, preventing
76 * internal database information from being
77 * exposed. This should be enabled only for
79 * string $pdo_identifier_quote_char By default, SquirrelMail will quote
80 * table and field names in database
81 * queries with what it thinks is the
82 * appropriate quote character for the
83 * database type being used (backtick
84 * for MySQL (and thus MariaDB), double
85 * quotes for all others), but you can
86 * override the character used by
87 * putting it here, or tell SquirrelMail
88 * NOT to quote identifiers by setting
91 * @package squirrelmail
92 * @subpackage addressbook
94 class abook_database
extends addressbook_backend
{
104 var $bname = 'database';
107 * Data Source Name (connection description)
113 * Character used to quote database table
117 var $identifier_quote_char = '';
120 * Table that stores addresses
127 * Limits list of database entries visible to end user
137 * Enable/disable writing into address book
140 var $writeable = true;
142 * Enable/disable address book listing
147 /* ========================== Private ======================= */
151 * @param array $param address book backend options
153 function abook_database($param) {
154 $this->sname
= _("Personal Address Book");
156 /* test if PDO or Pear DB classes are available and freak out if necessary */
158 if (!$use_pdo && !class_exists('DB')) {
159 // same error also in db_prefs.php
160 $error = _("Could not find or include PHP PDO or PEAR database functions required for the database backend.") . "\n";
161 $error .= sprintf(_("PDO should come preinstalled with PHP version 5.1 or higher. Otherwise, is PEAR installed, and is the include path set correctly to find %s?"), 'DB.php') . "\n";
162 $error .= _("Please contact your system administrator and report this error.");
163 return $this->set_error($error);
166 if (is_array($param)) {
167 if (empty($param['dsn']) ||
168 empty($param['table']) ||
169 empty($param['owner'])) {
170 return $this->set_error('Invalid parameters');
173 $this->dsn
= $param['dsn'];
174 $this->table
= $param['table'];
175 $this->owner
= $param['owner'];
177 if (!empty($param['name'])) {
178 $this->sname
= $param['name'];
181 if (isset($param['writeable'])) {
182 $this->writeable
= $param['writeable'];
185 if (isset($param['listing'])) {
186 $this->listing
= $param['listing'];
189 // figure out identifier quoting (only used for PDO, though we could change that)
190 global $pdo_identifier_quote_char;
191 if (empty($pdo_identifier_quote_char)) {
192 if (strpos($this->dsn
, 'mysql') === 0)
193 $this->identifier_quote_char
= '`';
195 $this->identifier_quote_char
= '"';
196 } else if ($pdo_identifier_quote_char === 'none')
197 $this->identifier_quote_char
= '';
199 $this->identifier_quote_char
= $pdo_identifier_quote_char;
205 return $this->set_error('Invalid argument to constructor');
212 * @param bool $new new connection if it is true
215 function open($new = false) {
219 /* Return true is file is open and $new is unset */
220 if ($this->dbh
&& !$new) {
224 /* Close old file, if any */
230 // parse and convert DSN to PDO style
231 // $matches will contain:
237 //TODO: add support for unix_socket and charset
238 if (!preg_match('|^(.+)://(.+):(.+)@(.+)/(.+)$|i', $this->dsn
, $matches)) {
239 return $this->set_error(_("Could not parse prefs DSN"));
241 if (preg_match('|^(.+):(\d+)$|', $matches[4], $host_port_matches)) {
242 $matches[4] = $host_port_matches[1];
243 $matches[6] = $host_port_matches[2];
246 $pdo_prefs_dsn = $matches[1] . ':host=' . $matches[4] . (!empty($matches[6]) ?
';port=' . $matches[6] : '') . ';dbname=' . $matches[5];
248 $dbh = new PDO($pdo_prefs_dsn, $matches[2], $matches[3]);
249 } catch (Exception
$e) {
250 return $this->set_error(sprintf(_("Database error: %s"), $e->getMessage()));
253 $dbh->setAttribute(PDO
::ATTR_CASE
, PDO
::CASE_LOWER
);
256 $dbh = DB
::connect($this->dsn
, true);
258 if (DB
::isError($dbh)) {
259 return $this->set_error(sprintf(_("Database error: %s"),
260 DB
::errorMessage($dbh)));
264 * field names are lowercased.
265 * We use unquoted identifiers and they use upper case in Oracle
267 $dbh->setOption('portability', DB_PORTABILITY_LOWERCASE
);
275 * Close the file and forget the filehandle
282 $this->dbh
->disconnect();
288 * Determine internal database field name given one of
289 * the SquirrelMail SM_ABOOK_FIELD_* constants
291 * @param integer $field The SM_ABOOK_FIELD_* contant to look up
293 * @return string The desired field name, or the string "ERROR"
294 * if the $field is not understood (the caller
295 * is responsible for handing errors)
298 function get_field_name($field) {
300 case SM_ABOOK_FIELD_NICKNAME
:
302 case SM_ABOOK_FIELD_FIRSTNAME
:
304 case SM_ABOOK_FIELD_LASTNAME
:
306 case SM_ABOOK_FIELD_EMAIL
:
308 case SM_ABOOK_FIELD_LABEL
:
315 /* ========================== Public ======================== */
318 * Search the database
320 * Backend supports only * and ? wildcards. Complex eregs are not supported.
321 * Search is case insensitive.
322 * @param string $expr search expression
323 * @return array search results. boolean false on error
325 function search($expr) {
331 /* To be replaced by advanded search expression parsing */
332 if (is_array($expr)) {
336 // don't allow wide search when listing is disabled.
337 if ($expr=='*' && ! $this->listing
)
340 /* lowercase expression in order to make it case insensitive */
341 $expr = strtolower($expr);
343 /* escape SQL wildcards */
344 $expr = str_replace('_', '\\_', $expr);
345 $expr = str_replace('%', '\\%', $expr);
347 /* Convert wildcards to SQL syntax */
348 $expr = str_replace('?', '_', $expr);
349 $expr = str_replace('*', '%', $expr);
353 global $use_pdo, $pdo_show_sql_errors;
355 if (!($sth = $this->dbh
->prepare('SELECT * FROM ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' WHERE ' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ' = ? AND (LOWER(' . $this->identifier_quote_char
. 'firstname' . $this->identifier_quote_char
. ') LIKE ? ESCAPE ? OR LOWER(' . $this->identifier_quote_char
. 'lastname' . $this->identifier_quote_char
. ') LIKE ? ESCAPE ? OR LOWER(' . $this->identifier_quote_char
. 'email' . $this->identifier_quote_char
. ') LIKE ? ESCAPE ? OR LOWER(' . $this->identifier_quote_char
. 'nickname' . $this->identifier_quote_char
. ') LIKE ? ESCAPE ?)'))) {
356 if ($pdo_show_sql_errors)
357 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
359 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
361 if (!($res = $sth->execute(array($this->owner
, $expr, '\\', $expr, '\\', $expr, '\\', $expr, '\\')))) {
362 if ($pdo_show_sql_errors)
363 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
365 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
368 while ($row = $sth->fetch(PDO
::FETCH_ASSOC
)) {
369 array_push($ret, array('nickname' => $row['nickname'],
370 'name' => $this->fullname($row['firstname'], $row['lastname']),
371 'firstname' => $row['firstname'],
372 'lastname' => $row['lastname'],
373 'email' => $row['email'],
374 'label' => $row['label'],
375 'backend' => $this->bnum
,
376 'source' => &$this->sname
));
380 $expr = $this->dbh
->quoteString($expr);
382 /* create escape expression */
383 $escape = 'ESCAPE \'' . $this->dbh
->quoteString('\\') . '\'';
385 $query = sprintf("SELECT * FROM %s WHERE owner='%s' AND " .
386 "(LOWER(firstname) LIKE '%s' %s " .
387 "OR LOWER(lastname) LIKE '%s' %s " .
388 "OR LOWER(email) LIKE '%s' %s " .
389 "OR LOWER(nickname) LIKE '%s' %s)",
390 $this->table
, $this->owner
, $expr, $escape, $expr, $escape,
391 $expr, $escape, $expr, $escape);
392 $res = $this->dbh
->query($query);
394 if (DB
::isError($res)) {
395 return $this->set_error(sprintf(_("Database error: %s"),
396 DB
::errorMessage($res)));
399 while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC
)) {
400 array_push($ret, array('nickname' => $row['nickname'],
401 'name' => $this->fullname($row['firstname'], $row['lastname']),
402 'firstname' => $row['firstname'],
403 'lastname' => $row['lastname'],
404 'email' => $row['email'],
405 'label' => $row['label'],
406 'backend' => $this->bnum
,
407 'source' => &$this->sname
));
414 * Lookup an address by the indicated field.
416 * @param string $value The value to look up
417 * @param integer $field The field to look in, should be one
418 * of the SM_ABOOK_FIELD_* constants
419 * defined in include/constants.php
420 * (OPTIONAL; defaults to nickname field)
421 * NOTE: uniqueness is only guaranteed
422 * when the nickname field is used here;
423 * otherwise, the first matching address
426 * @return array Array with lookup results when the value
427 * was found, an empty array if the value was
431 function lookup($value, $field=SM_ABOOK_FIELD_NICKNAME
) {
436 $value = strtolower($value);
438 if (!$this->open()) {
442 $db_field = $this->get_field_name($field);
443 if ($db_field == 'ERROR') {
444 return $this->set_error(sprintf(_("Unknown field name: %s"), $field));
447 global $use_pdo, $pdo_show_sql_errors;
449 if (!($sth = $this->dbh
->prepare('SELECT * FROM ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' WHERE ' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ' = ? AND LOWER(' . $this->identifier_quote_char
. $db_field . $this->identifier_quote_char
. ') = ?'))) {
450 if ($pdo_show_sql_errors)
451 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
453 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
455 if (!($res = $sth->execute(array($this->owner
, $value)))) {
456 if ($pdo_show_sql_errors)
457 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
459 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
462 if ($row = $sth->fetch(PDO
::FETCH_ASSOC
)) {
463 return array('nickname' => $row['nickname'],
464 'name' => $this->fullname($row['firstname'], $row['lastname']),
465 'firstname' => $row['firstname'],
466 'lastname' => $row['lastname'],
467 'email' => $row['email'],
468 'label' => $row['label'],
469 'backend' => $this->bnum
,
470 'source' => &$this->sname
);
474 $query = sprintf("SELECT * FROM %s WHERE owner = '%s' AND LOWER(%s) = '%s'",
475 $this->table
, $this->owner
, $db_field,
476 $this->dbh
->quoteString($value));
478 $res = $this->dbh
->query($query);
480 if (DB
::isError($res)) {
481 return $this->set_error(sprintf(_("Database error: %s"),
482 DB
::errorMessage($res)));
485 if ($row = $res->fetchRow(DB_FETCHMODE_ASSOC
)) {
486 return array('nickname' => $row['nickname'],
487 'name' => $this->fullname($row['firstname'], $row['lastname']),
488 'firstname' => $row['firstname'],
489 'lastname' => $row['lastname'],
490 'email' => $row['email'],
491 'label' => $row['label'],
492 'backend' => $this->bnum
,
493 'source' => &$this->sname
);
502 * @return array search results
504 function list_addr() {
506 if (!$this->open()) {
510 if(isset($this->listing
) && !$this->listing
) {
515 global $use_pdo, $pdo_show_sql_errors;
517 if (!($sth = $this->dbh
->prepare('SELECT * FROM ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' WHERE ' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ' = ?'))) {
518 if ($pdo_show_sql_errors)
519 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
521 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
523 if (!($res = $sth->execute(array($this->owner
)))) {
524 if ($pdo_show_sql_errors)
525 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
527 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
530 while ($row = $sth->fetch(PDO
::FETCH_ASSOC
)) {
531 array_push($ret, array('nickname' => $row['nickname'],
532 'name' => $this->fullname($row['firstname'], $row['lastname']),
533 'firstname' => $row['firstname'],
534 'lastname' => $row['lastname'],
535 'email' => $row['email'],
536 'label' => $row['label'],
537 'backend' => $this->bnum
,
538 'source' => &$this->sname
));
541 $query = sprintf("SELECT * FROM %s WHERE owner='%s'",
542 $this->table
, $this->owner
);
544 $res = $this->dbh
->query($query);
546 if (DB
::isError($res)) {
547 return $this->set_error(sprintf(_("Database error: %s"),
548 DB
::errorMessage($res)));
551 while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC
)) {
552 array_push($ret, array('nickname' => $row['nickname'],
553 'name' => $this->fullname($row['firstname'], $row['lastname']),
554 'firstname' => $row['firstname'],
555 'lastname' => $row['lastname'],
556 'email' => $row['email'],
557 'label' => $row['label'],
558 'backend' => $this->bnum
,
559 'source' => &$this->sname
));
568 * @param array $userdata added data
571 function add($userdata) {
572 if (!$this->writeable
) {
573 return $this->set_error(_("Address book is read-only"));
576 if (!$this->open()) {
580 // NB: if you want to check for some unwanted characters
581 // or other problems, do so here like this:
582 // TODO: Should pull all validation code out into a separate function
583 //if (strpos($userdata['nickname'], ' ')) {
584 // return $this->set_error(_("Nickname contains illegal characters"));
587 /* See if user exist already */
588 $ret = $this->lookup($userdata['nickname']);
590 return $this->set_error(sprintf(_("User \"%s\" already exists"), $ret['nickname']));
593 global $use_pdo, $pdo_show_sql_errors;
595 if (!($sth = $this->dbh
->prepare('INSERT INTO ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' (' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ', ' . $this->identifier_quote_char
. 'nickname' . $this->identifier_quote_char
. ', ' . $this->identifier_quote_char
. 'firstname' . $this->identifier_quote_char
. ', ' . $this->identifier_quote_char
. 'lastname' . $this->identifier_quote_char
. ', ' . $this->identifier_quote_char
. 'email' . $this->identifier_quote_char
. ', ' . $this->identifier_quote_char
. 'label' . $this->identifier_quote_char
. ') VALUES (?, ?, ?, ?, ?, ?)'))) {
596 if ($pdo_show_sql_errors)
597 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
599 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
601 if (!($res = $sth->execute(array($this->owner
, $userdata['nickname'], $userdata['firstname'], (!empty($userdata['lastname']) ?
$userdata['lastname'] : ''), $userdata['email'], (!empty($userdata['label']) ?
$userdata['label'] : ''))))) {
602 if ($pdo_show_sql_errors)
603 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
605 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
609 $query = sprintf("INSERT INTO %s (owner, nickname, firstname, " .
610 "lastname, email, label) VALUES('%s','%s','%s'," .
612 $this->table
, $this->owner
,
613 $this->dbh
->quoteString($userdata['nickname']),
614 $this->dbh
->quoteString($userdata['firstname']),
615 $this->dbh
->quoteString((!empty($userdata['lastname'])?
$userdata['lastname']:'')),
616 $this->dbh
->quoteString($userdata['email']),
617 $this->dbh
->quoteString((!empty($userdata['label'])?
$userdata['label']:'')) );
620 $r = $this->dbh
->simpleQuery($query);
622 /* Check for errors */
623 if (DB
::isError($r)) {
624 return $this->set_error(sprintf(_("Database error: %s"),
625 DB
::errorMessage($r)));
633 * Deletes address book entries
634 * @param array $alias aliases that have to be deleted. numerical
635 * array with nickname values
638 function remove($alias) {
639 if (!$this->writeable
) {
640 return $this->set_error(_("Address book is read-only"));
643 if (!$this->open()) {
647 global $use_pdo, $pdo_show_sql_errors;
651 $where_clause_args = array();
652 while (list($undef, $nickname) = each($alias)) {
653 $where_clause .= $sepstr . $this->identifier_quote_char
. 'nickname' . $this->identifier_quote_char
. ' = ?';
654 $where_clause_args[] = $nickname;
657 if (!($sth = $this->dbh
->prepare('DELETE FROM ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' WHERE ' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ' = ? AND (' . $where_clause . ')'))) {
658 if ($pdo_show_sql_errors)
659 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
661 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
663 array_unshift($where_clause_args, $this->owner
);
664 if (!($res = $sth->execute($where_clause_args))) {
665 if ($pdo_show_sql_errors)
666 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
668 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
672 $query = sprintf("DELETE FROM %s WHERE owner='%s' AND (",
673 $this->table
, $this->owner
);
676 while (list($undef, $nickname) = each($alias)) {
677 $query .= sprintf("%s nickname='%s' ", $sepstr,
678 $this->dbh
->quoteString($nickname));
684 $r = $this->dbh
->simpleQuery($query);
686 /* Check for errors */
687 if (DB
::isError($r)) {
688 return $this->set_error(sprintf(_("Database error: %s"),
689 DB
::errorMessage($r)));
698 * @param string $alias modified alias
699 * @param array $userdata new data
702 function modify($alias, $userdata) {
703 if (!$this->writeable
) {
704 return $this->set_error(_("Address book is read-only"));
707 if (!$this->open()) {
711 // NB: if you want to check for some unwanted characters
712 // or other problems, do so here like this:
713 // TODO: Should pull all validation code out into a separate function
714 //if (strpos($userdata['nickname'], ' ')) {
715 // return $this->set_error(_("Nickname contains illegal characters"));
718 /* See if user exist */
719 $ret = $this->lookup($alias);
721 return $this->set_error(sprintf(_("User \"%s\" does not exist"),$alias));
724 /* make sure that new nickname is not used */
725 if (strtolower($alias) != strtolower($userdata['nickname'])) {
726 /* same check as in add() */
727 $ret = $this->lookup($userdata['nickname']);
729 $error = sprintf(_("User '%s' already exist."), $ret['nickname']);
730 return $this->set_error($error);
734 global $use_pdo, $pdo_show_sql_errors;
736 if (!($sth = $this->dbh
->prepare('UPDATE ' . $this->identifier_quote_char
. $this->table
. $this->identifier_quote_char
. ' SET ' . $this->identifier_quote_char
. 'nickname' . $this->identifier_quote_char
. ' = ?, ' . $this->identifier_quote_char
. 'firstname' . $this->identifier_quote_char
. ' = ?, ' . $this->identifier_quote_char
. 'lastname' . $this->identifier_quote_char
. ' = ?, ' . $this->identifier_quote_char
. 'email' . $this->identifier_quote_char
. ' = ?, ' . $this->identifier_quote_char
. 'label' . $this->identifier_quote_char
. ' = ? WHERE ' . $this->identifier_quote_char
. 'owner' . $this->identifier_quote_char
. ' = ? AND ' . $this->identifier_quote_char
. 'nickname' . $this->identifier_quote_char
. ' = ?'))) {
737 if ($pdo_show_sql_errors)
738 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh
->errorInfo())));
740 return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
742 if (!($res = $sth->execute(array($userdata['nickname'], $userdata['firstname'], (!empty($userdata['lastname']) ?
$userdata['lastname'] : ''), $userdata['email'], (!empty($userdata['label']) ?
$userdata['label'] : ''), $this->owner
, $alias)))) {
743 if ($pdo_show_sql_errors)
744 return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
746 return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
750 $query = sprintf("UPDATE %s SET nickname='%s', firstname='%s', ".
751 "lastname='%s', email='%s', label='%s' ".
752 "WHERE owner='%s' AND nickname='%s'",
754 $this->dbh
->quoteString($userdata['nickname']),
755 $this->dbh
->quoteString($userdata['firstname']),
756 $this->dbh
->quoteString((!empty($userdata['lastname'])?
$userdata['lastname']:'')),
757 $this->dbh
->quoteString($userdata['email']),
758 $this->dbh
->quoteString((!empty($userdata['label'])?
$userdata['label']:'')),
760 $this->dbh
->quoteString($alias) );
763 $r = $this->dbh
->simpleQuery($query);
765 /* Check for errors */
766 if (DB
::isError($r)) {
767 return $this->set_error(sprintf(_("Database error: %s"),
768 DB
::errorMessage($r)));
774 } /* End of class abook_database */