]> git.mxchange.org Git - friendica.git/blobdiff - mod/like.php
Changed the tag search. This hopefully speeds it up on larger systems.
[friendica.git] / mod / like.php
index 8fe0cf7353b7169dabe2c9c00cfedd21fccc0ede..77fc0aec20361373effb60997c7f8f6f283630db 100755 (executable)
@@ -105,6 +105,10 @@ function like_content(&$a) {
        }
 
 
+       // See if we've been passed a return path to redirect to
+       $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+
+
        $r = q("SELECT * FROM `item` WHERE `verb` = '%s' AND `deleted` = 0 
                AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
                dbesc($activity),
@@ -117,7 +121,7 @@ function like_content(&$a) {
                $like_item = $r[0];
 
                // Already voted, undo it
-               $r = q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
+               $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
                        dbesc(datetime_convert()),
                        intval($like_item['id'])
                );
@@ -137,7 +141,9 @@ function like_content(&$a) {
 //             proc_run('php',"include/notifier.php","like","$post_id"); // $post_id isn't defined here!
                $like_item_id = $like_item['id'];
                proc_run('php',"include/notifier.php","like","$like_item_id");
-               return;
+
+               like_content_return($a->get_baseurl(), $return_path);
+               return; // NOTREACHED
        }
 
        $uri = item_new_uri($a->get_hostname(),$owner_uid);
@@ -221,11 +227,29 @@ EOT;
 
        proc_run('php',"include/notifier.php","like","$post_id");
 
-       killme();
+       like_content_return($a->get_baseurl(), $return_path);
+       killme(); // NOTREACHED
 //     return; // NOTREACHED
 }
 
 
+// Decide how to return. If we were called with a 'return' argument,
+// then redirect back to the calling page. If not, just quietly end
+
+function like_content_return($baseurl, $return_path) {
+
+       if($return_path) {
+               $rand = '_=' . time();
+               if(strpos($return_path, '?')) $rand = "&$rand";
+               else $rand = "?$rand";
+
+               goaway($baseurl . "/" . $return_path . $rand);
+       }
+
+       killme();
+}
+
+
 function store_diaspora_like_retract_sig($activity, $item, $like_item, $contact) {
        // Note that we can only create a signature for a user of the local server. We don't have
        // a key for remote users. That is ok, because if a remote user is "unlike"ing a post, it