mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +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:
@@ -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