Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PressSiteSettingsForm.inc.php
1 <?php
2 
16 import('lib.pkp.controllers.grid.admin.context.form.ContextSiteSettingsForm');
17 
23  function PressSiteSettingsForm($contextId = null) {
24  parent::ContextSiteSettingsForm($contextId);
25  }
26 
31  function execute($request) {
32  $pressDao = DAORegistry::getDAO('PressDAO');
33 
34  if (isset($this->contextId)) {
35  $press = $pressDao->getById($this->contextId); /* @var $press Press */
36 
37  import('classes.publicationFormat.PublicationFormatTombstoneManager');
38  $publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
39  if ($press->getEnabled() && !$this->getData('enabled')) {
40  // Will disable the press. Create tombstones for all
41  // published monographs publication formats.
42  $publicationFormatTombstoneMgr->insertTombstonesByPress($press);
43  } elseif (!$press->getEnabled() && $this->getData('enabled')) {
44  // Will enable the press. Delete all tombstones.
45  $publicationFormatTombstoneMgr->deleteTombstonesByPressId($press->getId());
46  }
47  }
48 
49  if (!isset($press)) {
50  $press = $pressDao->newDataObject();
51  }
52 
53  // Check if the press path has changed.
54  $pathChanged = false;
55  $pressPath = $press->getPath();
56  if ($pressPath != $this->getData('path')) {
57  $pathChanged = true;
58  }
59  $press->setPath($this->getData('path'));
60  $press->setEnabled($this->getData('enabled'));
61 
62  $isNewPress = false;
63 
64  if ($press->getId() != null) {
65  $pressDao->updateObject($press);
66  $series = null;
67  } else {
68  $isNewPress = true;
69  $site = $request->getSite();
70 
71  // Give it a default primary locale
72  $press->setPrimaryLocale($site->getPrimaryLocale());
73 
74  $contextId = $pressDao->insertObject($press);
75  $pressDao->resequence();
76 
77  // Make the file directories for the press
78  import('lib.pkp.classes.file.ContextFileManager');
79  $pressFileManager = new ContextFileManager($contextId);
80  $pressFileManager->mkdir($pressFileManager->getBasePath());
81  $pressFileManager->mkdir($pressFileManager->getBasePath() . '/monographs');
82 
83  $installedLocales = $site->getInstalledLocales();
84 
85  // Install default genres
86  $genreDao = DAORegistry::getDAO('GenreDAO');
87  $genreDao->installDefaults($contextId, $installedLocales); /* @var $genreDao GenreDAO */
88 
89  // load the default user groups and stage assignments.
90  $this->_loadDefaultUserGroups($press->getId());
91 
92  $this->_assignManagerGroup($press->getId());
93 
94  // Install default press settings
95  $pressSettingsDao = DAORegistry::getDAO('PressSettingsDAO');
96  $titles = $this->getData('title');
97  AppLocale::requireComponents(LOCALE_COMPONENT_APP_DEFAULT, LOCALE_COMPONENT_PKP_DEFAULT);
98  $pressSettingsDao->installSettings($contextId, 'registry/pressSettings.xml', array(
99  'indexUrl' => $request->getIndexUrl(),
100  'pressPath' => $this->getData('path'),
101  'primaryLocale' => $site->getPrimaryLocale(),
102  'pressName' => $titles[$site->getPrimaryLocale()]
103  ));
104  }
105  $press->updateSetting('supportedLocales', $site->getSupportedLocales());
106  $press->updateSetting('name', $this->getData('name'), 'string', true);
107  $press->updateSetting('description', $this->getData('description'), 'string', true);
108 
109  // Make sure all plugins are loaded for settings preload
111 
112  HookRegistry::call('PressSiteSettingsForm::execute', array(&$this, &$press, &$series, &$isNewPress));
113 
114  if ($isNewPress || $pathChanged) {
115  return $press->getPath();
116  }
117  }
118 }
119 
120 ?>
static & getDAO($name, $dbconn=null)
static requireComponents()
Class defining operations for private context file management.
getData($key)
Definition: Form.inc.php:210
PressSiteSettingsForm($contextId=null)
Class defining basic operations for publication format tombstones.
static call($hookName, $args=null)
static & loadAllPlugins($enabledOnly=false)
Form for site administrator to edit basic press settings.
Form for site administrator to edit basic context settings.