Removed permission system from models

This commit is contained in:
Paolo
2018-03-29 12:13:08 +02:00
parent 0906f5bc85
commit d9b80b790d
16 changed files with 43 additions and 241 deletions
@@ -18,16 +18,6 @@ class Recipient_model extends DB_Model
*/
public function getMessage($message_id, $person_id)
{
// Checks if the operation is permitted by the API caller
if (isError($ent = $this->isEntitled('public.tbl_person', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_kontakt', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$query = 'SELECT mr.message_id,
mr.person_id,
mm.subject,
@@ -55,14 +45,6 @@ class Recipient_model extends DB_Model
*/
public function getMessageByToken($token)
{
// Checks if the operation is permitted by the API caller
if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$sql = 'SELECT r.message_id,
m.person_id as sender_id,
r.person_id as receiver_id,
@@ -89,16 +71,6 @@ class Recipient_model extends DB_Model
*/
public function getMessagesByPerson($person_id, $oe_kurzbz, $all)
{
// Checks if the operation is permitted by the API caller
if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_person', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$sql = 'SELECT DISTINCT ON (r.message_id) r.message_id,
m.person_id,
m.subject,
@@ -166,21 +138,6 @@ class Recipient_model extends DB_Model
*/
public function getMessagesByUID($uid, $oe_kurzbz, $all)
{
// Checks if the operation is permitted by the API caller
// TODO: Define the special right for reading own messages 'basis/message:own'
// if same user
if ($uid === getAuthUID())
{
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
}
// if different user, for reading messages from other users
else
{
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
}
// get Data
$sql = 'SELECT DISTINCT ON (r.message_id) r.message_id,
m.person_id,
@@ -249,14 +206,6 @@ class Recipient_model extends DB_Model
*/
public function getMessages($kontaktType, $sent, $limit = null, $message_id = null)
{
// Checks if the operation is permitted by the API caller
if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_kontakt', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$query = 'SELECT mm.message_id,
ks.kontakt as sender,
kr.kontakt as receiver,
@@ -321,12 +270,6 @@ class Recipient_model extends DB_Model
*/
public function getCountUnreadMessages($person_id, $oe_kurzbz)
{
// Checks if the operation is permitted by the API caller
if (isError($ent = $this->isEntitled('public.tbl_msg_recipient', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
if (isError($ent = $this->isEntitled('public.tbl_msg_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
return $ent;
$sql = 'SELECT COUNT(r.message_id) AS unreadMessages
FROM public.tbl_msg_recipient r
JOIN public.tbl_msg_status s ON (r.message_id = s.message_id AND r.person_id = s.person_id)