<?
class admin_dialog extends base_dialog {


    function makeData() {
        parent::makeData();

        $this->is_logged = $_SESSION["is_logged"] == "1";
        $this->logged_as = $_SESSION["email"];
    }





    function processLogin($email, $password) {
        $sql = "
            SELECT
                `type`, `email`
            FROM
                jaws_users
            WHERE
                email = %un% AND
                password = %password%";
        $res = $this->db->get_first($sql, array("un" => $email, 
                                                "password" => $password) );
        if($res["type"] == "1") {
            $_SESSION["is_logged"] = 1;
            $_SESSION["email"] = $res["email"];
            $this->is_logged = true;
        } else {
            $this->login_error = true;
        }
    }


    function action_login() {
        $this->processLogin($_REQUEST["un"], $_REQUEST["pwd"]);
    }


    function action_logout() {
        unset($_SESSION["email"]);
        unset($_SESSION["is_logged"]);
        $this->is_logged = false;
        $this->show_logout_ok = true;
    }

}
?>