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

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



Revision: 3604
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3604&view=rev
Author:   einhverfr
Date:     2011-07-30 19:21:47 +0000 (Sat, 30 Jul 2011)

Log Message:
-----------
scripts/admin.pl docstrings and cleanup.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/scripts/admin.pl

Removed Paths:
-------------
    trunk/UI/Admin/main.html

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2011-07-30 17:47:32 UTC (rev 3603)
+++ trunk/LedgerSMB/DBObject/Company.pm	2011-07-30 19:21:47 UTC (rev 3604)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Company.pm, LedgerSMB Base Class for Customers/Vendors
+LedgerSMB::DBObject::Company.pm
 
 =head1 SYNOPSIS
 
@@ -9,6 +9,16 @@
 
 =cut
 
+# This module has the following problems associated with it which need to be 
+# revised.
+#
+# 1)  The data in this module is too free-form.  There needs to be more 
+# structure, and that probably requires breaking it out into a Location.pm, 
+# Contact.pm, Notes.pm, etc.
+#
+# 2)  The current code ties the company to the credit account too much.  This
+# needs to be separated. --CT
+
 package LedgerSMB::DBObject::Company;
 
 use LedgerSMB::Setting;

Deleted: trunk/UI/Admin/main.html
===================================================================
--- trunk/UI/Admin/main.html	2011-07-30 17:47:32 UTC (rev 3603)
+++ trunk/UI/Admin/main.html	2011-07-30 19:21:47 UTC (rev 3604)
@@ -1,49 +0,0 @@
-<div class="admin">
-    
-    <!-- first, a list of all active users -->
-    
-    <center>
-        <strong><font size="16"> Administration</font></strong>
-    </center>
-    
-    <?lsmb IF message?>
-        <strong><font color="red"><?lsmb message?></font></strong>
-    <?lsmb END?>
-    <form name="userlist" method="GET" action="admin.pl">    
-    <table>
-        <tr>
-            <td></td>
-            <td>Username</td>
-            <td>Active</td>
-            <td>Date Added</td>
-        </tr>
-
-    <?lsmb FOREACH user = users ?>
-    
-        <tr>
-            <td></td>
-            <td>
-                <a href="admin.pl?action=edit_user&amp;user_id=<?lsmb user.id?>">
-                <?lsmb user.username?>
-                </a>
-            </td>
-            <td>
-                <?lsmb user.active?>
-            </td>
-            <td>
-                <?lsmb user.creation_date?>
-            </td>
-            
-        </tr>    
-    <?lsmb END?>
-    </table>
-    
-    <hr/>
-    <div class="buttons">
-        <button name="action" value="new_user">New User</button>
-        <button name="action" value="new_group">New Group</button>
-        <button name="action" value="delete_user">Delete User</button>
-        <button name="action" value="delete_group">Delete Group</button>
-    </div>    
-    </form>
-</div>
\ No newline at end of file

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2011-07-30 17:47:32 UTC (rev 3603)
+++ trunk/scripts/admin.pl	2011-07-30 19:21:47 UTC (rev 3604)
@@ -2,6 +2,22 @@
 package LedgerSMB::Scripts::admin;
 use strict;
 
+=pod
+
+=head1 NAME
+
+LedgerSMB:Scripts::admin
+
+=head1 SYNOPSIS
+
+This module provides the workflow scripts for managing users and permissions.
+    
+=head1 METHODS
+        
+=over   
+        
+=cut
+
 require 'lsmb-request.pl';
 
 use LedgerSMB::Template;
@@ -12,8 +28,15 @@
 use LedgerSMB::Setting;
 use LedgerSMB::Log;
 
+# I don't really like the code in this module.  The callbacks are per form which
+# means there is no semantic difference between different buttons that can be 
+# clicked.  This results in a lot of code with a lot of conditionals which is
+# both difficult to read and maintain.  In the future, this should be revisited
+# and rewritten.  It makes the module too closely tied to the HTML.  --CT
+
 my $logger = Log::Log4perl->get_logger('LedgerSMB::Scripts::admin');
 
+
 sub __edit_page {
     
     
@@ -63,6 +86,19 @@
     $template->render($template_data);
 }
 
+=item save_user
+
+Saves the user information, including name, etc.
+
+This is also used to effect an administrative password reset or create new 
+users.  However, if the import value is set to 1, it will not set the password.
+
+The reasoning here is that we don't really want to set passwords when we are 
+importing db cluster users into LedgerSMB.  If that needs to be done it can be
+a separate stage.
+
+=cut
+
 sub save_user {
     my ($request, $admin) = @_;
     if ($request->{import} == "1"){
@@ -104,6 +140,12 @@
     __edit_page($admin);
 }
 
+=item save_roles
+
+Saves the role assignments for a given user
+
+=cut
+
 sub save_roles {
     my ($request, $admin) = @_;
     my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
@@ -112,7 +154,12 @@
     __edit_page($admin);
 }
 
+=item new_user 
 
+Displays a new user form.  No inputs used.
+
+=cut
+
 sub new_user {
     
     # uses the same page as create_user, only pre-populated.
@@ -145,6 +192,12 @@
         );
 }
 
