/** * Remove citation * * @return boolean */ public function unattachCitation($pid = 0, $cid = 0, $returnStatus = false) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; if (!$cid || !$pid) { $this->setError(Lang::txt('PLG_PROJECTS_LINKS_NO_DOI')); if ($returnStatus) { $out['error'] = $this->getError(); return $out; } return false; } $database = App::get('db'); $c = new \Components\Citations\Tables\Citation($database); $assoc = new \Components\Citations\Tables\Association($database); // Fetch all associations $aPubs = $assoc->getRecords(array('cid' => $cid)); // Remove citation if only one association if (count($aPubs) == 1) { // Delete the citation $c->delete($cid); } // Remove association foreach ($aPubs as $aPub) { if ($aPub->oid == $pid && ($aPub->tbl = 'publication')) { $assoc->delete($aPub->id); } } if ($returnStatus) { $out['success'] = true; return $out; } return true; }