- Moved class APIv1_Controller from FHC_Controller.php to APIv1_Controller.php

- Moved class DB_Model from FHC_Model.php to DB_Model.php
- load method of class person (person.class.php) now is calling getPerson
  method of the class Person_model
- getAllForBewerbung method of class studiengang (studiengang.class.php) now is calling getAllForBewerbung
  method of the class Studiengang_model
- getStudienplaene method of class studienplan (studienplan.class.php) now is calling getStudienplaene
  method of the class Studienplan_model
This commit is contained in:
paolo
2016-04-25 18:25:03 +02:00
parent a3a9c42e99
commit 4cc83999ed
10 changed files with 177 additions and 174 deletions
+1 -1
View File
@@ -518,4 +518,4 @@ function __autoload($class)
require_once $file;
}
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
require_once APPPATH . '/libraries/REST_Controller.php';
class APIv1_Controller extends REST_Controller
{
function __construct()
{
parent::__construct();
//$this->load->library('session'); // -> autoload
//$this->load->library('database'); -> autoload
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
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)
);
}
/**
* Method setAddonID
*
* @param $addonID
* @return void
*/
public function setAddonID($addonID)
{
$this->_addonID = $addonID;
}
/**
* Method getAddonID
*
* @return string _addonID
*/
public function getAddonID()
{
return $this->_addonID;
}
}
+1 -14
View File
@@ -8,17 +8,4 @@ class FHC_Controller extends CI_Controller
parent::__construct();
//$this->load->helper('language');
}
}
require_once APPPATH . '/libraries/REST_Controller.php';
class APIv1_Controller extends REST_Controller
{
function __construct()
{
parent::__construct();
//$this->load->library('session'); // -> autoload
//$this->load->library('database'); -> autoload
}
}
}
+1 -64
View File
@@ -43,67 +43,4 @@ class FHC_Model extends CI_Model
'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)
);
}
/**
* Method setAddonID
*
* @param $addonID
* @return void
*/
public function setAddonID($addonID)
{
$this->_addonID = $addonID;
}
/**
* Method getAddonID
*
* @return string _addonID
*/
public function getAddonID()
{
return $this->_addonID;
}
}
}
+13 -15
View File
@@ -2,20 +2,6 @@
class Studiengang_model extends DB_Model
{
//
protected $_allForBewerbungQuery = "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";
/**
*
*/
@@ -30,12 +16,24 @@ class Studiengang_model extends DB_Model
public function getAllForBewerbung()
{
$result = NULL;
$allForBewerbungQuery = "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";
// Checks if the operation is permitted by the API caller
// All the code should be put inside this if statement
if(isAllowed($this->getAddonID(), 'course'))
{
$result = $this->db->query($this->_allForBewerbungQuery);
$result = $this->db->query($allForBewerbungQuery);
}
return $result;
+39 -41
View File
@@ -2,41 +2,6 @@
class Person_model extends DB_Model
{
//
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 = ?";
/**
*
*/
@@ -48,7 +13,7 @@ class Person_model extends DB_Model
/**
*
*/
public function getPerson($personID = NULL, $code = NULL, $email = NULL)
public function getPerson($personId = NULL, $code = NULL, $email = NULL)
{
$result = NULL;
@@ -66,7 +31,7 @@ class Person_model extends DB_Model
}
else
{
$result = $this->_getPersonByID($personID);
$result = $this->_getPersonByID($personId);
}
}
@@ -74,16 +39,49 @@ class Person_model extends DB_Model
}
/**
* @param int $personID Person ID
* @param int $personId Person ID
* @return object
*/
private function _getPersonByID($personID = NULL)
private function _getPersonByID($personId = NULL)
{
$result = NULL;
$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 = ?";
if(isset($personID))
if(isset($personId))
{
$result = $this->db->query($this->_loadQuery, array($personID));
$result = $this->db->query($loadQuery, array($personId));
}
return $result;