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

SF.net SVN: ledger-smb:[5011] trunk/LedgerSMB



Revision: 5011
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5011&view=rev
Author:   einhverfr
Date:     2012-07-18 01:30:24 +0000 (Wed, 18 Jul 2012)
Log Message:
-----------
Removing old user management code from 1.3

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/LedgerSMB/Scripts/admin.pm

Removed Paths:
-------------
    trunk/LedgerSMB/Location.pm

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2012-07-18 01:00:12 UTC (rev 5010)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2012-07-18 01:30:24 UTC (rev 5011)
@@ -29,8 +29,6 @@
 
 use base qw(LedgerSMB::DBObject);
 
-use LedgerSMB::Location;
-use LedgerSMB::Contact;
 use LedgerSMB::DBObject::Entity::Person::Employee;
 use LedgerSMB::DBObject::User;
 use Log::Log4perl;
@@ -38,62 +36,6 @@
 
 my $logger = Log::Log4perl->get_logger("LedgerSMB::DBObject::Admin");
 
-#[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.
-
-# Deleting "save" method.  There is no point to a routine that only raises
-# an error given that it is not inherited.  An error will be raised in a way
-# which is more developer-friendly.   --CT
-
-=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 
-user_results hash value.
-
-Search criteria:
-
-=over
-
-=item username
-
-=item first_name
-
-=item last_name
-
-=item ssn
-
-=item dob
-
-=back
-
-Undef matches all values.  All matches exact except username which allows for
-partial matches.
-
-=cut
-
-sub search_users {
-   my $self = shift @_;
-   my @users = $self->exec_method(funcname => 'admin__search_users');
-   $self->{user_results} = ..hidden..;
-   return @users;
-}
-
 =item list_sessions
 
 returns a list of active sessions, when they were last used, and how many 
@@ -222,47 +164,6 @@
     return ..hidden..;
 }
 
-=item get_countries
-
-Returns a reference to an array of hashrefs including the country data in the db.
-
-Sets the same reference to the countries hash value.
-
-=cut
-
-sub get_countries {
-    
-    my $self = shift @_;
-    
-    @{$self->{countries}} 
-          =$self->exec_method(funcname => 'location_list_country'); 
-	# returns an array of hashrefs.
-    return $self->{countries};
-}
-
-=item get_contact_classes
-
-Returns a list of hashrefs ({id =>, class =>}) relating to the contact classes.
-
-=cut
-
-sub get_contact_classes {
-    
-    my $self = shift @_;
-
-    # There are a couple problems here:
-    # 1)  It's best to mix Perl and SQL as little as possible.  Mixing gets 
-    # around our centralized sql injection prevention measures.  While this 
-    # query poses no direct risk there, it's a bad habit to be in.
-    # 
-    # 2)  Lack of ordering means drop down list orders could change in the future
-    # which is nprobably not very good.
-    # --CT
-    my $sth = $self->{dbh}->prepare("select id, class as name from contact_class");
-    my $code = $sth->execute();
-    return $sth->fetchall_arrayref({});
-}
-
 =back
 
 =head1 COPYRIGHT

