1
0
Fork 0

Merge pull request #1271 from fabrixxm/api/favorites

api: favorite create/destroy update also thread table
This commit is contained in:
Tobias Diekershoff 2015-01-01 19:06:59 +01:00
commit 22ae03c1a3

View file

@ -1592,7 +1592,6 @@
} else { } else {
$itemid = intval($_REQUEST['id']); $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", $item = q("SELECT * FROM item WHERE id=%d AND uid=%d",
$itemid, api_user()); $itemid, api_user());
@ -1601,16 +1600,19 @@
switch($action){ switch($action){
case "create": case "create":
$r = q("UPDATE item SET starred=1 WHERE id=%d AND uid=%d",
$itemid, api_user());
$item[0]['starred']=1; $item[0]['starred']=1;
break; break;
case "destroy": case "destroy":
$r = q("UPDATE item SET starred=0 WHERE id=%d AND uid=%d",
$itemid, api_user());
$item[0]['starred']=0; $item[0]['starred']=0;
break; 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"))); if ($r===false) die(api_error($a, $type, t("DB error")));