/** * Execute the action */ public function execute() { parent::execute(); // action to execute $action = \SpoonFilter::getGetValue('action', array('delete'), ''); // form id $formId = \SpoonFilter::getGetValue('form_id', null, '', 'int'); // no id's provided if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-items-selected'); } elseif ($action == '') { // no action provided $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-action-selected'); } elseif (!BackendFormBuilderModel::exists($formId)) { // valid form id $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing'); } else { // redefine id's $ids = (array) $_GET['id']; // delete comment(s) if ($action == 'delete') { BackendFormBuilderModel::deleteData($ids); } // define report $report = count($ids) > 1 ? 'items-' : 'item-'; // init var if ($action == 'delete') { $report .= 'deleted'; } // redirect $this->redirect(BackendModel::createURLForAction('Data') . '&id=' . $formId . '&report=' . $report); } }
/** * Delete entry/entries. * * @param string $id The id/ids of the entries(s) to delete. */ public static function entriesDelete($id) { // authorize if (BaseAPI::isAuthorized() && BaseAPI::isValidRequestMethod('POST')) { // redefine if (!is_array($id)) { $id = (array) explode(',', $id); } // update statuses BackendFormBuilderModel::deleteData($id); } }