/** * Sets the state of one or more entries * * @param integer $state The state to set entries to * @return void */ public function stateTask($state = 0) { // Check for request forgeries Request::checkToken(['get', 'post']); // Incoming $state = $this->_task == 'publish' ? 1 : 0; $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; // Check for an ID if (count($ids) < 1) { $action = $state == 1 ? Lang::txt('COM_CRON_STATE_UNPUBLISH') : Lang::txt('COM_CRON_STATE_PUBLISH'); App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_CRON_ERROR_SELECT_ITEMS', $action), 'error'); return; } $total = 0; foreach ($ids as $id) { // Update record(s) $row = Job::oneOrFail(intval($id)); $row->set('state', $state); if (!$row->save()) { Notify::error($row->getError()); continue; } $total++; } // Set message if ($state == 1) { Notify::success(Lang::txt('COM_CRON_ITEMS_PUBLISHED', $total)); } else { Notify::success(Lang::txt('COM_CRON_ITEMS_UNPUBLISHED', $total)); } App::redirect(Route::url('index.php?option=' . $this->_option, false)); }
/** * Sets the state of one or more entries * * @param integer $state The state to set entries to * @return void */ public function stateTask($state = 0) { // Check for request forgeries Request::checkToken(['get', 'post']); if (!User::authorise('core.edit.state', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $state = $this->_task == 'publish' ? 1 : 0; $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; // Check for an ID if (count($ids) < 1) { $action = $state == 1 ? Lang::txt('COM_CRON_STATE_UNPUBLISH') : Lang::txt('COM_CRON_STATE_PUBLISH'); Notify::warning(Lang::txt('COM_CRON_ERROR_SELECT_ITEMS', $action)); return $this->cancelTask(); } $total = 0; foreach ($ids as $id) { // Update record(s) $row = Job::oneOrFail(intval($id)); $row->set('state', $state); if (!$row->save()) { Notify::error($row->getError()); continue; } $total++; } // Set message if ($total) { if ($state == 1) { Notify::success(Lang::txt('COM_CRON_ITEMS_PUBLISHED', $total)); } else { Notify::success(Lang::txt('COM_CRON_ITEMS_UNPUBLISHED', $total)); } } $this->cancelTask(); }