Deleted: trunk/LedgerSMB/Location.pm
===================================================================
--- trunk/LedgerSMB/Location.pm	2012-07-18 01:00:12 UTC (rev 5010)
+++ trunk/LedgerSMB/Location.pm	2012-07-18 01:30:24 UTC (rev 5011)
@@ -1,115 +0,0 @@
-=head1 NAME
-
-LedgerSMB::Location - LedgerSMB class for managing Business Locations
-
-=head1 SYOPSIS
-
-This module contains location management routines.  This subclasses 
-LedgerSMB::DBObject to provide access to automatice mapping of function 
-arguments and the like.
-
-=head1 METHODS
-
-=over
-
-=item delete 
-
-=cut
-
-package LedgerSMB::Location;
-use LedgerSMB;
-use LedgerSMB::DBObject;
-use strict;
-our $VERSION = '1.0.0';
-
-use base qw(LedgerSMB::DBObject);
-
-=item save
-
-Saves the location.  Properties to be set to be saved are:
-
-* location_id: Optional:  Overwrite location with this id.
-* address1: First line of the address.
-* address2: Second line of the address
-* address3: Third line of the address
-* city
-* state: state or province
-* zipcode: zipcode or mail code, 
-* country:  The id of the country as per the country table
-
-=cut
-
-sub save {
-    my $self = shift;
-    my $ref = shift @{ $self->exec_method( procname => "location_save" ) };
-    $self->merge( $ref, 'id' );
-}
-
-=item get
-
-Retrieves a location record based on the id field of the object.  Merges the 
-properties into the object.
-
-=cut
-
-sub get {
-    my $self = shift;
-    my $ref = shift @{ $self->exec_method( procname => 'location__get' ) };
-    $self->merge( $ref, keys %{$ref} );
-}
-
-=item search
-Returns anarrayref (and stores it on $self->{search_results} based on the 
-search of addresses.  Not currently used.
-
-Attributes used as search criteria:
-address1: Partial match for address line 1
-address2: Partial match for address line 2,
-city:  Partial match for city name
-state: Partial match for state or province name, 
-zipcode:  Partial match for zip or postal code,
-country: Partial name for country name)
-
-=cut
-
-sub search {
-    my $self = shift;
-    $self->{search_results} =
-      $self->exec_method( procname => 'location_search' );
-}
-
-=item list_all
-
-Provides a list of all locations, ordered by country, then city, then state.
-
-=cut
-
-sub list_all {
-    my $self = shift;
-    $self->{search_results} =
-      $self->exec_method( procname => 'location_list_all' );
-}
-
-=item delete
-
-Deletes the location identified by id
-
-=cut
-
-sub delete {
-    my $self = shift;
-    $self->exec_method( procname => 'location_delete' );
-    $self->{dbh}->commit;
-}
-
-=back
-
-=head1 Copyright (C) 2007, The LedgerSMB core team.
-
-This file is licensed under the Gnu General Public License version 2, or at your
-option any later version.  A copy of the license should have been included with
-your software.
-
-=cut
-
-1;

Modified: trunk/LedgerSMB/Scripts/admin.pm
===================================================================
--- trunk/LedgerSMB/Scripts/admin.pm	2012-07-18 01:00:12 UTC (rev 5010)
+++ trunk/LedgerSMB/Scripts/admin.pm	2012-07-18 01:30:24 UTC (rev 5011)
@@ -84,60 +84,6 @@
     $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"){
-         delete $request->{password};
-    }
-    my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
-    
-    my $sal = $admin->get_salutations();
-    
-    my $entity = $admin->save_user();
-    if ($entity == 8){ # Duplicate user
-          $request->{import} = 1;
-          $request->{reimport} = 1;
-          my $template = LedgerSMB::Template->new( 
-                  user => $request->{_user}, 
-              template => 'Admin/edit_user', 
-              language => $request->{_user}->{language}, 
-                format => 'HTML', 
-                   path=>'UI'
-          );
-          my $dcsetting = LedgerSMB::Setting->new(base=>$request, copy=>'base');
-          my $default_country = $dcsetting->get('default_country'); 
-          $template->render(
-            {
-                user=>{user => $request, employee => $request}, 
-                countries=>$admin->get_countries(),
-                stylesheet => $request->{stylesheet},
-                contact_classes=>$admin->get_contact_classes(),
-                default_country => $dcsetting->{value},
-                admin => $admin,
-                salutations=>$admin->get_salutations(),
-            }
-          );
-          return;
-    }
-    my $groups = $admin->get_roles();
-    $admin->{stylesheet} = $request->{stylesheet};
-    $admin->{user_id} = $admin->{user}->{id};
-    __edit_page($admin);
-}
-
 =item save_roles
 
 Saves the role assignments for a given user
@@ -152,61 +98,6 @@
     __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.
-    #my ($request) = @_;
-    my $request = shift @_;
-    my $admin = LedgerSMB::DBObject::Admin->new(base=>$request, copy=>'all');
-
-    my $setting = LedgerSMB::Setting->new(base => $request, copy => 'base');
-    
-    my @sal = $admin->get_salutations();
-    
-    my $groups = $admin->get_roles();
-    my $user = $request->{_user};
-    
-    $logger->debug("scripts/admin.pl new_user: \$user = " . Data::Dumper::Dumper($user));
-    
-        my $template = LedgerSMB::Template->new( 
-            user => $user, 
-    	    template => 'Admin/edit_user',
-    	    language => $user->{language}, 
-            format => 'HTML', 
-            path=>'UI'
-        );
-    
-        $template->render(
-            {
-                default_country => $setting->get('default_country'),
-                salutations=>..hidden..,
-                roles=>$groups,
-                countries=>$admin->get_countries(),
-                stylesheet => $request->{stylesheet},
-                user => { user => $request, employee => $request },
-            }
-        );
-}
-
-=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.
-    my ($request) = @_;
-    __edit_page($request);
-}
-
 =item delete_user
 
 Deletes a user and returns to search results.
