mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
only displays profil update requests the uid has permissions for (mitarbeiter/stammdaten or student/stammdaten), also fixes bug and adds JSON.parse to get the value in the sessionStorage
This commit is contained in:
@@ -16,7 +16,7 @@ class Profil extends Auth_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions?
|
||||
'index' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'foto_sperre_function' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getView' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'View' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
@@ -63,6 +63,16 @@ class Profil extends Auth_Controller
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function test(){
|
||||
|
||||
// Loads permission lib
|
||||
$this->load->library('PermissionLib');
|
||||
$mit_daten =$this->permissionlib->isBerechtigt('mitarbeiter/stammdaten','suid');
|
||||
var_dump($mit_daten);
|
||||
$stud_daten = $this->permissionlib->isBerechtigt('student/stammdaten','suid');
|
||||
var_dump($stud_daten);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
@@ -149,12 +159,7 @@ class Profil extends Auth_Controller
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function test(){
|
||||
|
||||
// Loads permission lib
|
||||
$this->load->library('PermissionLib');
|
||||
var_dump($this->permissionlib->getOE_isEntitledFor());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct([
|
||||
'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions?
|
||||
'getProfilUpdates' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'acceptProfilRequest'=>['user:r'],
|
||||
'denyProfilRequest'=>['user:r'],
|
||||
'index' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
|
||||
'getProfilUpdates' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
|
||||
'acceptProfilRequest'=>['student/stammdaten:rw','mitarbeiter/stammdaten:rw'],
|
||||
'denyProfilRequest'=>['student/stammdaten:rw','mitarbeiter/stammdaten:rw'],
|
||||
'show'=>['user:r'],
|
||||
|
||||
|
||||
@@ -46,12 +46,16 @@ class ProfilUpdate extends Auth_Controller
|
||||
}
|
||||
|
||||
public function getProfilUpdates($status=null){
|
||||
$this->load->library('PermissionLib');
|
||||
$studentBerechtigung = $this->permissionlib->isBerechtigt('student/stammdaten','s');
|
||||
$mitarbeiterBerechtigung = $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten','s');
|
||||
|
||||
$options = ["mitarbeiterView"=>$mitarbeiterBerechtigung,"studentView"=>$studentBerechtigung];
|
||||
if(isset($status)){
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate(["status"=>$status]);
|
||||
}else{
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate();
|
||||
$options['status'] = $status;
|
||||
}
|
||||
$res = hasData($res)? getData($res) : null;
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate($options);
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ class Profil_change_model extends DB_Model
|
||||
$this->pk = ['profil_update_id'];
|
||||
$this->hasSequence = true;
|
||||
|
||||
|
||||
$this->load->model('crm/Student_model','StudentModel');
|
||||
$this->load->model('ressource/Mitarbeiter_model','MitarbeiterModel');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,22 +53,41 @@ class Profil_change_model extends DB_Model
|
||||
* returns all profil updates if id is set to null
|
||||
*/
|
||||
public function getProfilUpdate($whereClause=null){
|
||||
|
||||
$res = $this->loadWhere($whereClause);
|
||||
if(isError($res)){
|
||||
// catch error
|
||||
}else{
|
||||
if(hasData($res)){
|
||||
|
||||
foreach($res->retval as $update){
|
||||
$update->requested_change = json_decode($update->requested_change);
|
||||
$update->insertamum = !is_null($update->insertamum)?date_create($update->insertamum)->format('d.m.Y'):null;
|
||||
$update->updateamum = !is_null($update->updateamum)?date_create($update->updateamum)->format('d.m.Y'):null;
|
||||
$update->status_timestamp = !is_null($update->status_timestamp)?date_create($update->status_timestamp)->format('d.m.Y'):null;
|
||||
|
||||
}
|
||||
$res =[];
|
||||
if($whereClause["studentView"]) {
|
||||
$this->addJoin('tbl_student','tbl_student.student_uid=tbl_cis_profil_update.uid');
|
||||
$studentRequests = $this->loadWhere(isset($whereClause['status']) && $whereClause['status']? ['status'=>$whereClause['status']]:[]);
|
||||
if(isError($studentRequests)) return error("db error: ". getData($studentRequests));
|
||||
$studentRequests = getData($studentRequests)?:[];
|
||||
foreach($studentRequests as $request){
|
||||
array_push($res,$request);
|
||||
}
|
||||
}
|
||||
if($whereClause["mitarbeiterView"]) {
|
||||
$this->addJoin('tbl_mitarbeiter','tbl_mitarbeiter.mitarbeiter_uid=tbl_cis_profil_update.uid');
|
||||
$mitarbeiterRequests = $this->loadWhere(isset($whereClause['status']) && $whereClause['status']? ['status'=>$whereClause['status']]:[]);
|
||||
if(isError($mitarbeiterRequests)) return error("db error: ". getData($mitarbeiterRequests));
|
||||
$mitarbeiterRequests = getData($mitarbeiterRequests)?:[];
|
||||
foreach($mitarbeiterRequests as $request){
|
||||
array_push($res,$request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($res){
|
||||
|
||||
foreach($res as $update){
|
||||
|
||||
|
||||
$update->requested_change = json_decode($update->requested_change);
|
||||
$update->insertamum = !is_null($update->insertamum)?date_create($update->insertamum)->format('d.m.Y'):null;
|
||||
$update->updateamum = !is_null($update->updateamum)?date_create($update->updateamum)->format('d.m.Y'):null;
|
||||
$update->status_timestamp = !is_null($update->status_timestamp)?date_create($update->status_timestamp)->format('d.m.Y'):null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ const app = Vue.createApp({
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editData: this.filteredEditData,
|
||||
|
||||
view:null,
|
||||
data:null,
|
||||
// notfound is null by default, but contains an UID if no user exists with that UID
|
||||
@@ -58,7 +58,7 @@ const app = Vue.createApp({
|
||||
provide() {
|
||||
return {
|
||||
|
||||
editData:this.editData,
|
||||
|
||||
collapseFunction: (e, column)=> {
|
||||
|
||||
//* check if property doesn't exist already and add it to the reactive this properties
|
||||
@@ -229,14 +229,14 @@ const app = Vue.createApp({
|
||||
},
|
||||
template:`
|
||||
<div>
|
||||
<pre>{{JSON.stringify(data.profilUpdates.length,null,2)}}</pre>
|
||||
|
||||
<div v-if="notFoundUID">
|
||||
|
||||
<h3>Es wurden keine oder mehrere Profile für {{this.notFoundUID}} gefunden</h3>
|
||||
|
||||
</div>
|
||||
|
||||
<component v-else :is="view" :data="data" ></component>
|
||||
<component v-else :is="view" :data="data" :editData="filteredEditData" ></component>
|
||||
|
||||
</div>`
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ const app = Vue.createApp({
|
||||
//params - the parameters passed with the request
|
||||
//response - the JSON object returned in the body of the response.
|
||||
//? sorts the response data from the backend
|
||||
if(response)
|
||||
response.sort(sortProfilUpdates);
|
||||
|
||||
return response;
|
||||
},
|
||||
//? adds tooltip with the status message of a profil update request if its status is not pending
|
||||
@@ -122,11 +124,11 @@ const app = Vue.createApp({
|
||||
ajaxURLGenerator: (url,config,params)=>{
|
||||
//? this function needs to be an array function in order to access the this properties of the Vue component
|
||||
if(this.showAll){
|
||||
return url +"getProfilUpdates";
|
||||
return url +"getProfilUpdates";
|
||||
}else{
|
||||
return url +"getProfilUpdates/pending";
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
height: 600,
|
||||
layout: "fitColumns",
|
||||
@@ -238,13 +240,13 @@ const app = Vue.createApp({
|
||||
|
||||
this.$refs.UpdatesTable.tabulator.setData();
|
||||
//? store the selected view in the session storage of the browser
|
||||
sessionStorage.setItem("showAll",event.target.value);
|
||||
sessionStorage.setItem("showAll",JSON.stringify(event.target.value));
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if(!(sessionStorage.getItem("showAll")===null))
|
||||
{
|
||||
this.showAll = sessionStorage.getItem("showAll");
|
||||
this.showAll = JSON.parse(sessionStorage.getItem("showAll"));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -109,9 +109,7 @@ export default {
|
||||
if(filesToDelete.length > 0) {
|
||||
Vue.$fhcapi.UserData.deleteOldVersionFiles(
|
||||
filesToDelete
|
||||
).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
RoleInformation,
|
||||
ProfilInformation,
|
||||
},
|
||||
inject: ['sortProfilUpdates','collapseFunction','editData'],
|
||||
inject: ['sortProfilUpdates','collapseFunction'],
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -136,6 +136,7 @@ export default {
|
||||
|
||||
props: {
|
||||
data: Object,
|
||||
editData: Object,
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -218,33 +219,11 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
personEmails() {
|
||||
return this.data?.emails ? this.data.emails : [];
|
||||
},
|
||||
|
||||
privateKontakte() {
|
||||
if (!this.data) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return this.data.kontakte;
|
||||
|
||||
},
|
||||
|
||||
privateAdressen() {
|
||||
if (!this.data) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return this.data.adressen;
|
||||
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
created() {
|
||||
|
||||
|
||||
//? sorts the profil Updates: pending -> accepted -> rejected
|
||||
this.data.profilUpdates.sort(this.sortProfilUpdates);
|
||||
|
||||
@@ -348,7 +327,7 @@ export default {
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<!-- EMAILS -->
|
||||
<profil-emails :data="personEmails" ></profil-emails>
|
||||
<profil-emails :data="data.emails" ></profil-emails>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -365,7 +344,7 @@ export default {
|
||||
<div class="card-body ">
|
||||
|
||||
<div class="gy-3 row ">
|
||||
<div v-for="element in privateKontakte" class="col-12">
|
||||
<div v-for="element in data.kontakte" class="col-12">
|
||||
|
||||
<Kontakt :data="element"></Kontakt>
|
||||
|
||||
@@ -387,7 +366,7 @@ export default {
|
||||
<div class="card-body">
|
||||
|
||||
<div class="gy-3 row ">
|
||||
<div v-for="element in privateAdressen" class="col-12">
|
||||
<div v-for="element in data.adressen" class="col-12">
|
||||
<Adresse :data="element"></Adresse>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,7 @@ export default {
|
||||
FetchProfilUpdates,
|
||||
|
||||
},
|
||||
inject:['sortProfilUpdates'],
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -76,14 +77,17 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
props: ["data"],
|
||||
props: {
|
||||
data:Object,
|
||||
editData:Object,
|
||||
},
|
||||
methods: {
|
||||
|
||||
fetchProfilUpdates: function(){
|
||||
Vue.$fhcapi.UserData.selectProfilRequest().then((res)=>{
|
||||
|
||||
if(!res.error){
|
||||
this.data.profilUpdates = res.data.retval?.length ? res.data.retval : null ;
|
||||
this.data.profilUpdates = res.data.retval?.length ? res.data.retval.sort(this.sortProfilUpdates) : null ;
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -91,14 +95,14 @@ export default {
|
||||
showModal() {
|
||||
|
||||
EditProfil.popup({
|
||||
value:JSON.parse(JSON.stringify(this.data.editData)),
|
||||
value:JSON.parse(JSON.stringify(this.editData)),
|
||||
title:"Profil bearbeiten",
|
||||
}).then((popup_result) => {
|
||||
if(popup_result){
|
||||
Vue.$fhcapi.UserData.selectProfilRequest()
|
||||
.then((res) =>{
|
||||
if(!res.error){
|
||||
this.data.profilUpdates = res.data.retval;
|
||||
this.data.profilUpdates = res.data.retval.sort(this.sortProfilUpdates);
|
||||
}else{
|
||||
alert("Error when fetching profile updates: " +res.data.retval);
|
||||
}
|
||||
@@ -133,10 +137,6 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
personEmails() {
|
||||
return this.data?.emails ? this.data.emails : [];
|
||||
},
|
||||
|
||||
|
||||
roleInformation() {
|
||||
if (!this.data) {
|
||||
@@ -154,89 +154,10 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
privateKontakte() {
|
||||
if (!this.data) {
|
||||
return {};
|
||||
}
|
||||
return this.data.kontakte;
|
||||
},
|
||||
|
||||
privateAdressen() {
|
||||
if (!this.data) {
|
||||
return {};
|
||||
}
|
||||
return this.data.adressen;
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
created(){
|
||||
this.data.editData = {
|
||||
view:null,
|
||||
data:{
|
||||
Personen_Informationen : {
|
||||
title:"Personen Informationen",
|
||||
view:null,
|
||||
data:{
|
||||
|
||||
vorname: {
|
||||
title:"vorname",
|
||||
view:"TextInputDokument",
|
||||
withFiles:true,
|
||||
data:{
|
||||
titel:"vorname",
|
||||
value:this.data.vorname,
|
||||
}},
|
||||
nachname: {
|
||||
title:"nachname",
|
||||
view:"TextInputDokument",
|
||||
withFiles:true,
|
||||
data:{
|
||||
titel:"nachname",
|
||||
value:this.data.nachname,
|
||||
}
|
||||
},
|
||||
titel:{
|
||||
title:"titel",
|
||||
view:"TextInputDokument",
|
||||
withFiles:true,
|
||||
data:{
|
||||
titel:"titel",
|
||||
value:this.data.titel,
|
||||
}
|
||||
},
|
||||
postnomen:{
|
||||
title:"postnomen",
|
||||
view:"TextInputDokument",
|
||||
withFiles:true,
|
||||
data:{
|
||||
titel:"postnomen",
|
||||
value:this.data.postnomen,
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
Private_Kontakte: {
|
||||
title:"Private Kontakte" ,
|
||||
data:this.privateKontakte.map(kontakt => {
|
||||
return {
|
||||
listview:'Kontakt',
|
||||
view:'EditKontakt',
|
||||
data:kontakt
|
||||
}})
|
||||
},
|
||||
Private_Adressen: {
|
||||
title: "Private Adressen",
|
||||
data:this.privateAdressen.map(kontakt => {
|
||||
return {
|
||||
listview:'Adresse',
|
||||
view:'EditAdresse',
|
||||
data:kontakt
|
||||
}})
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@@ -361,7 +282,7 @@ export default {
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<!-- EMAILS -->
|
||||
<profil-emails :data="personEmails" ></profil-emails>
|
||||
<profil-emails :data="data.emails" ></profil-emails>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -379,7 +300,7 @@ export default {
|
||||
<div class="card-body ">
|
||||
|
||||
<div class="gy-3 row ">
|
||||
<div v-for="element in privateKontakte" class="col-12">
|
||||
<div v-for="element in data.kontakte" class="col-12">
|
||||
|
||||
<Kontakt :data="element"></Kontakt>
|
||||
|
||||
@@ -400,7 +321,7 @@ export default {
|
||||
<div class="card-body">
|
||||
|
||||
<div class="gy-3 row ">
|
||||
<div v-for="element in privateAdressen" class="col-12">
|
||||
<div v-for="element in data.adressen" class="col-12">
|
||||
<Adresse :data="element"></Adresse>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user