Exemple #1
0
function saveSettingsExe()
{
    if (!is_numeric($_SESSION['userId'])) {
        addError("Not permited");
        redirect("../editor.php");
        exit(0);
    }
    $delegate = new Delegate();
    $user = $delegate->userGetById($_SESSION['userId']);
    //    print_r($user);
    //    exit();
    //    $name = trim($_POST['name']);
    $currentPassword = trim($_POST['currentPassword']);
    $newPassword = trim($_POST['newPassword']);
    //    if (strlen($name) >= 2) {
    //        $user->name = $name;
    //    }
    if (strlen($currentPassword) > 0) {
        //we want to change the password
        if (!strlen($newPassword) >= 4) {
            addError("New password too short or empty");
        }
        if (md5($currentPassword) != $user->password) {
            addError("Current password is wrong");
        } else {
            $user->password = md5($newPassword);
        }
    }
    if (errors()) {
        #print "Errors"; exit(0);
        redirect("../settings.php");
        exit(0);
    }
    if ($delegate->userUpdate($user)) {
        addMessage("Settings saved!");
        redirect("../settings.php");
        exit(0);
    } else {
        addError("Settings not saved (or nothing to save)");
        redirect("../settings.php");
        exit(0);
    }
}
Exemple #2
0
function closeQuickStart()
{
    if (!is_numeric($_SESSION['userId'])) {
        print "Wrong way";
        exit;
    }
    $delegate = new Delegate();
    $user = $delegate->userGetById($_SESSION['userId']);
    $user->tutorial = 0;
    $delegate->userUpdate($user);
    newDiagramExe();
}