diff --git a/classes/plugins/PubObjectsExportPlugin.php b/classes/plugins/PubObjectsExportPlugin.php index d09e2fa98a..37d50d7dc5 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; /** @@ -354,10 +351,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'), ]; } @@ -458,7 +455,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); } } @@ -567,7 +564,7 @@ public function getUnregisteredPreprints($context) null, null, $this->getDepositStatusSettingName(), - EXPORT_STATUS_NOT_DEPOSITED, + PubObjectsExportPlugin::EXPORT_STATUS_NOT_DEPOSITED, null ); return $preprints->toArray(); @@ -856,4 +853,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 5dcd5cf581..ecd955f7d4 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;