/** * @copydoc Form::execute() */ function execute($request) { parent::execute($request); // Retrieve the temporary file. $user = $request->getUser(); $temporaryFileId = $this->getData('temporaryFileId'); $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); $pluginHelper = new PluginHelper(); $errorMsg = null; $pluginDir = $pluginHelper->extractPlugin($temporaryFile->getFilePath(), $temporaryFile->getOriginalFileName(), $errorMsg); $notificationMgr = new NotificationManager(); if ($pluginDir) { if ($this->_function == PLUGIN_ACTION_UPLOAD) { $pluginVersion = $pluginHelper->installPlugin($pluginDir, $errorMsg); if ($pluginVersion) { $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('manager.plugins.installSuccessful', array('versionNumber' => $pluginVersion->getVersionString(false))))); } } else { if ($this->_function == PLUGIN_ACTION_UPGRADE) { $pluginVersion = $pluginHelper->upgradePlugin($request->getUserVar('category'), $request->getUserVar('plugin'), $pluginDir, $errorMsg); if ($pluginVersion) { $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('manager.plugins.upgradeSuccessful', array('versionString' => $pluginVersion->getVersionString(false))))); } } } } else { $errorMsg = __('manager.plugins.invalidPluginArchive'); } if ($errorMsg) { $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => $errorMsg)); return false; } return true; }
/** * @copydoc Plugin::manage() */ function manage($args, $request) { $notificationManager = new NotificationManager(); $user = $request->getUser(); $journal = $request->getJournal(); $settingsFormName = $this->getSettingsFormName(); $settingsFormNameParts = explode('.', $settingsFormName); $settingsFormClassName = array_pop($settingsFormNameParts); $this->import($settingsFormName); $form = new $settingsFormClassName($this, $journal->getId()); if ($request->getUserVar('save')) { $form->readInputData(); if ($form->validate()) { $form->execute(); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS); return new JSONMessage(true); } else { return new JSONMessage(true, $form->fetch($request)); } } elseif ($request->getUserVar('clearPubIds')) { $journalDao = DAORegistry::getDAO('JournalDAO'); $journalDao->deleteAllPubIds($journal->getId(), $this->getPubIdType()); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS); return new JSONMessage(true); } else { $form->initData(); return new JSONMessage(true, $form->fetch($request)); } }
/** * @copydoc Plugin::manage() */ function manage($args, $request) { $user = $request->getUser(); $router = $request->getRouter(); $context = $router->getContext($request); $form = $this->instantiateSettingsForm($context->getId()); $notificationManager = new NotificationManager(); switch ($request->getUserVar('verb')) { case 'save': $form->readInputData(); if ($form->validate()) { $form->execute(); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS); return new JSONMessage(true); } return new JSONMessage(true, $form->fetch($request)); case 'clearPubIds': if (!$request->checkCSRF()) { return new JSONMessage(false); } $contextDao = Application::getContextDAO(); $contextDao->deleteAllPubIds($context->getId(), $this->getPubIdType()); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS); return new JSONMessage(true); default: $form->initData(); return new JSONMessage(true, $form->fetch($request)); } return parent::manage($args, $request); }
/** * Display the grid's containing page. * @param $args array * @param $request PKPRequest */ function save($args, $request) { $filename = $this->_getFilename($request); $notificationManager = new NotificationManager(); $user = $request->getUser(); $contents = $this->correctCr($request->getUserVar('fileContents')); if (file_put_contents($filename, $contents)) { $notificationManager->createTrivialNotification($user->getId()); } else { // Could not write the file $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.couldNotWriteFile', array('filename' => $filename)))); } $message = new JSONMessage(true); return $message->getString(); }
/** * Update language settings. * @param $args array * @param $request object */ function saveLanguageSettings($args, &$request) { $this->validate(); $this->setupTemplate(true); $site =& $request->getSite(); $primaryLocale = $request->getUserVar('primaryLocale'); $supportedLocales = $request->getUserVar('supportedLocales'); if (Locale::isLocaleValid($primaryLocale)) { $site->setPrimaryLocale($primaryLocale); } $newSupportedLocales = array(); if (isset($supportedLocales) && is_array($supportedLocales)) { foreach ($supportedLocales as $locale) { if (Locale::isLocaleValid($locale)) { array_push($newSupportedLocales, $locale); } } } if (!in_array($primaryLocale, $newSupportedLocales)) { array_push($newSupportedLocales, $primaryLocale); } $site->setSupportedLocales($newSupportedLocales); $siteDao =& DAORegistry::getDAO('SiteDAO'); $siteDao->updateObject($site); import('notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); $request->redirect(null, 'index'); }
/** * @copydoc ScheduledTask::executeActions() */ function executeActions() { if (!$this->_plugin) { return false; } $plugin = $this->_plugin; $journals = $this->_getJournals(); foreach ($journals as $journal) { $notify = false; $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $journal->getId()); $doiPubIdPlugin = $pubIdPlugins['doipubidplugin']; if ($doiPubIdPlugin->getSetting($journal->getId(), 'enableSubmissionDoi')) { // Get unregistered articles $unregisteredArticles = $plugin->getUnregisteredArticles($journal); // Update the status and construct an array of the articles to be deposited $articlesToBeDeposited = $this->_getObjectsToBeDeposited($unregisteredArticles, $journal, $notify); // If there are articles to be deposited and we want automatic deposits if (count($articlesToBeDeposited) && $plugin->getSetting($journal->getId(), 'automaticRegistration')) { $this->_registerObjects($articlesToBeDeposited, 'article=>crossref-xml', $journal, 'articles'); } } // Notify journal managers if there is a new failed DOI status if ($notify) { $roleDao = DAORegistry::getDAO('RoleDAO'); $journalManagers = $roleDao->getUsersByRoleId(ROLE_ID_MANAGER, $journal->getId()); import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); while ($journalManager = $journalManagers->next()) { $notificationManager->createTrivialNotification($journalManager->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.importexport.crossref.notification.failed'))); } } } return true; }
/** * Perform SWORD deposit */ function execute() { import('classes.sword.OJSSwordDeposit'); $deposit = new OJSSwordDeposit($this->article); $deposit->setMetadata(); $deposit->addEditorial(); $deposit->createPackage(); import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $allowAuthorSpecify = $this->swordPlugin->getSetting($this->article->getJournalId(), 'allowAuthorSpecify'); $authorDepositUrl = $this->getData('authorDepositUrl'); if ($allowAuthorSpecify && $authorDepositUrl != '') { $deposit->deposit($this->getData('authorDepositUrl'), $this->getData('authorDepositUsername'), $this->getData('authorDepositPassword')); $notificationManager->createTrivialNotification(Locale::translate('notification.notification'), Locale::translate('plugins.generic.sword.depositComplete', array('itemTitle' => $this->article->getLocalizedTitle(), 'repositoryName' => $this->getData('authorDepositUrl'))), NOTIFICATION_TYPE_SUCCESS, null, false); } $depositableDepositPoints = $this->_getDepositableDepositPoints(); $depositPoints = $this->getData('depositPoint'); foreach ($depositableDepositPoints as $key => $depositPoint) { if (!isset($depositPoints[$key]['enabled'])) { continue; } if ($depositPoint['type'] == SWORD_DEPOSIT_TYPE_OPTIONAL_SELECTION) { $url = $depositPoints[$key]['depositPoint']; } else { // SWORD_DEPOSIT_TYPE_OPTIONAL_FIXED $url = $depositPoint['url']; } $deposit->deposit($url, $depositPoint['username'], $depositPoint['password']); $notificationManager->createTrivialNotification(Locale::translate('notification.notification'), Locale::translate('plugins.generic.sword.depositComplete', array('itemTitle' => $this->article->getLocalizedTitle(), 'repositoryName' => $depositPoint['name'])), NOTIFICATION_TYPE_SUCCESS, null, false); } $deposit->cleanup(); }
/** * Expedites a submission through the submission process, if the submitter is a manager or editor. * @param $args array * @param $request PKPRequest */ function expedite($args, $request) { $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); import('controllers.tab.issueEntry.form.IssueEntryPublicationMetadataForm'); $user = $request->getUser(); $form = new IssueEntryPublicationMetadataForm($submission->getId(), $user, null, array('expeditedSubmission' => true)); if ($submission && (int) $request->getUserVar('issueId') > 0) { // Process our submitted form in order to create the published article entry. $form->readInputData(); if ($form->validate()) { $form->execute($request); // Create trivial notification in place on the form, and log the event. $notificationManager = new NotificationManager(); $user = $request->getUser(); import('lib.pkp.classes.log.SubmissionLog'); SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_ISSUE_METADATA_UPDATE, 'submission.event.issueMetadataUpdated'); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedIssueMetadata'))); // Now, create a galley for this submission. Assume PDF, and set to 'available'. $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); $articleGalley = $articleGalleyDao->newDataObject(); $articleGalley->setGalleyType('pdfarticlegalleyplugin'); $articleGalley->setIsAvailable(true); $articleGalley->setSubmissionId($submission->getId()); $articleGalley->setLocale($submission->getLocale()); $articleGalley->setLabel('PDF'); $articleGalley->setSeq($articleGalleyDao->getNextGalleySequence($submission->getId())); $articleGalleyId = $articleGalleyDao->insertObject($articleGalley); // Next, create a galley PROOF file out of the submission file uploaded. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFiles = $submissionFileDao->getLatestRevisions($submission->getId(), SUBMISSION_FILE_SUBMISSION); // Assume a single file was uploaded, but check for something that's PDF anyway. foreach ($submissionFiles as $submissionFile) { // test both mime type and file extension in case the mime type isn't correct after uploading. if ($submissionFile->getFileType() == 'application/pdf' || preg_match('/\\.pdf$/', $submissionFile->getOriginalFileName())) { // Get the path of the current file because we change the file stage in a bit. $currentFilePath = $submissionFile->getFilePath(); // this will be a new file based on the old one. $submissionFile->setFileId(null); $submissionFile->setRevision(1); $submissionFile->setFileStage(SUBMISSION_FILE_PROOF); $submissionFile->setAssocType(ASSOC_TYPE_GALLEY); $submissionFile->setAssocId($articleGalleyId); $submissionFileDao->insertObject($submissionFile, $currentFilePath); break; } } // no errors, clear all notifications for this submission which may have been created during the submission process and close the modal. $context = $request->getContext(); $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationFactory = $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), null, null, $context->getId()); return new JSONMessage(true); } else { return new JSONMessage(true, $form->fetch($request)); } } return new JSONMessage(true, $form->fetch($request)); }
/** * Reset permissions data assigned to existing submissions. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON response. */ function resetPermissions($args, $request) { $context = $request->getContext(); $submissionDao = Application::getSubmissionDAO(); $submissionDao->deletePermissions($context->getId()); $notificationManager = new NotificationManager(); $user = $request->getUser(); $notificationManager->createTrivialNotification($user->getId()); return new JSONMessage(true); }
/** * Perform plugin-specific management functions. * @param $args array * @param $request object */ function plugin($args, &$request) { $category = array_shift($args); $plugin = array_shift($args); $verb = array_shift($args); $this->validate(); $this->setupTemplate(true); $plugins =& PluginRegistry::loadCategory($category); $message = null; if (!isset($plugins[$plugin]) || !$plugins[$plugin]->manage($verb, $args, $message)) { import('notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification(Locale::translate('notification.notification'), $message, NOTIFICATION_TYPE_SUCCESS, null, 0); $request->redirect(null, null, null, 'plugins', array($category)); } }
/** * 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()); // 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'))); return new JSONMessage(true); } return new JSONMessage(false); }
/** * Save changes to language settings. * @param $args array * @param $request object */ function saveLanguageSettings($args, &$request) { $this->validate(); $this->setupTemplate(true); import('manager.form.LanguageSettingsForm'); $settingsForm = new LanguageSettingsForm(); $settingsForm->readInputData(); if ($settingsForm->validate()) { $settingsForm->execute(); import('notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); $request->redirect(null, null, 'index'); } else { $settingsForm->display(); } }
/** * Reload the default localized settings for the journal. * @param $args array * @param $request object */ function reloadLocalizedDefaultSettings($args, &$request) { // make sure the locale is valid $locale = $request->getUserVar('localeToLoad'); if (!Locale::isLocaleValid($locale)) { $request->redirect(null, null, 'languages'); } $this->validate(); $this->setupTemplate(true); $journal =& $request->getJournal(); $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $journalSettingsDao->reloadLocalizedDefaultSettings($journal->getId(), 'registry/journalSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale); // Display a notification import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); $request->redirect(null, null, 'languages'); }
/** * Save 'manage review files' form. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateReviewFiles($args, $request) { $submission = $this->getSubmission(); import('lib.pkp.controllers.grid.files.review.form.ManageReviewFilesForm'); $manageReviewFilesForm = new ManageReviewFilesForm($submission->getId(), $this->getRequestArg('stageId'), $this->getRequestArg('reviewRoundId')); $manageReviewFilesForm->readInputData(); if ($manageReviewFilesForm->validate()) { $dataProvider = $this->getDataProvider(); $manageReviewFilesForm->execute($args, $request, $this->getGridCategoryDataElements($request, $this->getStageId())); $this->setupTemplate($request); $user = $request->getUser(); NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.updatedReviewFiles'))); // Let the calling grid reload itself return DAO::getDataChangedEvent(); } else { return new JSONMessage(false); } }
/** * 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); // 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'))); return new JSONMessage(); } else { return new JSONMessage(false); } }
/** * Perform plugin-specific management functions. * @param $args array * @param $request object */ function plugin($args, &$request) { $category = array_shift($args); $plugin = array_shift($args); $verb = array_shift($args); $this->validate(); $this->setupTemplate(true); $plugins =& PluginRegistry::loadCategory($category); $message = $messageParams = null; if (!isset($plugins[$plugin]) || !$plugins[$plugin]->manage($verb, $args, $message, $messageParams, $request)) { if ($message) { $user =& $request->getUser(); import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification($user->getId(), $message, $messageParams); } $request->redirect(null, null, 'plugins', array($category)); } }
/** * Update an existing journal. * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function updateContext($args, $request) { // Identify the context Id. $contextId = $request->getUserVar('contextId'); // Form handling. $settingsForm = new JournalSiteSettingsForm($contextId); $settingsForm->readInputData(); if (!$settingsForm->validate()) { $json = new JSONMessage(false); return $json->getString(); } PluginRegistry::loadCategory('blocks'); // The context settings form will return a context path in two cases: // 1 - if a new context was created; // 2 - if a press path of an existing context was edited. $newContextPath = $settingsForm->execute($request); // Create the notification. $notificationMgr = new NotificationManager(); $user = $request->getUser(); $notificationMgr->createTrivialNotification($user->getId()); // Check for the two cases above. if ($newContextPath) { $context = $request->getContext(); if (is_null($contextId)) { // CASE 1: new press created. // Create notification related to payment method configuration. $contextDao = Application::getContextDAO(); $newContext = $contextDao->getByPath($newContextPath); $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $newContext->getId(), ASSOC_TYPE_JOURNAL, $newContext->getId(), NOTIFICATION_LEVEL_NORMAL); // redirect and set the parameter to open the press // setting wizard modal after redirection. return $this->_getRedirectEvent($request, $newContextPath, true); } else { // CASE 2: check if user is in the context of // the press being edited. if ($context && $context->getId() == $contextId) { return $this->_getRedirectEvent($request, $newContextPath, false); } } } return DAO::getDataChangedEvent($contextId); }
/** * Reload the default localized settings for the press * @param $args array * @param $request object */ function reloadLocalizedDefaultSettings($args, &$request) { // make sure the locale is valid $locale = $request->getUserVar('localeToLoad'); if (!Locale::isLocaleValid($locale)) { $request->redirect(null, null, 'languages'); } $this->setupTemplate(true); $press =& $request->getPress(); $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO'); $pressSettingsDao->reloadLocalizedDefaultSettings($press->getId(), 'registry/pressSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'pressPath' => $press->getData('path'), 'primaryLocale' => $press->getPrimaryLocale(), 'pressName' => $press->getName($press->getPrimaryLocale())), $locale); // also reload the user group localizable data $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); $userGroupDao->installLocale($locale, $press->getId()); // Display a notification import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); $request->redirect(null, null, 'languages'); }
/** * Save the email editing form * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function updatePreparedEmail($args, $request) { $journal = $request->getJournal(); $emailKey = $request->getUserVar('emailKey'); import('lib.pkp.controllers.grid.settings.preparedEmails.form.PreparedEmailForm'); $preparedEmailForm = new PreparedEmailForm($emailKey, $journal); $preparedEmailForm->readInputData(); if ($preparedEmailForm->validate()) { $preparedEmailForm->execute(); // Create notification. $notificationMgr = new NotificationManager(); $user = $request->getUser(); $notificationMgr->createTrivialNotification($user->getId()); // Let the calling grid reload itself return DAO::getDataChangedEvent($emailKey); } else { $json = new JSONMessage(false); return $json->getString(); } }
/** * Validate and save changes to site settings. * @param $args array * @param $request object */ function saveSettings($args, &$request) { $this->validate(); $this->setupTemplate($request, true); $site =& $request->getSite(); import('classes.admin.form.SiteSettingsForm'); $settingsForm = new SiteSettingsForm(); $settingsForm->readInputData(); if ($request->getUserVar('uploadSiteStyleSheet')) { if (!$settingsForm->uploadSiteStyleSheet()) { $settingsForm->addError('siteStyleSheet', __('admin.settings.siteStyleSheetInvalid')); } } elseif ($request->getUserVar('deleteSiteStyleSheet')) { $publicFileManager = new PublicFileManager(); $publicFileManager->removeSiteFile($site->getSiteStyleFilename()); } elseif ($request->getUserVar('uploadPageHeaderTitleImage')) { if (!$settingsForm->uploadPageHeaderTitleImage($settingsForm->getFormLocale())) { $settingsForm->addError('pageHeaderTitleImage', __('admin.settings.homeHeaderImageInvalid')); } } elseif ($request->getUserVar('deletePageHeaderTitleImage')) { $publicFileManager = new PublicFileManager(); $setting = $site->getSetting('pageHeaderTitleImage'); $formLocale = $settingsForm->getFormLocale(); if (isset($setting[$formLocale])) { $publicFileManager->removeSiteFile($setting[$formLocale]['uploadName']); $setting[$formLocale] = array(); $site->updateSetting('pageHeaderTitleImage', $setting, 'object', true); // Refresh site header $templateMgr =& TemplateManager::getManager($request); $templateMgr->assign('displaySitePageHeaderTitle', $site->getLocalizedPageHeaderTitle()); } } elseif ($settingsForm->validate()) { $settingsForm->execute(); import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $user =& $request->getUser(); $notificationManager->createTrivialNotification($user->getId()); $request->redirect(null, null, null, 'index'); } $settingsForm->display(); }
/** * Update an existing press. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateContext($args, $request) { // Identify the press Id. $pressId = $request->getUserVar('contextId'); // Form handling. $settingsForm = new PressSiteSettingsForm($pressId); $settingsForm->readInputData(); if ($settingsForm->validate()) { PluginRegistry::loadCategory('blocks'); // The press settings form will return a press path in two cases: // 1 - if a new press was created; // 2 - if a press path of an existing press was edited. $newPressPath = $settingsForm->execute($request); // Create the notification. $notificationMgr = new NotificationManager(); $user = $request->getUser(); $notificationMgr->createTrivialNotification($user->getId()); // Check for the two cases above. if ($newPressPath) { $context = $request->getContext(); if (is_null($pressId)) { // CASE 1: new press created. // redirect and set the parameter to open the press // setting wizard modal after redirection. return $this->_getRedirectEvent($request, $newPressPath, true); } else { // CASE 2: check if user is in the context of // the press being edited. if ($context->getId() == $pressId) { return $this->_getRedirectEvent($request, $newPressPath, false); } } } return DAO::getDataChangedEvent($pressId); } else { return new JSONMessage(false); } }
/** * Save changes to a press' settings. */ function updatePress() { $this->validate(); $this->setupTemplate(true); import('classes.admin.form.PressSiteSettingsForm'); if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $settingsForm = new PressSiteSettingsForm(Request::getUserVar('pressId')); } else { $settingsForm =& new PressSiteSettingsForm(Request::getUserVar('pressId')); } $settingsForm->readInputData(); if ($settingsForm->validate()) { PluginRegistry::loadCategory('blocks'); $settingsForm->execute(); import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); Request::redirect(null, null, 'presses'); } else { $settingsForm->display(); } }
/** * @copydoc PKPPlugin::manage() */ function manage($args, $request) { $notificationManager = new NotificationManager(); $user = $request->getUser(); $press = $request->getPress(); $settingsFormName = $this->getSettingsFormName(); $settingsFormNameParts = explode('.', $settingsFormName); $settingsFormClassName = array_pop($settingsFormNameParts); $this->import($settingsFormName); $form = new $settingsFormClassName($this, $press->getId()); if ($request->getUserVar('save')) { $form->readInputData(); if ($form->validate()) { $form->execute(); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS); return new JSONMessage(true); } else { return new JSONMessage(true, $form->fetch($request)); } } else { $form->initData(); return new JSONMessage(true, $form->fetch($request)); } }
/** * Validate and save changes to site settings. * @param $args array * @param $request object */ function saveSettings($args, &$request) { $this->validate(); $this->setupTemplate(true); import('admin.form.SiteSettingsForm'); $settingsForm = new SiteSettingsForm(); $settingsForm->readInputData(); $editData = false; if ($request->getUserVar('uploadStyleSheet')) { if ($settingsForm->uploadStyleSheet('styleSheet')) { $editData = true; } else { $settingsForm->addError('styleSheet', Locale::translate('admin.settings.styleSheet.invalid')); } } elseif ($request->getUserVar('deleteStyleSheet')) { $editData = true; $settingsForm->deleteImage('styleSheet'); } elseif ($request->getUserVar('uploadCustomLogo')) { if ($settingsForm->uploadImage('customLogo')) { $editData = true; } else { $settingsForm->addError('customLogo', Locale::translate('admin.settings.customLogo.invalid')); } } elseif ($request->getUserVar('deleteCustomLogo')) { $editData = true; $settingsForm->deleteImage('customLogo'); } if (!$editData && $settingsForm->validate()) { $settingsForm->execute(); import('notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); $request->redirect(null, 'index'); } $settingsForm->display(); }
/** * User redeems a gift * @param $args array * @param $request PKPRequest */ function redeemGift($args, $request) { $this->validate(); if (empty($args)) { $request->redirect(null, 'dashboard'); } $journal = $request->getJournal(); if (!$journal) { $request->redirect(null, 'dashboard'); } // Ensure gift payments are enabled import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); $acceptGiftPayments = $paymentManager->acceptGiftPayments(); if (!$acceptGiftPayments) { $request->redirect(null, 'dashboard'); } $journalId = $journal->getId(); $user = $request->getUser(); $userId = $user->getId(); $giftId = isset($args[0]) ? (int) $args[0] : 0; // Try to redeem the gift $giftDao = DAORegistry::getDAO('GiftDAO'); $status = $giftDao->redeemGift(ASSOC_TYPE_JOURNAL, $journalId, $userId, $giftId); // Report redeem status to user import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); switch ($status) { case GIFT_REDEEM_STATUS_SUCCESS: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_SUCCESS; break; case GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM; break; case GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED; break; case GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID; break; case GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_TYPE_INVALID: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_TYPE_INVALID; break; case GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_NON_EXPIRING: $notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_NON_EXPIRING; break; default: $notificationType = NOTIFICATION_TYPE_NO_GIFT_TO_REDEEM; } $user = $request->getUser(); $notificationManager->createTrivialNotification($user->getId(), $notificationType); $request->redirect(null, 'user', 'gifts'); }
/** * Delete a note. * @param $args array * @param $request PKPRequest */ function deleteNote($args, $request) { $this->setupTemplate($request); $noteId = (int) $request->getUserVar('noteId'); $noteDao = DAORegistry::getDAO('NoteDAO'); $note = $noteDao->getById($noteId); if (!$note || $note->getAssocType() != $this->_getAssocType() || $note->getAssocId() != $this->_getAssocId()) { fatalError('Invalid note!'); } $noteDao->deleteById($noteId); $user = $request->getUser(); NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedNote'))); $json = new JSONMessage(true); return $json->getString(); }
/** * Sign off the given file revision. * @param $args array * @param $request Request */ function signOffFile($args, $request) { // Retrieve the file to be signed off. $fileId = (int) $request->getUserVar('fileId'); // Make sure that the file revision is in the grid. $submissionFiles = $this->getGridDataElements($request); if (!isset($submissionFiles[$fileId])) { fatalError('Invalid file id!'); } assert(isset($submissionFiles[$fileId]['submissionFile'])); $submissionFile = $submissionFiles[$fileId]['submissionFile']; assert(is_a($submissionFile, 'SubmissionFile')); // Retrieve the user. $user = $request->getUser(); // Insert or update the sign off corresponding // to this file revision. $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $signoff = $signoffDao->build($this->getSymbolic(), ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId(), $user->getId()); $signoff->setDateCompleted(Core::getCurrentDate()); $signoffDao->updateObject($signoff); $this->setupTemplate($request); NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.signedFile'))); return DAO::getDataChangedEvent($fileId); }
/** * Hook registry function that is called when it's time to perform all automatic * deposits and notify the author of optional deposits. * @param $hookName string * @param $args array */ function callbackAuthorDeposits($hookName, $args) { $sectionEditorSubmission =& $args[0]; $request =& $this->getRequest(); // Determine if the most recent decision was an "Accept" $decisions = $sectionEditorSubmission->getDecisions(); $decisions = array_pop($decisions); // Rounds $decision = array_pop($decisions); $decisionConst = $decision ? $decision['decision'] : null; if ($decisionConst != SUBMISSION_EDITOR_DECISION_ACCEPT) { return false; } // The most recent decision was an "Accept"; perform auto deposits. $journal = $request->getJournal(); $depositPoints = $this->getSetting($journal->getId(), 'depositPoints'); import('classes.sword.OJSSwordDeposit'); import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $sendDepositNotification = $this->getSetting($journal->getId(), 'allowAuthorSpecify') ? true : false; foreach ($depositPoints as $depositPoint) { $depositType = $depositPoint['type']; if ($depositType == SWORD_DEPOSIT_TYPE_OPTIONAL_SELECTION || $depositType == SWORD_DEPOSIT_TYPE_OPTIONAL_FIXED) { $sendDepositNotification = true; } if ($depositType != SWORD_DEPOSIT_TYPE_AUTOMATIC) { continue; } // For each automatic deposit point, perform a deposit. $deposit = new OJSSwordDeposit($sectionEditorSubmission); $deposit->setMetadata(); $deposit->addEditorial(); $deposit->createPackage(); $deposit->deposit($depositPoint['url'], $depositPoint['username'], $depositPoint['password']); $deposit->cleanup(); unset($deposit); $user = $request->getUser(); $params = array('itemTitle' => $sectionEditorSubmission->getLocalizedTitle(), 'repositoryName' => $depositPoint['name']); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SWORD_AUTO_DEPOSIT_COMPLETE, $params); } if ($sendDepositNotification) { $submittingUser = $sectionEditorSubmission->getUser(); import('classes.mail.ArticleMailTemplate'); $mail = new ArticleMailTemplate($sectionEditorSubmission, 'SWORD_DEPOSIT_NOTIFICATION', null, null, $journal, true, true); $mail->setReplyTo(null); $mail->addRecipient($submittingUser->getEmail(), $submittingUser->getFullName()); $mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'articleTitle' => $sectionEditorSubmission->getLocalizedTitle(), 'swordDepositUrl' => $request->url(null, 'sword', 'index', $sectionEditorSubmission->getId()))); $mail->send($request); } return false; }
/** * Set context primary locale. * @param $args array * @param $request Request * @return JSONMessage JSON object */ function setContextPrimaryLocale($args, $request) { $locale = (string) $request->getUserVar('rowId'); $context = $request->getContext(); $availableLocales = $this->getGridDataElements($request); if (AppLocale::isLocaleValid($locale) && array_key_exists($locale, $availableLocales)) { // Make sure at least the primary locale is chosen as available foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) { ${$name} = $context->getSetting($name); if (!in_array($locale, ${$name})) { array_push(${$name}, $locale); $context->updateSetting($name, ${$name}); } } $context->setPrimaryLocale($locale); $contextDao = $context->getDAO(); $contextDao->updateObject($context); $notificationManager = new NotificationManager(); $user = $request->getUser(); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.localeSettingsSaved'))); } return DAO::getDataChangedEvent(); }
/** * Delete a file or revision * @param $args array * @param $request Request * @return JSONMessage JSON object */ function deleteFile($args, $request) { $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); $stageId = $request->getUserVar('stageId'); if ($stageId) { // validate the stage id. $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $user = $request->getUser(); $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $stageId, null, $user->getId()); } assert($submissionFile && $submission); // Should have been validated already $noteDao = DAORegistry::getDAO('NoteDAO'); $noteDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId()); // Delete the submission file. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ // check to see if we need to remove review_round_file associations if (!$stageAssignments->wasEmpty()) { $submissionFileDao->deleteReviewRoundAssignment($submission->getId(), $stageId, $submissionFile->getFileId(), $submissionFile->getRevision()); } $success = (bool) $submissionFileDao->deleteRevisionById($submissionFile->getFileId(), $submissionFile->getRevision(), $submissionFile->getFileStage(), $submission->getId()); $notificationMgr = new NotificationManager(); if ($success) { if ($submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_REVISION) { // Get a list of author user IDs $authorUserIds = array(); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR); while ($assignment = $submitterAssignments->next()) { $authorUserIds[] = $assignment->getUserId(); } // Update the notifications $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS, NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS), $authorUserIds, ASSOC_TYPE_SUBMISSION, $submission->getId()); $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $lastReviewRound->getId()); } $this->removeFileIndex($submission, $submissionFile); $fileManager = $this->getFileManager($submission->getContextId(), $submission->getId()); $fileManager->deleteFile($submissionFile->getFileId(), $submissionFile->getRevision()); $this->setupTemplate($request); $user = $request->getUser(); if (!$request->getUserVar('suppressNotification')) { NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedFile'))); } $this->logDeletionEvent($request, $submission, $submissionFile, $user); return DAO::getDataChangedEvent(); } else { return new JSONMessage(false); } }