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