summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
commitd340ccd5ecbb731c273a07876ad0dfc0a9b33379 (patch)
tree15acb5cc66a14c787ef49a6bab8910cdca0f82c9 /sql
parentc366b783a65dfdd7dadb105962ae0807cddaa6b9 (diff)
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
Diffstat (limited to 'sql')
-rw-r--r--sql/modules/admin.sql47
1 files changed, 46 insertions, 1 deletions
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