summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-22 22:41:32 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-22 22:41:32 +0000
commitfb3428428330dde7d2757317c4a7ac4e7e9a2e9b (patch)
tree13ab16aeba5f4260c75d021dc91caba935a5e9a0
parent61ea910a5ba61a7c5eed2d679d1f25c431c449a8 (diff)
Fixes to user management
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2332 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/DBObject/Admin.pm11
-rw-r--r--UI/Admin/edit_user.html15
-rw-r--r--scripts/admin.pl33
-rw-r--r--sql/modules/admin.sql10
4 files changed, 31 insertions, 38 deletions
diff --git a/LedgerSMB/DBObject/Admin.pm b/LedgerSMB/DBObject/Admin.pm
index 061cbd72..5ab869b0 100644
--- a/LedgerSMB/DBObject/Admin.pm
+++ b/LedgerSMB/DBObject/Admin.pm
@@ -258,9 +258,10 @@ sub get_countries {
my $self = shift @_;
- my $sth = $self->{dbh}->prepare("SELECT id, name FROM country");
- my $code = $sth->execute();
-
- return $sth->fetchall_arrayref( {} ); # returns an array of hashrefs.
+ @{$self->{countries}}
+ =$self->exec_method(funcname => 'location_list_country');
+ # returns an array of hashrefs.
+ $self->debug({file => '/tmp/user'});
+ return $self->{countries};
}
-1; \ No newline at end of file
+1;
diff --git a/UI/Admin/edit_user.html b/UI/Admin/edit_user.html
index 6128e527..ebaaad93 100644
--- a/UI/Admin/edit_user.html
+++ b/UI/Admin/edit_user.html
@@ -1,3 +1,5 @@
+<?lsmb INCLUDE 'ui-header.html' ?>
+<?lsmb PROCESS 'elements.html' ?>
<div id="modify_user">
<font size="15">
<strong>
@@ -136,11 +138,12 @@
<input type="textarea" name="zipcode" value="<?lsmb location.zipcode?>"/>
</td>
<td valign="top">
- <select name="country">
- <?lsmb FOREACH country IN countries?>
- <option value="<?lsmb country.id?>"><?lsmb country.name?></option>
- <?lsmb END?>
- </select>
+ <?lsmb PROCESS select element_data = {
+ name = "country"
+ options = countries
+ value_attr = "id"
+ text_attr = "name"
+ } ?>
</td>
</tr>
<tr>
@@ -242,4 +245,4 @@
</tr>
</table>
<?lsmb END?>
-</div> \ No newline at end of file
+</div>
diff --git a/scripts/admin.pl b/scripts/admin.pl
index a9e11177..9a09f40f 100644
--- a/scripts/admin.pl
+++ b/scripts/admin.pl
@@ -76,20 +76,20 @@ sub edit_user {
path=>'UI'
);
+ my $template_data =
+ {
+ user=>$user,
+ roles=>@all_roles,
+ countries=>$admin->get_countries(),
+ user_roles=>$user->{roles},
+ salutations=>$admin->get_salutations(),
+ locations=>$location->get_all($u_id,"person"),
+ };
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}),
- salutations=>$admin->get_salutations(),
- locations=>$location->get_all($u_id,"person"),
- countries=>$admin->get_countries(),
- }
- );
+ $template->render($test_data);
}
else {
# print STDERR Dumper($user);
@@ -99,18 +99,7 @@ sub edit_user {
if ($request->{location_id}) {
$loc = $location->get($request->{location_id});
}
- print STDERR Dumper($admin->get_salutations());
- $template->render(
- {
- user=>$user,
- roles=>@all_roles,
- user_roles=>$user->{roles},
- salutations=>$admin->get_salutations(),
- location=>$loc,
- locations=>$location->get_all($u_id,"person"),
- countries=>$admin->get_countries(),
- }
- );
+ $template->render($template_data);
}
}
diff --git a/sql/modules/admin.sql b/sql/modules/admin.sql
index 1055ff29..5e72a280 100644
--- a/sql/modules/admin.sql
+++ b/sql/modules/admin.sql
@@ -218,7 +218,7 @@ $$ language plpgsql;
create or replace function admin__get_roles_for_user(in_user_id INT) returns setof text as $$
declare
- u_role text;
+ u_role record;
a_user users;
begin
select * into a_user from admin__get_user(in_user_id);
@@ -240,7 +240,7 @@ create or replace function admin__get_roles_for_user(in_user_id INT) returns set
r.oid = ar.roleid
LOOP
- RETURN NEXT u_role;
+ RETURN NEXT u_role.rolname;
END LOOP;
RETURN;
@@ -463,7 +463,7 @@ $$ language sql;
create or replace function admin__get_roles (in_database text) returns setof text as $$
DECLARE
- v_rol text;
+ v_rol record;
BEGIN
FOR v_rol in
SELECT
@@ -474,7 +474,7 @@ BEGIN
rolname ~ ('^lsmb_' || in_database)
order by rolname ASC
LOOP
- RETURN NEXT v_rol;
+ RETURN NEXT v_rol.rolname;
END LOOP;
END;
$$ language plpgsql;
@@ -495,4 +495,4 @@ BEGIN
END;
$$ language plpgsql;
-commit; \ No newline at end of file
+commit;