Also the data of the message sender are not taken anymore via
the Person_model, but via the MessageToken_model, to avoid that
the login will be prompted
This commit is contained in:
Paolo
2017-03-30 16:43:35 +02:00
3 changed files with 69 additions and 19 deletions
+14 -5
View File
@@ -14,6 +14,10 @@
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* NOTE: in this controller is not possible to include/call everything
* that automatically call the authentication system, like the most of models or libraries
*/
class ViewMessage extends CI_Controller
{
/**
@@ -22,11 +26,11 @@ class ViewMessage extends CI_Controller
public function __construct()
{
parent::__construct();
// Loading config file message
$this->config->load('message');
// Load model MessageToken_model
// Load model MessageToken_model, not calling the authentication system
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
}
@@ -37,12 +41,12 @@ class ViewMessage extends CI_Controller
public function toHTML($token)
{
$msg = $this->MessageTokenModel->getMessageByToken($token);
if ($msg->error)
{
show_error($msg->retval);
}
if (is_array($msg->retval) && count($msg->retval) > 0)
{
$setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token);
@@ -52,7 +56,12 @@ class ViewMessage extends CI_Controller
show_error($msg->$setReadMessageStatusByToken);
}
$sender_id = $msg->retval[0]->sender_id;
$sender = $this->MessageTokenModel->getSenderData($sender_id);
$data = array (
'sender_id' => $sender_id,
'sender' => $sender->retval[0],
'message' => $msg->retval[0],
'href' => APP_ROOT . $this->config->item('redirect_view_message_url') . $token
);
+34 -5
View File
@@ -12,17 +12,17 @@ class MessageToken_model extends CI_Model
public function __construct()
{
parent::__construct();
// Loads config file message
$this->config->load('message');
// Load return message helper
$this->load->helper('message');
// Loads the database object
$this->load->database();
}
/**
* Get a received message identified by token
*/
@@ -45,7 +45,7 @@ class MessageToken_model extends CI_Model
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.token = ?
LIMIT 1';
$result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token));
// If no errors occurred
@@ -139,5 +139,34 @@ class MessageToken_model extends CI_Model
{
return error($this->db->error());
}
return success($result->result());
}
/**
* Get data of the message sender
*/
public function getSenderData($person_id)
{
$sql = 'SELECT p.vorname,
p.nachname,
p.anrede,
p.titelpost,
p.titelpre,
p.vornamen
FROM public.tbl_person p
WHERE p.person_id = ?';
$result = $this->db->query($sql, array($person_id));
// If no errors occurred
if ($result)
{
return success($result->result());
}
else
{
return error($this->db->error());
}
}
}
+21 -9
View File
@@ -1,11 +1,23 @@
<?php $this->load->view("templates/header", array("title" => "Message viewer")); ?>
<body>
<table widht="70%">
<tr>
<center>
<br><br>
<table width="70%;" style="border: solid 1px gray; background-color:white; padding:5px;">
<tr style=''>
<td style="width: 80px;">
<b>From:</b>
</td>
<td>
Subject:
&nbsp;
</td>
<td>
<?php echo $sender->vorname.' '.$sender->nachname; ?>
</td>
</tr>
<tr>
<td style="width: 80px;">
<b>Subject:</b>
</td>
<td>
&nbsp;
@@ -16,7 +28,7 @@
</tr>
<tr>
<td>
Message:
<b>Message:</b>
</td>
<td>
&nbsp;
@@ -26,13 +38,13 @@
</td>
</tr>
<tr>
<td></td>
<td colspan="2" align="center">
<td colspan="3" align="center" style="background-color:#dddddd; padding:5px;">
<a href="<?php echo $href; ?>">Reply</a>
</td>
</tr>
</table>
</center>
</body>
<?php $this->load->view("templates/footer"); ?>
<?php $this->load->view("templates/footer"); ?>