From d340ccd5ecbb731c273a07876ad0dfc0a9b33379 Mon Sep 17 00:00:00 2001 From: aurynn_cmd Date: Thu, 15 Nov 2007 23:10:31 +0000 Subject: Significant work on the Entity and Administrative code. It's buggy, so please test, etc. thoroughly. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1869 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/modules/admin.sql | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/modules/admin.sql b/sql/modules/admin.sql index 84b65af3..dfd702c8 100644 --- a/sql/modules/admin.sql +++ b/sql/modules/admin.sql @@ -264,11 +264,13 @@ CREATE OR REPLACE FUNCTION admin_save_user( -- create an actual user v_user_id := nextval('users_id_seq'); - insert into users (id, name, entity_id) VALUES ( + insert into users (id, username, entity_id) VALUES ( v_user_id, in_username, in_entity_id ); + + insert into user_preference (id) values (v_user_id); -- Finally, issue the create user statement @@ -412,4 +414,47 @@ $$ LANGUAGE PLPGSQL; --$$ language plpgsql; +create or replace function admin_is_user (in_user text) returns bool as $$ + DECLARE + pg_user pg_roles; + + BEGIN + + select * into pg_user from pg_roles where rolname = in_user; + + IF NOT FOUND THEN + return 'f'::bool; + END IF; + return 't'::bool; + + END; + +$$ language plpgsql; + +create or replace function admin_is_user (in_user text) returns bool as $$ + + BEGIN + + return 'f'::bool; + + END; + +$$ language plpgsql; + +create or replace view user_listable as + select + u.id, + u.username, + e.created + from entity e + join users u on u.entity_id = e.id; + + +create or replace function user_get_all_users () returns setof user_listable as $$ + + select * from user_listable; + +$$ language sql; + + commit; \ No newline at end of file -- cgit v1.2.3