more mod cleanups

This commit is contained in:
mike 2012-10-22 19:18:50 +11:00
parent 8f9ddcb536
commit 56b95d50ed
2 changed files with 13 additions and 9 deletions

View file

@ -7,7 +7,7 @@ function pretheme_init(&$a) {
$info = get_theme_info($theme); $info = get_theme_info($theme);
if($info) { if($info) {
// unfortunately there will be no translation for this string // unfortunately there will be no translation for this string
$desc = $info['description']; $desc = $info['description'];
$version = $info['version']; $version = $info['version'];
$credits = $info['credits']; $credits = $info['credits'];
} }

View file

@ -12,24 +12,28 @@ function starred_init(&$a) {
if(! $message_id) if(! $message_id)
killme(); killme();
$r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", $r = q("SELECT item_flags FROM item WHERE uid = %d AND id = %d LIMIT 1",
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
if(! count($r)) if(! count($r))
killme(); killme();
if(! intval($r[0]['starred'])) $item_flags = $r[0]['item_flags'];
$starred = 1;
$r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d LIMIT 1", if($item_flags & ITEM_STARRED)
intval($starred), $item_flags -= ITEM_STARRED;
else
$item_flags = $item_flags | ITEM_STARRED;
$r = q("UPDATE item SET item_flags = %d WHERE uid = %d and id = %d LIMIT 1",
intval($item_flags),
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
// the json doesn't really matter, it will either be 0 or 1 header('Content-type: application/json');
echo json_encode(array('result' => intval($item_flags & ITEM_STARRED)));
echo json_encode($starred);
killme(); killme();
} }