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