messu-read.php 2.73 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id$
changi67's avatar
changi67 committed
7

8
$section = 'user_messages';
9 10
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
11 12
$access->check_user($user);
$access->check_feature('feature_messages');
13
$access->check_permission('tiki_p_messages');
14
if (isset($_REQUEST["delete"])) {
15 16
	check_ticket('messu-read');
	$messulib->delete_message($user, $_REQUEST['msgdel']);
17
}
18 19 20 21 22 23 24 25
$smarty->assign('sort_mode', $_REQUEST['sort_mode']);
$smarty->assign('find', $_REQUEST['find']);
$smarty->assign('flag', $_REQUEST['flag']);
$smarty->assign('offset', $_REQUEST['offset']);
$smarty->assign('flagval', $_REQUEST['flagval']);
$smarty->assign('priority', $_REQUEST['priority']);
$smarty->assign('legend', '');
if (!isset($_REQUEST['msgId']) || $_REQUEST['msgId'] == 0) {
26 27 28 29 30
	$smarty->assign('unread', 0);
	$smarty->assign('legend', tra("No more messages"));
	$smarty->assign('mid', 'messu-read.tpl');
	$smarty->display("tiki.tpl");
	die;
31 32
}
if (isset($_REQUEST['action'])) {
33
	$messulib->flag_message($user, $_REQUEST['msgId'], $_REQUEST['action'], $_REQUEST['actionval']);
34 35
}
// Using the sort_mode, flag, flagval and find get the next and prev messages
36
$smarty->assign('msgId', $_REQUEST['msgId']);
changi67's avatar
changi67 committed
37 38
$next = $messulib->get_next_message($user, $_REQUEST['msgId'], $_REQUEST['sort_mode'], $_REQUEST['find'], $_REQUEST['flag'], $_REQUEST['flagval'], $_REQUEST['priority']);
$prev = $messulib->get_prev_message($user, $_REQUEST['msgId'], $_REQUEST['sort_mode'], $_REQUEST['find'], $_REQUEST['flag'], $_REQUEST['flagval'], $_REQUEST['priority']);
39 40
$smarty->assign('next', $next);
$smarty->assign('prev', $prev);
41
// Mark the message as read in the receivers mailbox
42
$messulib->flag_message($user, $_REQUEST['msgId'], 'isRead', 'y');
43
// Get the message and assign its data to template vars
44
$msg = $messulib->get_message($user, $_REQUEST['msgId']);
45
$smarty->assign('msg', $msg);
46
// which quote format should tiki use?
47 48
global $prefs;
if ($prefs['feature_use_quoteplugin'] == 'y') {
49
	$quote_format = 'fancy';
50
} else {
51
	$quote_format = 'simple';
52
}
changi67's avatar
changi67 committed
53
$smarty->assign('quote_format', $quote_format);
54
if ($messulib->get_user_preference($user, 'mess_sendReadStatus', 'n') == 'y') {
55 56
	// Mark the message as read in the senders sent box:
	$messulib->flag_message($msg['user_from'], $_REQUEST['msgId'], 'isRead', 'y', 'sent');
57
}
58
if ($prefs['feature_actionlog'] == 'y') {
59
	$logslib->add_action('Viewed', '', 'message');
60
}
61
ask_ticket('messu-read');
62 63 64
include_once ('tiki-section_options.php');
include_once ('tiki-mytiki_shared.php');
$smarty->assign('mid', 'messu-read.tpl');
65
$smarty->display("tiki.tpl");