Improve pull-request #532

This commit is contained in:
Frederic Guillot 2016-07-28 21:11:58 -04:00
parent 092c52c0db
commit 148b4cccc1
No known key found for this signature in database
GPG Key ID: 92D77191BA7FBC99

View File

@ -85,185 +85,46 @@ $server->register('group.list', function () {
return Model\Group\get_all(); return Model\Group\get_all();
}); });
//--------------------------------------------------------------------------------
// mjb added 2016.07.24
// Add a new group // Add a new group
$server->register('group.create', function($title) { $server->register('group.create', function($title) {
return Model\Group\create($title);
try {
$result = Model\Group\create($title);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// Get assoc array of group ids with assigned feeds ids // Get assoc array of group ids with assigned feeds ids
$server->register('group.map', function() { $server->register('group.map', function() {
return Model\Group\get_map();
try {
$result = Model\Group\get_map();
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// Get the id of a group // Get the id of a group
$server->register('group.id', function($title) { $server->register('group.id', function($title) {
return Model\Group\get_group_id($title);
try {
$result = Model\Group\get_group_id($title);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// Get all feed ids assigned to a group // Get all feed ids assigned to a group
$server->register('group.feeds', function($group_id) { $server->register('group.feeds', function($group_id) {
return Model\Group\get_feeds_by_group($group_id);
try {
$result = Model\Group\get_feeds_by_group($group_id);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// add groups to feed // Add groups to feed
$server->register('group.add', function($feed_id, $group_ids) { $server->register('group.add', function($feed_id, $group_ids) {
return Model\Group\add($feed_id, $group_ids);
try {
$result = Model\Group\add($feed_id, $group_ids);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// remove groups from feed // Remove groups from feed
$server->register('group.remove', function($feed_id, $group_ids) { $server->register('group.remove', function($feed_id, $group_ids) {
return Model\Group\remove($feed_id, $group_ids);
try {
$result = Model\Group\remove($feed_id, $group_ids);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// Remove all groups from feed
// remove all groups from feed
$server->register('group.remove_all', function($feed_id) { $server->register('group.remove_all', function($feed_id) {
return Model\Group\remove_all($feed_id);
try {
$result = Model\Group\remove_all($feed_id);
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
// Update feed group associations
// Purge orphaned groups from database
$server->register('group.purge_groups', function() {
try {
$result = Model\Group\purge_groups();
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
});
// update feed group associations
$server->register('group.update_feed_groups', function($feed_id, $group_ids, $create_group = '') { $server->register('group.update_feed_groups', function($feed_id, $group_ids, $create_group = '') {
return Model\Group\update_feed_groups($feed_id, $group_ids, $create_group);
try {
$result = Model\Group\update_feed_groups($feed_id, $group_ids, $create_group = '');
}
catch (PicoFeedException $e) {
$result = false;
}
catch (UnexpectedValueException $e) {
$result = false;
}
Model\Config\write_debug();
return $result;
}); });
//--------------------------------------------------------------------------------
// Get all items for a specific feed // Get all items for a specific feed
$server->register('item.feed.list', function ($feed_id, $offset = null, $limit = null) { $server->register('item.feed.list', function ($feed_id, $offset = null, $limit = null) {
return Model\Item\get_all_by_feed($feed_id, $offset, $limit); return Model\Item\get_all_by_feed($feed_id, $offset, $limit);