From 9227cc12f04aa1cf112a8d78416ae20a6ca63a6d Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 14 Nov 2023 14:36:47 +0100 Subject: [PATCH] retrieving user data from mitarbeiter and benutzer models --- application/controllers/Cis/Profil.php | 23 ++++++++++++++++++----- public/js/apps/Cis/ProfilApp.js | 3 +++ public/js/apps/api/userdata.js | 5 +++++ public/js/components/Cis/Profil/Profil.js | 2 ++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index f24216bfd..9764b0cae 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -18,6 +18,8 @@ class Profil extends Auth_Controller 'index' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? 'getUser' => ['student/anrechnung_beantragen:r','user:r'] ]); + $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); } // ----------------------------------------------------------------------------------------------------------------- @@ -33,15 +35,26 @@ class Profil extends Auth_Controller $this->load->view('Cis/Profil', ["uid" => getAuthUID()]); } + + //? public function getUser returns information related to a user public function getUser() { - $myObj = new stdClass(); - $myObj->name = "John"; - $myObj->age = 30; - $myObj->city = "New York"; - echo json_encode($myObj); + //* retrieve info from the Mitarbeiter model + $mitarbeiter_result = $this->MitarbeiterModel->load(getAuthUID()); + //* retrieve info from the Benutzer model + $benutzer_result = $this->BenutzerModel->load([getAuthUID()]); + //* return JSON with info + $res = ['mitarbeiter' => $mitarbeiter_result, + 'Benutzer' => $benutzer_result]; + + echo json_encode($res); } + + + + + //? this idea was to use _remap, to call different views based on the type of user /* public function _remap($param) { diff --git a/public/js/apps/Cis/ProfilApp.js b/public/js/apps/Cis/ProfilApp.js index b6c727e88..31abc2ec9 100644 --- a/public/js/apps/Cis/ProfilApp.js +++ b/public/js/apps/Cis/ProfilApp.js @@ -17,6 +17,9 @@ const app = Vue.createApp({ methods: { testsearch: function() { return Vue.$fhcapi.UserData.getUser(); + }, + testsearch2: function() { + return Vue.$fhcapi.UserData.getUser2("ma0594"); } }, diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index d36628561..0b5442add 100644 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -5,6 +5,11 @@ export default { + 'Cis/Profil/getUser'; return axios.get(url); }, + getUser2: function(uid) { + const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + + 'models/person/Benutzer_model/getFromPersonId'; + return axios.get(url,{params: {uid}}); + }, getUserDumy: function(){ const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'public/js/apps/api/dummyapi.php/getUser'; diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js index 546767c5c..1a054fc80 100644 --- a/public/js/components/Cis/Profil/Profil.js +++ b/public/js/components/Cis/Profil/Profil.js @@ -16,6 +16,8 @@ export default { this.$parent.testsearch().then((res) => { this.person = res.data; }); + + }, template: `