[otrs-cvs] FAQ/Kernel/System FAQ.pm,1.15,1.16

cvs-log at otrs.org cvs-log at otrs.org
Fri Mar 14 15:50:49 GMT 2008


Comments:
Update of /home/cvs/FAQ/Kernel/System
In directory lancelot:/tmp/cvs-serv23184/Kernel/System

Modified Files:
	FAQ.pm 
Log Message:
Fixed SQL syntax problems.

Author: martin

Index: FAQ.pm
===================================================================
RCS file: /home/cvs/FAQ/Kernel/System/FAQ.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** FAQ.pm	2 Mar 2008 22:27:06 -0000	1.15
--- FAQ.pm	14 Mar 2008 15:50:44 -0000	1.16
***************
*** 618,622 ****
          $Param{$_} = $Self->{DBObject}->Quote($Param{$_});
      }
!     foreach (qw(ItemID)) {
          $Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
      }
--- 618,622 ----
          $Param{$_} = $Self->{DBObject}->Quote($Param{$_});
      }
!     foreach (qw(ItemID Rate)) {
          $Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
      }
***************
*** 629,633 ****
          " '$Param{IP}', ".
          " '$Param{Interface}', ".
!         " '$Param{Rate}', ".
          " current_timestamp ".
          " )";
--- 629,633 ----
          " '$Param{IP}', ".
          " '$Param{Interface}', ".
!         " $Param{Rate}, ".
          " current_timestamp ".
          " )";
***************
*** 1811,1815 ****
          Number => '*134*',
          What => '*some text*',
!         Keywords => '*webserver*',
          States => ['public', 'internal'],
          Order => 'Changed',
--- 1811,1815 ----
          Number => '*134*',
          What => '*some text*',
!         Keyword => '*webserver*',
          States => ['public', 'internal'],
          Order => 'Changed',
***************
*** 1832,1836 ****
  
      # sql
!     my $SQL = "SELECT i.id, count( v.item_id ) votes, avg( v.rate ) vrate".
          " FROM faq_item i ".
          " LEFT JOIN faq_voting v ON v.item_id = i.id".
--- 1832,1836 ----
  
      # sql
!     my $SQL = "SELECT i.id, count( v.item_id ) as votes, avg( v.rate ) as vrate".
          " FROM faq_item i ".
          " LEFT JOIN faq_voting v ON v.item_id = i.id".
***************
*** 1838,1842 ****
          " WHERE";
      my $Ext = '';
!     foreach my $Key (qw(f_subject f_field1 f_field2 f_field3 f_field4 f_field5 f_field6)) {
          if ($Ext) {
              $Ext .= ' OR ';
--- 1838,1842 ----
          " WHERE";
      my $Ext = '';
!     foreach my $Key (qw(f_subject f_keywords f_field1 f_field2 f_field3 f_field4 f_field5 f_field6)) {
          if ($Ext) {
              $Ext .= ' OR ';
***************
*** 1855,1860 ****
                      $What .= ' OR ';
                  }
!                 my $ValueInsert = lc $Self->{DBObject}->Quote($Value);
!                 $What .= " i.$Key LIKE '$ValueInsert'";
              }
              $Ext .= $What;
--- 1855,1873 ----
                      $What .= ' OR ';
                  }
! # prepared for OTRS 2.3.x
!                 my $ValueInsert = $Self->{DBObject}->Quote($Value);
! #                my $ValueInsert = $Self->{DBObject}->Quote($Value, 'Like');
! #                if ( $Self->{DBObject}->GetDatabaseFunction('NoLowerInLargeText') ) {
!                 if ( $Self->{DBObject}->GetDatabaseFunction('Type') eq 'mssql' ) {
!                     $What .= " i.$Key LIKE '$ValueInsert'";
!                 }
! # prepared for OTRS 2.3.x
! #                elsif ( $Self->{DBObject}->GetDatabaseFunction('LcaseLikeInLargeText') ) {
!                 elsif ( $Self->{DBObject}->GetDatabaseFunction('Type') eq 'db2' ) {
!                     $What .= " LCASE(i.$Key) LIKE LCASE('$ValueInsert')";
!                 }
!                 else {
!                     $What .= " LOWER(i.$Key) LIKE LOWER('$ValueInsert')";
!                 }
              }
              $Ext .= $What;
