- Removes unused method from Settings model
- Renames method to delete value
This commit is contained in:
@ -42,7 +42,7 @@ class CronHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function deleteDaemon() {
|
static function deleteDaemon() {
|
||||||
return Setting::deleteSetting(self::DAEMON_SETTING);
|
return Setting::deleteValue(self::DAEMON_SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createToken() {
|
static function createToken() {
|
||||||
|
@ -8,30 +8,30 @@ if(!defined('ABSPATH')) exit;
|
|||||||
class MailerLog {
|
class MailerLog {
|
||||||
const MAILER_LOG_CONFIG = 'mta_log';
|
const MAILER_LOG_CONFIG = 'mta_log';
|
||||||
|
|
||||||
static function getMailerLog() {
|
static function getMailerLog() {
|
||||||
$mailer_log = Setting::getValue(self::MAILER_LOG_CONFIG);
|
$mailer_log = Setting::getValue(self::MAILER_LOG_CONFIG);
|
||||||
if(!$mailer_log) {
|
if(!$mailer_log) {
|
||||||
$mailer_log = self::createOrResetMailerLog();
|
$mailer_log = self::createOrResetMailerLog();
|
||||||
|
}
|
||||||
|
return $mailer_log;
|
||||||
}
|
}
|
||||||
return $mailer_log;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function createOrResetMailerLog() {
|
static function createOrResetMailerLog() {
|
||||||
$mailer_log = array(
|
$mailer_log = array(
|
||||||
'sent' => 0,
|
'sent' => 0,
|
||||||
'started' => time()
|
'started' => time()
|
||||||
);
|
);
|
||||||
Setting::setValue(self::MAILER_LOG_CONFIG, $mailer_log);
|
Setting::setValue(self::MAILER_LOG_CONFIG, $mailer_log);
|
||||||
return $mailer_log;
|
return $mailer_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function updateMailerLog($mailer_log) {
|
static function updateMailerLog($mailer_log) {
|
||||||
Setting::setValue(self::MAILER_LOG_CONFIG, $mailer_log);
|
Setting::setValue(self::MAILER_LOG_CONFIG, $mailer_log);
|
||||||
return $mailer_log;
|
return $mailer_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function isSendingLimitReached() {
|
static function isSendingLimitReached() {
|
||||||
$mailer_config = Mailer::getMailerConfig();
|
$mailer_config = Mailer::getMailerConfig();
|
||||||
$mailer_log = self::getMailerLog();
|
$mailer_log = self::getMailerLog();
|
||||||
$elapsed_time = time() - (int)$mailer_log['started'];
|
$elapsed_time = time() - (int)$mailer_log['started'];
|
||||||
if($mailer_log['sent'] === $mailer_config['frequency_limit'] &&
|
if($mailer_log['sent'] === $mailer_config['frequency_limit'] &&
|
||||||
|
@ -161,12 +161,8 @@ class Setting extends Model {
|
|||||||
return $setting->save();
|
return $setting->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSetting($setting) {
|
public static function deleteValue($value) {
|
||||||
return self::where('name', $setting)->findOne();
|
$value = self::where('name', $value)->findOne();
|
||||||
}
|
return ($value) ? $value->delete() : false;
|
||||||
|
|
||||||
public static function deleteSetting($setting) {
|
|
||||||
$setting = self::where('name', $setting)->findOne();
|
|
||||||
return ($setting) ? $setting->delete() : false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user