mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
Merge branch 'ci' of https://github.com/FH-Complete/FHC-Core into ci
Conflicts: application/config/autoload.php application/controllers/api/v1/Person.php application/models/person/Person_model.php
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class Kontakt_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct($uid = null)
|
||||
{
|
||||
parent::__construct($uid);
|
||||
$this->dbTable = 'public.tbl_kontakt';
|
||||
}
|
||||
|
||||
public function saveKontakt($kontakt)
|
||||
{
|
||||
//TODO check berechtigung
|
||||
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
|
||||
// {
|
||||
$data = array(
|
||||
"person_id"=>$kontakt["person_id"],
|
||||
"kontakttyp"=>$kontakt["kontakttyp"],
|
||||
"kontakt"=>$kontakt["kontakt"],
|
||||
"insertvon"=>$kontakt["insertvon"],
|
||||
"insertamum"=>date('Y-m-d H:i:s')
|
||||
);
|
||||
if($this->db->insert("public.tbl_kontakt", $data)){
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "Nicht berechtigt";
|
||||
// }
|
||||
}
|
||||
|
||||
public function getKontaktPerson($person_id)
|
||||
{
|
||||
$this->db->select("*")
|
||||
->from("public.tbl_kontakt k")
|
||||
->where("k.person_id", $person_id);
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,36 @@
|
||||
<?php
|
||||
class Person_model extends DB_Model
|
||||
|
||||
class Person_model extends DB_Model
|
||||
{
|
||||
public function __construct($uid=null)
|
||||
|
||||
public function __construct($uid = null)
|
||||
{
|
||||
parent::__construct($uid);
|
||||
$this->dbTable = 'public.tbl_person';
|
||||
}
|
||||
|
||||
public function getPerson($person_id = null)
|
||||
{
|
||||
if (is_null($person_id))
|
||||
{
|
||||
parent::__construct($uid);
|
||||
$this->dbTable='public.tbl_person';
|
||||
$query = $this->db->get_where('public.tbl_person', array());
|
||||
return $query->result_object();
|
||||
}
|
||||
|
||||
public function getPerson($person_id = null)
|
||||
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
|
||||
return $query->row_object();
|
||||
}
|
||||
|
||||
public function getPersonByCode($code)
|
||||
{
|
||||
if ($this->fhc_db_acl->bb->isBerechtigt('person', 's'))
|
||||
{
|
||||
if (is_null($person_id))
|
||||
{
|
||||
$query = $this->db->get_where('public.tbl_person', array('vorname' => 'Christian'));
|
||||
return $query->result_object();
|
||||
}
|
||||
|
||||
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
|
||||
return $query->row_object();
|
||||
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
|
||||
return $query->result_object();
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* Laedt Personendaten einer Person mittels Code
|
||||
* @param string $code DB-Attr: tbl_benutzer.zugangscode .
|
||||
@@ -36,22 +48,117 @@ class Person_model extends DB_Model
|
||||
return $this->_general_error($this->fhc_db_acl->bb->errormsg);
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt Personendaten eine BenutzerUID
|
||||
* @param string $uid DB-Attr: tbl_benutzer.uid .
|
||||
* @return bool
|
||||
*/
|
||||
public function getPersonFromBenutzerUID($uid)
|
||||
=======
|
||||
/**
|
||||
* Laedt Personendaten eine BenutzerUID
|
||||
* @param string $uid DB-Attr: tbl_benutzer.uid .
|
||||
* @return bool
|
||||
*/
|
||||
public function getPersonFromBenutzerUID($uid)
|
||||
{
|
||||
if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
|
||||
{
|
||||
|
||||
if (!$this->fhc_db_acl->bb->isBerechtigt('person','s'))
|
||||
{
|
||||
$this->db->select('tbl_person.*');
|
||||
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
|
||||
$query = $this->db->get_where(null, array('uid' => $uid));
|
||||
return $query->result_object();
|
||||
}
|
||||
$this->db->select('tbl_person.*');
|
||||
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
|
||||
$query = $this->db->get_where(null, array('uid' => $uid));
|
||||
return $query->result_object();
|
||||
>>>>>>> 97ddc838a8c9e707d3bf5a6a700301252d2f5ed8
|
||||
}
|
||||
}
|
||||
|
||||
public function savePerson($person)
|
||||
{
|
||||
//TODO check berechtigung
|
||||
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
|
||||
// {
|
||||
$data = array(
|
||||
"vorname"=>$person["vorname"],
|
||||
"nachname"=>$person["nachname"],
|
||||
"gebdatum"=>$person["gebdatum"],
|
||||
"aktiv" => true,
|
||||
"zugangscode"=>$person["zugangscode"],
|
||||
"insertamum"=>date('Y-m-d H:i:s'),
|
||||
"insertvon"=>$person["insertvon"],
|
||||
);
|
||||
if($this->db->insert("public.tbl_person", $data)){
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "Nicht berechtigt";
|
||||
// }
|
||||
}
|
||||
|
||||
public function checkBewerbung($email, $studiensemester_kurzbz=NULL)
|
||||
{
|
||||
$this->db->distinct();
|
||||
|
||||
if(is_null($studiensemester_kurzbz))
|
||||
{
|
||||
$this->db->select("p.person_id, p.zugangscode, p.insertamum")
|
||||
->from("public.tbl_person p")
|
||||
->join("public.tbl_kontakt k", "p.person_id=k.person_id")
|
||||
->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
|
||||
->where("k.kontakttyp", 'email')
|
||||
->where("(kontakt='".$email."'".
|
||||
" OR alias ||'@technikum-wien.at'='".$email."'".
|
||||
" OR uid ||'@technikum-wien.at'='".$email."')")
|
||||
->order_by("p.insertamum", "DESC")
|
||||
->limit(1)
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->select("p.person_id,p.zugangscode,p.insertamum")
|
||||
->from("public.tbl_person p")
|
||||
->join("public.tbl_kontakt k", "p.person_id=k.person_id")
|
||||
->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
|
||||
->join("public.tbl_prestudent ps", "p.person_id=ps.person_id")
|
||||
->join("public.tbl_prestudentstatus pst", "pst.prestudent_id=ps.prestudent_id")
|
||||
->where("k.kontakttyp", 'email')
|
||||
->where("(kontakt='".$email."'".
|
||||
" OR alias ||'@technikum-wien.at'='".$email."'".
|
||||
" OR uid ||'@technikum-wien.at'='".$email."')")
|
||||
->where("studiensemester_kurzbz='".$studiensemester_kurzbz."'")
|
||||
->order_by("p.insertamum", "DESC")
|
||||
->limit(1)
|
||||
;
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function checkZugangscodePerson($code)
|
||||
{
|
||||
$this->db->select("p.person_id")
|
||||
->from("public.tbl_person p")
|
||||
->where("p.zugangscode", $code);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function updatePerson($person)
|
||||
{
|
||||
//TODO check berechtigung
|
||||
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
|
||||
// {
|
||||
//TODO set other columns to be updated
|
||||
$this->db->set("zugangscode", $person["zugangscode"]);
|
||||
$this->db->where("person_id", $person["person_id"]);
|
||||
if($this->db->update("public.tbl_person")){
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "Nicht berechtigt";
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user