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

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



Revision: 1869
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1869&view=rev
Author:   aurynn_cmd
Date:     2007-11-15 15:10:31 -0800 (Thu, 15 Nov 2007)

Log Message:
-----------
Significant work on the Entity and Administrative code. It's buggy, so please test, etc. thoroughly.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/LedgerSMB/DBObject/Customer.pm
    trunk/LedgerSMB/DBObject/User.pm
    trunk/LedgerSMB/Employee.pm
    trunk/LedgerSMB/Vendor.pm
    trunk/UI/Admin/main.html
    trunk/UI/get_password.html
    trunk/UI/login.js
    trunk/lsmb-request.pl
    trunk/scripts/admin.pl
    trunk/scripts/customer.pl
    trunk/scripts/login.pl
    trunk/sql/modules/admin.sql

Added Paths:
-----------
    trunk/LedgerSMB/Entity.pm

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -5,6 +5,7 @@
 use LedgerSMB::Location;
 use LedgerSMB::DBObject::Employee;
 use LedgerSMB::Contact;
+use LedgerSMB::Entity;
 
 #[18:00:31] <aurynn> I'd like to split them employee/user and roles/prefs
 #[18:00:44] <aurynn> edit/create employee and add user features if needed.
@@ -18,19 +19,27 @@
     
     my $self = shift @_;
     
-    my $entity_id = shift @{ $self->exec_method( procname => "save_user" ) };
-    $self->merge($entity_id);
+    my $entity = LedgerSMB::DBObject::Entity->new(base=>$self, copy=>'none');
     
-    my $person = LedgerSMB::DBObject::Person->new(base=>$self, copy=>'list',     
+    $entity->set(name=>$self->{first_name}." ".$self->{last_name});
+    $entity->save();
+    
+    $self->{entity_id} = $entity->{id};
+    
+    
+    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',     
         merge=>[
             'salutation',
             'first_name',
             'last_name',
         ]
     );
-    my $employee = LedgerSMB::DBObject::Employee->new(base=>$self, copy=>'list',
+    my $employee = LedgerSMB::DBObject::Employee->new( base=>$self, copy=>'list',
         merge=>[
-            '',
+            'salutation',
             'first_name',
             'last_name',
             'employeenumber',
@@ -76,16 +85,15 @@
             'is_a_user'
         ]
     );
-    
     $user->get();
     $user->save();
 }
 
-sub save_roles {
+sub save_roles_preferences {
     
     my $self = shift @_;
     
-    my $user = LedgerSMB::DBObject::User->new(base=>$self, copy=>'all');
+    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 } ] );

Modified: trunk/LedgerSMB/DBObject/Customer.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Customer.pm	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/LedgerSMB/DBObject/Customer.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -1,33 +1,47 @@
 package LedgerSMB::DBObject::Customer;
 
-use base qw(LedgerSMB);
+use base qw(LedgerSMB::DBObject::Company);
 use LedgerSMB::DBObject;
+use LedgerSMB::Entity;
 
