mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
adds isMitarbeiter to the new Profil FhcAPIController
This commit is contained in:
@@ -36,6 +36,7 @@ class Profil extends FHCAPI_Controller
|
||||
'fotoSperre' => self::PERM_LOGGED,
|
||||
'getGemeinden' => self::PERM_LOGGED,
|
||||
'getAllNationen' => self::PERM_LOGGED,
|
||||
'isMitarbeiter' => self::PERM_LOGGED,
|
||||
|
||||
]);
|
||||
|
||||
@@ -160,7 +161,7 @@ class Profil extends FHCAPI_Controller
|
||||
$nation_res = $this->NationModel->load();
|
||||
|
||||
if (isError($nation_res)) {
|
||||
show_error("error while trying to query table codex.tbl_nation");
|
||||
$this->terminateWithError("error while trying to query table codex.tbl_nation", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$nation_res = $this->getDataOrTerminateWithError($nation_res);
|
||||
@@ -278,6 +279,29 @@ class Profil extends FHCAPI_Controller
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether a specific userID is a mitarbeiter or not (foreword declaration of the function isMitarbeiter in Mitarbeiter_model.php)
|
||||
* @access public
|
||||
* @param $uid the userID used to check if it is a mitarbeiter
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMitarbeiter($uid)
|
||||
{
|
||||
|
||||
if(!$uid) $this->terminateWithError("No uid provided", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
$result = $this->MitarbeiterModel->isMitarbeiter($uid);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError("error when calling Mitarbeiter_model function isMitarbeiter with uid " . $uid, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for the mitarbeiter profile
|
||||
* @access private
|
||||
|
||||
@@ -33,10 +33,8 @@ export default {
|
||||
return this.$fhcApi.get(
|
||||
FHC_JS_DATA_STORAGE_OBJECT.app_root +
|
||||
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
|
||||
`/api/frontend/v1/Profil/isMitarbeiter`,
|
||||
{
|
||||
uid:uid,
|
||||
}
|
||||
`/api/frontend/v1/Profil/isMitarbeiter/${uid}`,
|
||||
{}
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
@@ -74,11 +74,9 @@ export default {
|
||||
files: files,
|
||||
};
|
||||
|
||||
//?TODO: check if updateRequest.uid is a mitarbeiter, if so add the flag isMitarbeiter:true
|
||||
if (view === "EditAdresse") {
|
||||
const isMitarbeiter = await Vue.$fhcapi.UserData.isMitarbeiter(
|
||||
updateRequest.uid
|
||||
).then((res) => res.data);
|
||||
|
||||
const isMitarbeiter = await this.$fhcApi.factory.profil.isMitarbeiter(updateRequest.uid).then((res)=>res.data);
|
||||
|
||||
if (isMitarbeiter) {
|
||||
content["isMitarbeiter"] = isMitarbeiter;
|
||||
@@ -141,83 +139,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// OLD way to open the editProfil modal, which was dynamically added to the html and then removed
|
||||
async openModal(updateRequest) {
|
||||
let view = this.getView(updateRequest.topic, updateRequest.status);
|
||||
|
||||
let data = null;
|
||||
let content = null;
|
||||
let files = null;
|
||||
let withFiles = false;
|
||||
|
||||
if (view === "TextInputDokument") {
|
||||
data = {
|
||||
titel: updateRequest.topic,
|
||||
value: updateRequest.requested_change.value,
|
||||
};
|
||||
|
||||
const filesFromDatabase =
|
||||
await Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles(
|
||||
updateRequest.profil_update_id
|
||||
).then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
|
||||
files = filesFromDatabase;
|
||||
if (files) {
|
||||
withFiles = true;
|
||||
}
|
||||
} else {
|
||||
data = updateRequest.requested_change;
|
||||
}
|
||||
|
||||
content = {
|
||||
updateID: updateRequest.profil_update_id,
|
||||
view: view,
|
||||
data: data,
|
||||
withFiles: withFiles,
|
||||
topic: updateRequest.topic,
|
||||
files: files,
|
||||
};
|
||||
|
||||
//?TODO: check if updateRequest.uid is a mitarbeiter, if so add the flag isMitarbeiter:true
|
||||
if (view === "EditAdresse") {
|
||||
const isMitarbeiter = await Vue.$fhcapi.UserData.isMitarbeiter(
|
||||
updateRequest.uid
|
||||
).then((res) => res.data);
|
||||
|
||||
if (isMitarbeiter) {
|
||||
content["isMitarbeiter"] = isMitarbeiter;
|
||||
}
|
||||
}
|
||||
|
||||
//? adds the status information if the profil update request was rejected or accepted
|
||||
if (updateRequest.status !== this.profilUpdateStates["Pending"]) {
|
||||
content["status"] = updateRequest.status;
|
||||
content["status_message"] = updateRequest.status_message;
|
||||
content["status_timestamp"] = updateRequest.status_timestamp;
|
||||
}
|
||||
|
||||
//? only show the popup if also the right content is available
|
||||
if (content) {
|
||||
EditProfil.popup({
|
||||
value: content,
|
||||
title: updateRequest.topic,
|
||||
zustellkontakteCount: this.getZustellkontakteCount,
|
||||
zustelladressenCount: this.getZustelladressenCount,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res === true) {
|
||||
this.$emit("fetchUpdates");
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
// Wenn der User das Modal abbricht ohne Änderungen
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {},
|
||||
|
||||
computed: {},
|
||||
|
||||
Reference in New Issue
Block a user