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

    /* Page that adds a new user account
    */

    require_once('simplePage.inc.php'); 

    class PageClass extends EditUserAccountsSimplePage
    {

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

            if (!$_POST['login'] || !$_POST['password'])
                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();
            }

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

            $db = connect();
            
            $query = "INSERT INTO bDbUser " .
                     "(login, password, canEditDatabase, canEditUserAccounts, canChangeOwnPassword) " .
                     "VALUES ('$login', '$password', $canEditDB, $canEditUserAccounts, $canChangeOwnPassword)";

            $db->Execute($query);

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

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