diff --git a/application/controllers/Test.php b/application/controllers/Test.php new file mode 100644 index 000000000..497f12f85 --- /dev/null +++ b/application/controllers/Test.php @@ -0,0 +1,63 @@ + 'dashboard/benutzer:r', + 'db' => 'dashboard/benutzer:r', + 'admin' => 'dashboard/admin:r', + ) + ); + + $this->load->library('AuthLib'); + + $this->_setAuthUID(); // sets property uid + + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + public function index() + { + $this->load->view('test/Test.php', ['dashboard' => 'CIS']); + } + + // Public methods + public function db($dashboard) + { + $this->load->view('test/Test.php', ['dashboard' => $dashboard]); + } + + public function admin() + { + $this->load->view('test/Admin.php', []); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } + +} diff --git a/application/controllers/dashboard/Config.php b/application/controllers/dashboard/Config.php index 213781b74..b9c4c6c31 100644 --- a/application/controllers/dashboard/Config.php +++ b/application/controllers/dashboard/Config.php @@ -207,7 +207,13 @@ class Config extends Auth_Controller foreach ($funktionen as $funktion) { $conf = $this->DashboardLib->getPreset($db, $funktion); if ($conf) - $result[$funktion] = json_decode($conf->preset, true)['widgets'][$funktion]; + { + $preset = json_decode($conf->preset, true); + if (!isset($preset['widgets']) || !isset($preset['widgets'][$funktion])) + $result[$funktion] = []; + else + $result[$funktion] = $preset['widgets'][$funktion]; + } else $result[$funktion] = []; } diff --git a/application/controllers/dashboard/Widget.php b/application/controllers/dashboard/Widget.php index 9a878fa36..07c57ea73 100644 --- a/application/controllers/dashboard/Widget.php +++ b/application/controllers/dashboard/Widget.php @@ -11,9 +11,9 @@ class Widget extends Auth_Controller { parent::__construct( array( - 'index' => 'dashboard/benutzer:r', + 'index' => ['dashboard/benutzer:r', 'dashboard/admin:r'], 'getAll' => 'dashboard/admin:r', - 'getWidgetsForDashboard' => 'dashboard/benutzer:rw', + 'getWidgetsForDashboard' => ['dashboard/benutzer:rw', 'dashboard/admin:r'], 'setAllowed' => 'dashboard/admin:rw' ) ); diff --git a/application/models/dashboard/Widget_model.php b/application/models/dashboard/Widget_model.php index 4e5a31502..554c7dea6 100644 --- a/application/models/dashboard/Widget_model.php +++ b/application/models/dashboard/Widget_model.php @@ -15,8 +15,8 @@ class Widget_model extends DB_Model public function getWithAllowedForDashboard($dashboard_id) { $this->addSelect($this->dbTable . '.*'); - $this->addSelect('CASE WHEN dashboard_id = ? THEN 1 ELSE 0 END AS allowed', false); - $this->addJoin('dashboard.tbl_dashboard_widget', 'widget_id', 'LEFT'); + $this->addSelect('CASE WHEN dashboard_id IS NULL THEN 0 ELSE 1 END AS allowed', false); + $this->db->join('dashboard.tbl_dashboard_widget dw', $this->dbTable . '.widget_id=dw.widget_id AND dashboard_id = ?', 'LEFT', false); return $this->execQuery($this->db->get_compiled_select($this->dbTable), [$dashboard_id]); } diff --git a/application/views/test/Admin.php b/application/views/test/Admin.php new file mode 100644 index 000000000..837f6411b --- /dev/null +++ b/application/views/test/Admin.php @@ -0,0 +1,32 @@ +load->view('templates/FHC-Header', + array( + 'title' => 'FH-Complete', + 'bootstrap5' => true, + 'fontawesome6' => true, + 'axios027' => true, + 'restclient' => true, + 'vue3' => true, + 'customJSModules' => ['public/js/apps/Test.js'], + 'customCSSs' => [ + 'public/css/components/dashboard.css' + ], + 'navigationcomponent' => true + ) +); +?> + +
+ 
{{ singleNews.betreff }}
{{ formatDateTime(singleNews.insertamum) }}