Überarbeitete MVC-Struktur, die ich jetzt auch nachvollziehen kann.
authorMarkus Bröker <broeker.markus@googlemail.com>
Fri, 13 Nov 2015 03:24:01 +0100
changeset 7 3ed6f90e97d9
parent 6 6c23ee543e0e
child 8 54ea0099329c
Überarbeitete MVC-Struktur, die ich jetzt auch nachvollziehen kann.
.idea/TicketSystem.iml
.idea/encodings.xml
classes/bfw/Dispatcher.php
classes/bfw/Request.php
classes/bfw/Response.php
classes/bfw/core/Controller.php
classes/bfw/core/Entity.php
classes/bfw/core/Model.php
classes/bfw/core/View.php
classes/bfw/database/DBInterface.php
classes/bfw/database/Database.php
classes/bfw/entities/TGroup.php
classes/bfw/entities/TUser.php
classes/bfw/entities/TView.php
classes/bfw/mvc/common/Controller.php
classes/bfw/mvc/common/Model.php
classes/bfw/mvc/common/View.php
classes/bfw/mvc/controller/BenutzerverwaltungController.php
classes/bfw/mvc/controller/DokumentationController.php
classes/bfw/mvc/controller/ErrorController.php
classes/bfw/mvc/controller/HistoryController.php
classes/bfw/mvc/controller/HomeController.php
classes/bfw/mvc/controller/TicketsController.php
classes/bfw/mvc/model/TAction.php
classes/bfw/mvc/model/TGroup.php
classes/bfw/mvc/model/THistory.php
classes/bfw/mvc/model/TStatus.php
classes/bfw/mvc/model/TText.php
classes/bfw/mvc/model/TTicket.php
classes/bfw/mvc/model/TUser.php
classes/bfw/mvc/model/TView.php
classes/bfw/mvc/model/benutzerverwaltung/Model.php
classes/bfw/mvc/model/dokumentation/Model.php
classes/bfw/mvc/model/error/Model.php
classes/bfw/mvc/model/home/Model.php
classes/bfw/mvc/view/benutzerverwaltung/abmelden.tpl
classes/bfw/mvc/view/benutzerverwaltung/anmelden.tpl
classes/bfw/mvc/view/benutzerverwaltung/index.tpl
classes/bfw/mvc/view/benutzerverwaltung/meinprofil.tpl
classes/bfw/mvc/view/benutzerverwaltung/registrieren.tpl
classes/bfw/mvc/view/benutzerverwaltung/resetpasswort.tpl
classes/bfw/mvc/view/dokumentation/index.tpl
classes/bfw/mvc/view/error/index.tpl
classes/bfw/mvc/view/footer.tpl
classes/bfw/mvc/view/header.tpl
classes/bfw/mvc/view/home/index.tpl
classes/bfw/mvc/view/layout.tpl
config/config.php
data/import/test_tickets.csv
js/main.js
library/smarty/libs/Autoloader.php
library/smarty/libs/plugins/function.html_select_date.php
library/smarty/libs/plugins/shared.escape_special_chars.php
library/smarty/libs/sysplugins/smarty_internal_compile_include.php
templates/benutzerverwaltung/abmelden.tpl
templates/benutzerverwaltung/anmelden.tpl
templates/benutzerverwaltung/index.tpl
templates/benutzerverwaltung/meinprofil.tpl
templates/benutzerverwaltung/registrieren.tpl
templates/benutzerverwaltung/resetpasswort.tpl
templates/error/index.tpl
templates/footer.tpl
templates/header.tpl
templates/history/index.tpl
templates/home/index.tpl
templates/layout.tpl
templates/tickets/index.tpl
templates/tickets/ticketanlegen.tpl
--- a/.idea/TicketSystem.iml
+++ b/.idea/TicketSystem.iml
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="WEB_MODULE" version="4">
   <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/classes" isTestSource="false" />
+    </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/classes/bfw/mvc/view/error/index.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/classes/bfw/mvc/view/footer.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/classes/bfw/mvc/view/header.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/classes/bfw/mvc/view/home/index.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/classes/bfw/mvc/view/layout.tpl" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/config/config.php" charset="UTF-8" />
     <file url="file://$PROJECT_DIR$/css/main.css" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltungs/abmelden.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltungs/anmelden.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltungs/benutzerverwaltung.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltungs/meinprofil.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltungs/registrieren.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/error/error.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/footer.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/header.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/home/home.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/layout.tpl" charset="UTF-8" />
-    <file url="file://$PROJECT_DIR$/templates/tickets/tickets.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltung/abmelden.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltung/anmelden.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltung/index.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltung/meinprofil.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/benutzerverwaltung/registrieren.tpl" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/templates/tickets/index.tpl" charset="UTF-8" />
     <file url="PROJECT" charset="UTF-8" />
   </component>
 </project>
\ No newline at end of file
--- a/classes/bfw/Dispatcher.php
+++ b/classes/bfw/Dispatcher.php
@@ -1,15 +1,16 @@
 <?php
 
-namespace bfw;
-
 /**
  * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
  *
  */
 
-use bfw\mvc\common\Controller;
-use bfw\mvc\common\View;
+namespace bfw;
+
+use bfw\core\Controller;
+use bfw\core\View;
 use ReflectionClass;
