messu-read_sent.php 2.46 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
rjsmelo's avatar
rjsmelo committed
6
//
7 8
// 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.
9
// $Id$
changi67's avatar
changi67 committed
10

11
$section = 'user_messages';
rjsmelo's avatar
rjsmelo committed
12
require_once('tiki-setup.php');
13
$messulib = TikiLib::lib('message');
14 15
$access->check_user($user);
$access->check_feature('feature_messages');
16
$access->check_permission('tiki_p_messages');
17

18
if ((! isset($_REQUEST['msgId']) || $_REQUEST['msgId'] == 0) && empty($_POST['msgdel'])) {
19 20 21 22 23 24
	$smarty->assign('legend', tra("No more messages"));
	$smarty->assign('mid', 'messu-read_sent.tpl');
	$smarty->display("tiki.tpl");
	die;
}

25 26 27 28 29 30
if (isset($_POST['action']) && $access->checkCsrf()) {
	$messulib->flag_message($user, $_POST['msgId'], $_POST['action'], $_POST['actionval'], 'sent');
}
if (isset($_POST['msgdel']) && $access->checkCsrfForm(tra('Delete sent message?'))) {
	$result = $messulib->delete_message($user, $_POST['msgdel'], 'sent');
	if ($result->numRows()) {
31
		Feedback::success(tr('Sent message deleted'));
32
	} else {
33
		Feedback::error(tr('Sent message not deleted'));
34
	}
35 36
	header('location: messu-sent.php');
	exit;
37
}
38

39 40 41 42 43 44 45
$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', '');
46

47 48
// Using the sort_mode, flag, flagval and find get the next and prev messages
$smarty->assign('msgId', $_REQUEST['msgId']);
changi67's avatar
changi67 committed
49 50
$next = $messulib->get_next_message($user, $_REQUEST['msgId'], $_REQUEST['sort_mode'], $_REQUEST['find'], $_REQUEST['flag'], $_REQUEST['flagval'], $_REQUEST['priority'], 'sent');
$prev = $messulib->get_prev_message($user, $_REQUEST['msgId'], $_REQUEST['sort_mode'], $_REQUEST['find'], $_REQUEST['flag'], $_REQUEST['flagval'], $_REQUEST['priority'], 'sent');
51 52
$smarty->assign('next', $next);
$smarty->assign('prev', $prev);
53 54
// Mark the message as read
$messulib->flag_message($user, $_REQUEST['msgId'], 'isRead', 'y', 'sent');
55 56 57
// Get the message and assign its data to template vars
$msg = $messulib->get_message($user, $_REQUEST['msgId'], 'sent');
$smarty->assign('msg', $msg);
rjsmelo's avatar
rjsmelo committed
58 59
include_once('tiki-section_options.php');
include_once('tiki-mytiki_shared.php');
60 61
$smarty->assign('mid', 'messu-read_sent.tpl');
$smarty->display("tiki.tpl");