[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [2183] trunk
- Subject: SF.net SVN: ledger-smb: [2183] trunk
- From: ..hidden..
- Date: Thu, 03 Jul 2008 16:33:11 -0700
Revision: 2183
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2183&view=rev
Author: aurynn_cmd
Date: 2008-07-03 16:33:08 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
Updates and clarifications to the new Admin interface. Testing to commence on Mon, Jul 7th.
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Admin.pm
trunk/LedgerSMB/DBObject/User.pm
trunk/UI/Admin/edit_group.html
trunk/UI/Admin/edit_user.html
trunk/scripts/admin.pl
trunk/sql/modules/admin.sql
Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/LedgerSMB/DBObject/Admin.pm 2008-07-03 23:33:08 UTC (rev 2183)
@@ -15,7 +15,7 @@
$self->error("Cannot save an Adminstrator object.");
}
-sub save_employee {
+sub save_user {
my $self = shift @_;
@@ -27,7 +27,7 @@
$self->{entity_id} = $entity->{id};
- my $user_id = shift @{ $self->exec_method( procname => "admin_save_user" ) };
+ my $user_id = shift @{ $self->exec_method( procname => "admin__save_user" ) };
$self->merge($user_id);
my $person = LedgerSMB::DBObject::Person->new( base=>$self, copy=>'list',
@@ -89,17 +89,17 @@
$user->save();
}
-sub save_roles_preferences {
+sub save_roles {
my $self = shift @_;
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 $roles = $self->exec_method( procname => "admin__all_roles" );
+ my $user_roles = $self->exec_method(procname => "admin__get_user_roles", args=>[ $self->{ username } ] );
my %active_roles;
- for my $role (@{$user_roles}) {
+ for my $role (@{ $user_roles }) {
# These are our user's roles.
@@ -112,25 +112,24 @@
# These roles are were ALL checked on the page, so they're the active ones.
- if ($active_roles{$role} && $self->{incoming_roles}->{$role}) {
+ if ($active_roles{$role} && $self->{$role}) {
# do nothing.
}
- elsif ($active_roles{$role} && !($self->{incoming_roles}->{$role} )) {
+ elsif ($active_roles{$role} && !($self->{$role} )) {
# do remove function
- $status = $self->exec_method(procname => "remove_user_from_role",
+ $status = $self->exec_method(procname => "admin__remove_user_from_role",
args=>[ $self->{ modifying_user }, $role ] );
}
elsif ($self->{incoming_roles}->{$role} and !($active_roles{$role} )) {
# do add function
- $status = $self->exec_method(procname => "add_user_to_role",
+ $status = $self->exec_method(procname => "admin__add_user_to_role",
args=>[ $self->{ modifying_user }, $role ]
);
}
}
-
}
sub save_group {
@@ -143,8 +142,8 @@
# first we grab all roles
- my $roles = $self->exec_method( procname => "all_roles" );
- my $user_roles = $self->exec_method(procname => "get_user_roles",
+ my $roles = $self->exec_method( procname => "admin__all_roles" );
+ my $user_roles = $self->exec_method(procname => "admin__get_user_roles",
args=>[ $self->{ group_name } ]
);
@@ -170,7 +169,7 @@
# do remove function
$status = $self->exec_method(
- procname => "remove_group_from_role",
+ procname => "admin__remove_group_from_role",
args=>[ $self->{ modifying_user }, $role ]
);
}
@@ -178,7 +177,7 @@
# do add function
$status = $self->exec_method(
- procname => "add_group_to_role",
+ procname => "admin__add_group_to_role",
args=>[ $self->{ modifying_user }, $role ]
);
}
@@ -190,7 +189,7 @@
my $self = shift @_;
- my $status = shift @{ $self->exec_method(procname=>'delete_user',
+ my $status = shift @{ $self->exec_method(procname=>'admin__delete_user',
args=>[$self->{modifying_user}])
};
@@ -210,7 +209,7 @@
my $self = shift @_;
- my $status = shift @{ $self->exec_method(procname=>'delete_group',
+ my $status = shift @{ $self->exec_method(procname=>'admin__delete_group',
args=>[$self->{groupname}]) }
;
@@ -238,4 +237,12 @@
return $sth->fetchall_arrayref( {} );
}
+
+sub get_roles {
+
+ # These are direct, assignable roles.
+ my $self = shift;
+
+ return $self->exec_method( procname => "admin__all_roles" );
+}
1;
Modified: trunk/LedgerSMB/DBObject/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/User.pm 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/LedgerSMB/DBObject/User.pm 2008-07-03 23:33:08 UTC (rev 2183)
@@ -11,7 +11,7 @@
if ( $user->{id} && $self->{is_a_user} ) {
# doesn't check for the password - that's done in the sproc.
- $self->{id} = shift @{ $self->exec_method(procname=>'admin_save_user',
+ $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user',
args=>[$user->{id}, $self->{username}, $self->{password}] ) };
if (!$self->{id}) {
@@ -29,7 +29,7 @@
elsif ($self->{is_a_user}) {
# No user ID, meaning, creating a new one.
- $self->{id} = shift @{ $self->exec_method(procname=>'admin_save_user',
+ $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user',
args=>[undef, $self->{username}, $self->{password}] ) };
}
return 1;
@@ -39,7 +39,7 @@
my $self = shift @_;
- my ($user_id, $username) = @{ $self->exec_method(procname=>'admin_get_user',
+ my ($user_id, $username) = @{ $self->exec_method(procname=>'admin__get_user',
args=>[$self->{id}])};
return {id=>$user_id, username=>$username};
@@ -49,7 +49,7 @@
my $self = shift;
- my $code = $self->exec_method(procname=>"admin_delete_user", args=>[$self->{id}, $self->{username}]);
+ my $code = $self->exec_method(procname=>"admin__delete_user", args=>[$self->{id}, $self->{username}]);
$self->{id} = undef; # never existed..
return $code->[0];
@@ -59,7 +59,7 @@
my $self = shift @_;
- my $pref_id = $self->exec_method(procname=>"admin_save_preferences",
+ my $pref_id = $self->exec_method(procname=>"admin__save_preferences",
args=>[
'language',
'stylesheet',
@@ -74,7 +74,7 @@
my $self = shift @_;
- $self->{users} = $self->exec_method( procname=>"user_get_all_users" );
+ $self->{users} = $self->exec_method( procname=>"user__get_all_users" );
}
1;
Modified: trunk/UI/Admin/edit_group.html
===================================================================
--- trunk/UI/Admin/edit_group.html 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/UI/Admin/edit_group.html 2008-07-03 23:33:08 UTC (rev 2183)
@@ -2,16 +2,36 @@
<?lsmb IF user.username ?>
- <center><b>Edit User</b></center>
+ <center><b>Edit Group</b></center>
<?lsmb ELSE ?>
- <center><b>Create User</b></center>
+ <center><b>Create Group</b></center>
<?lsmb ENDIF ?>
<form name="submit_user" action="/admin.pl?">
-
-
+ <table>
+ <tr>
+ <td>Name:</td>
+ <td><input type="textarea" name="name" value="<?lsmb user.username?>"/></td>
+ </tr>
+ <tr>
+ <td>Description:</td>
+ <td><textarea cols="25" rows="4"><? lsmb user.description ?></textarea></td>
+ </tr>
+ </table>
+ <hr/>
+ <table>
+ <tr>
+ <?lsmb FOREACH group IN groups ?>
+ <?lsmb IF loop.count % 8 == 0?>
+ </tr>
+ <tr>
+ <?lsmb END?>
+ <td><input type="checkbox" name="<?lsmb loop.index?>" value="1"/><?lsmb group.rolname?></td>
+ <?lsmb END?>
+ </tr>
+ </table>
</form>
\ No newline at end of file
Modified: trunk/UI/Admin/edit_user.html
===================================================================
--- trunk/UI/Admin/edit_user.html 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/UI/Admin/edit_user.html 2008-07-03 23:33:08 UTC (rev 2183)
@@ -146,7 +146,21 @@
</table>
<table>
+
+ <!-- Groups section -->
<tr>
+ <?lsmb FOREACH group IN groups ?>
+ <?lsmb IF loop.count % 8 == 0?>
+ </tr>
+ <tr>
+ <?lsmb END?>
+ <td><input type="checkbox" name="<?lsmb loop.index?>" value="1"/><?lsmb group.rolname?></td>
+ <?lsmb END?>
+ </tr>
+ </table>
+
+ <table>
+ <tr>
<td><button value="new_user">Submit</button></td>
<td><button name="method" value="cancel">Cancel</td>
</tr>
Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/scripts/admin.pl 2008-07-03 23:33:08 UTC (rev 2183)
@@ -16,12 +16,13 @@
my $sal = $admin->get_salutations();
+ my $groups = $admin->get_roles();
+
if ($request->type() eq 'POST') {
# do the save stuff
- my $entity = $admin->save_user();
-
+ my $entity = $admin->save_new_user();
my $template = LedgerSMB::Template->new( user => $user,
template => 'Admin/edit_user', language => $user->{ language },
@@ -30,7 +31,8 @@
$template->render(
{
user=>$entity,
- salutations=> $sal
+ salutations=>$sal,
+ roles=>$groups
}
);
} else {
@@ -41,7 +43,8 @@
$template->render(
{
- salutations=>$sal
+ salutations=>$sal,
+ roles=>$groups
}
);
}
@@ -53,14 +56,38 @@
my ($class, $request) = @_;
my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'user_id');
- my $edited_user = $admin->get_entire_user();
- my $all_roles = $admin->role_list();
+ my $all_roles = $admin->get_roles();
+
+ my $template = LedgerSMB::Template->new(
+ user => $user,
+ template => 'Admin/edit_user',
+ language => $user->{language},
+ format => 'HTML',
+ path=>'UI'
+ );
- my $template = LedgerSMB::Template->new( user => $user,
- template => 'Admin/edit_user', language => $user->{language},
- format => 'HTML', path=>'UI');
-
- $template->render($edited_user, $all_roles);
+ if ($request->type() eq 'POST') {
+
+ $admin->save_user();
+ $admin->save_roles();
+ $template->render(
+ {
+ user=>$admin->get_entire_user(),
+ roles=>$all_roles,
+ user_roles=>$admin->get_user_roles($request->{username})
+ }
+ );
+ }
+ else {
+ my $edited_user = $admin->get_entire_user();
+ $template->render(
+ {
+ user=>$edited_user,
+ roles=>$all_roles,
+ user_roles=>$admin->get_user_roles($request->{username})
+ }
+ );
+ }
}
sub edit_group {
@@ -69,13 +96,33 @@
my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
my $all_roles = $admin->role_list();
- my $group = $admin->get_group();
- my $template = LedgerSMB::Template->new( user => $user,
- template => 'Admin/edit_group', language => $user->{language},
- format => 'HTML', path=>'UI');
+ my $template = LedgerSMB::Template->new(
+ user => $user,
+ template => 'Admin/edit_group',
+ language => $user->{language},
+ format => 'HTML',
+ path=>'UI'
+ );
- $template->render($all_roles);
+ if ($request->type() eq "POST") {
+
+ my $role = $admin->save_role();
+ return $template->render(
+ {
+ user=> $request->{role},
+ roles=>$all_roles,
+ user_roles=>$admin->get_user_roles($request->{role});
+ }
+ );
+ }
+ else {
+ return $template->render(
+ {
+ roles=>$all_roles
+ }
+ );
+ }
}
sub create_group {
@@ -83,13 +130,26 @@
my ($class, $request) = @_;
my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
- my $all_roles = $admin->role_list();
-
- my $template = LedgerSMB::Template->new( user => $user,
- template => 'Admin/edit_group', language => $user->{language},
- format => 'HTML', path=>'UI');
+ my $all_roles = $admin->get_roles();
+ my $template = LedgerSMB::Template->new(
+ user => $user,
+ template => 'Admin/edit_group',
+ language => $user->{language},
+ format => 'HTML',
+ path=>'UI'
+ );
+ if ($request->type() eq "POST") {
- $template->render($all_roles);
+ my $role = $admin->save_role();
+ return $template->render(
+ {
+ user=> $role, roles=>$all_roles
+ }
+ );
+ }
+ else {
+ return $template->render({roles=>$all_roles});
+ }
}
sub delete_group {
Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql 2008-07-01 23:34:41 UTC (rev 2182)
+++ trunk/sql/modules/admin.sql 2008-07-03 23:33:08 UTC (rev 2183)
@@ -7,7 +7,7 @@
);
-CREATE OR REPLACE FUNCTION admin_add_user_to_role(in_user TEXT, in_role TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__add_user_to_role(in_user TEXT, in_role TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -31,13 +31,13 @@
stmt := 'GRANT '|| quote_ident(in_role) ||' to '|| quote_ident(in_user);
EXECUTE stmt;
-
+ insert into lsmb_roles (user_id, role) values (in_user, in_role);
return 1;
END;
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_remove_user_from_role(in_user TEXT, in_role TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__remove_user_from_role(in_user TEXT, in_role TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -67,7 +67,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_add_function_to_group(in_func TEXT, in_role TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__add_function_to_group(in_func TEXT, in_role TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -97,7 +97,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_remove_function_from_group(in_func TEXT, in_role TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__remove_function_from_group(in_func TEXT, in_role TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -128,7 +128,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_add_table_to_group(in_table TEXT, in_role TEXT, in_perm TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__add_table_to_group(in_table TEXT, in_role TEXT, in_perm TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -165,7 +165,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_remove_table_from_group(in_table TEXT, in_role TEXT) returns INT AS $$
+CREATE OR REPLACE FUNCTION admin__remove_table_from_group(in_table TEXT, in_role TEXT) returns INT AS $$
declare
stmt TEXT;
@@ -198,7 +198,7 @@
$$ 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 TEXT) returns setof users as $$
DECLARE
a_user users;
@@ -215,7 +215,7 @@
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 TEXT) returns setof lsmb_roles as $$
declare
u_role lsmb_roles;
@@ -233,7 +233,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_save_user(
+CREATE OR REPLACE FUNCTION admin__save_user(
in_id int,
in_entity_id INT,
in_username text,
@@ -297,7 +297,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_group_name text) returns bool as $$
DECLARE
@@ -317,7 +317,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_create_group(in_group_name TEXT, in_dbname TEXT) RETURNS int as $$
+CREATE OR REPLACE FUNCTION admin__create_group(in_group_name TEXT, in_dbname TEXT) RETURNS int as $$
DECLARE
@@ -331,7 +331,7 @@
$$ language 'plpgsql';
-CREATE OR REPLACE FUNCTION admin_delete_user(in_username TEXT) returns INT as $$
+CREATE OR REPLACE FUNCTION admin__delete_user(in_username TEXT) returns INT as $$
DECLARE
stmt text;
@@ -361,7 +361,7 @@
Drops the provided user, as well as deletes the entity and user configuration data.
$$;
-CREATE OR REPLACE FUNCTION admin_delete_group (in_dbname TEXT, in_group_name TEXT) returns bool as $$
+CREATE OR REPLACE FUNCTION admin__delete_group (in_dbname TEXT, in_group_name TEXT) returns bool as $$
DECLARE
stmt text;
@@ -385,7 +385,7 @@
remove a login-capable user.
$$;
-CREATE OR REPLACE FUNCTION admin_list_roles(in_username text)
+CREATE OR REPLACE FUNCTION admin__list_roles(in_username text)
RETURNS SETOF text AS
$$
DECLARE out_rolename RECORD;
@@ -414,7 +414,7 @@
--$$ language plpgsql;
-create or replace function admin_is_user (in_user text) returns bool as $$
+create or replace function admin__is_user (in_user text) returns bool as $$
DECLARE
pg_user pg_roles;
@@ -431,15 +431,6 @@
$$ 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.