+=item edit_user
+
+Displays the screen for editing a user.  user_id must be set to prepopulate.
+
+=cut
+
 sub edit_user {
     
     # uses the same page as create_user, only pre-populated.
@@ -152,92 +205,13 @@
     __edit_page($request);
 }
 
-sub edit_group {
-    
-    my ($request) = @_;
-    my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
-    
-    my $all_roles = $admin->role_list();
-    my $user = $request->{_user};
-    
-    my $template = LedgerSMB::Template->new( 
-        user => $user, 
-        template => 'Admin/edit_group', 
-        language => $user->{language}, 
-        format => 'HTML', 
-        path=>'UI'
-    );
-        
-    if ($request->type() eq "POST") {
+=item delete_user
 
-        my $role = $admin->save_role();
-        return $template->render(
-            {
-                user=> $request->{role}, 
-                roles=>$all_roles,
-                user_roles=>$admin->get_user_roles($request->{role})
-            }
-        );
-    }
-    else {
-        return $template->render(
-            {
-            roles=>$all_roles
-            }
-        );
-    }    
-}
+Deletes a user and returns to search results.
 
-sub create_group {
-    
-    my ($request) = @_;
-    my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
-    my $user = $request->{_user};
-    
-    my $all_roles = $admin->get_roles();
-    my $template = LedgerSMB::Template->new( 
-        user => $user, 
-        template => 'Admin/edit_group', 
-        language => $user->{language}, 
-        format => 'HTML', 
-        path=>'UI'
-    );
-    if ($request->type() eq "POST") {
-        
-        my $role = $admin->save_role();
-        return $template->render(
-            {
-                user=> $role, roles=>$all_roles
-            }
-        );
-    }
-    else {
-        return $template->render({roles=>$all_roles});
-    }
-}
+=cut
 
-sub delete_group {
-    
-    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_group($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_group', language=>$user->{language}, 
-        format=>'HTML', path=>'UI');    
-        
-    $template->render($status);    
-}
-
+# XXX Rewrite! --CT
 sub delete_user {
     
     my ($request) = @_;
@@ -260,49 +234,12 @@
     $template->render($status);
 }
 
-sub new_group {
-    
-    my ($request) = @_;
-    my $user = $request->{_user};
-    
-    my $template = LedgerSMB::Template->new( user=>$user, 
-        template=>'Admin/new_group', language=>$user->{language},
-        format=>'HTML', path=>'UI');
-    
-    $template->render();
-}
+=item save_contact
 
-sub cancel {
-        
-    &main(@_);
-}
+Saves contact information and returns to the edit user screen.
 
-sub __default {
-    
-    &main(@_);
-}
+=cut
 
-sub main {
-    
-    my ($request) = @_;
-    my $user = $request->{_user};
-    
-    my $template;
-    
-    my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'all');
-    
-    my $ret = $user->get_all_users();
-    
-    $template = LedgerSMB::Template->new( 
-        user=>$user, 
-        template=>'Admin/main', 
-        language=>$user->{language},
-        format=>'HTML', 
-        path=>'UI'
-    );
-    $template->render( { users=>$user->{users} } );
-}
-
 sub save_contact {
     
     my $request = shift @_;
@@ -332,6 +269,12 @@
     }
 }
 
+=item delete_contact 
+
+Deletes contact information and returns to edit user screen
+
+=cut
+
 sub delete_contact {
     
     
@@ -364,6 +307,12 @@
     }
 }
 
+=item save_location
+
+Saves location information and returns to the edit user screen.
+
+=cut
+
 sub save_location {
     
     my $request = shift @_;
@@ -405,7 +354,12 @@
     }
 }
 
+=item delete_location
 
+Deletes a location and returns to edit user screen
+
+=cut
+
 sub delete_location {
     
     my $request = shift @_;
@@ -426,8 +380,12 @@
     }
 }
 
-#eval { do "scripts/custom/admin.pl"};
+=item search_users
 
+Displays search criteria screen
+
+=cut
+
 sub search_users {
     my ($request) = @_;
     my $template = LedgerSMB::Template->new(
@@ -440,6 +398,13 @@
     $template->render($request);
 }
 
+=item get_user_results
+
+Displays user search results
+
+=cut
+
+#XXX Add delete link
 sub get_user_results {
     my ($request) = @_;
     my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
@@ -487,6 +452,12 @@
     }); 
 }
 
+=item list_sessions
+
+Displays a list of open sessions.  No inputs required or used.
+
+=cut
+
 sub list_sessions {
     my ($request) = @_;
     my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
@@ -531,6 +502,12 @@
     
 }
 
+=item delete_session
+
+Deletes the session specified by $request->{session_id}
+
+=cut
+
 sub delete_session {
     my ($request) = @_;
     my $admin = LedgerSMB::DBObject::Admin->new(base => $request);
@@ -538,4 +515,17 @@
     list_sessions($request);
 }
 
+eval { do "scripts/custom/admin.pl"};
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2010 LedgerSMB Core Team.  This file is licensed under the GNU 
+General Public License version 2, or at your option any later version.  Please
+see the included License.txt for details.
+
+=cut
+
+
 1;


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