From 5f6b20c9c39c5ddc3e9f180fee7e8725efc39a59 Mon Sep 17 00:00:00 2001 From: jGissinger Date: Thu, 2 Mar 2017 10:04:30 +0100 Subject: [PATCH] fix cast issue --- classes/CronJobsForms.php | 8 ++--- controllers/admin/AdminCronJobsController.php | 10 +++---- cronjobs.php | 30 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/classes/CronJobsForms.php b/classes/CronJobsForms.php index e239137..f889a0d 100644 --- a/classes/CronJobsForms.php +++ b/classes/CronJobsForms.php @@ -64,7 +64,7 @@ public static function getJobForm($title = 'New cron task', $update = false) if (($update == true) && (Tools::isSubmit('id_cronjob'))) { $id_cronjob = (int)Tools::getValue('id_cronjob'); - $id_module = (int)Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.self::$module->name.'` + $id_module = (int)Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.bqSQL(self::$module->name).'` WHERE `id_cronjob` = \''.(int)$id_cronjob.'\' AND `id_shop` = \''.$id_shop.'\' AND `id_shop_group` = \''.$id_shop_group.'\''); @@ -252,7 +252,7 @@ public static function getUpdateJobFormValues() $id_shop_group = (int)Context::getContext()->shop->id_shop_group; $id_cronjob = (int)Tools::getValue('id_cronjob'); - $cron = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.self::$module->name.'` + $cron = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.bqSQL(self::$module->name).'` WHERE `id_cronjob` = \''.$id_cronjob.'\' AND `id_shop` = \''.$id_shop.'\' AND `id_shop_group` = \''.$id_shop_group.'\''); @@ -281,14 +281,14 @@ public static function getTasksListValues() $id_shop_group = (int)Context::getContext()->shop->id_shop_group; self::$module->addNewModulesTasks(); - $crons = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.self::$module->name.'` WHERE `id_shop` = \''.$id_shop.'\' AND `id_shop_group` = \''.$id_shop_group.'\''); + $crons = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.bqSQL(self::$module->name).'` WHERE `id_shop` = \''.$id_shop.'\' AND `id_shop_group` = \''.$id_shop_group.'\''); foreach ($crons as $key => &$cron) { if (empty($cron['id_module']) == false) { $module = Module::getInstanceById((int)$cron['id_module']); if ($module == false) { - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.self::$module->name.' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.bqSQL(self::$module->name).' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); unset($crons[$key]); break; } diff --git a/controllers/admin/AdminCronJobsController.php b/controllers/admin/AdminCronJobsController.php index a487520..6e1d130 100644 --- a/controllers/admin/AdminCronJobsController.php +++ b/controllers/admin/AdminCronJobsController.php @@ -53,7 +53,7 @@ public function postProcess() protected function runModulesCrons() { - $query = 'SELECT * FROM '._DB_PREFIX_.$this->module->name.' WHERE `active` = 1 AND `id_module` IS NOT NULL'; + $query = 'SELECT * FROM '._DB_PREFIX_.bqSQL($this->module->name).' WHERE `active` = 1 AND `id_module` IS NOT NULL'; $crons = Db::getInstance()->executeS($query); if (is_array($crons) && (count($crons) > 0)) { @@ -61,11 +61,11 @@ protected function runModulesCrons() $module = Module::getInstanceById((int)$cron['id_module']); if ($module == false) { - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->module->name.' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.bqSQL($this->module->name).' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); break; } elseif ($this->shouldBeExecuted($cron) == true) { Hook::exec('actionCronJob', array(), $cron['id_module']); - $query = 'UPDATE '._DB_PREFIX_.$this->module->name.' SET `updated_at` = NOW(), `active` = IF (`one_shot` = TRUE, FALSE, `active`) WHERE `id_cronjob` = \''.$cron['id_cronjob'].'\''; + $query = 'UPDATE '._DB_PREFIX_.bqSQL($this->module->name).' SET `updated_at` = NOW(), `active` = IF (`one_shot` = TRUE, FALSE, `active`) WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''; Db::getInstance()->execute($query); } } @@ -74,14 +74,14 @@ protected function runModulesCrons() protected function runTasksCrons() { - $query = 'SELECT * FROM '._DB_PREFIX_.$this->module->name.' WHERE `active` = 1 AND `id_module` IS NULL'; + $query = 'SELECT * FROM '._DB_PREFIX_.bqSQL($this->module->name).' WHERE `active` = 1 AND `id_module` IS NULL'; $crons = Db::getInstance()->executeS($query); if (is_array($crons) && (count($crons) > 0)) { foreach ($crons as &$cron) { if ($this->shouldBeExecuted($cron) == true) { Tools::file_get_contents(urldecode($cron['task']), false); - $query = 'UPDATE '._DB_PREFIX_.$this->module->name.' SET `updated_at` = NOW(), `active` = IF (`one_shot` = TRUE, FALSE, `active`) WHERE `id_cronjob` = \''.$cron['id_cronjob'].'\''; + $query = 'UPDATE '._DB_PREFIX_.bqSQL($this->module->name).' SET `updated_at` = NOW(), `active` = IF (`one_shot` = TRUE, FALSE, `active`) WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''; Db::getInstance()->execute($query); } } diff --git a/cronjobs.php b/cronjobs.php index ca4a164..15e30bd 100755 --- a/cronjobs.php +++ b/cronjobs.php @@ -131,7 +131,7 @@ public function uninstall() public function installDb() { return Db::getInstance()->execute( - 'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.$this->name.' ( + 'CREATE TABLE IF NOT EXISTS '._DB_PREFIX_.bqSQL($this->name).' ( `id_cronjob` INTEGER(10) NOT NULL AUTO_INCREMENT, `id_module` INTEGER(10) DEFAULT NULL, `description` TEXT DEFAULT NULL, @@ -153,7 +153,7 @@ public function installDb() public function uninstallDb() { - return Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.$this->name); + return Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.bqSQL($this->name)); } public function installTab() @@ -454,7 +454,7 @@ protected function postProcessNewJob() $month = (int)Tools::getValue('month'); $day_of_week = (int)Tools::getValue('day_of_week'); - $result = Db::getInstance()->getRow('SELECT id_cronjob FROM '._DB_PREFIX_.$this->name.' + $result = Db::getInstance()->getRow('SELECT id_cronjob FROM '._DB_PREFIX_.bqSQL($this->name).' WHERE `task` = \''.$task.'\' AND `hour` = \''.$hour.'\' AND `day` = \''.$day.'\' AND `month` = \''.$month.'\' AND `day_of_week` = \''.$day_of_week.'\''); @@ -462,7 +462,7 @@ protected function postProcessNewJob() $id_shop = (int)Context::getContext()->shop->id; $id_shop_group = (int)Context::getContext()->shop->id_shop_group; - $query = 'INSERT INTO '._DB_PREFIX_.$this->name.' + $query = 'INSERT INTO '._DB_PREFIX_.bqSQL($this->name).' (`description`, `task`, `hour`, `day`, `month`, `day_of_week`, `updated_at`, `active`, `id_shop`, `id_shop_group`) VALUES (\''.$description.'\', \''.$task.'\', \''.$hour.'\', \''.$day.'\', \''.$month.'\', \''.$day_of_week.'\', NULL, TRUE, '.$id_shop.', '.$id_shop_group.')'; @@ -495,7 +495,7 @@ protected function postProcessUpdateJob() // $id_shop = (int)Context::getContext()->shop->id; // $id_shop_group = (int)Context::getContext()->shop->id_shop_group; - $query = 'UPDATE '._DB_PREFIX_.$this->name.' + $query = 'UPDATE '._DB_PREFIX_.bqSQL($this->name).' SET `description` = \''.$description.'\', `task` = \''.$task.'\', `hour` = \''.$hour.'\', @@ -526,11 +526,11 @@ public function addNewModulesTasks() $module = Module::getInstanceById((int)$cron['id_module']); if ($module == false) { - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->name.' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.bqSQL($this->name).' WHERE `id_cronjob` = \''.(int)$cron['id_cronjob'].'\''); break; } - $cronjob = (bool)Db::getInstance()->getValue('SELECT `id_cronjob` FROM `'._DB_PREFIX_.$this->name.'` + $cronjob = (bool)Db::getInstance()->getValue('SELECT `id_cronjob` FROM `'._DB_PREFIX_.bqSQL($this->name).'` WHERE `id_module` = \''.$id_module.'\' AND `id_shop` = \''.$id_shop.'\' AND `id_shop_group` = \''.$id_shop_group.'\''); if ($cronjob == false) { @@ -549,7 +549,7 @@ protected function postProcessUpdateJobOneShot() // $id_shop = (int)Context::getContext()->shop->id; // $id_shop_group = (int)Context::getContext()->shop->id_shop_group; - Db::getInstance()->execute('UPDATE '._DB_PREFIX_.$this->name.' + Db::getInstance()->execute('UPDATE '._DB_PREFIX_.bqSQL($this->name).' SET `one_shot` = IF (`one_shot`, 0, 1) WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) @@ -567,7 +567,7 @@ protected function postProcessUpdateJobStatus() // $id_shop = (int)Context::getContext()->shop->id; // $id_shop_group = (int)Context::getContext()->shop->id_shop_group; - Db::getInstance()->execute('UPDATE '._DB_PREFIX_.$this->name.' + Db::getInstance()->execute('UPDATE '._DB_PREFIX_.bqSQL($this->name).' SET `active` = IF (`active`, 0, 1) WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) @@ -709,12 +709,12 @@ protected function updateWebservice($use_webservice) protected function postProcessDeleteCronJob($id_cronjob) { $id_cronjob = Tools::getValue('id_cronjob'); - $id_module = Db::getInstance()->getValue('SELECT `id_module` FROM '._DB_PREFIX_.$this->name.' WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); + $id_module = Db::getInstance()->getValue('SELECT `id_module` FROM '._DB_PREFIX_.bqSQL($this->name).' WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); if ((bool)$id_module == false) { - Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->name.' WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.bqSQL($this->name).' WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); } else { - Db::getInstance()->execute('UPDATE '._DB_PREFIX_.$this->name.' SET `active` = FALSE WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); + Db::getInstance()->execute('UPDATE '._DB_PREFIX_.bqSQL($this->name).' SET `active` = FALSE WHERE `id_cronjob` = \''.(int)$id_cronjob.'\''); } return Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) @@ -731,13 +731,13 @@ protected function registerModuleHook($id_module) if (is_callable(array($module, 'getCronFrequency')) == true) { $frequency = $module->getCronFrequency(); - $query = 'INSERT INTO '._DB_PREFIX_.$this->name.' + $query = 'INSERT INTO '._DB_PREFIX_.bqSQL($this->name).' (`id_module`, `hour`, `day`, `month`, `day_of_week`, `active`, `id_shop`, `id_shop_group`) VALUES (\''.$id_module.'\', \''.$frequency['hour'].'\', \''.$frequency['day'].'\', \''.$frequency['month'].'\', \''.$frequency['day_of_week'].'\', TRUE, '.$id_shop.', '.$id_shop_group.')'; } else { - $query = 'INSERT INTO '._DB_PREFIX_.$this->name.' + $query = 'INSERT INTO '._DB_PREFIX_.bqSQL($this->name).' (`id_module`, `active`, `id_shop`, `id_shop_group`) VALUES ('.$id_module.', FALSE, '.$id_shop.', '.$id_shop_group.')'; } @@ -747,6 +747,6 @@ protected function registerModuleHook($id_module) protected function unregisterModuleHook($id_module) { - return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->name.' WHERE `id_module` = \''.(int)$id_module.'\''); + return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.bqSQL($this->name).' WHERE `id_module` = \''.(int)$id_module.'\''); } }