+ return $this->set_error(sprintf(_("User \"%s\" already exists"), $ret['nickname']));
+ }
+
+ global $use_pdo, $pdo_show_sql_errors;
+ if ($use_pdo) {
+ 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 (?, ?, ?, ?, ?, ?)'))) {
+ if ($pdo_show_sql_errors)
+ return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $this->dbh->errorInfo())));
+ else
+ return $this->set_error(sprintf(_("Database error: %s"), _("Could not prepare query")));
+ }
+ if (!($res = $sth->execute(array($this->owner, $userdata['nickname'], $userdata['firstname'], (!empty($userdata['lastname']) ? $userdata['lastname'] : ''), $userdata['email'], (!empty($userdata['label']) ? $userdata['label'] : ''))))) {
+ if ($pdo_show_sql_errors)
+ return $this->set_error(sprintf(_("Database error: %s"), implode(' - ', $sth->errorInfo())));
+ else
+ return $this->set_error(sprintf(_("Database error: %s"), _("Could not execute query")));
+ }
+ } else {
+ /* Create query */
+ $query = sprintf("INSERT INTO %s (owner, nickname, firstname, " .
+ "lastname, email, label) VALUES('%s','%s','%s'," .
+ "'%s','%s','%s')",
+ $this->table, $this->owner,
+ $this->dbh->quoteString($userdata['nickname']),
+ $this->dbh->quoteString($userdata['firstname']),
+ $this->dbh->quoteString((!empty($userdata['lastname'])?$userdata['lastname']:'')),
+ $this->dbh->quoteString($userdata['email']),
+ $this->dbh->quoteString((!empty($userdata['label'])?$userdata['label']:'')) );
+
+ /* Do the insert */
+ $r = $this->dbh->simpleQuery($query);
+
+ /* Check for errors */
+ if (DB::isError($r)) {
+ return $this->set_error(sprintf(_("Database error: %s"),
+ DB::errorMessage($r)));
+ }