Example #1
0
 function restoreVersions()
 {
     $this->validate();
     $journal =& Request::getJournal();
     $rtAdmin = new JournalRTAdmin($journal->getId());
     $rtAdmin->restoreVersions();
     // If the journal RT was configured, change its state to
     // "disabled" because the RT version it was configured for
     // has now been deleted.
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $journalRt = $rtDao->getJournalRTByJournal($journal);
     if ($journalRt) {
         $journalRt->setVersion(null);
         $rtDao->updateJournalRT($journalRt);
     }
     Request::redirect(null, null, 'versions');
 }
 /**
  * Save journal settings.
  */
 function execute()
 {
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     if (isset($this->journalId)) {
         $journal =& $journalDao->getJournal($this->journalId);
     }
     if (!isset($journal)) {
         $journal = new Journal();
     }
     $journal->setPath($this->getData('journalPath'));
     $journal->setEnabled($this->getData('enabled'));
     if ($journal->getId() != null) {
         $isNewJournal = false;
         $journalDao->updateJournal($journal);
         $section = null;
     } else {
         $isNewJournal = true;
         $site =& Request::getSite();
         // Give it a default primary locale
         $journal->setPrimaryLocale($site->getPrimaryLocale());
         $journalId = $journalDao->insertJournal($journal);
         $journalDao->resequenceJournals();
         // Make the site administrator the journal manager of newly created journals
         $sessionManager =& SessionManager::getManager();
         $userSession =& $sessionManager->getUserSession();
         if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($journalId)) {
             $role = new Role();
             $role->setJournalId($journalId);
             $role->setUserId($userSession->getUserId());
             $role->setRoleId(ROLE_ID_JOURNAL_MANAGER);
             $roleDao =& DAORegistry::getDAO('RoleDAO');
             $roleDao->insertRole($role);
         }
         // Make the file directories for the journal
         import('lib.pkp.classes.file.FileManager');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId);
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues');
         FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId);
         // Install default journal settings
         $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
         $titles = $this->getData('title');
         AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_DEFAULT, LOCALE_COMPONENT_APPLICATION_COMMON));
         $journalSettingsDao->installSettings($journalId, 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $this->getData('journalPath'), 'primaryLocale' => $site->getPrimaryLocale(), 'journalName' => $titles[$site->getPrimaryLocale()]));
         // Install the default RT versions.
         import('classes.rt.ojs.JournalRTAdmin');
         $journalRtAdmin = new JournalRTAdmin($journalId);
         $journalRtAdmin->restoreVersions(false);
         // Create a default "Articles" section
         $sectionDao =& DAORegistry::getDAO('SectionDAO');
         $section = new Section();
         $section->setJournalId($journal->getId());
         $section->setTitle(__('section.default.title'), $journal->getPrimaryLocale());
         $section->setAbbrev(__('section.default.abbrev'), $journal->getPrimaryLocale());
         $section->setMetaIndexed(true);
         $section->setMetaReviewed(true);
         $section->setPolicy(__('section.default.policy'), $journal->getPrimaryLocale());
         $section->setEditorRestricted(false);
         $section->setHideTitle(false);
         $sectionDao->insertSection($section);
     }
     $journal->updateSetting('title', $this->getData('title'), 'string', true);
     $journal->updateSetting('description', $this->getData('description'), 'string', true);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('JournalSiteSettingsForm::execute', array(&$this, &$journal, &$section, &$isNewJournal));
 }
 function createJournal()
 {
     $journalConfigXML = $this->getCurrentElementAsDom();
     $journalDao =& DAORegistry::getDAO("JournalDAO");
     $journal = new Journal();
     $journal->setPath((string) $journalConfigXML->path);
     $journal->setEnabled((int) $journalConfigXML->enabled);
     $journal->setPrimaryLocale((string) $journalConfigXML->primaryLocale);
     $this->generateJournalPath($journal);
     $journalId = $journalDao->insertJournal($journal);
     $journalDao->resequenceJournals();
     // Make the file directories for the journal
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     if (!file_exists(Config::getVar('files', 'files_dir') . '/journals/' . $journalId)) {
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId);
     }
     if (!file_exists(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles')) {
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles');
     }
     if (!file_exists(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues')) {
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues');
     }
     if (!file_exists(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId)) {
         $fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId);
     }
     import('classes.rt.ojs.JournalRTAdmin');
     $journalRtAdmin = new JournalRTAdmin($journalId);
     $journalRtAdmin->restoreVersions(false);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('JournalSiteSettingsForm::execute', array(&$this, &$journal, &$section, &$isNewJournal));
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     $this->restoreDataObjectSettings($journalSettingsDao, $journalConfigXML->settings, "journal_settings", "journal_id", $journal->getId());
     $this->journal = $journal;
 }
 /**
  * Save journal settings.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     $journalDao = DAORegistry::getDAO('JournalDAO');
     if (isset($this->contextId)) {
         $journal = $journalDao->getById($this->contextId);
     }
     if (!isset($journal)) {
         $journal = $journalDao->newDataObject();
     }
     // Check if the journal path has changed.
     $pathChanged = false;
     $journalPath = $journal->getPath();
     if ($journalPath != $this->getData('path')) {
         $pathChanged = true;
     }
     $journal->setPath($this->getData('path'));
     $journal->setEnabled($this->getData('enabled'));
     if ($journal->getId() != null) {
         $isNewJournal = false;
         $journalDao->updateObject($journal);
         $section = null;
     } else {
         $isNewJournal = true;
         $site = $request->getSite();
         // Give it a default primary locale
         $journal->setPrimaryLocale($site->getPrimaryLocale());
         $journalId = $journalDao->insertObject($journal);
         $journalDao->resequence();
         $installedLocales = $site->getInstalledLocales();
         // Install default genres
         $genreDao = DAORegistry::getDAO('GenreDAO');
         $genreDao->installDefaults($journalId, $installedLocales);
         /* @var $genreDao GenreDAO */
         // load the default user groups and stage assignments.
         $this->_loadDefaultUserGroups($journalId);
         // Put this user in the Manager group.
         $this->_assignManagerGroup($journalId);
         // Make the file directories for the journal
         import('lib.pkp.classes.file.FileManager');
         $fileManager = new FileManager();
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId);
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles');
         $fileManager->mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues');
         $fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId);
         // Install default journal settings
         $journalSettingsDao = DAORegistry::getDAO('JournalSettingsDAO');
         $names = $this->getData('name');
         AppLocale::requireComponents(LOCALE_COMPONENT_APP_DEFAULT, LOCALE_COMPONENT_APP_COMMON);
         $journalSettingsDao->installSettings($journalId, 'registry/journalSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'journalPath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'journalName' => $names[$site->getPrimaryLocale()]));
         // Install the default RT versions.
         import('classes.rt.ojs.JournalRTAdmin');
         $journalRtAdmin = new JournalRTAdmin($journalId);
         $journalRtAdmin->restoreVersions(false);
         // Create a default "Articles" section
         $sectionDao = DAORegistry::getDAO('SectionDAO');
         $section = new Section();
         $section->setJournalId($journal->getId());
         $section->setTitle(__('section.default.title'), $journal->getPrimaryLocale());
         $section->setAbbrev(__('section.default.abbrev'), $journal->getPrimaryLocale());
         $section->setMetaIndexed(true);
         $section->setMetaReviewed(true);
         $section->setPolicy(__('section.default.policy'), $journal->getPrimaryLocale());
         $section->setEditorRestricted(false);
         $section->setHideTitle(false);
         $sectionDao->insertObject($section);
     }
     $journal->updateSetting('supportedLocales', $site->getSupportedLocales());
     $journal->updateSetting('name', $this->getData('name'), 'string', true);
     $journal->updateSetting('description', $this->getData('description'), 'string', true);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('JournalSiteSettingsForm::execute', array($this, $journal, $section, $isNewJournal));
     if ($isNewJournal || $pathChanged) {
         return $journal->getPath();
     }
 }