Exemple #1
0
function do_install()
{
    global $path_to_root, $db_connections, $def_coy, $installed_extensions, $tb_pref_counter, $dflt_lang, $installed_languages;
    $coa = $_SESSION['inst_set']['coa'];
    if (install_connect_db() && db_import($path_to_root . '/sql/' . $coa, $_SESSION['inst_set'])) {
        $con = $_SESSION['inst_set'];
        $table_prefix = $con['tbpref'];
        $def_coy = 0;
        $tb_pref_counter = 0;
        $db_connections = array(0 => array('name' => $con['name'], 'host' => $con['host'], 'dbuser' => $con['dbuser'], 'dbpassword' => $con['dbpassword'], 'dbname' => $con['dbname'], 'tbpref' => $table_prefix));
        $_SESSION['wa_current_user']->cur_con = 0;
        update_company_prefs(array('coy_name' => $con['name']));
        $admin = get_user_by_login('admin');
        update_user_prefs($admin['id'], array('language' => $con['lang'], 'password' => md5($con['pass']), 'user_id' => $con['admin']));
        if (!copy($path_to_root . "/config.default.php", $path_to_root . "/config.php")) {
            display_error(_("Cannot save system configuration file 'config.php'."));
            return false;
        }
        $err = write_config_db($table_prefix != "");
        if ($err == -1) {
            display_error(_("Cannot open 'config_db.php' configuration file."));
            return false;
        } else {
            if ($err == -2) {
                display_error(_("Cannot write to the 'config_db.php' configuration file."));
                return false;
            } else {
                if ($err == -3) {
                    display_error(_("Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step."));
                    return false;
                }
            }
        }
        // update default language
        if (file_exists($path_to_root . "/lang/installed_languages.inc")) {
            include_once $path_to_root . "/lang/installed_languages.inc";
        }
        $dflt_lang = $_POST['lang'];
        write_lang();
        return true;
    }
    return false;
}
Exemple #2
0
}
//-------------------------------------------------------------------------------------------------
if (($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') && check_csrf_token()) {
    if (can_process()) {
        if ($selected_id != -1) {
            update_user_prefs($selected_id, get_post(array('user_id', 'real_name', 'phone', 'email', 'role_id', 'language', 'print_profile', 'rep_popup' => 0, 'pos')));
            if ($_POST['password'] != "") {
                update_user_password($selected_id, $_POST['user_id'], md5($_POST['password']));
            }
            display_notification_centered(_("The selected user has been updated."));
        } else {
            add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']), $_POST['phone'], $_POST['email'], $_POST['role_id'], $_POST['language'], $_POST['print_profile'], check_value('rep_popup'), $_POST['pos']);
            $id = db_insert_id();
            // use current user display preferences as start point for new user
            $prefs = $_SESSION['wa_current_user']->prefs->get_all();
            update_user_prefs($id, array_merge($prefs, get_post(array('print_profile', 'rep_popup' => 0, 'language'))));
            display_notification_centered(_("A new user has been added."));
        }
        $Mode = 'RESET';
    }
}
//-------------------------------------------------------------------------------------------------
if ($Mode == 'Delete' && check_csrf_token()) {
    $cancel_delete = 0;
    if (key_in_foreign_table($selected_id, 'audit_trail', 'user')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this user because entries are associated with this user."));
    }
    if ($cancel_delete == 0) {
        delete_user($selected_id);
        display_notification_centered(_("User has been deleted."));