mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Changed methods:
- getMessagesByPersonID - getMessagesByUID - getSentMessagesByPerson - getCountUnreadMessages of controller system/Message to get messages also with a given organisation unit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
@@ -13,11 +13,11 @@ class Message_model extends DB_Model
|
||||
$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)
|
||||
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_person', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
|
||||
@@ -26,7 +26,7 @@ class Message_model extends DB_Model
|
||||
return $ent;
|
||||
if (isError($ent = $this->isEntitled('public.tbl_msg_message', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))
|
||||
return $ent;
|
||||
|
||||
|
||||
$sql = 'SELECT m.message_id,
|
||||
m.person_id,
|
||||
m.subject,
|
||||
@@ -52,9 +52,9 @@ class Message_model extends DB_Model
|
||||
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, '');
|
||||
@@ -63,17 +63,23 @@ class Message_model extends DB_Model
|
||||
{
|
||||
$sql = sprintf($sql, 'WHERE status >= 3');
|
||||
}
|
||||
|
||||
|
||||
if ($oe_kurzbz != null)
|
||||
{
|
||||
array_push($parametersArray, $oe_kurzbz);
|
||||
$sql .= ' AND m.oe_kurzbz = ?';
|
||||
}
|
||||
|
||||
return $this->execQuery($sql, $parametersArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getMessageVars
|
||||
*/
|
||||
public function getMessageVars()
|
||||
{
|
||||
$result = $this->db->query('SELECT * FROM public.vw_msg_vars WHERE 0 = 1');
|
||||
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return success($result->list_fields());
|
||||
@@ -83,14 +89,14 @@ class Message_model extends DB_Model
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getMsgVarsDataByPrestudentId
|
||||
*/
|
||||
public function getMsgVarsDataByPrestudentId($prestudent_id)
|
||||
{
|
||||
$query = 'SELECT * FROM public.vw_msg_vars WHERE prestudent_id %s ?';
|
||||
|
||||
|
||||
return $this->execQuery(sprintf($query, is_array($prestudent_id) ? 'IN' : '='), array($prestudent_id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user