mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
- Moved class Studiengang to Studiengang2 to prevent class name conflicts
- Added a route rule to let to call Studiengang2 controller with the urn /api/v1/organisation/studiengang/ - Moved Kontank controller to /api/v1/person - Kontakt controller has two method getKontakt and postKontakt
This commit is contained in:
@@ -49,8 +49,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
| Examples: my-controller/index -> my_controller/index
|
||||
| my-controller/my-method -> my_controller/my_method
|
||||
*/
|
||||
$route['person/(:any)'] = 'person/view/$1';
|
||||
$route['person'] = 'person';
|
||||
$route['default_controller'] = 'Vilesci';
|
||||
$route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
|
||||
// Class name conflicts
|
||||
$route['api/v1/organisation/studiengang/(:any)'] = 'api/v1/organisation/studiengang2/$1';
|
||||
@@ -1,80 +0,0 @@
|
||||
<?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
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
class Kontakt extends APIv1_Controller
|
||||
{
|
||||
|
||||
//public $session;
|
||||
/**
|
||||
* Person API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('kontakt/Kontakt_model');
|
||||
}
|
||||
|
||||
public function kontaktPerson_get()
|
||||
{
|
||||
$result = $this->Kontakt_model->getKontaktPerson($this->get("person_id"));
|
||||
if($result != FALSE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Kontakt found.'
|
||||
];
|
||||
$payload['data'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Could not find Kontakt.'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
public function kontakt_post()
|
||||
{
|
||||
$result = $this->Kontakt_model->saveKontakt($this->post());
|
||||
if($result != FALSE)
|
||||
{
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
$payload = [
|
||||
'success' => true,
|
||||
'message' => 'Kontakt saved.'
|
||||
];
|
||||
$payload['data'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Could not save Kontakt.'
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($payload, $httpstatus);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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 Studiengang2 extends APIv1_Controller
|
||||
{
|
||||
/**
|
||||
* Course API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('organisation/studiengang_model', 'StudiengangModel');
|
||||
// Load set the uid of the model to let to check the permissions
|
||||
$this->StudiengangModel->setUID($this->_getUID());
|
||||
}
|
||||
|
||||
public function getAllForBewerbung()
|
||||
{
|
||||
$this->response($this->StudiengangModel->getAllForBewerbung(), REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
class Kontakt extends APIv1_Controller
|
||||
{
|
||||
/**
|
||||
* Person API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('person/kontakt_model', 'KontaktModel');
|
||||
// Load set the uid of the model to let to check the permissions
|
||||
$this->KontaktModel->setUID($this->_getUID());
|
||||
}
|
||||
|
||||
public function getKontakt()
|
||||
{
|
||||
$personID = $this->get("person_id");
|
||||
|
||||
if(isset($personID))
|
||||
{
|
||||
$result = $this->KontaktModel->loadWhere(array('person_id' => $personID));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
public function postKontakt()
|
||||
{
|
||||
$post = $this->post();
|
||||
|
||||
if(is_array($post))
|
||||
{
|
||||
if(isset($post['kontakt_id']))
|
||||
{
|
||||
$result = $this->KontaktModel->update($post['kontakt_id'], $post);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->KontaktModel->insert($post);
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,13 @@ class FHC_Model extends CI_Model
|
||||
$this->load->helper('language');
|
||||
$this->lang->load('fhc_model');
|
||||
$this->lang->load('fhcomplete');
|
||||
if (is_null($uid) && isset($this->session->uid))
|
||||
|
||||
$uid = NULL;
|
||||
if(is_null($uid) && isset($this->session->uid))
|
||||
{
|
||||
$uid = $this->session->uid;
|
||||
else
|
||||
$uid = null;
|
||||
}
|
||||
$this->load->library('FHC_DB_ACL', array('uid' => $uid));
|
||||
//$this->load->library('FHC_DB_ACL');
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
class Kontakt_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -11,39 +10,4 @@ class Kontakt_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_kontakt';
|
||||
$this->pk = 'kontakt_id';
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user