|
16 | 16 | use PKP\components\forms\FieldOptions; |
17 | 17 | use APP\facades\Repo; |
18 | 18 | use APP\plugins\generic\codecheck\api\v1\CodecheckApiHandler; |
| 19 | +use APP\plugins\generic\codecheck\api\v1\CurlApiClient; |
19 | 20 | use PKP\core\JSONMessage; |
20 | 21 | use APP\plugins\generic\codecheck\classes\Constants; |
21 | 22 | use APP\plugins\generic\codecheck\classes\Workflow\CodecheckStatusHandler; |
22 | 23 | use APP\plugins\generic\codecheck\controllers\page\CodecheckPageHandler; |
23 | 24 | use APP\plugins\generic\codecheck\classes\CodecheckRoles\CodecheckRoleArray; |
24 | 25 | use APP\plugins\generic\codecheck\classes\CodecheckRoles\CodecheckRoleManager; |
| 26 | +use APP\plugins\generic\codecheck\classes\Submission\CodecheckMetadataDAO; |
| 27 | +use APP\plugins\generic\codecheck\classes\Workflow\CodecheckMetadataHandler; |
25 | 28 | use PKP\core\Request; |
| 29 | +use \Github\Client; |
26 | 30 |
|
27 | 31 | class CodecheckPlugin extends GenericPlugin |
28 | 32 | { |
@@ -89,15 +93,21 @@ public function validateCodecheckStatus(string $hookName, array $args): bool |
89 | 93 | $publication = $args[1]; // sometimes passed by reference depending on version |
90 | 94 | $request = Application::get()->getRequest(); |
91 | 95 | $context = $request->getContext(); |
| 96 | + $codecheckMetadataHandler = new CodecheckMetadataHandler($request, new Client(), new CurlApiClient()); |
| 97 | + $codecheckStatus = CodecheckStatusHandler::getCurrentStatusData($codecheckMetadataHandler->getSubmissionId()); |
92 | 98 |
|
93 | | - error_log("[CODECHECK Plugin] Validating CODECHECK before publication!"); |
| 99 | + CodecheckLogger::debug("Validating CODECHECK before publication!"); |
94 | 100 |
|
95 | | - $codecheckStatus = 'plugins.generic.codecheck.status.completed.partialReproduction'; |
96 | 101 | $codecheckStatusKeysSelected = $this->getSetting($context->getId(), Constants::CODECHECK_STATUS_KEYS_SELECTED); |
97 | 102 |
|
98 | | - if (!in_array($codecheckStatus, $codecheckStatusKeysSelected)) { |
| 103 | + if (empty($codecheckStatus)) { |
| 104 | + $errors[] = __('plugins.generic.codecheck.status.validation.failed.noStatusSet'); |
| 105 | + return false; |
| 106 | + } |
| 107 | + |
| 108 | + if (!in_array($codecheckStatus->status, $codecheckStatusKeysSelected)) { |
99 | 109 | $errors[] = __('plugins.generic.codecheck.status.validation.failed', [ |
100 | | - 'codecheckStatus' => __($codecheckStatus) |
| 110 | + 'codecheckStatus' => __($codecheckStatus->status) |
101 | 111 | ]); |
102 | 112 | return false; |
103 | 113 | } |
|
0 commit comments