28 import(
'lib.pkp.classes.install.Installer');
29 import(
'classes.core.Services');
31 use Illuminate\Database\Capsule\Manager as Capsule;
58 if(!isset($this->currentVersion)) {
62 $this->locale = $this->
getParam(
'locale');
63 $this->installedLocales = $this->
getParam(
'additionalLocales');
64 if (!isset($this->installedLocales) || !is_array($this->installedLocales)) {
65 $this->installedLocales = array();
68 array_push($this->installedLocales, $this->locale);
73 $driver = $this->
getParam(
'databaseDriver'),
79 $connectionCharset = $this->
getParam(
'connectionCharset') ==
'' ?
false : $this->
getParam(
'connectionCharset')
82 $this->dbconn =& $conn->getDBConn();
84 if (!$conn->isConnected()) {
85 $this->
setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
90 $driver = strtolower($driver);
91 if (substr($driver, 0, 8) ===
'postgres') {
97 $capsule =
new Capsule;
98 $capsule->addConnection([
100 'host' => $this->
getParam(
'databaseHost'),
101 'database' => $this->
getParam(
'databaseName'),
102 'username' => $this->
getParam(
'databaseUsername'),
103 'password' => $this->
getParam(
'databasePassword'),
104 'charset' => $connectionCharset ==
'latin1'?
'latin1':
'utf8',
105 'collation' =>
'utf8_general_ci',
107 $capsule->setAsGlobal();
111 return parent::preInstall();
124 return array(
'site');
134 if (!(file_exists($this->
getParam(
'filesDir')) && is_writeable($this->
getParam(
'filesDir')))) {
136 $this->
setError(INSTALLER_ERROR_GENERAL,
'installer.installFilesDirError');
141 import(
'lib.pkp.classes.file.FileManager');
143 foreach ($dirsToCreate as $dirName) {
144 $dirToCreate = $this->
getParam(
'filesDir') .
'/' . $dirName;
145 if (!file_exists($dirToCreate)) {
146 if (!$fileManager->mkdir($dirToCreate)) {
147 $this->
setError(INSTALLER_ERROR_GENERAL,
'installer.installFilesDirError');
156 if (!(file_exists($publicFilesDir) && is_writeable($publicFilesDir))) {
158 $this->
setError(INSTALLER_ERROR_GENERAL,
'installer.publicFilesDirError');
163 import(
'lib.pkp.classes.file.FileManager');
165 foreach ($dirsToCreate as $dirName) {
166 $dirToCreate = $publicFilesDir .
'/' . $dirName;
167 if (!file_exists($dirToCreate)) {
168 if (!$fileManager->mkdir($dirToCreate)) {
169 $this->
setError(INSTALLER_ERROR_GENERAL,
'installer.publicFilesDirError');
184 if (!$this->
getParam(
'createDatabase')) {
189 $dbdict = NewDataDictionary($this->dbconn);
191 list(
$sql) = $dbdict->CreateDatabase($this->
getParam(
'databaseName'));
199 $this->dbconn->disconnect();
204 $this->
getParam(
'databaseUsername'),
205 $this->
getParam(
'databasePassword'),
208 $this->
getParam(
'connectionCharset') ==
'' ?
false : $this->
getParam(
'connectionCharset')
213 $this->dbconn =& $conn->getDBConn();
215 if (!$conn->isConnected()) {
216 $this->
setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
233 'base_url' => $request->getBaseUrl(),
234 'enable_beacon' => $this->getParam(
'enableBeacon')?
'On':
'Off',
237 'driver' => $this->
getParam(
'databaseDriver'),
238 'host' => $this->
getParam(
'databaseHost'),
239 'username' => $this->
getParam(
'databaseUsername'),
240 'password' => $this->
getParam(
'databasePassword'),
241 'name' => $this->
getParam(
'databaseName')
244 'locale' => $this->
getParam(
'locale'),
245 'client_charset' => $this->
getParam(
'clientCharset'),
246 'connection_charset' => $this->
getParam(
'connectionCharset') ==
'' ?
'Off' : $this->
getParam(
'connectionCharset'),
249 'files_dir' => $this->
getParam(
'filesDir')
252 'repository_id' => $this->
getParam(
'oaiRepositoryId')
263 $siteLocale = $this->
getParam(
'locale');
267 $user = $userDao->newDataObject();
268 $user->setUsername($this->
getParam(
'adminUsername'));
270 $user->setGivenName($user->getUsername(), $siteLocale);
271 $user->setFamilyName($user->getUsername(), $siteLocale);
272 $user->setEmail($this->
getParam(
'adminEmail'));
273 $user->setInlineHelp(1);
274 if (!$userDao->insertObject($user)) {
275 $this->
setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
282 $adminUserGroup = $userGroupDao->newDataObject();
283 $adminUserGroup->setRoleId(ROLE_ID_SITE_ADMIN);
284 $adminUserGroup->setContextId(CONTEXT_ID_NONE);
285 $adminUserGroup->setDefault(
true);
286 foreach ($this->installedLocales as
$locale) {
287 $name = __(
'default.groups.name.siteAdmin', array(),
$locale);
288 $namePlural = __(
'default.groups.plural.siteAdmin', array(),
$locale);
289 $adminUserGroup->setData(
'name', $name,
$locale);
290 $adminUserGroup->setData(
'namePlural', $namePlural,
$locale);
292 if (!$userGroupDao->insertObject($adminUserGroup)) {
293 $this->
setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
298 $userGroupDao->assignUserToGroup($user->getId(), $adminUserGroup->getId());
302 $site = $siteDao->newDataObject();
303 $site->setRedirect(0);
304 $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
305 $site->setPrimaryLocale($siteLocale);
306 $site->setInstalledLocales($this->installedLocales);
307 $site->setSupportedLocales($this->installedLocales);
308 if (!$siteDao->insertSite($site)) {
309 $this->
setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
314 foreach ($this->installedLocales as
$locale) {
318 $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), $this->installedLocales);
322 $site = $schemaService->setDefaults(SCHEMA_SITE, $site, $site->getSupportedLocales(), $site->getPrimaryLocale());
323 $site->setData(
'contactEmail', $this->
getParam(
'adminEmail'), $site->getPrimaryLocale());
324 $siteDao->updateObject($site);