예제 #1
0
 /**
  * Upload a new file.
  * @param $args array
  * @param $request PKPRequest
  * @return string
  */
 function uploadFile($args, $request)
 {
     $fileUploadForm = $this->_getFileUploadForm($request);
     $json = new JSONMessage();
     $temporaryFileId = $fileUploadForm->uploadFile($request);
     if ($temporaryFileId !== false) {
         $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFileId));
     } else {
         $json->setStatus(false);
         $json->setContent(__('common.uploadFailed'));
     }
     return $json->getString();
 }
 /**
  * Save form to generate custom reports.
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object
  */
 function saveReportGenerator($args, $request)
 {
     $this->setupTemplate($request);
     $reportGeneratorForm = $this->_getReportGeneratorForm($request);
     $reportGeneratorForm->readInputData();
     $json = new JSONMessage(true);
     if ($reportGeneratorForm->validate()) {
         $reportUrl = $reportGeneratorForm->execute($request);
         $json->setAdditionalAttributes(array('reportUrl' => $reportUrl));
     } else {
         $json->setStatus(false);
     }
     return $json;
 }
예제 #3
0
 /**
  * Returns a JSON response containing information regarding the galley formats enabled
  * for this submission.
  * @param $args array
  * @param $request Request
  */
 function fetchFormatInfo($args, $request)
 {
     $submission = $this->getSubmission();
     $json = new JSONMessage();
     $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $galleyDao->getBySubmissionId($submission->getId());
     $formats = array();
     while ($galley = $galleys->next()) {
         $formats[$galley->getId()] = $galley->getLocalizedName();
     }
     $json->setStatus(true);
     $json->setContent(true);
     $json->setAdditionalAttributes(array('formats' => $formats));
     return $json->getString();
 }
 /**
  * Save the submission metadata form.
  * @param $args array
  * @param $request Request
  */
 function saveForm($args, $request)
 {
     $submissionId = $request->getUserVar('submissionId');
     // Form handling
     $submissionMetadataViewForm = $this->getFormInstance($submissionId);
     $json = new JSONMessage();
     // Try to save the form data.
     $submissionMetadataViewForm->readInputData($request);
     if ($submissionMetadataViewForm->validate()) {
         $submissionMetadataViewForm->execute($request);
         // Create trivial notification.
         $notificationManager = new NotificationManager();
         $user = $request->getUser();
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
     } else {
         $json->setStatus(false);
     }
     return $json->getString();
 }
 /**
  * Save the metadata tab.
  * @param $args array
  * @param $request PKPRequest
  */
 function saveForm($args, $request)
 {
     $this->setupTemplate($request);
     import('controllers.modals.submissionMetadata.form.SubmissionMetadataViewForm');
     $submissionMetadataViewForm = new SubmissionMetadataViewForm($this->_submission->getId());
     $json = new JSONMessage();
     // Try to save the form data.
     $submissionMetadataViewForm->readInputData($request);
     if ($submissionMetadataViewForm->validate()) {
         $submissionMetadataViewForm->execute($request);
         // Create trivial notification.
         $notificationManager = new NotificationManager();
         $user = $request->getUser();
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedSubmissionMetadata')));
     } else {
         $json->setStatus(false);
     }
     return $json->getString();
 }
예제 #6
0
 /**
  * Fetch all grid rows from loaded data.
  * @param $args Array
  * @param $request Request
  * @return JSONMessage JSON object.
  */
 function fetchRows($args, $request)
 {
     // Render the rows.
     $this->setFirstDataColumn();
     $elements = $this->getGridDataElements($request);
     $renderedRows = $this->renderRowsInternally($request, $elements);
     $json = new JSONMessage();
     $json->setStatus(false);
     if ($renderedRows) {
         $renderedRowsString = null;
         foreach ($renderedRows as $rowString) {
             $renderedRowsString .= $rowString;
         }
         $json->setStatus(true);
         $json->setContent($renderedRowsString);
     }
     $this->callFeaturesHook('fetchRows', array('request' => &$request, 'grid' => &$this, 'jsonMessage' => &$json));
     return $json;
 }
 /**
  * Save user notification settings.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON-formatted response
  */
 function saveNotificationSettings($args, $request)
 {
     $this->setupTemplate($request);
     import('classes.notification.form.NotificationSettingsForm');
     $notificationSettingsForm = new NotificationSettingsForm();
     $notificationSettingsForm->readInputData();
     $json = new JSONMessage();
     if ($notificationSettingsForm->validate()) {
         $notificationSettingsForm->execute($request);
         $user = $request->getUser();
         $notificationMgr = new NotificationManager();
         $notificationMgr->createTrivialNotification($user->getId());
     } else {
         $json->setStatus(false);
     }
     return $json;
 }
 /**
  * Fetch regions from the passed request
  * variable country id.
  * @param $args array
  * @param $request Request
  * @return string JSON response
  */
 function fetchRegions(&$args, &$request)
 {
     $this->validate();
     $countryId = (string) $request->getUserVar('countryId');
     import('lib.pkp.classes.core.JSONMessage');
     $json = new JSONMessage(false);
     if ($countryId) {
         $geoLocationTool =& StatisticsHelper::getGeoLocationTool();
         if ($geoLocationTool) {
             $regions = $geoLocationTool->getRegions($countryId);
             if (!empty($regions)) {
                 $regionsData = array();
                 foreach ($regions as $id => $name) {
                     $regionsData[] = array('id' => $id, 'name' => $name);
                 }
                 $json->setStatus(true);
                 $json->setContent($regionsData);
             }
         }
     }
     return $json->getString();
 }
 /**
  * Save the forms handled by this Handler.
  * @param $request Request
  * @param $args array
  * @return string JSON message
  */
 function saveForm($args, $request)
 {
     $json = new JSONMessage();
     $form = null;
     $submission = $this->getSubmission();
     $stageId = $this->getStageId();
     $notificationKey = null;
     $this->_getFormFromCurrentTab($form, $notificationKey, $request);
     if ($form) {
         // null if we didn't have a valid tab
         $form->readInputData();
         if ($form->validate($request)) {
             $form->execute($request);
             // Create trivial notification in place on the form
             $notificationManager = new NotificationManager();
             $user = $request->getUser();
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($notificationKey)));
         } else {
             // Could not validate; redisplay the form.
             $json->setStatus(true);
             $json->setContent($form->fetch($request));
         }
         if ($request->getUserVar('displayedInContainer')) {
             $router = $request->getRouter();
             $dispatcher = $router->getDispatcher();
             $url = $dispatcher->url($request, ROUTE_COMPONENT, null, $this->_getHandlerClassPath(), 'fetch', null, array('submissionId' => $submission->getId(), 'stageId' => $stageId, 'tabPos' => $this->getTabPosition(), 'hideHelp' => true));
             $json->setAdditionalAttributes(array('reloadContainer' => true, 'tabsUrl' => $url));
             $json->setContent(true);
             // prevents modal closure
         }
         return $json;
     } else {
         fatalError('Unknown or unassigned format id!');
     }
 }