/** * @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; }
/** * 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'); }
/** * 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(); }
/** * @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 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; }
/** * @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); }
/** * 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)); }
/** * Delete a file or revision * @param $args array * @param $request Request * @return string a serialized 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 all signoffs related with this file. $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $signoffFactory = $signoffDao->getAllByAssocType(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId()); $signoffs = $signoffFactory->toArray(); $notificationMgr = new NotificationManager(); foreach ($signoffs as $signoff) { $signoffDao->deleteObject($signoff); // Delete for all users. $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST, NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT), null, ASSOC_TYPE_SIGNOFF, $signoff->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); } // 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()); if ($success) { if ($submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_REVISION) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS, NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS), array($submission->getUserId()), 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->indexSubmissionFiles($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 { $json = new JSONMessage(false); return $json->getString(); } }
/** * 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); }
/** * Get cell actions associated with this row/column combination * @param $row GridRow * @param $column GridColumn * @return array an array of LinkAction instances */ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) { assert($column->getId() == 'task'); $notification = $row->getData(); $contextDao = Application::getContextDAO(); $context = $contextDao->getById($notification->getContextId()); $notificationMgr = new NotificationManager(); $router = $request->getRouter(); return array(new LinkAction('details', new AjaxAction($router->url($request, null, null, 'markRead', null, array('redirect' => 1, 'selectedElements' => array($notification->getId())))), ($notification->getDateRead() ? '' : '<strong>') . __('common.tasks.titleAndTask', array('acronym' => $context->getLocalizedAcronym(), 'title' => $this->_getTitle($notification), 'task' => $notificationMgr->getNotificationMessage($request, $notification))) . ($notification->getDateRead() ? '' : '</strong>'))); }
/** * Save the form * @param $request PKPRequest */ function execute($request) { $userEmail = $this->getData('email'); $context = $request->getContext(); $notificationMailListDao = DAORegistry::getDAO('NotificationMailListDAO'); if ($password = $notificationMailListDao->subscribeGuest($userEmail, $context->getId())) { $notificationManager = new NotificationManager(); $notificationManager->sendMailingListEmail($request, $userEmail, $password, 'NOTIFICATION_MAILLIST_WELCOME'); return true; } else { $request->redirect(null, 'notification', 'mailListSubscribed', array('error')); return false; } }
public function postDispatch() { $o_view = new View($this->getRequest(), $this->getRequest()->config->get('views_directory')); $o_notification = new NotificationManager($this->getRequest()); if ($o_notification->numNotifications()) { $o_view->setVar('notifications', $o_notification->getNotifications($this->getResponse()->isRedirect())); $this->getResponse()->prependContent($o_view->render('pageFormat/notifications.php'), 'notifications'); } //$nav = new AppNavigation($this->getRequest(), $this->getResponse()); $o_view->setVar('nav', $nav); //$this->getResponse()->prependContent($o_view->render('pageFormat/menuBar.php'), 'menubar'); $this->getResponse()->prependContent($o_view->render('pageFormat/pageHeader.php'), 'head'); $this->getResponse()->appendContent($o_view->render('pageFormat/pageFooter.php'), 'footer'); }
public function handle(Event $event) { $manager = new NotificationManager(); $notificationType = $event->name; $manager->setNotificationType($notificationType); $manager->setUser($event->args[0]); if (isset($event->args[1])) { $notificationObject = $event->args[1]; $manager->setNotificationObject($notificationObject); } if (isset($event->args[1])) { $time = $event->args[2]; $manager->add($time); } }
/** * 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(); }
public function setVerified($bool) { NotificationManager::createNotification($this, "Your account was verified.", array()); $database = new DatabaseManager(); $database->query("UPDATE `users` SET `verified`='" . $database->sanitize($bool) . "' WHERE `email`='" . $database->sanitize($this->getEmail()) . "'"); apc_store('userObject_' . $this->blid, $this, 600); }
/** * 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)); } }
private static function getInstance() { if (!self::$theInstance) { self::$theInstance = new EmailNotificationManager(); } return self::$theInstance; }
/** * Save 'manage copyedited files' form * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateCopyeditFiles($args, $request) { $submission = $this->getSubmission(); import('lib.pkp.controllers.grid.files.copyedit.form.ManageCopyeditFilesForm'); $manageCopyeditFilesForm = new ManageCopyeditFilesForm($submission->getId()); $manageCopyeditFilesForm->readInputData(); if ($manageCopyeditFilesForm->validate()) { $manageCopyeditFilesForm->execute($args, $request, $this->getGridCategoryDataElements($request, $this->getStageId())); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); // Let the calling grid reload itself return DAO::getDataChangedEvent(); } else { return new JSONMessage(false); } }
/** * 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(); if (!file_exists($filename)) { $dir = dirname($filename); if (!file_exists($dir)) { mkdir($dir); } $localeList = PKPLocale::getAllLocales(); file_put_contents($filename, strtr(file_get_contents(self::$plugin->getRegistryPath() . '/locale.xml'), array('{$locale}' => $this->locale, '{$localeName}' => $localeList[$this->locale]))); } // Use the EditableLocaleFile class to handle changes. import('lib.pkp.classes.file.EditableLocaleFile'); $this->file = new EditableLocaleFile($this->locale, $filename); // Delegate processing to the listbuilder handler. This will invoke the callbacks below. self::$plugin->import('controllers.listbuilder.LocaleFileListbuilderHandler'); if (LocaleFileListbuilderHandler::unpack($request, $request->getUserVar('localeKeys'))) { if ($this->file->write()) { $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)))); } } else { // Some kind of error occurred (probably garbled formatting) $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.errorEditingFile', array('filename' => $filename)))); } $message = new JSONMessage(true); return $message->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()); // 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(); } }
/** * Get cell actions associated with this row/column combination * @param $row GridRow * @param $column GridColumn * @return array an array of LinkAction instances */ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) { assert($column->getId() == 'task'); $templateMgr = TemplateManager::getManager($request); $notification = $row->getData(); $contextDao = Application::getContextDAO(); $context = $contextDao->getById($notification->getContextId()); $notificationMgr = new NotificationManager(); $router = $request->getRouter(); $templateMgr->assign(array('notificationMgr' => $notificationMgr, 'notification' => $notification, 'context' => $context, 'notificationObjectTitle' => $this->_getTitle($notification), 'message' => PKPString::stripUnsafeHtml($notificationMgr->getNotificationMessage($request, $notification)))); // See if we're working in a multi-context environment $user = $request->getUser(); $contextDao = Application::getContextDAO(); $contexts = $contextDao->getAvailable($user ? $user->getId() : null)->toArray(); $templateMgr->assign('isMultiContext', count($contexts) > 1); return array(new LinkAction('details', new AjaxAction($router->url($request, null, null, 'markRead', null, array('redirect' => 1, 'selectedElements' => array($notification->getId())))), $templateMgr->fetch('controllers/grid/tasks/task.tpl'))); }
/** * 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); } }
/** * 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'); }
/** * 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); }
/** * 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(); } }
/** * Save announcement. * @param $request Request */ function execute(&$request) { $announcement = parent::execute(); $journalId = $this->getContextId(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $notificationUsers = array(); $allUsers = $roleDao->getUsersByJournalId($journalId); while (!$allUsers->eof()) { $user =& $allUsers->next(); $notificationUsers[] = array('id' => $user->getId()); unset($user); } foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_NEW_ANNOUNCEMENT, $journalId, ASSOC_TYPE_ANNOUNCEMENT, $announcement->getId()); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT, $journalId, ASSOC_TYPE_ANNOUNCEMENT, $announcement->getId())); }
/** * 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'); }
/** * 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(); }