diff options
author | Louis Brauer <louis@openbooking.ch> | 2024-05-26 01:47:22 +0200 |
---|---|---|
committer | Louis Brauer <louis@openbooking.ch> | 2024-05-26 01:47:22 +0200 |
commit | 9749a65007e88a6a7d8d98b6f6b98a1a47b46bdb (patch) | |
tree | 3adacb0e97d25cf26df9be696a8409dc90213219 /html.c | |
parent | 84a767dd0878013194ed7551b5ae6ef715e841a6 (diff) |
Enable deletion of avatar and header image in user settings
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -1013,11 +1013,21 @@ xs_html *html_top_controls(snac *snac) xs_html_attr("type", "file"), xs_html_attr("name", "avatar_file"))), xs_html_tag("p", + xs_html_sctag("input", + xs_html_attr("type", "checkbox"), + xs_html_attr("name", "avatar_delete")), + xs_html_text(L("Delete current avatar"))), + xs_html_tag("p", xs_html_text(L("Header image (banner): ")), xs_html_sctag("input", xs_html_attr("type", "file"), xs_html_attr("name", "header_file"))), xs_html_tag("p", + xs_html_sctag("input", + xs_html_attr("type", "checkbox"), + xs_html_attr("name", "header_delete")), + xs_html_text(L("Delete current header image"))), + xs_html_tag("p", xs_html_text(L("Bio:")), xs_html_sctag("br", NULL), xs_html_tag("textarea", @@ -3306,6 +3316,16 @@ int html_post_handler(const xs_dict *req, const char *q_path, } } + /* delete images by removing url from user.json */ + for (n = 0; uploads[n]; n++) { + xs *var_name = xs_fmt("%s_delete", uploads[n]); + const char *delete_var = xs_dict_get(p_vars, var_name); + + if (delete_var != NULL && strcmp(delete_var, "on") == 0) { + snac.config = xs_dict_set(snac.config, uploads[n], ""); + } + } + /* password change? */ if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL && (p2 = xs_dict_get(p_vars, "passwd2")) != NULL && |