@@ -221,159 +112,6 @@
     search_users($request); 
 }
 
-=item save_contact
-
-Saves contact information and returns to the edit user screen.
-
-=cut
-
-sub save_contact {
-    
-    my $request = shift @_;
-    
-    # Only ever a post, but check anyway
-    if ($request->type eq "POST") {
-        
-        if ($request->{cancel}) {
-            
-            # If we have a cancel request, we just go back to edit_page.
-            return __edit_page($request);
-        }
-        
-        # We have a contact ID, ie, something we made up.
-        my $c_id = $request->{contact_id};
-        my $u_id = $request->{user_id};
-        my $user_obj = LedgerSMB::DBObject::User->new(base=>$request, copy=>'list', merge=>['user_id','company']);
-        $user_obj->get($u_id);
-        
-        # so we have a user object.
-        # ->{contacts} is an arrayref to the list of contacts this user has
-        # $request->{contact_id} is a reference to this structure.
-        
-        $user_obj->save_contact($c_id, $request->{contact_class}, $request->{contact});
-        
-        __edit_page($request,{});
-    }
-}
-
-=item delete_contact 
-
-Deletes contact information and returns to edit user screen
-
-=cut
-
-sub delete_contact {
-    
-    
-    my $request = shift @_;
-    
-    # Only ever a post, but check anyway
-    if ($request->type eq "POST") {
-        
-        if ($request->{cancel}) {
-            
-            # If we have a cancel request, we just go back to edit_page.
-            return __edit_page($request);
-        }
-        
-        # We have a contact ID, ie, something we made up.
-        my $c_id = $request->{contact_id};
-        my $u_id = $request->{user_id};
-        my $user = LedgerSMB::DBObject::User->new(base=>$request, copy=>'user_id');
-        $user->get($u_id);
-        
-        # so we have a user object.
-        # ->{contacts} is an arrayref to the list of contacts this user has
-        # $request->{contact_id} is a reference to this structure.
-        
-        $user->delete_contact($c_id);
-        # Boom. Done.
-        # Now, just call the main edit user page.
-        
-        __edit_page($request,undef,);
-    }
-}
-
-=item search_users
-
-Displays search criteria screen
-
-=cut
-
-sub search_users {
-    my ($request) = @_;
-    my $template = LedgerSMB::Template->new(
-            user => $request->{_user}, 
-            template => 'Admin/user_search', 
-            locale => $request->{_locale}, 
-            format => 'HTML', 
-            path=>'UI'
-    );
-    $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);
-    my @users = $admin->search_users;
-    my $template = LedgerSMB::Template->new(
-            user => $request->{_user}, 
-            template => 'form-dynatable', 
-            locale => $request->{_locale}, 
-            format => 'HTML', 
-            path=>'UI'
-    );
-    my $columns;
-    @$columns = qw(id username first_name last_name ssn dob edit remove drop);
-    
-    my $column_names = {
-        id => 'ID',
-        username => 'Username',
-        first_name => 'First Name',
-        last_name => 'Last Name',
-        ssn => 'Tax ID',
-        dob => 'Date of Birth'
-    };
-    my $column_heading = $template->column_heading($column_names);
-    
-    my $rows = [];
-    my $rowcount = "0";
-    my $base_url = "admin.pl";
-    for my $u (@users) {
-        $u->{i} = $rowcount % 2;
-        $u->{edit} = {
-            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;
-    }
-    $admin->{title} = $request->{_locale}->text('Search Results');
-    $template->render({
-	form    => $admin,
-	columns => $columns,
-	heading => $column_heading,
-        rows    => $rows,
-	buttons => [],
-	hiddens => [],
-    }); 
-}
-
 =item list_sessions
 
 Displays a list of open sessions.  No inputs required or used.

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