Update profile
This commit is contained in:
@@ -1166,7 +1166,7 @@ long WrenchUpdateAccountTerms(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;
|
||||
try {
|
||||
REQ_STRING(in, "firstname", 3, 49, "(.*)");
|
||||
|
||||
@@ -186,27 +186,38 @@ long WrenchReturnUserProfile(CVars in, CVars &out) {
|
||||
|
||||
/* This profile apps*/
|
||||
long WrenchUpdateUserProfile(CVars in, CVars &out) {
|
||||
logfmt(logINFO, "WrenchReturnUserProfile()");
|
||||
logfmt(logINFO, "WrenchUpdateUserProfile()");
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
|
||||
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);
|
||||
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) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
||||
map_to_cvars(f, out);
|
||||
CVars x;
|
||||
x["firstname"] = in["firstname"];
|
||||
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;
|
||||
out["status"] = "OK";
|
||||
}
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,10 +79,10 @@ if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) {
|
||||
$endpoint = strtolower(str_replace('/svs/user/', '', strtok($_SERVER['REQUEST_URI'], '?')));
|
||||
|
||||
$id = 0; // update, get & delete actions require ID
|
||||
if (substr($endpoint, 0, 19) == 'gettransportrequest' || substr($endpoint, 0, 13) == 'updateprofile') {
|
||||
$endpoint = strtok($endpoint, '/');
|
||||
$id = strtok('/');
|
||||
}
|
||||
//if (substr($endpoint, 0, 19) == 'gettransportrequest' || substr($endpoint, 0, 13) == 'updateprofile') {
|
||||
// $endpoint = strtok($endpoint, '/');
|
||||
// $id = strtok('/');
|
||||
//}
|
||||
|
||||
if (!isset($endpoints[$endpoint])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
|
||||
Reference in New Issue
Block a user