00001 <?php
00002
00015 import('classes.handler.Handler');
00016
00017
00018 import('lib.pkp.classes.core.JSONMessage');
00019
00020 class SubmissionMetadataHandler extends Handler {
00024 function SubmissionMetadataHandler() {
00025 parent::Handler();
00026 }
00027
00028
00029
00030
00031
00035 function initialize($request) {
00036 $this->setupTemplate();
00037 }
00038
00039
00040
00041
00042
00049 function fetch(&$request, $args, $params = null) {
00050
00051 $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00052 AppLocale::requireComponents(LOCALE_COMPONENT_OMP_SUBMISSION);
00053
00054
00055 $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
00056
00057
00058 $userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
00059 if (!array_intersect(array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR), $userRoles)) {
00060 $params['hideSubmit'] = true;
00061 $params['readOnly'] = true;
00062 }
00063
00064
00065 $submissionMetadataViewForm = $this->getFormInstance($monograph->getId(), $stageId, $params);
00066
00067 $submissionMetadataViewForm->initData($args, $request);
00068
00069 $json = new JSONMessage(true, $submissionMetadataViewForm->fetch($request));
00070 return $json->getString();
00071 }
00072
00078 function saveForm($args, &$request) {
00079 $monographId = $request->getUserVar('monographId');
00080
00081
00082 $submissionMetadataViewForm = $this->getFormInstance($monographId);
00083
00084 $json = new JSONMessage();
00085
00086
00087 $submissionMetadataViewForm->readInputData($request);
00088 if($submissionMetadataViewForm->validate()) {
00089 $submissionMetadataViewForm->execute($request);
00090
00091 $notificationManager = new NotificationManager();
00092 $user =& $request->getUser();
00093 $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
00094 } else {
00095 $json->setStatus(false);
00096 }
00097
00098 return $json->getString();
00099 }
00100
00106 function getFormInstance($monographId, $stageId = null, $params = null) {
00107 import('controllers.modals.submissionMetadata.form.CatalogEntrySubmissionReviewForm');
00108 return new CatalogEntrySubmissionReviewForm($monographId, $stageId, $params);
00109 }
00110 }
00111
00112 ?>