mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c77d09c73 | ||
|
|
3d8c4fa4d0 | ||
|
|
272014bd78 | ||
|
|
76a8e00edf | ||
|
|
d40040efd8 |
@@ -101,6 +101,9 @@ class Widget extends FHCAPI_Controller
|
||||
$tmpsetup = json_decode($widget->setup);
|
||||
$tmpsetup->file = absoluteJsImportUrl($tmpsetup->file);
|
||||
$widget->setup = $tmpsetup;
|
||||
$widget->permitted = empty($widget->berechtigung_kurzbz)
|
||||
|| $this->permissionlib->isBerechtigt($widget->berechtigung_kurzbz);
|
||||
|
||||
return $widget;
|
||||
}, $widgets);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import BsModal from "../Bootstrap/Modal.js";
|
||||
import HeightTransition from "../Tranistion/HeightTransition.js";
|
||||
import MissingPermissionWidget from "../DashboardWidget/MissingPermission.js";
|
||||
|
||||
import { enableDragDropTouch } from "../../../../vendor/drag-drop-touch-js/dragdroptouch/dist/drag-drop-touch.esm.min.js";
|
||||
|
||||
@@ -112,6 +113,12 @@ export default {
|
||||
isPinned() {
|
||||
return this.place?.pinned ? true : false;
|
||||
},
|
||||
permitted() {
|
||||
// widgets without a linked permission (or before the template loaded)
|
||||
// are considered permitted; the backend sets permitted === false only
|
||||
// when the user is missing the widget's required permission
|
||||
return this.widgetTemplate?.permitted !== false;
|
||||
},
|
||||
ready() {
|
||||
return this.component && this.arguments !== null;
|
||||
}
|
||||
@@ -169,7 +176,11 @@ export default {
|
||||
&& this.widgetTemplate.widget_id
|
||||
&& this.widgetTemplate.arguments
|
||||
) {
|
||||
let component = (await import(this.widgetTemplate.setup.file)).default;
|
||||
// render the "missing permission" screen instead of the actual
|
||||
// widget when the user does not hold the widget's linked permission
|
||||
let component = this.permitted
|
||||
? (await import(this.widgetTemplate.setup.file)).default
|
||||
: MissingPermissionWidget;
|
||||
this.$options.components["widget" + this.widgetTemplate.widget_id] = component;
|
||||
this.component = "widget" + this.widgetTemplate.widget_id;
|
||||
this.arguments = { ...this.widgetTemplate.arguments, ...this.config };
|
||||
@@ -269,7 +280,7 @@ export default {
|
||||
</template>
|
||||
<!-- widget link -->
|
||||
<a
|
||||
v-if="widgetTemplate.setup.cis4link"
|
||||
v-if="widgetTemplate.setup.cis4link && permitted"
|
||||
:href="getWidgetC4Link(widgetTemplate)"
|
||||
class="col-auto ms-auto"
|
||||
:aria-label="$p.t('dashboard/widget_link')"
|
||||
|
||||
@@ -14,10 +14,14 @@ export default {
|
||||
callbacks: {}
|
||||
}),
|
||||
computed: {
|
||||
// filter widgets away the user has no permissions for
|
||||
availableWidgets() {
|
||||
return (this.widgets || []).filter(widget => widget.permitted !== false);
|
||||
},
|
||||
hasAnyWidgets() {
|
||||
if (!this.widgets)
|
||||
return false;
|
||||
if (!this.widgets.length && !this.hiddenWidgets?.length)
|
||||
if (!this.availableWidgets.length && !this.hiddenWidgets?.length)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -54,7 +58,7 @@ export default {
|
||||
<template v-slot:default>
|
||||
<template v-if="widgets && hiddenWidgets">
|
||||
<div
|
||||
v-if="!widgets.length && !hiddenWidgets.length"
|
||||
v-if="!availableWidgets.length && !hiddenWidgets.length"
|
||||
class="row g-2"
|
||||
>
|
||||
<div>{{ $p.t('dashboard/noWidgetsAvailable') }}</div>
|
||||
@@ -74,16 +78,17 @@ export default {
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="widgets.length"
|
||||
v-if="availableWidgets.length"
|
||||
class="row g-2"
|
||||
>
|
||||
<div
|
||||
v-for="widget in widgets"
|
||||
<template
|
||||
v-for="widget in availableWidgets"
|
||||
:key="widget.widget_id"
|
||||
class="widget-icon-container col-sm-6 col-md-4 col-lg-3 col-xl-2"
|
||||
>
|
||||
<widget-icon @select="pick" :widget="widget"></widget-icon>
|
||||
</div>
|
||||
<div v-if="widget.permitted" class="widget-icon-container col-sm-6 col-md-4 col-lg-3 col-xl-2">
|
||||
<widget-icon @select="pick" :widget="widget"></widget-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import AbstractWidget from './Abstract.js';
|
||||
|
||||
/**
|
||||
* Fallback screen rendered in place of a widget when the current user is missing
|
||||
* the permission (berechtigung_kurzbz) linked to that widget. Used for widgets
|
||||
* that are already on a user's dashboard but whose required permission the user
|
||||
* no longer holds.
|
||||
*/
|
||||
export default {
|
||||
mixins: [
|
||||
AbstractWidget
|
||||
],
|
||||
created() {
|
||||
this.$emit('setConfig', false);
|
||||
},
|
||||
template: /*html*/`
|
||||
<div class="dashboard-widget-missing-permission d-flex flex-column justify-content-center align-items-center text-center h-100 p-3 text-body-secondary">
|
||||
<i class="fa-solid fa-lock fa-2x mb-2" aria-hidden="true"></i>
|
||||
<p class="mb-0">{{ $p.t('dashboard/widget_missing_permission') }}</p>
|
||||
</div>`
|
||||
}
|
||||
@@ -124,8 +124,6 @@ export default {
|
||||
const studiengang_kz = this.studiengang_kz || '';
|
||||
const studiensemester = this.selectedStudiensemester;
|
||||
const semester = this.semester || '';
|
||||
const uid = this.emp || '';
|
||||
|
||||
|
||||
extraItems.push(
|
||||
{
|
||||
@@ -150,25 +148,8 @@ export default {
|
||||
description: 'lehre/lehrauftragsliste',
|
||||
requires: ['studiengang_kz']
|
||||
},
|
||||
{
|
||||
link: FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ 'content/pdfExport.php?xml=lehrauftrag.xml.php'
|
||||
+ '&xsl=Lehrauftrag'
|
||||
+ '&stg_kz=' + studiengang_kz
|
||||
+ '&ss=' + studiensemester,
|
||||
description: 'lehre/lehrauftraege',
|
||||
requires: ['studiengang_kz']
|
||||
},
|
||||
{
|
||||
link: FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ 'content/pdfExport.php?xml=lehrauftrag.xml.php'
|
||||
+ '&xsl=Lehrauftrag'
|
||||
+ '&stg_kz=' + studiengang_kz
|
||||
+ '&ss=' + studiensemester
|
||||
+ '&uid=' + uid,
|
||||
description: 'lehre/lehrauftragslisteemp',
|
||||
requires: ['emp']
|
||||
}
|
||||
this.lehrauftragLink,
|
||||
this.lehrauftragEmpLink,
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -181,6 +162,33 @@ export default {
|
||||
);
|
||||
|
||||
return extraItems;
|
||||
},
|
||||
lehrauftragLink()
|
||||
{
|
||||
return {
|
||||
link: FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ 'content/pdfExport.php?xml=lehrauftrag.xml.php'
|
||||
+ '&xsl=Lehrauftrag'
|
||||
+ '&stg_kz=' + (this.studiengang_kz || '')
|
||||
+ '&ss=' + this.selectedStudiensemester,
|
||||
description: 'lehre/lehrauftraege',
|
||||
requires: ['studiengang_kz'],
|
||||
shortDescription: 'F9'
|
||||
}
|
||||
},
|
||||
lehrauftragEmpLink()
|
||||
{
|
||||
return {
|
||||
link: FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ 'content/pdfExport.php?xml=lehrauftrag.xml.php'
|
||||
+ '&xsl=Lehrauftrag'
|
||||
+ '&stg_kz=' + (this.studiengang_kz || '')
|
||||
+ '&ss=' + this.selectedStudiensemester
|
||||
+ '&uid=' + (this.emp || ''),
|
||||
description: 'lehre/lehrauftragslisteemp',
|
||||
requires: ['emp'],
|
||||
shortDescription: 'F9'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -253,6 +261,7 @@ export default {
|
||||
params
|
||||
});
|
||||
}
|
||||
this.studiengang_kz = '';
|
||||
},
|
||||
searchfunction(params, config) {
|
||||
return this.$api.call(ApiSearchbar.search(params), config);
|
||||
@@ -292,7 +301,25 @@ export default {
|
||||
|
||||
return item.requires.some(req => !values[req]);
|
||||
|
||||
}
|
||||
},
|
||||
handleKeydown(event)
|
||||
{
|
||||
if (event.key !== 'F9' || event.repeat)
|
||||
return;
|
||||
|
||||
event.preventDefault();
|
||||
if (this.emp && !this.isDisabled(this.lehrauftragEmpLink))
|
||||
window.open(this.lehrauftragEmpLink.link, '_blank');
|
||||
else if (!this.isDisabled(this.lehrauftragLink))
|
||||
window.open(this.lehrauftragLink.link, '_blank');
|
||||
},
|
||||
},
|
||||
mounted()
|
||||
{
|
||||
document.addEventListener('keydown', this.handleKeydown)
|
||||
},
|
||||
beforeUnmount() {
|
||||
document.removeEventListener('keydown', this.handleKeydown);
|
||||
},
|
||||
created() {
|
||||
if (!this.$route.params.stdsem) {
|
||||
@@ -437,8 +464,11 @@ export default {
|
||||
v-for="(child, childKey) in item.children"
|
||||
:key="childKey"
|
||||
>
|
||||
<a class="dropdown-item" :href="child.link" target="_blank" :class="{ disabled: isDisabled(child) }">
|
||||
{{ $p.t(child.description) }}
|
||||
<a class="dropdown-item d-flex justify-content-between align-items-center" :href="child.link" target="_blank" :class="{ disabled: isDisabled(child) }">
|
||||
{{ $p.t(child.description) }}
|
||||
<small v-if="child.shortDescription" class="text-muted ms-3">
|
||||
{{ child.shortDescription }}
|
||||
</small>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -103,7 +103,7 @@ require_once('dbupdate_3.4/76160_lvv_favorites.php');
|
||||
require_once('dbupdate_3.4/77080_tabulator_presets_table.php');
|
||||
require_once('dbupdate_3.4/78292_gehaltsanpassungtyp.php');
|
||||
require_once('dbupdate_3.4/54225_reihungstest_ablauf_fuer_quereinsteiger.php');
|
||||
|
||||
require_once('dbupdate_3.4/77757_widgets_berechtigungen.php');
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* Copyright (C) 2026 fhcomplete.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Beschreibung:
|
||||
* Dashboard Widgets: Verknüpfung einer (einzelnen) Berechtigung pro Widget.
|
||||
* Neue Spalte dashboard.tbl_widget.berechtigung_kurzbz mit FK auf
|
||||
* system.tbl_berechtigung. Ist die Spalte NULL, erfordert das Widget keine
|
||||
* gesonderte Berechtigung. Benutzer denen die verknüpfte Berechtigung fehlt,
|
||||
* bekommen das Widget nicht mehr zur Auswahl angezeigt bzw. sehen (falls bereits
|
||||
* am Dashboard) einen "Fehlende Berechtigung"-Screen.
|
||||
*/
|
||||
if (! defined('DB_NAME')) exit('No direct script access allowed');
|
||||
|
||||
// Add column dashboard.tbl_widget.berechtigung_kurzbz (FK => system.tbl_berechtigung)
|
||||
if ($result = @$db->db_query("
|
||||
SELECT 1
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'dashboard'
|
||||
AND table_name = 'tbl_widget'
|
||||
AND column_name = 'berechtigung_kurzbz';"))
|
||||
{
|
||||
if ($db->db_num_rows($result) == 0)
|
||||
{
|
||||
$qry = "
|
||||
ALTER TABLE dashboard.tbl_widget
|
||||
ADD COLUMN berechtigung_kurzbz VARCHAR(32) NULL;
|
||||
|
||||
ALTER TABLE dashboard.tbl_widget
|
||||
ADD CONSTRAINT tbl_widget_berechtigung_fk
|
||||
FOREIGN KEY (berechtigung_kurzbz)
|
||||
REFERENCES system.tbl_berechtigung (berechtigung_kurzbz)
|
||||
ON UPDATE CASCADE ON DELETE SET NULL;";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
{
|
||||
echo '<strong>dashboard.tbl_widget: '.$db->db_last_error().'</strong><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'dashboard.tbl_widget: Spalte berechtigung_kurzbz (FK system.tbl_berechtigung) hinzugefuegt<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49620,6 +49620,26 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'dashboard',
|
||||
'phrase' => 'widget_missing_permission',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Ihnen fehlt die erforderliche Berechtigung, um dieses Widget anzuzeigen.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'You do not have the permission required to display this widget.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
// CIS4 phrases from legacy code end
|
||||
// FHC4 Phrases Abschlusspruefung
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user