4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
7 function starred_init(App $a) {
9 require_once("include/threads.php");
17 $message_id = intval($a->argv[1]);
23 $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
27 if (! DBM::is_result($r)) {
31 if (! intval($r[0]['starred'])) {
35 $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d",
41 update_thread($message_id);
43 // See if we've been passed a return path to redirect to
44 $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
46 $rand = '_=' . time();
47 if (strpos($return_path, '?')) {
53 goaway(System::baseUrl() . "/" . $return_path . $rand);
56 // the json doesn't really matter, it will either be 0 or 1
58 echo json_encode($starred);