// allerdings darf hier keine Fehlermeldung wg. dem safe_mode kommen @set_time_limit(300); $mainVersion = substr($installedDbVersion, 0, 1); $subVersion = substr($installedDbVersion, 2, 1); $microVersion = substr($installedDbVersion, 4, 1); $microVersion = (int) $microVersion + 1; $flagNextVersion = true; // erst einmal die evtl. neuen Orga-Einstellungen in DB schreiben require_once 'db_scripts/preferences.php'; // calculate the best cost value for your server performance $benchmarkResults = PasswordHashing::costBenchmark(); $orga_preferences['system_hashing_cost'] = $benchmarkResults['cost']; $sql = 'SELECT * FROM ' . TBL_ORGANIZATIONS; $orgaStatement = $gDb->query($sql); while ($row_orga = $orgaStatement->fetch()) { $gCurrentOrganization->setValue('org_id', $row_orga['org_id']); $gCurrentOrganization->setPreferences($orga_preferences, false); } if ($gDbType === 'mysql') { // disable foreign key checks for mysql, so tables can easily deleted $sql = 'SET foreign_key_checks = 0 '; $gDb->query($sql); } // before version 3 we had an other update mechanism which will be handled here if ($mainVersion < 3) { // nun in einer Schleife die Update-Scripte fuer alle Versionen zwischen der Alten und Neuen einspielen while ($flagNextVersion) { $flagNextVersion = false; if ($mainVersion < 3) { // until version 3 Admidio had sql and php files where the update statements where stored // these files must be executed
// form fields are not filled if ($_POST['orgaShortName'] === '' || $_POST['orgaLongName'] === '') { $gMessage->show($gL10n->get('INS_ORGANIZATION_NAME_NOT_COMPLETELY')); } // check if orga shortname exists $organization = new Organization($gDb, $_POST['orgaShortName']); if ($organization->getValue('org_id') > 0) { $gMessage->show($gL10n->get('INS_ORGA_SHORTNAME_EXISTS', $_POST['orgaShortName'])); } // set execution time to 2 minutes because we have a lot to do :) // there should be no error output because of safe mode @set_time_limit(120); $gDb->startTransaction(); // create new organization $newOrganization = new Organization($gDb, $_POST['orgaShortName']); $newOrganization->setValue('org_longname', $_POST['orgaLongName']); $newOrganization->setValue('org_shortname', $_POST['orgaShortName']); $newOrganization->setValue('org_homepage', $_SERVER['HTTP_HOST']); $newOrganization->save(); // write all preferences from preferences.php in table adm_preferences require_once '../../installation/db_scripts/preferences.php'; // set some specific preferences whose values came from user input of the installation wizard $orga_preferences['email_administrator'] = $_POST['orgaEmail']; $orga_preferences['system_language'] = $gPreferences['system_language']; // create all necessary data for this organization $newOrganization->setPreferences($orga_preferences, false); $newOrganization->createBasicData($gCurrentUser->getValue('usr_id')); // if installation of second organization than show organization select at login if ($gCurrentOrganization->countAllRecords() === 2) { $sql = 'UPDATE ' . TBL_PREFERENCES . ' SET prf_value = 1 WHERE prf_name = \'system_organization_select\' ';
$db->query($sql); // Inventoryfelder anlegen $sql = 'INSERT INTO ' . TBL_INVENT_FIELDS . ' (inf_cat_id, inf_type, inf_name_intern, inf_name, inf_description, inf_system, inf_disabled, inf_mandatory, inf_sequence, inf_usr_id_create, inf_timestamp_create) VALUES (' . $cat_id_master_inf . ', \'TEXT\', \'ITEM_NAME\', \'SYS_ITEMNAME\', NULL, 1, 1, 1, 1, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\') , (' . $cat_id_master_inf . ', \'NUMBER\', \'ROOM_ID\', \'SYS_ROOM\', NULL, 1, 1, 1, 2, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\') , (' . $cat_id_master_inf . ', \'NUMBER\', \'PRICE\', \'SYS_QUANTITY\', NULL, 0, 0, 0, 3, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\') '; $db->query($sql); if ($gDbType === 'postgresql') { // soundex is not a default function in PostgreSQL $sql = 'UPDATE ' . TBL_PREFERENCES . ' SET prf_value = \'0\' WHERE prf_name LIKE \'system_search_similar\''; $db->query($sql); } // create new organization $gCurrentOrganization = new Organization($db, $_SESSION['orga_shortname']); $gCurrentOrganization->setValue('org_longname', $_SESSION['orga_longname']); $gCurrentOrganization->setValue('org_shortname', $_SESSION['orga_shortname']); $gCurrentOrganization->setValue('org_homepage', $_SERVER['HTTP_HOST']); $gCurrentOrganization->save(); // create user webmaster and assign roles $webmaster = new TableUsers($db); $webmaster->setValue('usr_login_name', $_SESSION['user_login']); $webmaster->setPassword($_SESSION['user_password']); $webmaster->setValue('usr_usr_id_create', $gCurrentUser->getValue('usr_id')); $webmaster->setValue('usr_timestamp_create', DATETIME_NOW); $webmaster->save(false); // no registered user -> UserIdCreate couldn't be filled // write all preferences from preferences.php in table adm_preferences require_once 'db_scripts/preferences.php'; // set some specific preferences whose values came from user input of the installation wizard $orga_preferences['email_administrator'] = $_SESSION['orga_email'];