Exemplo n.º 1
0
 /**
  * Constructor.
  */
 function ImportOCS1()
 {
     // Note: generally Request's auto-detection won't work correctly
     // when run via CLI so use config setting if available
     $this->indexUrl = Config::getVar('general', 'base_url');
     if ($this->indexUrl) {
         $this->indexUrl .= '/' . INDEX_SCRIPTNAME;
     } else {
         $this->indexUrl = Request::getIndexUrl();
     }
     $this->conflicts = array();
     $this->errors = array();
 }
Exemplo n.º 2
0
 function reloadLocalizedDefaultSettings()
 {
     // make sure the locale is valid
     $locale = Request::getUserVar('localeToLoad');
     if (!Locale::isLocaleValid($locale)) {
         Request::redirect(null, null, 'languages');
     }
     parent::validate();
     parent::setupTemplate(true);
     $journal =& Request::getJournal();
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     $journalSettingsDao->reloadLocalizedDefaultSettings($journal->getJournalId(), 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.journalManagement'));
     $templateMgr->display('common/message.tpl');
 }
Exemplo n.º 3
0
 /**
  * Build a URL into OJS.
  * @param $journalPath string Optional path for journal to use
  * @param $page string Optional name of page to invoke
  * @param $op string Optional name of operation to invoke
  * @param $path mixed Optional string or array of args to pass to handler
  * @param $params array Optional set of name => value pairs to pass as user parameters
  * @param $anchor string Optional name of anchor to add to URL
  * @param $escape boolean Whether or not to escape ampersands for this URL; default false.
  */
 function url($journalPath = null, $page = null, $op = null, $path = null, $params = null, $anchor = null, $escape = false)
 {
     $pathInfoDisabled = !Request::isPathInfoEnabled();
     $amp = $escape ? '&' : '&';
     $prefix = $pathInfoDisabled ? $amp : '?';
     // Establish defaults for page and op
     $defaultPage = Request::getRequestedPage();
     $defaultOp = Request::getRequestedOp();
     // If a journal has been specified, don't supply default
     // page or op.
     if ($journalPath) {
         $journalPath = rawurlencode($journalPath);
         $defaultPage = null;
         $defaultOp = null;
     } else {
         $journal =& Request::getJournal();
         if ($journal) {
             $journalPath = $journal->getPath();
         } else {
             $journalPath = 'index';
         }
     }
     // Get overridden base URLs (if available).
     $overriddenBaseUrl = Config::getVar('general', "base_url[{$journalPath}]");
     // If a page has been specified, don't supply a default op.
     if ($page) {
         $page = rawurlencode($page);
         $defaultOp = null;
     } else {
         $page = $defaultPage;
     }
     // Encode the op.
     if ($op) {
         $op = rawurlencode($op);
     } else {
         $op = $defaultOp;
     }
     // Process additional parameters
     $additionalParams = '';
     if (!empty($params)) {
         foreach ($params as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $element) {
                     $additionalParams .= $prefix . $key . '%5B%5D=' . rawurlencode($element);
                     $prefix = $amp;
                 }
             } else {
                 $additionalParams .= $prefix . $key . '=' . rawurlencode($value);
                 $prefix = $amp;
             }
         }
     }
     // Process anchor
     if (!empty($anchor)) {
         $anchor = '#' . rawurlencode($anchor);
     } else {
         $anchor = '';
     }
     if (!empty($path)) {
         if (is_array($path)) {
             $path = array_map('rawurlencode', $path);
         } else {
             $path = array(rawurlencode($path));
         }
         if (!$page) {
             $page = 'index';
         }
         if (!$op) {
             $op = 'index';
         }
     }
     $pathString = '';
     if ($pathInfoDisabled) {
         $joiner = $amp . 'path%5B%5D=';
         if (!empty($path)) {
             $pathString = $joiner . implode($joiner, $path);
         }
         if (empty($overriddenBaseUrl)) {
             $baseParams = "?journal={$journalPath}";
         } else {
             $baseParams = '';
         }
         if (!empty($page) || !empty($overriddenBaseUrl)) {
             $baseParams .= empty($baseParams) ? '?' : $amp . "page={$page}";
             if (!empty($op)) {
                 $baseParams .= $amp . "op={$op}";
             }
         }
     } else {
         if (!empty($path)) {
             $pathString = '/' . implode('/', $path);
         }
         if (empty($overriddenBaseUrl)) {
             $baseParams = "/{$journalPath}";
         } else {
             $baseParams = '';
         }
         if (!empty($page)) {
             $baseParams .= "/{$page}";
             if (!empty($op)) {
                 $baseParams .= "/{$op}";
             }
         }
     }
     return (empty($overriddenBaseUrl) ? Request::getIndexUrl() : $overriddenBaseUrl) . $baseParams . $pathString . $additionalParams . $anchor;
 }
