Esempio n. 1
0
 /**
  * Removes a parent/child association
  * Redirects to parent's children listing
  *
  * @return  void
  */
 public function removechildTask()
 {
     // Incoming
     $ids = Request::getVar('id', array(0));
     $pid = Request::getInt('pid', 0);
     // Make sure we have a parent ID
     if (!$pid) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, true), Lang::txt('COM_RESOURCES_ERROR_MISSING_PARENT_ID'), 'error');
         return;
     }
     // Make sure we have children IDs
     if (!$ids || count($ids) < 1) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=children&pid=' . $pid, true), Lang::txt('COM_RESOURCES_ERROR_MISSING_CHILD_ID'), 'error');
         return;
     }
     $assoc = new Assoc($this->database);
     // Multiple IDs - loop through and delete them
     foreach ($ids as $id) {
         $assoc->delete($pid, $id);
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=children&pid=' . $pid, true), Lang::txt('COM_RESOURCES_ITEMS_REMOVED', count($ids)));
 }