diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index cc64c5a67..77f6ffb07 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -79,6 +79,9 @@ class Profil extends Auth_Controller $viewData = array ( 'uid' => $uid, 'profil_data'=>$profil_data, + 'permissions' => [ + 'basis/other_lv_plan' => $this->permissionlib->isBerechtigt(('basis/other_lv_plan')), + ] ); if($uid == getAuthUID()){ $viewData['editable'] = true; diff --git a/application/controllers/Cis4.php b/application/controllers/Cis4.php index b7ba2029d..11c723226 100644 --- a/application/controllers/Cis4.php +++ b/application/controllers/Cis4.php @@ -1,6 +1,7 @@ 'basis/cis:r' - ) + array( + 'index' => 'basis/cis:r' + ) ); // Load Config @@ -32,12 +33,12 @@ class Cis4 extends Auth_Controller { $this->load->model('person/Person_model', 'PersonModel'); $personData = getData($this->PersonModel->getByUid(getAuthUID()))[0]; - + $viewData = array( 'uid' => getAuthUID(), 'name' => $personData->vorname, 'person_id' => $personData->person_id, - 'timezone' => $this->config->item('timezone') + 'timezone' => $this->config->item('timezone'), ); $this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'FhcDashboard']); diff --git a/application/controllers/api/frontend/v1/LvPlan.php b/application/controllers/api/frontend/v1/LvPlan.php index e0159d9b2..fa70e919a 100644 --- a/application/controllers/api/frontend/v1/LvPlan.php +++ b/application/controllers/api/frontend/v1/LvPlan.php @@ -47,7 +47,7 @@ class LvPlan extends FHCAPI_Controller 'fetchFerienEvents' => self::PERM_LOGGED, 'getStudiengaenge' => self::PERM_LOGGED, 'getLehrverband' => self::PERM_LOGGED, - + 'permissionOtherLvPlan' => self::PERM_LOGGED, ]); $this->load->library('LogLib'); @@ -378,6 +378,16 @@ class LvPlan extends FHCAPI_Controller return $this->terminateWithSuccess($data); } + /** + * Checks if the current user has permission to view other users' timetables + * + * @return void + */ + public function permissionOtherLvPlan() + { + $this->terminateWithSuccess($this->permissionlib->isBerechtigt('basis/other_lv_plan')); + } + /** * fetch moodle events * diff --git a/public/js/api/factory/lvPlan.js b/public/js/api/factory/lvPlan.js index f1103a47d..41aa29299 100644 --- a/public/js/api/factory/lvPlan.js +++ b/public/js/api/factory/lvPlan.js @@ -118,4 +118,10 @@ export default { url: `/api/frontend/v1/lvPlan/getLehrverband/${stg_kz}/${sem}/${verband}` } }, + checkPermissionOtherLvPlan(){ + return { + method: 'get', + url: '/api/frontend/v1/lvPlan/permissionOtherLvPlan', + } + } }; \ No newline at end of file diff --git a/public/js/apps/Cis.js b/public/js/apps/Cis.js index fbbf197aa..ce148834e 100644 --- a/public/js/apps/Cis.js +++ b/public/js/apps/Cis.js @@ -1,172 +1,201 @@ import FhcSearchbar from "../components/searchbar/searchbar.js"; import CisMenu from "../components/Cis/Menu.js"; -import PluginsPhrasen from '../plugins/Phrasen.js'; -import ApiSearchbar from '../api/factory/searchbar.js'; +import PluginsPhrasen from "../plugins/Phrasen.js"; import Theme from "../plugins/Theme.js"; +import ApiSearchbar from "../api/factory/searchbar.js"; +import ApiLvPlan from "../api/factory/lvPlan.js"; + const app = Vue.createApp({ - name: 'CisApp', - components: { - FhcSearchbar, - CisMenu - }, - data: function() { - return { - searchbaroptions: { + name: "CisApp", + components: { + FhcSearchbar, + CisMenu, + }, + data: function () { + return { + searchbaroptions: { origin: "cis", cssclass: "", calcheightonly: true, types: { - employee: Vue.computed(() => this.$p.t("search/type_employee")), - student: Vue.computed(() => this.$p.t("search/type_student")), + employee: Vue.computed(() => + this.$p.t("search/type_employee"), + ), + student: Vue.computed(() => + this.$p.t("search/type_student"), + ), room: Vue.computed(() => this.$p.t("search/type_room")), - organisationunit: Vue.computed(() => this.$p.t("search/type_organisationunit")), + organisationunit: Vue.computed(() => + this.$p.t("search/type_organisationunit"), + ), cms: Vue.computed(() => this.$p.t("search/type_cms")), - dms: Vue.computed(() => this.$p.t("search/type_dms")) + dms: Vue.computed(() => this.$p.t("search/type_dms")), }, - actions: { - employee: { - defaultaction: { - type: "link", - action: function(data) { - return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - "/Cis/Profil/View/"+data.uid; - } + actions: { + employee: { + defaultaction: { + type: "link", + action: function (data) { + return ( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/Profil/View/" + + data.uid + ); + }, }, - childactions: [ - { - label: Vue.computed(() => this.$p.t("lehre/stundenplan")), - icon: "fas fa-calendar-days", - type: "link", - action: function(data) { - const uid = JSON.parse(data.data).uid; - const link = FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/Cis/OtherLvPlan/' + uid; - return link; - } - } - ] + childactions: [], }, student: { defaultaction: { type: "link", action: function (data) { - return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/Cis/Profil/View/" + data.uid; - - } + return ( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/Profil/View/" + + data.uid + ); + }, }, - childactions: [ - { - label: Vue.computed(() => this.$p.t("lehre/stundenplan")), - icon: "fas fa-calendar-days", - type: "link", - action: function(data) { - const uid = JSON.parse(data.data).uid; - const link = FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/Cis/OtherLvPlan/' + uid; - return link; - } - } - ] + childactions: [], }, - room: { - defaultaction: { - type: "link", - renderif: function(data) { - if(data.content_id === null){ + room: { + defaultaction: { + type: "link", + renderif: function (data) { + if (data.content_id === null) { return false; } return true; }, - action: function(data) { - const link= FHC_JS_DATA_STORAGE_OBJECT.app_root + + action: function (data) { + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/CisVue/Cms/content/' + data.content_id; + "/CisVue/Cms/content/" + + data.content_id; return link; - } - }, - childactions: [ - { - label: "LV-Plan", - icon: "fas fa-bookmark", - type: "link", - action: function(data) { - const link = FHC_JS_DATA_STORAGE_OBJECT.app_root + + }, + }, + childactions: [ + { + label: "LV-Plan", + icon: "fas fa-bookmark", + type: "link", + action: function (data) { + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/CisVue/Cms/getRoomInformation/' + data.ort_kurzbz; + "/CisVue/Cms/getRoomInformation/" + + data.ort_kurzbz; return link; - } - }, - { - label: "Rauminformation", - icon: "fas fa-info-circle", - type: "link", - renderif: function(data) { - if(data.content_id === null){ + }, + }, + { + label: "Rauminformation", + icon: "fas fa-info-circle", + type: "link", + renderif: function (data) { + if (data.content_id === null) { return false; } return true; - }, - action: function(data) { - const link= FHC_JS_DATA_STORAGE_OBJECT.app_root + + }, + action: function (data) { + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/CisVue/Cms/content/' + data.content_id; + "/CisVue/Cms/content/" + + data.content_id; return link; - } - }, - ] - }, - organisationunit: { - defaultaction: { - type: "link", - renderif: function(data) { - if(data.mailgroup) { + }, + }, + ], + }, + organisationunit: { + defaultaction: { + type: "link", + renderif: function (data) { + if (data.mailgroup) { return true; } return false; }, - action: function(data) { - const link = 'mailto:' + data.mailgroup; + action: function (data) { + const link = "mailto:" + data.mailgroup; return link; - } - }, - childactions: [] - }, + }, + }, + childactions: [], + }, cms: { defaultaction: { type: "link", action: function (data) { - const link = FHC_JS_DATA_STORAGE_OBJECT.app_root + + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - '/CisVue/Cms/content/' + data.content_id; + "/CisVue/Cms/content/" + + data.content_id; return link; - } + }, }, - childactions: [] + childactions: [], }, dms: { defaultaction: { type: "link", action: function (data) { - const link = FHC_JS_DATA_STORAGE_OBJECT.app_root + - 'cms/dms.php?id=' + data.dms_id; + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + "cms/dms.php?id=" + + data.dms_id; return link; - } + }, }, - childactions: [] - } - } - } - }; - }, - methods: { - searchfunction: function(searchsettings) { - return this.$api.call(ApiSearchbar.searchCis(searchsettings)); - } - } + childactions: [], + }, + }, + }, + }; + }, + methods: { + searchfunction: function (searchsettings) { + return this.$api.call(ApiSearchbar.searchCis(searchsettings)); + }, + }, + async mounted() { + const openOtherLvPlanAction = { + label: Vue.computed(() => this.$p.t("lehre/stundenplan")), + icon: "fas fa-calendar-days", + type: "link", + action: function (data) { + const uid = JSON.parse(data.data).uid; + const link = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/OtherLvPlan/" + + uid; + return link; + }, + }; + let checkPermissionOtherLvPlanResult = await this.$api.call( + ApiLvPlan.checkPermissionOtherLvPlan(), + ); + if ( + checkPermissionOtherLvPlanResult.meta.status === "success" && + checkPermissionOtherLvPlanResult.data + ) { + this.searchbaroptions.actions.employee.childactions.push( + openOtherLvPlanAction, + ); + this.searchbaroptions.actions.student.childactions.push( + openOtherLvPlanAction, + ); + } + }, }); FhcApps.makeExtendable(app); @@ -174,9 +203,9 @@ FhcApps.makeExtendable(app); app.use(primevue.config.default, { zIndex: { overlay: 9000, - tooltip: 8000 - } -}) + tooltip: 8000, + }, +}); app.use(PluginsPhrasen); app.use(Theme); -app.mount('#cis-header'); +app.mount("#cis-header"); diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index 18afbda47..98b5a822b 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -103,18 +103,7 @@ export default { }, ], }, - quickLinks: [ - { - icon: "fa-calendar-days", - phrase: "lehre/stundenplan", - action: () => { - this.$router.push({ - name: "OtherLvPlan", - params: { otherUid: this.$props.data.username }, - }) - }, - } - ], + quickLinks: [], betriebsmittel_table_options: { persistenceID: "filterTableMaProfilBetriebsmittel", persistence: { diff --git a/public/js/components/Cis/Profil/MitarbeiterViewProfil.js b/public/js/components/Cis/Profil/MitarbeiterViewProfil.js index c2e0cb3ec..42a2700f3 100644 --- a/public/js/components/Cis/Profil/MitarbeiterViewProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterViewProfil.js @@ -90,23 +90,12 @@ export default { }, ], }, - quickLinks: [ - { - icon: "fa-calendar-days", - phrase: "lehre/stundenplan", - action: () => { - this.$router.push({ - name: "OtherLvPlan", - params: { otherUid: this.$props.data.username }, - }) - }, - } - ], + quickLinks: [], }; }, //? this is the prop passed to the dynamic component with the custom data of the view - props: ["data"], + props: ["data", "permissions"], methods: { funktionenTableBuilt: function () { this.$refs.funktionenTable.tabulator.setData(this.data.funktionen); @@ -201,6 +190,21 @@ export default { this.preloadedPhrasen.wochenstundenPhrase = this.$p.t('profil/wochenstunden'); this.preloadedPhrasen.loaded = true; }); + + if (this.$props.permissions["basis/other_lv_plan"]) { + this.quickLinks.push( + { + icon: "fa-calendar-days", + phrase: "lehre/stundenplan", + action: () => { + this.$router.push({ + name: "OtherLvPlan", + params: { otherUid: this.$props.data.username }, + }) + }, + } + ); + } }, template: /*html*/ ` diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js index da205816d..c2d64982c 100644 --- a/public/js/components/Cis/Profil/Profil.js +++ b/public/js/components/Cis/Profil/Profil.js @@ -379,7 +379,7 @@ export const Profil = { } }, created() { - this.load() + this.load(); }, template: `