]> git.mxchange.org Git - friendica.git/blob - mod/like.php
Renamed System::redirect() to $a->redirect()
[friendica.git] / mod / like.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\System;
5 use Friendica\Model\Item;
6
7 require_once 'include/items.php';
8
9 function like_content(App $a) {
10         if (!local_user() && !remote_user()) {
11                 return false;
12         }
13
14
15         $verb = notags(trim($_GET['verb']));
16
17         if (!$verb) {
18                 $verb = 'like';
19         }
20
21         $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
22
23         $r = Item::performLike($item_id, $verb);
24         if (!$r) {
25                 return;
26         }
27
28         // See if we've been passed a return path to redirect to
29         $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
30
31         like_content_return($a, $return_path);
32         killme(); // NOTREACHED
33 }
34
35
36 // Decide how to return. If we were called with a 'return' argument,
37 // then redirect back to the calling page. If not, just quietly end
38
39 function like_content_return(App $a, $return_path) {
40         if ($return_path) {
41                 $rand = '_=' . time();
42                 if (strpos($return_path, '?')) {
43                         $rand = "&$rand";
44                 } else {
45                         $rand = "?$rand";
46                 }
47
48                 $a->redirect($return_path . $rand);
49         }
50
51         killme();
52 }