Files
FHC-Core/application/controllers/ViewMessage.php
T
Paolo a0eb6b0eba - Added method setReadMessageStatusByToken to MessageToken_model
- Now the method toHTML of the controller ViewMessage is calling also
the method setReadMessageStatusByToken of model MessageToken_model
2017-03-30 16:27:14 +02:00

63 lines
1.4 KiB
PHP

<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class ViewMessage extends CI_Controller
{
/**
* API constructor
*/
public function __construct()
{
parent::__construct();
// Loading config file message
$this->config->load('message');
// Load model MessageToken_model
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
}
/**
* Using the MessageTokenModel instead of MessageLib to allow
* viewing the message without prompting the login
*/
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);
if (isError($setReadMessageStatusByToken))
{
show_error($msg->$setReadMessageStatusByToken);
}
$data = array (
'message' => $msg->retval[0],
'href' => APP_ROOT . $this->config->item('redirect_view_message_url') . $token
);
$this->load->view('system/messageHTML.php', $data);
}
}
}