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

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



Revision: 2687
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2687&view=rev
Author:   einhverfr
Date:     2009-06-16 05:53:27 +0000 (Tue, 16 Jun 2009)

Log Message:
-----------
Session management works too

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	2009-06-16 05:36:38 UTC (rev 2686)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2009-06-16 05:53:27 UTC (rev 2687)
@@ -99,6 +99,18 @@
    return @users;
 }
 
+sub list_sessions {
+   my $self = shift @_;
+   my @sessions = $self->exec_method(funcname => 'admin__list_sessions');
+   $self->{active_sessions} = ..hidden..;
+   return @sessions;
+}
+
+sub delete_session {
+   my $self = shift @_;
+   my @sessions = $self->exec_method(funcname => 'admin__drop_session');
+   return $self->{dbh}->commit;
+}
 sub save_roles {
     
     my $self = shift @_;

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2009-06-16 05:36:38 UTC (rev 2686)
+++ trunk/scripts/admin.pl	2009-06-16 05:53:27 UTC (rev 2687)
@@ -435,9 +435,54 @@
 }
 
 sub list_sessions {
+    my ($request) = @_;
+    my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
+    my @sessions = $admin->list_sessions();
+    my $template = LedgerSMB::Template->new(
+            user => $request->{_user}, 
+            template => 'form-dynatable', 
+            locale => $request->{_locale}, 
+            format => 'HTML', 
+            path=>'UI'
+    );
+    my $columns;
+    @$columns = qw(id username last_used locks_active drop);
+    $column_headers = {
+        id         => $request->{_locale}->text('ID'),
+        username   => $request->{_locale}->text('Username'),
+        last_used => $request->{_locale}->text('Last Used'),
+        locks_active  => $request->{_locale}->text('Transactions Locked'),
+
+    };
+    my $rows = [];
+    my $rowcount = "0";
+    my $base_url = "admin.pl?action=delete_session";
+    for my $s (@sessions) {
+        $s->{i} = $rowcount % 2;
+        $s->{drop} = {
+            href =>"$base_url&session_id=$s->{id}", 
+            text => '[' . $request->{_locale}->text('delete') . ']',
+        };
+        push @$rows, $s;
+        ++$rowcount;
+    }
+    $admin->{title} = $request->{_locale}->text('Active Sessions');
+    $template->render({
+	form    => $admin,
+	columns => $columns,
+	heading => $column_headers,
+        rows    => $rows,
+	buttons => [],
+	hiddens => [],
+    }); 
+    
 }
 
 sub delete_session {
+    my ($request) = @_;
+    my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
+    $admin->delete_session();
+    list_sessions($request);
 }
 
 1;

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2009-06-16 05:36:38 UTC (rev 2686)
+++ trunk/sql/modules/admin.sql	2009-06-16 05:53:27 UTC (rev 2687)
@@ -657,10 +657,10 @@
 ORDER BY u.username;
 $$ LANGUAGE SQL;
 
-CREATE OR REPLACE FUNCTION admin__drop_session(in_id) RETURNS bool AS
+CREATE OR REPLACE FUNCTION admin__drop_session(in_session_id int) RETURNS bool AS
 $$
 BEGIN
-	DELETE FROM "session" WHERE session_id = in_id;
+	DELETE FROM "session" WHERE session_id = in_session_id;
 	RETURN FOUND;
 END;
 $$ language plpgsql;


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