/** * Method to set the default property for a zone * * @return void */ public function defaultTask() { // Get item to default from request $id = Request::getVar('id', [], '', 'array'); if (empty($id)) { App::abort(404, Lang::txt('COM_TOOLS_ERROR_MISSING_ID')); } // Get the middleware database $mwdb = Utils::getMWDBO(); $row = new \Components\Tools\Tables\Zones($mwdb); if ($row->load($id[0])) { // Get rid of the current default $default = new \Components\Tools\Tables\Zones($mwdb); $default->load(['is_default' => 1]); $default->is_default = 0; if (!$default->store()) { App::abort(500, Lang::txt('COM_TOOLS_ERROR_DEFAULT_UPDATE_FAILED')); } // Set a new default $row->is_default = 1; if (!$row->store()) { App::abort(500, Lang::txt('COM_TOOLS_ERROR_DEFAULT_UPDATE_FAILED')); } } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }