simplified notifications with index, updated the settings method, and fixed up template, sql fixes
This commit is contained in:
parent
bfd803ec28
commit
69eec05cb7
@ -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;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<span class="toggle">
|
||||
<label for="data[idle_worker]">
|
||||
<input type="hidden" name="data[idle_worker]" value="0" />
|
||||
<input type="checkbox" class="ios-switch" name="data[idle_worker]" id="data[idle_worker]" value="1"{nocache}{if $SETTINGS['idle_worker']}checked{/if}{/nocache} />
|
||||
<input type="checkbox" class="ios-switch" name="data[idle_worker]" id="data[idle_worker]" value="1"{nocache}{if $SETTINGS['idle_worker']|default:"0" == 1}checked{/if}{/nocache} />
|
||||
<div class="switch"></div>
|
||||
</label>
|
||||
</span>
|
||||
@ -30,7 +30,7 @@
|
||||
<span class="toggle">
|
||||
<label for="data[new_block]">
|
||||
<input type="hidden" name="data[new_block]" value="0" />
|
||||
<input type="checkbox" class="ios-switch" name="data[new_block]" id="data[new_block]" value="1"{nocache}{if $SETTINGS['new_block']}checked{/if}{/nocache} />
|
||||
<input type="checkbox" class="ios-switch" name="data[new_block]" id="data[new_block]" value="1"{nocache}{if $SETTINGS['new_block']|default:"0" == 1}checked{/if}{/nocache} />
|
||||
<div class="switch"></div>
|
||||
</label>
|
||||
</span>
|
||||
@ -42,7 +42,7 @@
|
||||
<span class="toggle">
|
||||
<label for="data[auto_payout]">
|
||||
<input type="hidden" name="data[auto_payout]" value="0" />
|
||||
<input type="checkbox" class="ios-switch" name="data[auto_payout]" id="data[auto_payout]" value="1"{nocache}{if $SETTINGS['auto_payout']}checked{/if}{/nocache} />
|
||||
<input type="checkbox" class="ios-switch" name="data[auto_payout]" id="data[auto_payout]" value="1"{nocache}{if $SETTINGS['auto_payout']|default:"0" == 1}checked{/if}{/nocache} />
|
||||
<div class="switch"></div>
|
||||
</label>
|
||||
</span>
|
||||
@ -54,7 +54,19 @@
|
||||
<span class="toggle">
|
||||
<label for="data[manual_payout]">
|
||||
<input type="hidden" name="data[manual_payout]" value="0" />
|
||||
<input type="checkbox" class="ios-switch" name="data[manual_payout]" id="data[manual_payout]" value="1"{nocache}{if $SETTINGS['manual_payout']}checked{/if}{/nocache} />
|
||||
<input type="checkbox" class="ios-switch" name="data[manual_payout]" id="data[manual_payout]" value="1"{nocache}{if $SETTINGS['manual_payout']|default:"0" == 1}checked{/if}{/nocache} />
|
||||
<div class="switch"></div>
|
||||
</label>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">Successful Login</td>
|
||||
<td>
|
||||
<span class="toggle">
|
||||
<label for="data[success_login]">
|
||||
<input type="hidden" name="data[success_login]" value="0" />
|
||||
<input type="checkbox" class="ios-switch" name="data[success_login]" id="data[success_login]" value="1"{nocache}{if $SETTINGS['success_login']|default:"0" == 1}checked{/if}{/nocache} />
|
||||
<div class="switch"></div>
|
||||
</label>
|
||||
</span>
|
||||
@ -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}
|
||||
</td>
|
||||
<td align="center">
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user