}
    }
    // ------------------
    if (!$error) {
        $page->setUILanguage($language);
        if ($change) {
            // existing user
            $user->realname = $realname;
            $user->language = $language;
            $user->email = $email;
            $user->save($password);
        } else {
            // new user
            $error = sotf_User::register($password, $username, $realname, $language, $email);
            if (!$error) {
                $error = sotf_User::login($username, $password);
            }
            if ($error) {
                $smarty->assign('ERRORMSG', $error);
            }
        }
        if (!$error) {
            if ($okURL) {
                $page->redirect($okURL);
            } else {
                $page->redirect('index.php');
            }
            exit;
        }
    }
} elseif (isset($user)) {
Exemple #2
0
////////////////////////// Test 8
$id = 8;
if (RunTest($id, "Node administrator", 7)) {
    dbug("TEST 8");
    require_once "../init.inc.php";
    // this will most probably cause an error if the connector class is configured properly!
    $res = sotf_User::findUsers("a");
    $res = NULL;
    $adminId = $db->getOne("SELECT user_id FROM sotf_user_permissions WHERE object_id='node' AND permission_id='1'");
    if (!$adminId && $admin_name && $admin_pass) {
        if (!sotf_User::getUserid($admin_name)) {
            // let's register the new admin user
            $error = sotf_User::register($admin_pass, $admin_name, '', 'en', '');
        }
        if (!$error) {
            $error = sotf_User::login($admin_name, $admin_pass);
        }
        if ($error) {
            $install_test_result[$id] = "Invalid username or password";
            $install_color[$id] = $install_red;
            //trigger_error("Invalid username or password");
        } else {
            $aid = $user->id;
            $count = $db->getOne("SELECT count(*) FROM sotf_user_permissions WHERE user_id='{$aid}' AND object_id='node' AND permission_id='1'");
            if ($count == 0) {
                $db->query("INSERT INTO sotf_user_permissions (object_id, user_id, permission_id) VALUES('node',{$aid},1)");
            }
            $count = $db->getOne("SELECT count(*) FROM sotf_user_prefs WHERE id='{$aid}' OR username='******'");
            if ($count == 0) {
                $db->query("INSERT INTO sotf_user_prefs (id,username) VALUES({$aid}, '{$admin_name}')");
            }