00001 <?php
00002
00015
00016
00017
00018 define('OJS1_MIN_VERSION', '1.1.5');
00019 define('OJS1_MIN_VERSION_SUBSCRIPTIONS', '1.1.8');
00020
00021 import('user.User');
00022 import('journal.Journal');
00023 import('journal.Section');
00024 import('security.Role');
00025 import('subscription.Subscription');
00026 import('subscription.SubscriptionType');
00027 import('currency.Currency');
00028 import('article.Article');
00029 import('article.ArticleComment');
00030 import('article.ArticleFile');
00031 import('article.ArticleGalley');
00032 import('article.ArticleHTMLGalley');
00033 import('article.ArticleNote');
00034 import('article.Author');
00035 import('article.PublishedArticle');
00036 import('article.SuppFile');
00037 import('submission.common/Action');
00038 import('submission.author.AuthorSubmission');
00039 import('submission.reviewer.ReviewerSubmission');
00040 import('issue.Issue');
00041 import('submission.copyAssignment.CopyAssignment');
00042 import('submission.editAssignment.EditAssignment');
00043 import('submission.layoutAssignment.LayoutAssignment');
00044 import('submission.proofAssignment.ProofAssignment');
00045 import('submission.reviewAssignment.ReviewAssignment');
00046 import('comment.Comment');
00047 import('file.ArticleFileManager');
00048 import('file.PublicFileManager');
00049 import('search.ArticleSearchIndex');
00050
00051
00052 class ImportOJS1 {
00053
00054
00055
00056
00057
00058 var $importPath;
00059 var $importVersion;
00060 var $journalPath;
00061 var $journalId = 0;
00062
00063 var $userMap = array();
00064 var $issueMap = array();
00065 var $sectionMap = array();
00066 var $articleMap = array();
00067 var $fileMap = array();
00068
00069 var $importDBConn;
00070 var $importDao;
00071
00072 var $indexUrl;
00073 var $importJournal;
00074 var $journalConfigInfo;
00075 var $journalInfo;
00076 var $journalLayoutUserId = 0;
00077
00078 var $showVolume = 0;
00079 var $showNumber = 0;
00080 var $showYear = 0;
00081 var $showTitle = 0;
00082
00083 var $userCount = 0;
00084 var $issueCount = 0;
00085 var $articleCount = 0;
00086
00087 var $options;
00088 var $error;
00089
00091 var $conflicts;
00092
00094 var $redirects;
00095
00099 function ImportOJS1() {
00100 $this->indexUrl = Request::getIndexUrl();
00101 $this->conflicts = array();
00102 $this->redirects = array();
00103 }
00104
00109 function error($message = null) {
00110 if (isset($message)) {
00111 $this->error = $message;
00112 }
00113 return $this->error;
00114 }
00115
00121 function hasOption($option) {
00122 return in_array($option, $this->options);
00123 }
00124
00134 function import($journalPath, $importPath, $options = array()) {
00135 @set_time_limit(0);
00136 $this->journalPath = $journalPath;
00137 $this->importPath = $importPath;
00138 $this->options = $options;
00139
00140
00141 $dbconn = &DBConnection::getInstance();
00142 $dbconn->reconnect(true);
00143
00144
00145 if (!@include($this->importPath . '/include/db.php')) {
00146 $this->error('Failed to load ' . $this->importPath . '/include/db.php');
00147 return false;
00148 }
00149
00150
00151
00152 $this->importDBConn = &new DBConnection($db_config['type'], $db_config['host'], $db_config['uname'], $db_config['password'], $db_config['name'], false, false, true, false, true);
00153 $dbconn = &$this->importDBConn->getDBConn();
00154
00155 if (!$this->importDBConn->isConnected()) {
00156 $this->error('Database connection error: ' . $dbconn->errorMsg());
00157 return false;
00158 }
00159
00160 $this->importDao = &new DAO($dbconn);
00161
00162 if (!$this->loadJournalConfig()) {
00163 $this->error('Unsupported or unrecognized OJS version');
00164 return false;
00165 }
00166
00167
00168 $journalDao = &DAORegistry::getDAO('JournalDAO');
00169 $journal = &$journalDao->getJournalByPath($this->journalPath);
00170 $this->importJournal = ($journal == null);
00171
00172
00173 if ($this->importJournal) {
00174 $this->importJournal();
00175 $this->importReadingTools();
00176 } else {
00177 $this->journalId = $journal->getJournalId();
00178 }
00179 $this->importUsers();
00180 if ($this->hasOption('importSubscriptions') && version_compare($this->importVersion, OJS1_MIN_VERSION_SUBSCRIPTIONS) >= 0) {
00181
00182 $this->importSubscriptions();
00183 }
00184 $this->importSections();
00185 $this->importIssues();
00186 $this->importArticles();
00187
00188
00189 $this->rebuildSearchIndex();
00190
00191 if ($this->hasOption('redirect')) {
00192 $this->generateRedirects();
00193 }
00194
00195 return $this->journalId;
00196 }
00197
00202 function loadJournalConfig() {
00203
00204 $result = &$this->importDao->retrieve('SELECT * FROM tbljournalconfig');
00205 $this->journalConfigInfo = &$result->fields;
00206 $result->Close();
00207
00208 if (!isset($this->journalConfigInfo['chOJSVersion'])) {
00209 return false;
00210 }
00211 $this->importVersion = $this->journalConfigInfo['chOJSVersion'];
00212 if (version_compare($this->importVersion, OJS1_MIN_VERSION) < 0) {
00213 return false;
00214 }
00215
00216
00217 $result = &$this->importDao->retrieve('SELECT * FROM tbljournal');
00218 $this->journalInfo = &$result->fields;
00219 $result->Close();
00220
00221 return true;
00222 }
00223
00224
00225
00226
00227
00228
00232 function importJournal() {
00233 if ($this->hasOption('verbose')) {
00234 printf("Importing journal\n");
00235 }
00236
00237
00238 $journalDao = &DAORegistry::getDAO('JournalDAO');
00239 $journal = &new Journal();
00240 $journal->setPrimaryLocale(Locale::getLocale());
00241 $journal->setPath($this->journalPath);
00242 $journal->setEnabled(1);
00243 $this->journalId = $journalDao->insertJournal($journal);
00244 $journal->updateSetting('title', array(Locale::getLocale() => $this->journalInfo['chTitle']), 'string', true);
00245 $journalDao->resequenceJournals();
00246
00247
00248 $roleDao = &DAORegistry::getDAO('RoleDAO');
00249 $admins = $roleDao->getUsersByRoleId(ROLE_ID_SITE_ADMIN);
00250 foreach ($admins->toArray() as $admin) {
00251 $role = &new Role();
00252 $role->setJournalId($this->journalId);
00253 $role->setUserId($admin->getUserId());
00254 $role->setRoleId(ROLE_ID_JOURNAL_MANAGER);
00255 $roleDao->insertRole($role);
00256 }
00257
00258
00259 import('rt.ojs.JournalRTAdmin');
00260 $journalRtAdmin = &new JournalRTAdmin($this->journalId);
00261 $journalRtAdmin->restoreVersions(false);
00262
00263
00264 $sponsors = array();
00265 $result = &$this->importDao->retrieve('SELECT * FROM tblsponsors ORDER BY nSponsorID');
00266 $publisherInstitution = $publisherUrl = null;
00267 while (!$result->EOF) {
00268 $row = &$result->fields;
00269 $sponsors[] = array('institution' => Core::cleanVar($row['chName']), 'url' => Core::cleanVar($row['chWebpage']));
00270 if (empty($publisher)) {
00271 $publisherInstitution = Core::cleanVar($row['chName']);
00272 $publisherUrl = Core::cleanVar($row['chWebpage']);
00273 }
00274 $result->MoveNext();
00275 }
00276 $result->Close();
00277
00278 $contributors = array();
00279 $result = &$this->importDao->retrieve('SELECT * FROM tblcontributors ORDER BY nContributorID');
00280 while (!$result->EOF) {
00281 $row = &$result->fields;
00282 $contributors[] = array('name' => Core::cleanVar($row['chName']), 'url' => Core::cleanVar($row['chWebpage']));
00283 $result->MoveNext();
00284 }
00285 $result->Close();
00286
00287
00288 $submissionChecklist = array();
00289 $result = &$this->importDao->retrieve('SELECT * FROM tblsubmissionchecklist ORDER BY nOrder');
00290 while (!$result->EOF) {
00291 $row = &$result->fields;
00292 $submissionChecklist[] = array('order' => $row['nOrder'], 'content' => Core::cleanVar($row['chCheck']));
00293 $result->MoveNext();
00294 }
00295 $result->Close();
00296
00297
00298 $customAboutItems = array();
00299 $result = &$this->importDao->retrieve('SELECT * FROM tblaboutjournal ORDER BY nItemID');
00300 while (!$result->EOF) {
00301 $row = &$result->fields;
00302 $customAboutItems[] = array('title' => Core::cleanVar($row['chTitle']), 'content' => Core::cleanVar($row['chContent']));
00303 $result->MoveNext();
00304 }
00305 $result->Close();
00306
00307
00308 $navItems = array();
00309 if ($this->journalInfo['bDiscussion'] && !empty($this->journalInfo['chDiscussionURL'])) {
00310 $navItems[] = array('name' => Core::cleanVar('Forum'), 'url' => Core::cleanVar($this->journalInfo['chDiscussionURL']), 'isLiteral' => '1', 'isAbsolute' => '1');
00311 }
00312
00313 $publicationFormatVolume = 1;
00314 $publicationFormatNumber = 1;
00315 $publicationFormatYear = 1;
00316 $publicationFormatTitle = 1;
00317
00318 if ($this->journalInfo['nSchedulingType'] == 1 && !$this->journalInfo['bPubUseNum']) {
00319 $publicationFormatNumber = 0;
00320 } else if($this->journalInfo['nSchedulingType'] == 2) {
00321 $publicationFormatVolume = 0;
00322 $publicationFormatNumber = 0;
00323 }
00324
00325
00326 $homeHeaderLogoImage = $this->copyJournalImage('chSmallHomeLogo', 'homeHeaderLogoImage');
00327 $homeHeaderTitleImage = $this->copyJournalImage('chLargeHomeLogo', 'homeHeaderTitleImage');
00328 $pageHeaderLogoImage = $this->copyJournalImage('chSmallLogo', 'pageHeaderLogoImage');
00329 $pageHeaderTitleImage = $this->copyJournalImage('chLargeLogo', 'pageHeaderTitleImage');
00330 $homepageImage = $this->copyJournalImage('chTableOfContentImage', 'homepageImage');
00331
00332 $translateParams = array('indexUrl' => $this->indexUrl, 'journalPath' => $this->journalPath, 'journalName' => Core::cleanVar($this->journalInfo['chTitle']));
00333
00334
00335
00336 $commentDao =& DAORegistry::getDAO('CommentDAO');
00337
00338
00339
00340 $journalSettings = array(
00341 'initials' => array('string', Core::cleanVar($this->journalInfo['chAbbrev'])),
00342 'onlineIssn' => array('string', Core::cleanVar($this->journalInfo['chISSN'])),
00343 'mailingAddress' => array('string', Core::cleanVar($this->journalInfo['chMailAddr'])),
00344 'useEditorialBoard' => array('bool', $this->journalInfo['bRevBoard']),
00345 'contactName' => array('string', Core::cleanVar($this->journalInfo['chContactName'])),
00346 'contactTitle' => array('string', Core::cleanVar($this->journalInfo['chContactTitle'])),
00347 'contactAffiliation' => array('string', Core::cleanVar($this->journalInfo['chContactAffiliation'])),
00348 'contactEmail' => array('string', Core::cleanVar($this->journalInfo['chContactEmail'])),
00349 'contactPhone' => array('string', Core::cleanVar($this->journalInfo['chContactPhone'])),
00350 'contactFax' => array('string', Core::cleanVar($this->journalInfo['chContactFax'])),
00351 'contactMailingAddress' => array('string', Core::cleanVar($this->journalInfo['chContactMailAddr'])),
00352 'supportName' => array('string', Core::cleanVar($this->journalInfo['chSupportName'])),
00353 'supportEmail' => array('string', Core::cleanVar($this->journalInfo['chSupportEmail'])),
00354 'supportPhone' => array('string', Core::cleanVar($this->journalInfo['chSupportPhone'])),
00355 'sponsorNote' => array('string', Core::cleanVar($this->journalInfo['chSponsorNote'])),
00356 'sponsors' => array('object', $sponsors),
00357 'publisherInstitution' => array('string', $publisherInstitution),
00358 'publisherUrl' => array('string', $publisherUrl),
00359 'contributorNote' => array('string', Core::cleanVar($this->journalInfo['chContribNote'])),
00360 'contributors' => array('object', $contributors),
00361 'searchDescription' => array('string', Core::cleanVar($this->journalInfo['chMetaDescription'])),
00362 'searchKeywords' => array('string', Core::cleanVar($this->journalInfo['chMetaKeywords'])),
00363
00364
00365 'focusScopeDesc' => array('string', Core::cleanVar($this->journalInfo['chFocusScope'])),
00366 'numWeeksPerReview' => array('int', $this->journalInfo['nReviewDueWeeks']),
00367
00368
00369
00370
00371
00372 'restrictReviewerFileAccess' => array('int', isset($this->journalInfo['bReviewerSubmissionRestrict']) ? $this->journalInfo['bReviewerSubmissionRestrict'] : 0),
00373 'reviewPolicy' => array('string', Core::cleanVar($this->journalInfo['chReviewProcess'])),
00374 'mailSubmissionsToReviewers' => array('int', isset($this->journalInfo['bReviewerMailSubmission']) ? $this->journalInfo['bReviewerMailSubmission'] : 0),
00375 'reviewGuidelines' => array('string', Core::cleanVar($this->journalInfo['chReviewerGuideline'])),
00376 'authorSelectsEditor' => array('int', isset($this->journalInfo['bAuthorSelectEditor']) ? $this->journalInfo['bAuthorSelectEditor'] : 0),
00377 'privacyStatement' => array('string', Core::cleanVar($this->journalInfo['chPrivacyStatement'])),
00378 'openAccessPolicy' => array('string', Core::cleanVar($this->journalInfo['chOpenAccess'])),
00379
00380 'emailSignature' => array('string', Locale::translate('default.journalSettings.emailSignature', $translateParams)),
00381
00382
00383
00384
00385
00386
00387
00388
00389 'customAboutItems' => array('object', $customAboutItems),
00390 'enableComments' => array('int', $this->journalInfo['bComments'] ? COMMENTS_UNAUTHENTICATED : COMMENTS_DISABLED),
00391 'enableLockss' => array('bool', isset($this->journalInfo['bEnableLOCKSS']) ? $this->journalInfo['bEnableLOCKSS'] : 0),
00392 'lockssLicense' => array('string', isset($this->journalInfo['chLOCKSSLicense']) ? Core::cleanVar($this->journalInfo['chLOCKSSLicense']) : Locale::translate('default.journalSettings.lockssLicense')),
00393
00394 'authorGuidelines' => array('string', Core::cleanVar($this->journalInfo['chAuthorGuideline'])),
00395 'submissionChecklist' => array('object', $submissionChecklist),
00396 'copyrightNotice' => array('string', Core::cleanVar($this->journalInfo['chCopyrightNotice'])),
00397 'metaDiscipline' => array('bool', $this->journalInfo['bMetaDiscipline']),
00398 'metaDisciplineExamples' => array('string', Core::cleanVar($this->journalInfo['chDisciplineExamples'])),
00399 'metaSubjectClass' => array('bool', $this->journalInfo['bMetaSubjectClass']),
00400 'metaSubjectClassTitle' => array('string', Core::cleanVar($this->journalInfo['chSubjectClassTitle'])),
00401 'metaSubjectClassUrl' => array('string', Core::cleanVar($this->journalInfo['chSubjectClassURL'])),
00402 'metaSubject' => array('bool', $this->journalInfo['bMetaSubject']),
00403 'metaSubjectExamples' => array('string', $this->journalInfo['chSubjectExamples']),
00404 'metaCoverage' => array('bool', $this->journalInfo['bMetaCoverage']),
00405 'metaCoverageGeoExamples' => array('string', Core::cleanVar($this->journalInfo['chCovGeoExamples'])),
00406 'metaCoverageChronExamples' => array('string', Core::cleanVar($this->journalInfo['chCovChronExamples'])),
00407 'metaCoverageResearchSampleExamples' => array('string', Core::cleanVar($this->journalInfo['chCovSampleExamples'])),
00408 'metaType' => array('bool', $this->journalInfo['bMetaType']),
00409 'metaTypeExamples' => array('string', Core::cleanVar($this->journalInfo['chDisciplineExamples'])),
00410
00411 'publicationFormatVolume' => array('int', $publicationFormatVolume),
00412 'publicationFormatNumber' => array('int', $publicationFormatNumber),
00413 'publicationFormatYear' => array('int', $publicationFormatYear),
00414 'publicationFormatTitle' => array('int', $publicationFormatTitle),
00415 'initialVolume' => array('int', $this->journalInfo['nInitVol']),
00416 'initialNumber' => array('int', $this->journalInfo['nInitNum']),
00417 'initialYear' => array('int', $this->journalInfo['nInitYear']),
00418 'pubFreqPolicy' => array('string', Core::cleanVar($this->journalInfo['chFreqPublication'])),
00419 'useCopyeditors' => array('bool', $this->journalInfo['bCopyEditor']),
00420 'copyeditInstructions' => array('string', Core::cleanVar($this->journalInfo['chCopyeditInstructions'])),
00421 'useLayoutEditors' => array('bool', $this->journalInfo['bLayoutEditor']),
00422
00423 'useProofreaders' => array('bool', $this->journalInfo['bProofReader']),
00424 'proofInstructions' => array('string', Core::cleanVar($this->journalInfo['chProofingInstructions'])),
00425 'enableSubscriptions' => array('bool', isset($this->journalInfo['bSubscriptions']) ? $this->journalInfo['bSubscriptions'] : 0),
00426 'subscriptionName' => array('string', Core::cleanVar($this->journalInfo['chContactName'])),
00427 'subscriptionEmail' => array('string', Core::cleanVar($this->journalInfo['chContactEmail'])),
00428 'subscriptionPhone' => array('string', Core::cleanVar($this->journalInfo['chContactPhone'])),
00429 'subscriptionFax' => array('string', Core::cleanVar($this->journalInfo['chContactFax'])),
00430 'subscriptionMailingAddress' => array('string', Core::cleanVar($this->journalInfo['chContactMailAddr'])),
00431
00432
00433
00434
00435
00436
00437
00438 'homeHeaderTitleType' => array('int', isset($homeHeaderTitleImage) ? 1 : 0),
00439 'homeHeaderTitle' => array('string', Core::cleanVar($this->journalInfo['chTitle'])),
00440
00441
00442
00443
00444 'pageHeaderTitleType' => array('int', isset($pageHeaderTitleImage) ? 1 : 0),
00445 'pageHeaderTitle' => array('string', $this->journalInfo['chTitle']),
00446
00447
00448
00449
00450 'homeHeaderLogoImage' => array('object', $homeHeaderLogoImage),
00451 'homeHeaderTitleImage' => array('object', $homeHeaderTitleImage),
00452 'pageHeaderLogoImage' => array('object', $pageHeaderLogoImage),
00453 'pageHeaderTitleImage' => array('object', $pageHeaderTitleImage),
00454 'homepageImage' => array('object', $homepageImage),
00455 'readerInformation' => array('string', Locale::translate('default.journalSettings.forReaders', $translateParams)),
00456 'authorInformation' => array('string', Locale::translate('default.journalSettings.forAuthors', $translateParams)),
00457 'librarianInformation' => array('string', Locale::translate('default.journalSettings.forLibrarians', $translateParams)),
00458 'journalPageHeader' => array('string', Core::cleanVar($this->journalInfo['chHeader'])),
00459 'journalPageFooter' => array('string', Core::cleanVar($this->journalInfo['chFooter'])),
00460 'displayCurrentIssue' => array('bool', $this->journalInfo['bHomepageCurrIssue']),
00461 'additionalHomeContent' => array('string', Core::cleanVar($this->journalInfo['chTableOfContentText'])),
00462 'journalDescription' => array('string', Core::cleanVar($this->journalInfo['chHomepageIntro'])),
00463 'navItems' => array('object', $navItems),
00464 'itemsPerPage' => array('int', 25),
00465 'numPageLinks' => array('int', 10),
00466 );
00467
00468 $settingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00469
00470
00471
00472
00473 import('manager.form.setup.JournalSetupStep1Form');
00474 import('manager.form.setup.JournalSetupStep2Form');
00475 import('manager.form.setup.JournalSetupStep3Form');
00476 import('manager.form.setup.JournalSetupStep4Form');
00477 import('manager.form.setup.JournalSetupStep5Form');
00478 $localizedSettings = array_merge(
00479 JournalSetupStep1Form::getLocaleFieldNames(),
00480 JournalSetupStep2Form::getLocaleFieldNames(),
00481 JournalSetupStep3Form::getLocaleFieldNames(),
00482 JournalSetupStep4Form::getLocaleFieldNames(),
00483 JournalSetupStep5Form::getLocaleFieldNames()
00484 );
00485
00486 foreach ($journalSettings as $settingName => $settingInfo) {
00487 list($settingType, $settingValue) = $settingInfo;
00488 $settingsDao->updateSetting(
00489 $this->journalId,
00490 $settingName,
00491 $settingValue,
00492 $settingType,
00493 in_array($settingName, $localizedSettings)
00494 );
00495 }
00496 }
00497
00501 function importReadingTools() {
00502 if ($this->hasOption('verbose')) {
00503 printf("Importing RT settings\n");
00504 }
00505
00506 $rtDao = &DAORegistry::getDAO('RTDAO');
00507
00508 $versionId = 0;
00509
00510
00511 $result = &$this->importDao->retrieve('SELECT chTitle FROM tblrstversions WHERE bDefault = 1');
00512 if ($result->RecordCount() != 0) {
00513 $result = &$rtDao->retrieve('SELECT version_id FROM rt_versions WHERE journal_id = ? AND title = ?', array($this->journalId, $result->fields[0]));
00514 if ($result->RecordCount() != 0) {
00515 $versionId = $result->fields[0];
00516 }
00517 }
00518 $result->Close();
00519
00520 $result = &$this->importDao->retrieve('SELECT * FROM tblrst');
00521 $row = &$result->fields;
00522
00523 import('rt.ojs.JournalRT');
00524 $rt = &new JournalRT($this->journalId);
00525 $rt->setVersion($versionId);
00526 $rt->setCaptureCite($row['bCaptureCite']);
00527 $rt->setViewMetadata($row['bViewMetadata']);
00528 $rt->setSupplementaryFiles($row['bSuppFiles']);
00529 $rt->setPrinterFriendly($row['bPrintVersion']);
00530 $rt->setAuthorBio($row['bAuthorBios']);
00531 $rt->setDefineTerms($row['bDefineTerms']);
00532 $rt->setEmailAuthor($row['bEmailAuthor']);
00533 $rt->setEmailOthers($row['bEmailOthers']);
00534
00535 $result->Close();
00536
00537 $rtDao->insertJournalRT($rt);
00538 }
00539
00540
00541
00542
00543
00544
00548 function importUsers() {
00549 if ($this->hasOption('verbose')) {
00550 printf("Importing users\n");
00551 }
00552
00553 $userDao = &DAORegistry::getDAO('UserDAO');
00554 $roleDao = &DAORegistry::getDAO('RoleDAO');
00555 $notifyDao = &DAORegistry::getDAO('NotificationStatusDAO');
00556
00557 $result = &$this->importDao->retrieve('SELECT *, DECODE(chPassword, ?) AS chPassword FROM tblusers ORDER BY nUserID', $this->journalConfigInfo['chPasswordSalt']);
00558 while (!$result->EOF) {
00559 $row = &$result->fields;
00560
00561 $chFirstName = Core::cleanVar($row['chFirstName']);
00562 $chMiddleInitial = Core::cleanVar($row['chMiddleInitial']);
00563 $chSurname = Core::cleanVar($row['chSurname']);
00564
00565 $initials = substr($chFirstName, 0, 1) . (empty($chMiddleInitial) ? '' : substr($chMiddleInitial, 0, 1)) . substr($chSurname, 0, 1);
00566 $interests = '';
00567
00568 if ($row['fkEditorID']) {
00569 $tmpResult = &$this->importDao->retrieve('SELECT chInitials, nEditorRole FROM tbleditors WHERE nEditorID = ?', $row['fkEditorID']);
00570 $initials = Core::cleanVar($tmpResult->fields[0]);
00571 $editorRole = Core::cleanVar($tmpResult->fields[1]);
00572 $tmpResult->Close();
00573 }
00574
00575 if ($row['fkReviewerID']) {
00576 $tmpResult = &$this->importDao->retrieve('SELECT chInterests FROM tblreviewers WHERE nReviewerID = ?', $row['fkReviewerID']);
00577 $interests = Core::cleanVar($tmpResult->fields[0]);
00578 $tmpResult->Close();
00579 }
00580
00581
00582 import('core.Transcoder');
00583 $trans =& new Transcoder('UTF-8', 'ASCII', true);
00584 $username = $trans->trans(Core::cleanVar($row['chUsername']));
00585 $email = $trans->trans(Core::cleanVar($row['chEmail']));
00586
00587
00588 $user = $userDao->getUserByUsername($username);
00589 $existingUser = ($user != null);
00590
00591 if (!isset($user)) {
00592
00593 $user = &new User();
00594 $user->setUsername($username);
00595 $user->setPassword(Validation::encryptCredentials($username, Core::cleanVar($row['chPassword'])));
00596 $user->setFirstName(Core::cleanVar($row['chFirstName']));
00597 $user->setMiddleName(Core::cleanVar($row['chMiddleInitial']));
00598 $user->setInitials(Core::cleanVar($initials));
00599 $user->setLastName(Core::cleanVar($row['chSurname']));
00600 $user->setAffiliation(Core::cleanVar($row['chAffiliation']));
00601 $user->setEmail($email);
00602 $user->setPhone(Core::cleanVar($row['chPhone']));
00603 $user->setFax(Core::cleanVar($row['chFax']));
00604 $user->setMailingAddress(Core::cleanVar($row['chMailAddr']));
00605 $user->setBiography(Core::cleanVar($row['chBiography']), Locale::getLocale());
00606 $user->setInterests(Core::cleanVar($interests), Locale::getLocale());
00607 $user->setLocales(array());
00608 $user->setDateRegistered($row['dtDateSignedUp']);
00609 $user->setDateLastLogin($row['dtDateSignedUp']);
00610 $user->setMustChangePassword(0);
00611 $user->setDisabled(0);
00612
00613 $otherUser =& $userDao->getUserByEmail($email);
00614 if ($otherUser !== null) {
00615
00616 $user->setEmail('ojs-' . $username . '+' . $email);
00617 $this->conflicts[] = array(&$otherUser, &$user);
00618 }
00619 unset($otherUser);
00620
00621 $userDao->insertUser($user);
00622 }
00623 $userId = $user->getUserId();
00624
00625 if ($row['bNotify']) {
00626 if ($existingUser) {
00627
00628 $notifyDao->setJournalNotifications($this->journalId, $userId, 0);
00629 }
00630 $notifyDao->setJournalNotifications($this->journalId, $userId, 1);
00631 }
00632
00633 if ($row['fkEditorID']) {
00634 $role = &new Role();
00635 $role->setJournalId($this->journalId);
00636 $role->setUserId($userId);
00637 switch ($editorRole) {
00638 case 0:
00639 $role->setRoleId(ROLE_ID_EDITOR);
00640 break;
00641 case 1:
00642 $role->setRoleId(ROLE_ID_SECTION_EDITOR);
00643 break;
00644 case 2:
00645 $role->setRoleId(ROLE_ID_JOURNAL_MANAGER);
00646 break;
00647 case 3:
00648 $role->setRoleId(ROLE_ID_LAYOUT_EDITOR);
00649 $this->journalLayoutUserId = $userId;
00650 break;
00651 }
00652
00653 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00654 $roleDao->insertRole($role);
00655 }
00656 }
00657
00658 if ($row['fkAuthorID']) {
00659 $role = &new Role();
00660 $role->setJournalId($this->journalId);
00661 $role->setUserId($userId);
00662 $role->setRoleId(ROLE_ID_AUTHOR);
00663 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00664 $roleDao->insertRole($role);
00665 }
00666 }
00667
00668 if ($row['fkReviewerID']) {
00669 $role = &new Role();
00670 $role->setJournalId($this->journalId);
00671 $role->setUserId($userId);
00672 $role->setRoleId(ROLE_ID_REVIEWER);
00673 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00674 $roleDao->insertRole($role);
00675 }
00676 }
00677
00678 if ($row['fkCopyEdID']) {
00679 $role = &new Role();
00680 $role->setJournalId($this->journalId);
00681 $role->setUserId($userId);
00682 $role->setRoleId(ROLE_ID_COPYEDITOR);
00683 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00684 $roleDao->insertRole($role);
00685 }
00686 }
00687
00688 if ($row['fkProofID']) {
00689 $role = &new Role();
00690 $role->setJournalId($this->journalId);
00691 $role->setUserId($userId);
00692 $role->setRoleId(ROLE_ID_PROOFREADER);
00693 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00694 $roleDao->insertRole($role);
00695 }
00696 }
00697
00698 if ($row['fkReaderID']) {
00699 $role = &new Role();
00700 $role->setJournalId($this->journalId);
00701 $role->setUserId($userId);
00702 $role->setRoleId(ROLE_ID_READER);
00703 if (!$existingUser || !$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
00704 $roleDao->insertRole($role);
00705 }
00706 }
00707
00708 $this->userMap[$row['nUserID']] = $userId;
00709 $this->userCount++;
00710 $result->MoveNext();
00711 unset($user);
00712 }
00713 $result->Close();
00714 }
00715
00719 function importSubscriptions() {
00720 if ($this->hasOption('verbose')) {
00721 printf("Importing subscriptions\n");
00722 }
00723
00724 $subscriptionTypeDao = &DAORegistry::getDAO('SubscriptionTypeDAO');
00725 $subscriptionDao = &DAORegistry::getDAO('SubscriptionDAO');
00726
00727 $subscriptionTypeMap = array();
00728
00729 $subscriptionFormatMap = array(
00730 1 => SUBSCRIPTION_TYPE_FORMAT_PRINT,
00731 2 => SUBSCRIPTION_TYPE_FORMAT_ONLINE,
00732 3 => SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE
00733 );
00734
00735 $currencyMap = array(
00736 1 => 'CAD',
00737 2 => 'USD'
00738 );
00739
00740 $result = &$this->importDao->retrieve('SELECT * FROM tblsubscriptiontype ORDER BY nOrder');
00741 $count = 0;
00742 while (!$result->EOF) {
00743 $row = &$result->fields;
00744
00745 $subscriptionType = &new SubscriptionType();
00746 $subscriptionType->setJournalId($this->journalId);
00747 $subscriptionType->setName(Core::cleanVar($row['chSubscriptionType']), Locale::getLocale());
00748 $subscriptionType->setDescription(Core::cleanVar($row['chSubscriptionTypeDesc']), Locale::getLocale());
00749 $subscriptionType->setCost($row['fCost']);
00750 $subscriptionType->setCurrencyCodeAlpha(isset($currencyMap[$row['fkCurrencyID']]) ? $currencyMap[$row['fkCurrencyID']] : 'USD');
00751 $subscriptionType->setDuration(12);
00752 $subscriptionType->setFormat(isset($subscriptionFormatMap[$row['fkSubscriptionFormatID']]) ? $subscriptionFormatMap[$row['fkSubscriptionFormatID']] : SUBSCRIPTION_TYPE_FORMAT_PRINT_ONLINE);
00753 $subscriptionType->setInstitutional($row['bInstitutional']);
00754 $subscriptionType->setMembership($row['bMembership']);
00755 $subscriptionType->setDisablePublicDisplay(0);
00756 $subscriptionType->setSequence(++$count);
00757
00758 $subscriptionTypeDao->insertSubscriptionType($subscriptionType);
00759 $subscriptionTypeMap[$row['nSubscriptionTypeID']] = $subscriptionType->getTypeId();
00760 $result->MoveNext();
00761 }
00762 $result->Close();
00763
00764 $result = &$this->importDao->retrieve('SELECT tblsubscribers.*, nUserID FROM tblsubscribers LEFT JOIN tblusers ON nSubscriberID = fkSubscriberID ORDER BY nSubscriberID');
00765 while (!$result->EOF) {
00766 $row = &$result->fields;
00767
00768 $subscription = &new Subscription();
00769 $subscription->setJournalId($this->journalId);
00770 $subscription->setUserId(isset($this->userMap[$row['nUserID']]) ? $this->userMap[$row['nUserID']] : 0);
00771 $subscription->setTypeId(isset($subscriptionTypeMap[$row['fkSubscriptionTypeID']]) ? $subscriptionTypeMap[$row['fkSubscriptionTypeID']] : 0);
00772 $subscription->setDateStart($row['dtDateStart']);
00773 $subscription->setDateEnd($row['dtDateEnd']);
00774 $subscription->setMembership(Core::cleanVar($row['chMembership']));
00775 $subscription->setDomain(Core::cleanVar($row['chDomain']));
00776 $subscription->setIPRange('');
00777
00778 $subscriptionDao->insertSubscription($subscription);
00779 $result->MoveNext();
00780 }
00781 $result->Close();
00782 }
00783
00784
00785
00786
00787
00788
00792 function importIssues() {
00793 if ($this->hasOption('verbose')) {
00794 printf("Importing issues\n");
00795 }
00796
00797 $issueDao = &DAORegistry::getDAO('IssueDAO');
00798
00799 $this->showVolume = 1;
00800 $this->showNumber = 1;
00801 $this->showYear = 1;
00802 $this->showTitle = 1;
00803
00804 if ($this->journalInfo['nSchedulingType'] == 1 && !$this->journalInfo['bPubUseNum']) {
00805 $this->showNumber = 0;
00806 } else if($this->journalInfo['nSchedulingType'] == 2) {
00807 $this->showVolume = 0;
00808 $this->showNumber = 0;
00809 }
00810
00811 $result = &$this->importDao->retrieve('SELECT * FROM tblissues ORDER BY bPublished DESC, bLive ASC, nYear ASC, nVolume ASC, nNumber ASC');
00812 while (!$result->EOF) {
00813 $row = &$result->fields;
00814
00815 $issue = &new Issue();
00816 $issue->setJournalId($this->journalId);
00817 $issue->setTitle(Core::cleanVar($row['chIssueTitle']), Locale::getLocale());
00818 $issue->setVolume($row['nVolume']);
00819 $issue->setNumber($row['nNumber']);
00820 $issue->setYear($row['nYear']);
00821 $issue->setPublished($row['bPublished']);
00822 $issue->setCurrent($row['bLive']);
00823 if (isset($row['dtDatePublished'])) {
00824 $issue->setDatePublished($row['dtDatePublished']);
00825 } elseif (isset($row['nYear']) && isset($row['nNumber']) && ($row['nNumber'] >= 1) && ($row['nNumber'] <= 31)) {
00826 $issue->setDatePublished($row['nYear'] . '-' . $row['nNumber'] . '-1');
00827 } elseif (isset($row['nYear'])) {
00828 $issue->setDatePublished($row['nYear'] . '-1-1');
00829 } else {
00830 $issue->setDatePublished(null);
00831 }
00832 $issue->setAccessStatus(OPEN_ACCESS);
00833 $issue->setOpenAccessDate(isset($row['dtDateOpenAccess']) ? $row['dtDateOpenAccess'] : null);
00834 $issue->setShowVolume($this->showVolume);
00835 $issue->setShowNumber($this->showNumber);
00836 $issue->setShowYear($this->showYear);
00837 $issue->setShowTitle($this->showTitle);
00838 $issue->setShowCoverPage(0, Locale::getLocale());
00839
00840 $issueId = $issueDao->insertIssue($issue);
00841 $this->issueMap[$row['nIssueID']] = $issueId;
00842 $this->issueCount++;
00843 $result->MoveNext();
00844 }
00845 $result->Close();
00846
00847 if (!$this->showVolume && !$this->showNumber && $this->showYear) {
00848
00849 $result = &$this->importDao->retrieve('SELECT DISTINCT(DATE_FORMAT(dtDatePublished, \'%Y\')) FROM tblarticles WHERE bPublished = 1 ORDER BY year');
00850 while (!$result->EOF) {
00851 list($year) = $result->fields;
00852
00853 $issue = &new Issue();
00854 $issue->setJournalId($this->journalId);
00855 $issue->setTitle('');
00856 $issue->setVolume('');
00857 $issue->setNumber('');
00858 $issue->setYear($year);
00859 $issue->setPublished(1);
00860 $issue->setDatePublished($year . '-01-01');
00861 $issue->setAccessStatus(OPEN_ACCESS);
00862 $issue->setOpenAccessDate(null);
00863 $issue->setShowVolume($this->showVolume);
00864 $issue->setShowNumber($this->showNumber);
00865 $issue->setShowYear($this->showYear);
00866 $issue->setShowTitle($this->showTitle);
00867
00868 $result->MoveNext();
00869
00870 $issue->setCurrent($result->EOF ? 1 : 0);
00871 $issueId = $issueDao->insertIssue($issue);
00872 $this->issueMap['YEAR' . $year] = $issueId;
00873 $this->issueCount++;
00874 }
00875 $result->Close();
00876 }
00877
00878
00879 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00880 $result = &$this->importDao->retrieve('SELECT * FROM tblissuestosections ORDER BY nSectionRank');
00881 while (!$result->EOF) {
00882 $row = &$result->fields;
00883
00884 $sectionId = isset($this->sectionMap[$row['fkSectionID']])?$this->sectionMap[$row['fkSectionID']]:null;
00885 $issueId = isset($this->issueMap[$row['fkIssueID']])?$this->issueMap[$row['fkIssueID']]:null;
00886
00887 if (isset($sectionId) && isset($issueId)) {
00888 $sectionDao->insertCustomSectionOrder($issueId, $sectionId, $row['nSectionRank']);
00889 }
00890 $result->MoveNext();
00891 }
00892 $result->Close();
00893 }
00894
00898 function importSections() {
00899 if ($this->hasOption('verbose')) {
00900 printf("Importing sections\n");
00901 }
00902
00903 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00904 $sectionEditorDao = &DAORegistry::getDAO('SectionEditorsDAO');
00905
00906 $result = &$this->importDao->retrieve('SELECT * FROM tblsections ORDER BY nRank');
00907 $count = 0;
00908 while (!$result->EOF) {
00909 $row = &$result->fields;
00910
00911 $section = &new Section();
00912 $section->setJournalId($this->journalId);
00913 $section->setTitle(Core::cleanVar($row['chTitle']), Locale::getLocale());
00914 $section->setAbbrev(Core::cleanVar($row['chAbbrev']), Locale::getLocale());
00915 $section->setSequence(++$count);
00916 $section->setMetaIndexed($row['bMetaIndex']);
00917 $section->setEditorRestricted($row['bAcceptSubmissions'] ? 0 : 1);
00918 $section->setPolicy(Core::cleanVar($row['chPolicies']), Locale::getLocale());
00919
00920 $sectionId = $sectionDao->insertSection($section);
00921 $this->sectionMap[$row['nSectionID']] = $sectionId;
00922 $result->MoveNext();
00923 }
00924 $result->Close();
00925
00926
00927 $result = &$this->importDao->retrieve('SELECT nUserID, fkSectionID FROM tblusers, tbleditorsections WHERE tblusers.fkEditorID = tbleditorsections.fkEditorID AND fkSectionID IS NOT NULL AND fkSectionID != -1 ORDER BY nUserID');
00928 while (!$result->EOF) {
00929 $row = &$result->fields;
00930
00931 if (isset($this->sectionMap[$row['fkSectionID']]) && isset($this->userMap[$row['nUserID']])) {
00932 $sectionEditorDao->insertEditor($this->journalId, $this->sectionMap[$row['fkSectionID']], $this->userMap[$row['nUserID']], true, true);
00933 }
00934
00935 $result->MoveNext();
00936 }
00937 $result->Close();
00938 }
00939
00943 function importArticles() {
00944 if ($this->hasOption('verbose')) {
00945 printf("Importing articles\n");
00946 }
00947
00948 $articleDao = &DAORegistry::getDAO('ArticleDAO');
00949 $publishedArticleDao = &DAORegistry::getDAO('PublishedArticleDAO');
00950 $galleyDao = &DAORegistry::getDAO('ArticleGalleyDAO');
00951 $editAssignmentDao = &DAORegistry::getDAO('EditAssignmentDAO');
00952 $copyAssignmentDao = &DAORegistry::getDAO('CopyeditorSubmissionDAO');
00953 $layoutAssignmentDao = &DAORegistry::getDAO('LayoutAssignmentDAO');
00954 $proofAssignmentDao = &DAORegistry::getDAO('ProofAssignmentDAO');
00955 $reviewAssignmentDao = &DAORegistry::getDAO('ReviewAssignmentDAO');
00956
00957 $articleUsers = array();
00958
00959 $reviewRecommendations = array(
00960 0 => null,
00961 1 => null,
00962 2 => SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT,
00963 3 => SUBMISSION_REVIEWER_RECOMMENDATION_PENDING_REVISIONS,
00964 4 => SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_HERE,
00965 5 => SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_ELSEWHERE,
00966 6 => SUBMISSION_REVIEWER_RECOMMENDATION_DECLINE,
00967 7 => SUBMISSION_REVIEWER_RECOMMENDATION_SEE_COMMENTS
00968 );
00969
00970
00971 $result = &$this->importDao->retrieve('SELECT tblarticles.*, editor.nUserID AS nEditorUserID FROM tblarticles LEFT JOIN tblusers AS editor ON (tblarticles.fkEditorId = editor.fkEditorID) ORDER by nArticleID');
00972 while (!$result->EOF) {
00973 $row = &$result->fields;
00974
00975 $status = STATUS_QUEUED;
00976 if ($row['nStatus'] !== null) {
00977 if ($row['nStatus'] == 3) {
00978 $status = STATUS_DECLINED;
00979 } else if ($row['bArchive']) {
00980 $status = STATUS_ARCHIVED;
00981 } else if($row['bPublished']) {
00982 $status = STATUS_PUBLISHED;
00983 } else if($row['bSchedule']) {
00984
00985 $status = STATUS_QUEUED;
00986 }
00987 }
00988
00989 $locale = Locale::getLocale();
00990 $article = &new Article();
00991 $article->setUserId(1);
00992 $article->setJournalId($this->journalId);
00993 $article->setSectionId(isset($this->sectionMap[$row['fkSectionID']]) ? $this->sectionMap[$row['fkSectionID']] : 0);
00994 $article->setTitle(Core::cleanVar($row['chMetaTitle']), $locale);
00995 $article->setPages(isset($row['chPages']) ? Core::cleanVar($row['chPages']) : '');
00996 $article->setAbstract(Core::cleanVar($row['chMetaAbstract']), $locale);
00997 $article->setDiscipline(Core::cleanVar($row['chMetaDiscipline']), $locale);
00998 $article->setSubjectClass(Core::cleanVar($row['chMetaSubjectClass']), $locale);
00999 $article->setSubject(Core::cleanVar($row['chMetaSubject']), $locale);
01000 $article->setCoverageGeo(Core::cleanVar($row['chMetaCoverageGeo']), $locale);
01001 $article->setCoverageChron(Core::cleanVar($row['chMetaCoverageChron']), $locale);
01002 $article->setCoverageSample(Core::cleanVar($row['chMetaCoverageSample']), $locale);
01003 $article->setType(Core::cleanVar($row['chMetaType_Author']), $locale);
01004 $article->setLanguage(Core::cleanVar($row['chMetaLanguage']));
01005 $article->setSponsor(Core::cleanVar($row['chMetaSponsor_Author']), $locale);
01006 $article->setCommentsToEditor(Core::cleanVar($row['chNotesToEditor']));
01007 $article->setDateSubmitted($row['dtDateSubmitted']);
01008 $article->setDateStatusModified($row['dtDateSubmitted']);
01009 $article->setLastModified($row['dtDateSubmitted']);
01010 $article->setStatus($status);
01011 $article->setSubmissionProgress($row['dtDateSubmitted'] ? 0 : $row['nSubmissionProgress']);
01012 $article->setCurrentRound(1);
01013
01014
01015 $authorResult = &$this->importDao->retrieve('SELECT nUserID, tblmetaauthors.* FROM tblmetaauthors LEFT JOIN tblusers ON tblmetaauthors.fkAuthorID = tblusers.fkAuthorID WHERE fkArticleID = ? ORDER BY nRank', $row['nArticleID']);
01016 while (!$authorResult->EOF) {
01017 $authorRow = &$authorResult->fields;
01018
01019 $author = &new Author();
01020 $author->setFirstName(Core::cleanVar($authorRow['chFirstName']));
01021 $author->setMiddleName(Core::cleanVar($authorRow['chMiddleInitial']));
01022 $author->setLastName(Core::cleanVar($authorRow['chSurname']));
01023 $author->setAffiliation(Core::cleanVar($authorRow['chAffiliation']));
01024 $author->setEmail(Core::cleanVar($authorRow['chEmail']));
01025 $author->setBiography(Core::cleanVar($authorRow['chBiography']), $locale);
01026 $author->setPrimaryContact($authorRow['bPrimaryContact']);
01027
01028 if ($authorRow['bPrimaryContact'] && isset($this->userMap[$authorRow['nUserID']])) {
01029 $article->setUserId($this->userMap[$authorRow['nUserID']]);
01030 }
01031
01032 $article->addAuthor($author);
01033 unset($author);
01034 $authorResult->MoveNext();
01035 }
01036 $authorResult->Close();
01037
01038 $articleDao->insertArticle($article);
01039 $articleId = $article->getArticleId();
01040 $this->articleMap[$row['nArticleID']] = $articleId;
01041 $this->articleCount++;
01042
01043 $articleUsers[$articleId] = array(
01044 'authorId' => $article->getUserId(),
01045 'editorId' => isset($this->userMap[$row['nEditorUserID']]) ? $this->userMap[$row['nEditorUserID']] : $article->getUserId(),
01046 'proofId' => 0,
01047 'reviewerId' => array(),
01048 'reviewId' => array()
01049 );
01050
01051 if (empty($row['fkIssueID']) && $row['bPublished'] && $row['dtDatePublished'] && !$this->showVolume && !$this->showNumber && $this->showYear) {
01052 $row['fkIssueID'] = 'YEAR' . date('Y', strtotime($row['dtDatePublished']));
01053 }
01054
01055 if ($row['fkIssueID']) {
01056 $publishedArticle = &new PublishedArticle();
01057 $publishedArticle->setArticleId($articleId);
01058 $publishedArticle->setIssueId($this->issueMap[$row['fkIssueID']]);
01059 $publishedArticle->setDatePublished($row['dtDatePublished'] ? $row['dtDatePublished'] : $row['dtDateSubmitted']);
01060 $publishedArticle->setSeq((int)$row['nOrder']);
01061 $publishedArticle->setViews($row['nHitCounter']);
01062 $publishedArticle->setSectionId(isset($this->sectionMap[$row['fkSectionID']]) ? $this->sectionMap[$row['fkSectionID']] : 0);
01063 $publishedArticle->setAccessStatus(isset($row['fkPublishStatusID']) && $row['fkPublishStatusID'] == 2 ? SUBSCRIPTION : OPEN_ACCESS);
01064
01065 $publishedArticleDao->insertPublishedArticle($publishedArticle);
01066 }
01067
01068
01069 if ($row['fkFileOriginalID']) {
01070 $fileId = $this->addArticleFile($articleId, $row['fkFileOriginalID'], ARTICLE_FILE_SUBMISSION);
01071 $article->setSubmissionFileId($fileId);
01072 }
01073 if ($row['fkFileRevisionsID']) {
01074 $fileId = $this->addArticleFile($articleId, $row['fkFileRevisionsID'], ARTICLE_FILE_EDITOR);
01075 $article->setRevisedFileId($fileId);
01076 }
01077 if ($row['fkFileEditorID']) {
01078 $fileId = $this->addArticleFile($articleId, $row['fkFileEditorID'], ARTICLE_FILE_EDITOR);
01079 $article->setEditorFileId($fileId);
01080 }
01081
01082 if ($row['dtDateSubmitted']) {
01083 $fileManager = &new ArticleFileManager($articleId);
01084
01085 if ($article->getSubmissionFileId()) {
01086
01087 $fileId = $fileManager->copyToReviewFile($article->getSubmissionFileId());
01088 $article->setReviewFileId($fileId);
01089 if (!$article->getEditorFileId()) {
01090 $fileId = $fileManager->copyToEditorFile($fileId);
01091 $article->setEditorFileId($fileId);
01092 }
01093 }
01094
01095
01096 if ($row['dtDateEdDec']) {
01097 $articleDao->update('INSERT INTO edit_decisions
01098 (article_id, round, editor_id, decision, date_decided)
01099 VALUES (?, ?, ?, ?, ?)',
01100 array($articleId, 1, isset($this->userMap[$row['nEditorUserID']]) ? $this->userMap[$row['nEditorUserID']] : 0, $row['nStatus'] == 3 ? SUBMISSION_EDITOR_DECISION_DECLINE : SUBMISSION_EDITOR_DECISION_ACCEPT, $articleDao->datetimeToDB($row['dtDateEdDec'])));
01101 }
01102
01103 $articleDao->update('INSERT INTO review_rounds
01104 (article_id, round, review_revision)
01105 VALUES
01106 (?, ?, ?)',
01107 array($articleId, 1, 1)
01108 );
01109
01110
01111 if ($row['fkFileHTMLID']) {
01112 $fileId = $this->addArticleFile($articleId, $row['fkFileHTMLID'], ARTICLE_FILE_PUBLIC);
01113 $galley = &new ArticleHTMLGalley();
01114 $galley->setArticleId($articleId);
01115 $galley->setFileId($fileId);
01116 $galley->setLabel('HTML');
01117 $galley->setLocale(Locale::getLocale());
01118 $galley->setSequence(1);
01119 if ($row['fkFileStyleID']) {
01120 $fileId = $this->addArticleFile($articleId, $row['fkFileStyleID'], ARTICLE_FILE_PUBLIC);
01121 $galley->setStyleFile($fileId);
01122 }
01123 $galleyDao->insertGalley($galley);
01124 $this->copyHTMLGalleyImages($galley, $row['chLongID']);
01125 }
01126 if ($row['fkFilePDFID']) {
01127 $fileId = $this->addArticleFile($articleId, $row['fkFilePDFID'], ARTICLE_FILE_PUBLIC);
01128 $galley = &new ArticleGalley();
01129 $galley->setArticleId($articleId);
01130 $galley->setFileId($fileId);
01131 $galley->setLabel('PDF');
01132 $galley->setLocale(Locale::getLocale());
01133 $galley->setSequence(2);
01134 $galleyDao->insertGalley($galley);
01135 }
01136 if ($row['fkFilePostScriptID']) {
01137 $fileId = $this->addArticleFile($articleId, $row['fkFilePostScriptID'], ARTICLE_FILE_PUBLIC);
01138 $galley = &new ArticleGalley();
01139 $galley->setArticleId($articleId);
01140 $galley->setFileId($fileId);
01141 $galley->setLocale(Locale::getLocale());
01142 $galley->setLabel('PostScript');
01143 $galley->setSequence(3);
01144 $galleyDao->insertGalley($galley);
01145 }
01146
01147
01148 if ($row['nEditorUserID']) {
01149
01150 $editAssignment = &new EditAssignment();
01151 $editAssignment->setArticleId($articleId);
01152 $editAssignment->setEditorId($this->userMap[$row['nEditorUserID']]);
01153 $editAssignment->setCanEdit(1);
01154 $editAssignment->setCanReview(1);
01155 $editAssignment->setDateNotified($row['dtDateEditorNotified']);
01156 $editAssignment->setDateUnderway($row['dtDateEditorNotified']);
01157 $editAssignmentDao->insertEditAssignment($editAssignment);
01158 }
01159
01160
01161 $copyAssignment = &new CopyeditorSubmission();
01162 $copyAssignment->setArticleId($articleId);
01163 $copyResult = &$this->importDao->retrieve('SELECT tblcopyedit.*, nUserID FROM tblcopyedit, tblarticlesassigned, tblusers WHERE tblcopyedit.fkArticleID = tblarticlesassigned.fkArticleID AND tblusers.fkCopyEdID = tblarticlesassigned.fkCopyEdID AND bReplaced = 0 AND bDeclined = 0 AND tblcopyedit.fkArticleID = ?', $row['nArticleID']);
01164 if ($copyResult->RecordCount() != 0) {
01165 $copyRow = &$copyResult->fields;
01166
01167 if ($copyRow['fkFileCopyEdID']) {
01168 $fileId = $this->addArticleFile($articleId, $copyRow['fkFileCopyEdID'], ARTICLE_FILE_COPYEDIT);
01169 $article->setCopyeditFileId($fileId);
01170 }
01171
01172 $copyAssignment->setCopyeditorId($this->userMap[$copyRow['nUserID']]);
01173 $copyAssignment->setDateNotified($copyRow['dtDateNotified_CEd']);
01174 $copyAssignment->setDateUnderway($copyRow['dtDateNotified_CEd']);
01175 $copyAssignment->setDateCompleted($copyRow['dtDateCompleted_CEd']);
01176 $copyAssignment->setDateAcknowledged($copyRow['dtDateAcknowledged_CEd']);
01177 $copyAssignment->setDateAuthorNotified($copyRow['dtDateNotified_Author']);
01178 $copyAssignment->setDateAuthorUnderway($copyRow['dtDateNotified_Author']);
01179 $copyAssignment->setDateAuthorCompleted($copyRow['dtDateCompleted_Author']);
01180 $copyAssignment->setDateAuthorAcknowledged($copyRow['dtDateAcknowledged_Author']);
01181 $copyAssignment->setDateFinalNotified($copyRow['dtDateNotified_Final']);
01182 $copyAssignment->setDateFinalUnderway($copyRow['dtDateNotified_Final']);
01183 $copyAssignment->setDateFinalCompleted($copyRow['dtDateCompleted_Final']);
01184 $copyAssignment->setDateFinalAcknowledged($copyRow['dtDateAcknowledged_Final']);
01185 $copyAssignment->setInitialRevision(1);
01186 $copyAssignment->setEditorAuthorRevision(1);
01187 $copyAssignment->setFinalRevision(1);
01188 } else {
01189 $copyAssignment->setCopyeditorId(0);
01190 }
01191 $copyResult->Close();
01192 $copyAssignmentDao->insertCopyeditorSubmission($copyAssignment);
01193
01194 $layoutAssignment = &new LayoutAssignment();
01195 $layoutAssignment->setArticleId($articleId);
01196
01197
01198 $proofAssignment = &new ProofAssignment();
01199 $proofAssignment->setArticleId($articleId);
01200 $proofResult = &$this->importDao->retrieve('SELECT tblproofread.*, nUserID, dtDateSchedule FROM tblproofread, tblarticlesassigned, tblusers, tblarticles WHERE tblproofread.fkArticleID = tblarticles.nArticleID AND tblproofread.fkArticleID = tblarticlesassigned.fkArticleID AND tblusers.fkProofID = tblarticlesassigned.fkProofID AND bReplaced = 0 AND bDeclined = 0 AND tblproofread.fkArticleID = ?', $row['nArticleID']);
01201 if ($proofResult->RecordCount() != 0) {
01202 $proofRow = &$proofResult->fields;
01203
01204 if ($proofRow['fkFileProofID']) {
01205
01206 $fileId = $this->addArticleFile($articleId, $proofRow['fkFileProofID'], ARTICLE_FILE_LAYOUT);
01207 $layoutAssignment->setLayoutFileId($fileId);
01208 }
01209
01210 $proofAssignment->setProofreaderId($this->userMap[$proofRow['nUserID']]);
01211
01212
01213 $proofAssignment->setDateAuthorNotified($proofRow['dtDateNotified_Author']);
01214 $proofAssignment->setDateAuthorUnderway($proofRow['dtDateNotified_Author']);
01215 $proofAssignment->setDateAuthorCompleted($proofRow['dtDateCompleted_Author']);
01216 $proofAssignment->setDateAuthorAcknowledged($proofRow['dtDateAcknowledged_Author']);
01217 $proofAssignment->setDateProofreaderNotified($proofRow['dtDateNotified_Proof']);
01218 $proofAssignment->setDateProofreaderUnderway($proofRow['dtDateNotified_Proof']);
01219 $proofAssignment->setDateProofreaderCompleted($proofRow['dtDateCompleted_Proof']);
01220 $proofAssignment->setDateProofreaderAcknowledged($proofRow['dtDateAcknowledged_Proof']);
01221 $proofAssignment->setDateLayoutEditorNotified(null);
01222 $proofAssignment->setDateLayoutEditorUnderway(null);
01223 $proofAssignment->setDateLayoutEditorCompleted(null);
01224 $proofAssignment->setDateLayoutEditorAcknowledged(null);
01225 } else {
01226 $proofAssignment->setProofreaderId(0);
01227 }
01228 $proofResult->Close();
01229 $proofAssignmentDao->insertProofAssignment($proofAssignment);
01230
01231
01232 $layoutAssignment->setEditorId($this->journalLayoutUserId);
01233 $layoutAssignment->setDateNotified($row['dtDateRequestGalleys']);
01234 $layoutAssignment->setDateUnderway($row['dtDateRequestGalleys']);
01235 $layoutAssignment->setDateCompleted($row['dtDateGalleysCompleted']);
01236 $layoutAssignment->setDateAcknowledged($row['dtDateGalleysCompleted']);
01237 $layoutAssignmentDao->insertLayoutAssignment($layoutAssignment);
01238
01239 $reviewResult = &$this->importDao->retrieve('SELECT tblreviews.*, tblarticlesassigned.*, nUserID FROM tblreviews, tblarticlesassigned, tblusers, tblarticles WHERE tblreviews.fkArticleID = tblarticles.nArticleID AND tblreviews.fkArticleID = tblarticlesassigned.fkArticleID AND tblusers.fkReviewerID = tblarticlesassigned.fkReviewerID AND tblreviews.fkReviewerID = tblarticlesassigned.fkReviewerID AND tblarticlesassigned.nOrder IS NOT NULL AND tblreviews.fkArticleID = ? ORDER BY nOrder', $row['nArticleID']);
01240 while (!$reviewResult->EOF) {
01241 $reviewRow = &$reviewResult->fields;
01242 $reviewerOrder = $reviewRow['nOrder'];
01243
01244 $reviewAssignment = &new ReviewAssignment();
01245
01246 if ($reviewRow['fkFileRevCopyID']) {
01247 $fileId = $this->addArticleFile($articleId, $reviewRow['fkFileRevCopyID'], ARTICLE_FILE_REVIEW);
01248 $reviewAssignment->setReviewFileId($fileId);
01249 }
01250
01251 $reviewAssignment->setArticleId($articleId);
01252 $reviewAssignment->setReviewerId($this->userMap[$reviewRow['nUserID']]);
01253 $reviewAssignment->setRecommendation($reviewRecommendations[(int)$reviewRow['nRecommendation']]);
01254 $reviewAssignment->setDateAssigned($reviewRow['dtDateAssigned']);
01255 $reviewAssignment->setDateNotified($reviewRow['dtDateNotified']);
01256 $reviewAssignment->setDateConfirmed($reviewRow['dtDateConfirmedDeclined']);
01257 $reviewAssignment->setDateCompleted($reviewRow['dtDateReviewed']);
01258 $reviewAssignment->setDateAcknowledged($reviewRow['dtDateAcknowledged']);
01259 $reviewAssignment->setDateDue($reviewRow['dtDateRequestedBy']);
01260 $reviewAssignment->setLastModified(isset($reviewRow['dtDateReviewed']) ? $reviewRow['dtDateReviewed'] : (isset($reviewRow['dtDateConfirmedDeclined']) ? $reviewRow['dtDateConfirmedDeclined'] : $reviewRow['dtDateAssigned']));
01261 $reviewAssignment->setDeclined($reviewRow['bDeclined']);
01262 $reviewAssignment->setReplaced($reviewRow['bReplaced']);
01263 $reviewAssignment->setCancelled($reviewRow['bReplaced']);
01264 $reviewAssignment->setQuality(null);
01265 $reviewAssignment->setDateRated(null);
01266 $reviewAssignment->setDateReminded($reviewRow['dtDateReminded']);
01267 $reviewAssignment->setReminderWasAutomatic(0);
01268 $reviewAssignment->setRound(1);
01269
01270 $reviewAssignmentDao->insertReviewAssignment($reviewAssignment);
01271
01272 if (!$reviewRow['bReplaced']) {
01273 $articleUsers[$articleId]['reviewerId'][$reviewerOrder] = $reviewAssignment->getReviewerId();
01274 $articleUsers[$articleId]['reviewId'][$reviewerOrder] = $reviewAssignment->getReviewId();
01275 }
01276
01277 $reviewResult->MoveNext();
01278 }
01279 $reviewResult->Close();
01280 }
01281
01282
01283 $articleDao->updateArticle($article);
01284
01285 $result->MoveNext();
01286 }
01287 $result->Close();
01288
01289
01290
01291 $suppFileDao = &DAORegistry::getDAO('SuppFileDAO');
01292
01293 $result = &$this->importDao->retrieve('SELECT * FROM tblsupplementaryfiles ORDER BY nSupFileID');
01294 while (!$result->EOF) {
01295 $row = &$result->fields;
01296
01297 $fileId = $this->addArticleFile($this->articleMap[$row['fkArticleID']], $row['fkFileID'], ARTICLE_FILE_SUPP);
01298
01299 $suppFile = &new SuppFile();
01300 $suppFile->setFileId($fileId);
01301 $suppFile->setArticleId($this->articleMap[$row['fkArticleID']]);
01302 $suppFile->setTitle(Core::cleanVar($row['chTitle']), Locale::getLocale());
01303 $suppFile->setCreator(Core::cleanVar($row['chCreator']), Locale::getLocale());
01304 $suppFile->setSubject(Core::cleanVar($row['chSubject']), Locale::getLocale());
01305 $suppFile->setType(Core::cleanVar($row['chType']), Locale::getLocale());
01306 $suppFile->setTypeOther(Core::cleanVar($row['chTypeOther']), Locale::getLocale());
01307 $suppFile->setDescription(Core::cleanVar($row['chDescription']), Locale::getLocale());
01308 $suppFile->setPublisher(Core::cleanVar($row['chPublisher']), Locale::getLocale());
01309 $suppFile->setSponsor(Core::cleanVar($row['chSponsor']), Locale::getLocale());
01310 $suppFile->setDateCreated($row['dtDateCreated']);
01311 $suppFile->setSource(Core::cleanVar($row['chSource']), Locale::getLocale());
01312 $suppFile->setLanguage(Core::cleanVar($row['chLanguage']));
01313 $suppFile->setShowReviewers($row['bShowReviewer']);
01314 $suppFile->setDateSubmitted($row['dtDateCreated']);
01315
01316 $suppFileDao->insertSuppFile($suppFile);
01317 $result->MoveNext();
01318 }
01319 $result->Close();
01320
01321
01322
01323 $commentDao = &DAORegistry::getDAO('CommentDAO');
01324
01325 $result = &$this->importDao->retrieve('SELECT * FROM tblcomments ORDER BY nCommentID');
01326 while (!$result->EOF) {
01327 $row = &$result->fields;
01328
01329 if (!empty($row['chAffiliation'])) {
01330 $row['chAuthor'] .= ', ' . Core::cleanVar($row['chAffiliation']);
01331 }
01332
01333 $comment = &new Comment();
01334 $comment->setArticleId($this->articleMap[$row['fkArticleID']]);
01335 $comment->setPosterIP('');
01336 $comment->setPosterName(Core::cleanVar($row['chAuthor']));
01337 $comment->setPosterEmail(Core::cleanVar($row['chEmail']));
01338 $comment->setTitle(Core::cleanVar($row['chCommentTitle']));
01339 $comment->setBody(Core::cleanVar($row['chComments']));
01340 $comment->setDatePosted($row['dtDate']);
01341 $comment->setDateModified($row['dtDate']);
01342 $comment->setChildCommentCount(0);
01343
01344 $commentDao->insertComment($comment);
01345 $result->MoveNext();
01346 }
01347 $result->Close();
01348
01349
01350
01351 $articleCommentDao = &DAORegistry::getDAO('ArticleCommentDAO');
01352
01353 $commentTypes = array(
01354 'reviewer' => COMMENT_TYPE_PEER_REVIEW,
01355 'editorrev' => COMMENT_TYPE_EDITOR_DECISION,
01356 'proof' => COMMENT_TYPE_PROOFREAD
01357 );
01358
01359 $result = &$this->importDao->retrieve('SELECT * FROM tblsubmissioncomments ORDER BY nCommentID');
01360 while (!$result->EOF) {
01361 $row = &$result->fields;
01362 $assocId = $this->articleMap[$row['fkArticleID']];
01363
01364
01365 switch ($row['chFrom']) {
01366 case 'Author':
01367 $authorId = $articleUsers[$this->articleMap[$row['fkArticleID']]]['authorId'];
01368 $roleId = ROLE_ID_AUTHOR;
01369 break;
01370 case 'Proofreader':
01371 $authorId = $articleUsers[$this->articleMap[$row['fkArticleID']]]['proofId'];
01372 $roleId = ROLE_ID_PROOFREADER;
01373 break;
01374 case 'Reviewer':
01375 $authorId = @$articleUsers[$this->articleMap[$row['fkArticleID']]]['reviewerId'][$row['nOrder']];
01376 $roleId = ROLE_ID_REVIEWER;
01377 $assocId = @$articleUsers[$this->articleMap[$row['fkArticleID']]]['reviewId'][$row['nOrder']];
01378 if (!isset($assocId)) $assocId = $this->articleMap[$row['fkArticleID']];
01379 break;
01380 case 'Editor':
01381 default:
01382 $authorId = $articleUsers[$this->articleMap[$row['fkArticleID']]]['editorId'];
01383 $roleId = ROLE_ID_EDITOR;
01384
01385
01386 if ($row['chType'] == 'reviewer') {
01387 $assocId = @$articleUsers[$this->articleMap[$row['fkArticleID']]]['reviewId'][$row['nOrder']];
01388 if (!isset($assocId)) $assocId = $this->articleMap[$row['fkArticleID']];
01389 }
01390 break;
01391 }
01392
01393 if (!isset($authorId)) {
01394
01395 $authorId = $articleUsers[$this->articleMap[$row['fkArticleID']]]['editorId'];
01396 $roleId = ROLE_ID_EDITOR;
01397 }
01398
01399
01400 $curComment = str_replace("<br />", "\n", $row['chComment']);
01401
01402 $articleComment = &new ArticleComment();
01403 $articleComment->setCommentType($commentTypes[$row['chType']]);
01404 $articleComment->setRoleId($roleId);
01405 $articleComment->setArticleId($this->articleMap[$row['fkArticleID']]);
01406 $articleComment->setAssocId($assocId);
01407 $articleComment->setAuthorId($authorId);
01408 $articleComment->setCommentTitle('');
01409 $articleComment->setComments(Core::cleanVar($curComment));
01410 $articleComment->setDatePosted($row['dtDateCreated']);
01411 $articleComment->setDateModified($row['dtDateCreated']);
01412 $articleComment->setViewable(0);
01413
01414 $articleCommentDao->insertArticleComment($articleComment);
01415 $result->MoveNext();
01416 }
01417 $result->Close();
01418 }
01419
01420
01421
01422
01423
01424
01430 function rebuildSearchIndex() {
01431 if ($this->hasOption('verbose')) {
01432 printf("Rebuilding search index\n");
01433 }
01434
01435 ArticleSearchIndex::rebuildIndex();
01436 }
01437
01444 function copyJournalImage($oldName, $newName) {
01445 if (empty($this->journalInfo[$oldName])) {
01446 return null;
01447 }
01448
01449 $oldPath = $this->importPath . '/images/custom/' . Core::cleanVar($this->journalInfo[$oldName]);
01450 if (!file_exists($oldPath)) {
01451 return null;
01452 }
01453
01454 list($width, $height) = getimagesize($oldPath);
01455
01456 $fileManager = &new PublicFileManager();
01457 $extension = $fileManager->getExtension(Core::cleanVar($this->journalInfo[$oldName]));
01458
01459 $uploadName = $newName . '.' . $extension;
01460 if (!$fileManager->copyJournalFile($this->journalId, $oldPath, $uploadName)) {
01461 printf("Failed to copy file %s\n", $oldPath);
01462 return null;
01463 }
01464
01465 return array(
01466 'name' => Core::cleanVar($this->journalInfo[$oldName]),
01467 'uploadName' => $uploadName,
01468 'width' => $width,
01469 'height' => $height,
01470 'dateUploaded' => Core::getCurrentDate()
01471 );
01472 }
01473
01480 function addArticleFile($articleId, $oldFileId, $fileType) {
01481 if (!$oldFileId) {
01482 return 0;
01483 }
01484
01485 $result = &$this->importDao->retrieve('SELECT * FROM tblfiles WHERE nFileID = ?', $oldFileId);
01486
01487 if ($result->RecordCount() == 0) {
01488 $result->Close();
01489 return 0;
01490 }
01491
01492 $row = &$result->fields;
01493 $oldPath = Core::cleanVar($this->journalConfigInfo['chFilePath']) . Core::cleanVar($row['chFilePath']);
01494
01495 $fileManager = &new ArticleFileManager($articleId);
01496 $articleFileDao = &DAORegistry::getDAO('ArticleFileDAO');
01497
01498 $articleOldFileName = !empty($row['chOldFileName']) ? $row['chOldFileName'] : $row['chFileName'];
01499
01500 $articleFile = &new ArticleFile();
01501 $articleFile->setArticleId($articleId);
01502 $articleFile->setFileName('temp');
01503 $articleFile->setOriginalFileName(Core::cleanVar($articleOldFileName));
01504 $articleFile->setFileType(Core::cleanVar($row['chFileType']));
01505 $articleFile->setFileSize(filesize($oldPath));
01506 $articleFile->setType($fileManager->typeToPath($fileType));
01507 $articleFile->setStatus('');
01508 $articleFile->setDateUploaded($row['dtDateUploaded']);
01509 $articleFile->setDateModified($row['dtDateUploaded']);
01510 $articleFile->setRound(1);
01511 $articleFile->setRevision(1);
01512
01513 $fileId = $articleFileDao->insertArticleFile($articleFile);
01514
01515 $newFileName = $fileManager->generateFilename($articleFile, $fileType, $articleOldFileName);
01516 if (!$fileManager->copyFile($oldPath, $fileManager->filesDir . $fileManager->typeToPath($fileType) . '/' . $newFileName)) {
01517 $articleFileDao->deleteArticleFileById($articleFile->getFileId());
01518 printf("Failed to copy file %s\n", $oldPath);
01519 $result->Close();
01520 return 0;
01521 }
01522
01523 $articleFileDao->updateArticleFile($articleFile);
01524 $this->fileMap[$oldFileId] = $fileId;
01525
01526 $result->Close();
01527
01528 return $fileId;
01529 }
01530
01536 function copyHTMLGalleyImages($galley, $prefix) {
01537 $dir = opendir($this->importPath . '/images/articleimages');
01538 if (!$dir) {
01539 printf("Failed to open directory %s\n", $this->importPath . '/images/articleimages');
01540 return;
01541 }
01542
01543 while(($file = readdir($dir)) !== false) {
01544 if (!strstr($file, $prefix . '-')) {
01545 continue;
01546 }
01547
01548 if (!isset($fileManager)) {
01549 $fileManager = &new ArticleFileManager($galley->getArticleId());
01550 $galleyDao = &DAORegistry::getDAO('ArticleGalleyDAO');
01551 $articleFileDao = &DAORegistry::getDAO('ArticleFileDAO');
01552 }
01553
01554 $fileType = ARTICLE_FILE_PUBLIC;
01555 $oldPath = $this->importPath . '/images/articleimages/' . $file;
01556
01557 $mimeType = String::mime_content_type($oldPath);
01558 if (empty($mimeType)) {
01559 $extension = $fileManager->getExtension($file);
01560 if ($extension == 'jpg') {
01561 $mimeType = 'image/jpeg';
01562 } else {
01563 $mimeType = 'image/' . $extension;
01564 }
01565 }
01566
01567 $articleFile = &new ArticleFile();
01568 $articleFile->setArticleId($galley->getArticleId());
01569 $articleFile->setFileName('temp');
01570 $articleFile->setOriginalFileName($file);
01571 $articleFile->setFileType($mimeType);
01572 $articleFile->setFileSize(filesize($oldPath));
01573 $articleFile->setType($fileManager->typeToPath($fileType));
01574 $articleFile->setStatus('');
01575 $articleFile->setDateUploaded(date('Y-m-d', filemtime($oldPath)));
01576 $articleFile->setDateModified($articleFile->getDateUploaded());
01577 $articleFile->setRound(1);
01578 $articleFile->setRevision(1);
01579
01580 $fileId = $articleFileDao->insertArticleFile($articleFile);
01581
01582 $newFileName = $fileManager->generateFilename($articleFile, $fileType, $file);
01583 if (!$fileManager->copyFile($oldPath, $fileManager->filesDir . $fileManager->typeToPath($fileType) . '/' . $newFileName)) {
01584 $articleFileDao->deleteArticleFileById($articleFile->getFileId());
01585 printf("Failed to copy file %s\n", $oldPath);
01586
01587 } else {
01588 $articleFileDao->updateArticleFile($articleFile);
01589 $galleyDao->insertGalleyImage($galley->getGalleyId(), $fileId);
01590 }
01591 }
01592
01593 closedir($dir);
01594 }
01595
01599 function generateRedirects() {
01600 $redirectHeader = "<?php\n\n";
01601 $redirectFooter = "?>";
01602
01603
01604 $redirectIndex = $redirectHeader;
01605 $redirectIndex .= "// Redirect OJS 1 index page to OJS 2 index page\n";
01606 $redirectIndex .= "header('Location: " . $this->indexUrl . "/" . $this->journalPath . "/index');" . "\n\n";
01607 $redirectIndex .= $redirectFooter;
01608
01609
01610 $redirectArchive = $redirectHeader;
01611 $redirectArchive .= "// Redirect OJS 1 archive page to OJS 2 archive page\n";
01612 $redirectArchive .= "header('Location: " . $this->indexUrl . "/" . $this->journalPath . "/issue/archive');" . "\n\n";
01613 $redirectArchive .= $redirectFooter;
01614
01615
01616 $redirectIssue = $redirectHeader;
01617 $redirectIssue .= "// Redirect OJS 1 issue TOC to OJS 2 issue TOC\n";
01618 $redirectIssue .= '$issueId = (PHP_VERSION <= \'4.1.0\') ? ((isset($HTTP_GET_VARS)) ? (int)$HTTP_GET_VARS[\'id\'] : null) : (isset($_GET) ? (int)$_GET[\'id\'] : null);' . "\n\n";
01619 $redirectIssue .= '$issueMap = array(' . "\n";
01620 reset($this->issueMap);
01621 $numIssues = sizeof($this->issueMap);
01622 for ($i=0; $i<$numIssues; $i++) {
01623 list($key, $item) = each($this->issueMap);
01624 $redirectIssue .= "\t$key => $item";
01625 if (($numIssues>1) && ($i != $numIssues-1)) {
01626 $redirectIssue .= ",\n";
01627 }
01628 }
01629 $redirectIssue .= "\n);\n\n";
01630 $redirectIssue .= 'if (array_key_exists($issueId, $issueMap)) {' . "\n";
01631 $redirectIssue .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "/issue/view/" . '$issueMap[$issueId]' . "\");" . "\n";
01632 $redirectIssue .= "} else {\n";
01633 $redirectIssue .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "\");" . "\n";
01634 $redirectIssue .= "}\n\n";
01635 $redirectIssue .= $redirectFooter;
01636
01637
01638 $redirectArticle = $redirectHeader;
01639 $redirectArticle .= "// Redirect OJS 1 articles to OJS 2 articles\n";
01640 $redirectArticle .= '$articleId = (PHP_VERSION <= \'4.1.0\') ? ((isset($HTTP_GET_VARS)) ? (int)$HTTP_GET_VARS[\'id\'] : null) : (isset($_GET) ? (int)$_GET[\'id\'] : null);' . "\n\n";
01641 $redirectArticle .= '$articleMap = array(' . "\n";
01642 reset($this->articleMap);
01643 $numArticles = sizeof($this->articleMap);
01644 for ($i=0; $i<$numArticles; $i++) {
01645 list($key, $item) = each($this->articleMap);
01646 $redirectArticle .= "\t$key => $item";
01647 if (($numArticles>1) && ($i != $numArticles-1)) {
01648 $redirectArticle .= ",\n";
01649 }
01650 }
01651 $redirectArticle .= "\n);\n\n";
01652 $redirectArticle .= 'if (array_key_exists($articleId, $articleMap)) {' . "\n";
01653 $redirectArticle .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "/article/view/" . '$articleMap[$articleId]' . "\");" . "\n";
01654 $redirectArticle .= "} else {\n";
01655 $redirectArticle .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "\");" . "\n";
01656 $redirectArticle .= "}\n\n";
01657 $redirectArticle .= $redirectFooter;
01658
01659
01660 $redirectArticleFile = $redirectHeader;
01661 $redirectArticleFile .= "// Redirect OJS 1 article files to OJS 2 articles\n";
01662 $redirectArticleFile .= '$articleId = (PHP_VERSION <= \'4.1.0\') ? ((isset($HTTP_GET_VARS)) ? (int)$HTTP_GET_VARS[\'article\'] : null) : (isset($_GET) ? (int)$_GET[\'article\'] : null);' . "\n\n";
01663 $redirectArticleFile .= '$articleMap = array(' . "\n";
01664 reset($this->articleMap);
01665 $numArticles = sizeof($this->articleMap);
01666 for ($i=0; $i<$numArticles; $i++) {
01667 list($key, $item) = each($this->articleMap);
01668 $redirectArticleFile .= "\t$key => $item";
01669 if (($numArticles>1) && ($i != $numArticles-1)) {
01670 $redirectArticleFile .= ",\n";
01671 }
01672 }
01673 $redirectArticleFile .= "\n);\n\n";
01674 $redirectArticleFile .= 'if (array_key_exists($articleId, $articleMap)) {' . "\n";
01675 $redirectArticleFile .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "/article/view/" . '$articleMap[$articleId]' . "\");" . "\n";
01676 $redirectArticleFile .= "} else {\n";
01677 $redirectArticleFile .= "\theader(\"Location: " . $this->indexUrl . "/" . $this->journalPath . "\");" . "\n";
01678 $redirectArticleFile .= "}\n\n";
01679 $redirectArticleFile .= $redirectFooter;
01680
01681 $this->redirects[] = array('index.php', 'admin.journals.importOJS1.redirect.ojs1root', "$redirectIndex");
01682 $this->redirects[] = array('archive.php', 'admin.journals.importOJS1.redirect.ojs1orojs2root', "$redirectArchive");
01683 $this->redirects[] = array('viewissue.php', 'admin.journals.importOJS1.redirect.ojs1orojs2root', "$redirectIssue");
01684 $this->redirects[] = array('viewarticle.php', 'admin.journals.importOJS1.redirect.ojs1orojs2root', "$redirectArticle");
01685 $this->redirects[] = array('include/getdoc.php', 'admin.journals.importOJS1.redirect.ojs1orojs2root', "$redirectArticleFile");
01686 }
01687
01691 function getConflicts() {
01692 return $this->conflicts;
01693 }
01694
01698 function getRedirects() {
01699 return $this->redirects;
01700 }
01701 }
01702
01703 ?>