Add the method "item.set_list_status" to the API

This commit is contained in:
Frédéric Guillot 2013-08-22 21:58:04 -04:00
parent bf0de86b8a
commit 51a746fac0
3 changed files with 21 additions and 2 deletions

View File

@ -24,7 +24,7 @@ print_r($result);
$result = $client->execute('feed.delete', array('feed_id' => $feed_id)); $result = $client->execute('feed.delete', array('feed_id' => $feed_id));
var_dump($result); var_dump($result);
$result = $client->execute('item.list_unread'); $result = $client->execute('item.list_read');
print_r($result); print_r($result);
$result = $client->execute('item.list_unread', array('offset' => 5, 'limit' => 2)); $result = $client->execute('item.list_unread', array('offset' => 5, 'limit' => 2));
@ -37,4 +37,6 @@ if (count($result)) {
} }
$result = $client->execute('item.bookmark.list'); $result = $client->execute('item.bookmark.list');
print_r($result); print_r($result);
var_dump($client->execute('item.set_list_status', array('status' => 'read', 'items' => array('57cdb841', '8ef6744e'))));

View File

@ -139,6 +139,12 @@ $server->register('item.mark_as_unread', function($item_id) {
return Model\set_item_unread($item_id); return Model\set_item_unread($item_id);
}); });
// Change the status of list of items
$server->register('item.set_list_status', function($status, array $items) {
return Model\set_items_status($status, $items);
});
// Flush all read items // Flush all read items
$server->register('item.flush', function() { $server->register('item.flush', function() {

View File

@ -602,6 +602,17 @@ function set_item_unread($id)
} }
function set_items_status($status, array $items)
{
if (! in_array($status, array('read', 'unread', 'removed'))) return false;
return \PicoTools\singleton('db')
->table('items')
->in('id', $items)
->save(array('status' => $status));
}
function set_bookmark_value($id, $value) function set_bookmark_value($id, $value)
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')