messu-sent.php 4.5 KB
Newer Older
1
<?php
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
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: /cvsroot/tikiwiki/tiki/messu-sent.php,v 1.6 2007-10-12 07:55:23 nyloth Exp $
7
$section = 'user_messages';
8 9 10
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
if (!$user) {
11 12 13 14 15 16 17 18
	if ($prefs['feature_redirect_on_error'] == 'y') {
		header('location: ' . $prefs['tikiIndex']);
		die;
	} else {
		$smarty->assign('msg', tra("You are not logged in"));
		$smarty->display("error.tpl");
		die;
	}
19
}
20
if ($prefs['feature_messages'] != 'y') {
21 22 23 24 25 26 27 28
	if ($prefs['feature_redirect_on_error'] == 'y') {
		header('location: ' . $prefs['tikiIndex']);
		die;
	} else {
		$smarty->assign('msg', tra("This feature is disabled") . ": feature_messages");
		$smarty->display("error.tpl");
		die;
	}
29 30
}
if ($tiki_p_messages != 'y') {
31 32 33 34
	$smarty->assign('errortype', 401);
	$smarty->assign('msg', tra("Permission denied"));
	$smarty->display("error.tpl");
	die;
35 36 37 38
}
$maxRecords = $messulib->get_user_preference($user, 'maxRecords', 20);
// Delete messages if the delete button was pressed
if (isset($_REQUEST["delete"]) && isset($_REQUEST["msg"])) {
39 40 41 42
	check_ticket('messu-sent');
	foreach(array_keys($_REQUEST["msg"]) as $msg) {
		$messulib->delete_message($user, $msg, 'sent');
	}
43 44 45
}
// Archive messages if the archive button was pressed
if (isset($_REQUEST["archive"]) && isset($_REQUEST["msg"])) {
46 47 48 49 50 51 52 53 54 55 56
	check_ticket('messu-sent');
	$tmp = $messulib->count_messages($user, 'archive');
	foreach(array_keys($_REQUEST["msg"]) as $msg) {
		if (($prefs['messu_archive_size'] > 0) && ($tmp >= $prefs['messu_archive_size'])) {
			$smarty->assign('msg', tra("Archive is full. Delete some messages from archive first."));
			$smarty->display("error.tpl");
			die;
		}
		$messulib->archive_message($user, $msg, 'sent');
		$tmp++;
	}
57
}
58 59
// Download messages if the download button was pressed
if (isset($_REQUEST["download"])) {
60 61 62 63 64 65 66 67 68 69 70 71 72 73
	check_ticket('messu-sent');
	// if message ids are handed over, use them:
	if (isset($_REQUEST["msg"])) {
		foreach(array_keys($_REQUEST["msg"]) as $msg) {
			$tmp = $messulib->get_message($user, $msg, 'sent');
			$items[] = $tmp;
		}
	} else {
		$items = $messulib->get_messages($user, 'sent', '', '', '');
	}
	$smarty->assign_by_ref('items', $items);
	header("Content-Disposition: attachment; filename=tiki-msg-sent-" . time("U") . ".txt ");
	$smarty->display('messu-download.tpl', null, null, 'application/download');
	die;
74
}
75
if (isset($_REQUEST['filter'])) {
76 77 78 79 80
	if ($_REQUEST['flags'] != '') {
		$parts = explode('_', $_REQUEST['flags']);
		$_REQUEST['flag'] = $parts[0];
		$_REQUEST['flagval'] = $parts[1];
	}
81
}
changi67's avatar
changi67 committed
82 83 84
if (!isset($_REQUEST["priority"])) $_REQUEST["priority"] = '';
if (!isset($_REQUEST["flag"])) $_REQUEST["flag"] = '';
if (!isset($_REQUEST["flagval"])) $_REQUEST["flagval"] = '';
85
if (!isset($_REQUEST["sort_mode"])) {
86
	$sort_mode = 'date_desc';
87
} else {
88
	$sort_mode = $_REQUEST["sort_mode"];
89 90
}
if (!isset($_REQUEST["offset"])) {
91
	$offset = 0;
92
} else {
93
	$offset = $_REQUEST["offset"];
94 95
}
if (isset($_REQUEST["find"])) {
96
	$find = $_REQUEST["find"];
97
} else {
98
	$find = '';
99 100 101 102 103 104 105 106
}
$smarty->assign_by_ref('flag', $_REQUEST['flag']);
$smarty->assign_by_ref('priority', $_REQUEST['priority']);
$smarty->assign_by_ref('flagval', $_REQUEST['flagval']);
$smarty->assign_by_ref('offset', $offset);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$smarty->assign('find', $find);
// What are we paginating: items
changi67's avatar
changi67 committed
107
$items = $messulib->list_user_messages($user, $offset, $maxRecords, $sort_mode, $find, $_REQUEST["flag"], $_REQUEST["flagval"], $_REQUEST['priority'], 'sent');
108
$smarty->assign_by_ref('cant_pages', $items["cant"]);
109 110 111
$smarty->assign_by_ref('items', $items["data"]);
$cellsize = 200;
$percentage = 1;
changi67's avatar
changi67 committed
112
if ($prefs['messu_sent_size'] > 0) {
113 114 115 116 117 118 119 120
	$current_number = $messulib->count_messages($user, 'sent');
	$smarty->assign('messu_sent_number', $current_number);
	$smarty->assign('messu_sent_size', $prefs['messu_sent_size']);
	$percentage = ($current_number / $prefs['messu_sent_size']) * 100;
	$cellsize = round($percentage / 100 * 200);
	if ($current_number > $prefs['messu_sent_size']) $cellsize = 200;
	if ($cellsize < 1) $cellsize = 1;
	$percentage = round($percentage);
121 122 123 124 125 126 127 128
}
$smarty->assign('cellsize', $cellsize);
$smarty->assign('percentage', $percentage);
include_once ('tiki-section_options.php');
include_once ('tiki-mytiki_shared.php');
ask_ticket('messu-sent');
$smarty->assign('mid', 'messu-sent.tpl');
$smarty->display("tiki.tpl");