/** * Import papers (including metadata and files). */ function importPapers() { if ($this->hasOption('verbose')) { printf("Importing papers\n"); } import('classes.file.PaperFileManager'); import('classes.search.PaperSearchIndex'); $userDao =& DAORegistry::getDAO('UserDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $trackDao =& DAORegistry::getDAO('TrackDAO'); $paperDao =& DAORegistry::getDAO('PaperDAO'); $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO'); $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO'); $unassignedTrackId = null; $result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id'); while (!$result->EOF) { $row =& $result->fields; $schedConf =& $this->schedConfMap[$row['cf']]; $schedConfId = $schedConf->getId(); // Bring in the primary user for this paper. $user = $userDao->getUserByUsername(Core::cleanVar($row['login'])); if (!$user) { unset($user); $user = new User(); $user->setUsername(Core::cleanVar($row['login'])); $user->setFirstName(Core::cleanVar($row['first_name'])); $user->setLastName(Core::cleanVar($row['surname'])); $user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale()); $user->setEmail(Core::cleanVar($row['email'])); $user->setUrl(Core::cleanVar($row['url'])); $user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale()); $user->setLocales(array()); $user->setDateRegistered($row['created']); $user->setDateLastLogin($row['created']); $user->setMustChangePassword(1); $password = Validation::generatePassword(); $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password)); if ($this->hasOption('emailUsers')) { import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } $user->setDisabled(0); $otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email'])); if ($otherUser !== null) { // User exists with this email -- munge it to make unique $user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email'])); $this->conflicts[] = array(&$otherUser, &$user); } unset($otherUser); $userDao->insertUser($user); // Make this user a author $role = new Role(); $role->setSchedConfId($schedConf->getId()); $role->setConferenceId($schedConf->getConferenceId()); $role->setUserId($user->getId()); $role->setRoleId(ROLE_ID_AUTHOR); $roleDao->insertRole($role); unset($role); } $userId = $user->getId(); // Bring in the basic entry for the paper $paper = new Paper(); $paper->setUserId($userId); $paper->setLocale(Locale::getPrimaryLocale()); $paper->setSchedConfId($schedConfId); $oldTrackId = $row['primary_track_id']; if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { $oldTrackId = $row['secondary_track_id']; } if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { if (!$unassignedTrackId) { // Create an "Unassigned" track to use for submissions // that didn't have a track in OCS 1.x. $track = new Track(); $track->setSchedConfId($schedConf->getId()); $track->setTitle('UNASSIGNED', Locale::getLocale()); $track->setSequence(REALLY_BIG_NUMBER); $track->setDirectorRestricted(1); $track->setMetaReviewed(1); $unassignedTrackId = $trackDao->insertTrack($track); } $newTrackId = $unassignedTrackId; } else { $newTrackId = $this->trackMap[$oldTrackId]; } $paper->setTrackId($newTrackId); $paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale()); $paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale()); $paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale()); $paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale()); $paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale()); $paper->setLanguage(Core::cleanVar($row['language'])); $paper->setDateSubmitted($row['created']); $paper->setDateStatusModified($row['timestamp']); // $paper->setTypeConst($row['present_format'] == 'multiple' ? SUBMISSION_TYPE_PANEL : SUBMISSION_TYPE_SINGLE); FIXME $paper->setCurrentRound(REVIEW_ROUND_ABSTRACT); $paper->setSubmissionProgress(0); $paper->setPages(''); // Bring in authors $firstNames = split("\n", Core::cleanVar($row['first_name'] . "\n" . $row['add_first_names'])); $lastNames = split("\n", Core::cleanVar($row['surname'] . "\n" . $row['add_surnames'])); $emails = split("\n", Core::cleanVar($row['email'] . "\n" . $row['add_emails'])); $affiliations = split("\n", Core::cleanVar($row['affiliation'] . "\n" . $row['add_affiliations'])); $urls = split("\n", Core::cleanVar($row['url'] . "\n" . $row['add_urls'])); foreach ($emails as $key => $email) { if (empty($email)) { continue; } $author = new Author(); $author->setEmail($email); $author->setFirstName($firstNames[$key]); $author->setLastName($lastNames[$key]); $author->setAffiliation($affiliations[$key], Locale::getLocale()); @$author->setUrl($urls[$key]); // Suppress warnings from inconsistent OCS 1.x data $author->setPrimaryContact($key == 0 ? 1 : 0); $paper->addAuthor($author); unset($author); } switch ($row['accepted']) { case 'true': $paper->setStatus(STATUS_PUBLISHED); $paperId = $paperDao->insertPaper($paper); $publishedPaper = new PublishedPaper(); $publishedPaper->setPaperId($paperId); $publishedPaper->setSchedConfId($schedConfId); $publishedPaper->setDatePublished(Core::getCurrentDate()); $publishedPaper->setSeq(REALLY_BIG_NUMBER); $publishedPaper->setViews(0); $publishedPaperDao->insertPublishedPaper($publishedPaper); $publishedPaperDao->resequencePublishedPapers($paper->getTrackId(), $schedConfId); break; case 'reject': $paper->setStatus(STATUS_DECLINED); $paperId = $paperDao->insertPaper($paper); break; default: $paper->setStatus(STATUS_QUEUED); $paperId = $paperDao->insertPaper($paper); } $this->paperMap[$row['id']] =& $paper; $paperFileManager = new PaperFileManager($paperId); if (!empty($row['paper']) && $row['paper'] != 'PDF') { $format = 'text/html'; $extension = $paperFileManager->getDocumentExtension($format); $fileId = $paperFileManager->writeSubmissionFile('migratedFile' . $extension, $row['paper'], $format); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->writePublicFile('migratedGalley' . $extension, $row['paper'], $format); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); if (strstr($format, 'html')) { $galley = new PaperHTMLGalley(); $galley->setLabel('HTML'); } else { $galley = new PaperGalley(); switch ($format) { case 'application/pdf': $galley->setLabel('PDF'); break; case 'application/postscript': $galley->setLabel('PostScript'); break; case 'application/msword': $galley->setLabel('Word'); break; case 'text/xml': $galley->setLabel('XML'); break; case 'application/powerpoint': $galley->setLabel('Slideshow'); break; default: $galley->setLabel('Untitled'); break; } } $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } elseif ($row['paper'] == 'PDF') { $fileId = $paperFileManager->copySubmissionFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->copyPublicFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); $galley = new PaperGalley(); $galley->setLabel('PDF'); $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } // FIXME: The following fields from OCS 1.x are UNUSED: // program_insert approach coverage format relation appendix_names appendix_dates // appendix appendix_pdf secondary_track_id multiple_* restrict_access paper_email // delete_paper comment_email unset($user); unset($paper); unset($schedConf); unset($paperFileManager); $result->MoveNext(); } $result->Close(); }
/** * Save scheduled conference settings. */ function execute() { $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); $conferenceDao =& DAORegistry::getDAO('ConferenceDAO'); $conference =& $conferenceDao->getConference($this->getData('conferenceId')); if (isset($this->schedConfId)) { $schedConf =& $schedConfDao->getSchedConf($this->schedConfId); } if (!isset($schedConf)) { $schedConf = new SchedConf(); } $schedConf->setConferenceId($this->getData('conferenceId')); $schedConf->setPath($this->getData('schedConfPath')); if ($schedConf->getId() != null) { $schedConfDao->updateSchedConf($schedConf); $track = null; // avoid warning } else { $schedConfId = $schedConfDao->insertSchedConf($schedConf); $schedConfDao->resequenceSchedConfs($this->getData('conferenceId')); // Make the file directories for the scheduled conference import('lib.pkp.classes.file.FileManager'); $conferenceId = $schedConf->getConferenceId(); $privateBasePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId; $publicBasePath = Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId; FileManager::mkdirtree($privateBasePath); FileManager::mkdirtree($privateBasePath . '/papers'); FileManager::mkdirtree($privateBasePath . '/tracks'); FileManager::mkdirtree($publicBasePath); // Install default scheduled conference settings $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO'); $title = $this->getData('title'); $title = $title[$this->getFormLocale()]; Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_OCS_DEFAULT)); $schedConfSettingsDao->installSettings($schedConfId, Config::getVar('general', 'registry_dir') . '/schedConfSettings.xml', array('authorGuidelinesUrl' => Request::url($conference->getPath(), $this->getData('schedConfPath'), 'about', 'submissions', null, null, 'authorGuidelines'), 'indexUrl' => Request::getIndexUrl(), 'conferencePath' => $conference->getPath(), 'conferenceName' => $conference->getConferenceTitle(), 'schedConfPath' => $this->getData('schedConfPath'), 'schedConfUrl' => Request::url($conference->getPath(), $this->getData('schedConfPath'), 'index'), 'schedConfName' => $title)); // Create a default "Papers" track $trackDao =& DAORegistry::getDAO('TrackDAO'); $track = new Track(); $track->setSchedConfId($schedConfId); $track->setMetaReviewed(true); $track->setTitle(Locale::translate('track.default.title'), $conference->getPrimaryLocale()); $track->setAbbrev(Locale::translate('track.default.abbrev'), $conference->getPrimaryLocale()); $track->setPolicy(Locale::translate('track.default.policy'), $conference->getPrimaryLocale()); $track->setDirectorRestricted(false); $trackDao->insertTrack($track); } $schedConf->updateSetting('title', $this->getData('title'), 'string', true); $schedConf->updateSetting('acronym', $this->getData('acronym'), 'string', true); HookRegistry::call('SchedConfSettingsForm::execute', array(&$this, &$conference, &$schedConf, &$track)); }
/** * Internal function to return a Track object from a row. * @param $row array * @return Track */ function &_returnTrackFromRow(&$row) { $track = new Track(); $track->setId($row['track_id']); $track->setSchedConfId($row['sched_conf_id']); $track->setReviewFormId($row['review_form_id']); $track->setSequence($row['seq']); $track->setMetaReviewed($row['meta_reviewed']); $track->setDirectorRestricted($row['director_restricted']); $track->setHideAbout($row['hide_about']); $track->setDisableComments($row['disable_comments']); $track->setAbstractWordCount($row['abstract_word_count']); $this->getDataObjectSettings('track_settings', 'track_id', $row['track_id'], $track); HookRegistry::call('TrackDAO::_returnTrackFromRow', array(&$track, &$row)); return $track; }
/** * Save track. */ function execute() { $schedConf =& Request::getSchedConf(); $trackDao =& DAORegistry::getDAO('TrackDAO'); if (isset($this->trackId)) { $track =& $trackDao->getTrack($this->trackId); } if (!isset($track)) { $track = new Track(); $track->setSchedConfId($schedConf->getId()); $track->setSequence(REALLY_BIG_NUMBER); } $track->setTitle($this->getData('title'), null); // Localized $track->setAbbrev($this->getData('abbrev'), null); // Localized $reviewFormId = $this->getData('reviewFormId'); if ($reviewFormId === '') { $reviewFormId = null; } $track->setReviewFormId($reviewFormId); $track->setMetaReviewed($this->getData('metaNotReviewed') ? 0 : 1); $track->setIdentifyType($this->getData('identifyType'), null); // Localized $track->setDirectorRestricted($this->getData('directorRestriction') ? 1 : 0); $track->setPolicy($this->getData('policy'), null); // Localized $track->setHideAbout($this->getData('hideAbout')); $track->setDisableComments($this->getData('disableComments') ? 1 : 0); $track->setAbstractWordCount($this->getData('wordCount')); if ($track->getId() != null) { $trackDao->updateTrack($track); $trackId = $track->getId(); } else { $trackId = $trackDao->insertTrack($track); $trackDao->resequenceTracks($schedConf->getId()); } // Save assigned directors $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO'); $trackDirectorsDao->deleteDirectorsByTrackId($trackId, $schedConf->getId()); $directors = explode(':', Request::getUserVar('assignedDirectors')); foreach ($directors as $edUserId) { if (!empty($edUserId)) { $trackDirectorsDao->insertDirector($schedConf->getId(), $trackId, $edUserId); } } }
/** * Save schedConf settings. * @param $request PKPRequest */ function execute($request) { $schedConfDao = DAORegistry::getDAO('SchedConfDAO'); $conference = $request->getConference(); if (isset($this->contextId)) { $schedConf = $schedConfDao->getById($this->contextId); } if (!isset($schedConf)) { $schedConf = $schedConfDao->newDataObject(); $schedConf->setConferenceId($conference->getId()); } $schedConf->setPath($this->getData('path')); $schedConf->setEnabled($this->getData('enabled')); if ($schedConf->getId() != null) { $isNewSchedConf = false; $schedConfDao->updateObject($schedConf); $section = null; } else { $isNewSchedConf = true; $site = $request->getSite(); // Give it a default primary locale $schedConfId = $schedConfDao->insertObject($schedConf); $schedConfDao->resequence(); // Make the file directories for the scheduled conference import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $conferenceId = $schedConf->getConferenceId(); $privateBasePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId; $publicBasePath = Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId; $fileManager->mkdirtree($privateBasePath); $fileManager->mkdirtree($privateBasePath . '/papers'); $fileManager->mkdirtree($privateBasePath . '/tracks'); $fileManager->mkdirtree($publicBasePath); // Install default scheduled conference settings $schedConfSettingsDao = DAORegistry::getDAO('SchedConfSettingsDAO'); $name = $this->getData('name'); $name = $name[$this->getFormLocale()]; AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_APP_DEFAULT); $dispatcher = $request->getDispatcher(); $schedConfSettingsDao->installSettings($schedConfId, Config::getVar('general', 'registry_dir') . '/schedConfSettings.xml', array('authorGuidelinesUrl' => $dispatcher->url($request, ROUTE_PAGE, array($conference->getPath(), $this->getData('schedConfPath')), 'about', 'submissions', null, null, 'authorGuidelines'), 'indexUrl' => $request->getIndexUrl(), 'conferencePath' => $conference->getPath(), 'conferenceName' => $conference->getLocalizedName(), 'schedConfPath' => $this->getData('path'), 'schedConfUrl' => $dispatcher->url($request, ROUTE_PAGE, array($conference->getPath(), $this->getData('schedConfPath')), 'index'), 'schedConfName' => $name)); // Create a default "Papers" track $trackDao = DAORegistry::getDAO('TrackDAO'); $track = new Track(); $track->setSchedConfId($schedConfId); $track->setMetaReviewed(true); $track->setTitle(__('track.default.title'), $conference->getPrimaryLocale()); $track->setAbbrev(__('track.default.abbrev'), $conference->getPrimaryLocale()); $track->setPolicy(__('track.default.policy'), $conference->getPrimaryLocale()); $track->setDirectorRestricted(false); $trackDao->insertTrack($track); } $schedConf->updateSetting('name', $this->getData('name'), 'string', true); $schedConf->updateSetting('acronym', $this->getData('acronym'), 'string', true); // Make sure all plugins are loaded for settings preload PluginRegistry::loadAllPlugins(); HookRegistry::call('SchedConfSettingsForm::execute', array(&$this, &$schedConf)); }