Exemplo n.º 1
0
 /**
  * Removes a course and all associated information
  *
  * @return	void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     $num = 0;
     // Do we have any IDs?
     if (!empty($ids)) {
         foreach ($ids as $id) {
             // Load the course page
             $model = new \Components\Courses\Models\Assetgroup($id);
             // Ensure we found the course info
             if (!$model->exists()) {
                 continue;
             }
             // Delete course
             if (!$model->delete()) {
                 throw new Exception(Lang::txt('COM_COURSES_ERROR_UNABLE_TO_REMOVE_ENTRY'), 500);
             }
             $num++;
         }
     }
     // Redirect back to the courses page
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&unit=' . Request::getInt('unit', 0), false), Lang::txt('COM_COURSES_ITEMS_REMOVED', $num));
 }