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
|
<?php
function notifications_post(&$a) {
if(! local_channel()) {
goaway(z_root());
}
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
if($request_id === "all")
return;
if($request_id) {
$r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($request_id),
intval(local_channel())
);
if(count($r)) {
$intro_id = $r[0]['id'];
$contact_id = $r[0]['contact-id'];
}
else {
notice( t('Invalid request identifier.') . EOL);
return;
}
// If it is a friend suggestion, the contact is not a new friend but an existing friend
// that should not be deleted.
$fid = $r[0]['fid'];
if($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d",
intval($intro_id)
);
if(! $fid) {
// The check for blocked and pending is in case the friendship was already approved
// and we just want to get rid of the now pointless notification
$r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 AND `blocked` = 1 AND `pending` = 1",
intval($contact_id),
intval(local_channel())
);
}
goaway(z_root() . '/notifications/intros');
}
if($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id));
goaway(z_root() . '/notifications/intros');
}
}
}
function notifications_content(&$a) {
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
nav_set_selected('notifications');
$o = '';
$notif_tpl = get_markup_template('notifications.tpl');
$not_tpl = get_markup_template('notify.tpl');
require_once('include/bbcode.php');
$r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
intval(local_channel())
);
if (count($r) > 0) {
$notifications_available =1;
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
'$item_link' => z_root().'/notify/view/'. $it['id'],
'$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date'])
));
}
} else {
$notif_content .= t('No more system notifications.');
}
$o .= replace_macros($notif_tpl,array(
'$notif_header' => t('System Notifications'),
'$notif_link_mark_seen' => t('Mark all system notifications seen'),
'$notif_content' => $notif_content,
'$notifications_available' => $notifications_available,
));
return $o;
}
|