/** * Save changes to an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); $recurrence = array(); if (isset($fields['minute'])) { $recurrence[] = $fields['minute']['c'] ? $fields['minute']['c'] : $fields['minute']['s']; } if (isset($fields['hour'])) { $recurrence[] = $fields['hour']['c'] ? $fields['hour']['c'] : $fields['hour']['s']; } if (isset($fields['day'])) { $recurrence[] = $fields['day']['c'] ? $fields['day']['c'] : $fields['day']['s']; } if (isset($fields['month'])) { $recurrence[] = $fields['month']['c'] ? $fields['month']['c'] : $fields['month']['s']; } if (isset($fields['dayofweek'])) { $recurrence[] = $fields['dayofweek']['c'] ? $fields['dayofweek']['c'] : $fields['dayofweek']['s']; } if (!empty($recurrence)) { $fields['recurrence'] = implode(' ', $recurrence); } unset($fields['minute']); unset($fields['hour']); unset($fields['day']); unset($fields['month']); unset($fields['dayofweek']); // Initiate extended database class $row = Job::oneOrNew($fields['id'])->set($fields); if ($row->get('recurrence')) { $row->set('next_run', $row->nextRun()); } $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post')); $row->set('params', $p->toString()); // Store content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_CRON_ITEM_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }
/** * Save changes to an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $fields = Request::getVar('fields', array(), 'post'); $recurrence = array(); if (isset($fields['minute'])) { $recurrence[] = $fields['minute']['c'] ? $fields['minute']['c'] : $fields['minute']['s']; } if (isset($fields['hour'])) { $recurrence[] = $fields['hour']['c'] ? $fields['hour']['c'] : $fields['hour']['s']; } if (isset($fields['day'])) { $recurrence[] = $fields['day']['c'] ? $fields['day']['c'] : $fields['day']['s']; } if (isset($fields['month'])) { $recurrence[] = $fields['month']['c'] ? $fields['month']['c'] : $fields['month']['s']; } if (isset($fields['dayofweek'])) { $recurrence[] = $fields['dayofweek']['c'] ? $fields['dayofweek']['c'] : $fields['dayofweek']['s']; } if (!empty($recurrence)) { $fields['recurrence'] = implode(' ', $recurrence); } unset($fields['minute']); unset($fields['hour']); unset($fields['day']); unset($fields['month']); unset($fields['dayofweek']); // Initiate extended database class $row = Job::oneOrNew($fields['id'])->set($fields); if ($row->get('recurrence')) { $row->set('next_run', $row->nextRun()); } $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post')); $row->set('params', $p->toString()); // Store content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_CRON_ITEM_SAVED')); // If the task was "apply", // fall back through to the edit form. if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect $this->cancelTask(); }