-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArkPageHandler.php
More file actions
62 lines (50 loc) · 1.6 KB
/
Copy pathArkPageHandler.php
File metadata and controls
62 lines (50 loc) · 1.6 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
<?php
/**
* @file plugins/pubIds/ark/ArkPageHandler.php
*/
namespace APP\plugins\pubIds\ark;
use PKP\handler\PKPHandler;
use PKP\security\Role;
use APP\core\Application;
class ArkPageHandler extends PKPHandler
{
public $plugin;
public function __construct(ARKPubIdPlugin $plugin)
{
parent::__construct();
$this->plugin = $plugin;
$this->addRoleAssignment(
[
Role::ROLE_ID_SITE_ADMIN,
Role::ROLE_ID_MANAGER,
Role::ROLE_ID_SUB_EDITOR,
Role::ROLE_ID_AUTHOR,
Role::ROLE_ID_READER,
],
['saveArk']
);
}
public function authorize($request, &$args, $roleAssignments)
{
return true;
}
public function saveArk($args, $request)
{
if ($request->getRequestMethod() !== 'POST') {
header('Content-Type: application/json');
echo json_encode(['status' => false, 'msg' => 'Method not allowed']);
exit;
}
$issueId = (int) $request->getUserVar('issueId');
$arkValue = $request->getUserVar('arkValue');
if (!$issueId || !$arkValue) {
header('Content-Type: application/json');
echo json_encode(['status' => false, 'msg' => 'Missing parameters']);
exit;
}
$success = $this->plugin->saveArk($issueId, $arkValue);
header('Content-Type: application/json');
echo json_encode(['status' => $success, 'issueId' => $issueId, 'ark' => $arkValue]);
exit;
}
}