Example #1
0
 /**
  * Remove an entry
  *
  * @return  void
  */
 public function removeTask()
 {
     // Incoming
     $step = Request::getInt('step', 1);
     $step = !$step ? 1 : $step;
     // What step are we on?
     switch ($step) {
         case 1:
             Request::setVar('hidemainmenu', 1);
             // Incoming
             $id = Request::getVar('id', array(0));
             if (!is_array($id) && !empty($id)) {
                 $id = array($id);
             }
             $this->view->cId = $id;
             // Set any errors
             if ($this->getError()) {
                 $this->view->setError($this->getError());
             }
             // Output the HTML
             $this->view->display();
             break;
         case 2:
             // Check for request forgeries
             Request::checkToken() or jexit('Invalid Token');
             // Incoming
             $cIds = Request::getVar('cId', array(0));
             // Make sure we have IDs to work with
             if (empty($cIds)) {
                 App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_STOREFRONT_NO_ID'), 'error');
                 return;
             }
             $delete = Request::getVar('delete', 0);
             $msg = "Delete canceled";
             $type = 'error';
             if ($delete) {
                 // Do the delete
                 foreach ($cIds as $cId) {
                     // Delete option group
                     try {
                         $collection = new Collection($cId);
                         $collection->delete();
                     } catch (\Exception $e) {
                         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $e->getMessage(), $type);
                         return;
                     }
                 }
                 $msg = "Collection(s) deleted";
                 $type = 'message';
             }
             // Set the redirect
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $msg, $type);
             break;
     }
 }