Ejemplo n.º 1
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->m_sGebruikersNaam = '';
     $this->m_sWachtwoord = '';
     $this->m_bLoggedIn = false;
     $this->m_aRechten = array();
     // controleer of gebruiker al is ingelogd
     $oValidator = InputValidator::instantiate();
     $oValidator->addValidation('gebruiker_id', InputValidator::SCOPE_SESSION, InputValidator::TYPE_INT, true);
     $oValidator->addValidation('gebruiker', InputValidator::SCOPE_SESSION, InputValidator::TYPE_STRING, true);
     $oValidator->addValidation('ingelogd', InputValidator::SCOPE_SESSION, InputValidator::TYPE_BOOLEAN, true);
     $oValidator->addValidation('rechten', InputValidator::SCOPE_SESSION, InputValidator::TYPE_ARRAY, true);
     if ($oValidator->ValidateAll() == InputValidator::RESULT_OK) {
         $this->m_nId = $oValidator->getValue('gebruiker_id', InputValidator::SCOPE_SESSION);
         if ($this->m_nId > 0) {
             $this->m_sGebruikersNaam = $oValidator->getValue('gebruiker', InputValidator::SCOPE_SESSION);
             $this->m_bLoggedIn = $oValidator->getValue('ingelogd', InputValidator::SCOPE_SESSION);
             $this->m_aRechten = $oValidator->getValue('rechten', InputValidator::SCOPE_SESSION);
             // haal de persoongegevens op
             $this->laadGegevens($this->m_nId);
         }
     }
     // leeg de lijst met validatie variabelen zodat validator schoon gebruik kan worden
     $oValidator->clearValidation();
 }
Ejemplo n.º 2
0
 /**
  * handlePagina	controleer of er inloggegevens zijn gepost, zo ja, log in en redirect naar homepage
  * @throws WebsiteException
  */
 public function handlePagina()
 {
     // standaard wordt dit scherm getoond
     $oResult = $this;
     if (Registry::exists('Bezoeker')) {
         $oGebruiker = Registry::get('Bezoeker');
     } else {
         // gebruiker moet al bestaan, dus fout
         throw new WebsiteException('Gebruiker object bestaat niet');
     }
     if (!$oGebruiker->isIngelogd()) {
         // gebruiker was nog niet ingelogd
         $oValidator = InputValidator::instantiate();
         $oValidator->addValidation('gebruiker', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         $oValidator->addValidation('wachtwoord', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         if ($oValidator->validateAll() == InputValidator::RESULT_OK) {
             // inloggegevens gepost
             if ($oGebruiker->login($oValidator->getValue('gebruiker', InputValidator::SCOPE_POST), $oValidator->getValue('wachtwoord', InputValidator::SCOPE_POST))) {
                 // login gelukt
                 $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
             }
         }
     } else {
         // gebruiker was al eerder ingelogd, ga naar homepage
         $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
     }
     return $oResult;
 }
Ejemplo n.º 3
0
 /**
  * handlePagina Handelt de gegeven pagina af
  * 
  * Deze methode controleert of de juiste invoer is gegeven en handelt de pagina verder af
  * Er wordt een gebruikerobject gemaakt dat de gegevens van de huidige gebruiker bevat.
  * @return void
  */
 public function handlePagina()
 {
     try {
         // vang alle fouten af
         // creeer een Gebruiker object
         $this->m_oGebruiker = new Gebruiker();
         // plaats de gebruiker in de Registry zodat andere objecten deze kunnen gebruiken
         Registry::add($this->m_oGebruiker, 'Bezoeker');
         // creeer de inputvalidator
         $oValidator = InputValidator::instantiate();
         $nResult = $oValidator->validate('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST, InputValidator::TYPE_INT, true);
         if ($nResult == InputValidator::RESULT_OK || $nResult == InputValidator::RESULT_CONVERTABLE) {
             // pagina bestaat in GET of POST
             $nPagina = intVal($oValidator->getValue('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST));
             // maak het juiste Scherm object aan
             $oScherm = SchermGenerator::genereerSchermObject($nPagina);
         } else {
             // geen pagina opgegeven, ga naar homepage
             $oScherm = SchermGenerator::genereerSchermObject(SchermGenerator::WELKOM);
         }
     } catch (Exception $e) {
         // iets is fout gegaan, log uit en toon homepage
         if (is_object($this->m_oGebruiker)) {
             $this->m_oGebruiker->logout();
         }
         // zet exception in de registry zodat de errorpage de info kan tonen
         Registry::add($e, 'Exception');
         $oScherm = SchermGenerator::genereerSchermObject(SchermGenerator::ERRORPAGE);
     }
     if (is_object($oScherm)) {
         // handel eventuele input af
         $oScherm = $oScherm->handlePagina();
         // bouw het scherm met de juiste informatie en toon het
         $oScherm->bouwScherm();
         $oScherm->toon();
     } else {
         // geen scherm object, heel erg fout.
         echo 'Er is geen scherm-object aangemaakt/of ontbreekt.';
     }
 }
Ejemplo n.º 4
0
 /**
  * constructor
  * Deze constructor controleert of de gebruiker is ingelogd, is dat het geval,
  * dan wordt het ingelogde menu gecreeerd. Als de gebruiker de rechten admin heeft,
  * wordt het adminmenu gecreeerd.
  * @param string $p_sTitel De getoonde titel op het scherm
  * @param array $p_aRechten array bevat alle benodigde rechten om deze pagina op te roepen. Een lege array 
  * @throws InsufficientRightsException
  */
 public function __construct($p_sTitel, $p_aRechten)
 {
     $this->m_sTitel = $p_sTitel;
     $this->m_sHTML = '';
     $this->m_aData = array();
     $this->m_aScripts = array();
     $this->m_oSmarty = null;
     $this->m_sTemplate = '';
     if (is_array($p_aRechten)) {
         $this->m_aBenodigdeRechten = $p_aRechten;
     } else {
         $this->m_aBenodigdeRechten = array(Gebruiker::TOEGANG_GEWEIGERD);
     }
     // genereer het menu aan de hand van de gebruikerrechten
     if (Registry::exists('Bezoeker')) {
         $this->m_oGebruiker = Registry::get('Bezoeker');
         if ($this->m_oGebruiker->isIngelogd()) {
             $oValidator = InputValidator::instantiate();
             $nPagina = intVal($oValidator->getValue('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST));
             if ($nPagina >= MenuGenerator::BEHEER) {
                 $aRechten = $this->m_oGebruiker->__get('Rechten');
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEHEER, $aRechten);
                 if (!$this->checkRechten()) {
                     // genereer een Exception zodat dit scherm nooit per ongeluk getoond kan worden
                     throw new OnvoldoendeRechtenException('Pagina ' . $p_sTitel);
                 }
             } else {
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
             }
         } else {
             $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
         }
     } else {
         $this->m_oGebruiker = null;
     }
 }