| 1 | package MYDan::Code; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | use MYDan::Code::Gitlab; | ||
| 6 | use MYDan::Code::SVN; | ||
| 7 | |||
| 8 | sub new | ||
| 9 | { | ||
| 10 | my ( $class, %self ) = splice @_; | ||
| 11 | |||
| 12 | if( $self{conf} && ref $self{conf} eq 'ARRAY' ) | ||
| 13 | { | ||
| 14 | for my $conf ( @{$self{conf}} ) | ||
| 15 | { | ||
| 16 | next unless ( ! $self{name} ) || ( $self{name} && $conf->{name} && $self{name} eq $conf->{name} ); | ||
| 17 | if( $conf->{apiurl} ) | ||
| 18 | { | ||
| 19 | push @{$self{code}}, MYDan::Code::Gitlab->new( %$conf ); | ||
| 20 | } | ||
| 21 | else | ||
| 22 | { | ||
| 23 | push @{$self{code}}, MYDan::Code::SVN->new( %$conf ); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | bless \%self, ref $class || $class; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub searchUser | ||
| 32 | { | ||
| 33 | my ( $this, $user ) = @_; | ||
| 34 | map { $_->searchUser( $user ); }@{$this->{code}}; | ||
| 35 | return $this; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub getUsers | ||
| 39 | { | ||
| 40 | my ( $this, %email ) = shift; | ||
| 41 | map { %email = ( %email, $_->getUsers() ); }@{$this->{code}}; | ||
| 42 | |||
| 43 | return $this unless $this->{checkuser}; | ||
| 44 | |||
| 45 | my $i = 0; | ||
| 46 | for my $email ( sort keys %email ) | ||
| 47 | { | ||
| 48 | printf "[%i]: plugin.checkuser $email %s\n", ++$i, $this->{checkuser}->( $email ); | ||
| 49 | } | ||
| 50 | |||
| 51 | return $this; | ||
| 52 | } | ||
| 53 | |||
| 54 | sub blockUser | ||
| 55 | { | ||
| 56 | my ( $this, $user ) = @_; | ||
| 57 | map { $_->blockUser( $user ); }@{$this->{code}}; | ||
| 58 | return $this; | ||
| 59 | } | ||
| 60 | |||
| 61 | sub unblockUser | ||
| 62 | { | ||
| 63 | my ( $this, $user ) = @_; | ||
| 64 | map { $_->unblockUser( $user ); }@{$this->{code}}; | ||
| 65 | return $this; | ||
| 66 | } | ||
| 67 | |||
| 68 | 1; |