mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
- Cleaned the controllers by moving the database related code and more complex logic
in the models or libraries - DmsLib bug fix - Person_model bug fix
This commit is contained in:
@@ -1,14 +1,45 @@
|
||||
<?php
|
||||
|
||||
class Studienplan_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'lehre.tbl_studienplan';
|
||||
$this->pk = 'studienplan_id';
|
||||
$this->dbTable = "lehre.tbl_studienplan";
|
||||
$this->pk = "studienplan_id";
|
||||
}
|
||||
|
||||
public function getStudienplaene($studiengang_kz)
|
||||
{
|
||||
$this->addJoin("lehre.tbl_studienordnung", "studienordnung_id");
|
||||
|
||||
return $this->loadWhere(array("studiengang_kz" => $studiengang_kz));
|
||||
}
|
||||
|
||||
public function getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester = null, $orgform_kurzbz = null)
|
||||
{
|
||||
$this->addJoin("lehre.tbl_studienordnung", "studienordnung_id");
|
||||
$this->addJoin("lehre.tbl_studienplan_semester", "studienplan_id");
|
||||
|
||||
$whereArray = array(
|
||||
"tbl_studienplan.aktiv" => "TRUE",
|
||||
"tbl_studienordnung.studiengang_kz" => $studiengang_kz,
|
||||
"tbl_studienplan_semester.studiensemester_kurzbz" => $studiensemester_kurzbz
|
||||
);
|
||||
|
||||
if(!is_null($ausbildungssemester))
|
||||
{
|
||||
$whereArray["tbl_studienplan_semester.semester"] = $ausbildungssemester;
|
||||
}
|
||||
|
||||
if(!is_null($orgform_kurzbz))
|
||||
{
|
||||
$whereArray["orgform_kurzbz"] = $orgform_kurzbz;
|
||||
}
|
||||
|
||||
return $this->StudienplanModel->loadWhere($whereArray);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
class Kontakt_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
@@ -7,7 +8,40 @@ class Kontakt_model extends DB_Model
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_kontakt';
|
||||
$this->pk = 'kontakt_id';
|
||||
$this->dbTable = "public.tbl_kontakt";
|
||||
$this->pk = "kontakt_id";
|
||||
}
|
||||
|
||||
public function getWholeKontakt($kontakt_id, $person_id = null, $kontakttyp = null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
$this->addJoin("public.tbl_standort", "standort_id", "LEFT");
|
||||
$this->addJoin("public.tbl_firma", "firma_id", "LEFT");
|
||||
|
||||
if (isset($kontakt_id))
|
||||
{
|
||||
$result = $this->load($kontakt_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$parametersArray = array();
|
||||
|
||||
if (!is_null($person_id))
|
||||
{
|
||||
$parametersArray["person_id"] = $person_id;
|
||||
}
|
||||
if (!is_null($kontakttyp))
|
||||
{
|
||||
$parametersArray["kontakttyp"] = $kontakttyp;
|
||||
}
|
||||
|
||||
if (count($parametersArray) > 0)
|
||||
{
|
||||
$result = $this->loadWhere($parametersArray);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,15 @@ class Person_model extends DB_Model
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_person';
|
||||
$this->pk = 'person_id';
|
||||
$this->dbTable = "public.tbl_person";
|
||||
$this->pk = "person_id";
|
||||
}
|
||||
|
||||
public function getPersonKontaktByZugangscode($zugangscode, $email)
|
||||
{
|
||||
$this->addJoin("public.tbl_kontakt", "person_id");
|
||||
|
||||
return $this->loadWhere(array("zugangscode" => $zugangscode, "kontakt" => $email));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,6 +36,8 @@ class Person_model extends DB_Model
|
||||
return $chkRights;
|
||||
|
||||
$result = null;
|
||||
$checkBewerbungQuery = "";
|
||||
$parametersArray = array($email, $email, $email);
|
||||
|
||||
if (is_null($studiensemester_kurzbz))
|
||||
{
|
||||
@@ -36,11 +45,9 @@ class Person_model extends DB_Model
|
||||
FROM public.tbl_person p JOIN public.tbl_kontakt k ON p.person_id = k.person_id
|
||||
LEFT JOIN public.tbl_benutzer b ON p.person_id = b.person_id
|
||||
WHERE k.kontakttyp = 'email'
|
||||
AND (kontakt = ? OR alias || '@technikum-wien.at' = ? OR uid || '@technikum-wien.at' = ?)
|
||||
AND (kontakt = ? OR alias || '@" . DOMAIN . "' = ? OR uid || '@" . DOMAIN . "' = ?)
|
||||
ORDER BY p.insertamum DESC
|
||||
LIMIT 1";
|
||||
|
||||
$result = $this->db->query($checkBewerbungQuery, array($email, $email, $email));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -50,17 +57,45 @@ class Person_model extends DB_Model
|
||||
JOIN public.tbl_prestudent ps ON p.person_id = ps.person_id
|
||||
JOIN public.tbl_prestudentstatus pst ON pst.prestudent_id = ps.prestudent_id
|
||||
WHERE k.kontakttyp = 'email'
|
||||
AND (kontakt = ? OR alias || '@technikum-wien.at' = ? OR uid || '@technikum-wien.at' = ?)
|
||||
AND (kontakt = ? OR alias || '@" . DOMAIN . "' = ? OR uid || '@" . DOMAIN . "' = ?)
|
||||
AND studiensemester_kurzbz = ?
|
||||
ORDER BY p.insertamum DESC
|
||||
LIMIT 1";
|
||||
|
||||
$result = $this->db->query($checkBewerbungQuery, array($email, $email, $email, $studiensemester_kurzbz));
|
||||
array_push($parametersArray, $studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
$result = $this->db->query($checkBewerbungQuery, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return $this->_success($result->result());
|
||||
else
|
||||
return $this->_error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
|
||||
public function updatePerson($person)
|
||||
{
|
||||
if (isset($person["svnr"]) && $person["svnr"] != "")
|
||||
{
|
||||
$this->PersonModel->addOrder("svnr", "DESC");
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
"person_id != " => $person["person_id"],
|
||||
"SUBSTRING(svnr FROM 1 FOR 10) = " => $person["svnr"])
|
||||
);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS &&
|
||||
is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
if (count($result->retval) == 1 && $result->retval[0]->svnr == $person["svnr"])
|
||||
{
|
||||
$person["svnr"] = $person["svnr"] . "v1";
|
||||
}
|
||||
else
|
||||
{
|
||||
$person["svnr"] = $person["svnr"] . "v" . ($result->retval[0]->svnr{11} + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->PersonModel->update($person["person_id"], $person);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,23 @@
|
||||
<?php
|
||||
|
||||
class Ort_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_ort';
|
||||
$this->pk = 'ort_kurzbz';
|
||||
$this->dbTable = "public.tbl_ort";
|
||||
$this->pk = "ort_kurzbz";
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll($raumtyp_kurzbz)
|
||||
{
|
||||
$this->addOrder("ort_kurzbz");
|
||||
|
||||
$this->addJoin("public.tbl_ortraumtyp", "ort_kurzbz");
|
||||
|
||||
return $this->OrtModel->loadWhere(array("raumtyp_kurzbz" => $raumtyp_kurzbz));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user