From adbe76047fc207eb09a2e03d4231e0713360140f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Wed, 16 Jun 2021 22:32:10 +0800 Subject: Create admin function --- admin.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'admin.c') diff --git a/admin.c b/admin.c index 3ba9464..a334f3b 100644 --- a/admin.c +++ b/admin.c @@ -17,9 +17,31 @@ icclient_admin *icclient_admin_login(const char *username, const char *password, return admin; } -void icclient_admin_newitem(const char *description, const char *comment, const char *price, const char *image_path) +void icclient_admin_new_admin(const char *username, const char *password, const char *name, bool super, + enum icclient_admin_group group, void (*handler)(icclient_fetch_t *)) { - request(NULL, NULL, &(struct body){ 15, { + request(handler, NULL, &(struct body){ 13, { + { "mv_todo", "set" }, + { "mv_data_table", "access" }, + { "mv_data_key", "username" }, + { "mv_update_empty", "1" }, + { "mv_data_fields", "username password name super groups" }, + { "mv_click", "process_filter" }, + { "user_id", "NEW" }, + { "name", name }, + { "mv_data_function", "insert" }, + { "username", username }, + { "password", password }, + { "super", super ? "1" : "0" }, + { "groups", group == ICCLIENT_ADMIN_GROUP_CONTENT ? ":CONTENT" + : group == ICCLIENT_ADMIN_GROUP_MERCH ? ":MERCH" : ":ORDERS" } + }}, "%s", "ui"); +} + +void icclient_admin_new_item(const char *description, const char *comment, const char *price, const char *image_path, + void (*handler)(icclient_fetch_t *)) +{ + request(handler, NULL, &(struct body){ 15, { { "mv_click", "process_filter" }, { "mv_data_fields", "sku description prod_group category comment inactive price wholesale image thumb image_large weight nontaxable gift_cert" }, { "mv_ui", "1" }, @@ -45,9 +67,9 @@ void icclient_admin_newitem(const char *description, const char *comment, const }}, "%s", "admin/item_edit"); } -void icclient_admin_logout(icclient_admin *admin) +void icclient_admin_logout(icclient_admin *admin, void (*handler)(icclient_fetch_t *)) { - request(NULL, NULL, NULL, "%s", "admin/login"); + request(handler, NULL, NULL, "%s", "admin/login"); if (admin->name) free(admin->name); if (admin->username) -- cgit v1.2.3