- ViewMessage: checks if the receiver is an employee or not. If an

employee then hides the reply link
- Added isEmployee method to MessageToken_model
This commit is contained in:
Paolo
2017-03-30 17:44:43 +02:00
parent d08de4b22b
commit 559b1b4cdf
3 changed files with 63 additions and 7 deletions
@@ -153,10 +153,13 @@ class MessageToken_model extends CI_Model
p.anrede,
p.titelpost,
p.titelpre,
p.vornamen
p.vornamen,
m.mitarbeiter_uid
FROM public.tbl_person p
LEFT JOIN public.tbl_benutzer b USING(person_id)
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
WHERE p.person_id = ?';
$result = $this->db->query($sql, array($person_id));
// If no errors occurred
@@ -169,4 +172,41 @@ class MessageToken_model extends CI_Model
return error($this->db->error());
}
}
/**
*
*/
public function isEmployee($person_id)
{
$sql = 'SELECT m.mitarbeiter_uid
FROM public.tbl_person p
LEFT JOIN public.tbl_benutzer b USING(person_id)
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
WHERE p.person_id = ?
AND b.aktiv = TRUE';
$result = $this->db->query($sql, array($person_id));
// If no errors occurred
if ($result)
{
// If data are present
if (is_array($result->result()) && count($result->result()) > 0)
{
$person = $result->result()[0];
// If it is an employee
if ($person->mitarbeiter_uid != null)
{
return true;
}
}
return false;
}
else
{
return error($this->db->error());
}
}
}