$sql = 'alter table ' . $g_tbl_praefix . '_members add constraint ' . $g_tbl_praefix . '_FK_MEM_USR foreign key (mem_usr_id) references ' . $g_tbl_praefix . '_users (usr_id) on delete restrict on update restrict'; $gDb->query($sql, false); $sql = 'create index IDX_' . $g_tbl_praefix . '_MEM_ROL_USR_ID on ' . TBL_MEMBERS . ' (mem_rol_id, mem_usr_id)'; $gDb->query($sql); $sql = 'UPDATE ' . TBL_ROLES . ' SET rol_webmaster = 1 WHERE rol_name = \'' . $gL10n->get('SYS_WEBMASTER') . '\' '; $gDb->query($sql); // convert <br /> to a normal line feed $emailText = preg_replace('/<br[[:space:]]*\\/?[[:space:]]*>/', chr(13) . chr(10), $gL10n->get('SYS_SYSMAIL_REFUSE_REGISTRATION')); // create new system user $systemUser = new TableUsers($gDb); $systemUser->setValue('usr_login_name', $gL10n->get('SYS_SYSTEM')); $systemUser->setValue('usr_valid', '0'); $systemUser->setValue('usr_timestamp_create', DATETIME_NOW); $systemUser->save(false); // no registered user -> UserIdCreate couldn't be filled $sql = 'SELECT usf_id FROM ' . TBL_USER_FIELDS . ' WHERE usf_name_intern = \'LAST_NAME\''; $pdoStatement = $gDb->query($sql); $usfRow = $pdoStatement->fetch(); $sql = 'INSERT INTO ' . TBL_USER_DATA . ' (usd_usf_id, usd_usr_id, usd_value) VALUES (' . $usfRow['usf_id'] . ', ' . $systemUser->getValue('usr_id') . ', \'' . $gL10n->get('SYS_SYSTEM') . '\')'; $gDb->query($sql); $sql = 'UPDATE ' . TBL_MEMBERS . ' SET mem_usr_id_create = ' . $systemUser->getValue('usr_id') . ' , mem_timestamp_create = \'' . DATETIME_NOW . '\''; $gDb->query($sql); $sql = 'UPDATE ' . TBL_MEMBERS . ' SET mem_usr_id_create = ' . $systemUser->getValue('usr_id') . ' , mem_timestamp_create = \'' . DATETIME_NOW . '\''; $gDb->query($sql); // write data for every organization $sql = 'SELECT * FROM ' . TBL_ORGANIZATIONS . ' ORDER BY org_id DESC';
/** * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's a new * record or if only an update is necessary. The update statement will only update the changed columns. * If the table has columns for creator or editor than these column with their timestamp will be updated. * First save recordset and then save all user fields. After that the session of this got a renew for the user object. * If the user doesn't have the right to save data of this user than an exception will be thrown. * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset * if table has columns like @b usr_id_create or @b usr_id_changed * @throws AdmException * @return bool */ public function save($updateFingerPrint = true) { global $gCurrentSession, $gCurrentUser; $fields_changed = $this->columnsValueChanged; $updateCreateUserId = false; // if current user is new or is allowed to edit this user than save data if ($this->getValue('usr_id') == 0 || $gCurrentUser->hasRightEditProfile($this) || $this->saveChangesWithoutRights) { $this->db->startTransaction(); // if new user then set create id if ($this->getValue('usr_id') == 0 && $gCurrentUser->getValue('usr_id') == 0) { $updateCreateUserId = true; $updateFingerPrint = false; } // if value of a field changed then update timestamp of user object if ($this->mProfileFieldsData->columnsValueChanged) { $this->columnsValueChanged = true; } $returnValue = parent::save($updateFingerPrint); // if this was an registration then set this user id to create user id if ($updateCreateUserId) { $this->setValue('usr_timestamp_create', DATETIME_NOW); $this->setValue('usr_usr_id_create', $this->getValue('usr_id')); $returnValue = parent::save($updateFingerPrint); } // save data of all user fields $this->mProfileFieldsData->saveUserData($this->getValue('usr_id')); if ($fields_changed && is_object($gCurrentSession)) { // now set user object in session of that user to invalid, // because he has new data and maybe new rights $gCurrentSession->renewUserObject($this->getValue('usr_id')); } $this->db->endTransaction(); return $returnValue; } else { throw new AdmException('The profile data of user ' . $this->getValue('FIRST_NAME') . ' ' . $this->getValue('LAST_NAME') . ' could not be saved because you don\'t have the right to do this.'); } }
* * @copyright 2004-2016 The Admidio Team * @see http://www.admidio.org/ * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 only * * Parameters: * * aid .. Activation id for confirmation of new password * usr_id .. Id of the user who wants a new password *********************************************************************************************** */ require_once 'common.php'; // Initialize and check the parameters $getActivationId = admFuncVariableIsValid($_GET, 'aid', 'string', array('requireValue' => true)); $getUserId = admFuncVariableIsValid($_GET, 'usr_id', 'int', array('requireValue' => true)); // Systemmails und Passwort zusenden muessen aktiviert sein if ($gPreferences['enable_system_mails'] != 1 || $gPreferences['enable_password_recovery'] != 1) { $gMessage->show($gL10n->get('SYS_MODULE_DISABLED')); } $user = new TableUsers($gDb, $getUserId); if ($user->getValue('usr_activation_code') === $getActivationId) { // activate the new password $user->setPassword($user->getValue('usr_new_password'), false, false); $user->setPassword('', true, false); $user->setValue('usr_activation_code', ''); $user->save(); $gMessage->setForwardUrl($g_root_path . '/adm_program/system/login.php', 2000); $gMessage->show($gL10n->get('SYS_PWACT_PW_SAVED')); } else { $gMessage->show($gL10n->get('SYS_PWACT_CODE_INVALID')); }
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']; $orga_preferences['system_language'] = $language; // calculate the best cost value for your server performance $benchmarkResults = PasswordHashing::costBenchmark(); $orga_preferences['system_hashing_cost'] = $benchmarkResults['cost']; // create all necessary data for this organization $gCurrentOrganization->setPreferences($orga_preferences, false); $gCurrentOrganization->createBasicData($webmaster->getValue('usr_id')); // create default room for room module in database $sql = 'INSERT INTO ' . TBL_ROOMS . ' (room_name, room_description, room_capacity, room_usr_id_create, room_timestamp_create) VALUES (\'' . $gL10n->get('INS_CONFERENCE_ROOM') . '\', \'' . $gL10n->get('INS_DESCRIPTION_CONFERENCE_ROOM') . '\',