family invite
This commit is contained in:
@@ -114,27 +114,22 @@ long WrenchFamilyInvite(CVars in, CVars &out){
|
|||||||
// const PGresult *res;
|
// const PGresult *res;
|
||||||
try{
|
try{
|
||||||
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
||||||
|
REQ_STRING(in, "uid", 3, 150, "(.*)");
|
||||||
REQ_STRING(in, "firstname", 3, 35, "(.*)");
|
REQ_STRING(in, "firstname", 3, 35, "(.*)");
|
||||||
REQ_STRING(in, "lastname", 3, 35, "(.*)");
|
REQ_STRING(in, "lastname", 3, 35, "(.*)");
|
||||||
REQ_STRING(in, "email", 3, 299, "(.*)");
|
REQ_STRING(in, "email", 3, 299, "(.*)");
|
||||||
REQ_STRING(in, "family_type", 3, 25, "(.*)");
|
REQ_STRING(in, "family_type", 3, 25, "(.*)");
|
||||||
|
|
||||||
out["invite_id"] ="0";// we will set if all okay
|
out["invite_id"] ="0";// we will set if all okay
|
||||||
const PGresult *res = pgsql_query("SELECT m.*,mf.uid AS family_uid FROM members m "
|
const PGresult *res = pgsql_query("SELECT id FROM members_family_relative "
|
||||||
" LEFT JOIN members_family mf ON mf.family_member_id = m.id "
|
" WHERE LOWER('%s') = LOWER(email) AND member_id= %lu", in["email"].c_str(), member_id);
|
||||||
" WHERE m.id=%lu AND m.uid='%s'", member_id, in["uid"].c_str());
|
if (res != NULL && pgsql_num_rows(res) == 0) {
|
||||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
|
||||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
|
||||||
CVars rec;
|
|
||||||
map_to_cvars(f, rec);
|
|
||||||
ret = PHP_API_OK;
|
|
||||||
out["status"] = "ACCOUNT FOUND";
|
|
||||||
//out = rec;
|
|
||||||
if (rec["family_uid"] != ""){ // we are sure you are a family now
|
|
||||||
|
|
||||||
CVars xx;
|
CVars xx;
|
||||||
xx["member_id"] = member_id;
|
xx["member_id"] = member_id;
|
||||||
xx["member_id"].set_valid(true);
|
xx["member_id"].set_valid(true);
|
||||||
|
xx["member_uid"] = in["uid"];
|
||||||
|
xx["member_uid"].set_valid(true);
|
||||||
xx["firstname"] = in["firstname"];
|
xx["firstname"] = in["firstname"];
|
||||||
xx["firstname"].set_valid(true);
|
xx["firstname"].set_valid(true);
|
||||||
xx["lastname"] = in["lastname"];
|
xx["lastname"] = in["lastname"];
|
||||||
@@ -151,7 +146,11 @@ long WrenchFamilyInvite(CVars in, CVars &out){
|
|||||||
}
|
}
|
||||||
ret = PHP_API_OK;
|
ret = PHP_API_OK;
|
||||||
out["status"] = "OK";
|
out["status"] = "OK";
|
||||||
}
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
out["status_msg"] = "Duplicate";
|
||||||
|
out["status_msg"] = "DUPLICATE";
|
||||||
}
|
}
|
||||||
} catch (bad_parameter) {
|
} catch (bad_parameter) {
|
||||||
logfmt(logINFO, "ERROR CALL long WrenchFamilyInvite");
|
logfmt(logINFO, "ERROR CALL long WrenchFamilyInvite");
|
||||||
|
|||||||
Reference in New Issue
Block a user