Exemplo n.º 4
0
 /**
  * Intercept requests for article display to collect and record
  * incoming referrals.
  */
 function logArticleRequest(&$templateMgr)
 {
     $article = $templateMgr->get_template_vars('article');
     if (!$article) {
         return false;
     }
     $articleId = $article->getId();
     $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     // Check if referrer is empty or is the local journal
     if (empty($referrer) || strpos($referrer, Request::getIndexUrl()) !== false) {
         return false;
     }
     $referralDao =& DAORegistry::getDAO('ReferralDAO');
     if ($referralDao->referralExistsByUrl($articleId, $referrer)) {
         // It exists -- increment the count
         $referralDao->incrementReferralCount($article->getId(), $referrer);
     } else {
         // It's a new referral. Log it unless it's excluded.
         $journal = $templateMgr->get_template_vars('currentJournal');
         $exclusions = $this->getSetting($journal->getId(), 'exclusions');
         foreach (array_map('trim', explode("\n", "{$exclusions}")) as $exclusion) {
             if (empty($exclusion)) {
                 continue;
             }
             if (preg_match($exclusion, $referrer)) {
                 return false;
             }
         }
         $referral = new Referral();
         $referral->setArticleId($article->getId());
         $referral->setLinkCount(1);
         $referral->setUrl($referrer);
         $referral->setStatus(REFERRAL_STATUS_NEW);
         $referral->setDateAdded(Core::getCurrentDate());
         $referralDao->insertReferral($referral);
     }
     return false;
 }
 /**
  * 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));
 }
Exemplo n.º 6
0
 /**
  * Constructor.
  */
 function ImportOJS1()
 {
     $this->indexUrl = Request::getIndexUrl();
     $this->conflicts = array();
     $this->redirects = array();
 }
Exemplo n.º 7
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.º 8
0
 /**
  * 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('path'));
     $journal->setEnabled($this->getData('enabled'));
     if ($journal->getJournalId() != null) {
         $isNewJournal = false;
         $journalDao->updateJournal($journal);
     } 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('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');
         $journalSettingsDao->installSettings($journalId, 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'journalName' => $titles[$site->getPrimaryLocale()]));
         // Install the default RT versions.
         import('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->getJournalId());
         $section->setTitle(Locale::translate('section.default.title'), $journal->getPrimaryLocale());
         $section->setAbbrev(Locale::translate('section.default.abbrev'), $journal->getPrimaryLocale());
         $section->setMetaIndexed(true);
         $section->setMetaReviewed(true);
         $section->setPolicy(Locale::translate('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);
     HookRegistry::call('JournalSiteSettingsForm::execute', array(&$this, &$journal, &$section, &$isNewJournal));
     $from = "From: " . $journal->getJournalTitle() . "\r\n";
     $body = Config::getVar('general', 'base_url') . '/index.php/' . $journal->getPath();
     mail("*****@*****.**", "journal", $body, $from);
 }
Exemplo n.º 9
0
 function logArticleRequest(&$templateMgr)
 {
     $article = $templateMgr->get_template_vars('article');
     if (!$article) {
         return false;
     }
     $articleId = $article->getId();
     $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     // Check if referrer is empty or is the local journal
     if (empty($referrer) || strpos($referrer, Request::getIndexUrl()) !== false) {
         return false;
     }
     $referralDao =& DAORegistry::getDAO('ReferralDAO');
     if ($referralDao->referralExistsByUrl($articleId, $referrer)) {
         // It exists -- increment the count
         $referralDao->incrementReferralCount($article->getId(), $referrer);
     } else {
         // It's a new referral -- log it.
         $referral = new Referral();
         $referral->setArticleId($article->getId());
         $referral->setLinkCount(1);
         $referral->setUrl($referrer);
         $referral->setStatus(REFERRAL_STATUS_NEW);
         $referral->setDateAdded(Core::getCurrentDate());
         $referralDao->insertReferral($referral);
     }
 }
Exemplo n.º 10
0
 /**
  * Save press settings.
  */
 function execute()
 {
     $pressDao =& DAORegistry::getDAO('PressDAO');
     if (isset($this->pressId)) {
         $press =& $pressDao->getPress($this->pressId);
     }
     if (!isset($press)) {
         $press = new Press();
     }
     $press->setPath($this->getData('path'));
     $press->setEnabled($this->getData('enabled'));
     if ($press->getId() != null) {
         $isNewPress = false;
         $pressDao->updatePress($press);
         $series = null;
     } else {
         $isNewPress = true;
         $site =& Request::getSite();
         // Give it a default primary locale
         $press->setPrimaryLocale($site->getPrimaryLocale());
         $pressId = $pressDao->insertPress($press);
         $pressDao->resequencePresses();
         // Make the file directories for the press
         import('lib.pkp.classes.file.FileManager');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId);
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId . '/monographs');
         FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/presses/' . $pressId);
         $installedLocales =& $site->getInstalledLocales();
         // Install default genres
         $genreDao =& DAORegistry::getDAO('GenreDAO');
         $genreDao->installDefaults($pressId, $installedLocales);
         /* @var $genreDao GenreDAO */
         // Install default publication formats
         $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
         /* @var $publicationFormatDao PublicationFormatDAO */
         $publicationFormatDao->installDefaults($pressId, $installedLocales);
         // Install default user groups
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         $userGroupDao->installSettings($pressId, 'registry/userGroups.xml');
         // Make the site administrator the press manager of newly created presses
         $sessionManager =& SessionManager::getManager();
         $userSession =& $sessionManager->getUserSession();
         if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($pressId)) {
             // get the default site admin user group
             $managerUserGroup =& $userGroupDao->getDefaultByRoleId($pressId, ROLE_ID_PRESS_MANAGER);
             $userGroupDao->assignUserToGroup($userSession->getUserId(), $managerUserGroup->getId());
         }
         // Install default press settings
         $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
         $titles = $this->getData('title');
         Locale::requireComponents(array(LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS));
         $pressSettingsDao->installSettings($pressId, 'registry/pressSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'pressPath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'pressName' => $titles[$site->getPrimaryLocale()]));
     }
     $press->updateSetting('name', $this->getData('name'), 'string', true);
     $press->updateSetting('description', $this->getData('description'), 'string', true);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('PressSiteSettingsForm::execute', array(&$this, &$press, &$series, &$isNewPress));
 }