]> git.mxchange.org Git - friendica.git/blob - mod/ignored.php
Merge pull request #2148 from annando/issue-1871
[friendica.git] / mod / ignored.php
1 <?php
2
3
4 function ignored_init(&$a) {
5
6         $ignored = 0;
7
8         if(! local_user())
9                 killme();
10         if($a->argc > 1)
11                 $message_id = intval($a->argv[1]);
12         if(! $message_id)
13                 killme();
14
15         $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
16                 intval(local_user()),
17                 intval($message_id)
18         );
19         if(! count($r))
20                 killme();
21
22         if(! intval($r[0]['ignored']))
23                 $ignored = 1;
24
25         $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
26                 intval($ignored),
27                 intval(local_user()),
28                 intval($message_id)
29         );
30
31         // See if we've been passed a return path to redirect to
32         $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
33         if($return_path) {
34                 $rand = '_=' . time();
35                 if(strpos($return_path, '?')) $rand = "&$rand";
36                 else $rand = "?$rand";
37
38                 goaway($a->get_baseurl() . "/" . $return_path . $rand);
39         }
40
41         // the json doesn't really matter, it will either be 0 or 1
42
43         echo json_encode($ignored);
44         killme();
45 }