mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
- 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:
@@ -518,4 +518,4 @@ function __autoload($class)
|
||||
require_once $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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -90,17 +90,19 @@ class person extends Person_model
|
||||
public function load($personId)
|
||||
{
|
||||
//person_id auf gueltigkeit pruefen
|
||||
if (is_numeric($personId) && $personId != '')
|
||||
if(is_numeric($personId) && $personId != '')
|
||||
{
|
||||
$qry = str_replace('?', $this->db_add_param($personId, FHC_INTEGER), $this->_loadQuery);
|
||||
|
||||
if (!$this->db_query($qry))
|
||||
$result = $this->getPerson($personId);
|
||||
|
||||
if(!is_object($result))
|
||||
{
|
||||
$this->errormsg = "Fehler beim Lesen der Personendaten\n";
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($row = $this->db_fetch_object())
|
||||
$row = $result->row();
|
||||
|
||||
if(isset($row))
|
||||
{
|
||||
$this->person_id = $row->person_id;
|
||||
$this->sprache = $row->sprache;
|
||||
|
||||
@@ -26,9 +26,9 @@ require_once(dirname(__FILE__).'/datum.class.php');
|
||||
|
||||
// CI
|
||||
require_once(dirname(__FILE__).'/../ci_hack.php');
|
||||
require_once(dirname(__FILE__).'/../application/models/studies/Course_model.php');
|
||||
require_once(dirname(__FILE__).'/../application/models/lehre/Studiengang_model.php');
|
||||
|
||||
class studiengang extends Course_model
|
||||
class studiengang extends Studiengang_model
|
||||
{
|
||||
use db_extra; //CI Hack
|
||||
|
||||
@@ -247,18 +247,19 @@ class studiengang extends Course_model
|
||||
*/
|
||||
public function getAllForBewerbung()
|
||||
{
|
||||
if(!$result = $this->db_query($this->_allForBewerbungQuery))
|
||||
error_log("getAllForBewerbung called!!!");
|
||||
|
||||
$result = parent::getAllForBewerbung();
|
||||
|
||||
if(!is_object($result))
|
||||
{
|
||||
$this->errormsg = 'Datensatz konnte nicht geladen werden';
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$this->result[] = $row;
|
||||
}
|
||||
$this->result = $result->result();
|
||||
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,9 +28,9 @@ require_once(dirname(__FILE__).'/datum.class.php');
|
||||
|
||||
// CI
|
||||
require_once(dirname(__FILE__).'/../ci_hack.php');
|
||||
require_once(dirname(__FILE__).'/../application/models/studies/Plan_model.php');
|
||||
require_once(dirname(__FILE__).'/../application/models/lehre/Studienplan_model.php');
|
||||
|
||||
class studienplan extends Plan_model
|
||||
class studienplan extends Studienplan_model
|
||||
{
|
||||
use db_extra; //CI Hack
|
||||
|
||||
@@ -729,33 +729,36 @@ class studienplan extends Plan_model
|
||||
*/
|
||||
function getStudienplaene($studiengang_kz)
|
||||
{
|
||||
$qry = str_replace('?', $this->db_add_param($studiengang_kz, FHC_INTEGER), $this->_studienplaeneQuery);
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
error_log("getStudienplaene called!!!");
|
||||
|
||||
$result = parent::getStudienplaene($studiengang_kz);
|
||||
|
||||
if(is_object($result))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
foreach($result->result() as $row)
|
||||
{
|
||||
$obj = new studienplan();
|
||||
$obj = new studienplan();
|
||||
|
||||
$obj->studienplan_id = $row->studienplan_id;
|
||||
$obj->studienordnung_id = $row->studienordnung_id;
|
||||
$obj->orgform_kurzbz = $row->orgform_kurzbz;
|
||||
$obj->version = $row->version;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->regelstudiendauer = $row->regelstudiendauer;
|
||||
$obj->sprache = $row->sprache;
|
||||
$obj->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$obj->semesterwochen = $row->semesterwochen;
|
||||
$obj->testtool_sprachwahl = $this->db_parse_bool($row->testtool_sprachwahl);
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->new=false;
|
||||
$obj->studienplan_id = $row->studienplan_id;
|
||||
$obj->studienordnung_id = $row->studienordnung_id;
|
||||
$obj->orgform_kurzbz = $row->orgform_kurzbz;
|
||||
$obj->version = $row->version;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->regelstudiendauer = $row->regelstudiendauer;
|
||||
$obj->sprache = $row->sprache;
|
||||
$obj->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$obj->semesterwochen = $row->semesterwochen;
|
||||
$obj->testtool_sprachwahl = $this->db_parse_bool($row->testtool_sprachwahl);
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->new = FALSE;
|
||||
|
||||
$this->result[] = $obj;
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user