aboutsummaryrefslogtreecommitdiffstats
path: root/mod/message.php
blob: 7f3b6180a75b94f4f57abacb713545e69a27ce5a (plain) (blame)
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
<?php

require_once('include/acl_selectors.php');
require_once('include/message.php');
require_once('include/zot.php');
require_once("include/bbcode.php");
require_once('include/Contact.php');


function message_content(&$a) {

	$o = '';
	nav_set_selected('messages');

	if(! local_user()) {
		notice( t('Permission denied.') . EOL);
		return login();
	}

	$channel = $a->get_channel();
	head_set_icon($channel['xchan_photo_s']);

	$cipher = get_pconfig(local_user(),'system','default_cipher');
	if(! $cipher)
		$cipher = 'aes256';



	$tpl = get_markup_template('mail_head.tpl');
	$header = replace_macros($tpl, array(
		'$messages' => t('Messages'),
		'$tab_content' => $tab_content
	));

	if((argc() == 3) && (argv(1) === 'dropconv')) {
		if(! intval(argv(2)))
			return;
		$cmd = argv(1);
		$r = private_messages_drop(local_user(), argv(2), true);
		if($r)
			info( t('Conversation removed.') . EOL );
		goaway($a->get_baseurl(true) . '/message' );
	}
	if(argc() == 1) {

		// list messages

		$o .= $header;

		// private_messages_list() can do other more complicated stuff, for now keep it simple


		$r = private_messages_list(local_user(), '', $a->pager['start'], $a->pager['itemspage']);

		if(! $r) {
			info( t('No messages.') . EOL);
			return $o;
		}

		$tpl = get_markup_template('mail_list.tpl');
		foreach($r as $rr) {
			
			$o .= replace_macros($tpl, array(
				'$id'         => $rr['id'],
				'$from_name'  => $rr['from']['xchan_name'],
				'$from_url'   => chanlink_hash($rr['from_xchan']),
				'$from_photo' => $rr['from']['xchan_photo_s'],
				'$to_name'    => $rr['to']['xchan_name'],
				'$to_url'     => chanlink_hash($rr['to_xchan']),
				'$to_photo'   => $rr['to']['xchan_photo_s'],
				'$subject'    => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'),
				'$delete'     => t('Delete conversation'),
				'$body'       => smilies(bbcode($rr['body'])),
				'$date'       => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')),
				'$seen'       => $rr['seen']
			));
		}
		$o .= alt_pager($a,count($r));	
		return $o;
	}


}