diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index 4a655cabf0..71cf2895ce 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -145,6 +145,9 @@ + + + diff --git a/lib/pkp b/lib/pkp index e0b14cf1c6..94148594b3 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit e0b14cf1c6fc2afc8effbcd52b9b008aa8df0a6e +Subproject commit 94148594b3e7f830780d482eb1f4f39e910118a8 diff --git a/plugins/generic/citationStyleLanguage b/plugins/generic/citationStyleLanguage index c7e90faf16..97c5752329 160000 --- a/plugins/generic/citationStyleLanguage +++ b/plugins/generic/citationStyleLanguage @@ -1 +1 @@ -Subproject commit c7e90faf16ac230e1869bcf51c3beb89203113b8 +Subproject commit 97c5752329e4c5b7b01915b66e6e00c234eddab7 diff --git a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php index b82d270ba7..8969ed858d 100755 --- a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php +++ b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php @@ -28,6 +28,7 @@ use APP\publicationFormat\PublicationFormat; use APP\section\Section; use APP\submission\Submission; +use PKP\controlledVocab\ControlledVocab; use PKP\db\DAORegistry; use PKP\facades\Locale; use PKP\i18n\LocaleConversion; @@ -35,8 +36,6 @@ use PKP\metadata\MetadataDescription; use PKP\plugins\Hook; use PKP\plugins\PluginRegistry; -use PKP\submission\SubmissionKeywordDAO; -use PKP\submission\SubmissionSubjectDAO; class Dc11SchemaPublicationFormatAdapter extends MetadataDataObjectAdapter { @@ -99,12 +98,20 @@ public function extractMetadataFromDataObject(&$publicationFormat) } // Subject - $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); /** @var SubmissionKeywordDAO $submissionKeywordDao */ - $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); /** @var SubmissionSubjectDAO $submissionSubjectDao */ $supportedLocales = array_keys(Locale::getSupportedFormLocales()); $subjects = array_merge_recursive( - (array) $submissionKeywordDao->getKeywords($publication->getId(), $supportedLocales), - (array) $submissionSubjectDao->getSubjects($publication->getId(), $supportedLocales) + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, + Application::ASSOC_TYPE_PUBLICATION, + $publication->getId(), + $supportedLocales + ), + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT, + Application::ASSOC_TYPE_PUBLICATION, + $publication->getId(), + $supportedLocales + ) ); $this->_addLocalizedElements($dc11Description, 'dc:subject', $subjects); diff --git a/plugins/reports/monographReport/Report.php b/plugins/reports/monographReport/Report.php index b834821acf..34e6a71380 100644 --- a/plugins/reports/monographReport/Report.php +++ b/plugins/reports/monographReport/Report.php @@ -32,14 +32,10 @@ use Illuminate\Support\LazyCollection; use IteratorAggregate; use PKP\category\Category; -use PKP\db\DAORegistry; +use PKP\controlledVocab\ControlledVocab; use PKP\facades\Locale; use PKP\security\Role; use PKP\stageAssignment\StageAssignment; -use PKP\submission\SubmissionAgencyDAO; -use PKP\submission\SubmissionDisciplineDAO; -use PKP\submission\SubmissionKeywordDAO; -use PKP\submission\SubmissionSubjectDAO; use PKP\user\User; use PKP\userGroup\UserGroup; use Traversable; @@ -368,9 +364,13 @@ private function getStatus(): string */ private function getKeywords(): string { - /** @var SubmissionKeywordDAO */ - $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); - return $this->flattenKeywords($submissionKeywordDao->getKeywords($this->publication->getId())); + return $this->flattenKeywords( + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, + Application::ASSOC_TYPE_PUBLICATION, + $this->publication->getId() + ) + ); } /** @@ -378,9 +378,13 @@ private function getKeywords(): string */ private function getSubjects(): string { - /** @var SubmissionSubjectDAO */ - $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); - return $this->flattenKeywords($submissionSubjectDao->getSubjects($this->publication->getId())); + return $this->flattenKeywords( + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT, + Application::ASSOC_TYPE_PUBLICATION, + $this->publication->getId() + ) + ); } /** @@ -388,9 +392,13 @@ private function getSubjects(): string */ private function getDisciplines(): string { - /** @var SubmissionDisciplineDAO */ - $submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO'); - return $this->flattenKeywords($submissionDisciplineDao->getDisciplines($this->publication->getId())); + return $this->flattenKeywords( + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE, + Application::ASSOC_TYPE_PUBLICATION, + $this->publication->getId() + ) + ); } /** @@ -398,9 +406,13 @@ private function getDisciplines(): string */ private function getAgencies(): string { - /** @var SubmissionAgencyDAO */ - $submissionAgencyDao = DAORegistry::getDAO('SubmissionAgencyDAO'); - return $this->flattenKeywords($submissionAgencyDao->getAgencies($this->publication->getId())); + return $this->flattenKeywords( + Repo::controlledVocab()->getBySymbolic( + ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY, + Application::ASSOC_TYPE_PUBLICATION, + $this->publication->getId() + ) + ); } /** diff --git a/plugins/reports/reviewReport b/plugins/reports/reviewReport index 14906b4ced..0481ed0af9 160000 --- a/plugins/reports/reviewReport +++ b/plugins/reports/reviewReport @@ -1 +1 @@ -Subproject commit 14906b4ced04cbce66d6d8404a56bca9664b8d82 +Subproject commit 0481ed0af93d3cfb38431e4c755572775a397755 diff --git a/tools/cleanReviewerInterests.php b/tools/cleanReviewerInterests.php index fbfc7a5c52..2c44645fbe 100755 --- a/tools/cleanReviewerInterests.php +++ b/tools/cleanReviewerInterests.php @@ -14,11 +14,12 @@ * @brief CLI tool to remove user interests that are not referenced by any user accounts. */ +use APP\core\Application; +use APP\facades\Repo; +use Illuminate\Support\Collection; use PKP\cliTool\CommandLineTool; -use PKP\controlledVocab\ControlledVocabDAO; -use PKP\controlledVocab\ControlledVocabEntryDAO; -use PKP\db\DAORegistry; -use PKP\user\InterestDAO; +use PKP\controlledVocab\ControlledVocabEntry; +use PKP\user\interest\UserInterest; require(dirname(__FILE__) . '/bootstrap.php'); @@ -60,7 +61,7 @@ public function usage() public function execute() { $orphans = $this->_getOrphanVocabInterests(); - if (!count($orphans)) { + if ($orphans->count() === 0) { echo "No user interests to remove.\n"; exit(0); } @@ -68,20 +69,13 @@ public function execute() $command = $this->parameters[0]; switch ($command) { case '--show': - $interests = array_map(function ($entry) { - return $entry->getData(InterestDAO::CONTROLLED_VOCAB_INTEREST); - }, $orphans); + $interests = $orphans->pluck(UserInterest::CONTROLLED_VOCAB_INTEREST)->toArray(); echo "Below are the user interests that are not referenced by any user account.\n"; echo "\t" . join("\n\t", $interests) . "\n"; break; case '--remove': - /** @var ControlledVocabEntryDAO */ - $vocabEntryDao = DAORegistry::getDAO('ControlledVocabEntryDAO'); - foreach ($orphans as $orphanVocab) { - $vocabEntryDao->deleteObject($orphanVocab); - } - echo count($orphans) . " entries deleted\n"; + echo $orphans->toQuery()->delete() . " entries deleted\n"; break; default: @@ -93,50 +87,19 @@ public function execute() /** * Returns user interests that are not referenced - * - * @return array array of ControlledVocabEntry object */ - protected function _getOrphanVocabInterests() + protected function _getOrphanVocabInterests(): Collection { - /** @var InterestDAO */ - $interestDao = DAORegistry::getDAO('InterestDAO'); - /** @var ControlledVocabDAO */ - $vocabDao = DAORegistry::getDAO('ControlledVocabDAO'); - /** @var ControlledVocabEntryDAO */ - $vocabEntryDao = DAORegistry::getDAO('ControlledVocabEntryDAO'); - - $interestVocab = $vocabDao->getBySymbolic(InterestDAO::CONTROLLED_VOCAB_INTEREST); - $vocabEntryIterator = $vocabEntryDao->getByControlledVocabId($interestVocab->getId()); - $vocabEntryList = $vocabEntryIterator->toArray(); - - // list of vocab interests in db - $allInterestVocabIds = array_map( - function ($entry) { - return $entry->getId(); - }, - $vocabEntryList - ); - - // list of vocabs associated to users - $interests = $interestDao->getAllInterests(); - $userInterestVocabIds = array_map( - function ($interest) { - return $interest->getId(); - }, - $interests->toArray() - ); - - // get the difference - $diff = array_diff($allInterestVocabIds, $userInterestVocabIds); - - $orphans = array_filter( - $vocabEntryList, - function ($entry) use ($diff) { - return in_array($entry->getId(), $diff); - } + $controlledVocab = Repo::controlledVocab()->build( + UserInterest::CONTROLLED_VOCAB_INTEREST, + Application::ASSOC_TYPE_SITE, + Application::SITE_CONTEXT_ID, ); - return $orphans; + return ControlledVocabEntry::query() + ->withControlledVocabId($controlledVocab->id) + ->whereDoesntHave('userInterest') + ->get(); } }