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

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



Revision: 3607
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3607&view=rev
Author:   einhverfr
Date:     2011-07-31 01:49:47 +0000 (Sun, 31 Jul 2011)

Log Message:
-----------
Delete user now working

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/scripts/admin.pl
    trunk/sql/modules/admin.sql

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2011-07-30 20:00:39 UTC (rev 3606)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2011-07-31 01:49:47 UTC (rev 3607)
@@ -133,6 +133,22 @@
     
 }
 
+=item delete_user($delete_role)
+
+Deletes a user specified by $self->{user_id}.
+
+if $delete_role is true, deletes the role too.
+
+=cut
+
+sub delete_user {
+    my ($self, $delete_role) = @_;
+    $self->{drop_role} = $delete_role;
+    $self->exec_method({funcname => 'admin__delete_user'});
+    return $self->{dbh}->commit;
+
+}
+
 =item search_users
 
 Returns a list of users matching search criteria, and attaches that list to the 

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2011-07-30 20:00:39 UTC (rev 3606)
+++ trunk/scripts/admin.pl	2011-07-31 01:49:47 UTC (rev 3607)
@@ -211,27 +211,12 @@
 
 =cut
 
-# XXX Rewrite! --CT
 sub delete_user {
-    
     my ($request) = @_;
-    my $user = $request->{_user};
-    
-    my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
-    
-    # requires the field modifying_user to be set.
-    
-    my $status = $admin->delete_user($request->{modifying_user});
-    
-    # status can either be 1, or an error.
-    # if there's an error, $status->throw() is called by admin.pm. Or possibly
-    # in the template itself.
-    
-    my $template = LedgerSMB::Template->new ( user=>$user, 
-        template=>'Admin/delete_user', language=>$user->{language}, 
-        format=>'HTML', path=>'UI');
-        
-    $template->render($status);
+    my $admin = LedgerSMB::DBObject::Admin->new({base => $request});
+    $admin->delete_user($request->{delete_user});
+    delete $request->{username};
+    search_users($request); 
 }
 
 =item save_contact
@@ -417,7 +402,7 @@
             path=>'UI'
     );
     my $columns;
-    @$columns = qw(id username first_name last_name ssn dob edit);
+    @$columns = qw(id username first_name last_name ssn dob edit remove drop);
     
     my $column_names = {
         id => 'ID',
@@ -431,13 +416,21 @@
     
     my $rows = [];
     my $rowcount = "0";
-    my $base_url = "admin.pl?action=edit_user";
+    my $base_url = "admin.pl";
     for my $u (@users) {
         $u->{i} = $rowcount % 2;
         $u->{edit} = {
-            href =>"$base_url&user_id=$u->{id}", 
+            href =>"$base_url?action=edit_user&user_id=$u->{id}", 
             text => '[' . $request->{_locale}->text('edit') . ']',
         };
+        $u->{remove} = {
+            href => "$base_url?action=delete_user&username=$u->{username}",
+            text => '[' . $request->{_locale}->text('Delete') . ']',
+        };
+        $u->{drop} = {
+           href=>"$base_url?action=delete_user&username=$u->{username}&delete_role=1",
+           text=>'[' . $request->{_locale}->text('Drop from All') . ']',
+        };
         push @$rows, $u;
         ++$rowcount;
     }

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2011-07-30 20:00:39 UTC (rev 3606)
+++ trunk/sql/modules/admin.sql	2011-07-31 01:49:47 UTC (rev 3607)
@@ -490,9 +490,6 @@
             delete from user_preference where id = (
                    select id from users where entity_id = a_user.entity_id);
             delete from users where entity_id = a_user.entity_id;
-            delete from person where entity_id = a_user.entity_id;
-            delete from entity_employee where entity_id = a_user.entity_id;
-            delete from entity where id = a_user.entity_id;
             return 1;
         END IF;   
     END;


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