/** * Allows a cron job to be set to enabled or disabled * * Params * =========================== * Required: * - name: The name of the cron job * - status: Either 'enabled' or 'disabled' * */ public function put($params) { $this->checkForEmptyParams(array('name', 'status'), $params); $status = strtolower($params['status']); if (!in_array($status, array('enabled', 'disabled'))) { throw new Ot_Exception_Data('msg-error-invalidStatus'); } $cron = new Ot_Model_DbTable_CronStatus(); return $cron->setCronStatus($params['name'], $status); }
/** * Toggles the status of the selected cron job * */ public function toggleAction() { $jobKey = $this->_getParam('jobKey', null); if (is_null($jobKey)) { throw new Ot_Exception_Input('msg-error-nameNotSet'); } $status = $this->_getParam('status', null); if (is_null($status) || !in_array($status, array('enabled', 'disabled'))) { throw new Ot_Exception_Input('Status not set in the query string'); } if ($this->_request->isPost()) { $cs = new Ot_Model_DbTable_CronStatus(); $cs->setCronStatus($jobKey, $status); $logOptions = array('attributeName' => 'cronName', 'attributeId' => $jobKey); $this->_helper->log(Zend_Log::INFO, 'Cronjob ' . $jobKey . ' was set to ' . $status . '.', $logOptions); $this->_helper->redirector->gotoRoute(array('controller' => 'cron'), 'ot', true); } else { throw new Ot_Exception_Access('You are not allowed to access this method directly'); } }