From d54c21f11cb8a5cb070d32a0036a1f39d792147e Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Thu, 30 May 2024 12:11:53 +0300 Subject: [PATCH] pkp/pkp-lib#8700 Namespaced PubObjectsExportPlugin constants (cherry picked from commit 8657b9838fc1676b553b0a21eea146511211d24e) --- classes/plugins/PubObjectsExportPlugin.php | 52 +++++++++++-------- classes/submission/DAO.php | 7 +-- ...ortRepresentationsListGridCellProvider.php | 3 +- ...IdExportRepresentationsListGridHandler.php | 2 +- ...blishedSubmissionsListGridCellProvider.php | 3 +- ...ortPublishedSubmissionsListGridHandler.php | 3 +- 6 files changed, 42 insertions(+), 28 deletions(-) diff --git a/classes/plugins/PubObjectsExportPlugin.php b/classes/plugins/PubObjectsExportPlugin.php index 91e0253a17..c429daabfc 100644 --- a/classes/plugins/PubObjectsExportPlugin.php +++ b/classes/plugins/PubObjectsExportPlugin.php @@ -43,23 +43,20 @@ use PKP\submission\PKPSubmission; use PKP\user\User; -// The statuses. -define('EXPORT_STATUS_ANY', ''); -define('EXPORT_STATUS_NOT_DEPOSITED', 'notDeposited'); -define('EXPORT_STATUS_MARKEDREGISTERED', 'markedRegistered'); -define('EXPORT_STATUS_REGISTERED', 'registered'); - -// The actions. -define('EXPORT_ACTION_EXPORT', 'export'); -define('EXPORT_ACTION_MARKREGISTERED', 'markRegistered'); -define('EXPORT_ACTION_DEPOSIT', 'deposit'); - -// Configuration errors. -define('EXPORT_CONFIG_ERROR_SETTINGS', 0x02); - abstract class PubObjectsExportPlugin extends ImportExportPlugin { - /** @var PubObjectCache */ + // The statuses + public const EXPORT_STATUS_ANY = ''; + public const EXPORT_STATUS_NOT_DEPOSITED = 'notDeposited'; + public const EXPORT_STATUS_MARKEDREGISTERED = 'markedRegistered'; + public const EXPORT_STATUS_REGISTERED = 'registered'; + // The actions + public const EXPORT_ACTION_EXPORT = 'export'; + public const EXPORT_ACTION_MARKREGISTERED = 'markRegistered'; + public const EXPORT_ACTION_DEPOSIT = 'deposit'; + // Configuration errors. + public const EXPORT_CONFIG_ERROR_SETTINGS = 2; /** @var PubObjectCache */ + public $_cache; /** @@ -355,10 +352,10 @@ public function getRepresentationFilter() public function getStatusNames() { return [ - EXPORT_STATUS_ANY => __('plugins.importexport.common.status.any'), - EXPORT_STATUS_NOT_DEPOSITED => __('plugins.importexport.common.status.notDeposited'), - EXPORT_STATUS_MARKEDREGISTERED => __('plugins.importexport.common.status.markedRegistered'), - EXPORT_STATUS_REGISTERED => __('plugins.importexport.common.status.registered'), + PubObjectsExportPlugin::EXPORT_STATUS_ANY => __('plugins.importexport.common.status.any'), + PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED => __('plugins.importexport.common.status.notDeposited'), + PubObjectsExportPlugin::EXPORT_STATUS_MARKEDREGISTERED => __('plugins.importexport.common.status.markedRegistered'), + PubObjectsExportPlugin::EXPORT_STATUS_REGISTERED => __('plugins.importexport.common.status.registered'), ]; } @@ -459,7 +456,7 @@ public function exportXML($objects, $filter, $context, $noValidation = null, &$o public function markRegistered($context, $objects) { foreach ($objects as $object) { - $object->setData($this->getDepositStatusSettingName(), EXPORT_STATUS_MARKEDREGISTERED); + $object->setData($this->getDepositStatusSettingName(), PubObjectsExportPlugin::EXPORT_STATUS_MARKEDREGISTERED); $this->updateObject($object); } } @@ -568,7 +565,7 @@ public function getUnregisteredPreprints($context) null, null, $this->getDepositStatusSettingName(), - EXPORT_STATUS_NOT_DEPOSITED, + PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED, null ); return $preprints->toArray(); @@ -857,4 +854,17 @@ protected function _checkForExportAction(string $exportAction): bool if (!PKP_STRICT_MODE) { class_alias('\APP\plugins\PubObjectsExportPlugin', '\PubObjectExportsPlugin'); + + foreach ([ + 'EXPORT_STATUS_ANY', + 'EXPORT_STATUS_NOT_DEPOSITED', + 'EXPORT_STATUS_MARKEDREGISTERED', + 'EXPORT_STATUS_REGISTERED', + 'EXPORT_ACTION_EXPORT', + 'EXPORT_ACTION_MARKREGISTERED', + 'EXPORT_ACTION_DEPOSIT', + 'EXPORT_CONFIG_ERROR_SETTINGS', + ] as $constantName) { + define($constantName, constant('\PubObjectsExportPlugin::' . $constantName)); + } } diff --git a/classes/submission/DAO.php b/classes/submission/DAO.php index d86ff29b57..88d79fc2ca 100644 --- a/classes/submission/DAO.php +++ b/classes/submission/DAO.php @@ -13,6 +13,7 @@ namespace APP\submission; +use APP\plugins\PubObjectsExportPlugin; use PKP\db\DAOResultFactory; use PKP\db\DBResultRange; use PKP\identity\Identity; @@ -72,7 +73,7 @@ public function getExportable( if ($issueId) { $params[] = $issueId; } - if ($pubIdSettingName && $pubIdSettingValue && $pubIdSettingValue != EXPORT_STATUS_NOT_DEPOSITED) { + if ($pubIdSettingName && $pubIdSettingValue && $pubIdSettingValue != PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED) { $params[] = $pubIdSettingValue; } @@ -92,8 +93,8 @@ public function getExportable( . ($pubIdType != null ? ' AND pspidt.setting_name = ? AND pspidt.setting_value IS NOT NULL' : '') . ($title != null ? ' AND (pst.setting_name = ? AND pst.setting_value LIKE ?)' : '') . ($author != null ? ' AND (asgs.setting_value LIKE ? OR asfs.setting_value LIKE ?)' : '') - . (($pubIdSettingName != null && $pubIdSettingValue != null && $pubIdSettingValue == EXPORT_STATUS_NOT_DEPOSITED) ? ' AND pss.setting_value IS NULL' : '') - . (($pubIdSettingName != null && $pubIdSettingValue != null && $pubIdSettingValue != EXPORT_STATUS_NOT_DEPOSITED) ? ' AND pss.setting_value = ?' : '') + . (($pubIdSettingName != null && $pubIdSettingValue != null && $pubIdSettingValue == PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED) ? ' AND pss.setting_value IS NULL' : '') + . (($pubIdSettingName != null && $pubIdSettingValue != null && $pubIdSettingValue != PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED) ? ' AND pss.setting_value = ?' : '') . (($pubIdSettingName != null && is_null($pubIdSettingValue)) ? ' AND (pss.setting_value IS NULL OR pss.setting_value = \'\')' : ''); $rows = $this->deprecatedDao->retrieveRange( diff --git a/controllers/grid/pubIds/PubIdExportRepresentationsListGridCellProvider.php b/controllers/grid/pubIds/PubIdExportRepresentationsListGridCellProvider.php index 8a60f88d93..cb61a29334 100644 --- a/controllers/grid/pubIds/PubIdExportRepresentationsListGridCellProvider.php +++ b/controllers/grid/pubIds/PubIdExportRepresentationsListGridCellProvider.php @@ -17,6 +17,7 @@ namespace APP\controllers\grid\pubIds; use APP\facades\Repo; +use APP\plugins\PubObjectsExportPlugin; use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridHandler; use PKP\linkAction\LinkAction; @@ -134,7 +135,7 @@ public function getTemplateVarsFromRowColumn($row, $column) $label = $statusNames[$status]; } } else { - $label = $statusNames[EXPORT_STATUS_NOT_DEPOSITED]; + $label = $statusNames[PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED]; } return ['label' => $label]; } diff --git a/controllers/grid/pubIds/PubIdExportRepresentationsListGridHandler.php b/controllers/grid/pubIds/PubIdExportRepresentationsListGridHandler.php index cf029b7c1a..4856409626 100644 --- a/controllers/grid/pubIds/PubIdExportRepresentationsListGridHandler.php +++ b/controllers/grid/pubIds/PubIdExportRepresentationsListGridHandler.php @@ -285,7 +285,7 @@ protected function getFilterValues($filter) } else { $column = null; } - if (isset($filter['statusId']) && $filter['statusId'] != EXPORT_STATUS_ANY) { + if (isset($filter['statusId']) && $filter['statusId'] != PubObjectsExportPlugin::EXPORT_STATUS_ANY) { $statusId = $filter['statusId']; } else { $statusId = null; diff --git a/controllers/grid/submissions/ExportPublishedSubmissionsListGridCellProvider.php b/controllers/grid/submissions/ExportPublishedSubmissionsListGridCellProvider.php index ada73275e4..2fded81e25 100644 --- a/controllers/grid/submissions/ExportPublishedSubmissionsListGridCellProvider.php +++ b/controllers/grid/submissions/ExportPublishedSubmissionsListGridCellProvider.php @@ -17,6 +17,7 @@ namespace APP\controllers\grid\submissions; use APP\facades\Repo; +use APP\plugins\PubObjectsExportPlugin; use PKP\controllers\grid\DataObjectGridCellProvider; use PKP\controllers\grid\GridHandler; use PKP\linkAction\LinkAction; @@ -119,7 +120,7 @@ public function getTemplateVarsFromRowColumn($row, $column) $label = $statusNames[$status]; } } else { - $label = $statusNames[EXPORT_STATUS_NOT_DEPOSITED]; + $label = $statusNames[PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED]; } return ['label' => $label]; } diff --git a/controllers/grid/submissions/ExportPublishedSubmissionsListGridHandler.php b/controllers/grid/submissions/ExportPublishedSubmissionsListGridHandler.php index 8d927de919..0c0a5d29c3 100644 --- a/controllers/grid/submissions/ExportPublishedSubmissionsListGridHandler.php +++ b/controllers/grid/submissions/ExportPublishedSubmissionsListGridHandler.php @@ -18,6 +18,7 @@ use APP\core\Application; use APP\facades\Repo; +use APP\plugins\PubObjectsExportPlugin; use PKP\controllers\grid\feature\PagingFeature; use PKP\controllers\grid\feature\selectableItems\SelectableItemsFeature; use PKP\controllers\grid\GridColumn; @@ -262,7 +263,7 @@ protected function getFilterValues($filter) } else { $column = null; } - if (isset($filter['statusId']) && $filter['statusId'] != EXPORT_STATUS_ANY) { + if (isset($filter['statusId']) && $filter['statusId'] != PubObjectsExportPlugin::EXPORT_STATUS_ANY) { $statusId = $filter['statusId']; } else { $statusId = null;