/[virtual-ldap]/lib/LDAP/Koha.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/LDAP/Koha.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 47 by dpavlin, Fri Apr 17 21:39:45 2009 UTC revision 50 by dpavlin, Wed Apr 29 09:03:47 2009 UTC
# Line 25  our $database = 'koha'; Line 25  our $database = 'koha';
25  our $user     = 'unconfigured-user';  our $user     = 'unconfigured-user';
26  our $passwd   = 'unconfigured-password';  our $passwd   = 'unconfigured-password';
27    
28  our $max_results = 15; # 100; # FIXME  our $max_results = 3000; # FIXME must be enough for all users
29    
30  our $objectclass = 'HrEduPerson';  our $objectclass = 'HrEduPerson';
31    
# Line 177  sub search { Line 177  sub search {
177                                          }                                          }
178                                  }                                  }
179    
                                 $sql_where .= ' ' . join( " $filter ", @limits );  
   
180                          } else {                          } else {
181                                  __ldap_search_to_sql( $filter, $reqData->{'filter'}->{$filter} );                                  __ldap_search_to_sql( $filter, $reqData->{'filter'}->{$filter} );
182                          }                          }
183    
184                            $sql_where .= ' ' . join( " $filter ", @limits ) if @limits;
185    
186                  }                  }
187    
188                    my $sql_select = read_file( lc "sql/$objectclass.sql" );
189                  if ( $sql_where ) {                  if ( $sql_where ) {
190                          $sql_where = " where $sql_where";                          if ( $sql_select !~ m{where}i ) {
191                                    $sql_where = " where $sql_where";
192                            } else {
193                                    $sql_where = " and $sql_where";
194                            }
195                  }                  }
196    
                 my $sql_select = read_file( lc "sql/$objectclass.sql" );  
197    
198                  warn "# SQL:\n$sql_select\n", $sql_where ? $sql_where : '-- no where', "\n# DATA: ",dump( @values );                  warn "# SQL:\n$sql_select\n", $sql_where ? $sql_where : '-- no where', "\n# DATA: ",dump( @values );
199                  my $sth = $dbh->prepare( $sql_select . $sql_where . " LIMIT $max_results" ); # XXX remove limit?                  my $sth = $dbh->prepare( $sql_select . $sql_where . " LIMIT $max_results" ); # XXX remove limit?
# Line 197  sub search { Line 201  sub search {
201    
202                  warn "# ", $sth->rows, " results for ",dump( $reqData->{'filter'} );                  warn "# ", $sth->rows, " results for ",dump( $reqData->{'filter'} );
203    
204                    my $last_dn = '?';
205                    my $entry;
206    
207                  while (my $row = $sth->fetchrow_hashref) {                  while (my $row = $sth->fetchrow_hashref) {
208    
209                          my ( $dn, $attributes ) = _dn_attributes( $row, $base );                          my ( $dn, $attributes ) = _dn_attributes( $row, $base );
210    
211                          my $entry = Net::LDAP::Entry->new;                          warn "# dn $last_dn ... $dn\n";
                         $entry->dn( $dn );  
                         $entry->add( %$attributes );  
212    
213                          #$entry->changetype( 'modify' );                          if ( $dn ne $last_dn ) {
214    
215                                    if ( $entry ) {
216                                            #$entry->changetype( 'modify' );
217                                            warn "### entry ",$entry->dump( \*STDERR );
218                                            push @entries, $entry;
219                                            undef $entry;
220                                    }
221    
222                          warn "### entry ",$entry->dump( \*STDERR );                                  $entry = Net::LDAP::Entry->new;
223                                    $entry->dn( $dn );
224    
225                                    $entry->add( %$attributes );
226    
227                            } else {
228                                    foreach my $n ( keys %$attributes ) {
229                                            my $v = $attributes->{$n};
230                                            warn "# attr $n = $v\n";
231                                            $entry->add( $n, $v ) if $entry->get_value( $n ) ne $v;
232                                    }
233                            }
234    
235    
236                            $last_dn = $dn;
237    
                         push @entries, $entry;  
238                  }                  }
239    
240                    warn "### last entry ",$entry->dump( \*STDERR );
241                    push @entries, $entry;
242    
243          } else {          } else {
244                  warn "UNKNOWN request: ",dump( $reqData );                  warn "UNKNOWN request: ",dump( $reqData );
245          }          }

Legend:
Removed from v.47  
changed lines
  Added in v.50

  ViewVC Help
Powered by ViewVC 1.1.26