/** * Gathers the state of a given cell given a $row/$column combination * @param $row GridRow * @param $column GridColumn * @return string */ function getCellState(&$row, &$column) { $element =& $row->getData(); $columnId = $column->getId(); assert(is_a($element, 'DataObject') && !empty($columnId)); switch ($columnId) { case 'name': return $element->getDateCompleted() ? 'linkReview' : ''; case is_numeric($columnId): // numeric implies a role column. if ($element->getDateCompleted()) { $viewsDao =& DAORegistry::getDAO('ViewsDAO'); $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $user =& $session->getUser(); $lastViewed = $viewsDao->getLastViewDate(ASSOC_TYPE_REVIEW_RESPONSE, $element->getId(), $user->getId()); if ($lastViewed) { return 'completed'; } else { return 'new'; } } else { return ''; } case 'reviewer': if ($element->getDateCompleted()) { return 'completed'; } elseif ($element->getDateDue() < Core::getCurrentDate()) { return 'overdue'; } elseif ($element->getDateConfirmed()) { return $element->getDeclined() ? 'declined' : 'accepted'; } return 'new'; } }
/** * Add a new event log entry with the specified parameters * @param $request object * @param $submission object * @param $eventType int * @param $messageKey string * @param $params array optional * @return object SubmissionLogEntry iff the event was logged */ static function logEvent($request, $submission, $eventType, $messageKey, $params = array()) { // Create a new entry object $submissionEventLogDao = DAORegistry::getDAO('SubmissionEventLogDAO'); $entry = $submissionEventLogDao->newDataObject(); // Set implicit parts of the log entry $entry->setDateLogged(Core::getCurrentDate()); $entry->setIPAddress($request->getRemoteAddr()); if (Validation::isLoggedInAs()) { // If user is logged in as another user log with real userid $sessionManager = SessionManager::getManager(); $session = $sessionManager->getUserSession(); $userId = $session->getSessionVar('signedInAs'); if ($userId) { $entry->setUserId($userId); } } else { $user = $request->getUser(); if ($user) { $entry->setUserId($user->getId()); } } $entry->setSubmissionId($submission->getId()); // Set explicit parts of the log entry $entry->setEventType($eventType); $entry->setMessage($messageKey); $entry->setParams($params); $entry->setIsTranslated(0); // Legacy for old entries. All messages now use locale keys. // Insert the resulting object $submissionEventLogDao->insertObject($entry); return $entry; }
/** * Create a new temporary file from an article file. * @param $articleFile object * @param $userId int * @return object The new TemporaryFile or false on failure */ function articleToTemporaryFile($articleFile, $userId) { // Get the file extension, then rename the file. $fileExtension = $this->parseFileExtension($articleFile->getFileName()); if (!$this->fileExists($this->filesDir, 'dir')) { // Try to create destination directory $this->mkdirtree($this->filesDir); } $newFileName = basename(tempnam($this->filesDir, $fileExtension)); if (!$newFileName) { return false; } if (copy($articleFile->getFilePath(), $this->filesDir . $newFileName)) { $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = new TemporaryFile(); $temporaryFile->setUserId($userId); $temporaryFile->setFileName($newFileName); $temporaryFile->setFileType($articleFile->getFileType()); $temporaryFile->setFileSize($articleFile->getFileSize()); $temporaryFile->setOriginalFileName($articleFile->getOriginalFileName()); $temporaryFile->setDateUploaded(Core::getCurrentDate()); $temporaryFileDao->insertTemporaryFile($temporaryFile); return $temporaryFile; } else { return false; } }
function addEntry(&$logEntry, $file = null) { if (!isset($file)) { $file = $this->getLogFilename(); } $stamp = strtr(Core::getCurrentDate(), "\t", " "); $user = strtr($logEntry->getUser(), "\t", " "); $site = strtr($logEntry->getSite(), "\t", " "); $journal = strtr($logEntry->getJournal(), "\t", " "); $publisher = strtr($logEntry->getPublisher(), "\t", " "); $printIssn = strtr($logEntry->getPrintIssn(), "\t", " "); $onlineIssn = strtr($logEntry->getOnlineIssn(), "\t", " "); $type = strtr($logEntry->getType(), "\t", " "); $value = strtr($logEntry->getValue(), "\t", " "); $journalUrl = strtr($logEntry->getJournalUrl(), "\t", " "); $line = "{$stamp}\t{$user}\t{$site}\t{$journal}\t{$publisher}\t{$printIssn}\t{$onlineIssn}\t{$type}\t{$value}\t{$journalUrl}\n"; $fp = fopen($file, 'a'); if (!$fp) { return false; } if (!flock($fp, LOCK_EX)) { fclose($fp); return false; } fwrite($fp, $line); fclose($fp); }
/** * @see ScheduledTask::executeActions() */ function executeActions() { if (!$this->_plugin) { return false; } if (!$this->_depositUrl) { $this->addExecutionLogEntry(__('plugins.generic.alm.senderTask.error.noDepositUrl'), SCHEDULED_TASK_MESSAGE_TYPE_ERROR); return false; } $plugin = $this->_plugin; $journals = $this->_getJournals(); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); /* @var $publishedArticleDao PublishedArticleDAO */ foreach ($journals as $journal) { $journalId = $journal->getId(); $lastExport = $plugin->getSetting($journalId, 'lastExport'); $articles =& $publishedArticleDao->getPublishedArticlesByJournalId($journalId, null, true); $articlesSinceLast = array(); while ($article =& $articles->next()) { if (strtotime($article->getDatePublished()) > $lastExport) { $articlesSinceLast[] = $article; } else { break; } unset($article); } if ($this->_exportArticles($journal, $articlesSinceLast)) { $plugin->updateSetting($journalId, 'lastExport', Core::getCurrentDate(), 'date'); } } if (empty($journals)) { $this->addExecutionLogEntry(__('plugins.generic.alm.senderTask.warning.noJournal'), SCHEDULED_TASK_MESSAGE_TYPE_WARNING); } return true; }
/** * Redeem a gift for a user. * @param $assocType int * @param $assocId int * @param $userId int * @param $giftId int * @return int Status code indicating whether gift could be redeemed */ function redeemGift($assocType, $assocId, $userId, $giftId) { // Ensure user has this gift if (!$this->recipientHasGift($assocType, $assocId, $userId, $giftId)) { return GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM; } // Ensure user has not already redeemed this gift if (!$this->recipientHasNotRedeemedGift($assocType, $assocId, $userId, $giftId)) { return GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED; } // Retrieve and try to redeem the gift $gift = $this->getGift($giftId); switch ($gift->getGiftType()) { case GIFT_TYPE_SUBSCRIPTION: $returner = $this->_redeemGiftSubscription($gift); break; default: $returner = GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID; } // If all went well, mark gift as redeemed if ($returner == GIFT_REDEEM_STATUS_SUCCESS) { $gift->setStatus(GIFT_STATUS_REDEEMED); $gift->setDatetimeRedeemed(Core::getCurrentDate()); $this->updateObject($gift); } return $returner; }
/** * Increment the view count for a published article * @param $journalId int * @param $pubId int * @param $ipAddress string * @param $userAgent string */ function incrementViewCount($journalId, $articleId, $galleyId = null, $ipAddress = null, $userAgent = null) { $this->update(sprintf('INSERT INTO timed_views_log (submission_id, galley_id, journal_id, date, ip_address, user_agent) VALUES (?, ?, ?, %s, ?, ?)', $this->datetimeToDB(Core::getCurrentDate())), array((int) $articleId, isset($galleyId) ? (int) $galleyId : null, (int) $journalId, $ipAddress, $userAgent)); }
/** * Add the comment. */ function execute() { // Personalized execute() method since now there are possibly two comments contained within each form submission. $commentDao = DAORegistry::getDAO('PaperCommentDAO'); $this->insertedComments = array(); // Assign all common information $comment = new PaperComment(); $comment->setCommentType($this->commentType); $comment->setRoleId($this->roleId); $comment->setPaperId($this->paper->getPaperId()); $comment->setAssocId($this->assocId); $comment->setAuthorId($this->user->getId()); $comment->setCommentTitle($this->getData('commentTitle')); $comment->setDatePosted(Core::getCurrentDate()); // If comments "For authors and director" submitted if ($this->getData('authorComments') != null) { $comment->setComments($this->getData('authorComments')); $comment->setViewable(1); array_push($this->insertedComments, $commentDao->insertPaperComment($comment)); } // If comments "For director" submitted if ($this->getData('comments') != null) { $comment->setComments($this->getData('comments')); $comment->setViewable(null); array_push($this->insertedComments, $commentDao->insertPaperComment($comment)); } }
/** * View an assigned submission's layout editing page. * @param $args array ($articleId) */ function submission($args) { $articleId = isset($args[0]) ? $args[0] : 0; list($journal, $submission) = SubmissionLayoutHandler::validate($articleId); parent::setupTemplate(true, $articleId); import('submission.proofreader.ProofreaderAction'); ProofreaderAction::layoutEditorProofreadingUnderway($submission); $layoutAssignment =& $submission->getLayoutAssignment(); if ($layoutAssignment->getDateNotified() != null && $layoutAssignment->getDateUnderway() == null) { // Set underway date $layoutAssignment->setDateUnderway(Core::getCurrentDate()); $layoutDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO'); $layoutDao->updateSubmission($submission); } $disableEdit = !SubmissionLayoutHandler::layoutEditingEnabled($submission); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('submission', $submission); $templateMgr->assign('disableEdit', $disableEdit); $templateMgr->assign('useProofreaders', $journal->getSetting('useProofreaders')); $templateMgr->assign('templates', $journal->getSetting('templates')); $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.layout'); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($submission->getArticleId()); if ($publishedArticle) { $issueDao =& DAORegistry::getDAO('IssueDAO'); $issue =& $issueDao->getIssueById($publishedArticle->getIssueId()); $templateMgr->assign_by_ref('publishedArticle', $publishedArticle); $templateMgr->assign_by_ref('issue', $issue); } $templateMgr->display('layoutEditor/submission.tpl'); }
/** * Upload a profile image. * @return boolean True iff success. */ function uploadProfileImage() { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $user = $this->getUser(); $type = $publicFileManager->getUploadedFileType('uploadedFile'); $extension = $publicFileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'profileImage-' . (int) $user->getId() . $extension; if (!$publicFileManager->uploadSiteFile('uploadedFile', $uploadName)) { return false; } $filePath = $publicFileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $uploadName); if ($width > PROFILE_IMAGE_MAX_WIDTH || $height > PROFILE_IMAGE_MAX_HEIGHT || $width <= 0 || $height <= 0) { $userSetting = null; $user->updateSetting('profileImage', $userSetting); $publicFileManager->removeSiteFile($filePath); return false; } $user->updateSetting('profileImage', array('name' => $publicFileManager->getUploadedFileName('uploadedFile'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate())); return true; }
function resubmit($args) { $articleId = isset($args[0]) ? (int) $args[0] : 0; $sectionDecisionDao = DAORegistry::getDAO('SectionDecisionDAO'); $lastDecision = $sectionDecisionDao->getLastSectionDecision($articleId); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission = $authorSubmissionDao->getAuthorSubmission($articleId); $lastDecisionValue = $lastDecision->getDecision(); if ($lastDecisionValue == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionValue == SUBMISSION_SECTION_DECISION_RESUBMIT) { $newSectionDecision =& new SectionDecision(); $newSectionDecision->setArticleId($articleId); $newSectionDecision->setReviewType($lastDecision->getReviewType()); $newSectionDecision->setRound($lastDecision->getRound() + 1); $newSectionDecision->setSectionId($lastDecision->getSectionId()); $newSectionDecision->setDecision(0); $newSectionDecision->setDateDecided(date(Core::getCurrentDate())); $authorSubmission->addDecision($newSectionDecision); $authorSubmissionDao->updateAuthorSubmission($authorSubmission); $step = 2; $articleDao =& DAORegistry::getDAO('ArticleDAO'); $articleDao->changeArticleStatus($articleId, STATUS_QUEUED); $articleDao->changeArticleProgress($articleId, $step); Request::redirect(null, null, 'submit', $step, array('articleId' => $articleId)); } else { Request::redirect(null, 'author', ''); } }
/** * Save changes to monograph. * @return int the monograph ID */ function execute() { $monographDao =& DAORegistry::getDAO('MonographDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); // Update monograph $monograph =& $this->monograph; $monograph->setTitle($this->getData('title'), null); // Localized $monograph->setAbstract($this->getData('abstract'), null); // Localized if (is_array($this->getData('agenciesKeywords'))) { $monograph->setSupportingAgencies(implode(", ", $this->getData('agenciesKeywords')), null); } // Localized if (is_array($this->getData('disciplinesKeywords'))) { $monograph->setDiscipline(implode(", ", $this->getData('disciplinesKeywords')), null); } // Localized if (is_array($this->getData('keywordKeywords'))) { $monograph->setSubject(implode(", ", $this->getData('keywordKeywords')), null); } // Localized if ($monograph->getSubmissionProgress() <= $this->step) { $monograph->setDateSubmitted(Core::getCurrentDate()); $monograph->stampStatusModified(); $monograph->setSubmissionProgress(0); } // Assign the default users to the submission workflow stage import('classes.submission.common.Action'); Action::assignDefaultStageParticipants($monograph->getId(), WORKFLOW_STAGE_ID_SUBMISSION); // Save the monograph $monographDao->updateMonograph($monograph); return $this->monographId; }
/** * View an assigned submission's layout editing page. * @param $args array ($articleId) */ function submission($args) { $articleId = isset($args[0]) ? $args[0] : 0; $journal =& Request::getJournal(); $submissionLayoutHandler = new SubmissionLayoutHandler(); $submissionLayoutHandler->validate($articleId); $submission =& $submissionLayoutHandler->submission; $this->setupTemplate(true, $articleId); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); import('classes.submission.proofreader.ProofreaderAction'); ProofreaderAction::proofreadingUnderway($submission, 'SIGNOFF_PROOFREADING_LAYOUT'); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId); if ($layoutSignoff->getDateNotified() != null && $layoutSignoff->getDateUnderway() == null) { // Set underway date $layoutSignoff->setDateUnderway(Core::getCurrentDate()); $signoffDao->updateObject($layoutSignoff); } $disableEdit = !$this->layoutEditingEnabled($submission); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('submission', $submission); $templateMgr->assign('disableEdit', $disableEdit); $templateMgr->assign('useProofreaders', $journal->getSetting('useProofreaders')); $templateMgr->assign('templates', $journal->getSetting('templates')); $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.layout'); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($submission->getArticleId()); if ($publishedArticle) { $issueDao =& DAORegistry::getDAO('IssueDAO'); $issue =& $issueDao->getIssueById($publishedArticle->getIssueId()); $templateMgr->assign_by_ref('publishedArticle', $publishedArticle); $templateMgr->assign_by_ref('issue', $issue); } $templateMgr->display('layoutEditor/submission.tpl'); }
function sendReminder($reviewAssignment, $article, $journal) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $reviewId = $reviewAssignment->getReviewId(); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId()); if (!isset($reviewer)) { return false; } import('mail.ArticleMailTemplate'); $reviewerAccessKeysEnabled = $journal->getSetting('reviewerAccessKeysEnabled'); $email =& new ArticleMailTemplate($article, $reviewerAccessKeysEnabled ? 'REVIEW_REMIND_AUTO_ONECLICK' : 'REVIEW_REMIND_AUTO', null, false, $journal); $email->setJournal($journal); $email->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName()); $email->setAssoc(ARTICLE_EMAIL_REVIEW_REMIND, ARTICLE_EMAIL_TYPE_REVIEW, $reviewId); $email->setSubject($email->getSubject($journal->getPrimaryLocale())); $email->setBody($email->getBody($journal->getPrimaryLocale())); $urlParams = array(); if ($reviewerAccessKeysEnabled) { import('security.AccessKeyManager'); $accessKeyManager =& new AccessKeyManager(); // Key lifetime is the typical review period plus four weeks $keyLifetime = ($journal->getSetting('numWeeksPerReview') + 4) * 7; $urlParams['key'] = $accessKeyManager->createKey('ReviewerContext', $reviewer->getUserId(), $reviewId, $keyLifetime); } $submissionReviewUrl = Request::url($journal->getPath(), 'reviewer', 'submission', $reviewId, $urlParams); $paramArray = array('reviewerName' => $reviewer->getFullName(), 'reviewerUsername' => $reviewer->getUsername(), 'journalUrl' => $journal->getUrl(), 'reviewerPassword' => $reviewer->getPassword(), 'reviewDueDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDateDue())), 'editorialContactSignature' => $journal->getSetting('contactName') . "\n" . $journal->getJournalTitle(), 'passwordResetUrl' => Request::url($journal->getPath(), 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getUserId()))), 'submissionReviewUrl' => $submissionReviewUrl); $email->assignParams($paramArray); $email->send(); $reviewAssignment->setDateReminded(Core::getCurrentDate()); $reviewAssignment->setReminderWasAutomatic(1); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); }
/** * Insert a new completed payment. * @param $completedPayment OJSCompletedPayment */ function insertCompletedPayment(&$completedPayment) { $this->update(sprintf('INSERT INTO completed_payments (timestamp, payment_type, journal_id, user_id, assoc_id, amount, currency_code_alpha, payment_method_plugin_name) VALUES (%s, ?, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB(Core::getCurrentDate())), array($completedPayment->getType(), $completedPayment->getJournalId(), $completedPayment->getUserId(), $completedPayment->getAssocId(), $completedPayment->getAmount(), $completedPayment->getCurrencyCode(), $completedPayment->getPayMethodPluginName())); return $this->getInsertCompletedPaymentId(); }
/** * Update an existing queued payment. * @param $queuedPaymentId int * @param $payment Payment */ function updateQueuedPayment($queuedPaymentId, &$queuedPayment) { return $this->update(sprintf('UPDATE queued_payments SET date_modified = %s, payment_data = ? WHERE queued_payment_id = ?', $this->datetimeToDB(Core::getCurrentDate())), array(serialize($queuedPayment), (int) $queuedPaymentId)); }
function recordView($assocType, $assocId, $userId) { if (!$this->getLastViewDate($assocType, $assocId, $userId)) { return $this->update(sprintf('INSERT INTO views (assoc_type, assoc_id, user_id, date_last_viewed) VALUES (?, ?, ?, %s)', $this->datetimeToDB(Core::getCurrentDate())), array($assocType, $assocId, $userId)); } else { return $this->update(sprintf('UPDATE views set date_last_viewed = %s WHERE assoc_type = ? AND assoc_id = ? and user_id = ?', $this->datetimeToDB(Core::getCurrentDate())), array($assocType, $assocId, $userId)); } }
/** * Update the comment. */ function execute() { $commentDao =& DAORegistry::getDAO('ArticleCommentDAO'); // Update comment $comment = $this->comment; $comment->setCommentTitle($this->getData('commentTitle')); $comment->setComments($this->getData('comments')); $comment->setViewable($this->getData('viewable') ? 1 : 0); $comment->setDateModified(Core::getCurrentDate()); $commentDao->updateArticleComment($comment); }
/** * Static method to return a new version from a version string of the form "W.X.Y.Z". * @param $versionString string * @param $productType string * @param $product string * @param $productClass string * @param $lazyLoad integer * @param $sitewide integer * @return Version */ function &fromString($versionString, $productType = null, $product = null, $productClass = '', $lazyLoad = 0, $sitewide = 1) { $versionArray = explode('.', $versionString); if (!$product && !$productType) { $application = PKPApplication::getApplication(); $product = $application->getName(); $productType = 'core'; } $version = new Version(isset($versionArray[0]) ? (int) $versionArray[0] : 0, isset($versionArray[1]) ? (int) $versionArray[1] : 0, isset($versionArray[2]) ? (int) $versionArray[2] : 0, isset($versionArray[3]) ? (int) $versionArray[3] : 0, Core::getCurrentDate(), 1, $productType, $product, $productClass, $lazyLoad, $sitewide); return $version; }
/** * Gathers the state of a given cell given a $row/$column combination * @param $row GridRow * @param $column GridColumn * @return string */ function getCellState($row, $column) { $reviewAssignment = $row->getData(); $columnId = $column->getId(); assert(is_a($reviewAssignment, 'DataObject') && !empty($columnId)); switch ($columnId) { case 'name': if ($reviewAssignment->getDateCompleted()) { return 'linkReview'; } if ($reviewAssignment->getDateDue() < Core::getCurrentDate(strtotime('tomorrow')) || $reviewAssignment->getDateResponseDue() < Core::getCurrentDate(strtotime('tomorrow'))) { return 'overdue'; } return ''; case 'considered': // The review has not been completed. if (!$reviewAssignment->getDateCompleted()) { return 'unfinished'; } // The reviewer has been sent an acknowledgement. // Completed states can be 'unconsidered' by an editor. if ($reviewAssignment->getDateAcknowledged() && !$reviewAssignment->getUnconsidered()) { return 'completed'; } if ($reviewAssignment->getUnconsidered() == REVIEW_ASSIGNMENT_UNCONSIDERED) { return 'reviewReady'; } // Check if the somebody assigned to this stage has read the review. $submissionDao = Application::getSubmissionDAO(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $userStageAssignmentDao = DAORegistry::getDAO('UserStageAssignmentDAO'); $viewsDao = DAORegistry::getDAO('ViewsDAO'); $submission = $submissionDao->getById($reviewAssignment->getSubmissionId()); // Get the user groups for this stage $userGroups = $userGroupDao->getUserGroupsByStage($submission->getContextId(), $reviewAssignment->getStageId(), true, true); while ($userGroup = $userGroups->next()) { $roleId = $userGroup->getRoleId(); if ($roleId != ROLE_ID_MANAGER && $roleId != ROLE_ID_SUB_EDITOR) { continue; } // Get the users assigned to this stage and user group $stageUsers = $userStageAssignmentDao->getUsersBySubmissionAndStageId($reviewAssignment->getSubmissionId(), $reviewAssignment->getStageId(), $userGroup->getId()); // mark as completed (viewed) if any of the manager/editor users viewed it. while ($user = $stageUsers->next()) { if ($viewsDao->getLastViewDate(ASSOC_TYPE_REVIEW_RESPONSE, $reviewAssignment->getId(), $user->getId())) { // Some user has read the review. return 'read'; } } } // Nobody has read the review. return 'reviewReady'; } }
/** * Save review assignment * @param $args array * @param $request PKPRequest */ function execute($args, $request) { $userDao = DAORegistry::getDAO('UserDAO'); $user = $userDao->newDataObject(); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setEmail($this->getData('email')); $authDao = DAORegistry::getDAO('AuthSourceDAO'); $auth = $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $user->setInlineHelp(1); // default new reviewers to having inline help visible $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setMustChangePassword(true); // Emailed P/W not safe $user->setDateRegistered(Core::getCurrentDate()); $reviewerId = $userDao->insertObject($user); // Set the reviewerId in the Form for the parent class to use $this->setData('reviewerId', $reviewerId); // Insert the user interests import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->setInterestsForUser($user, $this->getData('interests')); // Assign the selected user group ID to the user $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $userGroupId = (int) $this->getData('userGroupId'); $userGroupDao->assignUserToGroup($reviewerId, $userGroupId); if (!$this->getData('skipEmail')) { // Send welcome email to user import('lib.pkp.classes.mail.MailTemplate'); $mail = new MailTemplate('REVIEWER_REGISTER'); if ($mail->isEnabled()) { $context = $request->getContext(); $mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send($request); } } return parent::execute($args, $request); }
/** * Create initial required data. * @return boolean */ function createData() { if ($this->getParam('manualInstall')) { // Add insert statements for default data // FIXME use ADODB data dictionary? $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales))); $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale'))); $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale'))); $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale'))); $this->executeSQL(sprintf('INSERT INTO users (user_id, username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (%d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', 1, $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate())); $this->executeSQL(sprintf('INSERT INTO roles (journal_id, user_id, role_id) VALUES (%d, %d, %d)', 0, 1, ROLE_ID_SITE_ADMIN)); } else { // Add initial site data $locale = $this->getParam('locale'); $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn); $site =& new Site(); $site->setRedirect(0); $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH); $site->setPrimaryLocale($locale); $site->setInstalledLocales($this->installedLocales); $site->setSupportedLocales($this->installedLocales); if (!$siteDao->insertSite($site)) { $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg()); return false; } $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO'); $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true); $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true); $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true); // Add initial site administrator user $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn); $user =& new User(); $user->setUsername($this->getParam('adminUsername')); $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption'))); $user->setFirstName($user->getUsername()); $user->setLastName(''); $user->setEmail($this->getParam('adminEmail')); if (!$userDao->insertUser($user)) { $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg()); return false; } $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn); $role =& new Role(); $role->setJournalId(0); $role->setUserId($user->getUserId()); $role->setRoleId(ROLE_ID_SITE_ADMIN); if (!$roleDao->insertRole($role)) { $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg()); return false; } } return true; }
/** * Create an access key with the given information. * @param $context string The context of the access key * @param $userId int The ID of the effective user for this access key * @param $assocId int The associated ID of the key * @param $expiryDays int The number of days before this key expires * @return accessKey string The generated passkey */ function createKey($context, $userId, $assocId, $expiryDays) { $accessKey = new AccessKey(); $accessKey->setContext($context); $accessKey->setUserId($userId); $accessKey->setAssocId($assocId); $accessKey->setExpiryDate(Core::getCurrentDate(time() + 60 * 60 * 24 * $expiryDays)); $key = Validation::generatePassword(); $accessKey->setKeyHash($this->generateKeyHash($key)); $this->accessKeyDao->insertObject($accessKey); return $key; }
function sendReminder($reviewAssignment, $paper, $conference, $schedConf) { $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao = DAORegistry::getDAO('UserDAO'); $reviewId = $reviewAssignment->getId(); $reviewer =& $userDao->getById($reviewAssignment->getReviewerId()); if (!isset($reviewer)) { return false; } import('classes.mail.PaperMailTemplate'); $reviewerAccessKeysEnabled = $schedConf->getSetting('reviewerAccessKeysEnabled'); $email = new PaperMailTemplate($paper, $reviewerAccessKeysEnabled ? 'REVIEW_REMIND_AUTO_ONECLICK' : 'REVIEW_REMIND_AUTO', $conference->getPrimaryLocale(), false, $conference, $schedConf); $email->setConference($conference); $email->setSchedConf($schedConf); $contactEmail = $schedConf->getSetting('contactEmail') ? $schedConf->getSetting('contactEmail') : $conference->getSetting('contactEmail'); $contactName = $schedConf->getSetting('contactName') ? $schedConf->getSetting('contactName') : $conference->getSetting('contactName'); $email->setFrom($contactEmail, $contactName); $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName()); $email->setAssoc(PAPER_EMAIL_REVIEW_REMIND, PAPER_EMAIL_TYPE_REVIEW, $reviewId); $email->setSubject($email->getSubject($conference->getPrimaryLocale())); $email->setBody($email->getBody($conference->getPrimaryLocale())); $urlParams = array(); if ($reviewerAccessKeysEnabled) { import('lib.pkp.classes.security.AccessKeyManager'); $accessKeyManager = new AccessKeyManager(); // Key lifetime is the typical review period plus four weeks if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) { // Get number of days from now until review deadline date $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute'); $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24); $keyLifetime = (round($daysDiff / 7) + 4) * 7; } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) { $keyLifetime = ((int) $schedConf->getSetting('numWeeksPerReviewRelative') + 4) * 7; } $urlParams['key'] = $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime); } $submissionReviewUrl = Request::url($conference->getPath(), $schedConf->getPath(), 'reviewer', 'submission', $reviewId, $urlParams); // Format the review due date $reviewDueDate = strtotime($reviewAssignment->getDateDue()); $dateFormatShort = Config::getVar('general', 'date_format_short'); if ($reviewDueDate === -1 || $reviewDueDate === false) { // Use something human-readable if unspecified. $reviewDueDate = '_____'; } else { $reviewDueDate = strftime($dateFormatShort, $reviewDueDate); } $paramArray = array('reviewerName' => $reviewer->getFullName(), 'reviewerUsername' => $reviewer->getUsername(), 'conferenceUrl' => Request::url($conference->getPath()), 'schedConfUrl' => Request::url($conference->getPath(), $schedConf->getPath()), 'reviewerPassword' => $reviewer->getPassword(), 'reviewDueDate' => $reviewDueDate, 'weekLaterDate' => strftime(Config::getVar('general', 'date_format_short'), strtotime('+1 week')), 'editorialContactSignature' => $contactName . "\n" . $schedConf->getLocalizedName(), 'passwordResetUrl' => Request::url($conference->getPath(), $schedConf->getPath(), 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))), 'submissionReviewUrl' => $submissionReviewUrl); $email->assignParams($paramArray); $email->send(); $reviewAssignment->setDateReminded(Core::getCurrentDate()); $reviewAssignment->setReminderWasAutomatic(1); $reviewAssignmentDao->updateObject($reviewAssignment); }
/** * Assigns a section editor to a submission. * @param $articleId int * @param $sectionEditorId int * @param $isEditor boolean * @param $send boolean * @param $request object * @return boolean true iff ready for redirect */ function assignEditor($articleId, $sectionEditorId, $isEditor, $send, $request) { $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO'); $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); /* @var $editAssignmentDao EditAssignmentDAO */ $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $request->getUser(); $journal =& $request->getJournal(); $editorSubmission =& $editorSubmissionDao->getEditorSubmission($articleId); $sectionEditor =& $userDao->getById($sectionEditorId); if (!isset($sectionEditor)) { return true; } foreach ($editorSubmission->getEditAssignments() as $assignment) { if ($assignment->getEditorId() == $sectionEditorId) { return true; } } import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($editorSubmission, 'EDITOR_ASSIGN'); if ($user->getId() === $sectionEditorId || !$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('EditorAction::assignEditor', array(&$editorSubmission, &$sectionEditor, &$isEditor, &$email)); if ($email->isEnabled() && $user->getId() !== $sectionEditorId) { $email->send($request); } $editAssignment = $editAssignmentDao->newDataObject(); $editAssignment->setArticleId($articleId); $editAssignment->setCanEdit(1); $editAssignment->setCanReview(1); // Make the selected editor the new editor $editAssignment->setEditorId($sectionEditorId); $editAssignment->setDateAssigned(Core::getCurrentDate()); $editAssignment->setDateNotified(is_array($send) && isset($send['skip']) ? null : Core::getCurrentDate()); $editAssignment->setDateUnderway(null); $editAssignments =& $editorSubmission->getEditAssignments(); array_push($editAssignments, $editAssignment); $editorSubmission->setEditAssignments($editAssignments); $editorSubmissionDao->updateEditorSubmission($editorSubmission); // Add log import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $editorSubmission, ARTICLE_LOG_EDITOR_ASSIGN, 'log.editor.editorAssigned', array('editorName' => $sectionEditor->getFullName(), 'editorId' => $sectionEditorId)); return true; } else { if (!$request->getUserVar('continued')) { $email->addRecipient($sectionEditor->getEmail(), $sectionEditor->getFullName()); $paramArray = array('editorialContactName' => $sectionEditor->getFullName(), 'editorUsername' => $sectionEditor->getUsername(), 'editorPassword' => $sectionEditor->getPassword(), 'editorialContactSignature' => $user->getContactSignature(), 'submissionUrl' => $request->url(null, $isEditor ? 'editor' : 'sectionEditor', 'submissionReview', $articleId), 'submissionEditingUrl' => $request->url(null, $isEditor ? 'editor' : 'sectionEditor', 'submissionReview', $articleId)); $email->assignParams($paramArray); } $email->displayEditForm($request->url(null, null, 'assignEditor', 'send'), array('articleId' => $articleId, 'editorId' => $sectionEditorId)); return false; } }
/** * Add an entry into the execution log. * @param $message string A translated message. * @param $type string (optional) One of the ScheduledTaskHelper * SCHEDULED_TASK_MESSAGE_TYPE... constants. */ function addExecutionLogEntry($message, $type = null) { $log = $this->_executionLog; if (!$message) { return; } if ($type) { $log[] = '[' . Core::getCurrentDate() . '] ' . '[' . __($type) . '] ' . $message; } else { $log[] = $message; } $this->_executionLog = $log; }
/** * Insert a new version. * @param $version Version */ function insertVersion(&$version) { if ($version->getCurrent()) { // Version to insert is the new current, reset old current $this->update('UPDATE versions SET current = 0 WHERE current = 1'); } if ($version->getDateInstalled() == null) { $version->setDateInstalled(Core::getCurrentDate()); } return $this->update(sprintf('INSERT INTO versions (major, minor, revision, build, date_installed, current) VALUES (?, ?, ?, ?, %s, ?)', $this->datetimeToDB($version->getDateInstalled())), array($version->getMajor(), $version->getMinor(), $version->getRevision(), $version->getBuild(), $version->getCurrent())); }
/** * Assigns a track director to a submission. * @param $paperId int * @return boolean true iff ready for redirect */ function assignDirector($paperId, $trackDirectorId, $isDirector = false, $send = false) { $directorSubmissionDao =& DAORegistry::getDAO('DirectorSubmissionDAO'); $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $user =& Request::getUser(); $conference =& Request::getConference(); $directorSubmission =& $directorSubmissionDao->getDirectorSubmission($paperId); $trackDirector =& $userDao->getUser($trackDirectorId); if (!isset($trackDirector)) { return true; } import('mail.PaperMailTemplate'); $email = new PaperMailTemplate($directorSubmission, 'DIRECTOR_ASSIGN'); if ($user->getId() === $trackDirectorId || !$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('DirectorAction::assignDirector', array(&$directorSubmission, &$trackDirector, &$isDirector, &$email)); if ($email->isEnabled() && $user->getId() !== $trackDirectorId) { $email->setAssoc(PAPER_EMAIL_DIRECTOR_ASSIGN, PAPER_EMAIL_TYPE_DIRECTOR, $trackDirector->getId()); $email->send(); } $editAssignment = new EditAssignment(); $editAssignment->setPaperId($paperId); // Make the selected director the new director $editAssignment->setDirectorId($trackDirectorId); $editAssignment->setDateNotified(Core::getCurrentDate()); $editAssignment->setDateUnderway(null); $editAssignments =& $directorSubmission->getEditAssignments(); array_push($editAssignments, $editAssignment); $directorSubmission->setEditAssignments($editAssignments); $directorSubmissionDao->updateDirectorSubmission($directorSubmission); // Add log import('paper.log.PaperLog'); import('paper.log.PaperEventLogEntry'); PaperLog::logEvent($paperId, PAPER_LOG_DIRECTOR_ASSIGN, LOG_TYPE_DIRECTOR, $trackDirectorId, 'log.director.directorAssigned', array('directorName' => $trackDirector->getFullName(), 'paperId' => $paperId)); return true; } else { if (!Request::getUserVar('continued')) { $email->addRecipient($trackDirector->getEmail(), $trackDirector->getFullName()); $submissionUrl = Request::url(null, null, $isDirector ? 'director' : 'trackDirector', 'submissionReview', $paperId); $submissionUrl = $submissionUrl . "?u=" . $trackDirector->getUserId(); $paramArray = array('editorialContactName' => $trackDirector->getFullName(), 'directorUsername' => $trackDirector->getUsername(), 'directorPassword' => $trackDirector->getPassword(), 'editorialContactSignature' => $user->getContactSignature(), 'submissionUrl' => $submissionUrl); $email->assignParams($paramArray); } $email->displayEditForm(Request::url(null, null, null, 'assignDirector', 'send'), array('paperId' => $paperId, 'directorId' => $trackDirectorId)); return false; } }
/** * Assigns a reviewer to a submission. * @param $seriesEditorSubmission object * @param $reviewerId int */ function addReviewer($seriesEditorSubmission, $reviewerId, $reviewType, $round = null, $reviewDueDate = null, $responseDueDate = null) { $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO'); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $user =& Request::getUser(); $reviewer =& $userDao->getUser($reviewerId); // Check to see if the requested reviewer is not already // assigned to review this monograph. if ($round == null) { $round = $seriesEditorSubmission->getCurrentRound(); } $assigned = $seriesEditorSubmissionDao->reviewerExists($seriesEditorSubmission->getId(), $reviewerId, $reviewType, $round); // Only add the reviewer if he has not already // been assigned to review this monograph. if (!$assigned && isset($reviewer) && !HookRegistry::call('SeriesEditorAction::addReviewer', array(&$seriesEditorSubmission, $reviewerId))) { $reviewAssignment = new ReviewAssignment(); $reviewAssignment->setSubmissionId($seriesEditorSubmission->getId()); $reviewAssignment->setReviewerId($reviewerId); $reviewAssignment->setDateAssigned(Core::getCurrentDate()); $reviewAssignment->setReviewType($reviewType); $reviewAssignment->setRound($round); // Assign review form automatically if needed $pressId = $seriesEditorSubmission->getPressId(); $seriesDao =& DAORegistry::getDAO('SeriesDAO'); $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO'); $submissionId = $seriesEditorSubmission->getId(); $series =& $seriesDao->getById($submissionId, $pressId); $seriesEditorSubmission->addReviewAssignment($reviewAssignment, $reviewType, $round); $seriesEditorSubmissionDao->updateSeriesEditorSubmission($seriesEditorSubmission); $reviewAssignment = $reviewAssignmentDao->getReviewAssignment($seriesEditorSubmission->getId(), $reviewerId, $round, $reviewType); $press =& Request::getPress(); $settingsDao =& DAORegistry::getDAO('PressSettingsDAO'); $settings =& $settingsDao->getPressSettings($press->getId()); if (isset($reviewDueDate)) { SeriesEditorAction::setDueDate($seriesEditorSubmission->getId(), $reviewAssignment->getId(), $reviewDueDate); } if (isset($responseDueDate)) { SeriesEditorAction::setResponseDueDate($seriesEditorSubmission->getId(), $reviewAssignment->getId(), $responseDueDate); } // Add log import('classes.monograph.log.MonographLog'); import('classes.monograph.log.MonographEventLogEntry'); MonographLog::logEvent($seriesEditorSubmission->getId(), MONOGRAPH_LOG_REVIEW_ASSIGN, MONOGRAPH_LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewerAssigned', array('reviewerName' => $reviewer->getFullName(), 'monographId' => $seriesEditorSubmission->getId(), 'reviewType' => $reviewType, 'round' => $round)); } }
/** * Send email to object for review author * @param $ofrAssignment ObjectForReviewAssignment * @param $journal Journal * @param $emailKey string */ function sendReminder($ofrAssignment, $journal, $emailKey) { $journalId = $journal->getId(); $author =& $ofrAssignment->getUser(); $objectForReview =& $ofrAssignment->getObjectForReview(); $editor =& $objectForReview->getEditor(); $paramArray = array('authorName' => strip_tags($author->getFullName()), 'objectForReviewTitle' => '"' . strip_tags($objectForReview->getTitle()) . '"', 'objectForReviewDueDate' => date('l, F j, Y', strtotime($ofrAssignment->getDateDue())), 'submissionUrl' => Request::url($journal->getPath(), 'author', 'submit'), 'editorialContactSignature' => strip_tags($editor->getContactSignature())); import('classes.mail.MailTemplate'); $mail = new MailTemplate($emailKey); $mail->setReplyTo($editor->getEmail(), $editor->getFullName()); $mail->addRecipient($author->getEmail(), $author->getFullName()); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); $ofrAssignment->setDateReminded(Core::getCurrentDate()); $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO'); $ofrAssignmentDao->updateObject($ofrAssignment); }