[FIX] Clearing coin address for account

This commit is contained in:
Sebastian Grewe 2014-06-26 12:04:48 +02:00
parent 1e922829dd
commit a4e17e6a31
2 changed files with 25 additions and 3 deletions

View File

@ -51,7 +51,22 @@ class CoinAddress extends Base {
return false;
}
$stmt = $this->mysqli->prepare("INSERT INTO " . $this->getTableName() . " (account_id, currency, coin_address) VALUES (?, ?, ?)");
if ( $this->checkStmt($stmt) && $stmt->bind_param('sis', $userID, $currency, $address) && $stmt->execute()) {
if ( $this->checkStmt($stmt) && $stmt->bind_param('iss', $userID, $currency, $address) && $stmt->execute()) {
return true;
}
return $this->sqlError();
}
/**
* Remove a coin address record for a user
* @param userID int Account ID
* @param currency string Currency short handle, defaults to config option
* @return bool true or false
**/
public function remove ($userID, $currency=NULL) {
if ($currency === NULL) $currency = $this->config['currency'];
$stmt = $this->mysqli->prepare("DELETE FROM " . $this->getTableName() . " WHERE account_id = ? AND currency = ?");
if ( $this->checkStmt($stmt) && $stmt->bind_param('is', $userID, $currency) && $stmt->execute()) {
return true;
}
return $this->sqlError();

View File

@ -545,8 +545,15 @@ class User extends Base {
if ($this->checkStmt($stmt) && $stmt->bind_param('ddssii', $threshold, $donate, $email, $timezone, $is_anonymous, $userID) && $stmt->execute()) {
$this->log->log("info", $this->getUserName($userID)." updated their account details");
// Update coin address too
if ($this->coin_address->update($userID, $address))
return true;
if ($address) {
if ($this->coin_address->update($userID, $address)) {
return true;
}
} else {
if ($this->coin_address->remove($userID, $address)) {
return true;
}
}
}
// Catchall
$this->setErrorMessage('Failed to update your account');