| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::LDAP::HTMLWidget; | 
| 2 | 1 |  |  | 1 |  | 25349 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 36 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | our $VERSION = '0.07'; | 
| 6 |  |  |  |  |  |  | # pod after __END__ | 
| 7 | 1 |  |  | 1 |  | 5 | use Carp qw(croak); | 
|  | 1 |  |  |  |  | 6 |  | 
|  | 1 |  |  |  |  | 592 |  | 
| 8 |  |  |  |  |  |  | our $DECODE = 0; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | sub fill_widget { | 
| 11 | 0 |  |  | 0 | 1 |  | my ($self,$entry,$widget)=@_; | 
| 12 | 0 | 0 | 0 |  |  |  | if (ref($entry) and $entry->isa('HTML::Widget')) { | 
| 13 | 0 |  |  |  |  |  | $widget = $entry; | 
| 14 | 0 |  |  |  |  |  | $entry = $self; | 
| 15 |  |  |  |  |  |  | } | 
| 16 | 0 |  |  |  |  |  | my @elements = $widget->find_elements; | 
| 17 | 0 |  |  |  |  |  | foreach my $element ( @elements ) { | 
| 18 | 0 |  |  |  |  |  | my $name=$element->name; | 
| 19 | 0 | 0 | 0 |  |  |  | next unless $name && $entry->exists($name) && $element->can('value'); | 
|  |  |  | 0 |  |  |  |  | 
| 20 | 0 |  |  |  |  |  | my $v = $entry->get_value($name); | 
| 21 | 0 | 0 |  |  |  |  | if ($DECODE) { | 
| 22 | 0 |  |  |  |  |  | $v = Encode::decode($DECODE, $v); | 
| 23 |  |  |  |  |  |  | } | 
| 24 | 0 |  |  |  |  |  | $element->value( $v ); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub populate_from_widget { | 
| 30 | 0 |  |  | 0 | 1 |  | my ($self,$entry,$result,$ldap)=@_; | 
| 31 | 0 | 0 | 0 |  |  |  | if (ref($entry) and $entry->isa('HTML::Widget::Result')) { | 
| 32 | 0 |  |  |  |  |  | $ldap = $result; | 
| 33 | 0 |  |  |  |  |  | $result = $entry; | 
| 34 | 0 |  |  |  |  |  | $entry = $self; | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 0 | 0 | 0 |  |  |  | $ldap = $self if (ref $self && ($self->isa('Net::LDAP') || $self->isa('Catalyst::Model::LDAP::Connection'))); | 
|  |  |  | 0 |  |  |  |  | 
| 38 | 0 | 0 | 0 |  |  |  | $ldap = $self->_ldap_client if (ref($self) and $self->isa('Catalyst::Model::LDAP::Entry') && $self->_ldap_client); | 
|  |  |  | 0 |  |  |  |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 0 | 0 |  |  |  |  | croak("No LDAP connection: " . ref($self)) unless $ldap; | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 0 | 0 |  |  |  |  | foreach my $oc ( ref $entry->get_value('objectClass') | 
|  | 0 |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | ? @{$entry->get_value('objectClass')} | 
| 44 |  |  |  |  |  |  | : ($entry->get_value('objectClass'))) { | 
| 45 | 0 |  |  |  |  |  | foreach my $attr ($ldap->schema->must($oc),$ldap->schema->may($oc)) { | 
| 46 | 0 | 0 |  |  |  |  | $entry->replace($attr->{name}, $result->param($attr->{name})) | 
| 47 |  |  |  |  |  |  | if defined $result->param($attr->{name}); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | } | 
| 50 | 0 |  |  |  |  |  | return $entry->update($ldap); | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | 1; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | __END__ |