Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPSubmissionInformationCenterHandler.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 
25  parent::InformationCenterHandler();
26  }
27 
33  function metadata($args, $request) {
34  $this->setupTemplate($request);
35 
36  import('controllers.modals.submissionMetadata.form.SubmissionMetadataViewForm');
37  // prevent anyone but managers and editors from submitting the catalog entry form
38  $userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
39  $params = array();
40  if (!array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR), $userRoles)) {
41  $params['hideSubmit'] = true;
42  $params['readOnly'] = true;
43  }
44  $submissionMetadataViewForm = new SubmissionMetadataViewForm($this->_submission->getId(), null, $params);
45  $submissionMetadataViewForm->initData($args, $request);
46 
47  $json = new JSONMessage(true, $submissionMetadataViewForm->fetch($request));
48  return $json->getString();
49  }
50 
56  function saveForm($args, $request) {
57  $this->setupTemplate($request);
58 
59  import('controllers.modals.submissionMetadata.form.SubmissionMetadataViewForm');
60  $submissionMetadataViewForm = new SubmissionMetadataViewForm($this->_submission->getId());
61 
62  $json = new JSONMessage();
63 
64  // Try to save the form data.
65  $submissionMetadataViewForm->readInputData($request);
66  if($submissionMetadataViewForm->validate()) {
67  $submissionMetadataViewForm->execute($request);
68  // Create trivial notification.
69  $notificationManager = new NotificationManager();
70  $user = $request->getUser();
71  $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
72  } else {
73  $json->setStatus(false);
74  }
75 
76  return $json->getString();
77  }
78 
84  function viewInformationCenter($args, $request) {
85  // Get the latest history item to display in the header
86  $submissionEventLogDao = DAORegistry::getDAO('SubmissionEventLogDAO');
87  $submissionEvents = $submissionEventLogDao->getBySubmissionId($this->_submission->getId());
88  $lastEvent = $submissionEvents->next();
89 
90  // Assign variables to the template manager and display
91  $templateMgr = TemplateManager::getManager($request);
92  if(isset($lastEvent)) {
93  $templateMgr->assign('lastEvent', $lastEvent);
94 
95  // Get the user who posted the last note
96  $userDao = DAORegistry::getDAO('UserDAO');
97  $user = $userDao->getById($lastEvent->getUserId());
98  $templateMgr->assign('lastEventUser', $user);
99  }
100 
101  return parent::viewInformationCenter($request);
102  }
103 
109  function viewNotes($args, $request) {
110  $this->setupTemplate($request);
111 
112  import('lib.pkp.controllers.informationCenter.form.NewSubmissionNoteForm');
113  $notesForm = new NewSubmissionNoteForm($this->_submission->getId());
114  $notesForm->initData();
115 
116  $json = new JSONMessage(true, $notesForm->fetch($request));
117  return $json->getString();
118  }
119 
125  function saveNote($args, $request) {
126  $this->setupTemplate($request);
127 
128  import('lib.pkp.controllers.informationCenter.form.NewSubmissionNoteForm');
129  $notesForm = new NewSubmissionNoteForm($this->_submission->getId());
130  $notesForm->readInputData();
131 
132  if ($notesForm->validate()) {
133  $notesForm->execute($request);
134  $json = new JSONMessage(true);
135 
136  // Save to event log
137  $user = $request->getUser();
138  $userId = $user->getId();
139  $this->_logEvent($request, SUBMISSION_LOG_NOTE_POSTED);
140  } else {
141  // Return a JSON string indicating failure
142  $json = new JSONMessage(false);
143  }
144 
145  return $json->getString();
146  }
147 
153  function viewHistory($args, $request) {
154  $this->setupTemplate($request);
155  $templateMgr = TemplateManager::getManager($request);
156  $templateMgr->assign('submissionId', $this->_submission->getId());
157  return $templateMgr->fetchJson('controllers/informationCenter/submissionHistory.tpl');
158  }
159 
164  function _getAssocId() {
165  return $this->_submission->getId();
166  }
167 
172  function _getAssocType() {
173  return ASSOC_TYPE_SUBMISSION;
174  }
175 
181  function _logEvent ($request, $eventType) {
182  assert(false); // overridden in subclasses.
183  }
184 }
185 
186 ?>
static & getDAO($name, $dbconn=null)
Form to display and post notes on a file.
initData()
Definition: Form.inc.php:227
Parent class for file/submission information center handlers.
Handle requests to view the information center for a submission.
Class to represent a JSON (Javascript Object Notation) message.
& getAuthorizedContextObject($assocType)
Displays a submission&#39;s metadata view.