mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
- Added method chkRights to DB_Model
- Added method toPhp to DB_Model to convert array and boolean types from PostgresSQL to php - Added method execQuery to DB_Model to execute a query (it calls toPhp) - Added method pgsqlArrayToPhpArray to convert a pgsql array to php - Updated DB_Model methods to using chkRights (and toPhp where it is needed) - Removed methods escapeArray and _pgsqlArrayToPhpArray from controller APIv1_Controller - Removed escapeArray from controllers Dokumentstudiengang and Dokument - Updated models to use execQuery (and chkRights where it is needed)
This commit is contained in:
@@ -14,20 +14,14 @@ class Orgform_model extends DB_Model
|
||||
|
||||
public function getOrgformLV()
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($chkRights = $this->isEntitled($this->dbTable, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
// Checks rights
|
||||
if ($chkRights = $this->chkRights(PermissionLib::SELECT_RIGHT)) return $chkRights;
|
||||
|
||||
$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 success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
}
|
||||
@@ -75,12 +75,7 @@ class Akte_model extends DB_Model
|
||||
|
||||
$query .= ' ORDER BY erstelltam';
|
||||
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,11 +126,6 @@ class Akte_model extends DB_Model
|
||||
|
||||
$query .= ' GROUP BY a.akte_id ORDER BY a.erstelltam';
|
||||
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,10 @@ class Dokumentprestudent_model extends DB_Model
|
||||
AND ds.studiengang_kz = ?
|
||||
)';
|
||||
|
||||
$result = $this->db->query($query, array($prestudent_id, $studiengang_kz));
|
||||
$result = $this->execQuery($query, array($prestudent_id, $studiengang_kz));
|
||||
}
|
||||
|
||||
if ($result)
|
||||
return success($result);
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setAcceptedDocuments($prestudent_id, $dokument_kurzbz)
|
||||
@@ -66,12 +63,9 @@ class Dokumentprestudent_model extends DB_Model
|
||||
)
|
||||
)';
|
||||
|
||||
$result = $this->db->query($query, array($prestudent_id, $dokument_kurzbz, $prestudent_id));
|
||||
$result = $this->execQuery($query, array($prestudent_id, $dokument_kurzbz, $prestudent_id));
|
||||
}
|
||||
|
||||
if ($result)
|
||||
return success($result);
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -49,11 +49,6 @@ class Prestudentstatus_model extends DB_Model
|
||||
|
||||
$query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1';
|
||||
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,8 @@ class Organisationseinheit_model extends DB_Model
|
||||
if (!empty($typ))
|
||||
$qry .= 'WHERE organisationseinheittyp_kurzbz IN ('.$typ.') ';
|
||||
$qry .= 'ORDER BY path;';
|
||||
|
||||
|
||||
if ($res = $this->db->query($qry))
|
||||
return success($res);
|
||||
else
|
||||
return error($this->db->error());
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,13 +75,6 @@ class Organisationseinheit_model extends DB_Model
|
||||
|
||||
$query = sprintf($query, $table, $fields, $schema, $table, $where, $orderby);
|
||||
|
||||
if ($result = $this->db->query($query, array($oe_kurzbz)))
|
||||
{
|
||||
return success($result->result());
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
return $this->execQuery($query, array($oe_kurzbz));
|
||||
}
|
||||
}
|
||||
@@ -96,9 +96,7 @@ class Studiengang_model extends DB_Model
|
||||
AND t1.aktiv IS TRUE
|
||||
ORDER BY typ, studiengangbezeichnung, tbl_lgartcode.bezeichnung ASC';
|
||||
|
||||
$result = $this->db->query($allForBewerbungQuery);
|
||||
|
||||
return success($result->result());
|
||||
return $this->execQuery($allForBewerbungQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,9 +14,8 @@ class Studiensemester_model extends DB_Model
|
||||
|
||||
public function getLastOrAktSemester($days = 60)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($chkRights = $this->isEntitled('public.tbl_studiensemester', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
// Checks rights
|
||||
if ($chkRights = $this->chkRights(PermissionLib::SELECT_RIGHT)) return $chkRights;
|
||||
|
||||
if (!is_numeric($days))
|
||||
{
|
||||
@@ -29,19 +28,13 @@ class Studiensemester_model extends DB_Model
|
||||
ORDER BY start DESC
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->db->query($query);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
|
||||
public function getNextFrom($studiensemester_kurzbz)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($chkRights = $this->isEntitled('public.tbl_studiensemester', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
// Checks rights
|
||||
if ($chkRights = $this->chkRights(PermissionLib::SELECT_RIGHT)) return $chkRights;
|
||||
|
||||
$query = 'SELECT studiensemester_kurzbz,
|
||||
start,
|
||||
@@ -55,12 +48,7 @@ class Studiensemester_model extends DB_Model
|
||||
ORDER BY start
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->db->query($query, array($studiensemester_kurzbz));
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, array($studiensemester_kurzbz));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,11 +81,6 @@ class Studiensemester_model extends DB_Model
|
||||
|
||||
$query .= ' ORDER BY delta LIMIT 1';
|
||||
|
||||
$result = $this->db->query($query);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
}
|
||||
@@ -8,15 +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");
|
||||
$this->addJoin('public.tbl_kontakt', 'person_id');
|
||||
|
||||
return $this->loadWhere(array("zugangscode" => $zugangscode, "kontakt" => $email));
|
||||
return $this->loadWhere(array('zugangscode' => $zugangscode, 'kontakt' => $email));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,77 +24,71 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function checkBewerbung($email, $studiensemester_kurzbz = null)
|
||||
{
|
||||
if (($chkRights = $this->isEntitled("public.tbl_person", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
if (($chkRights = $this->isEntitled('public.tbl_person', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (($chkRights = $this->isEntitled("public.tbl_kontakt", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
if (($chkRights = $this->isEntitled('public.tbl_kontakt', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (($chkRights = $this->isEntitled("public.tbl_benutzer", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
if (($chkRights = $this->isEntitled('public.tbl_benutzer', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (($chkRights = $this->isEntitled("public.tbl_prestudent", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
if (($chkRights = $this->isEntitled('public.tbl_prestudent', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (($chkRights = $this->isEntitled("public.tbl_prestudentstatus", "s", FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
if (($chkRights = $this->isEntitled('public.tbl_prestudentstatus', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
|
||||
$result = null;
|
||||
$checkBewerbungQuery = "";
|
||||
$checkBewerbungQuery = '';
|
||||
$parametersArray = array($email, $email, $email);
|
||||
|
||||
if (is_null($studiensemester_kurzbz))
|
||||
{
|
||||
$checkBewerbungQuery = "SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum
|
||||
$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
|
||||
LEFT JOIN public.tbl_benutzer b ON p.person_id = b.person_id
|
||||
WHERE k.kontakttyp = 'email'
|
||||
AND (kontakt = ? OR alias || '@" . DOMAIN . "' = ? OR uid || '@" . DOMAIN . "' = ?)
|
||||
WHERE k.kontakttyp = \'email\'
|
||||
AND (kontakt = ? OR alias || \'@' . DOMAIN . '\' = ? OR uid || \'@' . DOMAIN . '\' = ?)
|
||||
ORDER BY p.insertamum DESC
|
||||
LIMIT 1";
|
||||
LIMIT 1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkBewerbungQuery = "SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum
|
||||
$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
|
||||
LEFT JOIN public.tbl_benutzer b ON p.person_id = b.person_id
|
||||
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 || '@" . DOMAIN . "' = ? OR uid || '@" . DOMAIN . "' = ?)
|
||||
WHERE k.kontakttyp = \'email\'
|
||||
AND (kontakt = ? OR alias || \'@' . DOMAIN . '\' = ? OR uid || \'@' . DOMAIN . '\' = ?)
|
||||
AND studiensemester_kurzbz = ?
|
||||
ORDER BY p.insertamum DESC
|
||||
LIMIT 1";
|
||||
LIMIT 1';
|
||||
|
||||
array_push($parametersArray, $studiensemester_kurzbz);
|
||||
}
|
||||
|
||||
$result = $this->db->query($checkBewerbungQuery, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($checkBewerbungQuery, $parametersArray);
|
||||
}
|
||||
|
||||
public function updatePerson($person)
|
||||
{
|
||||
if (isset($person["svnr"]) && $person["svnr"] != "")
|
||||
if (isset($person['svnr']) && $person['svnr'] != '')
|
||||
{
|
||||
$this->PersonModel->addOrder("svnr", "DESC");
|
||||
$this->PersonModel->addOrder('svnr', 'DESC');
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
"person_id != " => $person["person_id"],
|
||||
"SUBSTRING(svnr FROM 1 FOR 10) = " => $person["svnr"])
|
||||
'person_id != ' => $person['person_id'],
|
||||
'SUBSTRING(svnr FROM 1 FOR 10) = ' => $person['svnr'])
|
||||
);
|
||||
if (hasData($result))
|
||||
{
|
||||
if (count($result->retval) == 1 && $result->retval[0]->svnr == $person["svnr"])
|
||||
if (count($result->retval) == 1 && $result->retval[0]->svnr == $person['svnr'])
|
||||
{
|
||||
$person["svnr"] = $person["svnr"] . "v1";
|
||||
$person['svnr'] = $person['svnr'] . 'v1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$person["svnr"] = $person["svnr"] . "v" . ($result->retval[0]->svnr{11} + 1);
|
||||
$person['svnr'] = $person['svnr'] . 'v' . ($result->retval[0]->svnr{11} + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->PersonModel->update($person["person_id"], $person);
|
||||
return $this->PersonModel->update($person['person_id'], $person);
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,6 @@ class Message_model extends DB_Model
|
||||
$sql = sprintf($sql, 'WHERE status >= 3');
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql, $parametersArray);
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($sql, $parametersArray);
|
||||
}
|
||||
}
|
||||
@@ -57,12 +57,7 @@ class Phrase_model extends DB_Model
|
||||
$parametersArray['orgform_kurzbz'] = $orgform_kurzbz;
|
||||
$query .= ' AND orgform_kurzbz = ?';
|
||||
}
|
||||
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,11 +47,7 @@ class Recipient_model extends DB_Model
|
||||
$parametersArray = array($message_id, $person_id);
|
||||
|
||||
// Get data of the messages to sent
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +81,7 @@ class Recipient_model extends DB_Model
|
||||
WHERE r.token = ?
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token));
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($sql, array(MSG_STATUS_DELETED, $token));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,11 +139,7 @@ class Recipient_model extends DB_Model
|
||||
$sql = sprintf($sql, 'WHERE person_id = ? AND message_id NOT IN (SELECT message_id FROM public.tbl_msg_status WHERE status >= 3 AND person_id = ?)');
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql, $parametersArray);
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($sql, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,11 +192,7 @@ class Recipient_model extends DB_Model
|
||||
if (! $all)
|
||||
$sql .= ' AND (status < 3 OR status IS NULL)';
|
||||
|
||||
$result = $this->db->query($sql, array($uid));
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($sql, array($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,11 +257,6 @@ class Recipient_model extends DB_Model
|
||||
array_push($parametersArray, $limit);
|
||||
}
|
||||
|
||||
// Get data of the messages to sent
|
||||
$result = $this->db->query($query, $parametersArray);
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Vorlage_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -14,12 +14,11 @@ class Vorlage_model extends DB_Model
|
||||
|
||||
public function getMimeTypes()
|
||||
{
|
||||
$qry = 'SELECT DISTINCT mimetype FROM public.tbl_vorlage ORDER BY mimetype;';
|
||||
|
||||
// Checks rights
|
||||
if ($chkRights = $this->chkRights(PermissionLib::SELECT_RIGHT)) return $chkRights;
|
||||
|
||||
if ($res = $this->db->query($qry))
|
||||
return success($res);
|
||||
else
|
||||
return error($this->db->error());
|
||||
$query = 'SELECT DISTINCT mimetype FROM public.tbl_vorlage ORDER BY mimetype';
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,8 @@ class Vorlagedokument_model extends DB_Model
|
||||
*/
|
||||
public function loadDokumenteFromVorlagestudiengang($vorlagestudiengang_id)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($chkRights = $this->isEntitled('public.tbl_vorlagedokument', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
|
||||
$result = null;
|
||||
// Checks rights
|
||||
if ($chkRights = $this->chkRights(PermissionLib::SELECT_RIGHT)) return $chkRights;
|
||||
|
||||
$qry = 'SELECT vorlagedokument_id,
|
||||
sort,
|
||||
@@ -33,11 +30,6 @@ class Vorlagedokument_model extends DB_Model
|
||||
WHERE vorlagestudiengang_id = ?
|
||||
ORDER BY sort ASC';
|
||||
|
||||
$result = $this->db->query($qry, array($vorlagestudiengang_id));
|
||||
|
||||
if (is_object($result))
|
||||
return success($result->result());
|
||||
else
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return $this->execQuery($qry, array($vorlagestudiengang_id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user