From 35bb7816af1c4239b779ba195a4c351bcdee8425 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 31 Dec 2014 18:08:11 +0100 Subject: [PATCH] api: favorite create/destroy update also thread table --- include/api.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/api.php b/include/api.php index bacbd65338..e5711914fe 100644 --- a/include/api.php +++ b/include/api.php @@ -1590,7 +1590,6 @@ } else { $itemid = intval($_REQUEST['id']); } - if ($action!="create" && $action!="destroy") die(api_error($a, $type, t("Invalid action. ".$action))); $item = q("SELECT * FROM item WHERE id=%d AND uid=%d", $itemid, api_user()); @@ -1599,16 +1598,19 @@ switch($action){ case "create": - $r = q("UPDATE item SET starred=1 WHERE id=%d AND uid=%d", - $itemid, api_user()); $item[0]['starred']=1; break; case "destroy": - $r = q("UPDATE item SET starred=0 WHERE id=%d AND uid=%d", - $itemid, api_user()); $item[0]['starred']=0; break; + default: + die(api_error($a, $type, t("Invalid action. ".$action))); } + $r = q("UPDATE item SET starred=%d WHERE id=%d AND uid=%d", + $item[0]['starred'], $itemid, api_user()); + + q("UPDATE thread SET starred=%d WHERE iid=%d AND uid=%d", + $item[0]['starred'], $itemid, api_user()); if ($r===false) die(api_error($a, $type, t("DB error"))); @@ -1623,7 +1625,7 @@ $data = api_rss_extra($a, $data, $user_info); } - return api_apply_template("status", $type, $data); + return api_apply_template("status", $type, $data); } api_register_func('api/favorites/create', 'api_favorites_create_destroy', true); -- 2.39.5