mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
funciton that queries the ProfilUpdates now takes a associative array instead of multiple separate parameters
This commit is contained in:
@@ -162,17 +162,12 @@ class Profil extends Auth_Controller
|
||||
$_GET = json_decode($this->input->raw_input_stream, true);
|
||||
$uid = $this->input->get('uid');
|
||||
$id = $this->input->get('id');
|
||||
$whereClause=['uid'=> $this->uid];
|
||||
|
||||
if(isset($uid)) $whereClause['uid'] = $uid;
|
||||
if(isset($id)) $whereClause['id'] = $id;
|
||||
|
||||
if($uid && $id){
|
||||
$res= $this->ProfilChangeModel->getProfilUpdate($uid, $id);
|
||||
}elseif($uid){
|
||||
$res= $this->ProfilChangeModel->getProfilUpdate($uid);
|
||||
}elseif($id){
|
||||
$res= $this->ProfilChangeModel->getProfilUpdate($this->uid, $id);
|
||||
}else{
|
||||
$res= $this->ProfilChangeModel->getProfilUpdate($this->uid);
|
||||
}
|
||||
$res= $this->ProfilChangeModel->getProfilUpdate($whereClause);
|
||||
|
||||
echo json_encode($res);
|
||||
|
||||
@@ -659,7 +654,7 @@ class Profil extends Auth_Controller
|
||||
|
||||
|
||||
//? querying if the user has profil update requests
|
||||
$profilUpdates = $this->ProfilChangeModel->getProfilUpdate($this->uid);
|
||||
$profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]);
|
||||
if(isError($profilUpdates)){
|
||||
//error handling
|
||||
}else{
|
||||
@@ -769,9 +764,8 @@ class Profil extends Auth_Controller
|
||||
|
||||
if (
|
||||
|
||||
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as adr_typ", "plz", "ort"])) &&
|
||||
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as adr_typ", "plz", "ort","zustelladresse"])) &&
|
||||
isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC")) &&
|
||||
isSuccess($adresse_res = $this->AdresseModel->addOrder("sort")) &&
|
||||
isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"))
|
||||
) {
|
||||
$adresse_res = $this->AdresseModel->loadWhere(array("person_id" => $this->pid));
|
||||
@@ -866,7 +860,7 @@ class Profil extends Auth_Controller
|
||||
}
|
||||
|
||||
//? querying if the user has profil update requests
|
||||
$profilUpdates = $this->ProfilChangeModel->getProfilUpdate($this->uid);
|
||||
$profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]);
|
||||
if(isError($profilUpdates)){
|
||||
//error handling
|
||||
}else{
|
||||
|
||||
@@ -12,11 +12,11 @@ class ProfilUpdate extends Auth_Controller
|
||||
public function __construct(){
|
||||
parent::__construct([
|
||||
'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions?
|
||||
'getAllRequests' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getProfilUpdates' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'acceptProfilRequest'=>['user:r'],
|
||||
'denyProfilRequest'=>['user:r'],
|
||||
'show'=>['user:r'],
|
||||
'getPendingRequests'=>['user:r'],
|
||||
|
||||
|
||||
]);
|
||||
|
||||
@@ -45,20 +45,16 @@ class ProfilUpdate extends Auth_Controller
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function getAllRequests(){
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate();
|
||||
public function getProfilUpdates($status=null){
|
||||
if(isset($status)){
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate(["status"=>$status]);
|
||||
}else{
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate();
|
||||
}
|
||||
$res = hasData($res)? getData($res) : null;
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function getPendingRequests(){
|
||||
$res = $this->ProfilChangeModel->loadWhere(["status"=>"pending"]);
|
||||
|
||||
$res = hasData($res)? getData($res) : [];
|
||||
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function acceptProfilRequest(){
|
||||
|
||||
|
||||
@@ -49,15 +49,7 @@ class Profil_change_model extends DB_Model
|
||||
* returns a profil update with id
|
||||
* returns all profil updates if id is set to null
|
||||
*/
|
||||
public function getProfilUpdate($uid=null,$id=null){
|
||||
$whereClause=[];
|
||||
|
||||
if(!is_null($uid)){
|
||||
$whereClause['uid']=$uid;
|
||||
}
|
||||
if(!is_null($id)){
|
||||
$whereClause['profil_update_id']=$id;
|
||||
}
|
||||
public function getProfilUpdate($whereClause=null){
|
||||
|
||||
$res = $this->loadWhere($whereClause);
|
||||
if(isError($res)){
|
||||
@@ -68,6 +60,7 @@ class Profil_change_model extends DB_Model
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user