Open Journal Systems  3.3.0
SubmissionInformationCenterHandler.inc.php
1 <?php
2 
16 import('lib.pkp.controllers.informationCenter.InformationCenterHandler');
17 import('lib.pkp.classes.core.JSONMessage');
18 import('classes.log.SubmissionEventLogEntry');
19 
21 
24 
28  function authorize($request, &$args, $roleAssignments) {
29  $success = parent::authorize($request, $args, $roleAssignments);
30 
31  // Prevent users from accessing history unless they are assigned to an
32  // appropriate role in this submission
33  $this->_isCurrentUserAssignedEditor = false;
34  $userAssignedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
35  if (!empty($userAssignedRoles)) {
36  foreach ($userAssignedRoles as $stageId => $roles) {
37  if (array_intersect(array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), $roles)) {
38  $this->_isCurrentUserAssignedEditor = true;
39  break;
40  }
41  }
42  } else {
43  $userGlobalRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
44  if (array_intersect(array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER), $userGlobalRoles)) {
45  $this->_isCurrentUserAssignedEditor = true;
46  }
47  }
48 
49  if (!$this->_isCurrentUserAssignedEditor) {
50  return false;
51  }
52 
53  return $success;
54  }
55 
59  function viewInformationCenter($args, $request) {
60  $templateMgr = TemplateManager::getManager($request);
61  $user = $request->getUser();
62  // Do not display the History tab if the user is not a manager or a sub-editor
63  $userHasRole = $user->hasRole(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), $this->_submission->getContextId());
64  $templateMgr->assign('removeHistoryTab', !$userHasRole || !$this->_isCurrentUserAssignedEditor);
65  return parent::viewInformationCenter($args, $request);
66  }
67 
74  function viewNotes($args, $request) {
75  $this->setupTemplate($request);
76 
77  import('lib.pkp.controllers.informationCenter.form.NewSubmissionNoteForm');
78  $notesForm = new NewSubmissionNoteForm($this->_submission->getId());
79  $notesForm->initData();
80 
81  $templateMgr = TemplateManager::getManager($request);
82  $templateMgr->assign('notesList', $this->_listNotes($args, $request));
83 
84  return new JSONMessage(true, $notesForm->fetch($request));
85  }
86 
92  function saveNote($args, $request) {
93  $this->setupTemplate($request);
94 
95  import('lib.pkp.controllers.informationCenter.form.NewSubmissionNoteForm');
96  $notesForm = new NewSubmissionNoteForm($this->_submission->getId());
97  $notesForm->readInputData();
98 
99  if ($notesForm->validate()) {
100  $notesForm->execute();
101 
102  // Save to event log
103  $this->_logEvent($request, $this->_submission, SUBMISSION_LOG_NOTE_POSTED, 'SubmissionLog');
104 
105  $user = $request->getUser();
106  NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.addedNote')));
107 
108  $jsonViewNotesResponse = $this->viewNotes($args, $request);
109  $json = new JSONMessage(true);
110  $json->setEvent('dataChanged');
111  $json->setEvent('noteAdded', $jsonViewNotesResponse->_content);
112 
113  return $json;
114 
115  } else {
116  // Return a JSON string indicating failure
117  return new JSONMessage(false);
118  }
119  }
120 
127  function viewHistory($args, $request) {
128  $this->setupTemplate($request);
129  $templateMgr = TemplateManager::getManager($request);
130  $dispatcher = $request->getDispatcher();
131  $templateMgr->assign('gridParameters', $this->_getLinkParams());
132  return $templateMgr->fetchJson('controllers/informationCenter/submissionHistory.tpl');
133  }
134 
139  function _getAssocId() {
140  return $this->_submission->getId();
141  }
142 
147  function _getAssocType() {
148  return ASSOC_TYPE_SUBMISSION;
149  }
150 }
151 
152 
SubmissionInformationCenterHandler\viewHistory
viewHistory($args, $request)
Definition: SubmissionInformationCenterHandler.inc.php:130
InformationCenterHandler\_logEvent
_logEvent($request, $object, $eventType, $logClass)
Definition: InformationCenterHandler.inc.php:165
InformationCenterHandler\_getLinkParams
_getLinkParams()
Definition: InformationCenterHandler.inc.php:152
InformationCenterHandler
Parent class for file/submission information center handlers.
Definition: InformationCenterHandler.inc.php:20
InformationCenterHandler\_listNotes
_listNotes($args, $request)
Definition: InformationCenterHandler.inc.php:130
SubmissionInformationCenterHandler\viewInformationCenter
viewInformationCenter($args, $request)
Definition: SubmissionInformationCenterHandler.inc.php:62
InformationCenterHandler\setupTemplate
setupTemplate($request)
Definition: InformationCenterHandler.inc.php:181
SubmissionInformationCenterHandler\_getAssocType
_getAssocType()
Definition: SubmissionInformationCenterHandler.inc.php:150
SubmissionInformationCenterHandler\$_isCurrentUserAssignedEditor
$_isCurrentUserAssignedEditor
Definition: SubmissionInformationCenterHandler.inc.php:26
PKPNotificationOperationManager\createTrivialNotification
createTrivialNotification($userId, $notificationType=NOTIFICATION_TYPE_SUCCESS, $params=null)
Definition: PKPNotificationOperationManager.inc.php:193
SubmissionInformationCenterHandler\authorize
authorize($request, &$args, $roleAssignments)
Definition: SubmissionInformationCenterHandler.inc.php:31
SubmissionInformationCenterHandler\viewNotes
viewNotes($args, $request)
Definition: SubmissionInformationCenterHandler.inc.php:77
JSONMessage
Class to represent a JSON (Javascript Object Notation) message.
Definition: JSONMessage.inc.php:18
SubmissionInformationCenterHandler
Handle requests to view the information center for a submission.
Definition: SubmissionInformationCenterHandler.inc.php:20
SubmissionInformationCenterHandler\saveNote
saveNote($args, $request)
Definition: SubmissionInformationCenterHandler.inc.php:95
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
SubmissionInformationCenterHandler\_getAssocId
_getAssocId()
Definition: SubmissionInformationCenterHandler.inc.php:142
NewSubmissionNoteForm
Form to display and post notes on a file.
Definition: NewSubmissionNoteForm.inc.php:19
PKPHandler\getAuthorizedContextObject
& getAuthorizedContextObject($assocType)
Definition: PKPHandler.inc.php:174