Beispiel #1
0
 /**
  * Internal function to return a Press object from a row.
  * @param $row array
  * @return Press
  */
 function &_returnPressFromRow(&$row)
 {
     $press = new Press();
     $press->setId($row['press_id']);
     $press->setPath($row['path']);
     $press->setSequence($row['seq']);
     $press->setEnabled($row['enabled']);
     $press->setPrimaryLocale($row['primary_locale']);
     HookRegistry::call('PressDAO::_returnPressFromRow', array(&$press, &$row));
     return $press;
 }
 /**
  * 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));
 }