-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssuePreselectionPlugin.php
More file actions
138 lines (124 loc) · 4.56 KB
/
IssuePreselectionPlugin.php
File metadata and controls
138 lines (124 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* @file plugins/generic/issuePreselection/IssuePreselectionPlugin.php
*
* Copyright (c) 2017-2023 Simon Fraser University
* Copyright (c) 2017-2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class IssuePreselectionPlugin
* @brief Allows authors to select issue assignment during submission
*/
namespace APP\plugins\generic\issuePreselection;
use APP\core\Application;
use APP\plugins\generic\issuePreselection\classes\IssueManagement;
use APP\plugins\generic\issuePreselection\classes\SubmissionManagement;
use Exception;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
class IssuePreselectionPlugin extends GenericPlugin
{
/**
* @copydoc GenericPlugin::register()
*
* @param string $category The category of the plugin
* @param string $path The path to the plugin
* @param int|null $mainContextId The main context ID
*
* @return bool True if registration was successful
* @throws Exception
*/
public function register($category, $path, $mainContextId = null): bool
{
$success = parent::register($category, $path, $mainContextId);
if (Application::isUnderMaintenance()) {
return $success;
}
if ($success && $this->getEnabled($mainContextId)) {
$this->_init();
}
return $success;
}
/**
* Register hooks used in normal plugin setup and in CLI tools
*
* Initializes the management classes and registers all necessary hooks
* for both issue and submission functionality.
*
* @return void
* @throws Exception
*/
private function _init(): void
{
$issueManagement = new IssueManagement($this);
$submissionManagement = new SubmissionManagement($this);
$this->registerIssueHooks($issueManagement);
$this->registerSubmissionHooks($submissionManagement);
}
/**
* Register hooks for issue management functionality
*
* Registers all hooks related to issue schema, forms, and data handling.
*
* @param IssueManagement $issueManagement The issue management instance
*
* @return void
* @throws Exception
*/
private function registerIssueHooks(IssueManagement $issueManagement): void
{
Hook::add("Schema::get::issue", [$issueManagement, "addToIssueSchema"]);
Hook::add("Templates::Editor::Issues::IssueData::AdditionalMetadata", [$issueManagement, "addIssueFormFields"]);
Hook::add("issueform::readuservars", [$issueManagement, "readIssueFormData"]);
Hook::add("issueform::execute", [$issueManagement, "saveIssueFormData"]);
Hook::add("Issue::edit", [$issueManagement, "beforeIssueEdit"]);
}
/**
* Register hooks for submission management functionality
*
* Registers all hooks related to submission schema, forms, validation,
* and editor assignment.
*
* @param SubmissionManagement $submissionManagement The submission management instance
*
* @return void
* @throws Exception
*/
private function registerSubmissionHooks(SubmissionManagement $submissionManagement): void
{
Hook::add("Schema::get::submission", [$submissionManagement, "addToSubmissionSchema"]);
Hook::add("Form::config::after", [$submissionManagement, "addToSubmissionForm"]);
Hook::add("Submission::getSubmissionsListProps", [$submissionManagement, "addSubmissionListProps"]);
Hook::add("Template::SubmissionWizard::Section::Review::Editors", [
$submissionManagement,
"addIssueReviewSection",
]);
Hook::add("Submission::validateSubmit", [$submissionManagement, "handleSubmissionValidate"]);
}
/**
* Get the display name of this plugin
*
* @copydoc Plugin::getDisplayName()
*
* @return object|array|string|null Localized plugin display name
*/
public function getDisplayName(): object|array|string|null
{
return __("plugins.generic.issuePreselection.displayName");
}
/**
* Get the description of this plugin
*
* @copydoc Plugin::getDescription()
*
* @return object|array|string|null Localized plugin description
*/
public function getDescription(): object|array|string|null
{
return __("plugins.generic.issuePreselection.description");
}
}
// For backwards compatibility -- expect this to be removed approx. OJS/OMP/OPS 3.6
if (!PKP_STRICT_MODE) {
class_alias("\APP\plugins\generic\issuePreselection\IssuePreselectionPlugin", "\IssuePreselectionPlugin");
}