-sub save_to_db {
+sub save {
     
+    # this is doing way too much.
+    
     my $self = shift @_;
     
-    my $id;
-    if ($self->{id} >= 1) {
-        $id = $self->{id};
+    my $entity;
+    
+    # this is a fairly effective way of telling if we need to create a new
+    # entity or not.
+    
+    if (!$self->{entity_id}) {
+        
+        $entity = LedgerSMB::Entity->new(base=>$request);
     }
     else {
-        $id = $self->next_customer_id();
+        
+        $entity = LedgerSMB::Entity->get(id=>$self->{entity_id});
     }
-    $id = $self->save($id, $self->{discount}, $self->{tax_included}, 
-        $self->{creditlimit}, $self->{terms}, $self->{customernumber}, 
-        $self->{cc}, $self->{bcc}, $self->{business_id}, $self->{language},
-        $self->{pricegroup}, $self->{currency}, $self->{startdate}, 
-        $self->{enddate}
-    );
     
-    # Undef in the created field causes the system to use now() as the current
-    # creation date.
-    $self->location_save(
-        $id, 1, $self->{line_one}, $self->{line_two}, $self->{line_three},
-        $self->{city_province}, $self->{mailing_code}, $self->{country}, undef
+    $entity->set(name=> $reqeust->{first_name}." ".$request->{last_name} );
+    $entity->set(entity_class=>2);
+
+    $self->set(entity_id=>$entity->{id});
+    $self->set(entity_class=> 2);
+    
+    $entity->save();
+    if (!self->{entity_id}) {
         
-    );
-    return $id;
+        $self->{entity_id} = $entity->{id};
+    }
+    $self->SUPER::save();
+    
+    return $self->{id};
 }
+
+sub search {
+    
+    
+}
 1;
\ No newline at end of file

Modified: trunk/LedgerSMB/DBObject/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/User.pm	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/LedgerSMB/DBObject/User.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -8,13 +8,13 @@
     
     my $user = $self->get();
     
-    if ($user->{id} && $self->{is_a_user}) {
+    if ( $user->{id} && $self->{is_a_user} ) {
     
         # doesn't check for the password - that's done in the sproc.
-        $self->{id} = @{ $self->exec_method(procname=>'admin_save_user', 
-            args=>[$user->{id}, $self->{username}, $self->{password}] ) }[0]; 
-        else {
-        
+        $self->{id} = shift @{ $self->exec_method(procname=>'admin_save_user', 
+            args=>[$user->{id}, $self->{username}, $self->{password}] ) }; 
+        if (!$self->{id}) {
+            
             return 0;
         }
     }
@@ -26,6 +26,12 @@
         return $self->remove();
         
     }
+    elsif ($self->{is_a_user}) {
+        
+        # No user ID, meaning, creating a new one.        
+        $self->{id} = shift @{ $self->exec_method(procname=>'admin_save_user', 
+            args=>[undef, $self->{username}, $self->{password}] ) };
+    }
     return 1;
 }
 
@@ -49,4 +55,26 @@
     return $code->[0];
 }
 
+sub save_prefs {
+    
+    my $self = shift @_; 
+    
+    my $pref_id = $self->exec_method(procname=>"admin_save_preferences", 
+        args=>[
+            'language',
+            'stylesheet',
+            'printer',
+            'dateformat',
+            'numberformat'
+        ]
+    );
+}
+
+sub get_all_users {
+    
+    my $self = shift @_;
+    
+    $self->{users} = $self->exec_method( procname=>"user_get_all_users" );
+}
+
 1;
\ No newline at end of file

Modified: trunk/LedgerSMB/Employee.pm
===================================================================
--- trunk/LedgerSMB/Employee.pm	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/LedgerSMB/Employee.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -48,10 +48,7 @@
 
 sub save {
     my $self = shift;
-    
-    my $person = shift @{ $self->exec_method (procname => 'person_save', 
-        args => [] )};
-    
+        
     my $hashref = shift @{ $self->exec_method( procname => "employee_save" ) };
     $self->merge( $hashref, 'id' );
 }

Added: trunk/LedgerSMB/Entity.pm
===================================================================
--- trunk/LedgerSMB/Entity.pm	                        (rev 0)
+++ trunk/LedgerSMB/Entity.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -0,0 +1,43 @@
+package LedgerSMB::Entity;
+
+use base qw/LedgerSMB::DBObject/;
+
+sub save {
+    
+    my $self = shift @_;
+    
+    my $id = @{ $self->exec_method(procname=>'entity_save', 
+        args=>[
+            $self->{name},
+            $self->{entity_class},
+        ]
+    )};
+    
+    $self->{id} = shift @{ $id };
+    return $self->{id};
+}
+
+sub get {
+    
+    my $self = shift @_;
+    
+    my $hashref = $self->exec_method(procname=>'entity_get', args=>[$self->{id}]);
+    $self->merge($hashref);
+    return $self->{id};
+    
+}
+
+sub search {
+    
+    # Shouldn't really be necessary.. 
+    
+    # anyway, Search on name.
+    my $self = shift @_;
+    
+    my @list = @{ $self->exec_method( procname=>'entity_search', 
+        args=>[ 
+            $self->{name}
+        ]
+    ) };
+}
+1;
\ No newline at end of file

Modified: trunk/LedgerSMB/Vendor.pm
===================================================================
--- trunk/LedgerSMB/Vendor.pm	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/LedgerSMB/Vendor.pm	2007-11-15 23:10:31 UTC (rev 1869)
@@ -1,33 +1,39 @@
 package LedgerSMB::DBObject::Vendor;
 
-use base qw(LedgerSMB);
+use base qw(LedgerSMB::DBObject::Company);
 use LedgerSMB::DBObject;
 
-sub save_to_db {
-    
+sub save {
     my $self = shift @_;
     
-    my $id;
-    if ($self->{id} >= 1) {
-        $id = $self->{id};
+    my $entity;
+    
+    # this is a fairly effective way of telling if we need to create a new
+    # entity or not.
+    
+    if (!$self->{entity_id}) {
+        
+        $entity = LedgerSMB::Entity->new(base=>$request);
     }
     else {
-        $id = $self->next_vendor_id();
+        
+        $entity = LedgerSMB::Entity->get(id=>$self->{entity_id});
     }
-    $id = $self->save($id, $self->{discount}, $self->{tax_included}, 
-        $self->{creditlimit}, $self->{terms}, $self->{vendornumber}, 
-        $self->{cc}, $self->{bcc}, $self->{business_id}, $self->{language},
-        $self->{pricegroup}, $self->{currency}, $self->{startdate}, 
-        $self->{enddate}
-    );
     
-    # Undef in the created field causes the system to use now() as the current
-    # creation date.
-    $self->location_save(
-        $id, 1, $self->{line_one}, $self->{line_two}, $self->{line_three},
-        $self->{city_province}, $self->{mailing_code}, $self->{country}, undef
+    $entity->set(name=> $reqeust->{first_name}." ".$request->{last_name} );
+    $entity->set(entity_class=>2);
+
+    $self->set(entity_id=>$entity->{id});
+    $self->set(entity_class=> 1);
+    
+    $entity->save();
+    if (!self->{entity_id}) {
         
-    );
-    return $id;
+        $self->{entity_id} = $entity->{id};
+    }
+    $self->SUPER::save();
+    
+    return $self->{id};
+
 }
 1;
\ No newline at end of file

Modified: trunk/UI/Admin/main.html
===================================================================
--- trunk/UI/Admin/main.html	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/UI/Admin/main.html	2007-11-15 23:10:31 UTC (rev 1869)
@@ -19,7 +19,7 @@
             <td>Date Added</td>
         </tr>
 
-    <?lsmb FOREACH user = users.all ?>
+    <?lsmb FOREACH user = users ?>
     
         <tr>
             <td></td>

Modified: trunk/UI/get_password.html
===================================================================
--- trunk/UI/get_password.html	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/UI/get_password.html	2007-11-15 23:10:31 UTC (rev 1869)
@@ -7,17 +7,27 @@
 	<meta http-equiv="Expires" content="-1" />
 	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
 	<link rel="stylesheet" href="css/<?lsmb stylesheet ?>" type="text/css" />
+	
 
 	<meta http-equiv="content-type" 
 		content="text/html; charset=utf-8" />	
 	<meta name="robots" content="noindex,nofollow" />
-<script language="JavaScript" type="text/javascript">
-<!--
-function focus_input(){
-    document.getpassword.password.focus();
-}
-// End -->
-</script>
+	<script language="JavaScript" type="text/javascript" src="UI/login.js" />
+	
+    <script language="JavaScript" type="text/javascript">
+        <!--
+        function focus_input(){
+            document.getpassword.password.focus();
+        }
+        // End -->
+    </script>
+    <style>
+        div.admin_login {
+        
+            align: center;
+        }
+    
+    </style>
 </head>
 <body onload="focus_input()">
 <?lsmb IF sessionexpired ?>
@@ -25,13 +35,13 @@
 	<?lsmb text('Session expired!') ?>
 	</span></p>
 <?lsmb END ?>
-<form method="post" action="<?lsmb script ?>" name="getpassword">
+<form method="post" action="<?lsmb script?>.pl" name="getpassword">
 
-<div>
+<div class="admin_login">
     <span align=right class="label"> <?lsmb text('Password')  ?> </span>
     <span class="input"><input type="password" name="password" size="30"/>
     </span>
-    <span class="input"><button type="submit" value="continue">
+    <span class="input"><button type="submit" name="action" value="continue">
       <?lsmb text('Continue') ?>
     </button></span>
 </div>

Modified: trunk/UI/login.js
===================================================================
--- trunk/UI/login.js	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/UI/login.js	2007-11-15 23:10:31 UTC (rev 1869)
@@ -11,7 +11,7 @@
 
 function submit_form() {
 	var http = get_http_request_object();
-        var username = document.login.login.value;
+    var username = document.login.login.value;
 	var password = document.login.password.value;
 	http.open("get", 'login.pl?action=authenticate&company='
 		+ document.login.company.value, false, 
@@ -25,3 +25,15 @@
 	document.location = document.login.action + "?action=login&company="+
 		documnet.login.company.value;
 }
+
+function check_auth() {
+    
+    var http = get_http_request_object();
+    var username = "admin";
+    var password = document.login.password.value;
+    
+    http.open("get", "login.pl?action=authenticate&company="
+        + document.login.company.value, false, 
+		username, password
+    );
+}
\ No newline at end of file

Modified: trunk/lsmb-request.pl
===================================================================
--- trunk/lsmb-request.pl	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/lsmb-request.pl	2007-11-15 23:10:31 UTC (rev 1869)
@@ -47,13 +47,21 @@
 	$request->error($locale->text('No workflow script specified'));
 }
 
-eval { require "scripts/$script" } 
-  || $request->error($locale->text('Unable to open script') . ": scripts/$script : $!");
+&call_script( $script, $request );
 
-$script =~ s/\.pl$//;
-$script = "LedgerSMB::Scripts::$script";
-$script->can($request->{action}) 
-  || $request->error($locale->text("Action Not Defined: ") . $request->{action});
+sub call_script {
+    
+    my $script = shift @_;
+    my $request = shift @_;
 
-$script->can( $request->{action} )->($request);
+    eval { require "scripts/$script" } 
+      || $request->error($locale->text('Unable to open script') . ": scripts/$script : $!");
+
+    $script =~ s/\.pl$//;
+    $script = "LedgerSMB::Scripts::$script";
+    $script->can($request->{action}) 
+      || $request->error($locale->text("Action Not Defined: ") . $request->{action});
+
+    $script->can( $request->{action} )->($request);
+}
 1;

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/scripts/admin.pl	2007-11-15 23:10:31 UTC (rev 1869)
@@ -5,6 +5,7 @@
 
 use LedgerSMB::Template;
 use LedgerSMB::DBObject::Admin;
+use LedgerSMB::DBObject::User;
 
 sub new_user {
     
@@ -23,7 +24,7 @@
 
         
         my $template = LedgerSMB::Template->new( user => $user, 
-    	template => 'Admin/edit_user', language => $user->{language}, 
+    	template => 'Admin/edit_user', language => $user->{ language }, 
             format => 'HTML', path=>'UI');
     
         $template->render(
@@ -153,11 +154,14 @@
     
     my ($class, $request) = @_;
     
-    # TODO: check for login stuff.
     my $template;
+    my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'all');
+    
+    $user->get_all_users();
+    
     $template = LedgerSMB::Template->new( user=>$user, 
             template=>'Admin/main', language=>$user->{language},
             format=>'HTML', path=>'UI');
-    $template->render();
+    $template->render($user);
 }
 1;
\ No newline at end of file

Modified: trunk/scripts/customer.pl
===================================================================
--- trunk/scripts/customer.pl	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/scripts/customer.pl	2007-11-15 23:10:31 UTC (rev 1869)
@@ -44,11 +44,13 @@
 sub get {
     
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
-    my $result = $customer->get($customer->{id});
+    my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
     
+    $customer->set( entity_class=> '2' );
+    my $result = $customer->get();
+    
     my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'customer.html', language => $user->{language}, 
+	template => 'Customer/customer.html', language => $user->{language}, 
         format => 'html');
     $template->render($results);
         
@@ -68,10 +70,10 @@
 
 sub add {
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
-    
+    my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+    $customer->set(entity_class=>2);
     my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'customer.html', language => $user->{language}, 
+	template => 'Customer/customer.html', language => $user->{language}, 
         format => 'html');
     $template->render($results);
 }
@@ -94,13 +96,30 @@
 
 sub search {
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
-    my $results = $customer->search($customer->{search_pattern});
     
-    my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'customer_search.html', language => $user->{language}, 
-        format => 'html');
-    $template->render($results);
+    if ($request->type() eq 'POST') {
+        # assume it's asking us to do the search, now
+        
+        my $customer = LedgerSMB::DBObject::Company->new(base => $request, copy => 'all');
+        $customer->set(entity_class=>2);
+        my $results = $customer->search($customer->{search_pattern});
+
+        my $template = LedgerSMB::Template->new( user => $user, 
+    	template => 'Customer/customer.html', language => $user->{language}, 
+            format => 'html');
+        $template->render($results);
+        
+    }
+    else {
+        
+        # grab the happy search page out.
+        
+        my $template = LedgerSMB::Template->new( user => $user, 
+    	template => 'Customer/customer_search.html', language => $user->{language}, 
+            format => 'html');
+            
+        $template->render();
+    }
 }
 
 =pod
@@ -119,13 +138,26 @@
 sub save {
     
     my ($request) = @_;
-    my $customer = LedgerSMB::DBObject::Customer->new(base => $request, copy => 'all');
-    my $result = $customer->save_to_db();
     
-    my $template = LedgerSMB::Template->new( user => $user, 
-	template => 'customer.html', language => $user->{language}, 
-        format => 'html');
-    $template->render($result);    
+    if ($request->type() == 'POST') {
+        
+        my $customer = LedgerSMB::DBObject::Customer->get(base=>$request, copy=>'all');
+        
+        unless ($customer) {
+            
+            $customer = LedgerSMB::DBObject::Customer->new(base=>$reqest, copy=>'all');
+        }
+        
+        my $result = $customer->save();
+
+        my $template = LedgerSMB::Template->new( user => $user, 
+    	template => 'Customer/customer.html', language => $user->{language}, 
+            format => 'html');
+        $template->render($result);
+    } 
+    else {
+        
+    }
 }
 
 1;

Modified: trunk/scripts/login.pl
===================================================================
--- trunk/scripts/login.pl	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/scripts/login.pl	2007-11-15 23:10:31 UTC (rev 1869)
@@ -7,13 +7,18 @@
 use LedgerSMB::Auth;
 use strict;
 
+# this is kind of silly, as it doesn't check if someone IS trying to log in.
+# If one looks at the login template (get_password.html), it does not post
+# to any action, so this code will always get called, thereby preventing
+# anyone from actually logging in.
+
 sub __default {
    my ($request) = @_;
     my $locale;
     $locale = LedgerSMB::Locale->get_handle(${LedgerSMB::Sysconfig::language})
       or $request->error( __FILE__ . ':' . __LINE__ . 
-         ": Locale not loaded: $!\n" );
-    my $template = LedgerSMB::Template->new(
+         ": Locale not loaded: $!\n" );         
+     my $template = LedgerSMB::Template->new(
         user =>$request->{_user}, 
         locale => $locale,
         path => 'UI',
@@ -23,6 +28,8 @@
     $template->render($request);
 }
 
+# Directly printing like this is made of fail.
+
 sub authenticate {
     my ($request) = @_;
     if (!$request->{dbh}){
@@ -33,10 +40,20 @@
     }
     my $path = $ENV{SCRIPT_NAME};
     $path =~ s|[^/]*$||;
-    if ($request->{dbh} || $request->{log_out}){
+    
+    if ($request->{dbh} && $request->{next}) {
+        
         print "Content-Type: text/html\n";
         print "Set-Cookie: LedgerSMB=Login; path=$path\n";
-	print "Status: 200 Success\n\n";
+	    print "Status: 302 Found\n";
+	    print "Location: ".$path.$request->{next}."\n";
+	    print "\n";
+	    exit;	    
+    }
+    elsif ($request->{dbh} || $request->{log_out}){
+        print "Content-Type: text/html\n";
+        print "Set-Cookie: LedgerSMB=Login; path=$path\n";
+	    print "Status: 200 Success\n\n";
         if ($request->{log_out}){
             exit;
         }
@@ -44,7 +61,7 @@
     else {
         print "WWW-Authenticate: Basic realm=\"LedgerSMB\"\n";
         print "Status: 401 Unauthorized\n\n";
-	print "Please enter your credentials.\n";
+	    print "Please enter your credentials.\n";
         exit; 
     }
 }
@@ -69,5 +86,23 @@
     print "Content-type: text/html\n\n";
     exit;
 }
+
+sub continue {
     
+    my ($request) = @_;
+    
+    if ($request->{next} && $request->{password}) {
+                
+        $request->{user} = "admin";
+        
+        if (&authenticate($request)) {
+#            LedgerSMB::Handler::call_script();
+        }
+    }
+    else {
+        # well, wtf? This is kind of useless.
+        $request->error("Cannot continue to a Nonexistent page.");
+    }
+}
+    
 1;

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2007-11-14 17:23:29 UTC (rev 1868)
+++ trunk/sql/modules/admin.sql	2007-11-15 23:10:31 UTC (rev 1869)
@@ -264,11 +264,13 @@
             -- create an actual user
             
             v_user_id := nextval('users_id_seq');
-            insert into users (id, name, entity_id) VALUES (
+            insert into users (id, username, entity_id) VALUES (
                 v_user_id,
                 in_username,
                 in_entity_id
             );
+            
+            insert into user_preference (id) values (v_user_id);
 
             -- Finally, issue the create user statement
             
@@ -412,4 +414,47 @@
     
 --$$ language plpgsql;
 
+create or replace function admin_is_user (in_user text) returns bool as $$
+    DECLARE
+        pg_user pg_roles;
+    
+    BEGIN
+    
+        select * into pg_user from pg_roles where rolname = in_user;
+        
+        IF NOT FOUND THEN
+            return 'f'::bool;
+        END IF;
+        return 't'::bool;
+    
+    END;
+    
+$$ 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 
+        u.id,
+        u.username,
+        e.created
+    from entity e
+    join users u on u.entity_id = e.id;
+        
+
+create or replace function user_get_all_users () returns setof user_listable as $$
+    
+    select * from user_listable;
+    
+$$ language sql;
+
+
 commit;
\ No newline at end of file


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