diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 8c3088bd7..c287d87d0 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -55,8 +55,13 @@ class Profil extends Auth_Controller */ public function index() { + + $this->load->library('ProfilLib'); + $profil_data = $this->profillib->getView(getAuthUID()); + $profil_data = hasData($profil_data) ? getData($profil_data) : null; $viewData = array( - + 'editable'=>true, + 'profil_data' => $profil_data, ); $this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilIndex']); } @@ -68,8 +73,16 @@ class Profil extends Auth_Controller */ public function View($uid) { - $viewData = array ('uid' => $uid); - + $this->load->library('ProfilLib'); + $profil_data = $this->profillib->getView($uid); + $profil_data = hasData($profil_data) ? getData($profil_data) : null; + $viewData = array ( + 'uid' => $uid, + 'profil_data'=>$profil_data, + ); + if($uid == getAuthUID()){ + $viewData['editable'] = true; + } $this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilViewUid']); } diff --git a/application/controllers/api/frontend/v1/Profil.php b/application/controllers/api/frontend/v1/Profil.php index b58d90d07..57af6aa37 100644 --- a/application/controllers/api/frontend/v1/Profil.php +++ b/application/controllers/api/frontend/v1/Profil.php @@ -32,7 +32,7 @@ class Profil extends FHCAPI_Controller 'getGemeinden' => self::PERM_LOGGED, 'getAllNationen' => self::PERM_LOGGED, 'isMitarbeiter' => self::PERM_LOGGED, - + 'profilViewData' => self::PERM_LOGGED, ]); $this->load->library('PermissionLib'); @@ -58,7 +58,28 @@ class Profil extends FHCAPI_Controller //------------------------------------------------------------------------------------------------------------------ // Public methods - + public function profilViewData($uid){ + $uid = json_decode($uid); + $this->load->library('ProfilLib'); + $editable = false; + if(isset($uid) && $uid != null){ + $profil_data = $this->profillib->getView($uid); + if($uid == getAuthUID()){ + $editable = true; + } + }else{ + $editable = true; + $profil_data = $this->profillib->getView(getAuthUID()); + } + + $profil_data = hasData($profil_data) ? getData($profil_data) : null; + $viewData = array( + 'editable'=>$editable, + 'profil_data' => $profil_data, + ); + $this->terminateWithSuccess($viewData); + } + /** * function that returns the data used for the corresponding view @@ -70,7 +91,6 @@ class Profil extends FHCAPI_Controller public function getView($uid) { $res = new stdClass(); - $editAllowed = getAuthUID() == $uid || $this->permissionlib->isBerechtigt('admin'); // if parsing the URL did not found a UID then the UID of the logged in user is used if ($uid == "Profil" || $uid == $this->uid) { @@ -85,8 +105,6 @@ class Profil extends FHCAPI_Controller $res->data = $this->studentProfil(); $res->data->pid = $this->pid; } - // editing your own profil - true - $editAllowed = true; } // UID is availabe when accessing Profil/View/:uid else { @@ -109,7 +127,6 @@ class Profil extends FHCAPI_Controller } } $res->data->fotoStatus=$this->isFotoAkzeptiert($this->pid); - $res->data->editAllowed = $editAllowed; $this->terminateWithSuccess($res); } diff --git a/application/libraries/ProfilLib.php b/application/libraries/ProfilLib.php new file mode 100644 index 000000000..08caa0035 --- /dev/null +++ b/application/libraries/ProfilLib.php @@ -0,0 +1,583 @@ +ci =& get_instance(); + + + } + + public function getView($uid) + { + // loading required models + $this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel"); + $this->ci->load->model("person/Person_model","PersonModel"); + $res = new stdClass(); + + // checking the uid + if ($uid == getAuthUID()) { + $isMitarbeiter = $this->ci->MitarbeiterModel->isMitarbeiter(getAuthUID()); + if(isError($isMitarbeiter)) + { + return error(getData($isMitarbeiter)); + } + $isMitarbeiter = getData($isMitarbeiter); + $isMitarbeiter = $isMitarbeiter ? current($isMitarbeiter) : false; + if ($isMitarbeiter) { + $res->view = "MitarbeiterProfil"; + $res->data = $this->mitarbeiterProfil(); + $res->data->pid = getAuthPersonId(); + } else { + $res->view = "StudentProfil"; + $res->data = $this->studentProfil(); + $res->data->pid = getAuthPersonId(); + } + } + // UID is availabe when accessing Profil/View/:uid + else { + $isMitarbeiter = $this->ci->MitarbeiterModel->isMitarbeiter($uid); + if(isError($isMitarbeiter)) + { + return error(getData($isMitarbeiter)); + } + $isMitarbeiter = getData($isMitarbeiter); + $isMitarbeiter = $isMitarbeiter ? current($isMitarbeiter) : false; + if ($isMitarbeiter) { + $res->view = "ViewMitarbeiterProfil"; + $res->data = $this->viewMitarbeiterProfil($uid); + + } else { + $res->view = "ViewStudentProfil"; + $res->data = $this->viewStudentProfil($uid); + } + } + $res->data->fotoStatus=$this->isFotoAkzeptiert(getAuthPersonId()); + return success($res); + } + + //PRIVATE METHODS ############################################### + + /** + * function that returns the data used for the student profile + * @access private + * @return stdClass student data + */ + private function studentProfil() + { + $pid = getAuthPersonId(); + $uid = getAuthUID(); + $betriebsmittelperson_res = $this->getBetriebsmittelInfo($pid); + $kontakte_res = $this->getKontaktInfo($pid); + $zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($uid); + $adresse_res = $this->getAdressenInfo($pid); + $mailverteiler_res = $this->getMailverteiler($uid); + $person_res = $this->getPersonInfo($uid, true); + $zutrittsgruppe_res = $this->getZutrittsgruppen($uid); + $student_res = $this->getStudentInfo($uid); + $matr_res = $this->getMatrikelNummer($uid); + $profilUpdates = $this->getProfilUpdates($uid); + + $res = new stdClass(); + $res->username = $uid; + + //? Person Information + foreach ($person_res as $key => $value) { + $res->$key = $value; + } + + //? Student Information + foreach ($student_res as $key => $value) { + $res->$key = trim($value); + } + + $intern_email = array(); + $intern_email["type"] = "intern"; + $intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN :""; + + $res->emails = [$intern_email]; + $res->adressen = $adresse_res; + $res->zutrittsdatum = $zutrittskarte_ausgegebenam; + $res->kontakte = $kontakte_res; + $res->mittel = $betriebsmittelperson_res; + $res->matrikelnummer = $matr_res->matr_nr; + $res->zuttritsgruppen = $zutrittsgruppe_res; + $res->mailverteiler = $mailverteiler_res; + $res->profilUpdates = $profilUpdates; + + return $res; + } + + /** + * function that returns the data used for the mitarbeiter profile + * @access private + * @return stdClass mitarbeiter data + */ + private function mitarbeiterProfil() + { + $pid = getAuthPersonId(); + $uid = getAuthUID(); + $zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($uid); + $adresse_res = $this->getAdressenInfo($pid); + $kontakte_res = $this->getKontaktInfo($pid); + $mailverteiler_res = $this->getMailverteiler($uid); + $person_res = $this->getPersonInfo($uid, true); + $benutzer_funktion_res = $this->getBenutzerFunktion($uid); + $betriebsmittelperson_res = $this->getBetriebsmittelInfo($pid); + $profilUpdates = $this->getProfilUpdates($uid); + $telefon_res = $this->getTelefonInfo($uid); + $mitarbeiter_res = $this->getMitarbeiterInfo($uid); + + $res = new stdClass(); + $res->username = $uid; + + //? Person Information + foreach ($person_res as $key => $value) { + $res->$key = $value; + } + + //? Mitarbeiter Information + foreach ($mitarbeiter_res as $key => $value) { + $res->$key = $value; + } + + $res->adressen = $adresse_res; + $res->zutrittsdatum = $zutrittskarte_ausgegebenam; + $res->kontakte = $kontakte_res; + $res->mittel = $betriebsmittelperson_res; + $res->mailverteiler = $mailverteiler_res; + + $intern_email = array(); + $intern_email["type"] = "intern"; + $intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN : ""; + $extern_email = array(); + $extern_email["type"] = "alias"; + + $extern_email["email"] = $mitarbeiter_res->alias? ($mitarbeiter_res->alias . "@" . DOMAIN) : null; + $res->emails = $extern_email["email"]?[$intern_email, $extern_email]:[$intern_email]; + + $res->funktionen = $benutzer_funktion_res; + $res->standort_telefon = $telefon_res; + $res->profilUpdates = $profilUpdates; + + return $res; + } + + /** + * gets the date of issue of the FH access card corresponding to a user + * @access private + * @param integer $uid the userID used to get the date of issue of the FH access card + * @return string the date of issue of the FH access card corresponding to a userID + */ + private function getZutrittskarteDatum($uid) + { + $this->ci->load->model("ressource/Betriebsmittelperson_model","BetriebsmittelpersonModel"); + $zutrittskarte_ausgegebenam = $this->ci->BetriebsmittelpersonModel->getBetriebsmittelByUid($uid, "Zutrittskarte"); + + if(isError($zutrittskarte_ausgegebenam)){ + return error(getData($zutrittskarte_ausgegebenam)); + } + $zutrittskarte_ausgegebenam = getData($zutrittskarte_ausgegebenam); + $zutrittskarte_ausgegebenam = $zutrittskarte_ausgegebenam ? current($zutrittskarte_ausgegebenam)->ausgegebenam : null; + + //? formats date from 01-01-2000 to 01.01.2000 + $zutrittskarte_ausgegebenam = str_replace("-", ".", $zutrittskarte_ausgegebenam); + return $zutrittskarte_ausgegebenam; + } + + /** + * gets the address information corresponding to a user + * @access private + * @param integer $uid the userID used to get the address information + * @return array all the address information corresponding to a userID + */ + private function getAdressenInfo($pid) + { + $this->ci->load->model("person/Adresse_model","AdresseModel"); + $adresse_res = $this->ci->AdresseModel->addSelect(["adresse_id", "strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort", "zustelladresse", "gemeinde", "nation"]); + $adresse_res = $this->ci->AdresseModel->addOrder("zustelladresse", "DESC"); + $adresse_res = $this->ci->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"); + + $adresse_res = $this->ci->AdresseModel->loadWhere(["person_id" => $pid]); + if(isError($adresse_res)){ + return error(getData($adresse_res)); + } + $adresse_res = getData($adresse_res) ?? []; + return $adresse_res; + } + + /** + * gets the kontakt information corresponding to a user + * @access private + * @param integer $uid the userID used to get the kontakt information + * @return array all the kontakt information corresponding to a userID + */ + private function getKontaktInfo($pid) + { + $this->ci->load->model("person/Kontakt_model","KontaktModel"); + $this->ci->KontaktModel->addSelect(['kontakttyp', 'kontakt_id', 'kontakt', 'tbl_kontakt.anmerkung', 'tbl_kontakt.zustellung']); + $this->ci->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT'); + $this->ci->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT'); + $this->ci->KontaktModel->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum'); + + $kontakte_res = $this->ci->KontaktModel->loadWhere(['person_id' => $pid]); + if(isError($kontakte_res)){ + return error(getData($kontakte_res)); + } + $kontakte_res = getData($kontakte_res); + return $kontakte_res; + } + + /** + * gets all the mailverteiler using the tables: tbl_benutzer, tbl_benutzergruppe, tbl_gruppe + * @access private + * @param integer $uid the userID used to retrieve the mailverteiler + * @return array returns the mailvertailer corresponding to a userID + */ + private function getMailverteiler($uid) + { + $this->ci->load->model("person/Person_model","PersonModel"); + $this->ci->PersonModel->addSelect('gruppe_kurzbz, beschreibung'); + $this->ci->PersonModel->addJoin('tbl_benutzer', 'person_id'); + $this->ci->PersonModel->addJoin('tbl_benutzergruppe', 'uid'); + $this->ci->PersonModel->addJoin('tbl_gruppe', 'gruppe_kurzbz'); + + $mailverteiler_res = $this->ci->PersonModel->loadWhere(array('mailgrp' => true, 'uid' => $uid)); + if(isError($mailverteiler_res)){ + return error(getData($mailverteiler_res)); + } + $mailverteiler_res = getData($mailverteiler_res) ?? []; + $mailverteiler_res = gettype($mailverteiler_res) === 'array' ? $mailverteiler_res : []; + $mailverteiler_res = array_map(function ($element) { + $element->mailto = "mailto:" . $element->gruppe_kurzbz . "@" . DOMAIN; + return $element; + }, $mailverteiler_res); + return $mailverteiler_res; + } + + /** + * gets the person information corresponding to a user + * @access private + * @param integer $uid the userID used to get the person information + * @param integer $geburtsInfo flag wether to add the columns gebort, gebdatum, foto_sperre or not + * @return array all the person informaion corresponding to a userID + */ + private function getPersonInfo($uid, $geburtsInfo = null) + { + $this->ci->load->model("person/Benutzer_model","BenutzerModel"); + $selectClause = ["foto", "foto_sperre", "anrede", "titelpost as postnomen", "titelpre as titel", "vorname", "nachname"]; + /** @param integer $geburtsInfo */ + if ($geburtsInfo) { + array_push($selectClause, "gebort"); + array_push($selectClause, "TO_CHAR(gebdatum, 'DD.MM.YYYY') as gebdatum"); + } + $this->ci->BenutzerModel->addSelect($selectClause); + $this->ci->BenutzerModel->addJoin("tbl_person", "person_id"); + + $person_res = $this->ci->BenutzerModel->load([$uid]); + if(isError($person_res)){ + return error(getData($person_res)); + } + $person_res = getData($person_res); + $person_res = $person_res ? current($person_res) : null; + + if(isset($person_res)){ + if( ($person_res->foto === null) || ((getAuthUID() !== $uid) && ($person_res->foto_sperre !== false)) ) + { + $dummy_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg')); + $person_res->foto = $dummy_foto; + } + } + + return $person_res; + } + + /** + * gets all the Benutzerfunktionen of a corresponding user + * @access private + * @param integer $uid the userID used to retrieve the Benutzerfunktionen + * @return array returns the Benutzerfunktionen corresponding to a userID + */ + private function getBenutzerFunktion($uid) + { + $this->ci->load->model("person/Benutzerfunktion_model","BenutzerfunktionModel"); + $this->ci->BenutzerfunktionModel->addSelect(["tbl_benutzerfunktion.bezeichnung as Bezeichnung", "tbl_organisationseinheit.bezeichnung as Organisationseinheit", "datum_von as Gültig_von", "datum_bis as Gültig_bis", "wochenstunden as Wochenstunden"]); + $this->ci->BenutzerfunktionModel->addJoin("tbl_organisationseinheit", "oe_kurzbz"); + + $benutzer_funktion_res = $this->ci->BenutzerfunktionModel->loadWhere(array('uid' => $uid)); + if(isError($benutzer_funktion_res)){ + return error(getData($benutzer_funktion_res)); + } + $benutzer_funktion_res = getData($benutzer_funktion_res); + return $benutzer_funktion_res; + } + + /** + * gets all the Betriebsmittel of a corresponding user + * @access private + * @param integer $uid the userID used to retrieve the Betriebsmittel + * @return array returns the Betriebsmittel corresponding to a userID + */ + private function getBetriebsmittelInfo($pid) + { + $this->ci->load->model("ressource/Betriebsmittelperson_model","BetriebsmittelpersonModel"); + $this->ci->BetriebsmittelpersonModel->addSelect(["CONCAT(betriebsmitteltyp, ' ' ,beschreibung) as Betriebsmittel", "nummer as Nummer", "ausgegebenam as Ausgegeben_am"]); + + //? betriebsmittel are not needed in a view + $betriebsmittelperson_res = $this->ci->BetriebsmittelpersonModel->getBetriebsmittel($pid); + if(isError($betriebsmittelperson_res)){ + return error(getData($betriebsmittelperson_res)); + } + $betriebsmittelperson_res = getData($betriebsmittelperson_res); + return $betriebsmittelperson_res; + } + + /** + * gets the profil updates corresponding to a user + * @access private + * @param integer $uid the userID used to get the profil updates + * @return array all the profil updates corresponding to a userID + */ + private function getProfilUpdates($uid) + { + $this->ci->load->model("person/Profil_update_model","ProfilUpdateModel"); + $profilUpdates = $this->ci->ProfilUpdateModel->getProfilUpdatesWhere(['uid' => $uid]); + if(isError($profilUpdates)){ + return error(getData($profilUpdates)); + } + $profilUpdates = getData($profilUpdates); + return $profilUpdates; + } + + /** + * gets the telefon information corresponding to a user + * @access private + * @param integer $uid the userID used to get the telefon information + * @return array all the telefon informaion corresponding to a userID + */ + private function getTelefonInfo($uid) + { + $this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel"); + $this->ci->MitarbeiterModel->addSelect(["kontakt"]); + $this->ci->MitarbeiterModel->addJoin("tbl_kontakt", "tbl_mitarbeiter.standort_id = tbl_kontakt.standort_id"); + $this->ci->MitarbeiterModel->addLimit(1); + $telefon_res = $this->ci->MitarbeiterModel->loadWhere(["mitarbeiter_uid" => $uid, "kontakttyp" => "telefon"]); + if(isError($telefon_res)){ + return error(getData($telefon_res)); + } + $telefon_res = getData($telefon_res); + $telefon_res = $telefon_res ? current($telefon_res) : null; + return $telefon_res; + } + + /** + * gets the mitarbeiter information corresponding to a user + * @access private + * @param integer $uid the userID used to get the mitarbeiter information + * @return array all the mitarbeiter informaion corresponding to a userID + */ + private function getMitarbeiterInfo($uid) + { + $this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel"); + $this->ci->MitarbeiterModel->addSelect(["kurzbz", "telefonklappe", "alias", "ort_kurzbz"]); + $this->ci->MitarbeiterModel->addJoin("tbl_benutzer", "tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid"); + $mitarbeiter_res = $this->ci->MitarbeiterModel->load($uid); + if(isError($mitarbeiter_res)){ + return error(getData($mitarbeiter_res)); + } + $mitarbeiter_res = getData($mitarbeiter_res); + $mitarbeiter_res = $mitarbeiter_res ? current($mitarbeiter_res) : null; + + return $mitarbeiter_res; + } + + /** + * gets the Zutrittsgruppen corresponding to a user + * @access private + * @param integer $uid the userID used to get the Zutrittsgruppen + * @return array all the Zutrittsgruppen corresponding to a userID + */ + private function getZutrittsgruppen($uid) + { + $this->ci->load->model("person/Benutzergruppe_model","BenutzergruppeModel"); + $this->ci->BenutzergruppeModel->addSelect(['bezeichnung']); + $this->ci->BenutzergruppeModel->addJoin('tbl_gruppe', 'gruppe_kurzbz'); + + $zutrittsgruppe_res = $this->ci->BenutzergruppeModel->loadWhere(array("uid" => $uid, "zutrittssystem" => true)); + if(isError($zutrittsgruppe_res)){ + return error(getData($zutrittsgruppe_res)); + } + $zutrittsgruppe_res = getData($zutrittsgruppe_res); + return $zutrittsgruppe_res; + } + + /** + * gets the student information corresponding to a user + * @access private + * @param integer $uid the userID used to get the student information + * @return array all the student informaion corresponding to a userID + */ + private function getStudentInfo($uid) + { + $this->ci->load->model("crm/Student_model","StudentModel"); + $this->ci->StudentModel->addSelect(['tbl_studiengang.bezeichnung as studiengang', 'tbl_studiengang.studiengang_kz as studiengang_kz', 'tbl_student.semester', 'tbl_student.verband', 'tbl_student.gruppe', 'tbl_student.matrikelnr as personenkennzeichen']); + $this->ci->StudentModel->addJoin('tbl_studiengang', "tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz"); + + $student_res = $this->ci->StudentModel->load([$uid]); + + if(isError($student_res)){ + return error(getData($student_res)); + } + $student_res = getData($student_res); + $student_res = $student_res ? current($student_res) : null; + return $student_res; + } + + /** + * gets the Matrikelnummer corresponding to a user + * @access private + * @param integer $uid the userID used to get the Matrikelnummer + * @return object the Matrikelnummer corresponding to a userID + */ + private function getMatrikelNummer($uid) + { + $this->ci->load->model("person/Benutzer_model","BenutzerModel"); + $this->ci->BenutzerModel->addSelect(["matr_nr"]); + $this->ci->BenutzerModel->addJoin("tbl_person", "person_id"); + + $matr_res = $this->ci->BenutzerModel->load([$uid]); + + if(isError($matr_res)){ + return error(getData($matr_res)); + } + $matr_res = getData($matr_res); + $matr_res = $matr_res ? current($matr_res) : []; + return $matr_res; + } + + /** + * checks whether the foto of a user is accepted or not + * @access private + * @param integer $pid the personId of the student or mitarbeiter + * @return bool whether the foto is accepted or not + */ + private function isFotoAkzeptiert($pid) + { + $this->ci->load->model('person/Fotostatusperson_model','FotostatusModel'); + $fotostatus = $this->ci->FotostatusModel->execReadOnlyQuery(" + select distinct on (person_id) person_id, insertamum, fotostatus_kurzbz + from public.tbl_person_fotostatus + where person_id = ? + order by person_id, insertamum desc",[$pid]); + if(isError($fotostatus)){ + return error(getData($fotostatus)); + } + $fotostatus = getData($fotostatus); + if(is_array($fotostatus) && count($fotostatus) > 0){ + $fotostatus = current($fotostatus)->fotostatus_kurzbz == 'akzeptiert'; + } + else + $fotostatus = false; + return $fotostatus; + } + + /** + * function that returns the data used for viewing another mitarbeiter profile + * @access private + * @param integer $uid the userID to retrieve the mitarbeiter data + * @return stdClass restricted mitarbeiter data + */ + private function viewMitarbeiterProfil($uid) + { + $mailverteiler_res = $this->getMailverteiler($uid); + $benutzer_funktion_res = $this->getBenutzerFunktion($uid); + $benutzer_res = $this->getBenutzerAlias($uid); + $person_res = $this->getPersonInfo($uid); + $mitarbeiter_res = $this->getMitarbeiterInfo($uid); + $telefon_res = $this->getTelefonInfo($uid); + + $res = new stdClass(); + $res->username = $uid; + + //? Person Info + foreach ($person_res as $key => $val) { + $res->$key = $val; + } + + //? Mitarbeiter Info + foreach ($mitarbeiter_res as $key => $val) { + $res->$key = $val; + + } + + $intern_email = array(); + $intern_email["type"] = "intern"; + $intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN:""; + $extern_email = array(); + $extern_email["type"] = "alias"; + + $extern_email["email"] = $benutzer_res->alias ? ($benutzer_res->alias . "@" . DOMAIN) : null; + $res->emails = $extern_email?[$intern_email, $extern_email]:[$intern_email]; + + $res->funktionen = $benutzer_funktion_res; + $res->mailverteiler = $mailverteiler_res; + $res->standort_telefon = isset($telefon_res) ? $telefon_res->kontakt : null; + + return $res; + } + + /** + * gets the alias of a corresponding user + * @access private + * @param integer $uid the userID used to get the alias + * @return string the alias of the userID + */ + private function getBenutzerAlias($uid) + { + $this->BenutzerModel->addSelect(["alias"]); + $benutzer_res = $this->BenutzerModel->load([$uid]); + $benutzer_res = $this->getDataOrTerminateWithError($benutzer_res); + $benutzer_res = $benutzer_res ? current($benutzer_res) : null; + + return $benutzer_res; + } + + /** + * function that returns the data used for viewing another student profile + * @access private + * @param integer $uid the userID to retrieve the student data + * @return stdClass restricted student data + */ + private function viewStudentProfil($uid) + { + $mailverteiler_res = $this->getMailverteiler($uid); + $person_res = $this->getPersonInfo($uid); + $student_res = $this->getStudentInfo($uid); + $matr_res = $this->getMatrikelNummer($uid); + + $res = new stdClass(); + $res->username = $uid; + + //? Person Information + foreach ($person_res as $key => $value) { + $res->$key = $value; + } + + //? Student Information + foreach ($student_res as $key => $value) { + $res->$key = $value; + } + + $intern_email = array(); + $intern_email["type"] = "intern"; + $intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN:""; + + $res->emails = [$intern_email]; + $res->matrikelnummer = $matr_res->matr_nr; + $res->mailverteiler = $mailverteiler_res; + + return $res; + } +} \ No newline at end of file diff --git a/public/js/api/factory/profil.js b/public/js/api/factory/profil.js index 5da1f202d..49d0263c6 100644 --- a/public/js/api/factory/profil.js +++ b/public/js/api/factory/profil.js @@ -22,6 +22,12 @@ export default { url: `/api/frontend/v1/Profil/getView/${uid}` }; }, + profilViewData(uid) { + return { + method: 'get', + url: `/api/frontend/v1/Profil/profilViewData/${uid}` + }; + }, fotoSperre(value) { return { method: 'get', @@ -69,5 +75,5 @@ export default { method: 'get', url: '/api/frontend/v1/Profil/getAllNationen' }; - } + }, }; \ No newline at end of file diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index 840cdefc1..456d32375 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -27,7 +27,7 @@ export default { ProfilInformation, }, - inject: ["sortProfilUpdates", "collapseFunction", "language"], + inject: ["sortProfilUpdates", "collapseFunction", "language","isEditable"], data() { return { @@ -215,9 +215,6 @@ export default { }, computed: { - editable() { - return this.data?.editAllowed ?? false; - }, fotoStatus() { return this.data?.fotoStatus ?? false; }, @@ -322,7 +319,7 @@ export default { --> -