Subversion-Projekte lars-tiefland.ci

Revision

Revision 573 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

/**
 *
 * @package WebanOS CI
 * @author Lars Tiefland <ltiefland@gmail.com> 
 * @copyright 2016
 * @version $Rev: 573 $
 */

/**
 * Login
 * 
 * @package WebanOS CI
 * @author Lars Tiefland
 * @copyright 2016
 * @version $Id: Login.php 573 2016-09-16 19:02:24Z lars $
 * @access public
 */
class Login extends CI_Controller
{
        /**
         * Login::__construct()
         * 
         * @return
         */
        public function __construct()
        {
                parent::__construct();
                $GLOBALS['order_db'] = $this->load->database('order_db', TRUE);
                $GLOBALS['db_red'] = $this->load->database('db_red', TRUE);
                $this->load->model('login_model', 'login');
                $this->smarty->assign('aktiverTab', 3);
        }

        public function index()
        {
                $this->smarty->view('login_center.tpl');
        }

        /**
         * Login::login()
         * 
         * @return
         */
        public function login()
        {
                $this->form_validation->set_rules('email', 'Username',
                        'required|trim|valid_email');
                $this->form_validation->set_rules('password', 'Password', 'required');
                if ($this->form_validation->run() == FALSE)
                {
                        $errors = validation_errors();
                        $this->smarty->assign('errors', $errors);
                        $this->smarty->view('login_center.tpl');
                }
                else
                {
                        $res = $this->login->check();
                        if ($res['error'])
                        {
                                $this->smarty->assign('login', $res);
                                $this->smarty->view('login_meld.tpl');
                        }
                        else
                        {
                                $_SESSION['SHOP']['buy']['Persdata'] = $res['data'];
                                $_SESSION['SHOP']['Login'] = true;
                                $ret['msg'] = nl2br(sprintf($GLOBALS['langstrings']['login']['login_success'], $_SESSION["SHOP"]['buy']['Persdata']['Vorname'],
                                        $_SESSION["SHOP"]['buy']['Persdata']['Nachname']));

                                $this->smarty->assign("login", $ret);
                                $this->smarty->view("login_meld.tpl");


                                if (isset($_POST['return']) && $_POST["return"] == "true" && $res["error"] === false)
                                {
                                        header("Location: /order.html");
                                }
                        }
                }
        }

        public function logout()
        {
                unset($_SESSION['SHOP']['buy']['Persdata']);
                unset($_SESSION['SHOP']['Login']);
                $this->smarty->view('logout.tpl');
        }

        /**
         * Login::save()
         * 
         * @return
         */
        public function save()
        {
                $this->login->create();
        }
}

?>