[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2332] trunk



Revision: 2332
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2332&view=rev
Author:   einhverfr
Date:     2008-09-22 22:41:32 +0000 (Mon, 22 Sep 2008)

Log Message:
-----------
Fixes to user management

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    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-09-22 21:45:11 UTC (rev 2331)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2008-09-22 22:41:32 UTC (rev 2332)
@@ -258,9 +258,10 @@
     
     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;

Modified: trunk/UI/Admin/edit_user.html
===================================================================
--- trunk/UI/Admin/edit_user.html	2008-09-22 21:45:11 UTC (rev 2331)
+++ trunk/UI/Admin/edit_user.html	2008-09-22 22:41:32 UTC (rev 2332)
@@ -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>

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2008-09-22 21:45:11 UTC (rev 2331)
+++ trunk/scripts/admin.pl	2008-09-22 22:41:32 UTC (rev 2332)
@@ -76,20 +76,20 @@
         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 @@
         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);
     }
 }
 

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2008-09-22 21:45:11 UTC (rev 2331)
+++ trunk/sql/modules/admin.sql	2008-09-22 22:41:32 UTC (rev 2332)
@@ -218,7 +218,7 @@
 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 @@
             r.oid = ar.roleid
          LOOP
         
-            RETURN NEXT u_role;
+            RETURN NEXT u_role.rolname;
         
         END LOOP;
         RETURN;
@@ -463,7 +463,7 @@
 
 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 @@
             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 @@
 END;
 $$ language plpgsql;
 
-commit;
\ No newline at end of file
+commit;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.