Update profile

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-23 05:36:37 -04:00
parent 5aa9f6793a
commit 2d49e5fb46
3 changed files with 27 additions and 16 deletions
+1 -1
View File
@@ -1166,7 +1166,7 @@ long WrenchUpdateAccountTerms(CVars in, CVars &out) {
} }
long WrenchUpdateProfile(CVars in, CVars &out) { long WrenchUpdateProfile(CVars in, CVars &out) {
logfmt(logINFO, "long WrenchUpdateProfile(CVars in, CVars out)"); logfmt(logINFO, "long WrenchUpdateProfile(CVars in, CVars out) ******* RETIRE THIS FUNCTION - no country change");
long ret = PHP_API_BAD_PARAM; long ret = PHP_API_BAD_PARAM;
try { try {
REQ_STRING(in, "firstname", 3, 49, "(.*)"); REQ_STRING(in, "firstname", 3, 49, "(.*)");
+22 -11
View File
@@ -186,27 +186,38 @@ long WrenchReturnUserProfile(CVars in, CVars &out) {
/* This profile apps*/ /* This profile apps*/
long WrenchUpdateUserProfile(CVars in, CVars &out) { long WrenchUpdateUserProfile(CVars in, CVars &out) {
logfmt(logINFO, "WrenchReturnUserProfile()"); logfmt(logINFO, "WrenchUpdateUserProfile()");
long ret = PHP_API_BAD_PARAM; long ret = PHP_API_BAD_PARAM;
try { try {
REQ_STRING(in, "firstname", 3, 49, "(.*)");
REQ_STRING(in, "lastname", 3, 49, "(.*)");
REQ_STRING(in, "email", 5, 150, "(.*)");
REQ_STRING(in, "state", 3, 150, "(.*)");
REQ_STRING(in, "city", 3, 150, "(.*)");
long member_id = REQ_LONG(in, "member_id", 1, -1); long member_id = REQ_LONG(in, "member_id", 1, -1);
out["total_record"] = "0";
const PGresult *res;
res = pgsql_query("SELECT * FROM members WHERE id = %lu", member_id );
const PGresult *res;
res = pgsql_query("SELECT * FROM members WHERE id = %lu AND uid='%s'", member_id );
if (res != NULL && pgsql_num_rows(res) > 0) { if (res != NULL && pgsql_num_rows(res) > 0) {
out["total_record"] = pgsql_num_rows(res); CVars x;
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0); x["firstname"] = in["firstname"];
map_to_cvars(f, out); x["firstname"].set_valid(true);
x["lastname"] = in["lastname"];
x["lastname"].set_valid(true);
x["email"] = in["email"];
x["email"].set_valid(true);
x["state"] = in["state"];
x["state"].set_valid(true);
x["city"] = in["city"];
x["city"].set_valid(true);
update_db_record(DBS_VALID, "members", x, member_id);
ret = PHP_API_OK; ret = PHP_API_OK;
out["status"] = "OK";
} }
} catch (bad_parameter) { } catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchReturnUserProfile(CVars in, CVars &out)"); logfmt(logINFO, "ERROR CALL long WrenchUpdateUserProfile(CVars in, CVars &out)");
} }
logfmt(logINFO, "/WrenchReturnUserProfile()"); logfmt(logINFO, "/WrenchUpdateUserProfile()");
return ret; return ret;
} }
+4 -4
View File
@@ -79,10 +79,10 @@ if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) {
$endpoint = strtolower(str_replace('/svs/user/', '', strtok($_SERVER['REQUEST_URI'], '?'))); $endpoint = strtolower(str_replace('/svs/user/', '', strtok($_SERVER['REQUEST_URI'], '?')));
$id = 0; // update, get & delete actions require ID $id = 0; // update, get & delete actions require ID
if (substr($endpoint, 0, 19) == 'gettransportrequest' || substr($endpoint, 0, 13) == 'updateprofile') { //if (substr($endpoint, 0, 19) == 'gettransportrequest' || substr($endpoint, 0, 13) == 'updateprofile') {
$endpoint = strtok($endpoint, '/'); // $endpoint = strtok($endpoint, '/');
$id = strtok('/'); // $id = strtok('/');
} //}
if (!isset($endpoints[$endpoint])) { if (!isset($endpoints[$endpoint])) {
header('HTTP/1.1 400 Bad Request'); header('HTTP/1.1 400 Bad Request');