mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
- 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:
@@ -57,12 +57,21 @@ class ViewMessage extends CI_Controller
|
||||
}
|
||||
|
||||
$sender_id = $msg->retval[0]->sender_id;
|
||||
$receiver_id = $msg->retval[0]->receiver_id;
|
||||
$sender = $this->MessageTokenModel->getSenderData($sender_id);
|
||||
|
||||
// To decide how to change the redirection
|
||||
$isEmployee = $this->MessageTokenModel->isEmployee($receiver_id);
|
||||
if (!is_bool($isEmployee) && isError($isEmployee))
|
||||
{
|
||||
show_error($isEmployee);
|
||||
}
|
||||
|
||||
$data = array (
|
||||
'sender_id' => $sender_id,
|
||||
'sender' => $sender->retval[0],
|
||||
'message' => $msg->retval[0],
|
||||
'isEmployee' => $isEmployee,
|
||||
'href' => APP_ROOT . $this->config->item('redirect_view_message_url') . $token
|
||||
);
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,18 @@
|
||||
<?php echo $message->body; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center" style="background-color:#dddddd; padding:5px;">
|
||||
<a href="<?php echo $href; ?>">Reply</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($isEmployee === false)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" align="center" style="background-color:#dddddd; padding:5px;">
|
||||
<a href="<?php echo $href; ?>">Reply</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user