diff --git a/wrenchboard/src/include/common_tool.h b/wrenchboard/src/include/common_tool.h index 87101084..1acc6a91 100644 --- a/wrenchboard/src/include/common_tool.h +++ b/wrenchboard/src/include/common_tool.h @@ -10,6 +10,7 @@ long GetMemberAccountLink(long member_id, CVars &out); void GetOfferCode( unsigned long offer_id, char * number, int sz ); void Confirmation( unsigned long payment_id, char * number, int sz ); void SetFamilyUsername( unsigned long family_id, char * number, int sz ); +long WrenchLogRecent(CVars in, CVars &out); #endif diff --git a/wrenchboard/src/shared_tool/common_tool.cc b/wrenchboard/src/shared_tool/common_tool.cc index 4c57b8b5..60142bd0 100644 --- a/wrenchboard/src/shared_tool/common_tool.cc +++ b/wrenchboard/src/shared_tool/common_tool.cc @@ -125,4 +125,39 @@ void SetFamilyUsername( unsigned long family_id, char * number, int sz ) pgsql_exec("UPDATE members_family SET username='%s' WHERE id=%lu", family_username, family_id ); pgsql_exec("COMMIT" ); // Unlock table 'data' strsafecpy( number, family_username, sz ); -} \ No newline at end of file +} +/* +CREATE TABLE members_recentactivities ( + id SERIAL, + member_id INT REFERENCES members(id) NOT NULL, + uid uuid DEFAULT uuid_generate_v4(), + title VARCHAR(35) NOT NULL, + description VARCHAR(100), + status INT DEFAULT 1, + added timestamp without time zone DEFAULT now() + ); + ALTER TABLE ONLY members_recentactivities + ADD CONSTRAINT members_recentactivities_id_key UNIQUE (id); +*/ +long WrenchLogRecent(CVars in, CVars &out) { + long ret = PHP_API_BAD_PARAM; + logfmt(logINFO, "WrenchLogRecent()"); + try { + REQ_LONG(in, "member_id", 1, -1); + REQ_STRING(in, "title", 5, 35, "(.*)"); + REQ_STRING(in, "description", 5, 100, "(.*)"); + + CVars xx; + xx["member_id"] = in["member_id"]; xx["member_id"].set_valid(true); + xx["title"] = in["title"]; xx["title"].set_valid(true); + xx["description"] = in["description"]; xx["description"].set_valid(true); + out["recent_id"] = insert_db_record(DBS_VALID, "members_recentactivities", "members_recentactivities_id_seq", xx); + + } catch (bad_parameter) { + out["log_status"] = "Something went wrong"; + } + logfmt(logINFO, "WrenchLogRecent()"); + return ret; +} + + diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index a9f6a893..ad5afdb3 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -1672,6 +1672,14 @@ long WrenchDeleteJobsGroup(CVars in, CVars &out) { pgsql_exec("UPDATE members_job_group SET status = 0 WHERE status = 1 AND member_id = %lu AND id = %lu", in["member_id"].Long(), in["group_id"].Long()); ret = PHP_CREATED_OK; out["result"] = "OK"; + + //#include "common_tool.h" + CVars xx, yy; + xx["member_id"] = in["member_id"]; xx["member_id"].set_valid( true ); + xx["title"] = "A job was deleted"; xx["title"].set_valid( true ); + xx["description"] = "A job was deleted"; xx["description"].set_valid( true ); + WrenchLogRecent(xx, yy); + } catch (bad_parameter) { out["log_status"] = "Invalid Log Action"; }