Exemplo n.º 1
0
 function handleTrackNode(&$conference, &$schedConf, &$trackNode, &$errors, &$user, $isCommandLine, &$dependentItems, $trackIndex = null)
 {
     $trackDao =& DAORegistry::getDAO('TrackDAO');
     $errors = array();
     $schedConfSupportedLocales = array_keys($schedConf->getSupportedLocaleNames());
     // => sched conf locales must be set up before
     $schedConfPrimaryLocale = $schedConf->getPrimaryLocale();
     // The following page or two is responsible for locating an
     // existing track based on title and/or abbrev, or, if none
     // can be found, creating a new one.
     $titles = array();
     for ($index = 0; $node = $trackNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $schedConfPrimaryLocale;
         } elseif (!in_array($locale, $schedConfSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.trackTitleLocaleUnsupported', array('trackTitle' => $node->getValue(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $titles[$locale] = $node->getValue();
     }
     if (empty($titles)) {
         $errors[] = array('plugins.importexport.native.import.error.trackTitleMissing');
         return false;
     }
     $abbrevs = array();
     for ($index = 0; $node = $trackNode->getChildByName('abbrev', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $schedConfPrimaryLocale;
         } elseif (!in_array($locale, $schedConfSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.trackAbbrevLocaleUnsupported', array('trackAbbrev' => $node->getValue(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $abbrevs[$locale] = $node->getValue();
     }
     $identifyTypes = array();
     for ($index = 0; $node = $trackNode->getChildByName('identify_type', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $schedConfPrimaryLocale;
         } elseif (!in_array($locale, $schedConfSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.trackIdentifyTypeLocaleUnsupported', array('trackIdentifyType' => $node->getValue(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $identifyTypes[$locale] = $node->getValue();
     }
     $policies = array();
     for ($index = 0; $node = $trackNode->getChildByName('policy', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $schedConfPrimaryLocale;
         } elseif (!in_array($locale, $schedConfSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.trackPolicyLocaleUnsupported', array('trackPolicy' => $node->getValue(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $policies[$locale] = $node->getValue();
     }
     // $title and, optionally, $abbrev contain information that can
     // be used to locate an existing track. Otherwise, we'll
     // create a new one. If $title and $abbrev each match an
     // existing track, but not the same track, throw an error.
     $track = null;
     $foundTrackId = $foundTrackTitle = null;
     $index = 0;
     foreach ($titles as $locale => $title) {
         $track = $trackDao->getTrackByTitle($title, $schedConf->getId());
         if ($track) {
             $trackId = $track->getId();
             if ($foundTrackId) {
                 if ($foundTrackId != $trackId) {
                     // Mismatching tracks found. Throw an error.
                     $errors[] = array('plugins.importexport.native.import.error.trackTitleMismatch', array('track1Title' => $title, 'track2Title' => $foundTrackTitle));
                     return false;
                 }
             } else {
                 if ($index > 0) {
                     // the current title matches, but the prev titles didn't => error
                     $errors[] = array('plugins.importexport.native.import.error.trackTitleMatch', array('trackTitle' => $title));
                     return false;
                 }
             }
             $foundTrackId = $trackId;
             $foundTrackTitle = $title;
         } else {
             if ($foundTrackId) {
                 // a prev title matched, but the current doesn't => error
                 $errors[] = array('plugins.importexport.native.import.error.trackTitleMatch', array('trackTitle' => $foundTrackTitle));
                 return false;
             }
         }
         $index++;
     }
     // check abbrevs:
     $abbrevTrack = null;
     $foundTrackId = $foundTrackAbbrev = null;
     $index = 0;
     foreach ($abbrevs as $locale => $abbrev) {
         $abbrevTrack = $trackDao->getTrackByAbbrev($abbrev, $schedConf->getId());
         if ($abbrevTrack) {
             $trackId = $abbrevTrack->getTrackId();
             if ($foundTrackId) {
                 if ($foundTrackId != $trackId) {
                     // Mismatching tracks found. Throw an error.
                     $errors[] = array('plugins.importexport.native.import.error.trackAbbrevMismatch', array('track1Abbrev' => $abbrev, 'track2Abbrev' => $foundTrackAbbrev));
                     return false;
                 }
             } else {
                 if ($index > 0) {
                     // the current abbrev matches, but the prev abbrevs didn't => error
                     $errors[] = array('plugins.importexport.native.import.error.trackAbbrevMatch', array('trackAbbrev' => $trackAbbrev));
                     return false;
                 }
             }
             $foundTrackId = $trackId;
             $foundTrackAbbrev = $abbrev;
         } else {
             if ($foundTrackId) {
                 // a prev abbrev matched, but the current doesn't => error
                 $errors[] = array('plugins.importexport.native.import.error.trackAbbrevMatch', array('trackAbbrev' => $foundTrackAbbrev));
                 return false;
             }
         }
         $index++;
     }
     if (!$track && !$abbrevTrack) {
         // The track was not matched. Create one.
         // Note that because tracks are global-ish,
         // we're not maintaining a list of created
         // tracks to delete in case the import fails.
         unset($track);
         $track = new Track();
         $track->setTitle($titles, null);
         $track->setAbbrev($abbrevs, null);
         $track->setIdentifyType($identifyTypes, null);
         $track->setPolicy($policies, null);
         $track->setSchedConfId($schedConf->getId());
         $track->setSequence(REALLY_BIG_NUMBER);
         $track->setMetaIndexed(1);
         $track->setEditorRestricted(1);
         $track->setTrackId($trackDao->insertTrack($track));
         $trackDao->resequenceTracks($schedConf > getSchedConfId());
     }
     if (!$track && $abbrevTrack) {
         unset($track);
         $track =& $abbrevTrack;
     }
     // $track *must* now contain a valid track, whether it was
     // found amongst existing tracks or created anew.
     $hasErrors = false;
     for ($index = 0; $node = $trackNode->getChildByName('paper', $index); $index++) {
         if (!NativeImportDom::handlePaperNode($conference, $schedConf, $node, $track, $paper, $publishedPaper, $paperErrors, $user, $isCommandLine, $dependentItems)) {
             $errors = array_merge($errors, $paperErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * 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);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * 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));
 }
Exemplo n.º 4
0
 /**
  * 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));
 }