Gtk2-Net-LDAP-Widgets

 view release on metacpan or  search on metacpan

Widgets/LdapEntrySelector.pm  view on Meta::CPAN

package Gtk2::Net::LDAP::Widgets::LdapEntrySelector;

#---[ pod head ]---{{{

=head1 NAME

Gtk2::Net::LDAP::Widgets::LdapEntrySelector - LDAP entry selection window

=head1 SYNOPSIS

    use Gtk2::Net::LDAP::Widgets;

    my $entryPopup = Gtk2::Net::LDAP::Widgets::LdapEntrySelector->new ($parent_window,
      $ldap_source,
      'dc=example,dc=com',
      'objectClass=inetorgperson',
      'init_interactive_filter' => 'smith',
      'single_selection' => 1,
      'interactive_filter_type' => 'simple'
    );
    $entryPopup->signal_connect (response => sub {
      my ($popup, $response) = @_;
      if($response =~ 'accept') {
        print "Selected entry DN: ".$entryPopup->get_dn;
      } else {
				print "No existing entry selected.\n";
      }
      $_[0]->destroy;
      });
    $entryPopup->show_all;


=head1 ABSTRACT

Gtk2::Net::LDAP::Widgets::LdapEntrySelector is a child class to L<Gtk2::Dialog> 
and is used to create a Gtk2 dialog which lets the user search for a LDAP entry 
and select it.  

The dialog is equipped with a search/filter box.

=cut

#---}}}
use utf8;
use strict;
use warnings;
use vars qw(@ISA $VERSION);

use Carp qw(cluck);
use Net::LDAP;
use Net::LDAP::Util;
use Gtk2 -init;
use Data::Dumper;
use Gtk2::Net::LDAP::Widgets::LdapEntryView;
use Gtk2::Net::LDAP::Widgets::Util;

@ISA = qw(Gtk2::Dialog);

our $VERSION = "2.0.1";


use overload
q{""} => 'to_string';

# determine the filter (internal utility method)
sub _get_filter {
  my $self  = shift;
  if ($self->{interactive_filter_type} eq 'ldap') {
    return($self->{entryInteractiveFilter}->get_text);
  } elsif ($self->{interactive_filter_type} eq 'none') {
    return('');
  } elsif ($self->{interactive_filter_type} eq 'simple') {
    return('cn=*'.$self->{entryInteractiveFilter}->get_text.'*');
  }
  return('');
}

#---[ sub new ]---{{{

=head1 CONSTRUCTOR

=over 4



( run in 1.089 second using v1.01-cache-2.11-cpan-364913b4093 )