mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
5087826891
- Renamed method chkRights to _isEntitled in model DB_Model - Updated models where it was needed
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Message_model extends DB_Model
|
|
{
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->dbTable = 'public.tbl_msg_message';
|
|
$this->pk = 'message_id';
|
|
}
|
|
|
|
/**
|
|
* Get all sent messages from a person identified by person_id
|
|
*/
|
|
public function getMessagesByPerson($person_id, $all)
|
|
{
|
|
// Checks if the operation is permitted by the API caller
|
|
if (($isEntitled = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $isEntitled;
|
|
if (($isEntitled = $this->isEntitled('public.tbl_person', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $isEntitled;
|
|
if (($isEntitled = $this->isEntitled('public.tbl_msg_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $isEntitled;
|
|
|
|
$sql = 'SELECT m.message_id,
|
|
m.person_id,
|
|
m.subject,
|
|
m.body,
|
|
m.priority,
|
|
m.insertamum,
|
|
m.relationmessage_id,
|
|
m.oe_kurzbz,
|
|
p.anrede,
|
|
p.titelpost,
|
|
p.titelpre,
|
|
p.nachname,
|
|
p.vorname,
|
|
p.vornamen,
|
|
s.status,
|
|
s.statusinfo,
|
|
s.insertamum AS statusamum
|
|
FROM public.tbl_msg_message m JOIN public.tbl_person p ON (p.person_id = m.person_id)
|
|
LEFT JOIN (
|
|
SELECT message_id, person_id, status, statusinfo, insertamum
|
|
FROM public.tbl_msg_status
|
|
%s
|
|
ORDER BY insertamum DESC
|
|
) s ON (m.message_id = s.message_id AND m.person_id = s.person_id)
|
|
WHERE m.person_id = ?';
|
|
|
|
$parametersArray = array($person_id);
|
|
|
|
if ($all == 'true')
|
|
{
|
|
$sql = sprintf($sql, '');
|
|
}
|
|
else
|
|
{
|
|
$sql = sprintf($sql, 'WHERE status >= 3');
|
|
}
|
|
|
|
return $this->execQuery($sql, $parametersArray);
|
|
}
|
|
} |