channel,tags: differentiate between user and admin (config) requests - use all argument, fixes #2517
This commit is contained in:
parent
452ca85ff6
commit
9778bca323
5 changed files with 30 additions and 7 deletions
|
@ -34,6 +34,13 @@ api_channel_key_val(htsmsg_t *dst, const char *key, const char *val)
|
|||
htsmsg_add_msg(dst, NULL, e);
|
||||
}
|
||||
|
||||
static int
|
||||
api_channel_is_all(access_t *perm, htsmsg_t *args)
|
||||
{
|
||||
return htsmsg_get_bool_or_default(args, "all", 0) &&
|
||||
!access_verify2(perm, ACCESS_ADMIN);
|
||||
}
|
||||
|
||||
// TODO: this will need converting to an idnode system
|
||||
static int
|
||||
api_channel_list
|
||||
|
@ -41,11 +48,12 @@ api_channel_list
|
|||
{
|
||||
channel_t *ch;
|
||||
htsmsg_t *l;
|
||||
int cfg = api_channel_is_all(perm, args);
|
||||
|
||||
l = htsmsg_create_list();
|
||||
pthread_mutex_lock(&global_lock);
|
||||
CHANNEL_FOREACH(ch) {
|
||||
if (!channel_access(ch, perm, 0)) continue;
|
||||
if (!cfg && !channel_access(ch, perm, 0)) continue;
|
||||
api_channel_key_val(l, idnode_uuid_as_str(&ch->ch_id), channel_get_name(ch));
|
||||
}
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
|
@ -57,12 +65,13 @@ api_channel_list
|
|||
|
||||
static void
|
||||
api_channel_grid
|
||||
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf )
|
||||
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args )
|
||||
{
|
||||
channel_t *ch;
|
||||
int cfg = api_channel_is_all(perm, args);
|
||||
|
||||
CHANNEL_FOREACH(ch)
|
||||
if (channel_access(ch, perm, !access_verify2(perm, ACCESS_ADMIN)))
|
||||
if (cfg || channel_access(ch, perm, 0))
|
||||
idnode_set_add(ins, (idnode_t*)ch, &conf->filter);
|
||||
}
|
||||
|
||||
|
@ -91,10 +100,11 @@ api_channel_tag_list
|
|||
{
|
||||
channel_tag_t *ct;
|
||||
htsmsg_t *l;
|
||||
|
||||
int cfg = api_channel_is_all(perm, args);
|
||||
|
||||
l = htsmsg_create_list();
|
||||
TAILQ_FOREACH(ct, &channel_tags, ct_link)
|
||||
if (channel_tag_access(ct, perm, 0))
|
||||
if (cfg || channel_tag_access(ct, perm, 0))
|
||||
api_channel_key_val(l, idnode_uuid_as_str(&ct->ct_id), ct->ct_name);
|
||||
*resp = htsmsg_create_map();
|
||||
htsmsg_add_msg(*resp, "entries", l);
|
||||
|
@ -103,12 +113,13 @@ api_channel_tag_list
|
|||
|
||||
static void
|
||||
api_channel_tag_grid
|
||||
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf )
|
||||
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args )
|
||||
{
|
||||
channel_tag_t *ct;
|
||||
int cfg = api_channel_is_all(perm, args);
|
||||
|
||||
TAILQ_FOREACH(ct, &channel_tags, ct_link)
|
||||
if (channel_tag_access(ct, perm, !access_verify2(perm, ACCESS_ADMIN)))
|
||||
if (cfg || channel_tag_access(ct, perm, 0))
|
||||
idnode_set_add(ins, (idnode_t*)ct, &conf->filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,9 +193,12 @@ htsmsg_t *
|
|||
channel_class_get_list(void *o)
|
||||
{
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_t *p = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "type", "api");
|
||||
htsmsg_add_str(m, "uri", "channel/list");
|
||||
htsmsg_add_str(m, "event", "channel");
|
||||
htsmsg_add_u32(p, "all", 1);
|
||||
htsmsg_add_msg(m, "params", p);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -1119,9 +1122,12 @@ htsmsg_t *
|
|||
channel_tag_class_get_list(void *o)
|
||||
{
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_t *p = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "type", "api");
|
||||
htsmsg_add_str(m, "uri", "channeltag/list");
|
||||
htsmsg_add_str(m, "event", "channeltag");
|
||||
htsmsg_add_u32(p, "all", 1);
|
||||
htsmsg_add_msg(m, "params", p);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ tvheadend.channel_tab = function(panel, index)
|
|||
|
||||
tvheadend.idnode_grid(panel, {
|
||||
url: 'api/channel',
|
||||
all: 1,
|
||||
comet: 'channel',
|
||||
titleS: 'Channel',
|
||||
titleP: 'Channels',
|
||||
|
|
|
@ -6,6 +6,7 @@ tvheadend.cteditor = function(panel, index)
|
|||
{
|
||||
tvheadend.idnode_grid(panel, {
|
||||
url: 'api/channeltag',
|
||||
all: 1,
|
||||
titleS: 'Channel Tag',
|
||||
titleP: 'Channel Tags',
|
||||
iconCls: 'channelTags',
|
||||
|
|
|
@ -1026,9 +1026,12 @@ tvheadend.idnode_grid = function(panel, conf)
|
|||
});
|
||||
|
||||
/* Store */
|
||||
var params = {};
|
||||
if (conf.all) params['all'] = 1;
|
||||
store = new Ext.data.JsonStore({
|
||||
root: 'entries',
|
||||
url: conf.gridURL || (conf.url + '/grid'),
|
||||
baseParams: params,
|
||||
autoLoad: true,
|
||||
id: 'uuid',
|
||||
totalProperty: 'total',
|
||||
|
@ -1425,6 +1428,7 @@ tvheadend.idnode_grid = function(panel, conf)
|
|||
if (!conf.fields) {
|
||||
var p = {};
|
||||
if (conf.list) p['list'] = conf.list;
|
||||
if (conf.all) p['all'] = 1;
|
||||
tvheadend.Ajax({
|
||||
url: conf.url + '/class',
|
||||
params: p,
|
||||
|
|
Loading…
Add table
Reference in a new issue