[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2296] trunk
- Subject: SF.net SVN: ledger-smb:[2296] trunk
- From: ..hidden..
- Date: Thu, 21 Aug 2008 20:05:56 +0000
Revision: 2296
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2296&view=rev
Author: aurynn_cmd
Date: 2008-08-21 20:05:54 +0000 (Thu, 21 Aug 2008)
Log Message:
-----------
Further fixes to Recon and Admin. In testing.
Modified Paths:
--------------
trunk/LedgerSMB/Admin.pm
trunk/LedgerSMB/DBObject/Admin.pm
trunk/LedgerSMB/DBObject/User.pm
trunk/scripts/admin.pl
trunk/scripts/recon.pl
trunk/sql/modules/Employee.sql
trunk/sql/modules/Entity.sql
trunk/sql/modules/Reconciliaton.sql
trunk/sql/modules/admin.sql
Modified: trunk/LedgerSMB/Admin.pm
===================================================================
--- trunk/LedgerSMB/Admin.pm 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/LedgerSMB/Admin.pm 2008-08-21 20:05:54 UTC (rev 2296)
@@ -180,9 +180,16 @@
my $self = shift @_;
my $id = shift @_;
- my $user = LedgerSMB::DBObject::User->new(base=>$self,copy=>'all');
- $user->get($id);
+ my $user = {};
+ my $u = LedgerSMB::DBObject::User->new(base=>$self,copy=>'all');
+ $user->{user} = $u->get($id);
+ $user->{pref} = $u->preferences($id);
+ $user->{employee} = $u->employee($user->{user}->{entity_id});
+ $user->{person} = $u->person($user->{user}->{entity_id});
+ $user->{entity} = $u->entity($id);
+ $user->{roles} = $u->roles($id);
+ return $user;
}
sub get_roles {
Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/LedgerSMB/DBObject/Admin.pm 2008-08-21 20:05:54 UTC (rev 2296)
@@ -96,7 +96,7 @@
my $user = LedgerSMB::DBObject::User->new( base=>$self, copy=>'all' );
my $roles = $self->exec_method( procname => "admin__all_roles" );
- my $user_roles = $self->exec_method(procname => "admin__get_user_roles", args=>[ $self->{ username } ] );
+ my $user_roles = $self->exec_method(procname => "admin__get_user_roles", args=>[ $user->{id} ] );
my %active_roles;
for my $role (@{ $user_roles }) {
Modified: trunk/LedgerSMB/DBObject/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/User.pm 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/LedgerSMB/DBObject/User.pm 2008-08-21 20:05:54 UTC (rev 2296)
@@ -40,10 +40,43 @@
my $self = shift @_;
my $id = shift;
- my $user = @{ $self->exec_method(funcname=>'admin__get_user',
- args=>[$id])}[0];
-
- return $user;
+ $self->{user} = @{ $self->exec_method(
+ funcname=>'admin__get_user',
+ args=>[$id]
+ )
+ }[0];
+ $self->{pref} = @{ $self->exec_method(
+ funcname=>'admin__user_preferences',
+ args=>[$id]
+ )
+ }[0];
+ $self->{person} = @{ $self->exec_method(
+ funcname=>'admin__user_preferences',
+ args=>[$self->{user}->{entity_id}]
+ )
+ }[0];
+ $self->{employee} = @{ $self->exec_method(
+ funcname=>'employee__get',
+ args=>[$id]
+ )
+ }[0];
+ $self->{entity} = @{ $self->exec_method(
+ funcname=>'entity__get_entity',
+ args=>[ $self->{user}->{entity_id} ]
+ )
+ }[0];
+ $self->{roles} = $self->exec_method(
+ funcname=>'admin__get_roles_for_user',
+ args=>[$id]
+ );
+
+
+ #$user->{user} = $u->get($id);
+ #$user->{pref} = $u->preferences($id);
+ #$user->{employee} = $u->employee($user->{user}->{entity_id});
+ #$user->{person} = $u->person($user->{user}->{entity_id});
+ #$user->{entity} = $u->entity($id);
+ #$user->{roles} = $u->roles($id);
}
sub remove {
@@ -79,4 +112,12 @@
$self->{users} = ..hidden..;
}
+sub roles {
+
+ my $self = shift @_;
+ my $id = shift @_;
+
+
+}
+
1;
Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/scripts/admin.pl 2008-08-21 20:05:54 UTC (rev 2296)
@@ -60,7 +60,10 @@
# uses the same page as create_user, only pre-populated.
my ($request) = @_;
my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'user_id');
+ my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'user_id');
+ $user->get($request->{user_id});
+
my $all_roles = $admin->get_roles();
my $template = LedgerSMB::Template->new(
@@ -84,10 +87,9 @@
);
}
else {
- my $edited_user = $admin->get_entire_user($request->{user});
$template->render(
{
- user=>$edited_user,
+ user=>$user,
roles=>$all_roles,
user_roles=>$admin->get_user_roles($request->{user})
}
Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/scripts/recon.pl 2008-08-21 20:05:54 UTC (rev 2296)
@@ -113,7 +113,7 @@
format=>'HTML',
path=>"UI",
mode=>$type,
- accounts=>$recon->get_accounts();
+ accounts=>$recon->get_accounts()
);
return $template->render();
}
Modified: trunk/sql/modules/Employee.sql
===================================================================
--- trunk/sql/modules/Employee.sql 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/sql/modules/Employee.sql 2008-08-21 20:05:54 UTC (rev 2296)
@@ -2,7 +2,7 @@
BEGIN;
-CREATE OR REPLACE FUNCTION employee_save(
+CREATE OR REPLACE FUNCTION employee__save(
in_person int, in_entity int, in_startdate date, in_enddate date,
in_role text, in_sales boolean, in_dob date,
in_managerid integer, in_employeenumber text
@@ -75,7 +75,7 @@
JOIN salutation s ON (p.salutation_id = s.id);
-CREATE OR REPLACE FUNCTION employee_get
+CREATE OR REPLACE FUNCTION employee__get
(in_id integer)
returns employees as
$$
@@ -83,21 +83,16 @@
emp employees%ROWTYPE;
BEGIN
SELECT
- s.salutation,
- p.first_name,
- p.last_name,
ee.*
INTO emp
FROM employees ee
- join person p USING (entity_id)
- JOIN salutation s ON (p.salutation_id = s.id)
WHERE ee.entity_id = in_id;
RETURN emp;
END;
$$ language plpgsql;
-CREATE OR REPLACE FUNCTION employee_list_managers
+CREATE OR REPLACE FUNCTION employee__list_managers
(in_id integer)
RETURNS SETOF employees as
$$
Modified: trunk/sql/modules/Entity.sql
===================================================================
--- trunk/sql/modules/Entity.sql 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/sql/modules/Entity.sql 2008-08-21 20:05:54 UTC (rev 2296)
@@ -37,4 +37,24 @@
$$ language 'plpgsql';
+
+CREATE OR REPLACE FUNCTION entity__get_entity (
+ in_entity_id int
+) RETURNS setof entity AS $$
+
+declare
+ v_row entity;
+BEGIN
+ SELECT * INTO v_row FROM entity WHERE id = in_entity_id;
+ IF NOT FOUND THEN
+ raise exception "Could not find entity with ID %", in_entity_id;
+ ELSE
+ return next v_row;
+ END IF;
+END;
+
+$$ language plpgsql;
+
+
+
commit;
Modified: trunk/sql/modules/Reconciliaton.sql
===================================================================
--- trunk/sql/modules/Reconciliaton.sql 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/sql/modules/Reconciliaton.sql 2008-08-21 20:05:54 UTC (rev 2296)
@@ -491,7 +491,7 @@
id int
);
-create or replace function reconciliation__get_accounts () returns setof recon_accounts as $$
+create or replace function reconciliation__account_list () returns setof recon_accounts as $$
SELECT
coa.accno || ' ' || coa.description as name,
coa.id as id
Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql 2008-08-21 15:44:26 UTC (rev 2295)
+++ trunk/sql/modules/admin.sql 2008-08-21 20:05:54 UTC (rev 2296)
@@ -198,13 +198,13 @@
$$ language 'plpgsql';
-create or replace function admin__get_user(in_user TEXT) returns setof users as $$
+create or replace function admin__get_user(in_user INT) returns setof users as $$
DECLARE
a_user users;
BEGIN
- select * into a_user from users where username = in_user;
+ select * into a_user from users where id = in_user;
IF NOT FOUND THEN
RAISE EXCEPTION 'cannot find user %', in_user;
END IF;
@@ -215,15 +215,30 @@
END;
$$ language plpgsql;
-create or replace function admin__get_roles_for_user(in_user TEXT) returns setof lsmb_roles as $$
+create or replace function admin__get_roles_for_user(in_user_id INT) returns setof text as $$
declare
- u_role lsmb_roles;
+ u_role text;
a_user users;
begin
- select * into a_user from admin_get_user(in_user);
+ select * into a_user from admin__get_user(in_user_id);
- FOR u_role IN select * from lsmb_roles lr WHERE lr.user_id = a_user.id LOOP
+ FOR u_role IN
+ select r.rolname
+ from
+ pg_roles r,
+ (select
+ m.roleid
+ from
+ pg_auth_members m, pg_roles b
+ where
+ m.member = b.oid
+ and
+ b.rolname = a_user.username
+ ) as ar
+ where
+ r.oid = ar.roleid
+ LOOP
RETURN NEXT u_role;
@@ -297,7 +312,7 @@
select * from pg_auth_members m join pg_authid a ON (m.roleid = a.oid);
-create or replace function admin__is_group(in_group_name text) returns bool as $$
+create or replace function admin__is_group(in_dbname TEXT, in_group_name text) returns bool as $$
DECLARE
@@ -324,7 +339,7 @@
stmt text;
BEGIN
- stmt := 'create role '|| quote_ident(quote_ident(in_dbname) || '_lsmb_' || quote_ident(in_group_name) );
+ stmt := 'create role lsmb_'|| quote_ident(quote_ident(in_dbname) || '__' || quote_ident(in_group_name) );
execute stmt;
return 1;
END;
@@ -373,7 +388,7 @@
if not found then
return 'f'::bool;
else
- stmt := 'drop role ' || quote_ident(in_dbname || '_lsmb_' || in_group_name);
+ stmt := 'drop role lsmb_' || quote_ident(in_dbname || '__' || in_group_name);
execute stmt;
return 't'::bool;
end if;
@@ -392,7 +407,7 @@
BEGIN
FOR out_rolename IN
SELECT rolname FROM pg_authid
- WHERE oid IN (SELECT id FROM connectby(
+ WHERE oid IN (SELECT id FROM connectby (
'(SELECT m.member, m.roleid, r.oid FROM pg_authid r
LEFT JOIN pg_auth_members m ON (r.oid = m.roleid)) a',
'oid', 'member', 'oid', '320461', '0', ','
@@ -407,7 +422,6 @@
-- TODO: Add admin user
-
--CREATE OR REPLACE FUNCTION admin_audit_log () returns int as $$
@@ -464,5 +478,18 @@
END;
$$ language plpgsql;
+create or replace function admin__user_preferences (in_user int) returns setof user_preference as $$
+
+declare
+ v_row user_preferences;
+BEGIN
+ select * into v_row from user_preference where user_id = in_user;
+
+ IF NOT FOUND THEN
+
+ RAISE EXCEPTION "Could not find user preferences for id %", in_user;
+ ELSE
+ return next v_row;
+ END IF;
commit;
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.