commit 9749a65
Louis Brauer
·
2024-05-25 23:47:22 +0000 UTC
parent 84a767d
Enable deletion of avatar and header image in user settings
1 files changed,
+20,
-0
M
html.c
M
html.c
+20,
-0
1@@ -1012,12 +1012,22 @@ xs_html *html_top_controls(snac *snac)
2 xs_html_sctag("input",
3 xs_html_attr("type", "file"),
4 xs_html_attr("name", "avatar_file"))),
5+ xs_html_tag("p",
6+ xs_html_sctag("input",
7+ xs_html_attr("type", "checkbox"),
8+ xs_html_attr("name", "avatar_delete")),
9+ xs_html_text(L("Delete current avatar"))),
10 xs_html_tag("p",
11 xs_html_text(L("Header image (banner): ")),
12 xs_html_sctag("input",
13 xs_html_attr("type", "file"),
14 xs_html_attr("name", "header_file"))),
15 xs_html_tag("p",
16+ xs_html_sctag("input",
17+ xs_html_attr("type", "checkbox"),
18+ xs_html_attr("name", "header_delete")),
19+ xs_html_text(L("Delete current header image"))),
20+ xs_html_tag("p",
21 xs_html_text(L("Bio:")),
22 xs_html_sctag("br", NULL),
23 xs_html_tag("textarea",
24@@ -3306,6 +3316,16 @@ int html_post_handler(const xs_dict *req, const char *q_path,
25 }
26 }
27
28+ /* delete images by removing url from user.json */
29+ for (n = 0; uploads[n]; n++) {
30+ xs *var_name = xs_fmt("%s_delete", uploads[n]);
31+ const char *delete_var = xs_dict_get(p_vars, var_name);
32+
33+ if (delete_var != NULL && strcmp(delete_var, "on") == 0) {
34+ snac.config = xs_dict_set(snac.config, uploads[n], "");
35+ }
36+ }
37+
38 /* password change? */
39 if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL &&
40 (p2 = xs_dict_get(p_vars, "passwd2")) != NULL &&