diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-04-04 20:18:11 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-04-04 20:18:11 +0000 |
commit | 516f2cac8297abb49abe655b8c45dfac153c401f (patch) | |
tree | e2e0c2ea511ed4cf76a80e5ea7f8bded01901042 | |
parent | 49be3522dbec4ac0e42e069c5d8ac3552bed1202 (diff) |
Adding infrastructure for form tracking
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2125 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r-- | sql/Pg-database.sql | 5 | ||||
-rw-r--r-- | sql/modules/Session.sql | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 384e39eb..757567ed 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -68,6 +68,11 @@ users_id INTEGER NOT NULL references users(id), transaction_id INTEGER NOT NULL ); +CREATE TABLE open_forms ( +id SERIAL PRIMARY KEY, +session_id int REFERENCES session(session_id) ON DELETE CASCADE +); + -- CREATE TABLE transactions ( id int PRIMARY KEY, diff --git a/sql/modules/Session.sql b/sql/modules/Session.sql index 8b8b65c6..f8f0500e 100644 --- a/sql/modules/Session.sql +++ b/sql/modules/Session.sql @@ -1,3 +1,24 @@ +CREATE OR REPLACE FUNCTION form_check(in_session_id int, in_form_id int) +RETURNS BOOL AS +$$ +BEGIN + SELECT * FROM open_forms + WHERE session_id = in_session_id AND id = in_form_id; + + IF FOUND THEN RETURN TRUE; + ELSE RETURN FALSE; +END; +$$ language plpgsql; + +CREATE OR REPLACE FUNCTION form_open(in_session_id int) +RETURNS INT AS +$$ +BEGIN + INSERT INTO open_forms (session_id) VALUES (in_session_id); + RETURN currval('form_id_seq'); +END; +$$ LANGUAGE PLPGSQL + CREATE OR REPLACE FUNCTION session_check(in_session_id int, in_token text) RETURNS session AS $$ |