[otrs-cvs] CVS: FAQ/Kernel/System FAQ.pm,1.5,1.6

cvs-log at otrs.org cvs-log at otrs.org
Wed Dec 13 16:22:03 CET 2006


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

Modified Files:
	FAQ.pm 
Log Message:
fixed bug not display category

Index: FAQ.pm
===================================================================
RCS file: /home/cvs/FAQ/Kernel/System/FAQ.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** FAQ.pm	26 Oct 2006 14:29:08 -0000	1.5
--- FAQ.pm	13 Dec 2006 15:22:01 -0000	1.6
***************
*** 189,192 ****
--- 189,194 ----
          $Data{Content} = $Row[3];
      }
+     my $Hash = $Self->GetCategoryTree();
+     $Data{CategoryName} = $Hash->{$Data{CategoryID}};
  
      return %Data;
***************
*** 893,897 ****
      my @Data = ();
      $Self->{DBObject}->Prepare(
!         SQL => "SELECT name, created FROM faq_history WHERE item_id = $Param{ItemID}",
      );
      while  (my @Row = $Self->{DBObject}->FetchrowArray()) {
--- 895,899 ----
      my @Data = ();
      $Self->{DBObject}->Prepare(
!         SQL => "SELECT name, created, created_by FROM faq_history WHERE item_id = $Param{ItemID}",
      );
      while  (my @Row = $Self->{DBObject}->FetchrowArray()) {
***************
*** 899,902 ****
--- 901,905 ----
              Name => $Row[0],
              Created => $Row[1],
+             CreatedBy => $Row[2],
          );
          push (@Data, \%Record);
***************
*** 1951,1954 ****
--- 1954,2013 ----
  }
  
+ =item GetCategoryTree()
+ 
+ get all categories as tree
+ 
+   my $Hash = $FAQObject->GetCategoryTree(
+       Valid => 0, # if 1 then check valid category
+    );
+ 
+ =cut
+ 
+ sub GetCategoryTree {
+     my $Self = shift;
+     my %Param = @_;
+     my %Hash = ();
+     my $SQL = '';
+     # sql
+     $SQL = "SELECT id, parent_id, name FROM faq_category";
+     if ($Param{Valid}) {
+         $SQL .= " WHERE valid_id = 1";
+     }
+     $SQL .= " ORDER BY name";
+     $Self->{DBObject}->Prepare(SQL => $SQL);
+     # tree
+     my @Data;
+     while (my @Row = $Self->{DBObject}->FetchrowArray()) {
+         push (@Data, \@Row);
+     }
+     foreach my $Row (@Data) {
+         my @RowData = @{$Row};
+         $Hash{$RowData[1]}{$RowData[0]} = $RowData[2];
+     }
+     # return tree
+     my $Categories = $Self->_MakeTree(ParentID => 0, Parent => '', Hash => \%Hash, Tree => {},);
+     if (!$Categories) {
+         $Categories = {};
+     }
+     return $Categories;
+ }
+ 
+ sub _MakeTree {
+     my $Self = shift;
+     my %Param = @_;
+     foreach my $ID (keys(%{$Param{Hash}->{$Param{ParentID}}})) {
+         $Param{Tree}->{$ID} = $Param{Parent}.$Param{Hash}->{$Param{ParentID}}{$ID};
+         if (defined($Param{Hash}->{$ID})) {
+             $Self->_MakeTree(
+                 ParentID => $ID,
+                 Hash => $Param{Hash},
+                 Tree => $Param{Tree},
+                 Parent => $Param{Tree}->{$ID}.'::',
+             )
+         }
+     }
+     return $Param{Tree};
+ }
+ 
  1;
  



More information about the cvs-log mailing list