/** * Remove one or more types * * @return void Redirects back to main listing */ public function removeTask() { // Check for request forgeries Request::checkToken(); // Incoming (expecting an array) $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; $rtrn = Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&course=' . Request::getInt('course', 0) . '&offering=' . Request::getInt('offering', 0), false); // Ensure we have an ID to work with if (empty($ids)) { // Redirect with error message App::redirect($rtrn, Lang::txt('COM_COURSES_ERROR_NO_ENTRIES_SELECTED'), 'error'); return; } $tbl = new Tables\Page($this->database); $i = 0; foreach ($ids as $id) { // Delete the type if (!$tbl->delete($id)) { $this->setError($tbl->getError()); } else { $i++; } } // Redirect if ($i) { App::redirect($rtrn, Lang::txt('COM_COURSES_ITEMS_REMOVED', $i)); return; } App::redirect($rtrn, $this->getError(), 'error'); }