+use ReflectionException;
 
 class Dispatcher {
     private $request;
@@ -45,40 +46,33 @@
      *
      */
     public function getView() {
-        $controllerName = $this->request->get('controller');
-        $action = $this->request->get('action');
-
         $this->request->keepRequestData();
 
-        if ($controllerName == '') {
-            $controllerName = 'home';
-        }
+        $controllerName = $this->request->get('controller', 'home');
+        $action = $this->request->get('action', 'index');
+
+        $class = Controller::mapControllerName($controllerName);
+
+        try {
+            $reflection = new ReflectionClass($class);
+            $controller = $reflection->newInstance();
 
-        if ($action == '') {
+            // Mapping vom GET-Parameter 'action' auf Controller::$action()
+            if (!$reflection->hasMethod($action)) {
+                $action = 'index';
+            }
+        } catch (ReflectionException $e) {
+            $controller = new mvc\controller\ErrorController(new TView('NON_EXISTENT'));
+
+            $controllerName = 'error';
             $action = 'index';
         }
 
-        try {
-            $class = Controller::mapControllerName($controllerName);
-
-            $reflection = new ReflectionClass($class);
-            $controller = $reflection->newInstance();
-
-            $prefix = str_replace('bfw\mvc\controller\\', '', strtolower($class));
-            $controller->setPrefix(str_replace('controller', '', $prefix));
-
-            // Mapping vom GET-Parameter 'action' auf Controller::$action()
-            if ($reflection->hasMethod($action)) {
-                $controller->$action();
-            } else {
-                $controller->index();
-            }
-        } catch (Exception $e) {
-            $controller = new ErrorController(new TView('NON_EXISTENT'), $this->request);
-        }
+        $controller->$action();
 
         $view = new View($controller, $controller->getModel());
-        $view->assign('action', sprintf('%s/%s', $controller->getPrefix(), $action));
+        $view->assign('controller', $controllerName);
+        $view->assign('action', $action);
 
         return $view;
     }
--- a/classes/bfw/Request.php
+++ b/classes/bfw/Request.php
@@ -1,19 +1,22 @@
 <?php
 
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
 namespace bfw;
 
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\TUser;
 use Logger;
 
 /**
  * Class Request
  */
 class Request {
-    private static $logger = null;
+    protected $logger = null;
 
     public function __construct() {
-        self::$logger = Logger::getLogger('__CLASS__');
+        $this->logger = Logger::getLogger('__CLASS__');
 
         $this->initSession();
     }
@@ -29,10 +32,10 @@
                 'get' => array(),
                 'session' => array(),
                 'isLoggedIn' => false,
-                'user_id' => TUser::SYSTEM,
-                'group_id' => TGroup::GUEST,
-                'fehler' => 'Tickets for Free!',
-                'msg' => 'Tickets for Free!',
+                'user_id' => 1,
+                'group_id' => 1,
+                'error' => '',
+                'msg' => '',
                 'lastpage' => 'home',
             );
         }
@@ -53,17 +56,14 @@
      * @return string
      */
     public static function getBaseUrl() {
-        return sprintf("%s://%s",
-            isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
-            $_SERVER['SERVER_NAME']
-        );
+        return sprintf("%s://%s", isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', $_SERVER['SERVER_NAME']);
     }
 
     /**
      * <b>Liefert einen gefilterten 'session' Wert
      *
      * Hierbei handelt es sich um einen zuvor gespeicherten POST-Wert,
-     * der in ['prefix']['session'] geladet ist...
+     * der in ['prefix']['session'] gelandet ist...
      *
      * @param $param
      * @param string $default
@@ -197,16 +197,6 @@
     }
 
     /**
-     * <b>Liefert einen gefilterten POST-Wert</b>
-     *
-     * @param $param
-     * @return mixed|string
-     */
-    public function post($param) {
-        return filter_input(INPUT_POST, $param);
-    }
-
-    /**
      * <b>Setzt einen neuen Session Wert ins jeweilige Prefix</b>
      *
      * @param $key
@@ -228,7 +218,7 @@
      * @return string
      */
     public function printSession() {
-        self::$logger->info(sprintf('SESSION: %s', print_r($_SESSION['prefix'], true)));
+        $this->logger->info(sprintf('SESSION: %s', print_r($_SESSION['prefix'], true)));
 
         if ($this->get('debug') == '') {
             return '';
@@ -243,7 +233,29 @@
      * @param $param
      * @return string
      */
-    public function get($param) {
-        return filter_input(INPUT_GET, $param);
+    public function get($param, $default = '') {
+        $value = filter_input(INPUT_GET, $param);
+
+        if ($value == '') {
+            return $default;
+        }
+
+        return $value;
+    }
+
+    /**
+     * <b>Liefert einen gefilterten POST-Wert</b>
+     *
+     * @param $param
+     * @return string
+     */
+    public function post($param, $default = '') {
+        $value = filter_input(INPUT_POST, $param);
+
+        if ($value == '') {
+            return $default;
+        }
+
+        return $value;
     }
 }
\ No newline at end of file
--- a/classes/bfw/Response.php
+++ b/classes/bfw/Response.php
@@ -1,10 +1,12 @@
 <?php
 
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
 namespace bfw;
-/**
- * Response Headers sind kompliziert
- *
- */
+
 class Response {
     private $headers;
     private $statusCode;
rename from classes/bfw/mvc/common/Controller.php
rename to classes/bfw/core/Controller.php
--- a/classes/bfw/mvc/common/Controller.php
+++ b/classes/bfw/core/Controller.php
@@ -1,58 +1,52 @@
 <?php
 
-namespace bfw\mvc\common;
-
 /**
  * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
  *
  */
 
+namespace bfw\core;
+
 use bfw\Request;
 use bfw\Response;
+use Logger;
 
 /**
  *
  */
 abstract class Controller {
+    protected $logger = null;
     /**
      * @var Model
      */
     private $model;
-
     /**
      * @var Request
      */
     private $request;
-
     /**
      * @var Response
      */
     private $response;
-
     /**
      * @var View
      */
     private $view;
 
     /**
-     * @var
-     */
-    private $prefix;
-
-    /**
      * Controller constructor.
      *
      * @param Model $model
      * @param Request $request
      */
-    public function __construct(Model $model) {
+    public function __construct(Model $model = null) {
         $this->request = new Request();
         $this->response = new Response();
 
         $this->model = $model;
         $this->view = new View($this, $model);
 
-        $this->prefix = '';
+        $this->logger = Logger::getLogger(__CLASS__);
     }
 
     /**
@@ -108,28 +102,14 @@
     }
 
     /**
-     * @return string
-     */
-    public function getPage() {
-        if ($this->getPrefix() != '') {
-            return sprintf('%s/%s', $this->prefix, $this->request->get('action'));
-        }
-
-        return $this->request->get('action');
-    }
-
-    public function getPrefix() {
-        return $this->prefix;
-    }
-
-    public function setPrefix($prefix) {
-        $this->prefix = $prefix;
-
-        return $this;
-    }
-
-    /**
      *
      */
     abstract public function index();
+
+    protected function getModelName() {
+        $modelName = str_replace('controller', 'model', get_class($this));
+        $modelName = strtolower($modelName);
+
+        return str_replace('controller', '\Model', $modelName);
+    }
 }
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/core/Entity.php
@@ -0,0 +1,230 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\core;
+
+use bfw\database\Database;
+use Logger;
+
+/**
+ * Class Entity
+ *
+ * Entity besitzt einen State in $data
+ *
+ *
+ * @method string getId()
+ * @method setId($param)
+ */
+class Entity {
+    protected $logger = null;
+
+    protected $table;
+    protected $db;
+
+    protected $data;
+
+    /**
+     * @param $table
+     */
+    public function __construct($table) {
+        $this->logger = Logger::getLogger('__CLASS__');
+
+        $this->db = Database::getInstance();
+
+        $this->table = $table;
+        $this->data = array();
+    }
+
+    /**
+     * <b>Herzstück des Persistence-Frameworks</b>
+     *
+     * Dynamische Erzeugung von Getttern- und Settern
+     *
+     * Anstatt diese explizit zu pflegen und zu warten,
+     * werden Diese dynamisch, on, the fly, erzeugt.
+     *
+     * <b>Der Vorteil: Nicht Konfigurieren, nicht Erzeugen. Einfach Nutzen...</b>
+     *
+     * @param $methodName
+     * @param null $params
+     * @return $this
+     */
+    public function __call($methodName, $params = null) {
+        $prefix = substr($methodName, 0, 3);
+        $key = strtolower(substr($methodName, 3));
+
+        if ($prefix == 'set') {
+            $value = $params[0];
+
+            // no data, no state, null
+            if (!is_array($this->data)) {
+                return null;
+            }
+
+            $this->data[$key] = $value;
+
+            // fluent please!
+            return $this;
+
+        } else if ($prefix == 'get') {
+
+            // no data, no state, null
+            if (!is_array($this->data)) {
+                return null;
+            }
+
+            if (array_key_exists($key, $this->data)) {
+                return $this->data[$key];
+            }
+        }
+
+        exit(sprintf('Unbekannte Methode %s::%s(%s, %s) wurde aufgerufen.', get_class($this), $methodName, $key, $prefix));
+    }
+
+    /**
+     * <b>Vereinfachte Find Methode bezogen auf die jeweilige Instanz</b>
+     *
+     * @param $id
+     * @return Model
+     */
+    public function find($id) {
+        $this->logger->info(sprintf('%s(%d) ', __METHOD__, $id));
+
+        if (($this->data = $this->db->find($this->table, $id)) == null) {
+            return null;
+        }
+
+        return $this;
+    }
+
+    /**
+     * <b>Die Findall Methode erzeugt typsicher den Supertyp</b>
+     *
+     * @param bool|false $sys
+     * @return Model[]
+     */
+    public function findAll($sys = false) {
+        $this->logger->info(sprintf('%s() ', __METHOD__));
+
+        $initial_id = ($sys) ? 0 : 1;
+        $rows = $this->db->findAll($this->table, $initial_id);
+
+        if (count($rows) == 0) {
+            return array();
+        }
+
+        $list = array();
+        foreach ($rows as $row) {
+            $item = new static();
+            $item->data = $row;
+
+            $list[] = $item;
+        }
+
+        $this->logger->info(sprintf('%s(): %d', __METHOD__, count($list)));
+
+        return $list;
+    }
+
+    /**
+     * <b>Vereinfachte FindByField Methode</b>
+     *
+     * @param $field
+     * @param $value
+     * @return Model
+     */
+    public function findByField($field, $value) {
+        $this->logger->info(sprintf('%s(%s, %s) ', __METHOD__, $field, $value));
+
+        $this->data = $this->db->findByField($this->table, $field, $value);
+
+        // Keine Daten, keine Instanz
+        if ($this->data == null) {
+            return null;
+        }
+
+        return $this;
+    }
+
+    /**
+     * <b>Vereinfachte FindAllByField Methode</b>
+     *
+     * Erzeugt on the fly ein array mit dem Supertyp der Klasseninstanz
+     * @param $field
+     * @param $value
+     * @return Model[]
+     */
+    public function findAllByField($field, $value) {
+        $this->logger->info(sprintf('%s(%s, %s) ', __METHOD__, $field, $value));
+
+        $rows = $this->db->findAllByField($this->table, $field, $value);
+
+        if ($rows == null) {
+            return null;
+        }
+
+        $list = array();
+        foreach ($rows as $row) {
+            $item = new static();
+            $item->data = $row;
+
+            $list[] = $item;
+        }
+
+        return $list;
+    }
+
+    /**
+     * <b>Vereinfachte persist Methode</b>
+     *
+     * Der Logger loggt nur die Nutzdaten, deswegen sieht das im Log identisch aus.
+     *
+     * Es handelt sich allerdings einmal um ein Objekt und einmal nur um ein Array.
+     *
+     * @return bool
+     */
+    public function persist() {
+        $this->logger->info(sprintf('%s(%s)', __METHOD__, print_r($this->getData(), true)));
+
+        return $this->db->persist($this->table, $this->getData());
+    }
+
+    public function getData() {
+        return $this->data;
+    }
+
+    /**
+     * <b>Vereinfachte store Methode</b>
+     *
+     * @return bool
+     */
+    public function store() {
+        $this->logger->info(sprintf('%s(%d, %s)', __METHOD__, $this->getId(), print_r($this->getData(), true)));
+
+        if ($this->getId() > 1) {
+            return $this->db->store($this->table, $this->getId(), $this->getData());
+        }
+
+        return false;
+    }
+
+    /**
+     * <b>Vereinfachte delete Methode</b>
+     *
+     * @return bool
+     */
+    public function delete() {
+        $this->logger->info(sprintf('%s(%d) ', __METHOD__, $this->getId()));
+
+        if ($this->getId() > 1) {
+            return $this->db->delete($this->table, $this->getId());
+        }
+
+        return false;
+    }
+
+}
\ No newline at end of file
rename from classes/bfw/mvc/common/Model.php
rename to classes/bfw/core/Model.php
--- a/classes/bfw/mvc/common/Model.php
+++ b/classes/bfw/core/Model.php
@@ -1,226 +1,22 @@
 <?php
 
-namespace bfw\mvc\common;
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
 
-use bfw\database\Database;
+namespace bfw\core;
+
 use Logger;
 
 /**
  * Class Model
  *
- * Model besitzt einen State in $data
- *
- *
- * @method string getId()
- * @method setId($param)
  */
 class Model {
-    private static $logger = null;
-
-    protected $table;
-    protected $db;
-
-    protected $data;
-
-    /**
-     * @param $table
-     */
-    public function __construct($table) {
-        self::$logger = Logger::getLogger('__CLASS__');
-
-        $this->db = Database::getInstance();
-
-        $this->table = $table;
-        $this->data = array();
-    }
-
-    /**
-     * <b>Herzstück des Persistence-Frameworks</b>
-     *
-     * Dynamische Erzeugung von Getttern- und Settern
-     *
-     * Anstatt diese explizit zu pflegen und zu warten,
-     * werden Diese dynamisch, on, the fly, erzeugt.
-     *
-     * <b>Der Vorteil: Nicht Konfigurieren, nicht Erzeugen. Einfach Nutzen...</b>
-     *
-     * @param $methodName
-     * @param null $params
-     * @return $this
-     */
-    public function __call($methodName, $params = null) {
-        $prefix = substr($methodName, 0, 3);
-        $key = strtolower(substr($methodName, 3));
-
-        if ($prefix == 'set') {
-            $value = $params[0];
-
-            // no data, no state, null
-            if (!is_array($this->data)) {
-                return null;
-            }
-
-            $this->data[$key] = $value;
-
-            // fluent please!
-            return $this;
-
-        } else if ($prefix == 'get') {
-
-            // no data, no state, null
-            if (!is_array($this->data)) {
-                return null;
-            }
-
-            if (array_key_exists($key, $this->data)) {
-                return $this->data[$key];
-            }
-        }
-
-        exit(sprintf('Unbekannte Methode %s::%s(%s, %s) wurde aufgerufen.', get_class($this), $methodName, $key, $prefix));
-    }
-
-    /**
-     * <b>Vereinfachte Find Methode bezogen auf die jeweilige Instanz</b>
-     *
-     * @param $id
-     * @return Model
-     */
-    public function find($id) {
-        self::$logger->info(sprintf('%s(%d) ', __METHOD__, $id));
-
-        if (($this->data = $this->db->find($this->table, $id)) == null) {
-            return null;
-        }
-
-        return $this;
-    }
-
-    /**
-     * <b>Die Findall Methode erzeugt typsicher den Supertyp</b>
-     *
-     * @param bool|false $sys
-     * @return Model[]
-     */
-    public function findAll($sys = false) {
-        self::$logger->info(sprintf('%s() ', __METHOD__));
-
-        $initial_id = ($sys) ? 0 : 1;
-        $rows = $this->db->findAll($this->table, $initial_id);
-
-        if (count($rows) == 0) {
-            return array();
-        }
-
-        $list = array();
-        foreach ($rows as $row) {
-            $item = new static();
-            $item->data = $row;
-
-            $list[] = $item;
-        }
+    protected $logger = null;
 
-        self::$logger->info(sprintf('%s(): %d', __METHOD__, count($list)));
-
-        return $list;
-    }
-
-    /**
-     * <b>Vereinfachte FindByField Methode</b>
-     *
-     * @param $field
-     * @param $value
-     * @return Model
-     */
-    public function findByField($field, $value) {
-        self::$logger->info(sprintf('%s(%s, %s) ', __METHOD__, $field, $value));
-
-        $this->data = $this->db->findByField($this->table, $field, $value);
-
-        // Keine Daten, keine Instanz
-        if ($this->data == null) {
-            return null;
-        }
-
-        return $this;
-    }
-
-    /**
-     * <b>Vereinfachte FindAllByField Methode</b>
-     *
-     * Erzeugt on the fly ein array mit dem Supertyp der Klasseninstanz
-     * @param $field
-     * @param $value
-     * @return Model[]
-     */
-    public function findAllByField($field, $value) {
-        self::$logger->info(sprintf('%s(%s, %s) ', __METHOD__, $field, $value));
-
-        $rows = $this->db->findAllByField($this->table, $field, $value);
-
-        if ($rows == null) {
-            return null;
-        }
-
-        $list = array();
-        foreach ($rows as $row) {
-            $item = new static();
-            $item->data = $row;
-
-            $list[] = $item;
-        }
-
-        return $list;
+    public function __construct() {
+        $this->logger = Logger::getLogger(__CLASS__);
     }
-
-    /**
-     * <b>Vereinfachte persist Methode</b>
-     *
-     * Der Logger loggt nur die Nutzdaten, deswegen sieht das im Log identisch aus.
-     *
-     * Es handelt sich allerdings einmal um ein Objekt und einmal nur um ein Array.
-     *
-     * @return bool
-     */
-    public function persist() {
-        self::$logger->info(sprintf('%s(%s)', __METHOD__, print_r($this->getData(), true)));
-
-        return $this->db->persist($this->table, $this->getData());
-    }
-
-    public function getData() {
-        return $this->data;
-    }
-
-    /**
-     * <b>Vereinfachte store Methode</b>
-     *
-     * @return bool
-     */
-    public function store() {
-        self::$logger->info(sprintf('%s(%d, %s)', __METHOD__, $this->getId(), print_r($this->getData(), true)));
-
-        if ($this->getId() > 1) {
-            return $this->db->store($this->table, $this->getId(), $this->getData());
-        }
-
-        return false;
-    }
-
-    /**
-     * <b>Vereinfachte delete Methode</b>
-     *
-     * @param $id
-     * @return bool
-     */
-    public function delete() {
-        self::$logger->info(sprintf('%s(%d) ', __METHOD__, $this->getId()));
-
-        if ($this->getId() > 1) {
-            return $this->db->delete($this->table, $this->getId());
-        }
-
-        return false;
-    }
-
 }
\ No newline at end of file
rename from classes/bfw/mvc/common/View.php
rename to classes/bfw/core/View.php
--- a/classes/bfw/mvc/common/View.php
+++ b/classes/bfw/core/View.php
@@ -1,10 +1,14 @@
 <?php
 
-namespace bfw\mvc\common;
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
 
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\TStatus;
-use bfw\mvc\model\TUser;
+namespace bfw\core;
+
+use bfw\entities\TGroup;
+use bfw\entities\TUser;
 use Smarty;
 
 require_once 'library/smarty/libs/Smarty.class.php';
@@ -54,7 +58,7 @@
             $tpl = self::$tpl;
 
             $tpl->setCompileDir('./data/templates_c/');
-            $tpl->setTemplateDir('./templates/');
+            $tpl->setTemplateDir('./classes/bfw/mvc/view/');
         }
 
         return self::$tpl;
@@ -66,14 +70,13 @@
      * TODO: Namensschema festlegen, damit dieser Effekt nicht auftritt
      */
     public function display() {
-        $tUser = new TUser();
-        $tGroup = new TGroup();
-        $tStatus = new TStatus();
+        $user = new TUser();
+        $group = new TGroup();
 
         $request = $this->controller->getRequest();
 
         if ($request->getKey('isLoggedIn')) {
-            $tUser->find($request->getKey('user_id'));
+            $user->find($request->getKey('user_id'));
         }
 
         $controller = $this->controller;
@@ -81,9 +84,9 @@
         $response = $controller->getResponse();
         $this->assign('response', $response);
 
-        $this->assign('tUser', $tUser);
-        $this->assign('tGroup', $tGroup);
-        $this->assign('tStatus', $tStatus);
+        $this->assign('user', $user);
+        $this->assign('group', $group);
+
         $this->assign('request', $request);
 
         try {
--- a/classes/bfw/database/DBInterface.php
+++ b/classes/bfw/database/DBInterface.php
@@ -1,5 +1,10 @@
 <?php
 
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
 namespace bfw\database;
 
 interface DBInterface {
--- a/classes/bfw/database/Database.php
+++ b/classes/bfw/database/Database.php
@@ -1,15 +1,16 @@
 <?php
 
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
 namespace bfw\database;
 
 use Logger;
 use PDO;
 use PDOException;
 
-/**
- * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
- *
- */
 class Database implements DBInterface {
     private static $logger = null;
     private static $handle = null;
@@ -254,7 +255,7 @@
     }
 
     public function persist($table, $array) {
-        self::$logger->info(sprintf('%s(%s, %s) ', __METHOD__, $table, print_r($array, true)));
+        $this->logger->info(sprintf('%s(%s, %s) ', __METHOD__, $table, print_r($array, true)));
 
         $keys = array();
         foreach (array_keys($array) as $key) {
@@ -283,7 +284,7 @@
     }
 
     public function store($table, $id, $array) {
-        self::$logger->info(sprintf('%s(%s, %d, %s) ', __METHOD__, $table, $id, print_r($array, true)));
+        $this->logger->info(sprintf('%s(%s, %d, %s) ', __METHOD__, $table, $id, print_r($array, true)));
 
         $list = array();
         foreach ($array as $key => $value) {
@@ -304,7 +305,7 @@
     }
 
     public function delete($table, $id) {
-        self::$logger->info(sprintf('%s(%s, %s) ', __METHOD__, $table, $id));
+        $this->logger->info(sprintf('%s(%s, %s) ', __METHOD__, $table, $id));
 
         $sql = sprintf("
             DELETE FROM `%s`
rename from classes/bfw/mvc/model/TGroup.php
rename to classes/bfw/entities/TGroup.php
--- a/classes/bfw/mvc/model/TGroup.php
+++ b/classes/bfw/entities/TGroup.php
@@ -1,8 +1,13 @@
 <?php
 
-namespace bfw\mvc\model;
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
 
-use bfw\mvc\common\Model;
+namespace bfw\entities;
+
+use bfw\core\Entity;
 
 /**
  * Class TGroup
@@ -10,12 +15,9 @@
  * @method string getName()
  * @mthod setName($param)
  */
-class TGroup extends Model {
-    const GUEST = 5;
-    const SUPPORTER = 4;
-    const MANAGER = 3;
+class TGroup extends Entity {
+    const SYSTEM = 1;
     const ADMIN = 2;
-    const SYSTEM = 1;
 
     public function __construct() {
         parent::__construct('t_group');
@@ -34,28 +36,4 @@
         return $this->db->findByField('t_group', 'name', $name);
     }
 
-    /**
-     * <b>Besorgt ein Array mit der Liste der Manager und Darunter</b>
-     *
-     * @return array|null
-     */
-    public function findAllManagersAndBelow() {
-        /**
-         * SYSTEM = 1
-         * ADMIN = 2
-         *  [MANAGER = 3, SUPPORTER = 4]
-         * GUEST = 5
-         */
-        $groups = $this->db->fetchAll($this->table, 'id > 2 and id < 5');
-
-        $list = array();
-        foreach ($groups as $group) {
-            $item = new static();
-            $item->data = $group;
-
-            $list[] = $item;
-        }
-
-        return $list;
-    }
 }
\ No newline at end of file
rename from classes/bfw/mvc/model/TUser.php
rename to classes/bfw/entities/TUser.php
--- a/classes/bfw/mvc/model/TUser.php
+++ b/classes/bfw/entities/TUser.php
@@ -1,9 +1,13 @@
 <?php
 
-namespace bfw\mvc\model;
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
 
-use bfw\mvc\common\Model;
-use Logger;
+namespace bfw\entities;
+
+use bfw\core\Entity;
 
 /**
  * Class TUser
@@ -19,15 +23,12 @@
  * @method setFirstname()
  * @method setLastname()
  */
-class TUser extends Model {
+class TUser extends Entity {
     const SYSTEM = 1;
-    private static $logger = null;
 
     public function __construct() {
         parent::__construct('t_user');
 
-        self::$logger = Logger::getLogger('__CLASS__');
-
         $this->data = array(
             'id' => NULL,
             'group_id' => TGroup::SYSTEM,
@@ -64,92 +65,10 @@
         $user = $this->find($user_id);
 
         if (!is_object($user)) {
-            return 'Unbekannt, Unbekannt';
+            return null;
         }
 
         return sprintf("%s, %s", $user->getLastname(), $user->getFirstname());
     }
 
-    /**
-     * <b>FindMethode für alle Manager und Darunter</b>
-     *
-     * @return array|null
-     */
-    public function findAllManagersAndBelow() {
-        $managers = $this->db->query(sprintf("
-            SELECT
-                *
-            FROM
-              `%s`
-            WHERE
-              `group_id` in (3,4,5)",
-            $this->table));
-
-        $list = array();
-        foreach ($managers as $manager) {
-            $item = new static();
-            $item->data = $manager;
-
-            $list[] = $item;
-        }
-
-        return $list;
-    }
-
-    /**
-     * liefert den PK des nächst freien Supporters oder
-     * im Falle von nicht vorhandenen Supportern den System-Datensatz
-     *
-     * @return int
-     */
-    public function getFreeSupporterId() {
-
-        $sql = sprintf("
-          SELECT
-	        u.id,
-	        COUNT(t.user_id) AS `count`
-          FROM
-	        t_user u
-	      LEFT JOIN
-	          t_ticket t ON u.id = t.user_id
-          WHERE
-                u.group_id = 4
-          GROUP BY
-            u.id
-          ORDER BY
-            `count` ASC
-        ");
-
-        $data = $this->db->query($sql);
-
-        if ($data == null) {
-            // Ich will hier definitiv immer eine gültige ID haben, also einen PK
-            return 1;
-        }
-
-        self::$logger->info(sprintf("Data: %s", print_r($data, true)));
-
-        return $data[0]['id'];
-    }
-
-    /**
-     * <b>Anzahl der Tickets eines Benutzers</b>
-     *
-     * @return mixed
-     */
-    public function getTicketCount() {
-        $sql = sprintf("
-            SELECT
-              count(*) as anzahl
-            FROM
-                t_ticket
-            WHERE
-                user_id = %d
-        ", $this->getId());
-
-        $data = $this->db->query($sql);
-
-        return $data[0]['anzahl'];
-    }
-
 }
\ No newline at end of file
rename from classes/bfw/mvc/model/TView.php
rename to classes/bfw/entities/TView.php
--- a/classes/bfw/mvc/model/TView.php
+++ b/classes/bfw/entities/TView.php
@@ -1,15 +1,18 @@
 <?php
 
-namespace bfw\mvc\model;
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
 
-use bfw\mvc\common\Model;
+namespace bfw\entities;
 
 /**
  * Class TView
  *
  * @method string getId()
  */
-class TView extends Model {
+class TView extends Entity {
 
     /**
      * Nur Get-Methoden im View
--- a/classes/bfw/mvc/controller/BenutzerverwaltungController.php
+++ b/classes/bfw/mvc/controller/BenutzerverwaltungController.php
@@ -1,19 +1,16 @@
 <?php
 
-namespace bfw\mvc\controller;
-
 /**
  * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
  *
  */
 
+namespace bfw\mvc\controller;
+
+use bfw\core\Controller;
 use bfw\Dispatcher;
-use bfw\mvc\common\Controller;
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\TUser;
 
 class BenutzerverwaltungController extends Controller {
-    private static $logger = null;
 
     /**
      * BenutzerverwaltungsController constructor.
@@ -21,7 +18,9 @@
      */
     public function __construct() {
 
-        $model = new TUser();
+        $modelName = $this->getModelName();
+
+        $model = new $modelName();
         parent::__construct($model);
     }
 
@@ -30,33 +29,7 @@
      */
     public function meinProfil() {
         $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $username = $request->session('username');
-
-        $tUser = $this->getModel();
-        $user = $tUser->find($request->getKey('user_id'));
-
-        if ($request->post('aendern') != '') {
-            $firstname = $request->session('firstname');
-            $lastname = $request->session('lastname');
-
-            $tUser->setUsername($username);
-            $tUser->setFirstname($firstname);
-            $tUser->setLastname($lastname);
-
-            $password = $request->session('password');
-            if ($password != '') {
-                $tUser->setPassword(md5($password));
-            }
-
-            if ($tUser->store()) {
-                $request->setKey('msg', 'Der Nutzer wurde aktualisiert.');
-                $tUser->findByField('username', $tUser->getUsername());
-            } else {
-                $request->setKey('fehler', 'Der Nutzer konnte nicht aktualisiert werden.');
-            }
-        }
+        $view = $this->getView();
     }
 
     /**
@@ -64,13 +37,10 @@
      */
     public function abmelden() {
         $request = $this->getRequest();
-        $engine = $this->getView();
+        $view = $this->getView();
 
-        $request->deleteKey('username');
-        $request->deleteKey('group_id');
         $request->destroySession();
-
-        Dispatcher::route('/');
+        $request->initSession();
     }
 
     /**
@@ -78,42 +48,30 @@
      */
     public function anmelden() {
         $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $username = $request->session('username');
-        $password = md5($request->session('password'));
+        $view = $this->getView();
 
-        $tUser = $this->getModel();
-        $user = $tUser->findByUsername($username);
-
-        if ($user == null) {
+        if (!$request->hasPost()) {
+            // nothing to do!
             return;
         }
 
-        if (($username == $user->getUsername()) && ($password == $user->getPassword())) {
-            $request->setKey('isLoggedIn', true);
-            $request->setKey('user_id', $user->getId());
-            $request->setKey('group_id', $user->getGroup_id());
+        $model = $this->getModel()->getUser();
 
-            $tGroup = new TGroup();
-            if (($group = $tGroup->find($user->getGroup_Id())) == null) {
-                $request->setKey('fehler', "DB-Inkonsistenz: Prüfen Sie die exisitierenden Gruppen.");
-            }
+        $username = $request->post('username');
+        $password = $request->post('password');
+
+        $lastpage = $request->getKey('lastpage');
 
-            $msg = sprintf('Sie gehören der Gruppe %s an.', $group->getName());
-            $request->setKey('msg', $msg);
+        $model->findByUsername($username);
 
-            $lastpage = $request->getKey('lastpage');
-            if ($lastpage == 'benutzerverwaltung/anmelden') {
-                $lastpage = 'tickets/index';
-            }
+        if ($model->getPassword() == md5($password)) {
+            $request->setKey('user_id', $model->getId());
+            $request->setKey('group_id', $model->getGroup_Id());
 
-            $request->setKey('lastpage', $lastpage);
+            $request->setKey('isLoggedIn', true);
 
-            // Routing ist final
             Dispatcher::route(sprintf('/%s/', $lastpage));
         }
-
     }
 
     /**
@@ -121,192 +79,23 @@
      */
     public function registrieren() {
         $request = $this->getRequest();
-        $engine = $this->getView();
+        $view = $this->getView();
 
-        $currentUser = new TUser();
-        if ($request->post('registrieren') != '') {
-            $currentUser = $this->registrierenFunc($currentUser);
-        }
+        $model = $this->getModel();
 
-        $engine->assign('currentUser', $currentUser);
+        $view->assign('currentUser', $model->getUser());
     }
 
-    /**
-     *
-     * @param $currentUser
-     * @return mixed
-     */
-    public function registrierenFunc($currentUser) {
-        $request = $this->getRequest();
-
-        $password1 = $request->session('password1');
-        $password2 = $request->session('password2');
-
-        if (strlen($password1) == 0) {
-            return $currentUser;
-        }
-
-        // Validierung
-        if ($password1 != $password2) {
-            $request->setKey('fehler', 'Die Passwörter sind verschieden.');
-            return $currentUser;
-        }
-
-        $username = $request->session('username');
-        $firstname = $request->session('firstname');
-        $lastname = $request->session('lastname');
-
-        $currentUser->setUsername($username);
-        $currentUser->setPassword(md5($password1));
-        $currentUser->setFirstname($firstname);
-        $currentUser->setLastname($lastname);
-        $currentUser->setGroup_Id(TGroup::SUPPORTER);
-
-        if ($username == '' || $firstname == '' || $lastname == '') {
-            $request->setKey('fehler', 'Sie müssen die Pflichtfelder ausfüllen.');
-            return $currentUser;
-        }
-
-        if ($currentUser->persist()) {
-            $request->setKey('msg', 'Der Nutzer wurde angelegt.');
-
-            if ($currentUser->findByUsername($currentUser->getUsername())) {
-                $request->setKey('isLoggedIn', true);
-                $request->setKey('user_id', $currentUser->getId());
-                $request->setKey('group_id', $currentUser->getGroup_id());
-
-                Dispatcher::route('/benutzerverwaltung/meinprofil/');
-            }
-        } else {
-            $request->setKey('fehler', 'Der Nutzer konnte nicht angelegt werden.');
-        }
-
-        return $currentUser;
-    }
-
-    /**
-     *
-     */
     public function index() {
         $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $tUser = $this->getModel();
-        $tGroup = new TGroup();
-
-        if ($request->post('loeschen') != '') {
-            $this->loeschenFunc();
-        }
-
-        if ($request->post('aendern') != '') {
-            $this->aendernFunc();
-        }
-
-        $group_id = $request->getKey('group_id', TGroup::GUEST);
-
-        switch ($group_id) {
-            case TGroup::ADMIN:
-                $users = $tUser->findAll();
-                $groups = $tGroup->findAll();
-                break;
-            case TGroup::MANAGER:
-                $users = $tUser->findAllManagersAndBelow();
-                $groups = $tGroup->findAllManagersAndBelow();
-                break;
-            default:
-                Dispatcher::route('/benutzerverwaltung/home/');
-        }
+        $view = $this->getView();
 
-        $engine->assign('users', $users);
-        $engine->assign('groups', $groups);
-    }
-
-    /**
-     *
-     */
-    public function loeschenFunc() {
-        $tUser = new TUser();
-        $request = $this->getRequest();
-
-        $uid = $request->session('uid');
-
-        $tUser->find($uid);
-        if (!$tUser->delete()) {
-            $request->setKey('fehler', 'Der Benutzer konnte nicht gelöscht werden.');
-            Dispatcher::route('/home/');
-        } else {
-            $request->setKey('msg', 'Der Benutzer wurde gelöscht.');
-        }
-    }
-
-    /**
-     *
-     */
-    public function aendernFunc() {
-        $request = $this->getRequest();
-
-        $uid = $request->session('uid');
-        $username = $request->session('username');
-        $password = $request->session('password');
-        $group_id = $request->session('groupbox');
+        $model = $this->getModel();
 
-        $tUser = $this->getModel();
-        $user = $tUser->find($uid);
-
-        $user->setUsername($username);
-        if ($password != '') {
-            $user->setPassword(md5($password));
-        }
-
-        if ($group_id != '') {
-            $user->setGroup_id($group_id);
-        }
-
-        if ($tUser->store()) {
-            $request->setKey('msg', 'Der Benutzer wurde erfolgreich aktualisiert.');
-        } else {
-            $request->setKey('fehler', 'Der Benutzer konnte nicht aktualisiert werden.');
-        }
-    }
-
-    /**
-     *
-     */
-    public function resetpasswort() {
-        $request = $this->getRequest();
-        $engine = $this->getView();
+        $users = $model->getUsers();
+        $groups = $model->getGroups();
 
-        if ($request->post('pw-reset')) {
-            if ($this->resetPasswordFunc()) {
-                Dispatcher::route('/benutzerverwaltung/anmelden/');
-            }
-        }
+        $view->assign('users', $users);
+        $view->assign('groups', $groups);
     }
-
-    /**
-     *
-     * @return bool
-     */
-    public function resetPasswordFunc() {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $username = $request->session('username');
-
-        if (!$request->hasPost()) {
-            return false;
-        }
-
-        $tUser = $this->getModel();
-
-        if ($tUser->findByUsername($username)) {
-            $tUser->setPassword(md5($tUser->getUsername()));
-
-            return $tUser->store();
-        }
-
-        $engine->assign('request', $request);
-        return false;
-    }
-
 }
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/controller/DokumentationController.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\mvc\controller;
+
+use bfw\core\Controller;
+use bfw\mvc\model\TUser;
+
+/**
+ * Class DokumentationController
+ * @package bfw\mvc\controller
+ */
+class DokumentationController extends Controller {
+
+    public function __construct() {
+        $modelName = $this->getModelName();
+        $model = new $modelName();
+
+        parent::__construct($model);
+    }
+
+    public function index() {
+
+    }
+}
\ No newline at end of file
--- a/classes/bfw/mvc/controller/ErrorController.php
+++ b/classes/bfw/mvc/controller/ErrorController.php
@@ -1,8 +1,13 @@
 <?php
 
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
 namespace bfw\mvc\controller;
 
-use bfw\mvc\common\Controller;
+use bfw\core\Controller;
 
 /**
  * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
@@ -10,8 +15,8 @@
  */
 class ErrorController extends Controller {
 
-    public function __construct($model, $request) {
-        parent::__construct($model, $request);
+    public function __construct($model) {
+        parent::__construct($model);
     }
 
     public function index() {
deleted file mode 100644
--- a/classes/bfw/mvc/controller/HistoryController.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace bfw\mvc\controller;
-
-/**
- * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
- *
- */
-
-use bfw\mvc\common\Controller;
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\THistory;
-use bfw\mvc\model\TTicket;
-use bfw\mvc\model\TUser;
-
-class HistoryController extends Controller {
-
-    private $user_id;
-    private $group_id;
-    private $currentTicket;
-
-    public function __construct() {
-        $model = new THistory();
-        parent::__construct($model);
-
-        $this->currentTicket = null;
-
-        $request = $this->getRequest();
-
-        $this->user_id = $request->getKey('user_id', TUser::SYSTEM);
-        $this->group_id = $request->getKey('group_id', TGroup::GUEST);
-    }
-
-    public function index() {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $tid = $request->session('tid');
-        $ticket = new TTicket();
-
-        if ($ticket->find($tid) == null) {
-            $request->setKey('fehler', 'Datensatz nicht gefunden.');
-        }
-
-        $history = $this->getModel();
-        $histories = $history->findAllByField('ticket_id', $tid);
-        if ($histories == null) {
-            $request->setKey('fehler', 'Die Daten sind nicht aktuell.');
-        }
-
-        $engine->assign('ticket', $ticket);
-        $engine->assign('histories', $histories);
-    }
-
-}
\ No newline at end of file
--- a/classes/bfw/mvc/controller/HomeController.php
+++ b/classes/bfw/mvc/controller/HomeController.php
@@ -1,27 +1,23 @@
 <?php
 
-namespace bfw\mvc\controller;
-
-use bfw\database\Database;
-use bfw\Dispatcher;
-use bfw\mvc\common\Controller;
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\TText;
-use bfw\mvc\model\TUser;
-
 /**
  * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
  *
  */
+
+namespace bfw\mvc\controller;
+
+use bfw\core\Controller;
+
 class HomeController extends Controller {
-    const TEXT_ID = 2;
-
     /**
      * HomeController constructor.
      *
      */
     public function __construct() {
-        $model = new TUser();
+        $modelName = $this->getModelName();
+        $model = new $modelName();
+
         parent::__construct($model);
     }
 
@@ -35,88 +31,6 @@
     public function index() {
         $request = $this->getRequest();
         $engine = $this->getView();
-
-        /**
-         * Reset mit Redirect
-         */
-        if ($request->getParameter('reset') == '1') {
-            $this->reset($engine, $request);
-
-            return;
-        }
-
-        /**
-         * Eintragen mit Redirect
-         */
-        if ($request->get('unit') == '1') {
-            $this->unit();
-
-            return;
-        }
-
-        if ($request->post('eintragen') != '') {
-            $this->eintragen();
-        }
-
-        $tText = new TText();
-        $group_id = $request->getKey('group_id', TGroup::GUEST);
-
-        $text = $tText->find(self::TEXT_ID);
-        $engine->assign('text', $text);
-        $engine->assign('group_id', $group_id);
-    }
-
-    /**
-     *
-     */
-    public function reset() {
-        $request = $this->getRequest();
-        $db = Database::getInstance();
-
-        if (!$db->cleanup()) {
-            $request->deleteParameterKey('reset');
-            $request->setKey('fehler', 'Fehler beim Aufräumen');
-            Dispatcher::route('/');
-        }
-
-        $request->deleteParameterKey('reset');
-        $request->destroySession();
-
-        Dispatcher::route('/');
-    }
-
-    /**
-     *
-     */
-    public function unit() {
-        $request = $this->getRequest();
-
-        $db = Database::getInstance();
-        $db->csvImport('t_user', 'data/import/test_users.csv');
-        $db->csvImport('t_ticket', 'data/import/test_tickets.csv');
-
-        $request->deleteParameterKey('unit');
-
-        Dispatcher::route('/');
-    }
-
-    /**
-     *
-     */
-    public function eintragen() {
-        $request = $this->getRequest();
-
-        $tText = new TText();
-        $text = $tText->find(self::TEXT_ID);
-
-        $text->setHeadline($request->session('headline'));
-        $text->setText($request->session('text'));
-
-        if ($tText->store()) {
-            $request->setKey('msg', 'Der CMS-Text wurde aktualisiert.');
-        } else {
-            $request->setKey('fehler', 'Der CMS-Text kontne nicht aktualisiert werden.');
-        }
     }
 
 }
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/controller/TicketsController.php
+++ /dev/null
@@ -1,353 +0,0 @@
-<?php
-
-namespace bfw\mvc\controller;
-
-/**
- * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
- *
- */
-
-use bfw\Dispatcher;
-use bfw\mvc\common\Controller;
-use bfw\mvc\common\Model;
-use bfw\mvc\model\TGroup;
-use bfw\mvc\model\TStatus;
-use bfw\mvc\model\TTicket;
-use bfw\mvc\model\TUser;
-use Logger;
-
-class TicketsController extends Controller {
-    private $user_id;
-    private $group_id;
-    private $currentTicket;
-
-    /**
-     * TicketsController constructor.
-     *
-     */
-    public function __construct() {
-        $model = new TTicket();
-        parent::__construct($model);
-
-        $this->currentTicket = null;
-
-        $request = $this->getRequest();
-
-        $this->user_id = $request->getKey('user_id', TUser::SYSTEM);
-        $this->group_id = $request->getKey('group_id', TGroup::GUEST);
-    }
-
-    /**
-     * Default Index Action
-     */
-    public function index() {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $user_id = $this->user_id;
-        $group_id = $this->group_id;
-
-        $engine = $this->getView();
-        $currentTicket = $this->currentTicket;
-
-        // Umleiten zur Historie
-        if ($request->post('historie') != '') {
-            Dispatcher::route("/history/");
-        }
-
-        // finde das aktuelle Ticket, welches per GET live angegeben wurde.
-        if ($request->get('tid') != '') {
-            $currentTicket = $this->processTickedId($user_id);
-            $this->handleRequest($currentTicket, $user_id, $group_id);
-
-            return;
-        }
-
-        // lade das ausgewählte Ticket, Supporter nehmen es automatisch an.
-        if ($request->post('laden') != '') {
-            $currentTicket = $this->processLaden($user_id);
-            $this->handleRequest($currentTicket, $user_id, $group_id);
-
-            return;
-        }
-
-        // erstelle oder aktualisiere das aktuelle Ticket.
-        if ($request->post('eintragen') != '') {
-            $currentTicket = $this->processEintragen($user_id, $group_id);
-            $this->handleRequest($currentTicket, $user_id, $group_id);
-
-            return;
-        }
-
-        // lösche das aktuelle Ticket.
-        if ($request->post('loeschen') != '') {
-            $this->processLoeschen($user_id);
-            $this->handleRequest($currentTicket, $user_id, $group_id);
-
-            return;
-        }
-
-        $this->handleRequest($this->currentTicket, $this->user_id, $this->group_id);
-    }
-
-    /**
-     * @param $user_id
-     * @return null|TTicket
-     */
-    public function processTickedId($user_id) {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $tUser = new TUser();
-        $user = $tUser->find($user_id);
-
-        if ($user == null) {
-            $request->setKey('fehler', sprintf('Benutzer(%d) konnte nicht mehr gefunden werden.', $user_id));
-            Dispatcher::route('/');
-        }
-
-        $tid = $request->get('tid');
-
-        $tTicket = $this->getModel();
-        $currentTicket = $tTicket->find($tid);
-
-        if ($currentTicket == null) {
-            $request->setKey('fehler', sprintf('Ticket Nr. %d konnte nicht gefunden werden.', $tid));
-
-            return null;
-        }
-
-        if (!$currentTicket->hasPrivilege($currentTicket, $user, false)) {
-            $request->setKey('fehler', sprintf('Ihnen fehlen die Berechtigungen für das Ticket Nr. %d.', $tid));
-
-            return null;
-        }
-
-        return $currentTicket;
-    }
-
-    /**
-     * <b>Diese Funktion kümmert sich um die Anfragen dieses Ticket-Controllers</b>
-     *
-     * @param $currentTicket
-     * @param $user_id
-     * @param $group_id
-     */
-    public function handleRequest($currentTicket, $user_id, $group_id) {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        /**
-         * @var TTIcket
-         */
-        $tTicket = $this->getModel();
-
-        $tUser = new TUser();
-        $user = $tUser->find($user_id);
-
-        /**
-         * 'Cron-Job' ohne 'Cron': Alle Tickets werden bei jedem Zugriff geprüft
-         *
-         * Gibt es Tickets, die derzeit gesperrt sind? Befreie Sie! Free Tickets!!!
-         * Falls Tickets frei sind, weise diese korrekt und fair wieder zu.
-         */
-        $tTicket->unlockTickets();
-        $tTicket->reassignFreeTickets();
-
-        switch ($group_id) {
-            case TGroup::SUPPORTER:
-                $tickets = $tTicket->findAllTicketsByUserid($user_id);
-                if ($tickets == null) {
-                    $request->setKey('fehler', 'Es existieren derzeit keine Tickets für Sie!');
-                }
-
-                $users = array($tUser->findByUsername($user->getUsername()));
-                break;
-            case TGroup::ADMIN:
-            case TGroup::MANAGER:
-                $tickets = $tTicket->findAll();
-                $users = $tUser->findAll(false);
-                break;
-            default:
-                $tickets = $tTicket->findAll();
-                $users = $tUser->findAll();
-        }
-
-        $tStatus = new TStatus();
-        $statusItems = $tStatus->findAll();
-
-        // erstelle eine neue Ticket-Instanz, falls es keine instanzierte gibt.
-        if ($currentTicket == null) {
-            $currentTicket = new TTicket();
-        }
-
-        $engine->assign('users', $users);
-        $engine->assign('tStatus', $tStatus);
-        $engine->assign('tickets', $tickets);
-        $engine->assign('statusItems', $statusItems);
-        $engine->assign('currentTicket', $currentTicket);
-        $engine->assign('group_id', $group_id);
-    }
-
-    /**
-     * <b>Ticket nach TID laden</b>
-     *
-     * @param $user_id
-     *
-     * @return null|TTicket
-     */
-    public function processLaden($user_id) {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $tid = $request->session('tid');
-
-        $tTicket = $this->getModel();
-        $currentTicket = $tTicket->find($tid);
-
-        if ($currentTicket == null) {
-            $request->setKey('fehler', sprintf('Ticket Nr. %d konnte nicht gefunden werden.', $tid));
-
-            return null;
-        }
-
-        $tUser = new TUser();
-        $user = $tUser->find($user_id);
-
-        if ($user == null) {
-            $request->setKey('fehler', sprintf('Benutzer(%d) konnte nicht mehr gefunden werden.', $user_id));
-
-            return null;
-        }
-
-        $tTicket->lockTicket($currentTicket, $user);
-
-        if (!$currentTicket->hasPrivilege($currentTicket, $user, true)) {
-            $request->setKey('fehler', sprintf('Ihnen fehlen die Berechtigungen für das Ticket Nr. %d.', $tid));
-
-            return null;
-        }
-
-        return $currentTicket;
-    }
-
-    /**
-     * @param $user_id
-     * @param $group_id
-     * @return Model|null
-     */
-    public function processEintragen($user_id, $group_id) {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $logger = Logger::getLogger('main');
-
-        $tid = $request->session('tid');
-        $status_id = $request->session('status', TStatus::OFFEN);
-
-        $tTicket = $this->getModel();
-
-        if ($tid != '') {
-            $tTicket->find($tid, $user_id);
-        }
-
-        $tUser = new TUser();
-        $user = $tUser->find($user_id);
-        if ($user == null) {
-            return null;
-        }
-
-        $theHolyUserId = $tTicket->getUser_Id();
-        if ($group_id == TGroup::ADMIN || $group_id == TGroup::MANAGER) {
-            $theHolyUserId = $request->session('user_id');
-        }
-
-        $subject = $request->session('subject');
-        $message = $request->session('message');
-
-        if (($subject == '') && ($message == '')) {
-            $request->setKey('fehler', sprintf('Füllen Sie die Pflichtfelder aus.'));
-
-            return null;
-        }
-
-        $tTicket->setUser_Id($theHolyUserId);
-        $tTicket->setStatus_Id($status_id);
-        $tTicket->setSubject($subject);
-        $tTicket->setMessage($message);
-        $tTicket->setLast_Access(date("Y-m-d H:i:s"));
-
-        if ($tid == '') {
-            if ($tTicket->persist()) {
-                $request->setKey('msg', sprintf('Ein neues Ticket wurde erfolgreich eingetragen.'));
-                $logger->info(sprintf('Ticket wurde eingetragen: (%s)', print_r($tTicket->getData(), true)));
-
-                return null;
-            }
-        } else {
-            if (!$tTicket->hasPrivilege($tTicket, $user, true)) {
-                $request->setKey('fehler', sprintf('Ihnen fehlen die Berechtigungen für das Ticket Nr. %d.', $tid));
-
-                return null;
-            }
-
-            if ($tTicket->getId() != 1) {
-                if ($tTicket->store()) {
-                    $request->setKey('msg', 'Das Ticket wurde erfolgreich aktualisiert.');
-                    $logger->info(sprintf('Ticket wurde aktualisiert: (%s)', print_r($tTicket->getData(), true)));
-                }
-
-                return $tTicket;
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * <b>Löschen von Tickets</b>
-     *
-     * @return bool
-     */
-    public function processLoeschen($user_id) {
-        $request = $this->getRequest();
-        $engine = $this->getView();
-
-        $tid = $request->session('tid');
-
-        $tTicket = $this->getModel();
-        $currentTicket = $tTicket->find($tid);
-
-        if ($currentTicket == null) {
-            $request->setKey('fehler', sprintf('Nicht existierende Tickets(%d) können nicht gelöscht werden.', $tid));
-
-            return false;
-        }
-
-        $tUser = new TUser();
-        $user = $tUser->find($user_id);
-
-        if ($user == null) {
-            $request->setKey('fehler', sprintf('Benutzer(%d) konnte nicht mehr gefunden werden.', $user_id));
-
-            return false;
-        }
-
-        if (!$currentTicket->hasPrivilege($currentTicket, $user, true)) {
-            $request->setKey('fehler', sprintf('Ihnen fehlen die Berechtigungen für das Ticket Nr. %d.', $tid));
-
-            return false;
-        }
-
-        if ($currentTicket->delete($tid)) {
-            $request->setKey('msg', sprintf('Das Ticket mit der Nummer %d wurde gelöscht.', $tid));
-
-            return true;
-        }
-
-        $request->setKey('fehler', sprintf('Das Ticket mit der Nummer %d konnte nicht gelöscht werden.', $tid));
-
-        return false;
-    }
-
-}
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/model/TAction.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-namespace bfw\mvc\model;
-
-use bfw\mvc\common\Model;
-
-/**
- * Class TAction
- *
- * @method string getName()
- * @mthod setName($param)
- */
-class TAction extends Model {
-    const ANGELEGT = 2;
-    const GEANDERT = 3;
-    const GELOESCHT = 4;
-
-    public function __construct() {
-        parent::__construct('t_action');
-
-        $this->data = array(
-            'id' => NULL,
-            'name' => '',
-        );
-    }
-
-}
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/model/THistory.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-namespace bfw\mvc\model;
-
-use bfw\mvc\common\Model;
-
-/**
- * Class THistory
- *
- * @method getTicket_Id()
- * @method getAction_Id()
- * @method getUser_Id()
- * @method getStatus_Id()
- *
- * @method getSubject()
- * @method getMessage()
- *
- * @method getLocked()
- * @method getLast_Access()
- *
- * @method setTicket_Id($param)
- * @method setAction_Id($param)
- * @method setUser_Id($param)
- * @method setStatus_Id($param)
- *
- * @method setSubject($param)
- * @method setMessage($param)
- *
- * @method setLocked($locked)
- * @method setLast_Access($lastAccess)
- *
- */
-class THistory extends Model {
-
-    public function __construct() {
-        parent::__construct('t_history');
-
-        $this->data = array(
-            'id' => NULL,
-            'ticked_id' => 1,
-            'action_id' => 1,
-            'user_id' => 1,
-            'status_id' => 1,
-            'subject' => '',
-            'message' => '',
-            'locked' => false,
-            'last_access' => 'now()',
-        );
-    }
-
-    /**
-     * <b>Liefert das Name-Attribut der jeweiligen Action</b>
-     *
-     * @return string
-     */
-    public function getActionName() {
-        $action = new TAction();
-        $action->find($this->getAction_Id());
-
-        return $action->getName();
-    }
-
-    /**
-     * <b>Liefert das Name-Attribut des jeweiligen Status</b>
-     *
-     * @return string|null
-     */
-    public function getStatusName() {
-        $status = new TStatus();
-        $status->find($this->getStatus_Id());
-
-        return $status->getName();
-    }
-
-    /**
-     * <b>Liefert das jeweilige Username Attribut des angebenen Benutzers</b>
-     *
-     * @return string
-     */
-    public function getUsername() {
-        $user = new TUser();
-
-        return $user->getFormattedUsername($this->getUser_Id());
-    }
-}
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/model/TStatus.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-namespace bfw\mvc\model;
-
-use bfw\mvc\common\Model;
-
-/**
- * Class TStatus
- *
- * @method getName()
- */
-class TStatus extends Model {
-    const OFFEN = 2;
-    const GESCHLOSSEN = 3;
-
-    public function __construct() {
-        parent::__construct('t_status');
-
-        $this->data = array(
-            'id' => NULL,
-            'name' => '',
-        );
-
-    }
-
-    /**
-     * <b>Liefert den Bezeichner des angegebenen PKs der Status-Instanz<</b>
-     *
-     * @param $id
-     * @return mixed
-     */
-    public function getFormattedStatus($id) {
-        $status = $this->find($id);
-
-        return $status->getName();
-    }
-}
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/model/TText.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace bfw\mvc\model;
-
-use bfw\mvc\common\Model;
-
-/**
- * Class TText
- *
- * @method int getUser_Id()
- * @method string getHeadline()
- * @method string getText()
- * @method setUser_Id($param)
- * @method setHeadline($param)
- * @method setText($param)
- */
-class TText extends Model {
-    public function __construct() {
-        parent::__construct('t_text');
-
-        $this->data = array(
-            'id' => NULL,
-            'user_id' => 1,
-            'headline' => '',
-            'text' => '',
-        );
-
-    }
-}
\ No newline at end of file
deleted file mode 100644
--- a/classes/bfw/mvc/model/TTicket.php
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-
-namespace bfw\mvc\model;
-
-use bfw\mvc\common\Model;
-use Logger;
-
-/**
- * Class TTicket
- *
- * @method int getUser_Id()
- * @method int getStatus_Id()
- * @method string getSubject()
- * @method string getMessage()
- * @method bool getLocked()
- * @method timestamp getLast_Access()
- *
- * @method setStatus_Id($param)
- * @method setSubject($param)
- * @method setMessage($param)
- * @method setLocked($param)
- * @method setLast_Access($param)
- *
- */
-class TTicket extends Model {
-    private static $logger = null;
-
-    public function __construct() {
-        parent::__construct('t_ticket');
-
-        self::$logger = Logger::getLogger('__CLASS__');
-
-        $this->data = array(
-            'id' => NULL,
-            'user_id' => 1,
-            'status_id' => 1,
-            'subject' => '',
-            'message' => '',
-            'locked' => 0,
-            'last_access' => 'now()',
-        );
-    }
-
-    /**
-     * <b>Findet alle Tickets des angegebenen Nutzers</b>
-     *
-     *
-     * @param SERIAL $uid
-     * @return array|null
-     */
-    public function findAllTicketsByUserid($uid) {
-        return $this->findAllByField('user_id', $uid);
-    }
-
-    /**
-     * <b>Weisst frei gewordenen Tickets automatisiert zu.</b>
-     */
-    public function reassignFreeTickets() {
-        $tickets = $this->findAllByField('user_id', 1);
-
-        if (!is_object($tickets)) {
-            return;
-        }
-
-        $tUser = new TUser();
-        foreach ($tickets as $ticket) {
-            $freeSupporterId = $tUser->getFreeSupporterId();
-
-            /**
-             * Niemals vergessen: Nur aktualisieren, wenn auch
-             * aktualisiert werden muss.
-             *
-             */
-            if ($freeSupporterId > 1) {
-                $ticket->setUser_Id($freeSupporterId);
-                if ($ticket->store()) {
-                    self::$logger->info(sprintf("TICKET %d wurde neu zugewiesen.", $ticket->getId()));
-                }
-            }
-        }
-    }
-
-    public function lockTicket($ticket, $user) {
-        if ($user->getGroup_id() == TGroup::SUPPORTER) {
-            if ($ticket->getLocked() == false) {
-                $ticket->setLocked(1);
-                $ticket->setLast_Access(date('Y-m-d H:i:s'));
-
-                if ($ticket->store()) {
-                    self::$logger->info(sprintf("TICKET %d wurde gesperrt", $ticket->getId()));
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * <b>Das Ticket wird automatisch entsperrt nach 2 Stunden</b>
-     *
-     * @return bool
-     */
-    public function unlockTickets() {
-        $tickets = $this->findAll(false);
-        $user = new TUser();
-
-        foreach ($tickets as $ticket) {
-            if ($ticket->getStatus_Id() == TStatus::GESCHLOSSEN) {
-                continue;
-            }
-
-            // Ticketalter
-            $ticketAge = time() - strtotime($ticket->getLast_Access());
-
-            // Die Bearbeitungszeit beträgt 2 Stunden pro Supporter
-            $deadLine = 3600 * 2;
-
-            self::$logger->info('Ticket-Alter: ' . $ticketAge);
-            self::$logger->info('Deadline: ' . $deadLine);
-
-            if ($ticketAge > $deadLine) {
-                self::$logger->info('Time is up: Daten werden geändert.');
-                $freeSupporterId = $user->getFreeSupporterId();
-
-                if ($freeSupporterId > 1) {
-                    $ticket->setUser_Id($freeSupporterId);
-                    $ticket->setLocked(0);
-
-                    if (!$ticket->store()) {
-                        self::$logger->info(sprintf('Fehler beim Schreiben: %s', print_r($ticket->getData(), true)));
-                    }
-                } else {
-                    // Es existieren keine Supporter
-                    self::$logger->info(sprintf("%s(): Es existieren keine Supporter!", __METHOD__));
-                }
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * <b>Überladene find Methode</b>
-     *
-     * In früheren Versionen wurde hier das Ticket 'on the fly' modifiziert.
-     * Da das aber nicht Sinn und Zweck einer 'find' Methode ist, wurde das
-     * wieder entfernt und die Modifizierung erfolgt außerhalb...
-     *
-     * <b>Sinn und Zweck dieser Methode ist: 'Ticket-ID: nnn' ins Log zu schreiben...</b>
-     *
-     * @param $id
-     *
-     * @return array|null
-     */
-    public function find($id) {
-        self::$logger->info(sprintf("Ticket-ID: %d", $id));
-
-        return parent::find($id);
-    }
-
-    /**
-     * <b>Prüft, ob der übergebene Nutzer überhaupt die Berechtigung für das übergebene Ticket besitzt.</b>
-     *
-     * @param $ticket
-     * @param $user
-     * @return bool
-     */
-    public function hasPrivilege($ticket, $user, $write = true) {
-
-        // NULL Tickets: Kein Zugriff
-        if (!is_object($ticket)) {
-            self::$logger->warn(sprintf("%s(): Ticket wurde nicht initialisiert!", __METHOD__));
-            return false;
-        }
-
-        // NULL User: Kein Zugriff
-        if (!is_object($user)) {
-            self::$logger->warn(sprintf("%s(): Benutzer wurde nicht initialisiert!", __METHOD__));
-            return false;
-        }
-
-        // ADMIN UND MANAGER: Zugriff per Default
-        switch ($user->getGroup_Id()) {
-            case TGroup::ADMIN:
-            case TGroup::MANAGER:
-                return true;
-        }
-
-        if ($write == false) {
-            // System-Datensatz herausfiltern
-            if ($ticket->getId() > 1) {
-                return true;
-            }
-        }
-
-        // Ticketbasierter Zugriff: Ticket-Owner == Angemeldeter Benutzer?
-        return ($ticket->getUser_Id() == $user->getId());
-    }
-
-}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/model/benutzerverwaltung/Model.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\mvc\model\benutzerverwaltung;
+
+use bfw\entities\TGroup;
+use bfw\entities\TUser;
+
+class Model extends \bfw\core\Model {
+
+    private $user;
+    private $group;
+
+    public function __construct() {
+        $this->user = new TUser();
+        $this->group = new TGroup();
+    }
+
+    public function getUser() {
+        return $this->user;
+    }
+
+    public function getGroup() {
+        return $this->group;
+    }
+
+    public function getUsers() {
+        return $this->user->findAll();
+    }
+
+    public function getGroups() {
+        return $this->group->findAll();
+    }
+
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/model/dokumentation/Model.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\mvc\model\dokumentation;
+
+use bfw\entities\TGroup;
+use bfw\entities\TUser;
+
+class Model extends \bfw\core\Model {
+
+    private $user;
+    private $group;
+
+    public function __construct() {
+        $this->user = new TUser();
+        $this->group = new TGroup();
+    }
+
+    public function getUsers() {
+        return $this->user->findAll();
+    }
+
+    public function getGroups() {
+        return $this->group->findAll();
+    }
+
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/model/error/Model.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\mvc\model\error;
+
+use bfw\entities\TGroup;
+use bfw\entities\TUser;
+
+class Model extends \bfw\core\Model {
+
+    private $user;
+    private $group;
+
+    public function __construct() {
+        $this->user = new TUser();
+        $this->group = new TGroup();
+    }
+
+    public function getUsers() {
+        return $this->user->findAll();
+    }
+
+    public function getGroups() {
+        return $this->group->findAll();
+    }
+
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/model/home/Model.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Copyright(C) 2015 Markus Bröker<broeker.markus@googlemail.com>
+ *
+ */
+
+namespace bfw\mvc\model\home;
+
+use bfw\core\Model as MyModel;
+use bfw\entities\TGroup;
+use bfw\entities\TUser;
+
+class Model extends MyModel {
+
+    private $user;
+    private $group;
+
+    public function __construct() {
+        $this->user = new TUser();
+        $this->group = new TGroup();
+    }
+
+    public function getUsers() {
+        return $this->user->findAll();
+    }
+
+    public function getGroups() {
+        return $this->group->findAll();
+    }
+
+}
\ No newline at end of file
rename from templates/benutzerverwaltung/abmelden.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/abmelden.tpl
rename from templates/benutzerverwaltung/anmelden.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/anmelden.tpl
--- a/templates/benutzerverwaltung/anmelden.tpl
+++ b/classes/bfw/mvc/view/benutzerverwaltung/anmelden.tpl
@@ -1,6 +1,6 @@
 <div class="container">
-    <div class="row">
-        <form action="" method="post">
+    <form action="" method="post">
+        <div class="row">
             <div class="col-lg-12">
                 <p>
                     <label for="usernameField">Benutzername:</label>
@@ -12,20 +12,21 @@
                     <input type="password" name="password" value="{$request->post('password')}"/>
                 </p>
             </div>
+        </div>
 
-            <div class="row">
-                <div class="col-lg-12">
-                    <div class="col-lg-6">
-                        <input type="button" onClick="route('/resetpasswort/')" value="Passwort zurück setzen"/>
-                    </div>
+        <div class="row">
+            <div class="col-lg-12">
+                <div class="col-lg-6">
+                    <a href="/benutzerverwaltung/resetpasswort/">Passwort zurück setzen</a>
+                </div>
 
-                    <div class="col-lg-6">
-                        <input type="submit" name="anmelden" value="anmelden"/>
-                    </div>
+                <div class="col-lg-6">
+                    <input type="submit" name="anmelden" value="anmelden"/>
                 </div>
             </div>
-        </form>
-    </div>
+        </div>
+    </form>
+</div>
 
-    {$request->printSession()}
+{$request->printSession()}
 </div>
\ No newline at end of file
rename from templates/benutzerverwaltung/index.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/index.tpl
--- a/templates/benutzerverwaltung/index.tpl
+++ b/classes/bfw/mvc/view/benutzerverwaltung/index.tpl
@@ -8,22 +8,22 @@
                 <form action="" method="post" autocomplete="off">
                     <div class="col-lg-4">
                         <p>
-                            <label for="usernameField">Benutzername<span class="pull-right">({$user->getTicketCount()})</span></label>
-                            <input id="usernameField" type="text" name="username" value="{$user->getUsername()}"/>
+                            <label for="usernameField{$user->getId()}">Benutzername<span class="pull-right"></span></label>
+                            <input id="usernameField{$user->getId()}" type="text" name="username" value="{$user->getUsername()}"/>
                         </p>
                     </div>
 
-                    <div class="col-lg-3">
+                    <div class="col-lg-4">
                         <p>
-                            <label for="passwordField">Password</label>
-                            <input id="passwordField" type="password" name="password" value="" autocomplete="off"/>
+                            <label for="passwordField{$user->getId()}">Password</label>
+                            <input id="passwordField{$user->getId()}" type="password" name="password" value="" autocomplete="off"/>
                         </p>
                     </div>
 
-                    <div class="col-lg-3">
+                    <div class="col-lg-4">
                         <p>
-                            <label for="groupBox">Gruppenzugehörigkeit</label>
-                            <select id="groupBox" name="groupbox">
+                            <label for="groupBox{$user->getId()}">Gruppenzugehörigkeit</label>
+                            <select id="groupBox{$user->getId()}" name="groupbox">
                                 {foreach $groups as $group}
                                     {if $group->getId() == $user->getGroup_id()}
                                         <option value="{$group->getId()}" selected="'selected'">{$group->getName()}</option>
@@ -35,20 +35,9 @@
                         </p>
                     </div>
 
-                    <div class="col-lg-1">
-                        <label for="actionsKnopf1">Aktion</label>
-                        <input id="aktionsKnopf1" type="submit" name="aendern" value="Ändern"/>
-                    </div>
-
-                    <div class="col-lg-1">
-                        <label for="actionsKnopf2">Aktion</label>
-                        <input id="aktionsKnopf2" type="submit" name="loeschen" value="Löschen"/>
-                    </div>
-
                     <input type="hidden" name="uid" value="{$user->getId()}"/>
 
                     <br class="clearfix"/>
-                    <hr/>
                 </form>
             </div>
         </div>
@@ -69,6 +58,5 @@
                 </div>
             </div>
         </div>
-
     </div>
 </div>
rename from templates/benutzerverwaltung/meinprofil.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/meinprofil.tpl
rename from templates/benutzerverwaltung/registrieren.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/registrieren.tpl
--- a/templates/benutzerverwaltung/registrieren.tpl
+++ b/classes/bfw/mvc/view/benutzerverwaltung/registrieren.tpl
@@ -1,7 +1,7 @@
 <h2 class="text-center">Benutzerregistrierung</h2>
 <hr/>
 
-<form action="" method="post">
+<form action="/benutzerverwaltung/registrieren/" method="post">
     <div class="container">
         <div class="row">
             <div class="col-lg-12">
rename from templates/benutzerverwaltung/resetpasswort.tpl
rename to classes/bfw/mvc/view/benutzerverwaltung/resetpasswort.tpl
new file mode 100644
--- /dev/null
+++ b/classes/bfw/mvc/view/dokumentation/index.tpl
@@ -0,0 +1,2 @@
+<h2 class="text-center">Dokumentation</h2>
+<hr/>
rename from templates/error/index.tpl
rename to classes/bfw/mvc/view/error/index.tpl
rename from templates/footer.tpl
rename to classes/bfw/mvc/view/footer.tpl
--- a/templates/footer.tpl
+++ b/classes/bfw/mvc/view/footer.tpl
@@ -4,11 +4,10 @@
     </div>
 
     <div class="col-lg-4">
-        <p class="text-info bold">Ticket-System V1.0 / UID: {$smarty.session.prefix.user_id} /
-            GID: {$smarty.session.prefix.group_id} / HTTP-STATUS: {$response->getStatusCode()}</p>
+        <p class="text-info bold">BFw V0.1 / UID: {$smarty.session.prefix.user_id} / GID: {$smarty.session.prefix.group_id}</p>
     </div>
 
     <div class="col-lg-4">
-        <p class="text-danger bold">{$smarty.session.prefix.fehler}</p>
+        <p class="text-danger bold">{$smarty.session.prefix.error}</p>
     </div>
 </div>
\ No newline at end of file
rename from templates/header.tpl
rename to classes/bfw/mvc/view/header.tpl
--- a/templates/header.tpl
+++ b/classes/bfw/mvc/view/header.tpl
@@ -7,24 +7,22 @@
                 <span class="icon-bar"></span>
                 <span class="icon-bar"></span>
             </button>
-            <a class="navbar-brand" href="/">Ticket-System</a>
+            <a class="navbar-brand" href="/">Bröker Framework</a>
         </div>
 
         <div class="collapse navbar-collapse" id="ticketbar">
-            {if $smarty.session.prefix.group_id == $tGroup::ADMIN || $smarty.session.prefix.group_id == $tGroup::MANAGER}
                 <ul class="nav navbar-nav">
                     <li class="active"><a href="/benutzerverwaltung/">Benutzerverwaltung <span class="sr-only">(current)</span></a></li>
                 </ul>
-            {/if}
 
             <ul class="nav navbar-nav">
-                <li class="active"><a href="/tickets/">Tickets <span class="sr-only">(current)</span></a></li>
+                <li class="active"><a href="/dokumentation/">Dokumentation<span class="sr-only">(current)</span></a></li>
             </ul>
-            <form class="navbar-form navbar-left" role="search" method="get" action="/tickets/">
+            <form class="navbar-form navbar-left" role="search" method="get" action="/dokumentation/">
                 <div class="form-group">
-                    <input type="text" class="form-control" placeholder="Suchen..." name="tid" value="">
+                    <input type="text" class="form-control" placeholder="Suchen..." name="did" value="">
                 </div>
-                <button type="submit" class="btn btn-default">Ticket-Suche</button>
+                <button type="submit" class="btn btn-default">Volltext-Suche</button>
             </form>
             <ul class="nav navbar-nav navbar-right">
                 {if $request->getKey('isLoggedIn')}
rename from templates/home/index.tpl
rename to classes/bfw/mvc/view/home/index.tpl
--- a/templates/home/index.tpl
+++ b/classes/bfw/mvc/view/home/index.tpl
@@ -1,38 +1,2 @@
-<div class="container-fluid">
-    <div class="row">
-        <div class="col-lg-12">
-            <h4>
-                {html_entity_decode($text->getHeadline())}
-            </h4>
-
-            <hr/>
-
-            <p>
-                {html_entity_decode($text->getText())}
-            </p>
-        </div>
-    </div>
-
-    {if $group_id == $tGroup::ADMIN}
-        <div class="row">
-            <div class="col-lg-12">
-                <form action="" method="post">
-                    <p>
-                        <label for="text">Überschrift</label>
-                        <textarea id="headline" name="headline">{$text->getHeadline()}</textarea>
-                    </p>
-
-                    <p>
-                        <label for="text">Nachricht</label>
-                        <textarea id="text" name="text">{$text->getText()}</textarea>
-                    </p>
-
-                    <p>
-                        <input type="submit" name="eintragen" value="eintragen"/>
-                        <input type="hidden" name="tid" value="{$text->getId()}"/>
-                    </p>
-                </form>
-            </div>
-        </div>
-    {/if}
-</div>
+<h2 class="text-center">Das Bröker Framework</h2>
+<hr/>
rename from templates/layout.tpl
rename to classes/bfw/mvc/view/layout.tpl
--- a/templates/layout.tpl
+++ b/classes/bfw/mvc/view/layout.tpl
@@ -2,7 +2,7 @@
 <html lang="de">
 <head>
     <meta charset="utf-8"/>
-    <title>Ticket-System-Demo</title>
+    <title>BFW Demo Page</title>
 
     <link href="/js/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
 
@@ -18,7 +18,7 @@
 <div id="page">
     {include file="header.tpl"}
     <div class="content">
-        {include file="{$action}.tpl"}
+        {include file="{$controller}/{$action}.tpl"}
     </div>
 
     <div class="footer-area">
--- a/config/config.php
+++ b/config/config.php
@@ -32,5 +32,5 @@
 spl_autoload_register('bfw_autoLoader');
 
 // Durchs Überschreiben habe ich eine eigene Session und teile mir diese nicht mit den 'PHPSESSID' Leuten...
-session_name('ticked-id');
+session_name('bfw-id');
 session_start();
\ No newline at end of file
deleted file mode 100644
--- a/data/import/test_tickets.csv
+++ /dev/null
@@ -1,11 +0,0 @@
-user_id;status_id;subject;message;locked;last_access
-1;2;Ticket-1;Beschreibung-1;f;now()
-1;2;Ticket-2;Beschreibung-2;f;now()
-1;2;Ticket-3;Beschreibung-3;f;now()
-1;2;Ticket-4;Beschreibung-4;f;now()
-1;2;Ticket-5;Beschreibung-5;f;now()
-1;2;Ticket-6;Beschreibung-6;f;now()
-1;2;Ticket-7;Beschreibung-7;f;now()
-1;2;Ticket-8;Beschreibung-8;f;now()
-1;2;Ticket-9;Beschreibung-9;f;now()
-1;2;Ticket-10;Beschreibung-10;f;now()
--- a/js/main.js
+++ b/js/main.js
@@ -3,12 +3,5 @@
 }
 
 $(document).ready(function () {
-    $('.clickable').click(function () {
-        var tidStr = $(this).attr('id');
-        var tid = tidStr.substring(3);
-
-        window.location.href = "/tickets/?tid=" + tid;
-    });
-
-    tinymce.init({selector: 'textarea'});
+    tinymce.init({selector: '.tiny-mce textarea'});
 });
\ No newline at end of file
--- a/library/smarty/libs/Autoloader.php
+++ b/library/smarty/libs/Autoloader.php
@@ -15,7 +15,7 @@
  *             Smarty_Autoloader::register();
  *             $smarty = new Smarty();
  *             Note:       This autoloader is not needed if you use Composer.
- *             Composer will automatically add the classes of the Smarty package to it common autoloader.
+ *             Composer will automatically add the classes of the Smarty package to it core autoloader.
  */
 class Smarty_Autoloader {
     /**
--- a/library/smarty/libs/plugins/function.html_select_date.php
+++ b/library/smarty/libs/plugins/function.html_select_date.php
@@ -87,7 +87,7 @@
     $day_size = null;
     $month_size = null;
     $year_size = null;
-    /* Unparsed attributes common to *ALL* the <select>/<input> tags.
+    /* Unparsed attributes core to *ALL* the <select>/<input> tags.
        An example might be in the template: all_extra ='class ="foo"'. */
     $all_extra = null;
     /* Separate attributes for the tags. */
--- a/library/smarty/libs/plugins/shared.escape_special_chars.php
+++ b/library/smarty/libs/plugins/shared.escape_special_chars.php
@@ -8,7 +8,7 @@
 
 if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
     /**
-     * escape_special_chars common function
+     * escape_special_chars core function
      * Function: smarty_function_escape_special_chars<br>
      * Purpose:  used by other smarty functions to escape
      *           special chars except for already escaped ones
@@ -28,7 +28,7 @@
     }
 } else {
     /**
-     * escape_special_chars common function
+     * escape_special_chars core function
      * Function: smarty_function_escape_special_chars<br>
      * Purpose:  used by other smarty functions to escape
      *           special chars except for already escaped ones
--- a/library/smarty/libs/sysplugins/smarty_internal_compile_include.php
+++ b/library/smarty/libs/sysplugins/smarty_internal_compile_include.php
@@ -128,7 +128,7 @@
 
         /*
         * if the {include} tag provides individual parameter for caching or compile_id
-        * the subtemplate must not be included into the common cache file and is treated like
+        * the subtemplate must not be included into the core cache file and is treated like
         * a call in nocache mode.
         *
         */
deleted file mode 100644
--- a/templates/history/index.tpl
+++ /dev/null
@@ -1,35 +0,0 @@
-<h2 class="text-center">Historie des Tickets Nr. {$ticket->getId()}</h2>
-<hr/>
-
-<table border="1" style="width: 100%">
-    <tr>
-        <th>Aktion</th>
-        <th>Status</th>
-        <th>Benutzer</th>
-        <th>Betreff</th>
-        <th>Nachricht</th>
-        <th>Gesperrt</th>
-        <th>Letzter Zugriff</th>
-    </tr>
-
-    {foreach $histories as $history}
-        {assign var="coloredRow" value=""}
-        {if $history->getLocked() == 1}
-            {assign var="coloredRow" value=" yellow-row"}
-        {/if}
-
-        {if $history->getStatus_Id() == $tStatus::GESCHLOSSEN}
-            {assign var="coloredRow" value=" red-row"}
-        {/if}
-        <tr class="clickable{$coloredRow}" id="tid{$ticket->getId()}">
-            <td>{$history->getActionName()}</td>
-            <td>{$history->getStatusName()}</td>
-            <td>{$history->getUsername()}</td>
-            <td>{$history->getSubject()}</td>
-            <td>{$history->getMessage()}</td>
-            <td>{$history->getLocked()}</td>
-            <td>{$history->getLast_Access()}</td>
-        </tr>
-    {/foreach}
-</table>
-
deleted file mode 100644
--- a/templates/tickets/index.tpl
+++ /dev/null
@@ -1,78 +0,0 @@
-<h2 class="text-center">Ticketverwaltung</h2>
-<hr/>
-
-<div class="container-fluid">
-    <div class="row">
-        <div class="col-lg-12">
-            {include file="tickets/ticketanlegen.tpl"}
-        </div>
-
-        <br class="clearfix"/>
-    </div>
-</div>
-
-{if $tickets != null}
-    <br class="clearfix"/>
-    <div class="container-fluid">
-        <div class="row">
-            <div class="col-lg-12">
-                <table class="achtel">
-                    <tr>
-                        <th>Nummer</th>
-                        <th>Besitzer</th>
-                        <th>Betreff</th>
-                        <th>Nachricht</th>
-                        <th>Status</th>
-                        <th>Aktion1</th>
-                        <th>Aktion2</th>
-                        <th>Aktion3</th>
-                    </tr>
-                </table>
-            </div>
-        </div>
-
-        <div class="row">
-            {foreach $tickets as $ticket}
-                <div class="col-lg-12">
-                    <form action="/tickets/" method="post">
-                        <table class="achtel">
-                            {assign var="coloredRow" value=""}
-                            {if $ticket->getLocked()}
-                                {assign var="coloredRow" value="yellow-row"}
-                            {/if}
-
-                            {if $ticket->getStatus_Id() == $tStatus::GESCHLOSSEN}
-                                {assign var="coloredRow" value="red-row"}
-                            {/if}
-
-                            <tr class="{$coloredRow}">
-                                <td><input readonly='readonly' type="text" name="tid" value="{$ticket->getId()}"/></td>
-                                <td><input readonly='readonly' type="text" name="username" value="{$tUser->getFormattedUsername($ticket->getUser_Id())}"/></td>
-                                <td><input readonly='readonly' type="text" name="subject" value="{$ticket->getSubject()}"/></td>
-                                <td><input readonly='readonly' type="text" name="message" value="{strip_tags(html_entity_decode($ticket->getMessage()))}"/></td>
-                                <td><input readonly='readonly' type="text" name="status" value="{$tStatus->getFormattedStatus($ticket->getStatus_Id())}"/></td>
-
-                                {if $group_id != $tGroup::GUEST}
-                                    {if $group_id == $tGroup::SUPPORTER && $ticket->getLocked() == 0}
-                                        <td><input type="submit" name="laden" value="annehmen"/></td>
-                                    {else}
-                                        <td><input type="submit" name="laden" value="laden"/></td>
-                                    {/if}
-                                {else}
-                                    <td>Bearbeiten ist gesperrt</td>
-                                {/if}
-
-                                {if $group_id == $tGroup::MANAGER || $group_id == $tGroup::ADMIN}
-                                    <td><input type="submit" name="loeschen" value="löschen"/></td>
-                                {else}
-                                    <td>Löschen ist gesperrt</td>
-                                {/if}
-                                <td><input type="submit" name="historie" value="Historie"/></td>
-                            </tr>
-                        </table>
-                    </form>
-                </div>
-            {/foreach}
-        </div>
-    </div>
-{/if}
\ No newline at end of file
deleted file mode 100644
--- a/templates/tickets/ticketanlegen.tpl
+++ /dev/null
@@ -1,53 +0,0 @@
-<h4 class="text-center">{if $currentTicket->getId() == NULL}Neues Ticket{else}Ticket Nr. {$currentTicket->getId()}{/if}</h4>
-<hr/>
-
-<div class="container-fluid">
-    <div class="row">
-        <div class="col-lg-12">
-            <form action="/tickets/" method="post">
-                <p>
-                    <label for="subjectId">Betreff</label>
-                    <input id="subjectId" type="text" name="subject" value="{$currentTicket->getSubject()}"/>
-                </p>
-
-                <p>
-                    <label for="messageId">Nachricht</label>
-                    <textarea id="messageId" name="message">{$currentTicket->getMessage()}</textarea>
-                </p>
-
-                <p>
-                    <label for="statusId">Status</label>
-                    <select id="statusId" name="status">
-                        {foreach $statusItems as $status}
-                            {if $status->getId() == $currentTicket->getStatus_Id()}
-                                <option value="{$status->getId()}" selected="selected">{$status->getName()}</option>
-                            {else}
-                                <option value="{$status->getId()}">{$status->getName()}</option>
-                            {/if}
-                        {/foreach}
-                    </select>
-                </p>
-
-                {if $smarty.session.prefix.group_id == $tGroup::ADMIN || $smarty.session.prefix.group_id == $tGroup::MANAGER}
-                    <p>
-                        <label for="userId">Bearbeiter</label>
-                        <select id="userId" name="user_id">
-                            {foreach $users as $user}
-                                {if $user->getId() == $currentTicket->getUser_Id()}
-                                    <option value="{$user->getId()}" selected="selected">{$tUser->getFormattedUsername($user->getId())}</option>
-                                {else}
-                                    <option value="{$user->getId()}">{$tUser->getFormattedUsername($user->getId())}</option>
-                                {/if}
-                            {/foreach}
-                        </select>
-                    </p>
-                {/if}
-
-                <p>
-                    <input type="submit" name="eintragen" value="eintragen"/>
-                    <input type="hidden" name="tid" value="{$currentTicket->getId()}"/>
-                </p>
-            </form>
-        </div>
-    </div>
-</div>