[otrs-cvs] otrs/Kernel/System/CustomerUser DB.pm, 1.110, 1.111 LDAP.pm, 1.72, 1.73
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/otrs/Kernel/System/CustomerUser
In directory lancelot:/tmp/cvs-serv12751/CustomerUser
Modified Files:
DB.pm LDAP.pm
Log Message:
Code cleanup.
Author: mh
Index: DB.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/CustomerUser/DB.pm,v
retrieving revision 1.110
retrieving revision 1.111
diff -2 -u -d -r1.110 -r1.111
--- DB.pm 3 Dec 2012 10:37:10 -0000 1.110
+++ DB.pm 16 Jan 2013 15:47:15 -0000 1.111
@@ -1,5 +1,5 @@
# --
# Kernel/System/CustomerUser/DB.pm - some customer user functions
-# Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
+# Copyright (C) 2001-2013 OTRS AG, http://otrs.org/
# --
# $Id$
@@ -616,5 +616,5 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
@@ -746,5 +746,5 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
@@ -875,5 +875,5 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
@@ -989,5 +989,4 @@
. $Self->{DBObject}->Quote( $Param{UserLogin} ) . "')";
}
-
}
@@ -1012,5 +1011,5 @@
my ( $Self, %Param ) = @_;
- # Generated passwords are eight characters long by default.
+ # generated passwords are eight characters long by default.
my $Size = $Param{Size} || 8;
@@ -1020,14 +1019,13 @@
= ( 0 .. 9, 'A' .. 'Z', 'a' .. 'z', '-', '_', '!', '@', '#', '$', '%', '^', '&', '*' );
- # The number of characters in the list.
+ # number of characters in the list.
my $PwCharsLen = scalar(@PwChars);
- # Generate the password.
+ # generate the password.
my $Password = '';
for ( my $i = 0; $i < $Size; $i++ ) {
- $Password .= $PwChars[ rand($PwCharsLen) ];
+ $Password .= $PwChars[ rand $PwCharsLen ];
}
- # Return the password.
return $Password;
}
@@ -1073,4 +1071,5 @@
return $Text;
}
+
return $Self->{EncodeObject}->Convert(
Text => $Text,
@@ -1090,4 +1089,5 @@
return $Text;
}
+
return $Self->{EncodeObject}->Convert(
Text => $Text,
@@ -1117,5 +1117,5 @@
);
- # delete all search chache entries
+ # delete all search cache entries
$Self->{CacheObject}->CleanUp(
Type => $Self->{CacheType} . '_CustomerIDList',
@@ -1131,7 +1131,8 @@
Key => "${Function}::${Valid}",
);
-
}
}
+
+ return 1;
}
@@ -1145,4 +1146,5 @@
}
}
+
return 1;
}
Author: mh
Index: LDAP.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/CustomerUser/LDAP.pm,v
retrieving revision 1.72
retrieving revision 1.73
diff -2 -u -d -r1.72 -r1.73
--- LDAP.pm 20 Nov 2012 15:44:51 -0000 1.72
+++ LDAP.pm 16 Jan 2013 15:47:15 -0000 1.73
@@ -1,5 +1,5 @@
# --
# Kernel/System/CustomerUser/LDAP.pm - some customer user functions in LDAP
-# Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
+# Copyright (C) 2001-2013 OTRS AG, http://otrs.org/
# --
# $Id$
@@ -58,6 +58,5 @@
$Self->{Params} = $Self->{ConfigObject}->Get( 'AuthModule::LDAP::Params' . $Param{Count} );
}
- else
- {
+ else {
$Self->{Params} = {};
}
@@ -175,4 +174,5 @@
# ldap connect and bind (maybe with SearchUserDN and SearchUserPw)
$Self->{LDAP} = Net::LDAP->new( $Self->{Host}, %{ $Self->{Params} } );
+
if ( !$Self->{LDAP} ) {
if ( $Self->{Die} ) {
@@ -187,4 +187,5 @@
}
}
+
my $Result;
if ( $Self->{SearchUserDN} && $Self->{SearchUserPw} ) {
@@ -197,4 +198,5 @@
$Result = $Self->{LDAP}->bind();
}
+
if ( $Result->code ) {
$Self->{LogObject}->Log(
@@ -205,4 +207,5 @@
return;
}
+
return 1;
}
@@ -246,4 +249,5 @@
attrs => $Self->{CustomerUserMap}->{CustomerUserNameFields},
);
+
if ( $Result->code ) {
$Self->{LogObject}->Log(
@@ -253,7 +257,11 @@
return;
}
+
for my $Entry ( $Result->all_entries ) {
+
for my $Field ( @{ $Self->{CustomerUserMap}->{CustomerUserNameFields} } ) {
+
if ( defined $Entry->get_value($Field) ) {
+
if ( !$Name ) {
$Name = $Self->_ConvertFrom( $Entry->get_value($Field) );
@@ -275,4 +283,5 @@
);
}
+
return $Name;
}
@@ -294,7 +303,9 @@
my $Filter = '';
if ( $Param{Search} ) {
+
my $Count = 0;
my @Parts = split( /\+/, $Param{Search}, 6 );
for my $Part (@Parts) {
+
$Part = $Self->{SearchPrefix} . $Part . $Self->{SearchSuffix};
$Part =~ s/(\%+)/\%/g;
@@ -313,4 +324,5 @@
}
}
+
if ( $Count > 1 ) {
$Filter = "(&$Filter)";
@@ -318,4 +330,5 @@
}
elsif ( $Param{PostMasterSearch} ) {
+
if ( $Self->{CustomerUserMap}->{CustomerUserPostMasterSearchFields} ) {
$Filter = '(|';
@@ -374,9 +387,14 @@
);
}
+
my %Users;
for my $entry ( $Result->all_entries ) {
+
my $CustomerString = '';
+
for my $Field ( @{ $Self->{CustomerUserMap}->{CustomerUserListFields} } ) {
+
my $Value = $Self->_ConvertFrom( $entry->get_value($Field) );
+
if ($Value) {
if ( $Field =~ /^targetaddress$/i ) {
@@ -386,5 +404,7 @@
}
}
+
$CustomerString =~ s/^(.*)\s(.+?\@.+?\..+?)(\s|)$/"$1" <$2>/;
+
if ( defined $entry->get_value( $Self->{CustomerKey} ) ) {
$Users{ $Self->_ConvertFrom( $entry->get_value( $Self->{CustomerKey} ) ) }
@@ -395,5 +415,7 @@
# check if user need to be in a group!
if ( $Self->{GroupDN} ) {
+
for my $Filter2 ( sort keys %Users ) {
+
my $Result2 = $Self->{LDAP}->search(
base => $Self->{GroupDN},
@@ -403,4 +425,5 @@
attrs => ['1.1'],
);
+
if ( !$Result2->all_entries ) {
delete $Users{$Filter2};
@@ -418,4 +441,5 @@
);
}
+
return %Users;
}
@@ -489,5 +513,7 @@
# check if user need to be in a group!
if ( $Self->{GroupDN} ) {
+
for my $Filter2 ( sort keys %Users ) {
+
my $Result2 = $Self->{LDAP}->search(
base => $Self->{GroupDN},
@@ -497,4 +523,5 @@
attrs => ['1.1'],
);
+
if ( !$Result2->all_entries ) {
delete $Users{$Filter2};
@@ -617,4 +644,5 @@
);
}
+
return @Result;
}
@@ -646,11 +674,12 @@
# used seperators
- for my $Split ( ';', ',', '|' ) {
+ SEPERATOR:
+ for my $Seperator ( ';', ',', '|' ) {
- # next if seperator is not there
- next if $Data{UserCustomerIDs} !~ /\Q$Split\E/;
+ next SEPERATOR if $Data{UserCustomerIDs} !~ /\Q$Seperator\E/;
# split it
- my @IDs = split /\Q$Split\E/, $Data{UserCustomerIDs};
+ my @IDs = split /\Q$Seperator\E/, $Data{UserCustomerIDs};
+
for my $ID (@IDs) {
$ID =~ s/^\s+//g;
@@ -658,5 +687,6 @@
push @CustomerIDs, $ID;
}
- last;
+
+ last SEPERATOR;
}
@@ -683,4 +713,5 @@
);
}
+
return @CustomerIDs;
}
@@ -689,6 +720,4 @@
my ( $Self, %Param ) = @_;
- my %Data;
-
# check needed stuff
if ( !$Param{User} ) {
@@ -745,13 +774,16 @@
# get customer user info
+ my %Data;
for my $Entry ( @{ $Self->{CustomerUserMap}->{Map} } ) {
+
my $Value = $Self->_ConvertFrom( $Result2->get_value( $Entry->[2] ) ) || '';
+
if ( $Value && $Entry->[2] =~ /^targetaddress$/i ) {
$Value =~ s/SMTP:(.*)/$1/;
}
+
$Data{ $Entry->[0] } = $Value;
}
- # check data
return if !$Data{UserLogin};
@@ -779,5 +811,4 @@
}
- # return data
return ( %Data, %Preferences );
}
@@ -788,8 +819,10 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
+
$Self->{LogObject}->Log( Priority => 'error', Message => 'Not supported for this module!' );
+
return;
}
@@ -800,8 +833,10 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
+
$Self->{LogObject}->Log( Priority => 'error', Message => 'Not supported for this module!' );
+
return;
}
@@ -814,8 +849,10 @@
# check ro/rw
if ( $Self->{ReadOnly} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is ro!' );
+ $Self->{LogObject}->Log( Priority => 'error', Message => 'Customer backend is read only!' );
return;
}
+
$Self->{LogObject}->Log( Priority => 'error', Message => 'Not supported for this module!' );
+
return;
}
@@ -824,5 +861,5 @@
my ( $Self, %Param ) = @_;
- # Generated passwords are eight characters long by default.
+ # generated passwords are eight characters long by default.
my $Size = $Param{Size} || 8;
@@ -832,14 +869,13 @@
= ( 0 .. 9, 'A' .. 'Z', 'a' .. 'z', '-', '_', '!', '@', '#', '$', '%', '^', '&', '*' );
- # The number of characters in the list.
+ # number of characters in the list.
my $PwCharsLen = scalar(@PwChars);
- # Generate the password.
+ # generate the password.
my $Password = '';
for ( my $i = 0; $i < $Size; $i++ ) {
- $Password .= $PwChars[ rand($PwCharsLen) ];
+ $Password .= $PwChars[ rand $PwCharsLen ];
}
- # Return the password.
return $Password;
}
@@ -922,4 +958,5 @@
$Self->{LDAP}->unbind;
}
+
return 1;
}
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log