mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
Merge origin/ci into ci
Conflicts: application/config/rest.php application/libraries/FHC_Auth.php tests/codeception/api/LoginCept.php
This commit is contained in:
@@ -21,7 +21,7 @@ class Test extends REST_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_get()
|
||||
public function getTest()
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
@@ -38,7 +38,7 @@ class Test extends REST_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_post()
|
||||
public function postTest()
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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 Nation extends REST_Controller
|
||||
{
|
||||
/**
|
||||
* Course API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('nation_model', 'NationModel');
|
||||
// Load set the addonID of the model to let to check the permissions
|
||||
$this->NationModel->setAddonID($this->_getAddonID());
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$notLocked = $this->get('ohnesperre');
|
||||
$orderEnglish = $this->get('orderEnglish');
|
||||
|
||||
$result = $this->NationModel->getAll($notLocked, $orderEnglish);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Nation found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => FALSE,
|
||||
'message' => 'Nation not found'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
public function getFederalState()
|
||||
{
|
||||
$result = $this->NationModel->getFederalState();
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Bundesland found',
|
||||
'data' => $result->result_array()
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => FALSE,
|
||||
'message' => 'Bundesland not found'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
@@ -13,97 +12,74 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (! defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
if(!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Person extends APIv1_Controller
|
||||
class Person extends REST_Controller
|
||||
{
|
||||
/**
|
||||
* Person API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/**
|
||||
* Person API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('person/person_model');
|
||||
}
|
||||
// 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 person_get()
|
||||
{
|
||||
//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);
|
||||
|
||||
public function getPerson()
|
||||
{
|
||||
$personID = $this->get('person_id');
|
||||
$code = $this->get('code');
|
||||
$email = $this->get('email');
|
||||
$person_id = $this->get('person_id');
|
||||
|
||||
if ((!is_null($code)) && (!is_null($email)))
|
||||
$result = $this->PersonModel->getPerson($personID, $code, $email);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
{
|
||||
$result = $this->person_model->getPersonByCodeAndEmail($code, $email);
|
||||
}
|
||||
elseif (! is_null($code))
|
||||
{
|
||||
$result = $this->person_model->getPersonByCode($code);
|
||||
}
|
||||
elseif (! is_null($person_id))
|
||||
{
|
||||
$result = $this->person_model->getPerson($person_id);
|
||||
if($result->num_rows() > 1)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'People found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else if($result->num_rows() == 1)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Person found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->person_model->getPerson();
|
||||
}
|
||||
|
||||
if ($result['err'])
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => $result['msg'].': '.$result['retval']
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// return all available persons
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Persons found'
|
||||
];
|
||||
$payload['data'] = $result;
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
if (empty($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Person not found'
|
||||
'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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function person_post()
|
||||
{
|
||||
$result = $this->person_model->savePerson($this->post());
|
||||
if ($result != false)
|
||||
public function postPerson()
|
||||
{
|
||||
$result = $this->PersonModel->savePerson($this->post());
|
||||
|
||||
if($result === TRUE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
@@ -121,40 +97,14 @@ class Person extends APIv1_Controller
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function checkBewerbung_get()
|
||||
{
|
||||
$result = $this->person_model->checkBewerbung($this->get("email"), $this->get("studiensemester_kurzbz"));
|
||||
public function getCheckBewerbung()
|
||||
{
|
||||
$result = $this->PersonModel->checkBewerbung($this->get("email"), $this->get("studiensemester_kurzbz"));
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
@@ -162,16 +112,16 @@ class Person extends APIv1_Controller
|
||||
];
|
||||
$payload['data'] = $result;
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function checkZugangscodePerson_get()
|
||||
{
|
||||
$result = $this->person_model->checkZugangscodePerson($this->get("code"));
|
||||
public function getCheckZugangscodePerson()
|
||||
{
|
||||
$result = $this->PersonModel->checkZugangscodePerson($this->get("code"));
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
if (!empty($result))
|
||||
if(!empty($result))
|
||||
{
|
||||
$payload = [
|
||||
'success' => true,
|
||||
@@ -189,5 +139,32 @@ class Person extends APIv1_Controller
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function postInterestedStudent()
|
||||
{
|
||||
$result = $this->PersonModel->saveInterestedStudent($this->post());
|
||||
|
||||
if($result === TRUE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Interested student saved.'
|
||||
];
|
||||
$payload['data'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Could not save interested student.'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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 Course extends REST_Controller
|
||||
{
|
||||
/**
|
||||
* Course API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('studies/course_model', 'CourseModel');
|
||||
// Load set the addonID of the model to let to check the permissions
|
||||
$this->CourseModel->setAddonID($this->_getAddonID());
|
||||
}
|
||||
|
||||
public function getEnabledCourses()
|
||||
{
|
||||
$result = $this->CourseModel->getEnabledCourses();
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Courses found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => FALSE,
|
||||
'message' => 'Person not found'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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 Plan extends REST_Controller
|
||||
{
|
||||
/**
|
||||
* Course API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('studies/plan_model', 'PlanModel');
|
||||
// Load set the addonID of the model to let to check the permissions
|
||||
$this->PlanModel->setAddonID($this->_getAddonID());
|
||||
}
|
||||
|
||||
public function getCurricula()
|
||||
{
|
||||
$courseOfStudiesID = $this->get('studiengang_kz');
|
||||
|
||||
$result = $this->PlanModel->getCurricula($courseOfStudiesID);
|
||||
|
||||
if(!is_null($result) && $result->num_rows() > 0)
|
||||
{
|
||||
$payload = [
|
||||
'success' => TRUE,
|
||||
'message' => 'Curricula found',
|
||||
'data' => $result->result()[0]
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => FALSE,
|
||||
'message' => 'Curricula not found'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
class Kontakt extends FHC_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('kontakt/kontakt_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['person'] = $this->person_model->getPersonen();
|
||||
$data['title'] = 'Personen Archiv';
|
||||
|
||||
$this->load->view('templates/header', $data);
|
||||
$this->load->view('kontakt/index', $data);
|
||||
$this->load->view('templates/footer');
|
||||
}
|
||||
|
||||
public function view($slug = null)
|
||||
{
|
||||
$data['person_item'] = $this->person_model->getPersonen($slug);
|
||||
if (empty($data['person_item']))
|
||||
show_404();
|
||||
|
||||
$data['title'] = $data['person_item']->titelpre;
|
||||
|
||||
$this->load->view('templates/header', $data);
|
||||
$this->load->view('kontakt/view', $data);
|
||||
$this->load->view('templates/footer');
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
class Person extends FHC_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('person/person_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['person'] = $this->person_model->getPersonen();
|
||||
$data['title'] = 'Personen Archiv';
|
||||
|
||||
$this->load->view('templates/header', $data);
|
||||
$this->load->view('person/index', $data);
|
||||
$this->load->view('templates/footer');
|
||||
}
|
||||
|
||||
public function view($slug = null)
|
||||
{
|
||||
$data['person_item'] = $this->person_model->getPersonen($slug);
|
||||
if (empty($data['person_item']))
|
||||
show_404();
|
||||
|
||||
$data['title'] = $data['person_item']->titelpre;
|
||||
|
||||
$this->load->view('templates/header', $data);
|
||||
$this->load->view('person/view', $data);
|
||||
$this->load->view('templates/footer');
|
||||
}
|
||||
}
|
||||
@@ -1,93 +1,106 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class FHC_Model extends CI_Model
|
||||
class FHC_Model extends CI_Model
|
||||
{
|
||||
//protected errormsg;
|
||||
function __construct()
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct();
|
||||
$this->load->helper('language');
|
||||
$this->lang->load('fhcomplete');
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
* Success
|
||||
*
|
||||
* @param mixed $retval
|
||||
* @return array
|
||||
*/
|
||||
protected function _success($retval = '', $message = FHC_SUCCESS)
|
||||
{
|
||||
return array(
|
||||
'err' => 0,
|
||||
'code' => FHC_SUCCESS,
|
||||
'msg' => lang('fhc_' . $message),
|
||||
'retval' => $retval
|
||||
);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
* General Error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
|
||||
{
|
||||
return array(
|
||||
'err' => 1,
|
||||
'code' => FHC_ERR_GENERAL,
|
||||
'msg' => lang('fhc_'.$message),
|
||||
'retval' => $retval
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DB_Model extends FHC_Model
|
||||
{
|
||||
|
||||
protected $dbTable=null; // Name of the DB-Table for CI-Insert, -Update, ...
|
||||
|
||||
function __construct($uid=null)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
$this->load->helper('language');
|
||||
$this->lang->load('fhc_db');
|
||||
|
||||
// UID must be set in Production Mode
|
||||
if (ENVIRONMENT=='production' && is_null($uid))
|
||||
log_message('error', 'UID must be set in Production Mode.');
|
||||
elseif (is_null($uid))
|
||||
log_message('info', 'UID is not set.');
|
||||
|
||||
// Loading Tools for Access Control (Benutzerberechtigungen)
|
||||
$this->load->library('FHC_DB_ACL',array('uid' => $uid));
|
||||
}
|
||||
|
||||
public function insert($data)
|
||||
{
|
||||
if (! is_null($this->dbTable))
|
||||
{
|
||||
$this->db->insert($this->dbTable, $data);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
$this->lang->load('fhcomplete');
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
* Invalid ID
|
||||
*
|
||||
* @param integer config.php error code numbers
|
||||
* @return array
|
||||
*/
|
||||
protected function _invalid_id($error = '')
|
||||
{
|
||||
return array(
|
||||
'err' => 1,
|
||||
'code' => $error,
|
||||
'msg' => lang('fhc_'.$error)
|
||||
);
|
||||
}
|
||||
* Success
|
||||
*
|
||||
* @param mixed $retval
|
||||
* @return array
|
||||
*/
|
||||
protected function _success($retval = '', $message = FHC_SUCCESS)
|
||||
{
|
||||
return array(
|
||||
'err' => 0,
|
||||
'code' => FHC_SUCCESS,
|
||||
'msg' => lang('fhc_' . $message),
|
||||
'retval' => $retval
|
||||
);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
* General Error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
|
||||
{
|
||||
return array(
|
||||
'err' => 1,
|
||||
'code' => FHC_ERR_GENERAL,
|
||||
'msg' => lang('fhc_' . $message),
|
||||
'retval' => $retval
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DB_Model extends FHC_Model
|
||||
{
|
||||
protected $dbTable = NULL; // Name of the DB-Table for CI-Insert, -Update, ...
|
||||
// Addon ID, stored to let to check the permissions
|
||||
private $_addonID;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
$this->lang->load('fhc_db');
|
||||
}
|
||||
|
||||
public function insert($data)
|
||||
{
|
||||
if(!is_null($this->dbTable))
|
||||
{
|
||||
$this->db->insert($this->dbTable, $data);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
* Invalid ID
|
||||
*
|
||||
* @param integer config.php error code numbers
|
||||
* @return array
|
||||
*/
|
||||
protected function _invalid_id($error = '')
|
||||
{
|
||||
return array(
|
||||
'err' => 1,
|
||||
'code' => $error,
|
||||
'msg' => lang('fhc_' . $error)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
protected function _checkPermissions()
|
||||
{
|
||||
// If _addonID is NOT set (core) or if _addonID is set (API call) and has permissions
|
||||
return !isset($this->_addonID) || (isset($this->_addonID) && TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setAddonID
|
||||
*
|
||||
* @param $addonID
|
||||
* @return void
|
||||
*/
|
||||
public function setAddonID($addonID)
|
||||
{
|
||||
$this->_addonID = $addonID;
|
||||
}
|
||||
}
|
||||
@@ -428,3 +428,23 @@ function indexSort($a, $b)
|
||||
{
|
||||
return strcmp($a->index, $b->index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereitet ein Array von Elementen auf, damit es in der IN-Klausel eines
|
||||
* Select Befehls verwendet werden kann.
|
||||
*/
|
||||
function dbImplode4SQL($array)
|
||||
{
|
||||
$string = '';
|
||||
|
||||
foreach($array as $row)
|
||||
{
|
||||
if($string != '')
|
||||
{
|
||||
$string.=',';
|
||||
}
|
||||
$string.=$this->db_add_param($row);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
@@ -60,4 +60,4 @@ class FHC_Auth
|
||||
|
||||
return md5($aam->getPasswordByUsername($username));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,8 +351,13 @@ abstract class REST_Controller extends CI_Controller {
|
||||
self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR',
|
||||
self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED'
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $_addonID = NULL;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Extend this function to apply additional checking early on in the process
|
||||
*
|
||||
* @access protected
|
||||
@@ -361,7 +366,7 @@ abstract class REST_Controller extends CI_Controller {
|
||||
protected function early_checks()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the REST API
|
||||
*
|
||||
@@ -604,8 +609,10 @@ abstract class REST_Controller extends CI_Controller {
|
||||
// Remove the supported format from the function name e.g. index.json => index
|
||||
$object_called = preg_replace('/^(.*)\.(?:' . implode('|', array_keys($this->_supported_formats)) . ')$/', '$1', $object_called);
|
||||
|
||||
$controller_method = $object_called . '_' . $this->request->method;
|
||||
|
||||
//$controller_method = $object_called . '_' . $this->request->method;
|
||||
// CamelCase compliant
|
||||
$controller_method = $this->request->method.ucfirst($object_called);
|
||||
|
||||
// Do we want to log this method (if allowed by config)?
|
||||
$log_method = !(isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE);
|
||||
|
||||
@@ -1900,6 +1907,25 @@ abstract class REST_Controller extends CI_Controller {
|
||||
], self::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TO BE COMMENTED
|
||||
*/
|
||||
private function _setAddonID($username)
|
||||
{
|
||||
if(!isset($this->_addonID) && isset($username))
|
||||
{
|
||||
$this->_addonID = $username;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int ID of the authenticated addon
|
||||
*/
|
||||
protected function _getAddonID()
|
||||
{
|
||||
return $this->_addonID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares for basic authentication
|
||||
@@ -1940,6 +1966,10 @@ abstract class REST_Controller extends CI_Controller {
|
||||
{
|
||||
$this->_force_login();
|
||||
}
|
||||
else // If logged
|
||||
{
|
||||
$this->_setAddonID($username);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2155,5 +2185,4 @@ abstract class REST_Controller extends CI_Controller {
|
||||
->get($this->config->item('rest_access_table'))
|
||||
->num_rows() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
class Nation_model extends DB_Model
|
||||
{
|
||||
protected $_federalStateQuery = "SELECT * FROM bis.tbl_bundesland";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getAll($notLocked = FALSE, $orderEnglish = FALSE)
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions())
|
||||
{
|
||||
$result = $this->db->query($this->_getNationQuery($notLocked, $orderEnglish));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function _getNationQuery($notLocked = FALSE, $orderEnglish = FALSE)
|
||||
{
|
||||
$qry = "SELECT * FROM bis.tbl_nation";
|
||||
|
||||
if($notLocked)
|
||||
{
|
||||
$qry .= " WHERE sperre is null";
|
||||
}
|
||||
if(!$orderEnglish)
|
||||
{
|
||||
$qry .= " ORDER BY kurztext";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry .= " ORDER BY engltext";
|
||||
}
|
||||
|
||||
return $qry;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getFederalState()
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions())
|
||||
{
|
||||
$result = $this->db->query($this->_federalStateQuery);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -2,157 +2,285 @@
|
||||
|
||||
class Person_model extends DB_Model
|
||||
{
|
||||
public function __construct($uid = null)
|
||||
{
|
||||
parent::__construct($uid);
|
||||
$this->dbTable = 'public.tbl_person';
|
||||
}
|
||||
//
|
||||
protected $_loadQuery = "SELECT person_id,
|
||||
sprache,
|
||||
anrede,
|
||||
titelpost,
|
||||
titelpre,
|
||||
nachname,
|
||||
vorname,
|
||||
vornamen,
|
||||
gebdatum,
|
||||
gebort,
|
||||
gebzeit,
|
||||
foto,
|
||||
anmerkung,
|
||||
homepage,
|
||||
svnr,
|
||||
ersatzkennzeichen,
|
||||
familienstand,
|
||||
anzahlkinder,
|
||||
aktiv,
|
||||
insertamum,
|
||||
insertvon,
|
||||
updateamum,
|
||||
updatevon,
|
||||
ext_id,
|
||||
geschlecht,
|
||||
staatsbuergerschaft,
|
||||
geburtsnation,
|
||||
kurzbeschreibung,
|
||||
zugangscode,
|
||||
foto_sperre,
|
||||
matr_nr
|
||||
FROM public.tbl_person
|
||||
WHERE person_id = ?";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getPerson($person_id = null)
|
||||
{
|
||||
if (is_null($person_id))
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getPerson($personID = NULL, $code = NULL, $email = NULL)
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions())
|
||||
{
|
||||
$query = $this->db->get_where('public.tbl_person', array());
|
||||
return $query->result_object();
|
||||
if((!is_null($code)) && (!is_null($email)))
|
||||
{
|
||||
$result = $this->_getPersonByCodeAndEmail($code, $email);
|
||||
}
|
||||
elseif(!is_null($code))
|
||||
{
|
||||
$result = $this->_getPersonByCode($code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->_getPersonByID($personID);
|
||||
}
|
||||
}
|
||||
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
|
||||
return $query->row_object();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $personID Person ID
|
||||
* @return object
|
||||
*/
|
||||
private function _getPersonByID($personID)
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
if(!is_null($personID))
|
||||
{
|
||||
$result = $this->db->query($this->_loadQuery, array($personID));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getPersonByCodeAndEmail($code, $email)
|
||||
{
|
||||
// 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();
|
||||
// }
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getPersonByCodeAndEmail($code, $email)
|
||||
{
|
||||
$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);
|
||||
|
||||
public function getPersonByCode($code)
|
||||
{
|
||||
// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'suid'))
|
||||
// {
|
||||
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
|
||||
return $query->result_object();
|
||||
// }
|
||||
}
|
||||
return $this->db->get()->result_object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt Personendaten eine BenutzerUID
|
||||
* @param string $uid DB-Attr: tbl_benutzer.uid .
|
||||
* @return bool
|
||||
*/
|
||||
public function getPersonFromBenutzerUID($uid)
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getPersonByCode($code)
|
||||
{
|
||||
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
|
||||
return $query->result_object();
|
||||
}
|
||||
|
||||
if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function savePerson($person = NULL)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions() && isset($person))
|
||||
{
|
||||
if(isset($person['person_id']))
|
||||
{
|
||||
return $this->_updatePerson($person);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_insertPerson($person);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _insertPerson($person)
|
||||
{
|
||||
$data = array(
|
||||
"vorname" => $person["vorname"],
|
||||
"nachname" => $person["nachname"],
|
||||
"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"],
|
||||
);
|
||||
|
||||
if($this->db->insert("public.tbl_person", $data))
|
||||
{
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _updatePerson($person)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'))
|
||||
{
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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"],
|
||||
"zugangscode_timestamp"=>date('Y-m-d H:i:s'),
|
||||
"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)
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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)
|
||||
->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)
|
||||
->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)
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function checkZugangscodePerson($code)
|
||||
{
|
||||
$this->db->select("p.person_id")
|
||||
->from("public.tbl_person p")
|
||||
->where("p.zugangscode", $code);
|
||||
->from("public.tbl_person p")
|
||||
->where("p.zugangscode", $code);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function saveInterestedStudent($interestedStudent = NULL)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions() && isset($interestedStudent))
|
||||
{
|
||||
/*
|
||||
$data = array(
|
||||
"vorname" => $person["vorname"],
|
||||
"nachname" => $person["nachname"],
|
||||
"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"],
|
||||
);
|
||||
|
||||
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";
|
||||
// }
|
||||
}
|
||||
}
|
||||
if($this->db->insert("public.tbl_person", $data))
|
||||
{
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}*/
|
||||
|
||||
//$prestudent = new prestudent();
|
||||
|
||||
error_log($interestedStudent['zgv_code']);
|
||||
|
||||
/*$prestudent->zgv_code = $interestedStudent['zgv_code'];
|
||||
|
||||
$prestudent->save();*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class Course_model extends DB_Model
|
||||
{
|
||||
//
|
||||
protected $_enabledCoursesQuery = "SELECT DISTINCT studiengang_kz,
|
||||
typ,
|
||||
organisationseinheittyp_kurzbz,
|
||||
studiengangbezeichnung,
|
||||
standort,
|
||||
studiengangbezeichnung_englisch,
|
||||
lgartcode,
|
||||
tbl_lgartcode.bezeichnung
|
||||
FROM lehre.vw_studienplan LEFT JOIN bis.tbl_lgartcode USING (lgartcode)
|
||||
WHERE onlinebewerbung IS TRUE
|
||||
AND aktiv IS TRUE
|
||||
ORDER BY typ, studiengangbezeichnung, tbl_lgartcode.bezeichnung ASC";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getEnabledCourses()
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions())
|
||||
{
|
||||
$result = $this->db->query($this->_enabledCoursesQuery);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class Plan_model extends DB_Model
|
||||
{
|
||||
//
|
||||
protected $_curriculaQuery = "SELECT DISTINCT tbl_studienplan.*
|
||||
FROM lehre.tbl_studienplan JOIN lehre.tbl_studienordnung USING(studienordnung_id)
|
||||
WHERE tbl_studienordnung.studiengang_kz = ?";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getCurricula($courseOfStudiesID)
|
||||
{
|
||||
$result = NULL;
|
||||
|
||||
// Checks if the operation is permitted by the API caller
|
||||
// All the code should be put inside this if statement
|
||||
if($this->_checkPermissions())
|
||||
{
|
||||
$result = $this->db->query($this->_curriculaQuery, array($courseOfStudiesID));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user