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); }
/** * 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())); }
/** * Save announcement. */ function execute() { parent::execute(); $journal =& Request::getJournal(); $journalId = $journal->getId(); // Send a notification to associated users import('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); } $url = Request::url(null, 'announcement', 'view', array(1)); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($userRole['id'], 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT); } $notificationManager->sendToMailingList($notificationManager->createNotification(0, 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT)); }
/** * Save announcement. */ function execute() { $announcement = parent::execute(); $press =& Request::getPress(); $pressId = $press->getId(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $userGroupDao =& DAORegistry::getDAO('RoleAssignmentDAO'); $notificationUsers = array(); $allUsers = $userGroupDao->getUsersByContextId($pressId); while (!$allUsers->eof()) { $user =& $allUsers->next(); $notificationUsers[] = array('id' => $user->getId()); unset($user); } $url = Request::url(null, 'announcement', 'view', array($announcement->getId())); $notificationManager = new NotificationManager(); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($userRole['id'], 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT); } $notificationManager->sendToMailingList($notificationManager->createNotification(0, 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT)); }
/** * 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); }
/** * @copydoc ContextSettingsForm::execute() */ function execute($request) { $context = $request->getContext(); // Get the selected payment plugin $paymentPluginName = $this->getData('paymentPluginName'); if (isset($this->paymentPlugins[$paymentPluginName])) { $plugin = $this->paymentPlugins[$paymentPluginName]; // Save the plugin-specific settings foreach ($plugin->getSettingsFormFieldNames() as $settingName) { $plugin->updateSetting($context->getId(), $settingName, $this->getData($settingName)); } // Remove notification. $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationDao->deleteByAssoc($context->getAssocType(), $context->getId(), null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $context->getId()); } else { // Create notification. $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $context->getId(), $context->getAssocType(), $context->getId(), NOTIFICATION_LEVEL_NORMAL); } return parent::execute($request); }
/** * Save review form response. * @param $reviewId int * @param $reviewFormId int */ function saveReviewFormResponse($reviewId, $reviewFormId) { if (!HookRegistry::call('ReviewerAction::saveReviewFormResponse', array($reviewId, $reviewFormId))) { import('classes.submission.form.ReviewFormResponseForm'); $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId); $reviewForm->readInputData(); if ($reviewForm->validate()) { $reviewForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO'); $reviewAssignment = $reviewAssignmentDao->getById($reviewId); $sectionDecision =& $sectionDecisionDao->getSectionDecision($reviewAssignment->getDecisionId()); $articleId = $sectionDecision->getArticleId(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($articleId); $notificationUsers = $article->getAssociatedUserIds(); foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submission', array($article->getId(), 'submissionReview'), null, 'peerReview'); $notificationManager->createNotification($userRole['id'], 'notification.type.reviewerFormComment', $article->getScientificTitle, $url, 1, NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT); } } else { $reviewForm->display(); return false; } return true; } }
/** * Save a supplementary file. * @param $args array ($suppFileId) */ function saveSuppFile($args, $request) { $articleId = $request->getUserVar('articleId'); $submissionLayoutHandler = new SubmissionLayoutHandler(); $submissionLayoutHandler->validate($articleId); $submission =& $submissionLayoutHandler->submission; $this->setupTemplate(true, $articleId, 'editing'); $suppFileId = (int) array_shift($args); $journal =& $request->getJournal(); import('classes.submission.form.SuppFileForm'); $submitForm = new SuppFileForm($submission, $journal, $suppFileId); $submitForm->readInputData(); if ($submitForm->validate()) { $submitForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($articleId); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = $request->url(null, $userRole['role'], 'submissionEditing', $article->getId(), null, 'layout'); $notificationManager->createNotification($userRole['id'], 'notification.type.suppFileModified', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUPP_FILE_MODIFIED); } $request->redirect(null, null, 'submission', $articleId); } else { $submitForm->display(); } }
/** * Initiate a new review round and add selected files * to it. Also saves the new round to the submission. * @param $submission Submission * @param $stageId integer One of the WORKFLOW_STAGE_ID_* constants. * @param $request Request * @param $status integer One of the REVIEW_ROUND_STATUS_* constants. * @return $newRound integer The round number of the new review round. */ function _initiateReviewRound($submission, $stageId, $request, $status = null) { // If we already have review round for this stage, // we create a new round after the last one. $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */ $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId); if ($lastReviewRound) { $newRound = $lastReviewRound->getRound() + 1; } else { // If we don't have any review round, we create the first one. $newRound = 1; } // Create a new review round. $reviewRound = $reviewRoundDao->build($submission->getId(), $stageId, $newRound, $status); // Check for a notification already in place for the current review round. $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationFactory = $notificationDao->getByAssoc(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), null, NOTIFICATION_TYPE_REVIEW_ROUND_STATUS, $submission->getContextId()); // Create round status notification if there is no notification already. if ($notificationFactory->wasEmpty()) { $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_REVIEW_ROUND_STATUS, $submission->getContextId(), ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), NOTIFICATION_LEVEL_NORMAL); } // Add the selected files to the new round. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ // Bring in the SUBMISSION_FILE_* constants. import('lib.pkp.classes.submission.SubmissionFile'); // Bring in the Manager (we need it). import('lib.pkp.classes.file.SubmissionFileManager'); $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId()); foreach (array('selectedFiles', 'selectedAttachments') as $userVar) { $selectedFiles = $this->getData($userVar); if (is_array($selectedFiles)) { foreach ($selectedFiles as $fileId) { // Retrieve the file last revision number. $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId); list($newFileId, $newRevision) = $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_REVIEW_FILE, null, true); $submissionFileDao->assignRevisionToReviewRound($newFileId, $newRevision, $reviewRound); } } } return $newRound; }
/** * Save comment. * @param $commentId int */ function saveComment($article, &$comment, $emailComment) { if (!HookRegistry::call('Action::saveComment', array(&$article, &$comment, &$emailComment))) { import('classes.submission.form.comment.EditCommentForm'); $commentForm = new EditCommentForm($article, $comment); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submissionReview', $article->getId(), null, 'editorDecision'); $notificationManager->createNotification($userRole['id'], 'notification.type.submissionComment', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUBMISSION_COMMENT); } if ($emailComment) { $commentForm->email($commentForm->emailHelper()); } } else { $commentForm->display(); } } }
/** * Publish issue * @param $args array * @param $request Request */ function publishIssue($args, $request) { $issueId = (int) array_shift($args); $this->validate($issueId); $issue =& $this->issue; $journal =& $request->getJournal(); $journalId = $journal->getId(); if (!$issue->getPublished()) { // Set the status of any attendant queued articles to STATUS_PUBLISHED. $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $publishedArticles =& $publishedArticleDao->getPublishedArticles($issueId); foreach ($publishedArticles as $publishedArticle) { $article =& $articleDao->getArticle($publishedArticle->getId()); if ($article && $article->getStatus() == STATUS_QUEUED) { $article->setStatus(STATUS_PUBLISHED); $article->stampStatusModified(); $articleDao->updateArticle($article); } // delete article tombstone $tombstoneDao =& DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($article->getId()); unset($article); } } $issue->setCurrent(1); $issue->setPublished(1); $issue->setDatePublished(Core::getCurrentDate()); // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) { $delayDuration = $journal->getSetting('delayedOpenAccessDuration'); $delayYears = (int) floor($delayDuration / 12); $delayMonths = (int) fmod($delayDuration, 12); $curYear = date('Y'); $curMonth = date('n'); $curDay = date('j'); $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12); $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12); $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION); $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear))); } $issueDao =& DAORegistry::getDAO('IssueDAO'); $issueDao->updateCurrentIssue($journalId, $issue); // 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_PUBLISHED_ISSUE, $journalId); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId)); $request->redirect(null, null, 'issueToc', $issue->getId()); }
/** * Create a notification if none exists. * @param $request PKPRequest * @param $submissionId int * @param $userId int * @param $notificationType int NOTIFICATION_TYPE_ * @param $contextId int */ function _createNotification($request, $submissionId, $userId, $notificationType, $contextId) { $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */ $notificationFactory = $notificationDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId, $userId, $notificationType, $contextId); if ($notificationFactory->wasEmpty()) { $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, $userId, $notificationType, $contextId, ASSOC_TYPE_SUBMISSION, $submissionId, NOTIFICATION_LEVEL_NORMAL, null, true); } }
/** * Post copyedit comment. * @param $article object */ function postCopyeditComment($article, $emailComment, $request) { if (!HookRegistry::call('CopyeditorAction::postCopyeditComment', array(&$article, &$emailComment))) { import('classes.submission.form.comment.CopyeditCommentForm'); $commentForm = new CopyeditCommentForm($article, ROLE_ID_COPYEDITOR); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = $request->url(null, $userRole['role'], 'submissionEditing', $article->getId(), null, 'coypedit'); $notificationManager->createNotification($userRole['id'], 'notification.type.copyeditComment', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_COPYEDIT_COMMENT); } if ($emailComment) { $commentForm->email($request); } } else { $commentForm->display(); return false; } return true; } }
/** * Save changes to a galley. * @param $args array ($articleId, $galleyId) */ function saveGalley($args) { $articleId = isset($args[0]) ? (int) $args[0] : 0; $galleyId = isset($args[1]) ? (int) $args[1] : 0; $this->validate($articleId, SECTION_EDITOR_ACCESS_EDIT); $this->setupTemplate(true, $articleId, 'editing'); $submission =& $this->submission; import('classes.submission.form.ArticleGalleyForm'); $submitForm = new ArticleGalleyForm($articleId, $galleyId); $submitForm->readInputData(); if ($submitForm->validate()) { $submitForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($articleId); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submissionEditing', $article->getId(), null, 'layout'); $notificationManager->createNotification($userRole['id'], 'notification.type.galleyModified', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_GALLEY_MODIFIED); } if (Request::getUserVar('uploadImage')) { $submitForm->uploadImage(); Request::redirect(null, null, 'editGalley', array($articleId, $galleyId)); } else { if (($deleteImage = Request::getUserVar('deleteImage')) && count($deleteImage) == 1) { list($imageId) = array_keys($deleteImage); $submitForm->deleteImage($imageId); Request::redirect(null, null, 'editGalley', array($articleId, $galleyId)); } } Request::redirect(null, null, 'submissionEditing', $articleId); } else { $submitForm->display(); } }
/** * Save review form response. * @param $reviewId int * @param $reviewFormId int */ function saveReviewFormResponse($reviewId, $reviewFormId) { if (!HookRegistry::call('ReviewerAction::saveReviewFormResponse', array($reviewId, $reviewFormId))) { import('submission.form.ReviewFormResponseForm'); $reviewForm = new ReviewFormResponseForm($reviewId, $reviewFormId); $reviewForm->readInputData(); if ($reviewForm->validate()) { $reviewForm->execute(); // Send a notification to associated users import('notification.NotificationManager'); $notificationManager = new NotificationManager(); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment = $reviewAssignmentDao->getReviewAssignmentById($reviewId); $paperId = $reviewAssignment->getPaperId(); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paper =& $paperDao->getPaper($paperId); $notificationUsers = $paper->getAssociatedUserIds(); foreach ($notificationUsers as $userRole) { $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'peerReview'); $notificationManager->createNotification($userRole['id'], 'notification.type.reviewerFormComment', $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT); } } else { $reviewForm->display(); return false; } return true; } }
/** * Save a submission step. * @param $args array first parameter is the step being saved */ function saveSubmit($args, $request) { $step = (int) array_shift($args); $paperId = (int) $request->getUserVar('paperId'); $this->validate($request, $paperId, $step); $this->setupTemplate($request, true); $paper =& $this->paper; $formClass = "AuthorSubmitStep{$step}Form"; import("classes.author.form.submit.{$formClass}"); $submitForm = new $formClass($paper); $submitForm->readInputData(); if (!HookRegistry::call('SubmitHandler::saveSubmit', array($step, &$paper, &$submitForm))) { // Check for any special cases before trying to save switch ($step) { case 2: if ($request->getUserVar('uploadSubmissionFile')) { if (!$submitForm->uploadSubmissionFile('submissionFile')) { $submitForm->addError('uploadSubmissionFile', Locale::translate('common.uploadFailed')); } $editData = true; } break; case 3: if ($request->getUserVar('addAuthor')) { // Add a sponsor $editData = true; $authors = $submitForm->getData('authors'); array_push($authors, array()); $submitForm->setData('authors', $authors); } else { if (($delAuthor = $request->getUserVar('delAuthor')) && count($delAuthor) == 1) { // Delete an author $editData = true; list($delAuthor) = array_keys($delAuthor); $delAuthor = (int) $delAuthor; $authors = $submitForm->getData('authors'); if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) { $deletedAuthors = explode(':', $submitForm->getData('deletedAuthors')); array_push($deletedAuthors, $authors[$delAuthor]['authorId']); $submitForm->setData('deletedAuthors', join(':', $deletedAuthors)); } array_splice($authors, $delAuthor, 1); $submitForm->setData('authors', $authors); if ($submitForm->getData('primaryContact') == $delAuthor) { $submitForm->setData('primaryContact', 0); } } else { if ($request->getUserVar('moveAuthor')) { // Move an author up/down $editData = true; $moveAuthorDir = $request->getUserVar('moveAuthorDir'); $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd'; $moveAuthorIndex = (int) $request->getUserVar('moveAuthorIndex'); $authors = $submitForm->getData('authors'); if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) { $tmpAuthor = $authors[$moveAuthorIndex]; $primaryContact = $submitForm->getData('primaryContact'); if ($moveAuthorDir == 'u') { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1]; $authors[$moveAuthorIndex - 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $submitForm->setData('primaryContact', $moveAuthorIndex - 1); } else { if ($primaryContact == $moveAuthorIndex - 1) { $submitForm->setData('primaryContact', $moveAuthorIndex); } } } else { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1]; $authors[$moveAuthorIndex + 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $submitForm->setData('primaryContact', $moveAuthorIndex + 1); } else { if ($primaryContact == $moveAuthorIndex + 1) { $submitForm->setData('primaryContact', $moveAuthorIndex); } } } } $submitForm->setData('authors', $authors); } } } break; case 4: if ($request->getUserVar('submitUploadSuppFile')) { if ($suppFileId = SubmitHandler::submitUploadSuppFile(array(), $request)) { $request->redirect(null, null, null, 'submitSuppFile', $suppFileId, array('paperId' => $paperId)); } else { $submitForm->addError('uploadSubmissionFile', Locale::translate('common.uploadFailed')); } } break; } } if (!isset($editData) && $submitForm->validate()) { $paperId = $submitForm->execute(); $conference =& $request->getConference(); $schedConf =& $request->getSchedConf(); // For the "abstract only" or sequential review models, nothing else needs // to be collected beyond page 2. $reviewMode = $paper ? $paper->getReviewMode() : $schedConf->getSetting('reviewMode'); if ($step == 3 && $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL && !$schedConf->getSetting('acceptSupplementaryReviewMaterials') || $step == 3 && $reviewMode == REVIEW_MODE_ABSTRACTS_ALONE && !$schedConf->getSetting('acceptSupplementaryReviewMaterials') || $step == 5) { // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $notificationUsers = array(); $conferenceManagers = $roleDao->getUsersByRoleId(ROLE_ID_CONFERENCE_MANAGER); $allUsers = $conferenceManagers->toArray(); $directors = $roleDao->getUsersByRoleId(ROLE_ID_DIRECTOR); array_merge($allUsers, $directors->toArray()); foreach ($allUsers as $user) { $notificationUsers[] = array('id' => $user->getId()); } foreach ($notificationUsers as $userRole) { $url = $request->url(null, null, 'director', 'submission', $paperId); $notificationManager->createNotification($userRole['id'], 'notification.type.paperSubmitted', $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_PAPER_SUBMITTED); } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('conference', $conference); $templateMgr->assign('paperId', $paperId); $templateMgr->assign('helpTopicId', 'submission.index'); $templateMgr->display('author/submit/complete.tpl'); } elseif ($step == 3 && !$schedConf->getSetting('acceptSupplementaryReviewMaterials')) { $request->redirect(null, null, null, 'submit', 5, array('paperId' => $paperId)); } elseif ($step == 1 && ($reviewMode == REVIEW_MODE_ABSTRACTS_ALONE || $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL)) { $request->redirect(null, null, null, 'submit', 3, array('paperId' => $paperId)); } elseif ($step == 2 && $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL) { $nextStep = $schedConf->getSetting('acceptSupplementaryReviewMaterials') ? 4 : 5; $request->redirect(null, null, null, 'submit', $nextStep, array('paperId' => $paperId)); } else { $request->redirect(null, null, null, 'submit', $step + 1, array('paperId' => $paperId)); } } else { $submitForm->display(); } }
/** * Assigns a reviewer to a submission. * @param $request PKPRequest * @param $submission object * @param $reviewerId int * @param $reviewRound ReviewRound * @param $reviewDueDate datetime optional * @param $responseDueDate datetime optional */ function addReviewer($request, $submission, $reviewerId, &$reviewRound, $reviewDueDate = null, $responseDueDate = null, $reviewMethod = null) { $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao = DAORegistry::getDAO('UserDAO'); $reviewer = $userDao->getById($reviewerId); // Check to see if the requested reviewer is not already // assigned to review this submission. $assigned = $reviewAssignmentDao->reviewerExists($reviewRound->getId(), $reviewerId); // Only add the reviewer if he has not already // been assigned to review this submission. $stageId = $reviewRound->getStageId(); $round = $reviewRound->getRound(); if (!$assigned && isset($reviewer) && !HookRegistry::call('EditorAction::addReviewer', array(&$submission, $reviewerId))) { $reviewAssignment = new ReviewAssignment(); $reviewAssignment->setSubmissionId($submission->getId()); $reviewAssignment->setReviewerId($reviewerId); $reviewAssignment->setDateAssigned(Core::getCurrentDate()); $reviewAssignment->setStageId($stageId); $reviewAssignment->setRound($round); $reviewAssignment->setReviewRoundId($reviewRound->getId()); if (isset($reviewMethod)) { $reviewAssignment->setReviewMethod($reviewMethod); } $reviewAssignmentDao->insertObject($reviewAssignment); // Stamp modification date $submission->stampStatusModified(); $submissionDao = Application::getSubmissionDAO(); $submissionDao->updateObject($submission); $this->setDueDates($request, $submission, $reviewAssignment, $reviewDueDate, $responseDueDate); // Add notification $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, $reviewerId, NOTIFICATION_TYPE_REVIEW_ASSIGNMENT, $submission->getContextId(), ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId(), NOTIFICATION_LEVEL_TASK); // Insert a trivial notification to indicate the reviewer was added successfully. $currentUser = $request->getUser(); $notificationMgr = new NotificationManager(); $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.addedReviewer'))); // Update the review round status. $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */ $reviewAssignments = $reviewAssignmentDao->getBySubmissionId($submission->getId(), $reviewRound->getId(), $stageId); $reviewRoundDao->updateStatus($reviewRound, $reviewAssignments); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); // Add log import('lib.pkp.classes.log.SubmissionLog'); import('lib.pkp.classes.log.PKPSubmissionEventLogEntry'); SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_REVIEW_ASSIGN, 'log.review.reviewerAssigned', array('reviewerName' => $reviewer->getFullName(), 'submissionId' => $submission->getId(), 'stageId' => $stageId, 'round' => $round)); } }
/** * Save changes to the report file. * @return int the report file ID */ function execute($fileName = null) { $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($this->article->getArticleId()); $fileName = isset($fileName) ? $fileName : 'uploadReportFile'; $lastDecision = $this->article->getLastSectionDecision(); $lastDecisionDecision = $lastDecision->getDecision(); $lastDecisionType = $lastDecision->getReviewType(); // Ensure to start a new round of review when needed, and if the file to upload is correct if (($lastDecisionDecision == SUBMISSION_SECTION_DECISION_APPROVED || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_EXEMPTED || $lastDecisionType == REVIEW_TYPE_SAE && ($lastDecisionDecision == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_RESUBMIT)) && $articleFileManager->uploadedFileExists($fileName)) { $this->fileId = $articleFileManager->uploadSAEFile($fileName); } else { $this->fileId = 0; } if ($this->fileId && $this->fileId > 0) { $sectionDecision =& new SectionDecision(); $sectionDecision->setSectionId($lastDecision->getSectionId()); $sectionDecision->setDecision(0); $sectionDecision->setDateDecided(date(Core::getCurrentDate())); $sectionDecision->setArticleId($this->article->getArticleId()); $sectionDecision->setReviewType(REVIEW_TYPE_SAE); if ($lastDecisionType == $sectionDecision->getReviewType()) { $lastRound = (int) $lastDecision->getRound(); $sectionDecision->setRound($lastRound + 1); } else { $sectionDecision->setRound(1); } $sectionDecisionDao->insertSectionDecision($sectionDecision); $articleDao->changeArticleStatus($this->article->getArticleId(), STATUS_QUEUED); } // Notifications import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $journal =& Request::getJournal(); $url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($this->article->getArticleId(), 'submissionReview')); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $lastDecision->getSectionId()); foreach ($sectionEditors as $sectionEditor) { $notificationSectionEditors[] = array('id' => $sectionEditor->getId()); } foreach ($notificationSectionEditors as $userRole) { $notificationManager->createNotification($userRole['id'], 'notification.type.sae', $this->article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED); } return $this->fileId; }
/** * Save announcement. * @param $request PKPRequest */ function execute($request) { $announcementDao = DAORegistry::getDAO('AnnouncementDAO'); $announcement = $announcementDao->getById($this->announcementId); if (!$announcement) { $announcement = $announcementDao->newDataObject(); } $announcement->setAssocType(Application::getContextAssocType()); $announcement->setAssocId($this->getContextId()); $announcement->setTitle($this->getData('title'), null); // Localized $announcement->setDescriptionShort($this->getData('descriptionShort'), null); // Localized $announcement->setDescription($this->getData('description'), null); // Localized if ($this->getData('typeId')) { $announcement->setTypeId($this->getData('typeId')); } else { $announcement->setTypeId(null); } // Give the parent class a chance to set the dateExpire. $dateExpireSetted = $this->setDateExpire($announcement); if (!$dateExpireSetted) { if ($this->getData('dateExpireYear') != null) { $announcement->setDateExpire($this->getData('dateExpire')); } else { $announcement->setDateExpire(null); } } // Update or insert announcement if ($announcement->getId()) { $announcementDao->updateObject($announcement); } else { $announcement->setDatetimePosted(Core::getCurrentDate()); $announcementDao->insertObject($announcement); } $contextId = $this->getContextId(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $notificationUsers = array(); $allUsers = $userGroupDao->getUsersByContextId($contextId); while ($user = $allUsers->next()) { $notificationUsers[] = array('id' => $user->getId()); } if (!$this->announcementId) { // Only for new announcements foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_NEW_ANNOUNCEMENT, $contextId, ASSOC_TYPE_ANNOUNCEMENT, $announcement->getId()); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT, $contextId, ASSOC_TYPE_ANNOUNCEMENT, $announcement->getId())); } return $announcement->getId(); }
/** * Save changes to a galley. * @param $args array ($paperId, $galleyId) */ function saveGalley($args, $request) { $paperId = (int) array_shift($args); $galleyId = (int) array_shift($args); $round = (int) array_shift($args); $this->validate($request, $paperId, TRACK_DIRECTOR_ACCESS_EDIT); $this->setupTemplate($request, true, $paperId, 'editing'); $submission =& $this->submission; import('classes.submission.form.PaperGalleyForm'); $submitForm = new PaperGalleyForm($paperId, $galleyId, $round); $submitForm->readInputData(); if ($submitForm->validate()) { $submitForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paper =& $paperDao->getPaper($paperId); $notificationUsers = $paper->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = $request->url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'layout'); $notificationManager->createNotification($userRole['id'], 'notification.type.galleyModified', $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_GALLEY_MODIFIED); } if ($request->getUserVar('uploadImage')) { $submitForm->uploadImage(); $request->redirect(null, null, null, 'editGalley', array($paperId, $galleyId, $round)); } else { if (($deleteImage = $request->getUserVar('deleteImage')) && count($deleteImage) == 1) { list($imageId) = array_keys($deleteImage); $submitForm->deleteImage($imageId); $request->redirect(null, null, null, 'editGalley', array($paperId, $galleyId, $round)); } } $request->redirect(null, null, null, 'submissionReview', array($paperId, $round)); } else { $submitForm->display(); } }
/** * Add upload task notifications. * @param $request PKPRequest * @param $type int NOTIFICATION_TYPE_... * @param $userId int User ID * @param $submissionId int Submission ID */ private function _addAssignmentTaskNotification($request, $type, $userId, $submissionId) { $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */ $notificationFactory = $notificationDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId, $userId, $type); if ($notificationFactory->wasEmpty()) { $context = $request->getContext(); $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, $userId, $type, $context->getId(), ASSOC_TYPE_SUBMISSION, $submissionId, NOTIFICATION_LEVEL_TASK); } }
/** * Save comment. * @param $commentId int */ function saveComment($article, &$comment, $emailComment, $request) { if (!HookRegistry::call('Action::saveComment', array(&$article, &$comment, &$emailComment))) { import('classes.submission.form.comment.EditCommentForm'); $commentForm = new EditCommentForm($article, $comment); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_SUBMISSION_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); } if ($emailComment) { $commentForm->email($commentForm->emailHelper(), $request); } } else { $commentForm->display(); } } }
/** * @copydoc Form::execute() * @param $request PKPRequest * @return Note The created note object. */ function execute($request) { $user = $request->getUser(); // Create a new note. $noteDao = DAORegistry::getDAO('NoteDAO'); $note = $noteDao->getById($this->_noteId); $note->setUserId($request->getUser()->getId()); $note->setContents($this->getData('comment')); $noteDao->updateObject($note); // Check whether the query needs re-opening $query = $this->getQuery(); if ($query->getIsClosed()) { $headNote = $query->getHeadNote(); if ($user->getId() != $headNote->getUserId()) { // Re-open the query. $query->setIsClosed(false); $queryDao = DAORegistry::getDAO('QueryDAO'); $queryDao->updateObject($query); } } $notificationDao = DAORegistry::getDAO('NotificationDAO'); $queryDao = DAORegistry::getDAO('QueryDAO'); $notificationManager = new NotificationManager(); foreach ($queryDao->getParticipantIds($query->getId()) as $userId) { // Delete any prior notifications of the same type (e.g. prior "new" comments) $notificationDao->deleteByAssoc(ASSOC_TYPE_QUERY, $query->getId(), $userId, NOTIFICATION_TYPE_QUERY_ACTIVITY, $request->getContext()->getId()); // No need to additionally notify the posting user. if ($userId == $user->getId()) { continue; } // Notify the user of a new query. $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_QUERY_ACTIVITY, $request->getContext()->getId(), ASSOC_TYPE_QUERY, $query->getId(), NOTIFICATION_LEVEL_TASK); } return $note; }
/** * Post proofread comment. * @param $article object * @param $emailComment boolean * @param $request Request */ function postProofreadComment($article, $emailComment, $request) { if (HookRegistry::call('SectionEditorAction::postProofreadComment', array(&$article, &$emailComment))) { return; } import('classes.submission.form.comment.ProofreadCommentForm'); $commentForm = new ProofreadCommentForm($article, Validation::isEditor() ? ROLE_ID_EDITOR : ROLE_ID_SECTION_EDITOR); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PROOFREAD_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); } if ($emailComment) { $commentForm->email($request); } } else { $commentForm->display(); return false; } return true; }
/** * Publish issue * @param $args array * @param $request Request */ function publishIssue($args, $request) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); $issueId = $issue->getId(); $journal = $request->getJournal(); $journalId = $journal->getId(); $articleSearchIndex = null; if (!$issue->getPublished()) { $confirmationText = __('editor.issues.confirmPublish'); import('controllers.grid.pubIds.form.AssignPublicIdentifiersForm'); $formTemplate = $this->getAssignPublicIdentifiersFormTemplate(); $assignPublicIdentifiersForm = new AssignPublicIdentifiersForm($formTemplate, $issue, true, $confirmationText); if (!$request->getUserVar('confirmed')) { // Display assign pub ids modal $assignPublicIdentifiersForm->initData($args, $request); return new JSONMessage(true, $assignPublicIdentifiersForm->fetch($request)); } // Asign pub ids $assignPublicIdentifiersForm->readInputData(); $assignPublicIdentifiersForm->execute($request); // Set the status of any attendant queued articles to STATUS_PUBLISHED. $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $articleDao = DAORegistry::getDAO('ArticleDAO'); $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId); foreach ($publishedArticles as $publishedArticle) { $article = $articleDao->getById($publishedArticle->getId()); if ($article && $article->getStatus() == STATUS_QUEUED) { $article->setStatus(STATUS_PUBLISHED); $article->stampStatusModified(); $articleDao->updateObject($article); if (!$articleSearchIndex) { import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); } $articleSearchIndex->articleMetadataChanged($publishedArticle); } // delete article tombstone $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($article->getId()); } } $issue->setCurrent(1); $issue->setPublished(1); $issue->setDatePublished(Core::getCurrentDate()); // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) { $delayDuration = $journal->getSetting('delayedOpenAccessDuration'); $delayYears = (int) floor($delayDuration / 12); $delayMonths = (int) fmod($delayDuration, 12); $curYear = date('Y'); $curMonth = date('n'); $curDay = date('j'); $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12); $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12); $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION); $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear))); } $issueDao = DAORegistry::getDAO('IssueDAO'); $issueDao->updateCurrent($journalId, $issue); if ($articleSearchIndex) { $articleSearchIndex->articleChangesFinished(); } // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = array(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $allUsers = $userGroupDao->getUsersByContextId($journalId); while ($user = $allUsers->next()) { $notificationUsers[] = array('id' => $user->getId()); } foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId)); return DAO::getDataChangedEvent(); }
/** * Add a comment * @param $args array * @param $request Request */ function add($args, $request) { $articleId = isset($args[0]) ? (int) $args[0] : 0; $galleyId = isset($args[1]) ? (int) $args[1] : 0; $parentId = isset($args[2]) ? (int) $args[2] : 0; $journal =& $request->getJournal(); $commentDao =& DAORegistry::getDAO('CommentDAO'); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId); $parent =& $commentDao->getById($parentId, $articleId); if (isset($parent) && $parent->getSubmissionId() != $articleId) { $request->redirect(null, null, 'view', array($articleId, $galleyId)); } $this->validate($request, $articleId); $this->setupTemplate($request, $publishedArticle, $galleyId, $parent); // Bring in comment constants $enableComments = $journal->getSetting('enableComments'); switch ($enableComments) { case COMMENTS_UNAUTHENTICATED: break; case COMMENTS_AUTHENTICATED: case COMMENTS_ANONYMOUS: // The user must be logged in to post comments. if (!$request->getUser()) { Validation::redirectLogin(); } break; default: // Comments are disabled. Validation::redirectLogin(); } import('classes.comment.form.CommentForm'); $commentForm = new CommentForm(null, $articleId, $galleyId, isset($parent) ? $parentId : null); $commentForm->initData(); if (isset($args[3]) && $args[3] == 'save') { $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($articleId); $notificationUsers = $article->getAssociatedUserIds(); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_USER_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); } $request->redirect(null, null, 'view', array($articleId, $galleyId, $parentId), array('refresh' => 1)); } } $commentForm->display(); }
/** * Publish issue * @param $args array * @param $request Request */ function publishIssue($args, $request) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); $issueId = $issue->getId(); $journal = $request->getJournal(); $journalId = $journal->getId(); $articleSearchIndex = null; if (!$issue->getPublished()) { // Set the status of any attendant queued articles to STATUS_PUBLISHED. $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $articleDao = DAORegistry::getDAO('ArticleDAO'); $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId); foreach ($publishedArticles as $publishedArticle) { $article = $articleDao->getById($publishedArticle->getId()); if ($article && $article->getStatus() == STATUS_QUEUED) { $article->setStatus(STATUS_PUBLISHED); $article->stampStatusModified(); $articleDao->updateObject($article); if (!$articleSearchIndex) { import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); } $articleSearchIndex->articleMetadataChanged($publishedArticle); } // delete article tombstone $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($article->getId()); } } $issue->setCurrent(1); $issue->setPublished(1); $issue->setDatePublished(Core::getCurrentDate()); // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) { $delayDuration = $journal->getSetting('delayedOpenAccessDuration'); $delayYears = (int) floor($delayDuration / 12); $delayMonths = (int) fmod($delayDuration, 12); $curYear = date('Y'); $curMonth = date('n'); $curDay = date('j'); $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12); $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12); $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION); $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear))); } $issueDao = DAORegistry::getDAO('IssueDAO'); $issueDao->updateCurrent($journalId, $issue); if ($articleSearchIndex) { $articleSearchIndex->articleChangesFinished(); } // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = array(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $allUsers = $userGroupDao->getUsersByContextId($journalId); while ($user = $allUsers->next()) { $notificationUsers[] = array('id' => $user->getId()); } foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId)); $dispatcher = $request->getDispatcher(); // FIXME: Find a better way to reload the containing tabs. // Without this, issues don't move between tabs properly. return $request->redirectUrlJson($dispatcher->url($request, ROUTE_PAGE, null, 'manageIssues')); }
/** * Post proofread comment. * @param $article object * @param $emailComment boolean */ function postProofreadComment($article, $emailComment) { if (HookRegistry::call('SectionEditorAction::postProofreadComment', array(&$article, &$emailComment))) { return; } import('classes.submission.form.comment.ProofreadCommentForm'); $commentForm = new ProofreadCommentForm($article, Validation::isEditor() ? ROLE_ID_EDITOR : ROLE_ID_SECTION_EDITOR); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submissionEditing', $article->getId(), null, 'proofread'); $notificationManager->createNotification($userRole['id'], 'notification.type.proofreadComment', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_PROOFREAD_COMMENT); } if ($emailComment) { $commentForm->email(); } } else { $commentForm->display(); return false; } return true; }
/** * Save a submission step. * @param $args array first parameter is the step being saved * @param $request Request */ function saveSubmit($args, $request) { $step = (int) array_shift($args); $articleId = (int) $request->getUserVar('articleId'); $journal =& $request->getJournal(); $this->validate($request, $articleId, $step); $this->setupTemplate($request, true); $article =& $this->article; $formClass = "AuthorSubmitStep{$step}Form"; import("classes.author.form.submit.{$formClass}"); $submitForm = new $formClass($article, $journal, $request); $submitForm->readInputData(); if (!HookRegistry::call('SubmitHandler::saveSubmit', array($step, &$article, &$submitForm))) { // Check for any special cases before trying to save switch ($step) { case 2: if ($request->getUserVar('uploadSubmissionFile')) { $submitForm->uploadSubmissionFile('submissionFile'); $editData = true; } break; case 3: if ($request->getUserVar('addAuthor')) { // Add a sponsor $editData = true; $authors = $submitForm->getData('authors'); array_push($authors, array()); $submitForm->setData('authors', $authors); } else { if (($delAuthor = $request->getUserVar('delAuthor')) && count($delAuthor) == 1) { // Delete an author $editData = true; list($delAuthor) = array_keys($delAuthor); $delAuthor = (int) $delAuthor; $authors = $submitForm->getData('authors'); if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) { $deletedAuthors = explode(':', $submitForm->getData('deletedAuthors')); array_push($deletedAuthors, $authors[$delAuthor]['authorId']); $submitForm->setData('deletedAuthors', join(':', $deletedAuthors)); } array_splice($authors, $delAuthor, 1); $submitForm->setData('authors', $authors); if ($submitForm->getData('primaryContact') == $delAuthor) { $submitForm->setData('primaryContact', 0); } } else { if ($request->getUserVar('moveAuthor')) { // Move an author up/down $editData = true; $moveAuthorDir = $request->getUserVar('moveAuthorDir'); $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd'; $moveAuthorIndex = (int) $request->getUserVar('moveAuthorIndex'); $authors = $submitForm->getData('authors'); if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) { $tmpAuthor = $authors[$moveAuthorIndex]; $primaryContact = $submitForm->getData('primaryContact'); if ($moveAuthorDir == 'u') { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1]; $authors[$moveAuthorIndex - 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $submitForm->setData('primaryContact', $moveAuthorIndex - 1); } else { if ($primaryContact == $moveAuthorIndex - 1) { $submitForm->setData('primaryContact', $moveAuthorIndex); } } } else { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1]; $authors[$moveAuthorIndex + 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $submitForm->setData('primaryContact', $moveAuthorIndex + 1); } else { if ($primaryContact == $moveAuthorIndex + 1) { $submitForm->setData('primaryContact', $moveAuthorIndex); } } } } $submitForm->setData('authors', $authors); } } } break; case 4: if ($request->getUserVar('submitUploadSuppFile')) { $this->submitUploadSuppFile(array(), $request); return; } break; } if (!isset($editData) && $submitForm->validate()) { $articleId = $submitForm->execute(); HookRegistry::call('Author::SubmitHandler::saveSubmit', array(&$step, &$article, &$submitForm)); if ($step == 5) { // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($articleId); $roleDao =& DAORegistry::getDAO('RoleDAO'); $notificationUsers = array(); $editors = $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getId()); while ($editor =& $editors->next()) { $notificationManager->createNotification($request, $editor->getId(), NOTIFICATION_TYPE_ARTICLE_SUBMITTED, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); unset($editor); } $journal =& $request->getJournal(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('journal', $journal); // If this is an editor and there is a // submission file, article can be expedited. if (Validation::isEditor($journal->getId()) && $article->getSubmissionFileId()) { $templateMgr->assign('canExpedite', true); } $templateMgr->assign('articleId', $articleId); $templateMgr->assign('helpTopicId', 'submission.index'); $templateMgr->display('author/submit/complete.tpl'); } else { $request->redirect(null, null, 'submit', $step + 1, array('articleId' => $articleId)); } } else { $submitForm->display(); } } }
public static function approveAddon($id, $board, $approver) { $database = new DatabaseManager(); //to do: check for mysql error and handle it $database->query("UPDATE `addon_addons` SET `approved`='1', `board`='" . $database->sanitize($board) . "' WHERE `id`='" . $database->sanitize($id) . "'"); apc_delete('addonObject_' . $id); $manager = AddonManager::getFromId($id)->getManagerBLID(); $params = new stdClass(); $params->vars = array(); $user = new stdClass(); $user->type = "user"; $user->blid = $approver; $addon = new stdClass(); $addon->type = "addon"; $addon->id = $id; $params->vars[] = $user; $params->vars[] = $addon; NotificationManager::createNotification($manager, '$2 was approved by $1', $params); }