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