<?php 
    # $Id: user_CHANGE.php,v 1.2 2007/01/08 12:51:13 jarda Exp $

    /* Page that changes data of a user account
    */

    require_once('simplePage.inc.php'); 

    class PageClass extends EditUserAccountsSimplePage
    {

        function checkEnvironment()
        {
            if (!$_POST['OK'])
                return True;

            if (!$_POST['userId'])
                return False;

            return True;
        }


        function handleInvalidEnvironment()
        {
            header("Location: users_LISTING.php"); /* Redirect browser */
        }


        function createPage()
        {
            if (!$_POST['OK'])
            {
                header("Location: index.php"); /* Redirect browser */ 
                exit();
            }

            $userId = $_POST['userId'];
            $password = $_POST['password'];
            $canEditDB = $_POST['canEditDB'] ? 1 : 0;
            $canEditUserAccounts = $_POST['canEditUserAccounts'] ? 1 : 0;
            $canChangeOwnPassword = $_POST['canChangeOwnPassword'] ? 1 : 0;

            $db = connect();
            
            $query = "UPDATE bDbUser " .
                     "SET canEditDatabase = $canEditDB, canEditUserAccounts = $canEditUserAccounts, canChangeOwnPassword = $canChangeOwnPassword";

            if ($password)
                $query = $query . ", password = '$password'";

            $query = $query . " WHERE id = $userId";

            $db->Execute($query);

            header("Location: users_LISTING.php"); /* Redirect browser */ 
        }
    }

    launchPage();
    
    # vim:enc=iso8859-2:fenc=iso8859-2:
?>
