- 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:
bison-paolo
2016-10-17 17:07:51 +02:00
parent 19ff69110d
commit f3b79cd731
17 changed files with 327 additions and 318 deletions
@@ -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);
}
}