function confirmSubmission(&$paper, &$user, &$schedConf, &$conference, $mailTemplate = 'SUBMISSION_ACK') { // Update search index import('classes.search.PaperSearchIndex'); PaperSearchIndex::indexPaperMetadata($paper); PaperSearchIndex::indexPaperFiles($paper); // Send author notification email import('classes.mail.PaperMailTemplate'); $mail = new PaperMailTemplate($paper, $mailTemplate, null, null, null, null, false, true); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); if ($mail->isEnabled()) { $mail->addRecipient($user->getEmail(), $user->getFullName()); // If necessary, BCC the acknowledgement to someone. if ($schedConf->getSetting('copySubmissionAckPrimaryContact')) { $mail->addBcc($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); } if ($schedConf->getSetting('copySubmissionAckSpecified')) { $copyAddress = $schedConf->getSetting('copySubmissionAckAddress'); if (!empty($copyAddress)) { $mail->addBcc($copyAddress); } } $editAssignmentDao = DAORegistry::getDAO('EditAssignmentDAO'); $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($paper->getId()); while ($editAssignment =& $editAssignments->next()) { $mail->addBcc($editAssignment->getDirectorEmail(), $editAssignment->getDirectorFullName()); unset($editAssignment); } $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'editorialContactSignature' => $schedConf->getSetting('contactName') . "\n" . $conference->getLocalizedName(), 'submissionUrl' => Request::url(null, null, 'author', 'submission', $paper->getId()))); $mail->send(); } }
function confirmSubmissionBBC(&$paper, $user, &$schedConf, &$conference, $mailTemplate = 'SUBMISSION_ACK_BCC') { // Update search index import('search.PaperSearchIndex'); PaperSearchIndex::indexPaperMetadata($paper); PaperSearchIndex::indexPaperFiles($paper); $roleDao =& DAORegistry::getDAO('RoleDAO'); $directors =& $roleDao->getUsersArrayByRoleId(ROLE_ID_DIRECTOR, $conference->getId(), $schedConf->getId()); //print_r($users->toArray()); //echo count($users); // 嘗試找看看有沒有這位使用者 //$userDao =& DAORegistry::getDAO('UserDAO'); //$contactUser = $userDao->getUserByEmail($schedConf->getSetting('contactEmail')); // if (isset($contactUser)) { // $submissionUrl = $submissionUrl . "?u=" . $contactUser->getUserId(); // } // $contactName = $schedConf->getSetting('contactName'); // $contactEmail = $schedConf->getSetting('contactEmail'); // if (isset($contactUser)) { // $contactName = $contactUser->getFullName(); // $contactEmail = $contactUser->getEmail(); // } // Send author notification email import('mail.PaperMailTemplate'); $mail = new PaperMailTemplate($paper, $mailTemplate, null, false, $conference, $schedConf, true, true); $mail->setBccSender(false); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); if ($mail->isEnabled() && count($directors > 0)) { $contactName = ""; foreach ($directors as $director) { $mail->addRecipient($director->getEmail(), $director->getFullName()); if ($contactName !== "") { $contactName .= ", "; } $contactName .= $director->getFullName(); } // $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); // $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($paper->getId()); // while ($editAssignment =& $editAssignments->next()) { // $mail->addBcc($editAssignment->getDirectorEmail(), $editAssignment->getDirectorFullName()); // unset($editAssignment); // } $submissionUrl = Request::url(null, null, 'director', 'submissionReview', $paper->getId()); $mail->assignParams(array('contactName' => $contactName, 'authorName' => trim($user->getFullName()), 'authorUsername' => $user->getUsername(), 'editorialContactSignature' => $schedConf->getSetting('contactName') . "\n" . $conference->getConferenceTitle(), 'submissionUrl' => $submissionUrl)); $mail->send(); } }
function handlePaperNode(&$conference, &$schedConf, &$paperNode, &$track, &$paper, &$publishedPaper, &$errors, &$user, $isCommandLine, &$dependentItems) { $errors = array(); $conferenceSupportedLocales = array_keys($conference->getSupportedLocaleNames()); // => locales must be set up before $conferencePrimaryLocale = $conference->getPrimaryLocale(); $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO'); $paperDao =& DAORegistry::getDAO('PaperDAO'); $paper = new Paper(); $paper->setSchedConfId($schedConf->getId()); $paper->setUserId($user->getId()); $paper->setTrackId($track->getId()); $paper->setStatus(STATUS_PUBLISHED); $paper->setSubmissionProgress(0); $paper->setCurrentStage(REVIEW_STAGE_ABSTRACT); $paper->setReviewMode(REVIEW_MODE_ABSTRACTS_ALONE); $paper->setDateSubmitted(Core::getCurrentDate()); $paper->stampStatusModified(); $titleExists = false; for ($index = 0; $node = $paperNode->getChildByName('title', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperTitleLocaleUnsupported', array('paperTitle' => $node->getValue(), 'locale' => $locale)); return false; } $paper->setTitle($node->getValue(), $locale); $titleExists = true; } if (!$titleExists || $paper->getTitle($conferencePrimaryLocale) == "") { $errors[] = array('plugins.importexport.native.import.error.paperTitleMissing', array('trackTitle' => $track->getLocalizedTitle())); return false; } for ($index = 0; $node = $paperNode->getChildByName('abstract', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperAbstractLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setAbstract($node->getValue(), $locale); } if ($indexingNode = $paperNode->getChildByName('indexing')) { for ($index = 0; $node = $indexingNode->getChildByName('discipline', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperDisciplineLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setDiscipline($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('type', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperTypeLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setType($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperSubjectLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setSubject($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject_class', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperSubjectClassLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setSubjectClass($node->getValue(), $locale); } if ($coverageNode = $indexingNode->getChildByName('coverage')) { for ($index = 0; $node = $coverageNode->getChildByName('geographical', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperCoverageGeoLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setCoverageGeo($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('chronological', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperCoverageChronLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setCoverageChron($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('sample', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperCoverageSampleLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setCoverageSample($node->getValue(), $locale); } } } for ($index = 0; $node = $paperNode->getChildByName('sponsor', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $conferencePrimaryLocale; } elseif (!in_array($locale, $conferenceSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.paperSponsorLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale)); return false; } $paper->setSponsor($node->getValue(), $locale); } if ($node = $paperNode->getChildByName('pages')) { $paper->setPages($node->getValue()); } if ($language = $paperNode->getAttribute('language')) { $paper->setLanguage($language); } /* --- Handle authors --- */ $hasErrors = false; for ($index = 0; $node = $paperNode->getChildByName('author', $index); $index++) { if (!NativeImportDom::handleAuthorNode($conference, $schedConf, $node, $track, $paper, $authorErrors)) { $errors = array_merge($errors, $authorErrors); $hasErrors = true; } } if ($hasErrors) { return false; } $paperDao->insertPaper($paper); $dependentItems[] = array('paper', $paper); // Log the import in the paper event log. import('paper.log.PaperLog'); import('paper.log.PaperEventLogEntry'); PaperLog::logEvent($paper->getId(), PAPER_LOG_PAPER_IMPORT, PAPER_LOG_DEFAULT, 0, 'log.imported', array('userName' => $user->getFullName(), 'paperId' => $paper->getId())); // Insert published paper entry. $publishedPaper = new PublishedPaper(); $publishedPaper->setPaperId($paper->getId()); $publishedPaper->setSchedConfId($schedConf->getId()); if ($node = $paperNode->getChildByName('date_published')) { $publishedDate = strtotime($node->getValue()); if ($publishedDate === -1) { $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue())); return false; } else { $publishedPaper->setDatePublished($publishedDate); } } $node = $paperNode->getChildByName('open_access'); $publishedPaper->setSeq(REALLY_BIG_NUMBER); $publishedPaper->setViews(0); $publishedPaper->setPublicPaperId($paperNode->getAttribute('public_id')); $publishedPaper->setPubId($publishedPaperDao->insertPublishedPaper($publishedPaper)); $publishedPaperDao->resequencePublishedPapers($track->getId(), $schedConf->getId()); /* --- Galleys (html or otherwise handled simultaneously) --- */ import('file.PaperFileManager'); $paperFileManager = new PaperFileManager($paper->getId()); /* --- Handle galleys --- */ $hasErrors = false; $galleyCount = 0; for ($index = 0; $index < count($paperNode->children); $index++) { $node =& $paperNode->children[$index]; if ($node->getName() == 'htmlgalley') { $isHtml = true; } elseif ($node->getName() == 'galley') { $isHtml = false; } else { continue; } if (!NativeImportDom::handleGalleyNode($conference, $schedConf, $node, $track, $paper, $galleyErrors, $isCommandLine, $isHtml, $galleyCount, $paperFileManager)) { $errors = array_merge($errors, $galleyErrors); $hasErrors = true; } $galleyCount++; } if ($hasErrors) { return false; } /* --- Handle supplemental files --- */ $hasErrors = false; for ($index = 0; $node = $paperNode->getChildByName('supplemental_file', $index); $index++) { if (!NativeImportDom::handleSuppFileNode($conference, $schedConf, $node, $track, $paper, $suppFileErrors, $isCommandLine, $paperFileManager)) { $errors = array_merge($errors, $suppFileErrors); $hasErrors = true; } } if ($hasErrors) { return false; } // Index the inserted paper. import('search.PaperSearchIndex'); PaperSearchIndex::indexPaperMetadata($paper); PaperSearchIndex::indexPaperFiles($paper); return true; }
/** * Rebuild the search index for all conferences. */ function rebuildIndex($log = false) { // Clear index if ($log) { echo 'Clearing index ... '; } $searchDao =& DAORegistry::getDAO('PaperSearchDAO'); // FIXME Abstract into PaperSearchDAO? $searchDao->update('DELETE FROM paper_search_object_keywords'); $searchDao->update('DELETE FROM paper_search_objects'); $searchDao->update('DELETE FROM paper_search_keyword_list'); $searchDao->setCacheDir(Config::getVar('files', 'files_dir') . '/_db'); $searchDao->_dataSource->CacheFlush(); if ($log) { echo "done\n"; } // Build index $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); $paperDao =& DAORegistry::getDAO('PaperDAO'); $schedConfs =& $schedConfDao->getSchedConfs(); while (!$schedConfs->eof()) { $schedConf =& $schedConfs->next(); $numIndexed = 0; if ($log) { echo "Indexing \"", $schedConf->getFullTitle(), "\" ... "; } $papers =& $paperDao->getPapersBySchedConfId($schedConf->getId()); while (!$papers->eof()) { $paper =& $papers->next(); if ($paper->getDateSubmitted()) { PaperSearchIndex::indexPaperMetadata($paper); PaperSearchIndex::indexPaperFiles($paper); $numIndexed++; } unset($paper); } if ($log) { echo $numIndexed, " papers indexed\n"; } unset($schedConf); } }