freenetis-github/application/controllers/mail.php @ 53cf4ce8
8baed187 | Michal Kliment | <?php defined('SYSPATH') or die('No direct script access.');
|
|
/*
|
|||
* This file is part of open source system FreenetIS
|
|||
* and it is released under GPLv3 licence.
|
|||
*
|
|||
* More info about licence can be found:
|
|||
* http://www.gnu.org/licenses/gpl-3.0.html
|
|||
*
|
|||
* More info about project can be found:
|
|||
* http://www.freenetis.org/
|
|||
*
|
|||
*/
|
|||
/**
|
|||
* Controller for mail messages.
|
|||
* Mail messages are inner system for communication between users and system.
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @package Controller
|
|||
*/
|
|||
class Mail_Controller extends Mail_messages_Controller
|
|||
{
|
|||
/**
|
|||
* Mail sections, for rendering menu
|
|||
*
|
|||
* @var array[string]
|
|||
*/
|
|||
public static $sections = array
|
|||
(
|
|||
'mail/inbox' => 'Mail inbox',
|
|||
'mail/sent' => 'Mail sent',
|
|||
'mail/write_message' => 'Write new message'
|
|||
);
|
|||
/**
|
|||
* index redirects to inbox
|
|||
*/
|
|||
public function index()
|
|||
{
|
|||
url::redirect('mail/inbox');
|
|||
}
|
|||
/**
|
|||
* Function to get all inbox messages of user
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param number $limit_results
|
|||
* @param string $page_word
|
|||
* @param number $page
|
|||
*/
|
|||
public function inbox($limit_results = 10, $page_word = null, $page = 1)
|
|||
{
|
|||
$mail_message_model = new Mail_message_Model();
|
|||
$total_messages = $mail_message_model->count_all_inbox_messages_by_user_id(
|
|||
c1bdc1c4 | Michal Kliment | $this->user_id
|
|
8baed187 | Michal Kliment | );
|
|
c1bdc1c4 | Michal Kliment | if (is_numeric($this->input->post('record_per_page')))
|
|
{
|
|||
$limit_results = (int) $this->input->post('record_per_page');
|
|||
}
|
|||
8baed187 | Michal Kliment | if (($sql_offset = ($page - 1) * $limit_results) > $total_messages)
|
|
c1bdc1c4 | Michal Kliment | {
|
|
8baed187 | Michal Kliment | $sql_offset = 0;
|
|
c1bdc1c4 | Michal Kliment | }
|
|
8baed187 | Michal Kliment | ||
// finds all user's inbox messages
|
|||
$messages = $mail_message_model->get_all_inbox_messages_by_user_id(
|
|||
c1bdc1c4 | Michal Kliment | $this->user_id, $sql_offset, (int) $limit_results
|
|
8baed187 | Michal Kliment | );
|
|
// finds ids of all messages - for javascript mark-all function
|
|||
$arr_ids = array();
|
|||
foreach ($messages as $message)
|
|||
{
|
|||
$arr_ids[] = $message->id;
|
|||
}
|
|||
c1bdc1c4 | Michal Kliment | ||
// mail redirection
|
|||
if (Settings::get('email_enabled') && $this->acl_check_edit(
|
|||
'Users_Controller', 'additional_contacts', $this->member_id
|
|||
))
|
|||
{
|
|||
$uc_model = new Users_contacts_Model();
|
|||
$email_redirections = $uc_model->get_redirected_email_boxes_of($this->user_id);
|
|||
$contacts_link = html::anchor('/contacts/show_by_user/' . $this->user_id, __('here'));
|
|||
if (count($email_redirections))
|
|||
{
|
|||
$emails = '';
|
|||
foreach ($email_redirections as $e)
|
|||
{
|
|||
$emails .= $e->value . ', ';
|
|||
}
|
|||
status::minfo('Your inner mail is redirected to your following e-mail '
|
|||
. 'addresses %s you can disable this %s.', TRUE,
|
|||
array(substr($emails, 0, -2), $contacts_link));
|
|||
}
|
|||
else
|
|||
{
|
|||
status::minfo('You can redirect your inner mail to your e-mail box '
|
|||
. 'by editing your e-mail %s.', TRUE, array($contacts_link));
|
|||
}
|
|||
}
|
|||
8baed187 | Michal Kliment | ||
// create grid
|
|||
$grid = new Grid('mail/inbox', '', array
|
|||
(
|
|||
'use_paginator' => true,
|
|||
c1bdc1c4 | Michal Kliment | 'use_selector' => true,
|
|
8baed187 | Michal Kliment | 'total_items' => $total_messages,
|
|
'current' => $limit_results,
|
|||
'base_url' => Config::get('lang') . '/mail/inbox/'
|
|||
. $limit_results,
|
|||
'uri_segment' => 'page',
|
|||
'items_per_page' => $limit_results,
|
|||
'style' => 'classic',
|
|||
'limit_results' => $limit_results,
|
|||
));
|
|||
c1bdc1c4 | Michal Kliment | ||
$grid->add_new_button(
|
|||
'mail/mark_inbox_read', 'Mark all messages as read'
|
|||
);
|
|||
8baed187 | Michal Kliment | $grid->form_field('delete')
|
|
->order(false)
|
|||
->type('checkbox');
|
|||
$grid->callback_field('from_id')
|
|||
->label(__('From'))
|
|||
->class('grid_mail_from')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::from_field');
|
|||
$grid->callback_field('subject')
|
|||
->label(__('Subject'))
|
|||
->class('grid_mail_subject')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::subject_field');
|
|||
$grid->callback_field('time')
|
|||
->label(__('Time'))
|
|||
->class('grid_mail_time')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::time_field');
|
|||
$grid->grouped_action_field()
|
|||
->add_action()
|
|||
->icon_action('delete')
|
|||
->url('mail/delete_message')
|
|||
->class('delete_link');
|
|||
// adds extra buttons for messages administration
|
|||
$grid->form_extra_buttons = array
|
|||
(
|
|||
form::checkbox(
|
|||
'mark_all','on', False,
|
|||
'onclick="mark_all_checkboxs(\'delete\', new Array(\''.
|
|||
implode('\',\'',$arr_ids).'\'))"'
|
|||
).form::label(
|
|||
'mark_all', __('Mark all'),
|
|||
'class="mark_all_label"'
|
|||
),
|
|||
form::dropdown('operation', array
|
|||
(
|
|||
'delete' => __('Delete selected messages'),
|
|||
'read' => __('Mark selected messages as read'),
|
|||
'unread' => __('Mark selected messages as unread')
|
|||
))
|
|||
);
|
|||
c1bdc1c4 | Michal Kliment | ||
$grid->form_submit_value = __('Perform');
|
|||
8baed187 | Michal Kliment | $grid->datasource($messages);
|
|
// form is post
|
|||
c1bdc1c4 | Michal Kliment | if ($_POST && count($_POST) && isset($_POST['operation']))
|
|
8baed187 | Michal Kliment | {
|
|
$operation = $_POST['operation'];
|
|||
$user_id = $this->session->get('user_id');
|
|||
$mail_message_model = new Mail_message_Model();
|
|||
// for each checked messages
|
|||
c1bdc1c4 | Michal Kliment | if (isset($_POST['delete']) && is_array($_POST['delete']))
|
|
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | foreach ($_POST['delete'] as $message_id => $true)
|
|
{
|
|||
$message = $mail_message_model->where('id', $message_id)->find();
|
|||
8baed187 | Michal Kliment | ||
c1bdc1c4 | Michal Kliment | // message doesn't exist
|
|
if (!$message->id)
|
|||
continue;
|
|||
8baed187 | Michal Kliment | ||
c1bdc1c4 | Michal Kliment | // deletes message
|
|
if ($operation == 'delete')
|
|||
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | // check if message is really from user inbox
|
|
if ($message->to_id == $user_id)
|
|||
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | if ($message->from_deleted || $message->from_id == $user_id)
|
|
$message->delete();
|
|||
else
|
|||
{
|
|||
$message->to_deleted = 1;
|
|||
$message->readed = 1;
|
|||
$message->save();
|
|||
}
|
|||
8baed187 | Michal Kliment | }
|
|
}
|
|||
c1bdc1c4 | Michal Kliment | // marks as read
|
|
else if ($operation == 'read')
|
|||
{
|
|||
$message->readed = 1;
|
|||
$message->save();
|
|||
}
|
|||
// marks as unread
|
|||
else if ($operation == 'unread')
|
|||
{
|
|||
$message->readed = 0;
|
|||
$message->save();
|
|||
}
|
|||
8baed187 | Michal Kliment | }
|
|
}
|
|||
url::redirect(url::base(TRUE).url::current(TRUE));
|
|||
}
|
|||
$view = new View('main');
|
|||
$view->title = __('Mail inbox');
|
|||
$view->content = new View('mail/main');
|
|||
$view->content->title = __('Mail inbox');
|
|||
$view->content->content = $grid;
|
|||
$view->render(TRUE);
|
|||
}
|
|||
/**
|
|||
* Function to get all inbox messages of user
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param number $limit_results
|
|||
* @param string $page_word
|
|||
* @param number $page
|
|||
*/
|
|||
public function sent($limit_results = 10, $page_word = null, $page = 1)
|
|||
{
|
|||
$mail_message_model = new Mail_message_Model();
|
|||
$total_messages = $mail_message_model->count_all_sent_messages_by_user_id(
|
|||
$this->session->get('user_id')
|
|||
);
|
|||
c1bdc1c4 | Michal Kliment | if (is_numeric($this->input->post('record_per_page')))
|
|
{
|
|||
$limit_results = (int) $this->input->post('record_per_page');
|
|||
}
|
|||
8baed187 | Michal Kliment | if (($sql_offset = ($page - 1) * $limit_results) > $total_messages)
|
|
c1bdc1c4 | Michal Kliment | {
|
|
8baed187 | Michal Kliment | $sql_offset = 0;
|
|
c1bdc1c4 | Michal Kliment | }
|
|
8baed187 | Michal Kliment | ||
// finds all user's sent messages
|
|||
$messages = $mail_message_model->get_all_sent_messages_by_user_id(
|
|||
$this->session->get('user_id'), $sql_offset, (int) $limit_results
|
|||
);
|
|||
// finds ids of all messages - for javascript mark-all function
|
|||
$arr_ids = array();
|
|||
foreach ($messages as $message)
|
|||
{
|
|||
$arr_ids[] = $message->id;
|
|||
}
|
|||
// create grid
|
|||
$grid = new Grid('mail/sent', '', array
|
|||
(
|
|||
'use_paginator' => true,
|
|||
c1bdc1c4 | Michal Kliment | 'use_selector' => true,
|
|
8baed187 | Michal Kliment | 'total_items' => $total_messages,
|
|
'current' => $limit_results,
|
|||
'base_url' => Config::get('lang').'/mail/sent/'
|
|||
. $limit_results,
|
|||
'uri_segment' => 'page',
|
|||
'items_per_page' => $limit_results,
|
|||
'style' => 'classic',
|
|||
'limit_results' => $limit_results,
|
|||
));
|
|||
$grid->form_field('delete')
|
|||
->order(false)
|
|||
->type('checkbox');
|
|||
$grid->callback_field('to_id')
|
|||
->label(__('To'))
|
|||
->class('grid_mail_to')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::to_field');
|
|||
$grid->callback_field('subject')
|
|||
->class('grid_mail_subject')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::subject_field');
|
|||
$grid->callback_field('time')
|
|||
->class('grid_mail_time')
|
|||
->order(false)
|
|||
->callback('Mail_Controller::time_field');
|
|||
$grid->grouped_action_field()
|
|||
->add_action()
|
|||
->icon_action('delete')
|
|||
->url('mail/delete_message')
|
|||
->class('delete_link');
|
|||
// adds extra buttons for messages administration
|
|||
$grid->form_extra_buttons = array(
|
|||
form::checkbox(
|
|||
'mark_all','on', False,
|
|||
'onclick="mark_all_checkboxs(\'delete\', new Array(\''.
|
|||
implode('\',\'',$arr_ids).'\'))"'
|
|||
) . form::label(
|
|||
'mark_all', __('Mark all'),
|
|||
'class="mark_all_label"'
|
|||
),
|
|||
form::dropdown('operation', array
|
|||
(
|
|||
'delete' => __('Delete selected messages')
|
|||
))
|
|||
);
|
|||
$grid->form_submit_value = __('Submit');
|
|||
$grid->datasource($messages);
|
|||
// form is post
|
|||
c1bdc1c4 | Michal Kliment | if ($_POST && count($_POST) && isset($_POST['operation']))
|
|
8baed187 | Michal Kliment | {
|
|
$operation = $_POST['operation'];
|
|||
$user_id = $this->session->get('user_id');
|
|||
$mail_message_model = new Mail_message_Model();
|
|||
// for each checked messages
|
|||
c1bdc1c4 | Michal Kliment | if (isset($_POST['delete']) && is_array($_POST['delete']))
|
|
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | foreach ($_POST['delete'] as $message_id => $true)
|
|
{
|
|||
$message = $mail_message_model->where('id', $message_id)->find();
|
|||
8baed187 | Michal Kliment | ||
c1bdc1c4 | Michal Kliment | // message doesn't exist
|
|
if (!$message->id)
|
|||
continue;
|
|||
8baed187 | Michal Kliment | ||
c1bdc1c4 | Michal Kliment | // deletes message
|
|
if ($operation == 'delete')
|
|||
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | // check if message is really from user inbox
|
|
if ($message->from_id == $user_id)
|
|||
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | if ($message->to_deleted || $message->to_id == $user_id)
|
|
$message->delete();
|
|||
else
|
|||
{
|
|||
$message->from_deleted = 1;
|
|||
$message->save();
|
|||
}
|
|||
8baed187 | Michal Kliment | }
|
|
}
|
|||
}
|
|||
}
|
|||
url::redirect(url::base(TRUE).url::current(TRUE));
|
|||
}
|
|||
$view = new View('main');
|
|||
$view->title = __('Mail sent');
|
|||
$view->content = new View('mail/main');
|
|||
$view->content->title = __('Mail sent');
|
|||
$view->content->content = $grid;
|
|||
$view->render(TRUE);
|
|||
}
|
|||
/**
|
|||
* Function to get message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param number $message_id
|
|||
*/
|
|||
public function show_message($message_id = NULL)
|
|||
{
|
|||
// bad parameter
|
|||
if (!$message_id || !is_numeric($message_id))
|
|||
Controller::warning(PARAMETER);
|
|||
$message = new Mail_message_Model($message_id);
|
|||
// message doen't exist
|
|||
if (!$message->id)
|
|||
Controller::error(RECORD);
|
|||
$user_id = $this->session->get('user_id');
|
|||
// access control
|
|||
if ($message->from_id != $user_id && $message->to_id != $user_id)
|
|||
Controller::error(ACCESS);
|
|||
$from_user = NULL;
|
|||
$to_user = NULL;
|
|||
$current = NULL;
|
|||
// message is not from user
|
|||
if ($message->from_id != $user_id)
|
|||
$from_user = new User_Model($message->from_id);
|
|||
else
|
|||
// message is un user's sent messages
|
|||
$current = 'mail/sent';
|
|||
// message is not to user
|
|||
if ($message->to_id != $user_id)
|
|||
$to_user = new User_Model($message->to_id);
|
|||
// message is un user's inbox messages
|
|||
else
|
|||
{
|
|||
$current = 'mail/inbox';
|
|||
// marks message as read
|
|||
$message->readed = 1;
|
|||
$message->save();
|
|||
}
|
|||
$view = new View('main');
|
|||
$view->title = __('Show mail message');
|
|||
$view->content = new View('mail/main');
|
|||
$view->content->current = $current;
|
|||
$view->content->title = __('Show mail message');
|
|||
$view->content->content = new View('mail/show');
|
|||
$view->content->content->message = $message;
|
|||
$view->content->content->from_user = $from_user;
|
|||
$view->content->content->to_user = $to_user;
|
|||
$view->render(TRUE);
|
|||
}
|
|||
/**
|
|||
* Function to write message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param number $to_id
|
|||
* @param number $origin_id
|
|||
*/
|
|||
public function write_message($to_id = NULL, $origin_id = NULL)
|
|||
{
|
|||
$to_value = '';
|
|||
$subject_value = '';
|
|||
$body_value = '';
|
|||
// this is reply
|
|||
if ($origin_id)
|
|||
{
|
|||
// bad parameter
|
|||
if (!is_numeric($origin_id))
|
|||
Controller::warning(PARAMETER);
|
|||
$origin = new Mail_message_Model($origin_id);
|
|||
// message doesn't exist
|
|||
c1bdc1c4 | Michal Kliment | if (!$origin->id || $origin->from_id == User_Model::ASSOCIATION)
|
|
8baed187 | Michal Kliment | Controller::error(RECORD);
|
|
// message is not from user
|
|||
if ($origin->from_id != $this->session->get('user_id'))
|
|||
c1bdc1c4 | Michal Kliment | {
|
|
$prev_user = $to_user = new User_Model($origin->from_id);
|
|||
}
|
|||
8baed187 | Michal Kliment | else
|
|
c1bdc1c4 | Michal Kliment | { // user will reply to recipient, not to himself :-)
|
|
8baed187 | Michal Kliment | $to_user = new User_Model($origin->to_id);
|
|
c1bdc1c4 | Michal Kliment | $prev_user = $to_user = new User_Model($origin->from_id);
|
|
}
|
|||
8baed187 | Michal Kliment | ||
// record doesn't exist
|
|||
if (!$to_user->id)
|
|||
Controller::error(RECORD);
|
|||
$to_value = $to_user->login;
|
|||
$subject_value = 'Re: '.$origin->subject;
|
|||
c1bdc1c4 | Michal Kliment | $body_value = '<p></p><p>'.$prev_user->name.' '.$prev_user->surname.' '
|
|
8baed187 | Michal Kliment | . __('wrote on').' '.date::pretty($origin->time).', '
|
|
. __('at').' '.date::pretty_time($origin->time)
|
|||
. ':</p> <i>'.$origin->body.'</i>';
|
|||
}
|
|||
// this is message to user
|
|||
else if ($to_id)
|
|||
{
|
|||
// bad parameter
|
|||
if (!is_numeric($to_id))
|
|||
Controller::warning(PARAMETER);
|
|||
$to_user = new User_Model($to_id);
|
|||
// record doesn't exist
|
|||
if (!$to_user->id)
|
|||
Controller::error(RECORD);
|
|||
$to_value = $to_user->login;
|
|||
}
|
|||
$form = new Forge(url::base(TRUE).url::current(TRUE));
|
|||
$form->input('to')
|
|||
c1bdc1c4 | Michal Kliment | ->class('mail_to_field autocomplete')
|
|
8baed187 | Michal Kliment | ->rules('required')
|
|
->value($to_value)
|
|||
->callback(array($this, 'valid_to_field'))
|
|||
->help(help::hint('mail_to_field'));
|
|||
$form->input('subject')
|
|||
->class('mail_subject_field')
|
|||
->rules('required|length[1,150]')
|
|||
->value($subject_value);
|
|||
$form->html_textarea('body')
|
|||
->label(__('Text').':')
|
|||
->rules('required')
|
|||
->value($body_value);
|
|||
c1bdc1c4 | Michal Kliment | $form->submit('Send');
|
|
8baed187 | Michal Kliment | ||
// form is validate
|
|||
if ($form->validate())
|
|||
{
|
|||
$form_data = $form->as_array(FALSE);
|
|||
c1bdc1c4 | Michal Kliment | $recipients = explode(',', trim(trim($form_data['to']), ','));
|
|
8baed187 | Michal Kliment | $user_model = new User_Model();
|
|
c1bdc1c4 | Michal Kliment | ||
try
|
|||
8baed187 | Michal Kliment | {
|
|
c1bdc1c4 | Michal Kliment | $user_model->transaction_start();
|
|
// sends message fo each recipients
|
|||
foreach ($recipients as $recipient)
|
|||
{
|
|||
$user = $user_model->where('login',trim($recipient))->find();
|
|||
Mail_message_Model::create(
|
|||
$this->user_id, $user->id,
|
|||
htmlspecialchars($form_data['subject']),
|
|||
$form_data['body']
|
|||
);
|
|||
}
|
|||
$user_model->transaction_commit();
|
|||
status::success('Message has been successfully sent.');
|
|||
url::redirect('mail/sent');
|
|||
}
|
|||
catch (Exception $e)
|
|||
{
|
|||
$user_model->transaction_rollback();
|
|||
status::error('Message has not been sent.', $e);
|
|||
Log::add_exception($e);
|
|||
8baed187 | Michal Kliment | }
|
|
}
|
|||
c1bdc1c4 | Michal Kliment | ||
8baed187 | Michal Kliment | $view = new View('main');
|
|
$view->title = __('Write new message');
|
|||
$view->content = new View('mail/main');
|
|||
$view->content->title = __('Write new message');
|
|||
$view->content->content = $form->html();
|
|||
$view->render(TRUE);
|
|||
}
|
|||
/**
|
|||
* Function to delete message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param number $message_id
|
|||
*/
|
|||
public function delete_message($message_id = NULL)
|
|||
{
|
|||
// bad parameter
|
|||
if (!$message_id)
|
|||
Controller::warning(PARAMETER);
|
|||
$message = new Mail_message_Model($message_id);
|
|||
// record does't exist
|
|||
if (!$message->id)
|
|||
Controller::error(RECORD);
|
|||
$user_id = $this->session->get('user_id');
|
|||
// access control
|
|||
if ($message->from_id != $user_id && $message->to_id != $user_id)
|
|||
Controller::error(ACCESS);
|
|||
// user is recipient
|
|||
if ($message->to_id == $user_id)
|
|||
{
|
|||
if ($message->from_deleted || $message->from_id == $user_id)
|
|||
$message->delete();
|
|||
else
|
|||
{
|
|||
$message->to_deleted = 1;
|
|||
$message->save();
|
|||
}
|
|||
status::success('Message has been successfully deleted.');
|
|||
url::redirect('mail/inbox');
|
|||
}
|
|||
// user is sender
|
|||
else if ($message->from_id == $user_id)
|
|||
{
|
|||
if ($message->to_deleted || $message->to_id == $user_id)
|
|||
$message->delete();
|
|||
else
|
|||
{
|
|||
$message->from_deleted = 1;
|
|||
$message->save();
|
|||
}
|
|||
status::success('Message has been successfully deleted.');
|
|||
url::redirect('mail/sent');
|
|||
}
|
|||
}
|
|||
c1bdc1c4 | Michal Kliment | ||
/**
|
|||
* Function to mark all messages as read
|
|||
*/
|
|||
public function mark_inbox_read()
|
|||
{
|
|||
$user_id = $this->session->get('user_id');
|
|||
$mail_message_model = new Mail_message_Model();
|
|||
$mail_message_model->mark_all_inbox_messages_as_read_by_user_id($user_id);
|
|||
$this->redirect('mail/inbox');
|
|||
}
|
|||
8baed187 | Michal Kliment | ||
/* ********************* CALLBACK FUNCTION ********************************/
|
|||
/**
|
|||
* Callback function to return sender as link, marks unread message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param object $item
|
|||
* @param string $name
|
|||
*/
|
|||
protected static function from_field($item, $name)
|
|||
{
|
|||
if (!$item->readed) echo '<b>';
|
|||
c1bdc1c4 | Michal Kliment | $user_name = $item->user_name;
|
|
if ($item->from_id == Member_Model::ASSOCIATION)
|
|||
{
|
|||
$user_name = __('System message');
|
|||
}
|
|||
8baed187 | Michal Kliment | // access conntrol
|
|
if (Controller::instance()->acl_check_view(
|
|||
'Users_Controller', 'users', $item->member_id
|
|||
))
|
|||
{
|
|||
c1bdc1c4 | Michal Kliment | echo html::anchor('users/show/'.$item->from_id, $user_name, array
|
|
8baed187 | Michal Kliment | (
|
|
'title' => __('Show user')
|
|||
));
|
|||
}
|
|||
else
|
|||
{
|
|||
c1bdc1c4 | Michal Kliment | echo $user_name;
|
|
8baed187 | Michal Kliment | }
|
|
if (!$item->readed) echo '</b>';
|
|||
}
|
|||
/**
|
|||
* Callback function to return recipient as link, marks unread message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param object $item
|
|||
* @param string $name
|
|||
*/
|
|||
protected static function to_field($item, $name)
|
|||
{
|
|||
if (!$item->readed) echo '<b>';
|
|||
// access conntrol
|
|||
if (Controller::instance()->acl_check_view(
|
|||
'Users_Controller', 'users', $item->member_id
|
|||
))
|
|||
{
|
|||
echo html::anchor('users/show/' . $item->to_id, $item->user_name, array
|
|||
(
|
|||
'title' => __('Show user')
|
|||
));
|
|||
}
|
|||
else
|
|||
{
|
|||
echo $item->user_name;
|
|||
}
|
|||
if (!$item->readed) echo '</b>';
|
|||
}
|
|||
/**
|
|||
* Callback function to return subject as link, marks unread message
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param object $item
|
|||
* @param string $name
|
|||
*/
|
|||
protected static function subject_field($item, $name)
|
|||
{
|
|||
$subject = $item->subject;
|
|||
if (mail_message::is_formated($subject))
|
|||
{
|
|||
$subject = mail_message::printf($subject);
|
|||
}
|
|||
if (!$item->readed) echo '<b>';
|
|||
{
|
|||
echo html::anchor('mail/show_message/'.$item->id, $subject, array
|
|||
(
|
|||
'title' => __('Read message')
|
|||
));
|
|||
}
|
|||
if (!$item->readed)
|
|||
echo '</b> ('.strtolower(__('unread')).')';
|
|||
}
|
|||
/**
|
|||
* Callback function to return time in human format (Google style)
|
|||
*
|
|||
* @author Michal Kliment
|
|||
* @param object $item
|
|||
* @param string $name
|
|||
*/
|
|||
protected static function time_field($item, $name)
|
|||
{
|
|||
if (!$item->readed)
|
|||
echo '<b>';
|
|||
echo date::mail_time($item->time);
|
|||
if (!$item->readed)
|
|||
echo '</b>';
|
|||
}
|
|||
}
|