mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
- Modified FHC_Model contructor to get UID from vilesci authentication
- Copied functionalities from old libraries to controllers - Ported old libraries to CI - Modified codeception
This commit is contained in:
@@ -189,6 +189,7 @@ $config['fhc_acl'] = array
|
||||
'public.tbl_variable' => 'basis/variable',
|
||||
'public.tbl_vorlage' => 'basis/vorlage',
|
||||
'public.tbl_vorlagestudiengang' => 'basis/vorlagestudiengang',
|
||||
'public.vw_studiensemester' => 'basis/vw_studiensemester',
|
||||
'system.tbl_appdaten' => 'basis/appdaten',
|
||||
'system.tbl_benutzerrolle' => 'basis/benutzerrolle',
|
||||
'system.tbl_berechtigung' => 'basis/berechtigung',
|
||||
|
||||
@@ -28,6 +28,22 @@ class Nation extends APIv1_Controller
|
||||
$this->NationModel->setUID($this->_getUID());
|
||||
}
|
||||
|
||||
public function getNation()
|
||||
{
|
||||
$nation_code = $this->get("nation_code");
|
||||
|
||||
if (isset($nation_code))
|
||||
{
|
||||
$result = $this->NationModel->loadWhere(array('nation_code' => $nation_code));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
if (!$this->get('orderEnglish'))
|
||||
|
||||
@@ -46,6 +46,26 @@ class Orgform extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$result = $this->OrgformModel->loadWhole();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getOrgformLV()
|
||||
{
|
||||
$result = $this->OrgformModel->getOrgformLV();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@@ -71,13 +91,6 @@ class Orgform extends APIv1_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$result = $this->OrgformModel->loadWhole();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
private function _validate($orgform = NULL)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -54,25 +54,212 @@ class Studiensemester extends APIv1_Controller
|
||||
{
|
||||
$art = $this->get('art');
|
||||
|
||||
$result = $this->StudiensemesterModel->addOrder('start');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
$this->StudiensemesterModel->addOrder('start');
|
||||
$this->StudiensemesterModel->addLimit(1);
|
||||
|
||||
if (isset($art))
|
||||
{
|
||||
$result = $this->StudiensemesterModel->addLimit(1);
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
if (isset($art))
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start >' => 'NOW()', 'SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) = ' => $art));
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start >' => 'NOW()'));
|
||||
}
|
||||
}
|
||||
$result = $this->StudiensemesterModel->loadWhere(
|
||||
array('start >' => 'NOW()',
|
||||
'SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) = ' => $art
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start >' => 'NOW()'));
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$order = $this->get('order');
|
||||
|
||||
if (strcasecmp($order, 'DESC') == 0)
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende', 'DESC');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende', 'ASC');
|
||||
}
|
||||
|
||||
$result = $this->StudiensemesterModel->loadWhole();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAkt()
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start <=' => 'NOW()', 'ende >=' => 'NOW()'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAktNext()
|
||||
{
|
||||
$semester = $this->get('semester');
|
||||
|
||||
$result = null;
|
||||
|
||||
if (!is_numeric($semester))
|
||||
{
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start <=' => 'NOW()', 'ende >=' => 'NOW()'));
|
||||
}
|
||||
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) &&
|
||||
count($result->retval) > 0)
|
||||
{
|
||||
// Return $result
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende');
|
||||
$this->StudiensemesterModel->addLimit(1);
|
||||
|
||||
$whereArray = array('ende >=' => 'NOW()');
|
||||
|
||||
if (is_numeric($semester))
|
||||
{
|
||||
if ($semester % 2 == 0)
|
||||
{
|
||||
$ss = 'SS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ss = 'WS';
|
||||
}
|
||||
|
||||
$whereArray['SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) ='] = $ss;
|
||||
}
|
||||
|
||||
$result = $this->StudiensemesterModel->loadWhere($whereArray);
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getLastOrAktSemester()
|
||||
{
|
||||
$result = $this->StudiensemesterModel->getLastOrAktSemester($this->get('days'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getNextFrom()
|
||||
{
|
||||
$result = $this->StudiensemesterModel->getNextFrom($this->get('studiensemester_kurzbz'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getPrevious()
|
||||
{
|
||||
$this->StudiensemesterModel->addOrder('ende', 'DESC');
|
||||
$this->StudiensemesterModel->addLimit(1);
|
||||
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('ende <' => 'NOW()'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getNearest()
|
||||
{
|
||||
$result = $this->StudiensemesterModel->getNearest($this->get('semester'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getFinished()
|
||||
{
|
||||
$limit = $this->get('limit');
|
||||
|
||||
$this->StudiensemesterModel->addOrder('ende', 'DESC');
|
||||
$this->StudiensemesterModel->addLimit($limit);
|
||||
|
||||
$result = $this->StudiensemesterModel->loadWhere(array('start <=' => 'NOW()'));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
|
||||
|
||||
if (isset($studiensemester_kurzbz))
|
||||
{
|
||||
$result = $this->StudiensemesterModel->load($studiensemester_kurzbz);
|
||||
|
||||
if (is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
$studiensemester = $result->retval[0];
|
||||
|
||||
if (is_object($studiensemester))
|
||||
{
|
||||
$start = "";
|
||||
if (isset($studiensemester->start))
|
||||
{
|
||||
$start = mktime(0, 0, 0,
|
||||
mb_substr($studiensemester->start, 5, 2),
|
||||
mb_substr($studiensemester->start, 8, 2),
|
||||
mb_substr($studiensemester->start, 0, 4)
|
||||
);
|
||||
}
|
||||
|
||||
$ende = "";
|
||||
if (isset($studiensemester->ende))
|
||||
{
|
||||
$ende = mktime(0, 0, 0,
|
||||
mb_substr($studiensemester->ende, 5, 2),
|
||||
mb_substr($studiensemester->ende, 8, 2),
|
||||
mb_substr($studiensemester->ende, 0, 4)
|
||||
);
|
||||
}
|
||||
|
||||
$result->retval = array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'start' => $start,
|
||||
'ende' => $ende
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
@@ -29,25 +29,82 @@ class Kontakt extends APIv1_Controller
|
||||
$this->KontaktModel->setUID($this->_getUID());
|
||||
}
|
||||
|
||||
public function getKontakt()
|
||||
public function getKontakt()
|
||||
{
|
||||
$personID = $this->get("person_id");
|
||||
$kontakt_id = $this->get("kontakt_id");
|
||||
|
||||
if (isset($personID))
|
||||
if (isset($kontakt_id))
|
||||
{
|
||||
$result = $this->KontaktModel->loadWhere(array('person_id' => $personID));
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->loadWhere(array('kontakt_id' => $kontakt_id));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
public function getKontaktByPersonID()
|
||||
{
|
||||
$person_id = $this->get("person_id");
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->loadWhere(array('person_id' => $person_id));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
public function getKontaktByPersonIDKontaktTyp()
|
||||
{
|
||||
$person_id = $this->get("person_id");
|
||||
$kontakttyp = $this->get("kontakttyp");
|
||||
|
||||
if (isset($person_id) && isset($kontakttyp))
|
||||
{
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->KontaktModel->loadWhere(array('person_id' => $person_id, 'kontakttyp' => $kontakttyp));
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
public function postKontakt()
|
||||
{
|
||||
$post = $this->_parseData($this->post());
|
||||
$post = $this->_parseData($this->post());
|
||||
|
||||
if (is_array($post))
|
||||
{
|
||||
|
||||
@@ -11,11 +11,19 @@ class FHC_Model extends CI_Model
|
||||
$this->lang->load('fhc_model');
|
||||
$this->lang->load('fhcomplete');
|
||||
|
||||
$uid = NULL;
|
||||
if (is_null($uid) && isset($this->session->uid))
|
||||
$uid = null;
|
||||
|
||||
// Get UID from CI session
|
||||
if(isset($this->session->uid))
|
||||
{
|
||||
$uid = $this->session->uid;
|
||||
}
|
||||
// Get UID from the environment (HTTP authentication via authentication.class.php)
|
||||
else if(isset($_SERVER['PHP_AUTH_USER']))
|
||||
{
|
||||
$uid = $_SERVER['PHP_AUTH_USER'];
|
||||
}
|
||||
|
||||
$this->load->library('FHC_DB_ACL', array('uid' => $uid));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Orgform_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -11,4 +11,23 @@ class Orgform_model extends DB_Model
|
||||
$this->dbTable = 'bis.tbl_orgform';
|
||||
$this->pk = 'orgform_kurzbz';
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrgformLV()
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['bis.tbl_orgform'], 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['bis.tbl_orgform'], FHC_MODEL_ERROR);
|
||||
|
||||
$query = "SELECT *
|
||||
FROM bis.tbl_orgform
|
||||
WHERE orgform_kurzbz NOT IN ('VBB', 'ZGS')
|
||||
ORDER BY orgform_kurzbz";
|
||||
|
||||
$result = $this->db->query($query);
|
||||
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Studiensemester_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -11,4 +11,93 @@ class Studiensemester_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_studiensemester';
|
||||
$this->pk = 'studiensemester_kurzbz';
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastOrAktSemester($days = 60)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_studiensemester'], 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_studiensemester'], FHC_MODEL_ERROR);
|
||||
|
||||
if (!is_numeric($days))
|
||||
{
|
||||
$days = 60;
|
||||
}
|
||||
|
||||
$query = "SELECT studiensemester_kurzbz
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE start < NOW() - '" . $days . " DAYS'::INTERVAL
|
||||
ORDER BY start DESC
|
||||
LIMIT 1";
|
||||
|
||||
$result = $this->db->query($query);
|
||||
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
|
||||
public function getNextFrom($studiensemester_kurzbz)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_studiensemester'], 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_studiensemester'], FHC_MODEL_ERROR);
|
||||
|
||||
$query = "SELECT studiensemester_kurzbz,
|
||||
start,
|
||||
ende
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE start > (
|
||||
SELECT ende
|
||||
FROM public.tbl_studiensemester
|
||||
WHERE studiensemester_kurzbz = ?
|
||||
)
|
||||
ORDER BY start
|
||||
LIMIT 1";
|
||||
|
||||
$result = $this->db->query($query, array($studiensemester_kurzbz));
|
||||
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getNearest($semester = '')
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.vw_studiensemester'], 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.vw_studiensemester'], FHC_MODEL_ERROR);
|
||||
|
||||
$query = "SELECT studiensemester_kurzbz,
|
||||
start,
|
||||
ende
|
||||
FROM public.vw_studiensemester";
|
||||
|
||||
if (is_numeric($semester))
|
||||
{
|
||||
if ($semester % 2 == 0)
|
||||
{
|
||||
$ss = 'SS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ss = 'WS';
|
||||
}
|
||||
|
||||
$query .= " WHERE SUBSTRING(studiensemester_kurzbz FROM 1 FOR 2) = '" . $ss . "'";
|
||||
}
|
||||
|
||||
$query .= " ORDER BY delta LIMIT 1";
|
||||
|
||||
$result = $this->db->query($query);
|
||||
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class Person_model extends DB_Model
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function checkBewerbung($email, $studiensemester_kurzbz = NULL)
|
||||
public function checkBewerbung($email, $studiensemester_kurzbz = null)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_person'], 's'))
|
||||
@@ -33,9 +33,9 @@ class Person_model extends DB_Model
|
||||
if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_prestudentstatus'], 's'))
|
||||
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_prestudentstatus'], FHC_MODEL_ERROR);
|
||||
|
||||
$result = NULL;
|
||||
$result = null;
|
||||
|
||||
if(is_null($studiensemester_kurzbz))
|
||||
if (is_null($studiensemester_kurzbz))
|
||||
{
|
||||
$checkBewerbungQuery = "SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum
|
||||
FROM public.tbl_person p JOIN public.tbl_kontakt k ON p.person_id = k.person_id
|
||||
@@ -63,9 +63,9 @@ class Person_model extends DB_Model
|
||||
$result = $this->db->query($checkBewerbungQuery, array($email, $email, $email, $studiensemester_kurzbz));
|
||||
}
|
||||
|
||||
if(is_object($result))
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user