***************
*** 1867,1876 ****
      if ($Param{Number}) {
          $Param{Number} =~ s/\*/%/g;
!         $Param{Number} = lc $Self->{DBObject}->Quote($Param{Number});
!         $Ext .= " AND i.f_number LIKE '$Param{Number}'";
      }
      if ($Param{Title}) {
!         $Param{Title} = lc $Self->{DBObject}->Quote($Param{Title});
!         $Ext .= " AND i.f_subject LIKE '%".$Param{Title}."%'";
      }
      if ($Param{LanguageIDs} && ref($Param{LanguageIDs}) eq 'ARRAY' && @{$Param{LanguageIDs}}) {
--- 1880,1893 ----
      if ($Param{Number}) {
          $Param{Number} =~ s/\*/%/g;
!         $Param{Number} =~ s/%%/%/g;
!         $Param{Number} = $Self->{DBObject}->Quote($Param{Number});
!         $Ext .= " AND LOWER(i.f_number) LIKE LOWER('$Param{Number}')";
      }
      if ($Param{Title}) {
!         $Param{Title} = "\%$Param{Title}\%";
!         $Param{Title} =~ s/\*/%/g;
!         $Param{Title} =~ s/%%/%/g;
!         $Param{Title} = $Self->{DBObject}->Quote($Param{Title});
!         $Ext .= " AND LOWER(i.f_subject) LIKE LOWER('".$Param{Title}."')";
      }
      if ($Param{LanguageIDs} && ref($Param{LanguageIDs}) eq 'ARRAY' && @{$Param{LanguageIDs}}) {
***************
*** 1906,1911 ****
      }
      if ($Param{Keyword}) {
!         $Param{Keyword} = lc $Self->{DBObject}->Quote($Param{Keyword});
!         $Ext .= " AND i.f_keywords LIKE '%".$Param{Keyword}."%'";
      }
      $Ext .= " GROUP BY i.id, i.f_subject, i.f_language_id, i.created, i.changed, s.name, v.item_id";
--- 1923,1944 ----
      }
      if ($Param{Keyword}) {
!         $Param{Keyword} = "\%$Param{Keyword}\%";
!         $Param{Keyword} =~ s/\*/%/g;
!         $Param{Keyword} =~ s/%%/%/g;
!         $Param{Keyword} = $Self->{DBObject}->Quote($Param{Keyword});
! # prepared for OTRS 2.3.x
! #        $Param{Keyword} = $Self->{DBObject}->Quote($Param{Keyword}, 'Like');
! #        if ( $Self->{DBObject}->GetDatabaseFunction('NoLowerInLargeText') ) {
!         if ( $Self->{DBObject}->GetDatabaseFunction('Type') eq 'mssql' ) {
!             $Ext .= " AND i.f_keywords LIKE '".$Param{Keyword}."'";
!         }
! # prepared for OTRS 2.3.x
! #        elsif ( $Self->{DBObject}->GetDatabaseFunction('LcaseLikeInLargeText') ) {
!         elsif ( $Self->{DBObject}->GetDatabaseFunction('Type') eq 'db2' ) {
!             $Ext .= " AND LCASE(i.f_keywords) LIKE LCASE('".$Param{Keyword}."')";
!         }
!         else {
!             $Ext .= " AND LOWER(i.f_keywords) LIKE LOWER('".$Param{Keyword}."')";
!         }
      }
      $Ext .= " GROUP BY i.id, i.f_subject, i.f_language_id, i.created, i.changed, s.name, v.item_id";


More information about the cvs-log mailing list