family invite

This commit is contained in:
CHIEFSOFT\ameye
2024-01-23 10:03:45 -05:00
parent ed42ce0ea3
commit d093ef037a
+11 -12
View File
@@ -114,27 +114,22 @@ long WrenchFamilyInvite(CVars in, CVars &out){
// const PGresult *res;
try{
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, "lastname", 3, 35, "(.*)");
REQ_STRING(in, "email", 3, 299, "(.*)");
REQ_STRING(in, "family_type", 3, 25, "(.*)");
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 "
" LEFT JOIN members_family mf ON mf.family_member_id = m.id "
" WHERE m.id=%lu AND m.uid='%s'", member_id, in["uid"].c_str());
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
const PGresult *res = pgsql_query("SELECT id FROM members_family_relative "
" WHERE LOWER('%s') = LOWER(email) AND member_id= %lu", in["email"].c_str(), member_id);
if (res != NULL && pgsql_num_rows(res) == 0) {
CVars xx;
xx["member_id"] = member_id;
xx["member_id"].set_valid(true);
xx["member_uid"] = in["uid"];
xx["member_uid"].set_valid(true);
xx["firstname"] = in["firstname"];
xx["firstname"].set_valid(true);
xx["lastname"] = in["lastname"];
@@ -151,7 +146,11 @@ long WrenchFamilyInvite(CVars in, CVars &out){
}
ret = PHP_API_OK;
out["status"] = "OK";
}
}
else{
out["status_msg"] = "Duplicate";
out["status_msg"] = "DUPLICATE";
}
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchFamilyInvite");