diff -burN OpenTRS.orig/Kernel/Config.pm OpenTRS/Kernel/Config.pm --- OpenTRS.orig/Kernel/Config.pm Thu Dec 5 13:06:04 2002 +++ OpenTRS/Kernel/Config.pm Thu Dec 5 13:09:11 2002 @@ -475,7 +475,7 @@ # ----------------------------------------------------# # external customer db settings # # ----------------------------------------------------# - $Self->{CustomerDBLink} = 'http://yourhost/customer.pl?CID=$Data{"CustomerID"}'; + $Self->{CustomerDBLink} = 'http://yourhost/customer_view.pl?CID=$Data{"CustomerID"}'; # $Self->{CustomerDBLink} = ''; # ----------------------------------------------------# diff -burN OpenTRS.orig/Kernel/System/CustomerUser.pm OpenTRS/Kernel/System/CustomerUser.pm --- OpenTRS.orig/Kernel/System/CustomerUser.pm Thu Dec 5 12:33:55 2002 +++ OpenTRS/Kernel/System/CustomerUser.pm Thu Dec 5 14:50:30 2002 @@ -96,6 +96,46 @@ return (%Data, %Preferences); } # -- +sub CustomerUserDataGetForView { + my $Self = shift; + my %Param = @_; + my $CustomerID = $Param{CustomerID}; + my %Data; + # -- + # get inital data + # -- + my $SQL = "SELECT login, email, customer_id, pw, salutation, ". + " first_name, last_name, comment, valid_id ". + " FROM " . + " customer_user " . + " WHERE customer_id=$CustomerID"; + $Self->{DBObject}->Prepare(SQL => $SQL); + while (my @RowTmp = $Self->{DBObject}->FetchrowArray()) { + $Data{UserLogin} = $RowTmp[0]; + $Data{UserEmail} = $RowTmp[1]; + $Data{UserCustomerID} = $RowTmp[2]; + $Data{UserPw} = $RowTmp[3]; + $Data{UserSalutation} = $RowTmp[4]; + $Data{UserFirstname} = $RowTmp[5]; + $Data{UserLastname} = $RowTmp[6]; + $Data{UserComment} = $RowTmp[7]; + $Data{ValidID} = $RowTmp[8]; + } + # -- + # check data + # -- + if (! exists $Data{CustomerID} && ! $CustomerID) { + $Self->{LogObject}->Log( + Priority => 'notice', + Message => "Panic! No Data for customer: '$CustomerID'!!!", + ); + return; + } + + # return data + return (%Data); +} +# -- sub CustomerUserAdd { my $Self = shift; my %Param = @_; diff -burN OpenTRS.orig/bin/cgi-bin/customer_view.pl OpenTRS/bin/cgi-bin/customer_view.pl --- OpenTRS.orig/bin/cgi-bin/customer_view.pl Thu Jan 1 01:00:00 1970 +++ OpenTRS/bin/cgi-bin/customer_view.pl Thu Dec 5 15:14:06 2002 @@ -0,0 +1,145 @@ +#!/usr/bin/perl -w +# -- +# customer_view.pl - view customer data +# Copyright (C) 2002 Wiktor Wodecki +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# -- + +# use ../../ as lib location +use FindBin qw($Bin); + +use lib "$Bin/../.."; + +use strict; + +use vars qw($VERSION @INC); +$VERSION = '$Revision: 0.5 $'; +$VERSION =~ s/^.*:\s(\d+\.\d+)\s.*$/$1/; + +# -- +# 0=off;1=on; +# -- +my $Debug = 0; + +# -- +# check @INC for mod_perl (add lib path for "require module"!) +# -- +$ENV{MOD_PERL} && push (@INC, "$Bin/../.."); + +# -- +# all framework needed modules +# (if you use mod_perl with startup.pl, drop this "use Kernel::.." and add +# this to your startup.pl) +# -- +use Kernel::Config; +use Kernel::Config::ModulesCustomerPanel; +use Kernel::System::Log; +use Kernel::System::WebRequest; +use Kernel::System::DB; +use Kernel::System::AuthSession; +use Kernel::System::CustomerAuth; +use Kernel::System::CustomerUser; +use Kernel::System::Permission; + +# -- +# create common framework objects 1/3 +# -- +my %CommonObject = (); +$CommonObject{ConfigObject} = Kernel::Config->new(); +$CommonObject{LogObject} = Kernel::System::Log->new( + LogPrefix => $CommonObject{ConfigObject}->Get('CGILogPrefix'), + %CommonObject, +); +# -- +# debug info +# -- +if ($Debug) { + $CommonObject{LogObject}->Log( + Priority => 'debug', + Message => 'Global handle started...', + ); +} +# -- +# create common framework objects 2/3 +# -- +$CommonObject{ParamObject} = Kernel::System::WebRequest->new(); +#$CommonObject{LayoutObject} = Kernel::Output::HTML::Generic->new(%CommonObject); +$CommonObject{DBObject} = Kernel::System::DB->new(%CommonObject); +# -- +# check common db objects +# -- +if (!$CommonObject{DBObject}) { + print $CommonObject{LayoutObject}->CustomerHeader(Title => 'Error!'); + print $CommonObject{LayoutObject}->CustomerError( + Message => $DBI::errstr, + Comment => 'Please contact your admin' + ); + print $CommonObject{LayoutObject}->CustomerFooter(); + exit (1); +} +# -- +# create common framework objects 3/3 +# -- +$CommonObject{UserObject} = Kernel::System::CustomerUser->new(%CommonObject); +$CommonObject{SessionObject} = Kernel::System::AuthSession->new(%CommonObject); +# -- +# application and add on application common objects +# -- +foreach ('$Kernel::Config::ModulesCustomerPanel::CommonObject') { + my $ModuleCommonObject = eval $_; + foreach my $Key (keys %{$ModuleCommonObject}) { + # create + $CommonObject{$Key} = $ModuleCommonObject->{$Key}->new(%CommonObject); + } +} + +# -- +# get the customer_id +# evil, evil +# -- +use CGI; +my $q = new CGI; +my $CustomerID = $q->param('CID'); +my %UserData = $CommonObject{UserObject}->CustomerUserDataGetForView(CustomerID => $CustomerID); + +print ("Content-type: text/html\n\n"); +my $i = 1; +foreach (%UserData){ + if ( $i%2 != 0) { + print($_.": "); + } + else { + print($_."
\n"); + } + $i++; +} + +# -- +# debug info +# -- +if ($Debug) { + $CommonObject{LogObject}->Log( + Priority => 'debug', + Message => 'Global handle stopped.', + ); +} +# -- +# db disconnect && undef %CommonObject %% undef % +# -- +$CommonObject{DBObject}->Disconnect(); +undef %CommonObject; +