mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
- Added new library ReihungstestLib
- Added method isEntitled to FCH_Model - Cleaned the controllers by moving the database related code in the models or libraries
This commit is contained in:
@@ -55,10 +55,7 @@ class Gemeinde extends APIv1_Controller
|
||||
|
||||
if (is_numeric($plz))
|
||||
{
|
||||
$this->GemeindeModel->addSelect("DISTINCT ON (ortschaftsname) ortschaftsname, gemeinde_id, plz, name, ortschaftskennziffer, bulacode, bulabez, kennziffer");
|
||||
$this->GemeindeModel->addOrder("ortschaftsname");
|
||||
|
||||
$result = $this->GemeindeModel->loadWhere(array("plz" => $plz));
|
||||
$result = $this->GemeindeModel->getGemeindeByPlz($plz);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class Dokumentstudiengang extends APIv1_Controller
|
||||
{
|
||||
@@ -23,9 +23,7 @@ class Dokumentstudiengang extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model DokumentstudiengangModel
|
||||
$this->load->model('crm/dokumentstudiengang_model', 'DokumentstudiengangModel');
|
||||
|
||||
|
||||
$this->load->model("crm/Dokumentstudiengang_model", "DokumentstudiengangModel");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,8 +31,8 @@ class Dokumentstudiengang extends APIv1_Controller
|
||||
*/
|
||||
public function getDokumentstudiengang()
|
||||
{
|
||||
$studiengang_kz = $this->get('studiengang_kz');
|
||||
$dokument_kurzbz = $this->get('dokument_kurzbz');
|
||||
$studiengang_kz = $this->get("studiengang_kz");
|
||||
$dokument_kurzbz = $this->get("dokument_kurzbz");
|
||||
|
||||
if (isset($studiengang_kz) && isset($dokument_kurzbz))
|
||||
{
|
||||
@@ -53,29 +51,13 @@ class Dokumentstudiengang extends APIv1_Controller
|
||||
*/
|
||||
public function getDokumentstudiengangByStudiengang_kz()
|
||||
{
|
||||
$studiengang_kz = $this->get('studiengang_kz');
|
||||
$onlinebewerbung = $this->get('onlinebewerbung');
|
||||
$pflicht = $this->get('pflicht');
|
||||
$studiengang_kz = $this->get("studiengang_kz");
|
||||
$onlinebewerbung = $this->get("onlinebewerbung");
|
||||
$pflicht = $this->get("pflicht");
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$result = $this->DokumentstudiengangModel->addJoin("public.tbl_dokument", "dokument_kurzbz");
|
||||
if(is_object($result) && $result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$parameterArray = array("studiengang_kz" => $studiengang_kz);
|
||||
|
||||
if( isset($onlinebewerbung))
|
||||
{
|
||||
$parameterArray["onlinebewerbung"] = $onlinebewerbung;
|
||||
}
|
||||
|
||||
if( isset($pflicht))
|
||||
{
|
||||
$parameterArray["pflicht"] = $pflicht;
|
||||
}
|
||||
|
||||
$result = $this->DokumentstudiengangModel->loadWhere($parameterArray);
|
||||
}
|
||||
$result = $this->DokumentstudiengangModel->getDokumentstudiengangByStudiengang_kz($studiengang_kz, $onlinebewerbung, $pflicht);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -92,9 +74,9 @@ class Dokumentstudiengang extends APIv1_Controller
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
{
|
||||
if (isset($this->post()['studiengang_kz']) && isset($this->post()['dokument_kurzbz']))
|
||||
if (isset($this->post()["studiengang_kz"]) && isset($this->post()["dokument_kurzbz"]))
|
||||
{
|
||||
$result = $this->DokumentstudiengangModel->update(array($this->post()['studiengang_kz'], $this->post()['dokument_kurzbz']), $this->post());
|
||||
$result = $this->DokumentstudiengangModel->update(array($this->post()["studiengang_kz"], $this->post()["dokument_kurzbz"]), $this->post());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class Prestudent extends APIv1_Controller
|
||||
{
|
||||
@@ -23,7 +23,9 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PrestudentModel
|
||||
$this->load->model('crm/prestudent_model', 'PrestudentModel');
|
||||
$this->load->model("crm/prestudent_model", "PrestudentModel");
|
||||
// Load library ReihungstestLib
|
||||
$this->load->library("ReihungstestLib");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ class Prestudent extends APIv1_Controller
|
||||
*/
|
||||
public function getPrestudent()
|
||||
{
|
||||
$prestudentID = $this->get('prestudent_id');
|
||||
$prestudentID = $this->get("prestudent_id");
|
||||
|
||||
if (isset($prestudentID))
|
||||
{
|
||||
@@ -50,11 +52,11 @@ class Prestudent extends APIv1_Controller
|
||||
*/
|
||||
public function getPrestudentByPersonID()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
$person_id = $this->get("person_id");
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->PrestudentModel->load(array('person_id' => $person_id));
|
||||
$result = $this->PrestudentModel->load(array("person_id" => $person_id));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -71,9 +73,9 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
{
|
||||
if (isset($this->post()['prestudent_id']))
|
||||
if (isset($this->post()["prestudent_id"]))
|
||||
{
|
||||
$result = $this->PrestudentModel->update($this->post()['prestudent_id'], $this->post());
|
||||
$result = $this->PrestudentModel->update($this->post()["prestudent_id"], $this->post());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,22 +97,18 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
$ddReihungstest = $this->_parseData($this->post());
|
||||
|
||||
if ($this->_validateAddReihungstest($ddReihungstest))
|
||||
if ($this->_validateReihungstest($ddReihungstest))
|
||||
{
|
||||
$this->load->model('crm/RtPerson_model', 'RtPersonModel');
|
||||
|
||||
if(isset($ddReihungstest['new']) && $ddReihungstest['new'] == true)
|
||||
if(isset($ddReihungstest["new"]) && $ddReihungstest["new"] == true)
|
||||
{
|
||||
// Remove new parameter to avoid DB insert errors
|
||||
unset($ddReihungstest['new']);
|
||||
unset($ddReihungstest["new"]);
|
||||
|
||||
$result = $this->RtPersonModel->insert($ddReihungstest);
|
||||
$result = $this->reihungstestlib->insertPersonReihungstest($ddReihungstest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pksArray = array($ddReihungstest['person_id'], $ddReihungstest['rt_id']);
|
||||
|
||||
$result = $this->RtPersonModel->update($pksArray, $ddReihungstest);
|
||||
$result = $this->reihungstestlib->updatePersonReihungstest($ddReihungstest);
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
@@ -128,11 +126,9 @@ class Prestudent extends APIv1_Controller
|
||||
{
|
||||
$ddReihungstest = $this->_parseData($this->post());
|
||||
|
||||
if ($this->_validateAddReihungstest($ddReihungstest))
|
||||
if (isset($ddReihungstest["rt_person_id"]))
|
||||
{
|
||||
$this->load->model('crm/RtPerson_model', 'RtPersonModel');
|
||||
|
||||
$result = $this->RtPersonModel->delete($ddReihungstest['rt_person_id'], $ddReihungstest);
|
||||
$result = $this->reihungstestlib->deletePersonReihungstest($ddReihungstest);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -147,9 +143,9 @@ class Prestudent extends APIv1_Controller
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _validateAddReihungstest($ddReihungstest = NULL)
|
||||
private function _validateReihungstest($ddReihungstest = NULL)
|
||||
{
|
||||
if (!isset($ddReihungstest['person_id']) || !isset($ddReihungstest['rt_id']))
|
||||
if (!isset($ddReihungstest["person_id"]) || !isset($ddReihungstest["rt_id"]) || !isset($ddReihungstest["studienplan_id"]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class Reihungstest extends APIv1_Controller
|
||||
{
|
||||
@@ -23,7 +23,9 @@ class Reihungstest extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model ReihungstestModel
|
||||
$this->load->model('crm/reihungstest_model', 'ReihungstestModel');
|
||||
$this->load->model("crm/reihungstest_model", "ReihungstestModel");
|
||||
// Load library ReihungstestLib
|
||||
$this->load->library("ReihungstestLib");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ class Reihungstest extends APIv1_Controller
|
||||
*/
|
||||
public function getReihungstest()
|
||||
{
|
||||
$reihungstestID = $this->get('reihungstest_id');
|
||||
$reihungstestID = $this->get("reihungstest_id");
|
||||
|
||||
if (isset($reihungstestID))
|
||||
{
|
||||
@@ -50,15 +52,15 @@ class Reihungstest extends APIv1_Controller
|
||||
*/
|
||||
public function getByStudiengangStudiensemester()
|
||||
{
|
||||
$studiengang_kz = $this->get('studiengang_kz');
|
||||
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
|
||||
$studiengang_kz = $this->get("studiengang_kz");
|
||||
$studiensemester_kurzbz = $this->get("studiensemester_kurzbz");
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
$parameters = array('studiengang_kz' => $studiengang_kz);
|
||||
$parameters = array("studiengang_kz" => $studiengang_kz);
|
||||
if (isset($studiensemester_kurzbz))
|
||||
{
|
||||
$parameters['studiensemester_kurzbz'] = $studiensemester_kurzbz;
|
||||
$parameters["studiensemester_kurzbz"] = $studiensemester_kurzbz;
|
||||
}
|
||||
$result = $this->ReihungstestModel->loadWhere($parameters);
|
||||
|
||||
@@ -75,23 +77,11 @@ class Reihungstest extends APIv1_Controller
|
||||
*/
|
||||
public function getReihungstestByPersonID()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
$person_id = $this->get("person_id");
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->ReihungstestModel->addJoin('public.tbl_rt_person', 'reihungstest_id = rt_id');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->ReihungstestModel->addJoin('public.tbl_person', 'person_id');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->ReihungstestModel->addJoin('public.tbl_ort', 'tbl_ort.ort_kurzbz = tbl_rt_person.ort_kurzbz', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->ReihungstestModel->loadWhere(array('person_id' => $person_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $this->reihungstestlib->getReihungstestByPersonID($person_id);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -108,9 +98,9 @@ class Reihungstest extends APIv1_Controller
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
{
|
||||
if (isset($this->post()['reihungstest_id']))
|
||||
if (isset($this->post()["reihungstest_id"]))
|
||||
{
|
||||
$result = $this->ReihungstestModel->update($this->post()['reihungstest_id'], $this->post());
|
||||
$result = $this->ReihungstestModel->update($this->post()["reihungstest_id"], $this->post());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class FHC_Model extends CI_Model
|
||||
{
|
||||
@@ -10,16 +10,16 @@ class FHC_Model extends CI_Model
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->lang->load('fhc_model');
|
||||
$this->lang->load('fhcomplete');
|
||||
$this->lang->load("fhc_model");
|
||||
$this->lang->load("fhcomplete");
|
||||
|
||||
$this->load->helper('language');
|
||||
$this->load->helper('Message');
|
||||
$this->load->helper('fhcauth');
|
||||
$this->load->helper("language");
|
||||
$this->load->helper("Message");
|
||||
$this->load->helper("fhcauth");
|
||||
|
||||
$this->load->library('FHC_DB_ACL');
|
||||
$this->load->library("FHC_DB_ACL");
|
||||
|
||||
$this->acl = $this->config->item('fhc_acl');
|
||||
$this->acl = $this->config->item("fhc_acl");
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------------------
|
||||
@@ -54,4 +54,18 @@ class FHC_Model extends CI_Model
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function isEntitled($sourceName, $accessType, $languageMessageCode, $msgErrorCode)
|
||||
{
|
||||
$fhc_acl = $this->getBerechtigungKurzbz($sourceName);
|
||||
|
||||
if (! $this->fhc_db_acl->isBerechtigt($fhc_acl, $accessType))
|
||||
{
|
||||
return $this->_error(lang("fhc_" . $languageMessageCode)." -> " . $fhc_acl . ":" . $accessType, $msgErrorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ReihungstestLib
|
||||
{
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
|
||||
$this->ci->load->model("crm/RtPerson_model", "RtPersonModel");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function insertPersonReihungstest($ddReihungstest)
|
||||
{
|
||||
return $this->ci->RtPersonModel->insert($ddReihungstest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function updatePersonReihungstest($ddReihungstest)
|
||||
{
|
||||
$pksArray = array($ddReihungstest["person_id"], $ddReihungstest["rt_id"]);
|
||||
|
||||
return $this->ci->RtPersonModel->update($pksArray, $ddReihungstest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function deletePersonReihungstest($ddReihungstest)
|
||||
{
|
||||
return $this->ci->RtPersonModel->delete($ddReihungstest["rt_person_id"], $ddReihungstest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getReihungstestByPersonID($person_id)
|
||||
{
|
||||
$this->ci->ReihungstestModel->addJoin("public.tbl_rt_person", "reihungstest_id = rt_id");
|
||||
$this->ci->ReihungstestModel->addJoin("public.tbl_person", "person_id");
|
||||
$this->ci->ReihungstestModel->addJoin("public.tbl_ort", "tbl_ort.ort_kurzbz = tbl_rt_person.ort_kurzbz", "LEFT");
|
||||
|
||||
return $this->ci->ReihungstestModel->loadWhere(array("person_id" => $person_id));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
<?php
|
||||
|
||||
class Gemeinde_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'bis.tbl_gemeinde';
|
||||
$this->pk = 'gemeinde_id';
|
||||
$this->dbTable = "bis.tbl_gemeinde";
|
||||
$this->pk = "gemeinde_id";
|
||||
}
|
||||
}
|
||||
|
||||
public function getGemeindeByPlz($plz)
|
||||
{
|
||||
$this->addSelect("DISTINCT ON (ortschaftsname) ortschaftsname, gemeinde_id, plz, name, ortschaftskennziffer, bulacode, bulabez, kennziffer");
|
||||
$this->addOrder("ortschaftsname");
|
||||
|
||||
return $this->loadWhere(array("plz" => $plz));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,37 @@
|
||||
<?php
|
||||
|
||||
class Dokumentstudiengang_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_dokumentstudiengang';
|
||||
$this->pk = array('studiengang_kz', 'dokument_kurzbz');
|
||||
$this->dbTable = "public.tbl_dokumentstudiengang";
|
||||
$this->pk = array("studiengang_kz", "dokument_kurzbz");
|
||||
}
|
||||
}
|
||||
|
||||
public function getDokumentstudiengangByStudiengang_kz($studiengang_kz, $onlinebewerbung, $pflicht)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($chkRights = $this->isEntitled("public.tbl_dokument", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
|
||||
$this->addJoin("public.tbl_dokument", "dokument_kurzbz");
|
||||
|
||||
$parameterArray = array("studiengang_kz" => $studiengang_kz);
|
||||
|
||||
if( isset($onlinebewerbung))
|
||||
{
|
||||
$parameterArray["onlinebewerbung"] = $onlinebewerbung;
|
||||
}
|
||||
|
||||
if( isset($pflicht))
|
||||
{
|
||||
$parameterArray["pflicht"] = $pflicht;
|
||||
}
|
||||
|
||||
return $this->loadWhere($parameterArray);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user