diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php index b11f990c..3db6acf8 100644 --- a/public/include/classes/notification.class.php +++ b/public/include/classes/notification.class.php @@ -112,28 +112,16 @@ class Notification extends Mail { $this->debug->append("STA " . __METHOD__, 4); $failed = $ok = 0; foreach ($data as $type => $active) { - // Does an entry exist already - $stmt = $this->mysqli->prepare("SELECT * FROM $this->tableSettings WHERE account_id = ? AND type = ?"); - if ($stmt && $stmt->bind_param('is', $account_id, $type) && $stmt->execute() && $stmt->store_result() && $stmt->num_rows() > 0) { - // We found a matching row - $stmt = $this->mysqli->prepare("UPDATE $this->tableSettings SET active = ? WHERE type = ? AND account_id = ?"); - if ($stmt && $stmt->bind_param('isi', $active, $type, $account_id) && $stmt->execute() && $stmt->close()) { - $ok++; - } else { - $failed++; - } + $stmt = $this->mysqli->prepare("INSERT INTO $this->tableSettings (active, type, account_id) VALUES (?,?,?) ON DUPLICATE KEY UPDATE active = ?"); + if ($stmt && $stmt->bind_param('isii', $active, $type, $account_id, $active) && $stmt->execute()) { + $ok++; } else { - $stmt = $this->mysqli->prepare("INSERT INTO $this->tableSettings (active, type, account_id) VALUES (?,?,?)"); - if ($stmt && $stmt->bind_param('isi', $active, $type, $account_id) && $stmt->execute()) { - $ok++; - } else { - $failed++; - } + $failed++; } } if ($failed > 0) { $this->setErrorMessage($this->getErrorMsg('E0047', $failed)); - return false; + return $this->sqlError(); } return true; } diff --git a/public/templates/mpos/account/notifications/default.tpl b/public/templates/mpos/account/notifications/default.tpl index 2d1f5901..b0003f6a 100644 --- a/public/templates/mpos/account/notifications/default.tpl +++ b/public/templates/mpos/account/notifications/default.tpl @@ -18,7 +18,7 @@ @@ -30,7 +30,7 @@ @@ -42,7 +42,7 @@ @@ -54,7 +54,19 @@ + + + + + Successful Login + + + @@ -94,6 +106,7 @@ {else if $NOTIFICATIONS[notification].type == auto_payout}Auto Payout {else if $NOTIFICATIONS[notification].type == idle_worker}IDLE Worker {else if $NOTIFICATIONS[notification].type == manual_payout}Manual Payout +{else if $NOTIFICATIONS[notification].type == success_login}Successful Login {/if} diff --git a/sql/000_base_structure.sql b/sql/000_base_structure.sql index eebe28ff..f5f8685e 100644 --- a/sql/000_base_structure.sql +++ b/sql/000_base_structure.sql @@ -128,7 +128,7 @@ CREATE TABLE IF NOT EXISTS `settings` ( UNIQUE KEY `setting` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.2'); +INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.3'); CREATE TABLE IF NOT EXISTS `shares` ( `id` bigint(30) NOT NULL AUTO_INCREMENT, diff --git a/sql/013_tokentype_update.sql b/sql/013_tokentype_update.sql index d1e09e20..c19e2537 100644 --- a/sql/013_tokentype_update.sql +++ b/sql/013_tokentype_update.sql @@ -1,5 +1,7 @@ INSERT INTO `token_types` (`name`, `expiration`) VALUES ('account_edit', 360); INSERT INTO `token_types` (`name`, `expiration`) VALUES ('change_pw', 360); INSERT INTO `token_types` (`name`, `expiration`) VALUES ('withdraw_funds', 360); +CREATE INDEX `account_id` ON `notification_settings` (`account_id`); +CREATE UNIQUE INDEX `account_id_type` ON `notification_settings` (`account_id`,`type`); INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.3') ON DUPLICATE KEY UPDATE `value` = '0.0.3'; INSERT INTO `settings` (`name`, `value`) VALUES ('db_upgrade_required', 0) ON DUPLICATE KEY UPDATE `value` = 0;