Controllers
[ class tree: Controllers ] [ index: Controllers ] [ all elements ]

Source for file logon.php

Documentation is available at logon.php

  1. <?php //if (empty($_SESSION['RG']['Retreat'])) { display_error_page('session_expired'); }
  2. /**
  3.  * <b>Class Description</b>: controller class for login screen.
  4.  * Created On: 30 March 2009
  5.  * @author Jan van der Breggen
  6.  * @package Controllers
  7.  * @subpackage RetreatRegistrationControllers
  8.  * @see controllersPackage.php
  9.  * @todo gather requirements and implement functionality
  10.  ***/ 
  11.  
  12. class Logon extends MainScreen
  13. {
  14.     public $View = array();
  15.     public $localUsers;
  16.     /*-----------------------------------------------------------------------------*/
  17.     /* Logon - Display the form                                                    */
  18.     /*-----------------------------------------------------------------------------*/
  19.     function index($ErrorMsg '')
  20.     {
  21.        $this->_init('','',false);
  22.         $this->View['text_to_display'=  $GLOBALS['lang']['title_logon'];
  23.         $this->setPackageInfo("RetreatRegistrationControllers");
  24.         /**
  25.          * Display the page
  26.          */
  27.         // If exists, display the error message
  28.         if (!empty($ErrorMsg))
  29.         {
  30.             $this->View['error_message_logon'$ErrorMsg;
  31.         }
  32.  
  33.         // Display in the email field the last email saved in the session
  34.         // Its for the usability only.
  35.         if (empty($_POST['email']and !empty($_SESSION['RG']['USER']['Email']))
  36.         {
  37.             $_POST['email'$_SESSION['RG']['USER']['Email'];
  38.         elseif (!empty($_POST['email']and empty($ErrorMsg))
  39.             {
  40.                 $_SESSION['RG']['USER']['Email'$_POST['email'];
  41.             }
  42.  
  43.         // Display the email after the post
  44.         if (!empty($_POST['email'])) {
  45.  
  46.             $this->View['logon_email'$_POST['email'];
  47.         }
  48.  
  49.         // Display the page
  50.  
  51.         $this->View['page_to_display''logon';
  52.         display_view('view_template_mainscreen'$this->View);
  53.  
  54.     }
  55.  
  56.  
  57.     /*-----------------------------------------------------------------------------*/
  58.     /* Logon - Form verification                                                   */
  59.     /*-----------------------------------------------------------------------------*/
  60.     function verification()
  61.     {
  62.         /**
  63.          *  * Set the rules to validate the data
  64.          */
  65.  
  66.  
  67.         $Rules['email''trim|required|valid_email';
  68.         $Rules['password''required';
  69.  
  70.         $Names['email'$GLOBALS['lang']['label_your_email'];
  71.         $Names['password'$GLOBALS['lang']['label_rigpa_password'];
  72.  
  73.         $valid new Validation_Old();
  74.         $ErrorMsg $valid->valid($Rules$Names);
  75.         
  76.         //$authentication = new model_students();
  77.  
  78.         /*
  79.         * load the local user file
  80.         */
  81.         $this->localUsers = $this->_loadLocalUsers();
  82.  
  83.         /**
  84.          * Logon verification
  85.          */
  86.         if (empty($ErrorMsg))
  87.         {
  88.  
  89.             $Data $this->_checkAcl($_POST['email']$_POST['password']);
  90.  
  91.             /**
  92.              * Check for logon in the database
  93.              */
  94.             if (empty($Data['local_key']))
  95.             {
  96.                 
  97.                 $Data $authentication->selectLogon($_POST['email']$_POST['password']);
  98.             }
  99.  
  100.  
  101.             /**
  102.              * If logon wrong, display an error message.
  103.              */
  104.             if (empty($Data['local_key']))
  105.             {
  106.                 $ErrorMsg $GLOBALS['lang']['error_unknow_logon'];
  107.             else {
  108.                 $_SESSION['RG']['USER']['id']        $Data['local_key'];
  109.                 $_SESSION['RG']['USER']['Email']     $_POST['email'];
  110.                 $_SESSION['RG']['USER']['FirstName'$Data['first_name'];
  111.                 $_SESSION['RG']['USER']['LastName']  $Data['last_name'];
  112.                 $_SESSION['RG']['USER']['Roles''roles here';//$authentication->getRoles($Data['local_key']);
  113.                $_SESSION['Object']serialize(new User($Data['local_key'],$Data['first_name'],
  114.                $Data['last_name'],$_POST['email'],$_SESSION['RG']['USER']['Roles']));
  115.                 $x new externalDataServerConnection();
  116.                 $x->refreshLocalData();
  117.                 redirect('applicationSetupOne');
  118.             }
  119.         }
  120.  
  121.  
  122.         /**
  123.          * If errors occurred, display it
  124.          */
  125.         if (!empty($ErrorMsg)) {
  126.             $ErrorMsg '<ul class="error_message">' $ErrorMsg '</ul>';
  127.             $this->index($ErrorMsg);
  128.         }
  129.     }
  130.  
  131.  
  132.     function _checkAcl($user$pwd)
  133.     {
  134.         if (array_key_exists($user$this->localUsers)) {
  135.             if ($this->localUsers[$user== $pwd{
  136.                 return array('local_key' => -1
  137.                              'Email' => $user
  138.                              'first_name' => "admin"
  139.                              'last_name' => "admin");
  140.             }
  141.  
  142.         }
  143.  
  144.         return array();
  145.     }
  146.  
  147.     function _loadLocalUsers()
  148.     {        
  149.         $tok strtok(str_replace("\n"
  150.             ""
  151.             file_get_contents(PATH_CONF "/acl.txt")),
  152.             ";");
  153.         $config array();
  154.         while ($tok !== false)
  155.         {
  156.             $cf explode(","$tok);
  157.             $config[$cf[0]] $cf[1];
  158.             $tok strtok(";");
  159.         }
  160.         return $config;
  161.     }
  162. }
  163. ?>

Documentation generated on Mon, 18 May 2009 11:22:06 +0200 by phpDocumentor 1.4.1