changed method to post

This commit is contained in:
Stefan Puraner
2016-04-11 08:43:29 +02:00
parent 97ddc838a8
commit d4a33fc1f9
2 changed files with 61 additions and 10 deletions
+47 -4
View File
@@ -33,13 +33,56 @@ class Person extends REST_Controller
{
//if (!$this->session_model->validate($this->get('session_id'), $this->get('device_id')))
// $this->response(array(['success' => false, 'message' => 'access denied']), REST_Controller::HTTP_UNAUTHORIZED);
$code = $this->get('code');
$email = $this->get('email');
$person_id = $this->get('person_id');
if (!is_null($code))
if ((!is_null($code)) && (!is_null($email)))
{
$result = $this->person_model->getPersonByCode($code);
$result = $this->person_model->getPersonByCodeAndEmail($code, $email);
}
elseif (!is_null($person_id))
{
$result = $this->person_model->getPerson($person_id);
}
else
{
$result = $this->person_model->getPerson();
}
if (empty($result))
{
$payload = [
'success' => false,
'message' => 'Person not found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
// return all available persons
$payload = [
'success' => true,
'message' => 'Persons found'
];
$payload['data'] = $result;
$httpstatus = REST_Controller::HTTP_OK;
}
// Set the response and exit
$this->response($payload, $httpstatus);
}
public function personFromCode_post()
{
$code = $this->post('code');
$email = $this->post('email');
$person_id = $this->post('person_id');
if ((!is_null($code)) && (!is_null($email)))
{
$result = $this->person_model->getPersonByCodeAndEmail($code, $email);
}
elseif (!is_null($person_id))
{
@@ -134,7 +177,7 @@ class Person extends REST_Controller
$this->response($payload, $httpstatus);
}
public function checkZugangscodePerson_get()
public function checkZugangscodePerson_get()
{
$result = $this->person_model->checkZugangscodePerson($this->get("code"));
$httpstatus = REST_Controller::HTTP_OK;
+14 -6
View File
@@ -21,13 +21,20 @@ class Person_model extends DB_Model
return $query->row_object();
}
public function getPersonByCode($code)
public function getPersonByCodeAndEmail($code, $email)
{
if ($this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
return $query->result_object();
}
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'suid'))
// {
$this->db->select("*")
->from('public.tbl_person p')
->join("public.tbl_kontakt k", "k.person_id=p.person_id")
->where("p.zugangscode", $code)
->where("k.kontakt", $email);
return $this->db->get()->result_object();
// $query = $this->db->get_where('public.tbl_person p ', array('zugangscode' => $code));
// return $query->result_object();
// }
}
/**
@@ -57,6 +64,7 @@ class Person_model extends DB_Model
"gebdatum"=>$person["gebdatum"],
"aktiv" => true,
"zugangscode"=>$person["zugangscode"],
"zugangscode_timestamp"=>date('Y-m-d H:i:s'),
"insertamum"=>date('Y-m-d H:i:s'),
"insertvon"=>$person["insertvon"],
);