/** * Remove one or more citations * * @return void */ public function removeTask() { // Incoming (we're expecting an array) $ids = Request::getVar('id', array()); if (!is_array($ids)) { $ids = array($ids); } // Make sure we have IDs to work with if (count($ids) > 0) { // Loop through the IDs and delete the citation $citation = new Citation($this->database); $assoc = new Association($this->database); $author = new Author($this->database); foreach ($ids as $id) { // Fetch and delete all the associations to this citation $assocs = $assoc->getRecords(array('cid' => $id)); foreach ($assocs as $a) { $assoc->delete($a->id); } // Fetch and delete all the authors to this citation $authors = $author->getRecords(array('cid' => $id)); foreach ($authors as $a) { $author->delete($a->id); } // Delete the citation $citation->delete($id); //citation tags $ct = new Tags($id); $ct->removeAll(); } $message = Lang::txt('CITATION_REMOVED'); } else { $message = Lang::txt('NO_SELECTION'); } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, true), $message); }