Files
FHC-Core/application/controllers/api/v1/person/Person.php
T
paolo a3a9c42e99 - Renamed classes, methods and properties names in german
- All the controllers exends APIv1_Controller rather than REST_Controller
 - Codeceptions modified to be compliant to changes
2016-04-25 15:57:52 +02:00

158 lines
3.2 KiB
PHP

<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Person extends APIv1_Controller
{
/**
* Person API constructor.
*/
public function __construct()
{
parent::__construct();
// Load model PersonModel
$this->load->model('person/person_model', 'PersonModel');
// Load set the addonID of the model to let to check the permissions
$this->PersonModel->setAddonID($this->_getAddonID());
}
/**
* @return void
*/
public function getPerson()
{
$personID = $this->get('person_id');
$code = $this->get('code');
$email = $this->get('email');
$result = $this->PersonModel->getPerson($personID, $code, $email);
if(is_object($result) && $result->num_rows() > 0)
{
$payload = [
'success' => TRUE,
'message' => 'Person found',
'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
$payload = [
'success' => FALSE,
'message' => 'Person not found'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
/**
* @return void
*/
public function postPerson()
{
$result = $this->PersonModel->savePerson($this->post());
if($result === TRUE)
{
$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 postPrestudent()
{
$result = $this->PersonModel->savePrestudent($this->post());
if($result === TRUE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
'message' => 'Interested student saved.'
];
}
else
{
$payload = [
'success' => false,
'message' => 'Could not save interested student.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
}
/**
* @return void
*/
public function getCheckBewerbung()
{
$result = $this->PersonModel->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);
}
/**
* @return void
*/
public function getCheckZugangscodePerson()
{
$result = $this->PersonModel->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);
}
}