summaryrefslogtreecommitdiff
path: root/cgi-bin/inbox
blob: 9760a549ab8422053a62b9292547b157d4e6ba58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/perl
#########################################
# inbox
# deal with inboxing, message display
#########################################

use localbucky;

$dbh = DBI->connect ($dsn);

our ($USER, $lastlog) = checkin();
logout() unless ($USER != -1);

if ( defined($input->{object_from_uri}) )
	{
	if ( $input->{object_from_uri} =~ /^[0-9]+$/ )
		{
		$input->{id} ||= $input->{object_from_uri};
		}
	else
		{
		$input->{box} ||= $input->{object_from_uri};
		}
	
	}
#$input->{id} ||= $input->{object_from_uri} if defined($input->{object_from_uri}) && ($input->{object_from_uri} =~ /^[0-9]+$/);
#$input->{box} ||= $input->{object_from_uri} if defined($input->{object_from_uri}) && (
if (exists($input->{id}))
	{
	# display message

	my $message = get_message($input->{id});
	my $bn = $b->{mbox};
	$bn =~ s/^$USER->{username}\.//;
	if ($message == -1)
		{ error("No such message!"); }
	if ($USER->{username} ne $message->{recipient} && $USER->{username} ne $message->{sender})
		{ error("You are not the recipient of this message."); }
	unflag_message($input->{id});
	my $header_args= {};
	$header_args->{'title'} = $message->{'subject'};	
	if ($message->{'body'} =~ /body bgcolor="?([#0-9a-fA-F]+)/)
		{
	  $header_args->{'color'} = $1;
		}

	header($header_args);
	menu();
	print "<br><br>";
	display_message($message);
	footer();
	}

elsif ($input->{c} eq "f")
	{
	# folder_management_form();
	}

else
	{
	my $box = exists($input->{box}) ? $input->{box} : "inbox";
	my $limit = exists($input->{limit}) ? int($input->{limit}) : 50;
	my $date = exists($input->{start}) ? int($input->{start}) : "now";

	header("your $box");
	menu();

	my $messages = get_messages("$USER->{username}.$box", $limit, $date);
	my $boxes = get_boxes($USER->{username});

	print qq!<center>!;

	print <<userbox;
<div class="bluebox" style="float: right;">
<b>message center</b>
<hr noshade color="$BUCKY_COLOR_HR">
<center>
<table border=0 cellspacing=2 width=100>
<tr><td align=left><small><b>Folders</b></small></td><td align=center><small>msgs</small></td></tr>
userbox

	foreach my $b (@$boxes)
		{
		my $count = $b->{mcount} || 0;
		my $bn = $b->{mbox};
		$bn =~ s/^$USER->{username}\.//;
		print qq!<tr><td align=left><small><a href="$BUCKY/inbox/$bn"><b>$bn</b></a></small></td>! .
			qq!<td align=center>!.hushnull($count, undef, 1).qq!</td></tr>!;
		}

	print <<userbox;
</table>
</center>
<hr noshade color="$BUCKY_COLOR_HR">
<small>
<a href="$BUCKY/message"><b>Compose New Mail</b></a>
</small>
<hr noshade color="$BUCKY_COLOR_HR">
<small>
need to find someone?<br>
<a href="$BUCKY/users"><u>check the userlist</u></a>
</small>
</div>
userbox

	print qq!<table width="100%" cellpadding=0 cellspacing=0 border=0><tr><td align=left valign=top>!;

	message_list($messages, $box);

	if (@$messages == $limit)
		{
		print qq!<div align="right"><big><br>!;
		$oldest = $messages->[-1]->{date};
		print qq(<a href="$BUCKY/inbox/$box&limit=$limit&start=$oldest">next <b>$limit</b> messages &gt;&gt;</a>);
		print qq!</big></div>\n!;
		}

	print qq!</td></tr></table>!;

	footer();
	}

$dbh->disconnect ();

print "Inbox: " . &report_time() . "\n" if $timer;