if ($response['auth']) { $item_ids = Database::getInstance('db')->table('items')->eq('bookmark', 1)->findAllByColumn('rowid'); $response['saved_item_ids'] = implode(',', $item_ids); } response($response); }); // handle write items route('write_items', function () { $response = auth(); if ($response['auth']) { $query = Database::getInstance('db')->table('items')->eq('rowid', $_POST['id']); if ($_POST['as'] === 'saved') { $query->update(array('bookmark' => 1)); // Send bookmark to third-party services if enabled $item_id = Database::getInstance('db')->table('items')->eq('rowid', $_POST['id'])->findOneColumn('id'); Service\push($item_id); } else { if ($_POST['as'] === 'unsaved') { $query->update(array('bookmark' => 0)); } else { if ($_POST['as'] === 'read') { $query->update(array('status' => 'read')); } else { if ($_POST['as'] === 'unread') { $query->update(array('status' => 'unread')); } } } } } response($response);
function set_bookmark_value($id, $value) { if ($value == 1) { Service\push($id); } return Database::getInstance('db')->table('items')->eq('id', $id)->in('status', array('read', 'unread'))->save(array('bookmark' => $value)); }