Conflicts:
	application/models/person/Person_model.php
	ci_hack.php
This commit is contained in:
Paminger
2016-04-10 18:20:43 +02:00
5 changed files with 195 additions and 206 deletions
+5 -5
View File
@@ -8,8 +8,8 @@ documents/
.settings
.project
.buildpath
!tests/codeception.yml
!tests/codeception/api.suite.yml
!tests/codeception/functional.suite.yml
!tests/codeception/acceptance.suite.yml
!/submodules/d3
tests/codeception.yml
tests/codeception/api.suite.yml
tests/codeception/functional.suite.yml
tests/codeception/acceptance.suite.yml
/submodules/d3
+121 -131
View File
@@ -17,47 +17,43 @@ defined('BASEPATH') || exit('No direct script access allowed');
class Person extends APIv1_Controller
{
//public $session;
/**
* Person API constructor.
*/
public function __construct()
{
parent::__construct();
$this->load->model('person/person_model');
parent::__construct();
$this->load->model('person/person_model');
}
public function person_get()
{
//if (!$this->session_model->validate($this->get('session_id'), $this->get('device_id')))
//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');
$person_id = $this->get('person_id');
$code = $this->get('code');
$person_id = $this->get('person_id');
if (!is_null($code))
{
$result = $this->person_model->getPersonByCode($code);
}
elseif (!is_null($person_id))
{
$result = $this->person_model->getPerson($person_id);
}
else
{
$result = $this->person_model->getPerson();
}
if(!is_null($code))
{
$result = $this->person_model->getPersonByCode($code);
}
elseif(!is_null($person_id))
{
$result = $this->person_model->getPerson($person_id);
}
else
{
$result = $this->person_model->getPerson();
}
<<<<<<< HEAD
if ($result['err'])
if($result['err'])
{
$payload = [
'success' => false,
'message' => $result['msg'].': '.$result['retval']
];
$httpstatus = REST_Controller::HTTP_OK;
'success' => false,
'message' => $result['msg'].': '.$result['retval']
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
@@ -69,114 +65,108 @@ class Person extends APIv1_Controller
$payload['data'] = $result;
$httpstatus = REST_Controller::HTTP_OK;
}
=======
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;
}
>>>>>>> 97ddc838a8c9e707d3bf5a6a700301252d2f5ed8
// Set the response and exit
$this->response($payload, $httpstatus);
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 person_post()
{
$result = $this->person_model->savePerson($this->post());
if($result != FALSE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Person saved.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save person.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
public function personUpdate_post()
{
$result = $this->person_model->updatePerson($this->post());
if($result != FALSE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Person updated.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Could not update person.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
//
$this->response($payload, $httpstatus);
}
public function checkBewerbung_get()
{
$result = $this->person_model->checkBewerbung($this->get("email"),$this->get("studiensemester_kurzbz"));
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Bewerbung exists.'
];
$payload['data'] = $result;
$this->response($payload, $httpstatus);
}
public function checkZugangscodePerson_get()
{
$result = $this->person_model->checkZugangscodePerson($this->get("code"));
$httpstatus = REST_Controller::HTTP_OK;
if(!empty($result))
{
$payload = [
'success' => true,
'message' => 'Zugangscode exists.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Zugangscode does not exist.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
$result = $this->person_model->savePerson($this->post());
if($result != FALSE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Person saved.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save person.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
public function personUpdate_post()
{
$result = $this->person_model->updatePerson($this->post());
if($result != FALSE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Person updated.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Could not update person.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
public function checkBewerbung_get()
{
$result = $this->person_model->checkBewerbung($this->get("email"),$this->get("studiensemester_kurzbz"));
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Bewerbung exists.'
];
$payload['data'] = $result;
$this->response($payload, $httpstatus);
}
public function checkZugangscodePerson_get()
{
$result = $this->person_model->checkZugangscodePerson($this->get("code"));
$httpstatus = REST_Controller::HTTP_OK;
if(!empty($result))
{
$payload = [
'success' => true,
'message' => 'Zugangscode exists.'
];
$payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
'message' => 'Zugangscode does not exist.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
}
+57 -58
View File
@@ -2,7 +2,6 @@
class Person_model extends DB_Model
{
public function __construct($uid = null)
{
parent::__construct($uid);
@@ -16,10 +15,9 @@ class Person_model extends DB_Model
$query = $this->db->get_where('public.tbl_person', array());
return $query->result_object();
}
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
return $query->row_object();
}
}
/**
* Laedt Personendaten einer Person mittels Code
@@ -28,7 +26,7 @@ class Person_model extends DB_Model
*/
public function getPersonByCode($code)
{
if ($this->fhc_db_acl->bb->isBerechtigt('person','s'))
if($this->fhc_db_acl->bb->isBerechtigt('person','s'))
{
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
return $query->result_object();
@@ -47,6 +45,7 @@ class Person_model extends DB_Model
*/
public function getPersonFromBenutzerUID($uid)
{
if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$this->db->select('tbl_person.*');
@@ -55,27 +54,27 @@ class Person_model extends DB_Model
return $query->result_object();
}
}
public function savePerson($person)
{
//TODO check berechtigung
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
// 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"],
"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();
return $this->db->insert_id();
}
else
{
return false;
return false;
}
// }
// else
@@ -86,64 +85,64 @@ class Person_model extends DB_Model
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();
$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();
$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'))
// 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;
return true;
}
else
{
return false;
return false;
}
// }
// else
+8 -9
View File
@@ -329,23 +329,23 @@ require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Contro
* depending on another class that uses it.
*
*/
$CFG =& load_class('Config', 'core');
$CFG =& load_class('Config', 'core');
// Do we have any manually set config items in the index.php file?
if (isset($assign_to_config) && is_array($assign_to_config))
// Do we have any manually set config items in the index.php file?
if (isset($assign_to_config) && is_array($assign_to_config))
{
foreach ($assign_to_config as $key => $value)
{
foreach ($assign_to_config as $key => $value)
{
$CFG->set_item($key, $value);
}
$CFG->set_item($key, $value);
}
}
/*
* ------------------------------------------------------
* Load the Language class
* ------------------------------------------------------
*/
$LANG =& load_class('Lang', 'core');
$LANG =& load_class('Lang', 'core');
function &get_instance()
{
@@ -466,4 +466,3 @@ trait db_extra
die('Invalid DB Boolean. Wrong DB-Engine?');
}
}
+4 -3
View File
@@ -22,14 +22,15 @@
</properties>
</rule>
<rule ref="FHComplete.Commenting.FunctionComment.ParamCommentFullStop">
<severity>0</severity>
</rule>
<!--
Temporarily ignore until API docblock formatting and line length issues in core code are fixed.
<rule ref="FHComplete.Commenting.FunctionComment.ParamCommentNotCapital">
<severity>0</severity>
</rule>
<rule ref="FHComplete.Commenting.FunctionComment.ParamCommentFullStop">
<severity>0</severity>
</rule>
<rule ref="FHComplete.Commenting.FunctionComment.ThrowsNotCapital">
<severity>0</severity>
</rule>