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