function install() { //if ($this->entryPoint->type == 'cmdline') // return; $authconfig = $this->config->getValue('auth', 'coordplugins'); if ($authconfig && $this->firstExec($authconfig)) { // a config file for the auth plugin exists, so we can install // the module, else we ignore it $conf = new \Jelix\IniFile\IniModifier(jApp::configPath($authconfig)); $driver = $conf->getValue('driver'); if ($driver == '') { $driver = 'Db'; $conf->setValue('driver', 'Db'); $conf->setValue('dao', 'jauthdb~jelixuser', 'Db'); $conf->save(); } else { if ($driver != 'Db') { return; } } $this->useDbProfile($conf->getValue('profile', 'Db')); // FIXME: should use the given dao to create the table $daoName = $conf->getValue('dao', 'Db'); if ($daoName == 'jauthdb~jelixuser' && $this->firstDbExec()) { $this->execSQLScript('install_jauth.schema'); if ($this->getParameter('defaultuser')) { require_once JELIX_LIB_PATH . 'auth/jAuth.class.php'; require_once JELIX_LIB_PATH . 'plugins/auth/db/db.auth.php'; $confIni = parse_ini_file(jApp::configPath($authconfig), true); $authConfig = jAuth::loadConfig($confIni); $driver = new dbAuthDriver($authConfig['Db']); $passwordHash = $driver->cryptPassword('admin'); $cn = $this->dbConnection(); $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n ('admin', " . $cn->quote($passwordHash) . " , '*****@*****.**')"); } } } }
function install() { $lizmapConfFile = jApp::configPath('lizmapConfig.ini.php'); if (!file_exists($lizmapConfFile)) { $lizmapConfFileDist = jApp::configPath('lizmapConfig.ini.php.dist'); if (file_exists($lizmapConfFileDist)) { copy($lizmapConfFileDist, $lizmapConfFile); } else { $this->copyFile('config/lizmapConfig.ini.php', $lizmapConfFile); } } $localConfig = jApp::configPath('localconfig.ini.php'); if (!file_exists($localConfig)) { $localConfigDist = jApp::configPath('localconfig.ini.php.dist'); if (file_exists($localConfigDist)) { copy($localConfigDist, $localConfig); } else { file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>'); } } $ini = new jIniFileModifier($localConfig); $ini->setValue('lizmap', 'lizmapConfig.ini.php', 'coordplugins'); $ini->save(); if ($this->firstDbExec()) { // Add log table $this->useDbProfile('lizlog'); $this->execSQLScript('sql/lizlog'); // Add geobookmark table $this->useDbProfile('jauth'); $this->execSQLScript('sql/lizgeobookmark'); } if ($this->firstExec('acl2') && $this->getParameter('demo')) { $this->useDbProfile('auth'); // create group jAcl2DbUserGroup::createGroup('lizadmins'); jAcl2DbUserGroup::createGroup('Intranet demos group', 'intranet'); // create user in jAuth require_once JELIX_LIB_PATH . 'auth/jAuth.class.php'; require_once JELIX_LIB_PATH . 'plugins/auth/db/db.auth.php'; $authconfig = $this->config->getValue('auth', 'coordplugins'); $confIni = parse_ini_file(jApp::configPath($authconfig), true); $authConfig = jAuth::loadConfig($confIni); $driver = new dbAuthDriver($authConfig['Db']); $passwordHash1 = $driver->cryptPassword('lizadmin'); $passwordHash2 = $driver->cryptPassword('logintranet'); $cn = $this->dbConnection(); $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n ('lizadmin', " . $cn->quote($passwordHash1) . " , '*****@*****.**')"); $cn->exec("INSERT INTO " . $cn->prefixTable('jlx_user') . " (usr_login, usr_password, usr_email ) VALUES\n ('logintranet', " . $cn->quote($passwordHash2) . " , '*****@*****.**')"); // declare users in jAcl2 jAcl2DbUserGroup::createUser('lizadmin', true); jAcl2DbUserGroup::createUser('logintranet', true); jAcl2DbUserGroup::addUserToGroup('lizadmin', 'lizadmins'); jAcl2DbUserGroup::addUserToGroup('logintranet', 'intranet'); jAcl2DbManager::setRightsOnGroup('lizadmins', array('lizmap.admin.access' => true, 'lizmap.admin.services.update' => true, 'lizmap.admin.repositories.create' => true, 'lizmap.admin.repositories.delete' => true, 'lizmap.admin.repositories.update' => true, 'lizmap.admin.repositories.view' => true, 'lizmap.admin.services.view' => true)); // admins jAcl2DbManager::addRight('admins', 'lizmap.tools.edition.use', 'intranet'); jAcl2DbManager::addRight('admins', 'lizmap.repositories.view', 'intranet'); jAcl2DbManager::addRight('admins', 'lizmap.tools.loginFilteredLayers.override', 'intranet'); jAcl2DbManager::addRight('admins', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet'); jAcl2DbManager::addRight('admins', 'lizmap.tools.edition.use', 'montpellier'); jAcl2DbManager::addRight('admins', 'lizmap.repositories.view', 'montpellier'); jAcl2DbManager::addRight('admins', 'lizmap.tools.loginFilteredLayers.override', 'montpellier'); jAcl2DbManager::addRight('admins', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier'); // lizadmins jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.edition.use', 'intranet'); jAcl2DbManager::addRight('lizadmins', 'lizmap.repositories.view', 'intranet'); jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.loginFilteredLayers.override', 'intranet'); jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet'); jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.edition.use', 'montpellier'); jAcl2DbManager::addRight('lizadmins', 'lizmap.repositories.view', 'montpellier'); jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.loginFilteredLayers.override', 'montpellier'); jAcl2DbManager::addRight('lizadmins', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier'); // intranet jAcl2DbManager::addRight('intranet', 'lizmap.tools.edition.use', 'intranet'); jAcl2DbManager::addRight('intranet', 'lizmap.repositories.view', 'intranet'); jAcl2DbManager::addRight('intranet', 'lizmap.tools.loginFilteredLayers.override', 'intranet'); jAcl2DbManager::addRight('intranet', 'lizmap.tools.displayGetCapabilitiesLinks', 'intranet'); jAcl2DbManager::addRight('intranet', 'lizmap.tools.edition.use', 'montpellier'); jAcl2DbManager::addRight('intranet', 'lizmap.repositories.view', 'montpellier'); jAcl2DbManager::addRight('intranet', 'lizmap.tools.loginFilteredLayers.override', 'montpellier'); jAcl2DbManager::addRight('intranet', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier'); // anonymous jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.edition.use', 'montpellier'); jAcl2DbManager::addRight('__anonymous', 'lizmap.repositories.view', 'montpellier'); jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.loginFilteredLayers.override', 'montpellier'); jAcl2DbManager::addRight('__anonymous', 'lizmap.tools.displayGetCapabilitiesLinks', 'montpellier'); // declare the repositories of demo in the configuration $ini = new jIniFileModifier($lizmapConfFile); $ini->setValues(array('label' => 'LizMap Demo', 'path' => '../install/qgis/', 'allowUserDefinedThemes' => 1), 'repository:montpellier'); $ini->setValues(array('label' => 'Lizmap Demo - Intranet', 'path' => '../install/qgis_intranet/', 'allowUserDefinedThemes' => ''), 'repository:intranet'); $ini->setValue('defaultRepository', 'montpellier', 'services'); $ini->save(); } }
function install() { $authconfig = $this->config->getValue('auth', 'coordplugins'); $authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true); $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc')); $createdConfFile = false; if (!$authconfig || $forWS && $authconfig == $authconfigMaster) { //if ($this->entryPoint->type == 'cmdline') { // return; //} if ($forWS) { $pluginIni = 'authsw.coord.ini.php'; } else { $pluginIni = 'auth.coord.ini.php'; } $authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni; if ($this->firstExec($authconfig)) { // no configuration, let's install the plugin for the entry point $this->config->setValue('auth', $authconfig, 'coordplugins'); $this->copyFile('var/config/' . $pluginIni, 'epconfig:' . $pluginIni); $createdConfFile = true; } } $conf = new jIniFileModifier(jApp::configPath($authconfig)); $usedStandardDao = $conf->getValue('dao', 'Db') == 'jauthdb~jelixuser'; $this->useDbProfile($conf->getValue('profile', 'Db')); if ($createdConfFile) { mt_srand(); $conf->setValue('persistant_crypt_key', sha1("jelix" . time() . mt_rand())); $conf->save(); } if ($this->firstExec($authconfig) && $this->getParameter('rewriteconfig')) { $conf->setValue('driver', 'Db'); $conf->setValue('dao', 'jcommunity~user', 'Db'); $conf->setValue('form', 'jcommunity~account_admin', 'Db'); $conf->setValue('error_message', 'jcommunity~login.error.notlogged'); $conf->setValue('on_error_action', 'jcommunity~login:out'); $conf->setValue('bad_ip_action', 'jcommunity~login:out'); $conf->setValue('after_logout', 'jcommunity~login:index'); $conf->setValue('enable_after_login_override', 'on'); $conf->setValue('enable_after_logout_override', 'on'); $conf->setValue('after_login', 'jcommunity~account:show'); $conf->save(); } if ($this->getParameter('masteradmin')) { $conf->setValue('after_login', 'master_admin~default:index'); $conf->save(); $this->config->setValue('loginResponse', 'htmlauth', 'jcommunity'); } if ($this->firstDbExec() && !$this->getParameter('notjcommunitytable')) { $conf->setValue('dao', 'jcommunity~user', 'Db'); $conf->setValue('form', 'jcommunity~account_admin', 'Db'); $conf->save(); $this->execSQLScript('sql/install'); $cn = $this->dbConnection(); if ($usedStandardDao && $this->getParameter('migratejauthdbusers')) { $cn->exec("INSERT INTO " . $cn->prefixTable('community_users') . "\n (login, password, email, nickname, status, create_date)\n SELECT usr_login, usr_password, usr_email, usr_login, 1, '" . date('Y-m-d H:i:s') . "'\n FROM " . $cn->prefixTable('jlx_user')); } else { if ($this->getParameter('defaultuser')) { require_once JELIX_LIB_PATH . 'auth/jAuth.class.php'; require_once JELIX_LIB_PATH . 'plugins/auth/db/db.auth.php'; $confIni = parse_ini_file(jApp::configPath($authconfig), true); $authConfig = jAuth::loadConfig($confIni); $driver = new dbAuthDriver($authConfig['Db']); $passwordHash = $driver->cryptPassword('admin'); $cn->exec("INSERT INTO " . $cn->prefixTable('community_users') . " (login, password, email, nickname, status, create_date) VALUES\n ('admin', " . $cn->quote($passwordHash) . ", '*****@*****.**', 'admin', 1, '" . date('Y-m-d H:i:s') . "')"); } } } if ($this->firstExec('acl2') && class_exists('jAcl2DbManager')) { jAcl2DbManager::addSubjectGroup('jcommunity.admin', 'jcommunity~prefs.admin.jcommunity'); jAcl2DbManager::addSubject('jcommunity.prefs.change', 'jcommunity~prefs.admin.prefs.change', 'jprefs.prefs.management'); jAcl2DbManager::addRight('admins', 'jcommunity.prefs.change'); // for admin group } if ($this->firstExec('preferences')) { $prefIni = new jIniFileModifier(__DIR__ . '/prefs.ini'); $prefFile = jApp::configPath('preferences.ini.php'); if (file_exists($prefFile)) { $mainPref = new jIniFileModifier($prefFile); //import this way to not erase changed value. $prefIni->import($mainPref); } $prefIni->saveAs($prefFile); } }