public function executeCommand($cmd, $id) { echo "<p>Executing Command <b>{$cmd}</b></p>"; //$this->getController()->redirect(array('/cron/execute/sa/'.$cmd.'/id/'.$id)); $ret = false; if (method_exists($this, $cmd)) { call_user_func($cmd, $a); } if ($ret) { $test = CronJobs::model()->updateLastExecution($id, 'Success'); exit; } else { $test = CronJobs::model()->updateLastExecution($id, 'Error Generate'); } }
public function executeCommand($cmd, $id) { echo "<p>Executing Command <b>{$cmd}</b></p>"; $anObject = $this; $methodVariable = array($anObject, $cmd); var_dump(is_callable($methodVariable, true, $callable_name)); // bool(true) echo $callable_name, "\n"; // someClass::someMethod $ret = call_user_func($callable_name); if ($ret) { $test = CronJobs::model()->updateLastExecution($id, 'Success'); } else { $test = CronJobs::model()->updateLastExecution($id, 'Error Generate'); } }
public function ajaxProcessCronjobLiveExchangeRate() { $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); $moduleManager = $moduleManagerBuilder->build(); if (!$moduleManager->isInstalled('cronjobs')) { die(json_encode(array())); } $enable = (int) Tools::getValue('enable'); $config = Configuration::get('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', null, null, $this->context->shop->id); $cronJobUrl = 'http://' . ShopUrl::getMainShopDomain($this->context->shop->id) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/cron_currency_rates.php?secure_key=' . md5(_COOKIE_KEY_ . Configuration::get('PS_SHOP_NAME')); if ($config && $enable == 0) { Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0, false, null, $this->context->shop->id); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cronjobs WHERE `id_cronjob` = \'' . (int) $config . '\''); } //The cronjob is not defined, create it if ($enable == 1 && (!$config || $config == 0)) { $cronJobs = new CronJobs(); $cronJobs->addOneShotTask($cronJobUrl, sprintf($this->l('Live exchange Rate for %s'), Configuration::get('PS_SHOP_NAME'))); Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', Db::getInstance()->Insert_ID(), false, null, $this->context->shop->id); } else { $cronJob = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'cronjobs WHERE `id_cronjob` = \'' . (int) $config . '\''); //if cronjob do not exsit anymore OR cronjob dis disabled => disable conf if (!$cronJob || $cronJob[0]['active'] == 0) { Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0, false, null, $this->context->shop->id); } } die(json_encode(array())); }