diff --git a/application/config/config.php b/application/config/config.php index e07aeebbb..809e0a08e 100755 --- a/application/config/config.php +++ b/application/config/config.php @@ -518,4 +518,4 @@ function __autoload($class) require_once $file; } } -} +} \ No newline at end of file diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php new file mode 100644 index 000000000..b33c5a530 --- /dev/null +++ b/application/core/APIv1_Controller.php @@ -0,0 +1,13 @@ +load->library('session'); // -> autoload + //$this->load->library('database'); -> autoload + } +} \ No newline at end of file diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php new file mode 100644 index 000000000..1e590b3e3 --- /dev/null +++ b/application/core/DB_Model.php @@ -0,0 +1,64 @@ +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; + } +} \ No newline at end of file diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 0e6847cca..b08696193 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -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 - } - -} +} \ No newline at end of file diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php index 18bf28787..67cda7d15 100644 --- a/application/core/FHC_Model.php +++ b/application/core/FHC_Model.php @@ -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; - } -} +} \ No newline at end of file diff --git a/application/models/lehre/Studiengang_model.php b/application/models/lehre/Studiengang_model.php index 88a6d20b5..3fcb6aa35 100644 --- a/application/models/lehre/Studiengang_model.php +++ b/application/models/lehre/Studiengang_model.php @@ -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; diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index d2910523f..73dab4b34 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -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; diff --git a/include/person.class.php b/include/person.class.php index 835660878..58b718de0 100644 --- a/include/person.class.php +++ b/include/person.class.php @@ -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; diff --git a/include/studiengang.class.php b/include/studiengang.class.php index f49963f44..e0dd2db97 100644 --- a/include/studiengang.class.php +++ b/include/studiengang.class.php @@ -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; } /** diff --git a/include/studienplan.class.php b/include/studienplan.class.php index 53b5fcfef..0af89ff0c 100644 --- a/include/studienplan.class.php +++ b/include/studienplan.class.php @@ -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; } }