Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ACL: Add WWW language selection (only edit form), fixes #2976
  • Loading branch information
perexg committed Jun 29, 2015
1 parent a7ee941 commit 3d1262c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/access.c
Expand Up @@ -209,6 +209,8 @@ access_copy(access_t *src)
dst->aa_representative = strdup(src->aa_representative);
if (src->aa_lang)
dst->aa_lang = strdup(src->aa_lang);
if (src->aa_lang_ui)
dst->aa_lang_ui = strdup(src->aa_lang_ui);
if (src->aa_profiles)
dst->aa_profiles = htsmsg_copy(src->aa_profiles);
if (src->aa_dvrcfgs)
Expand Down Expand Up @@ -252,6 +254,7 @@ access_destroy(access_t *a)
free(a->aa_username);
free(a->aa_representative);
free(a->aa_lang);
free(a->aa_lang_ui);
htsmsg_destroy(a->aa_profiles);
htsmsg_destroy(a->aa_dvrcfgs);
htsmsg_destroy(a->aa_chtags);
Expand Down Expand Up @@ -546,9 +549,12 @@ access_update(access_t *a, access_entry_t *ae)
}
}

if (!a->aa_lang && ae->ae_lang)
if (!a->aa_lang && ae->ae_lang && ae->ae_lang[0])
a->aa_lang = lang_code_user(ae->ae_lang);

if (!a->aa_lang_ui && ae->ae_lang_ui && ae->ae_lang_ui[0])
a->aa_lang_ui = lang_code_user(ae->ae_lang_ui);

a->aa_rights |= ae->ae_rights;
}

Expand Down Expand Up @@ -1009,6 +1015,7 @@ access_entry_destroy(access_entry_t *ae)
free(ae->ae_username);
free(ae->ae_comment);
free(ae->ae_lang);
free(ae->ae_lang_ui);
free(ae);
}

Expand Down Expand Up @@ -1325,6 +1332,14 @@ const idclass_t access_entry_class = {
.list = language_get_list,
.off = offsetof(access_entry_t, ae_lang),
},
{
.type = PT_STR,
.id = "langui",
.name = N_("WWW Language"),
.list = language_get_list,
.off = offsetof(access_entry_t, ae_lang_ui),
.opts = PO_ADVANCED,
},
{
.type = PT_BOOL,
.id = "streaming",
Expand Down
2 changes: 2 additions & 0 deletions src/access.h
Expand Up @@ -76,6 +76,7 @@ typedef struct access_entry {
char *ae_username;
char *ae_comment;
char *ae_lang;
char *ae_lang_ui;

int ae_index;
int ae_enabled;
Expand Down Expand Up @@ -117,6 +118,7 @@ typedef struct access {
char *aa_username;
char *aa_representative;
char *aa_lang;
char *aa_lang_ui;
uint32_t aa_rights;
htsmsg_t *aa_profiles;
htsmsg_t *aa_dvrcfgs;
Expand Down
2 changes: 1 addition & 1 deletion src/webui/static/app/acleditor.js
Expand Up @@ -13,7 +13,7 @@ tvheadend.acleditor = function(panel, index)
'channel_tag_exclude,channel_tag,comment';

var list2 = 'enabled,username,password,prefix,' +
'lang,webui,admin,' +
'lang,webui,langui,admin,' +
'streaming,adv_streaming,htsp_streaming,' +
'profile,conn_limit_type,conn_limit,' +
'dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
Expand Down
6 changes: 4 additions & 2 deletions src/webui/webui.c
Expand Up @@ -1434,7 +1434,8 @@ http_redir(http_connection_t *hc, const char *remain, void *opaque)

if (nc == 1) {
if (!strcmp(components[0], "locale.js")) {
lang = tvh_gettext_get_lang(hc->hc_access->aa_lang);
lang = hc->hc_access->aa_lang_ui ?: hc->hc_access->aa_lang;
lang = tvh_gettext_get_lang(lang);
if (lang) {
snprintf(buf, sizeof(buf), "src/webui/static/intl/tvh.%s.js.gz", lang);
if (!http_file_test(buf)) {
Expand All @@ -1452,7 +1453,8 @@ http_redir(http_connection_t *hc, const char *remain, void *opaque)

if (nc >= 2) {
if (!strcmp(components[0], "docs")) {
lang = tvh_gettext_get_lang(hc->hc_access->aa_lang);
lang = hc->hc_access->aa_lang_ui ?: hc->hc_access->aa_lang;
lang = tvh_gettext_get_lang(lang);
snprintf(buf, sizeof(buf), "docs/html/%s/%s%s%s", lang, components[1],
nc > 2 ? "/" : "", nc > 2 ? components[1] : "");
if (http_file_test(buf)) lang = "en";
Expand Down

2 comments on commit 3d1262c

@perexg
Copy link
Contributor Author

@perexg perexg commented on 3d1262c Jun 29, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ProfYaffle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if "web interface language", "browser interface language" or simply "interface language" is clearer than "WWW language"?

Please sign in to comment.