mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
refactor(Profil Library): exports Profil functions in its own library to reuse functionalities
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,583 @@
|
||||
<?php
|
||||
|
||||
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class ProfilLib{
|
||||
public function __construct()
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -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 {
|
||||
</div>
|
||||
</div>-->
|
||||
<!-- Bearbeiten Button -->
|
||||
<div class="row mb-3 ">
|
||||
<div v-if="isEditable" class="row mb-3 ">
|
||||
<div class="col">
|
||||
<button @click="()=>showEditProfilModal()" type="button" class="text-start w-100 btn btn-outline-secondary" >
|
||||
<div class="row">
|
||||
@@ -352,7 +349,7 @@ export default {
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<!-- PROFIL INFORMATION -->
|
||||
<profil-information @showEditProfilModal="showEditProfilModal" :title="$p.t('profil','mitarbeiterIn')" :data="profilInformation" :editable="editable" :fotoStatus="fotoStatus"></profil-information>
|
||||
<profil-information @showEditProfilModal="showEditProfilModal" :title="$p.t('profil','mitarbeiterIn')" :data="profilInformation" :fotoStatus="fotoStatus"></profil-information>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
|
||||
@@ -110,9 +110,6 @@ export default {
|
||||
return this.data.telefonklappe
|
||||
}
|
||||
},
|
||||
editable() {
|
||||
return this.data?.editAllowed ?? false;
|
||||
},
|
||||
fotoStatus() {
|
||||
return this.data?.fotoStatus ?? false;
|
||||
},
|
||||
@@ -202,7 +199,7 @@ export default {
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<!-- Profil Informationen -->
|
||||
<profil-information :title="$p.t('profil','mitarbeiterIn')" :data="profilInformation" :editable="editable" :fotoStatus="fotoStatus"></profil-information>
|
||||
<profil-information :title="$p.t('profil','mitarbeiterIn')" :data="profilInformation" :fotoStatus="fotoStatus"></profil-information>
|
||||
</div>
|
||||
</div>
|
||||
<!-- START OF SECOND PROFIL INFORMATION COLUMN -->
|
||||
|
||||
@@ -46,7 +46,10 @@ export const Profil = {
|
||||
props: {
|
||||
uid: {
|
||||
type: String,
|
||||
default: 'Profil'
|
||||
required:false,
|
||||
},
|
||||
viewData: {
|
||||
type: Object,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -59,10 +62,12 @@ export const Profil = {
|
||||
data: null,
|
||||
// notfound is null by default, but contains an UID if no user exists with that UID
|
||||
notFoundUID: null,
|
||||
isEditable: this.viewData.editable ?? false,
|
||||
};
|
||||
},
|
||||
provide() {
|
||||
return {
|
||||
isEditable: Vue.computed(()=>this.isEditable),
|
||||
profilUpdateStates: Vue.computed(() =>
|
||||
this.profilUpdateStates ? this.profilUpdateStates : false
|
||||
),
|
||||
@@ -153,18 +158,19 @@ export const Profil = {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
let uid = this.uid ?? location.pathname.split("/").pop();
|
||||
|
||||
|
||||
this.$api
|
||||
.call(ApiProfil.getView(uid))
|
||||
.then((res) => {
|
||||
if (!res.data) {
|
||||
this.notFoundUID = uid;
|
||||
} else {
|
||||
this.view = res.data?.view;
|
||||
this.data = res.data?.data;
|
||||
}
|
||||
});
|
||||
.call(ApiProfil.profilViewData(this.$route.params.uid??null))
|
||||
.then((response) => response.data).then(data=>{
|
||||
this.view = data?.profil_data.view;
|
||||
this.data = data?.profil_data.data;
|
||||
this.isEditable = data?.editable ?? false;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
zustellAdressenCount() {
|
||||
if (!this.data || !this.data.adressen) {
|
||||
@@ -254,6 +260,7 @@ export const Profil = {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
|
||||
filteredEditData() {
|
||||
if (!this.data) {
|
||||
return;
|
||||
@@ -365,7 +372,7 @@ export const Profil = {
|
||||
this.load()
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
created() {
|
||||
this.load()
|
||||
},
|
||||
template: `
|
||||
|
||||
@@ -9,10 +9,6 @@ export default {
|
||||
data: {
|
||||
type: Object,
|
||||
},
|
||||
editable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
fotoStatus:{
|
||||
type: Boolean,
|
||||
default: true
|
||||
@@ -27,6 +23,7 @@ export default {
|
||||
};
|
||||
},
|
||||
emits: ["showEditProfilModal"],
|
||||
inject:["isEditable"],
|
||||
|
||||
methods: {
|
||||
showModal(){
|
||||
@@ -76,7 +73,7 @@ export default {
|
||||
<image-upload ref="imageUpload" :titel="$p.t('profilUpdate','profilBild')"></image-upload>
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div v-if="editable" @click="$emit('showEditProfilModal','Personen_Informationen')" class="col-auto" type="button">
|
||||
<div v-if="isEditable" @click="$emit('showEditProfilModal','Personen_Informationen')" class="col-auto" type="button">
|
||||
<i class="fa fa-edit"></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
@@ -93,7 +90,7 @@ export default {
|
||||
<div class="col-auto " style="position:relative">
|
||||
<img alt="profile picture" class=" img-thumbnail " style=" max-height:150px; " :src="get_image_base64_src"/>
|
||||
<!-- LOCKING IMAGE FUNCTIONALITY -->
|
||||
<div v-if="editable" role="button" @click.prevent="sperre_foto_function" class="image-lock">
|
||||
<div v-if="isEditable" role="button" @click.prevent="sperre_foto_function" class="image-lock">
|
||||
<i :class="{'fa':true, ...(FotoSperre?{'fa-lock':true}:{'fa-lock-open':true})} "></i>
|
||||
</div>
|
||||
<div v-if="!fotoStatus" role="button" @click.prevent="showModal" class="image-upload">
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
FetchProfilUpdates,
|
||||
EditProfil,
|
||||
},
|
||||
inject: ["sortProfilUpdates", "collapseFunction", "language"],
|
||||
inject: ["sortProfilUpdates", "collapseFunction", "language","isEditable"],
|
||||
data() {
|
||||
return {
|
||||
showModal: false,
|
||||
@@ -163,9 +163,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
editable() {
|
||||
return this.data?.editAllowed ?? false;
|
||||
},
|
||||
|
||||
fotoStatus() {
|
||||
return this.data?.fotoStatus ?? false;
|
||||
},
|
||||
@@ -264,7 +262,7 @@ export default {
|
||||
</div>-->
|
||||
|
||||
<!-- Bearbeiten Button -->
|
||||
<div v-if="editable" class="row ">
|
||||
<div v-if="isEditable" class="row ">
|
||||
<div class="col mb-3">
|
||||
<button @click="showEditProfilModal" type="button" class="text-start w-100 btn btn-outline-secondary" >
|
||||
<div class="row">
|
||||
@@ -295,7 +293,7 @@ export default {
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<!-- PROFIL INFORMATION -->
|
||||
<profil-information @showEditProfilModal="showEditProfilModal" :title="$p.t('profil','studentIn')" :data="profilInformation" :editable="editable" :fotoStatus="fotoStatus"></profil-information>
|
||||
<profil-information @showEditProfilModal="showEditProfilModal" :title="$p.t('profil','studentIn')" :data="profilInformation" :fotoStatus="fotoStatus"></profil-information>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
|
||||
@@ -26,9 +26,6 @@ export default {
|
||||
methods: {},
|
||||
|
||||
computed: {
|
||||
editable() {
|
||||
return this.data?.editAllowed ?? false;
|
||||
},
|
||||
fotoStatus() {
|
||||
return this.data?.fotoStatus ?? false;
|
||||
},
|
||||
@@ -118,7 +115,7 @@ export default {
|
||||
<div class="col-lg-12 col-xl-6 ">
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<profil-information :data="profilInformation" :title="$p.t('profil','studentIn')" :editable="editable" :fotoStatus="fotoStatus"></profil-information>
|
||||
<profil-information :data="profilInformation" :title="$p.t('profil','studentIn')" :fotoStatus="fotoStatus"></profil-information>
|
||||
</div>
|
||||
</div>
|
||||
<!-- START OF SECOND PROFIL INFORMATION COLUMN -->
|
||||
|
||||
Reference in New Issue
Block a user