account settings
This commit is contained in:
@@ -370,6 +370,10 @@ long account_calls(CVars in, CVars &out) {
|
||||
return WrenchCardRechargePayment(in, out);
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_GETUSER_SETTINGS:
|
||||
return WrenchAccountSettings(in, out);
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_USER_SETTINGS:
|
||||
REQ_LONG(in, "member_id", 1, -1);
|
||||
REQ_STRING(in, "pref_id", 4, 6, "(.*)");
|
||||
|
||||
@@ -791,4 +791,64 @@ ADD CONSTRAINT members_pending_id_key UNIQUE (id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
long WrenchAccountSettings( CVars in, CVars &out ){
|
||||
logfmt(logINFO, "WrenchAccountSettings()");
|
||||
char vname[30];
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
const PGresult *res;
|
||||
const PGresult *res;
|
||||
|
||||
try {
|
||||
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
||||
|
||||
res0 = pgsql_query("SELECT pref_id,status FROM members_settings WHERE member_id = %lu",member_id);
|
||||
if (res0 != NULL && pgsql_num_rows(res0) > 0) {
|
||||
for (int i = 0, n = pgsql_num_rows(res0); i < n; i++) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res0, i);
|
||||
if (f.empty()) continue;
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
snprintf(vname, sizeof (vname), "%s_%05d",rec["pref_id"].c_str(), i);
|
||||
out[vname] = rec["status"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
out["total_record"] = "0";
|
||||
res = pgsql_query("SELECT id,title,description,pref_id FROM members_settings_options ORDER BY lorder ASC");
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
|
||||
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
||||
if (f.empty()) continue;
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
|
||||
snprintf(vname, sizeof (vname), "id_%05d", i);
|
||||
out[vname] = rec["id"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "title_%05d", i);
|
||||
out[vname] = rec["title"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "description_%05d", i);
|
||||
out[vname] = rec["description"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "pref_id_%05d", i);
|
||||
out[vname] = rec["pref_id"];
|
||||
|
||||
// snprintf(vname, sizeof (vname), "user_value_%05d", i);
|
||||
// out[vname] = rec["user_value"];
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchAccountSettings(CVars in, CVars &out)");
|
||||
}
|
||||
logfmt(logINFO, "/WrenchAccountSettings()");
|
||||
return ret;
|
||||
}
|
||||
//******************************************************************************
|
||||
Reference in New Issue
Block a user