/**
  * Initialize the user session information.
  */
 function init()
 {
     try {
         // Make sure the session has been created.
         if (!isset(self::$cachedSession)) {
             self::$cachedSession = new Zend_Session_Namespace('Web');
         }
     } catch (Zend_Session_Exception $ex) {
         // Log the error.
         Logger::getLogger()->debug("Zend_Session_Exception" . $ex->getMessage());
     }
     // Get the session.
     $session = self::$cachedSession;
     // Fix the request.
     self::fixRequest($this->getRequest());
     // Get the request URI.
     $requestUri = $this->getRequest()->getRequestUri();
     // Write a log of this page request.
     if (isset($session->employee)) {
         Logger::getLogger()->info("Request [" . $session->employee->login . "]: " . $requestUri);
     } else {
         Logger::getLogger()->info("Request [guest]: " . $requestUri);
     }
     // Wrap the whole thing in a try/catch.
     try {
         // Check to see if the user is trying to access an admin page.
         if (preg_match("/^\\/admin/i", $requestUri)) {
             // Make sure the employee is an administrator.
             if (!isset($session->employee) || !$session->employee->admin) {
                 // Redirect to the home page.
                 $this->_helper->redirector('index', 'index', 'default');
             }
         } else {
             if (preg_match("/^\\/manager/i", $requestUri)) {
                 // Make sure the employee is a manager.
                 if (!isset($session->employee) || !$session->employee->manager) {
                     // Redirect to the home page.
                     $this->_helper->redirector('index', 'index', 'default');
                 } else {
                     // Set the manage layout.
                     $this->_helper->layout->setLayout('manage');
                 }
             } else {
                 if (preg_match("/^\\/payroll/i", $requestUri)) {
                     // Make sure the employee is in payroll.
                     if (!isset($session->employee) || !$session->employee->payroll) {
                         // Redirect to the home page.
                         $this->_helper->redirector('index', 'index', 'default');
                     } else {
                         // Set the manage layout.
                         $this->_helper->layout->setLayout('manage');
                     }
                 } else {
                     if (preg_match("/^\\/supervisor/i", $requestUri)) {
                         // Make sure the employee is a supervisor.
                         if (!isset($session->employee) || !$session->employee->supervisor) {
                             // Redirect to the home page.
                             $this->_helper->redirector('index', 'index', 'default');
                         } else {
                             // Set the manage layout.
                             $this->_helper->layout->setLayout('manage');
                         }
                     } else {
                         if (preg_match("/^\\/user/i", $requestUri)) {
                             // Make sure the employee is logged in.
                             if (!isset($session->employee)) {
                                 // Redirect to the home page.
                                 $this->_helper->redirector('index', 'index', 'default');
                             }
                         }
                     }
                 }
             }
         }
         // Set the pay period in the session.
         if (!isset($session->payPeriod)) {
             // Save the current pay period to the session.
             $payPeriodDao = new PayPeriodDao();
             $session->payPeriod = $payPeriodDao->getCurrent();
             // Make sure the pay period was found.
             if (!isset($session->payPeriod)) {
                 // Make sure all the pay periods exist in the database,
                 // then retrieve the current pay period.
                 $session->payPeriod = $payPeriodDao->addThroughCurrent();
             }
         }
     } catch (Zend_Exception $ex) {
         // Log the exception.
         Logger::getLogger()->debug("Base Controller Error: " . $ex->getMessage());
     }
     // Save the pay period to the view.
     $this->view->payPeriod = $session->payPeriod;
     // Save the employee to the view.
     $this->view->employee = $session->employee;
 }