<?php

class UserController
{
    function __construct()
    {
        try {
            global $dsn, $rep, $vues, $error;
            $model = new UserModel();
            $action = $_REQUEST['action'];
            //register_event_handler('add_to_queue',array($this,"onAddToQueue"));
            switch ($action) {
                case NULL:
                    $model->goToHome();
                    break;
                case "goToPresentation":
                    $model->goToPresentation();
                    break;
                case "goToHome":
                    $model->goToHome();
                    break;
                case "goToTest":
                    $model->goToTest();
                    break;
                case "goToEnigme":
                    $model->goToEnigme();
                    break;
                case "goToChouette" :
                    $model->goToChouette();
                    break;
                case "goToCesarEncrypt":
                    $model->goToCesarEncrypt();
                    break;
                case "goToCesarDecrypt":
                    $model->goToCesarDecrypt();
                    break;
                case "goToChuckNorris" :
                    $model->goToChuckNorris();
                    break;
                case "goToHanoi" :
                    $model->goToHanoi();
                    break;
                case "goToTrianglePascal":
                    $model->goToTrianglePascal();
                    break;
                case "goToQueue":
                    $model->goToQueue();
                    break;
                case "goToNext":
                    $model->goToNext();
                    break;
                case "logout":
                    $model->logout();
                    break;
                default:
                    $error = "Action non valide";
                    require($rep . $vues['erreur']);
                    break;
            }
        } catch (PDOException $e) {
            $error = $e->getMessage();
            require($rep . $vues['erreur']);
        } catch (Exception $e2) {
            $error = $e2->getMessage();
            require($rep . $vues['erreur']);
        }
    }
    public function onAddToQueue(){
        $model=new UserModel;
        $model->AddUserToQueueEvent();
        $this->goToMulti();
    }

    /*public function goToMulti(){

    }*/
}