setJournalId() public method

Set ID of journal.
public setJournalId ( $journalId )
$journalId int
 /**
  * Save section.
  */
 function execute()
 {
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     // We get the section DAO early on so that
     // the section class will be imported.
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $section =& $this->section;
     if (!is_a($section, 'Section')) {
         $section = new Section();
         $section->setJournalId($journalId);
         $section->setSequence(REALLY_BIG_NUMBER);
     }
     $section->setTitle($this->getData('title'), null);
     // Localized
     $section->setAbbrev($this->getData('abbrev'), null);
     // Localized
     $reviewFormId = $this->getData('reviewFormId');
     if ($reviewFormId === '') {
         $reviewFormId = null;
     }
     $section->setReviewFormId($reviewFormId);
     $section->setMetaIndexed($this->getData('metaIndexed') ? 0 : 1);
     // #2066: Inverted
     $section->setMetaReviewed($this->getData('metaReviewed') ? 0 : 1);
     // #2066: Inverted
     $section->setAbstractsNotRequired($this->getData('abstractsNotRequired') ? 1 : 0);
     $section->setIdentifyType($this->getData('identifyType'), null);
     // Localized
     $section->setEditorRestricted($this->getData('editorRestriction') ? 1 : 0);
     $section->setHideTitle($this->getData('hideTitle') ? 1 : 0);
     $section->setHideAuthor($this->getData('hideAuthor') ? 1 : 0);
     $section->setHideAbout($this->getData('hideAbout') ? 1 : 0);
     $section->setDisableComments($this->getData('disableComments') ? 1 : 0);
     $section->setPolicy($this->getData('policy'), null);
     // Localized
     $section->setAbstractWordCount($this->getData('wordCount'));
     $section =& parent::execute($section);
     if ($section->getId() != null) {
         $sectionDao->updateSection($section);
         $sectionId = $section->getId();
     } else {
         $sectionId = $sectionDao->insertSection($section);
         $sectionDao->resequenceSections($journalId);
     }
     // Save assigned editors
     $assignedEditorIds = Request::getUserVar('assignedEditorIds');
     if (empty($assignedEditorIds)) {
         $assignedEditorIds = array();
     } elseif (!is_array($assignedEditorIds)) {
         $assignedEditorIds = array($assignedEditorIds);
     }
     $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
     $sectionEditorsDao->deleteEditorsBySectionId($sectionId, $journalId);
     foreach ($this->sectionEditors as $key => $junk) {
         $sectionEditor =& $this->sectionEditors[$key];
         $userId = $sectionEditor->getId();
         // We don't have to worry about omit- and include-
         // section editors because this function is only called
         // when the Save button is pressed and those are only
         // used in other cases.
         if (in_array($userId, $assignedEditorIds)) {
             $sectionEditorsDao->insertEditor($journalId, $sectionId, $userId, Request::getUserVar('canReview' . $userId), Request::getUserVar('canEdit' . $userId));
         }
         unset($sectionEditor);
     }
 }
 function handleSectionNode(&$journal, &$sectionNode, &$issue, &$errors, &$user, $isCommandLine, &$dependentItems, $sectionIndex = null)
 {
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $errors = array();
     $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames());
     // => journal locales must be set up before
     $journalPrimaryLocale = $journal->getPrimaryLocale();
     // The following page or two is responsible for locating an
     // existing section based on title and/or abbrev, or, if none
     // can be found, creating a new one.
     $titles = array();
     for ($index = 0; $node = $sectionNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.sectionTitleLocaleUnsupported', array('sectionTitle' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $titles[$locale] = $node->getValue();
     }
     if (empty($titles)) {
         $errors[] = array('plugins.importexport.native.import.error.sectionTitleMissing', array('issueTitle' => $issue->getIssueIdentification()));
         return false;
     }
     $abbrevs = array();
     for ($index = 0; $node = $sectionNode->getChildByName('abbrev', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.sectionAbbrevLocaleUnsupported', array('sectionAbbrev' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $abbrevs[$locale] = $node->getValue();
     }
     $identifyTypes = array();
     for ($index = 0; $node = $sectionNode->getChildByName('identify_type', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.sectionIdentifyTypeLocaleUnsupported', array('sectionIdentifyType' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
             // or ignore this error?
         }
         $identifyTypes[$locale] = $node->getValue();
     }
     $policies = array();
     for ($index = 0; $node = $sectionNode->getChildByName('policy', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.sectionPolicyLocaleUnsupported', array('sectionPolicy' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), '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 section. Otherwise, we'll
     // create a new one. If $title and $abbrev each match an
     // existing section, but not the same section, throw an error.
     $section = null;
     $foundSectionId = $foundSectionTitle = null;
     $index = 0;
     foreach ($titles as $locale => $title) {
         $section = $sectionDao->getSectionByTitle($title, $journal->getId());
         if ($section) {
             $sectionId = $section->getId();
             if ($foundSectionId) {
                 if ($foundSectionId != $sectionId) {
                     // Mismatching sections found. Throw an error.
                     $errors[] = array('plugins.importexport.native.import.error.sectionTitleMismatch', array('section1Title' => $title, 'section2Title' => $foundSectionTitle, 'issueTitle' => $issue->getIssueIdentification()));
                     return false;
                 }
             } else {
                 if ($index > 0) {
                     // the current title matches, but the prev titles didn't => error
                     $errors[] = array('plugins.importexport.native.import.error.sectionTitleMatch', array('sectionTitle' => $title, 'issueTitle' => $issue->getIssueIdentification()));
                     return false;
                 }
             }
             $foundSectionId = $sectionId;
             $foundSectionTitle = $title;
         } else {
             if ($foundSectionId) {
                 // a prev title matched, but the current doesn't => error
                 $errors[] = array('plugins.importexport.native.import.error.sectionTitleMatch', array('sectionTitle' => $foundSectionTitle, 'issueTitle' => $issue->getIssueIdentification()));
                 return false;
             }
         }
         $index++;
     }
     // check abbrevs:
     $abbrevSection = null;
     $foundSectionId = $foundSectionAbbrev = null;
     $index = 0;
     foreach ($abbrevs as $locale => $abbrev) {
         $abbrevSection = $sectionDao->getSectionByAbbrev($abbrev, $journal->getId());
         if ($abbrevSection) {
             $sectionId = $abbrevSection->getSectionId();
             if ($foundSectionId) {
                 if ($foundSectionId != $sectionId) {
                     // Mismatching sections found. Throw an error.
                     $errors[] = array('plugins.importexport.native.import.error.sectionAbbrevMismatch', array('section1Abbrev' => $abbrev, 'section2Abbrev' => $foundSectionAbbrev, 'issueTitle' => $issue->getIssueIdentification()));
                     return false;
                 }
             } else {
                 if ($index > 0) {
                     // the current abbrev matches, but the prev abbrevs didn't => error
                     $errors[] = array('plugins.importexport.native.import.error.sectionAbbrevMatch', array('sectionAbbrev' => $sectionAbbrev, 'issueTitle' => $issue->getIssueIdentification()));
                     return false;
                 }
             }
             $foundSectionId = $sectionId;
             $foundSectionAbbrev = $abbrev;
         } else {
             if ($foundSectionId) {
                 // a prev abbrev matched, but the current doesn't => error
                 $errors[] = array('plugins.importexport.native.import.error.sectionAbbrevMatch', array('sectionAbbrev' => $foundSectionAbbrev, 'issueTitle' => $issue->getIssueIdentification()));
                 return false;
             }
         }
         $index++;
     }
     if (!$section && !$abbrevSection) {
         // The section was not matched. Create one.
         // Note that because sections are global-ish,
         // we're not maintaining a list of created
         // sections to delete in case the import fails.
         unset($section);
         $section = new Section();
         $section->setTitle($titles, null);
         $section->setAbbrev($abbrevs, null);
         $section->setIdentifyType($identifyTypes, null);
         $section->setPolicy($policies, null);
         $section->setJournalId($journal->getId());
         $section->setSequence(REALLY_BIG_NUMBER);
         $section->setMetaIndexed(1);
         $section->setEditorRestricted(1);
         $section->setSectionId($sectionDao->insertSection($section));
         $sectionDao->resequenceSections($journal->getId());
     }
     if (!$section && $abbrevSection) {
         unset($section);
         $section =& $abbrevSection;
     }
     // $section *must* now contain a valid section, whether it was
     // found amongst existing sections or created anew.
     // Handle custom ordering, if necessary.
     if ($sectionIndex !== null) {
         $sectionDao->insertCustomSectionOrder($issue->getId(), $section->getId(), $sectionIndex);
     }
     $hasErrors = false;
     for ($index = 0; $node = $sectionNode->getChildByName('article', $index); $index++) {
         if (!NativeImportDom::handleArticleNode($journal, $node, $issue, $section, $article, $publishedArticle, $articleErrors, $user, $isCommandLine, $dependentItems)) {
             $errors = array_merge($errors, $articleErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     return true;
 }
 /**
  * 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));
 }
Beispiel #4
0
 /**
  * Internal function to return a Section object from a row.
  * @param $row array
  * @return Section
  */
 function &_returnSectionFromRow(&$row)
 {
     $section = new Section();
     $section->setId($row['section_id']);
     $section->setJournalId($row['journal_id']);
     $section->setReviewFormId($row['review_form_id']);
     $section->setSequence($row['seq']);
     $section->setMetaIndexed($row['meta_indexed']);
     $section->setMetaReviewed($row['meta_reviewed']);
     $section->setAbstractsNotRequired($row['abstracts_not_required']);
     $section->setEditorRestricted($row['editor_restricted']);
     $section->setHideTitle($row['hide_title']);
     $section->setHideAuthor($row['hide_author']);
     $section->setHideAbout($row['hide_about']);
     $section->setDisableComments($row['disable_comments']);
     $section->setAbstractWordCount($row['abstract_word_count']);
     $this->getDataObjectSettings('section_settings', 'section_id', $row['section_id'], $section);
     HookRegistry::call('SectionDAO::_returnSectionFromRow', array(&$section, &$row));
     return $section;
 }
 function importSections()
 {
     assert($this->xml->name == 'sections');
     $sectionDAO =& DAORegistry::getDAO('SectionDAO');
     $sectionEditorsDAO =& DAORegistry::getDAO('SectionEditorsDAO');
     $sections = $sectionDAO->getJournalSections($this->journal->getId());
     $this->nextElement();
     while ($this->xml->name == 'section') {
         $sectionXML = $this->getCurrentElementAsDom();
         $section = new Section();
         $section->setJournalId($this->journal->getId());
         $section->setReviewFormId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM, (int) $sectionXML->reviewFormId));
         $section->setSequence((int) $sectionXML->sequence);
         $section->setMetaIndexed((string) $sectionXML->metaIndexed);
         $section->setMetaReviewed((string) $sectionXML->metaReviewed);
         $section->setAbstractsNotRequired((int) $sectionXML->abstractsNotRequired);
         $section->setEditorRestricted((int) $sectionXML->editorRestricted);
         $section->setHideTitle((int) $sectionXML->hideTitle);
         $section->setHideAuthor((int) $sectionXML->hideAuthor);
         $section->setHideAbout((int) $sectionXML->hideAbout);
         $section->setDisableComments((int) $sectionXML->disableComments);
         $section->setAbstractWordCount((int) $sectionXML->wordCount);
         $sectionDAO->insertSection($section);
         $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_SECTION, (int) $sectionXML->oldId, $section->getId());
         $this->restoreDataObjectSettings($sectionDAO, $sectionXML->settings, 'section_settings', 'section_id', $section->getId());
         foreach ($sectionXML->sectionEditor as $sectionEditorXML) {
             $userId = $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $sectionEditorXML->userId);
             $canReview = (int) $sectionEditorXML->canReview;
             $canEdit = (int) $sectionEditorXML->canEdit;
             $sectionEditorsDAO->insertEditor($this->journal->getId(), $section->getId(), $userId, $canReview, $canEdit);
         }
         $this->nextElement();
     }
 }
 /**
  * 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();
     }
 }
Beispiel #7
0
 /**
  * Save section.
  */
 function execute()
 {
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     if (isset($this->sectionId)) {
         $section =& $sectionDao->getSection($this->sectionId, $journalId);
     }
     if (!isset($section)) {
         $section = new Section();
         $section->setJournalId($journalId);
         $section->setSequence(REALLY_BIG_NUMBER);
     }
     $section->setTitle($this->getData('title'), null);
     // Localized
     $section->setAbbrev($this->getData('abbrev'), null);
     // Localized
     // Added region
     // EL on Febraurt 11th 2013
     $section->setRegion($this->getData('region'), null);
     $reviewFormId = $this->getData('reviewFormId');
     if ($reviewFormId === '') {
         $reviewFormId = null;
     }
     $section->setReviewFormId($reviewFormId);
     $section->setMetaIndexed($this->getData('metaIndexed') ? 0 : 1);
     // #2066: Inverted
     $section->setMetaReviewed($this->getData('metaReviewed') ? 0 : 1);
     // #2066: Inverted
     $section->setAbstractsNotRequired($this->getData('abstractsNotRequired') ? 1 : 0);
     $section->setIdentifyType($this->getData('identifyType'), null);
     // Localized
     $section->setEditorRestricted($this->getData('editorRestriction') ? 1 : 0);
     $section->setHideTitle($this->getData('hideTitle') ? 1 : 0);
     $section->setHideAuthor($this->getData('hideAuthor') ? 1 : 0);
     $section->setHideAbout($this->getData('hideAbout') ? 1 : 0);
     $section->setDisableComments($this->getData('disableComments') ? 1 : 0);
     $section->setPolicy($this->getData('policy'), null);
     // Localized
     $section->setAbstractWordCount($this->getData('wordCount'));
     if ($section->getId() != null) {
         $sectionDao->updateSection($section);
         $sectionId = $section->getId();
     } else {
         $sectionId = $sectionDao->insertSection($section);
         $sectionDao->resequenceSections($journalId);
     }
 }