phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.13,1.14 class.


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.13,1.14 class.sokb.inc.php,1.14,1.15 class.uikb.inc.php,1.13,1.14
Date: Wed, 28 May 2003 02:22:46 -0400

Update of /cvsroot/phpgroupware/phpbrain/inc
In directory subversions:/tmp/cvs-serv29388

Modified Files:
        class.bokb.inc.php class.sokb.inc.php class.uikb.inc.php 
Log Message:
various fixes

Index: class.bokb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.bokb.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.bokb.inc.php  30 Apr 2003 21:42:56 -0000      1.13
--- class.bokb.inc.php  28 May 2003 06:22:44 -0000      1.14
***************
*** 1,267 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - KnowledgeBase                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Dave Hall [skwashd AT phpgroupware DOT org]                
   *
!       * 
------------------------------------------------------------------------ *
!       * Started off as a port of phpBrain - http://vrotvrot.com/phpBrain/     
   *
!       *  but quickly became a full rewrite                                    
   *
!       * 
------------------------------------------------------------------------ *
!       *  This program is free software; you can redistribute it and/or modify 
it *
!       *  under the terms of the GNU General Public License as published by 
the   *
!       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
!       *  option) any later version.                                           
   *
!       
\**************************************************************************/
! 
!       class bokb
!       {
!               var $cats;
!               var $rated;
!               var $so;
!               var $viewed;
!       
!               function bokb()
!               {
!                       $this->cats = createObject('phpgwapi.categories');
!                               $this->rated = 
$GLOBALS['phpgw']->session->appsession('rated','phpbrain');
!                               $this->so = createObject('phpbrain.sokb');
!                               $this->viewed = 
$GLOBALS['phpgw']->session->appsession('viewed','phpbrain');
!                               
$GLOBALS['phpgw_info']['apps']['phpkb']['config'] = $this->get_config();
!               }
!               
!               function get_cat_data($cat_id)
!               {
!                       $cat_id = (int) $cat_id;
!                       $cats = $this->cats->return_array('all', 0, False, '', 
'', '', False, $cat_id);
!                       if(is_array($cats))
!                       {
!                       foreach ($cats as $c_key => $c_vals)
!                       {
!                               $id = $c_vals['id'];
!                               $return_cats[$id] = array('name'                
=> $c_vals['name'],
!                                                                               
'num_entries'   => $this->so->get_count($id)
!                                                                               
);
!   
!                               $sub_cats = $this->cats->return_array('subs', 
0, False, '', '', '', False, $id);
!                               if(is_array($sub_cats))
!                               {
!                                       foreach($sub_cats as $sub_key => 
$sub_vals)
!                                       {
!                                               $sub_id = $sub_vals['id'];
!                                               
$return_cats[$id]['subs'][$sub_id] 
!                                                       = array('name'  => 
$sub_vals['name'],
!                                                               'num_entries'   
=> $this->so->get_count($sub_id)
!                                                               );
!                                       }//end foreach(subcats)
!                                       unset($sub_cats);
!                               }//end if is_array(sub_cats)
!                       }//end foreach(cats)
!                               return $return_cats;
!                       }
!                       else //no cats
!                       {
!                               return false;
!                       }//end if is_array(cats)
! 
!               }//end get_cat_data
!               
!               function delete_comment($comment_id)
!               {
!                       $faq_id = (int) $faq_id;
!                       if(faq_id)
!                       {
!                               return $this->so->delete_comment($comment_id);
!                       }
!                       return false;
!               }
! 
!               function get_comments($faq_id)
!               {
!                       $comments = $this->so->get_comments($faq_id);
!                       if(is_array($comments))
!                       {
!                               foreach($comments as $key => $vals)
!                               {
!                                       $comments[$key]['comment_date'] = 
date('d-M-Y', $vals['entered']);
!                                       $comments[$key]['comment_user'] = 
$GLOBALS['phpgw']->common->grab_owner_name($vals['user_id']);
!                               }//end foreach(comment)
!                       }//end is_array(comments)
!                       return $comments;
!               }//end get_comments
! 
!               function get_config()
!               {
!                       if(!is_object($GLOBALS['phpgw']->config))
!                       {
!                               $config = createObject('phpgwapi.config');
!                       }
!                       else
!                       {
!                               $config = $GLOBALS['phpgw']->config;
!                       }
!                       
!                       $config->read_repository();
!                       return $config->config_data;
!                       
!               }//end get_config
!               
!               function get_faq_list($cat_id = '', $unpublished = false)
!               {
!                       if(!$this->is_admin() && $unpublished)
!                       {
!                               $unpublished = false;
!                       }
! 
!                       $faqs = $this->so->get_faq_list($cat_id, $unpublished);
!                       if(is_array($faqs))
!                       {
!                       foreach($faqs as $faq_id => $faq_vals)
!                       {
!                               $faqs[$faq_id]['vote_avg'] = 
(($faq_vals['total'] && $faq_vals['votes'])
!                                                                               
                ? round(($faq_vals['total'] / $faq_vals['votes']),2) : 0);
!                               $faqs[$faq_id]['last_mod'] = date('d-M-Y', 
$faqs[$faq_id]['modified']);
!                                       $faqs[$faq_id]['score'] = '1.00'; 
!                                       $faqs[$faq_id]['title'] = 
($item['is_faq'] 
!                                                                               
        ? lang('question') . ': '. $faqs[$faq_id]['title']
!                                                                               
        : lang('tutorial') . ': '. $faqs[$faq_id]['title']);
! 
!                       }
!                       }
!                       return $faqs;
!               }//end get_faq_list
! 
!               function get_item($faq_id, $show_type = True)
!               {
!                       $item = $this->so->get_item($faq_id, 
address@hidden>viewed[$faq_id]);
!                       if(is_array($item))
!                       {
!                               $item['last_mod']       = date('d-M-Y', 
$item['modified']);
!                               $item['username']       = 
$GLOBALS['phpgw']->common->grab_owner_name($item['user_id']);
!                               $item['rating']         = ($item['votes'] 
!                                                               ? 
round(($item['total']/$item['votes']),2) : 0);
!                               $item['comments']       = 
$this->get_comments($faq_id); 
!                               if($show_type)
!                               {
!                                       $item['title'] = ($item['is_faq'] 
!                                                               ? lang('faq') . 
': '. $item['title']
!                                                               : 
lang('tutorial') . ': '. $item['title']);
!                               }
!                               $this->viewed[$faq_id] = True;
!                               
$GLOBALS['phpgw']->session->appsession('viewed','phpbrain', $this->viewed);
! 
!                       }//end if is_array(item)
! 
!                       return $item;
! 
!               }//end get_item
!               
!               function get_latest()
!               {
!                       return $this->so->get_latest();
!               }// end get_latest
!               
!               function get_questions($pending = false)
!               {
!                       if(!$this->is_admin() && $pending)
!                       {
!                               return null;
!                       }
!                       else
!                       {
!                               return $this->so->get_questions($pending);
!                       }
!               }//end questions
! 
!               function get_search_results($search, $show)
!               {
!                       $results = $this->so->get_search_results($search, 
$show);
!                       if(is_array($results))
!                       {
!                       foreach($results as $id => $vals)
!                       {
!                               $results[$id]['vote_avg'] = (($vals['total'] && 
$vals['votes'])
!                                                                               
                ? round(($vals['total'] / $vals['votes']),2) : 0);
!                               $results[$id]['last_mod'] = date('d-M-Y', 
$vals['modified']);
! 
!                                               $results[$id]['title'] = 
($results[$id]['is_faq'] 
!                                                                               
                ? lang('question') . ': '. $results[$id]['title']
!                                                                               
                : lang('tutorial') . ': '. $results[$id]['title']);
!                       }
!                       }
!                       return $results;
!               }//end get search results
!               
!               function get_stats()
!               {
!                       return $this->so->get_stats();
!               }//end get_stats
! 
!               function is_admin()
!               {
!                       return 
isset($GLOBALS['phpgw_info']['user']['apps']['admin']);
!               }//end is_admin
!               
!               function is_anon()
!               {
!                       return 
($GLOBALS['phpgw_info']['apps']['phpkb']['config']['anon_user'] 
!                                               == 
$GLOBALS['phpgw_info']['user']['account_id']);
!               }//end is_anon
! 
!               function save($faq_id, $faq, $question_id)
!               {
!                       
if(!$GLOBALS['phpgw_info']['apps']['phpkb']['config']['alow_tags'])
!                       {
!                               $faq['title'] = strip_tags($faq['title']);
!                               $faq['keywords'] = strip_tags($faq['keywords']);
!                               $faq['text'] = strip_tags($faq['text']);
!                       }
!                       $faq['user_id'] = (isset($faq['user_id']) ? 
$faq['user_id'] : $GLOBALS['phpgw_info']['user']['account_id']);
!                       $new_faq_id = $this->so->save($faq_id, $faq, 
$this->is_admin());
!                       if($new_faq_id && $question_id && !$faq_id)
!                       {
!                               $this->so->delete_question($question_id);
!                       }
!                       return $new_faq_id;
!                       
!               }//end save
!               
!               function set_active_answer($faq_ids)
!               {
!                       return $this->so->set_active_answer($faq_ids);
!               }//end set active answer
!               
!               function set_active_question($question_ids)
!               {
!                       return $this->so->set_active_question($question_ids);
!               }//end set active question
! 
!               function set_comment($comment_id, $comment_data)
!               {
!                       $comment_id = (int) $comment_id;
!                       $comment_data['faq_id'] = (int) $comment_data['faq_id'];
!                       $comment_data['user_id'] = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                       $this->so->set_comment($comment_id, $comment_data);
!               }//end set comment
! 
!               function set_question($question)
!               {
!                       return $this->so->set_question($question, 
$this->is_admin());
!               }//end set question
!               
!               function set_rating($faq_id, $rating)
!               {
!                       if(address@hidden>rated[$faq_id])//only rate if not 
already done so
!                       {
!                               //make sure values are within a valid range
!                               $rating = ($rating < 1 ? 1 : $rating);
!                               $rating = ($rating > 5 ? 5 : $rating);
! 
!                               $this->so->set_rating($faq_id, $rating);
!                               $this->rated[$faq_id] = True;
!                               
$GLOBALS['phpgw']->session->appsession('rated','phpbrain', $this->rated);
!                       }
!               }//end set_rating
!               
!       }//end class bokb
!       
!       
--- 1,273 ----
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - KnowledgeBase                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Dave Hall [skwashd AT phpgroupware DOT org]                
   *
!       * 
------------------------------------------------------------------------ *
!       * Started off as a port of phpBrain - http://vrotvrot.com/phpBrain/     
   *
!       *  but quickly became a full rewrite                                    
   *
!       * 
------------------------------------------------------------------------ *
!       *  This program is free software; you can redistribute it and/or modify 
it *
!       *  under the terms of the GNU General Public License as published by 
the   *
!       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
!       *  option) any later version.                                           
   *
!       
\**************************************************************************/
! 
!       class bokb
!       {
!               var $cats;
!               var $rated;
!               var $so;
!               var $viewed;
!       
!               function bokb()
!               {
!                       $this->cats = createObject('phpgwapi.categories');
!                               $this->rated = 
$GLOBALS['phpgw']->session->appsession('rated','phpbrain');
!                               $this->so = createObject('phpbrain.sokb');
!                               $this->viewed = 
$GLOBALS['phpgw']->session->appsession('viewed','phpbrain');
!                               
$GLOBALS['phpgw_info']['apps']['phpkb']['config'] = $this->get_config();
!               }
!               
!               function get_cat_data($cat_id)
!               {
!                       $cat_id = (int) $cat_id;
!                       $cats = $this->cats->return_array('all', 0, False, '', 
'', '', False, $cat_id);
!                       if(is_array($cats))
!                       {
!                       foreach ($cats as $c_key => $c_vals)
!                       {
!                               $id = $c_vals['id'];
!                               $return_cats[$id] = array('name'                
=> $c_vals['name'],
!                                                                               
'num_entries'   => $this->so->get_count($id)
!                                                                               
);
!   
!                               $sub_cats = $this->cats->return_array('subs', 
0, False, '', '', '', False, $id);
!                               if(is_array($sub_cats))
!                               {
!                                       foreach($sub_cats as $sub_key => 
$sub_vals)
!                                       {
!                                               $sub_id = $sub_vals['id'];
!                                               
$return_cats[$id]['subs'][$sub_id] 
!                                                       = array('name'  => 
$sub_vals['name'],
!                                                               'num_entries'   
=> $this->so->get_count($sub_id)
!                                                               );
!                                       }//end foreach(subcats)
!                                       unset($sub_cats);
!                               }//end if is_array(sub_cats)
!                       }//end foreach(cats)
!                               return $return_cats;
!                       }
!                       else //no cats
!                       {
!                               return false;
!                       }//end if is_array(cats)
! 
!               }//end get_cat_data
!               
!               function delete_comment($comment_id)
!               {
!                       $comment_id = (int) $comment_id;
!                       if($comment_id)
!                       {
!                               return $this->so->delete_comment($comment_id);
!                       }
!                       return false;
!               }
! 
!               function delete_answer($answers)
!               {
!                       return $this->so->delete_answer($answers);
!               }
! 
!               
!               function get_comments($faq_id)
!               {
!                       $comments = $this->so->get_comments($faq_id);
!                       if(is_array($comments))
!                       {
!                               foreach($comments as $key => $vals)
!                               {
!                                       $comments[$key]['comment_date'] = 
date('d-M-Y', $vals['entered']);
!                                       $comments[$key]['comment_user'] = 
$GLOBALS['phpgw']->common->grab_owner_name($vals['user_id']);
!                               }//end foreach(comment)
!                       }//end is_array(comments)
!                       return $comments;
!               }//end get_comments
! 
!               function get_config()
!               {
!                       if(!is_object($GLOBALS['phpgw']->config))
!                       {
!                               $config = createObject('phpgwapi.config');
!                       }
!                       else
!                       {
!                               $config = $GLOBALS['phpgw']->config;
!                       }
!                       
!                       $config->read_repository();
!                       return $config->config_data;
!                       
!               }//end get_config
!               
!               function get_faq_list($cat_id = '', $unpublished = false)
!               {
!                       if(!$this->is_admin() && $unpublished)
!                       {
!                               $unpublished = false;
!                       }
! 
!                       $faqs = $this->so->get_faq_list($cat_id, $unpublished);
!                       if(is_array($faqs))
!                       {
!                       foreach($faqs as $faq_id => $faq_vals)
!                       {
!                               $faqs[$faq_id]['vote_avg'] = 
(($faq_vals['total'] && $faq_vals['votes'])
!                                                                               
                ? round(($faq_vals['total'] / $faq_vals['votes']),2) : 0);
!                               $faqs[$faq_id]['last_mod'] = date('d-M-Y', 
$faqs[$faq_id]['modified']);
!                                       $faqs[$faq_id]['score'] = '1.00'; 
!                                       $faqs[$faq_id]['title'] = 
($item['is_faq'] 
!                                                                               
        ? lang('question') . ': '. $faqs[$faq_id]['title']
!                                                                               
        : lang('tutorial') . ': '. $faqs[$faq_id]['title']);
! 
!                       }
!                       }
!                       return $faqs;
!               }//end get_faq_list
! 
!               function get_item($faq_id, $show_type = True)
!               {
!                       $item = $this->so->get_item($faq_id, 
address@hidden>viewed[$faq_id]);
!                       if(is_array($item))
!                       {
!                               $item['last_mod']       = date('d-M-Y', 
$item['modified']);
!                               $item['username']       = 
$GLOBALS['phpgw']->common->grab_owner_name($item['user_id']);
!                               $item['rating']         = ($item['votes'] 
!                                                               ? 
round(($item['total']/$item['votes']),2) : 0);
!                               $item['comments']       = 
$this->get_comments($faq_id); 
!                               if($show_type)
!                               {
!                                       $item['title'] = ($item['is_faq'] 
!                                                               ? lang('faq') . 
': '. $item['title']
!                                                               : 
lang('tutorial') . ': '. $item['title']);
!                               }
!                               $this->viewed[$faq_id] = True;
!                               
$GLOBALS['phpgw']->session->appsession('viewed','phpbrain', $this->viewed);
! 
!                       }//end if is_array(item)
! 
!                       return $item;
! 
!               }//end get_item
!               
!               function get_latest()
!               {
!                       return $this->so->get_latest();
!               }// end get_latest
!               
!               function get_questions($pending = false)
!               {
!                       if(!$this->is_admin() && $pending)
!                       {
!                               return null;
!                       }
!                       else
!                       {
!                               return $this->so->get_questions($pending);
!                       }
!               }//end questions
! 
!               function get_search_results($search, $show)
!               {
!                       $results = $this->so->get_search_results($search, 
$show);
!                       if(is_array($results))
!                       {
!                       foreach($results as $id => $vals)
!                       {
!                               $results[$id]['vote_avg'] = (($vals['total'] && 
$vals['votes'])
!                                                                               
                ? round(($vals['total'] / $vals['votes']),2) : 0);
!                               $results[$id]['last_mod'] = date('d-M-Y', 
$vals['modified']);
! 
!                                               $results[$id]['title'] = 
($results[$id]['is_faq'] 
!                                                                               
                ? lang('question') . ': '. $results[$id]['title']
!                                                                               
                : lang('tutorial') . ': '. $results[$id]['title']);
!                       }
!                       }
!                       return $results;
!               }//end get search results
!               
!               function get_stats()
!               {
!                       return $this->so->get_stats();
!               }//end get_stats
! 
!               function is_admin()
!               {
!                       return 
isset($GLOBALS['phpgw_info']['user']['apps']['admin']);
!               }//end is_admin
!               
!               function is_anon()
!               {
!                       return 
($GLOBALS['phpgw_info']['apps']['phpkb']['config']['anon_user'] 
!                                               == 
$GLOBALS['phpgw_info']['user']['account_id']);
!               }//end is_anon
! 
!               function save($faq_id, $faq, $question_id)
!               {
!                       
if(!$GLOBALS['phpgw_info']['apps']['phpkb']['config']['alow_tags'])
!                       {
!                               $faq['title'] = strip_tags($faq['title']);
!                               $faq['keywords'] = strip_tags($faq['keywords']);
!                               $faq['text'] = strip_tags($faq['text']);
!                       }
!                       $faq['user_id'] = (isset($faq['user_id']) ? 
$faq['user_id'] : $GLOBALS['phpgw_info']['user']['account_id']);
!                       $new_faq_id = $this->so->save($faq_id, $faq, 
$this->is_admin());
!                       if($new_faq_id && $question_id && !$faq_id)
!                       {
!                               $this->so->delete_question($question_id);
!                       }
!                       return $new_faq_id;
!                       
!               }//end save
!               
!               function set_active_answer($faq_ids)
!               {
!                       return $this->so->set_active_answer($faq_ids);
!               }//end set active answer
!               
!               function set_active_question($question_ids)
!               {
!                       return $this->so->set_active_question($question_ids);
!               }//end set active question
! 
!               function set_comment($comment_id, $comment_data)
!               {
!                       $comment_id = (int) $comment_id;
!                       $comment_data['faq_id'] = (int) $comment_data['faq_id'];
!                       $comment_data['user_id'] = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                       $this->so->set_comment($comment_id, $comment_data);
!               }//end set comment
! 
!               function set_question($question)
!               {
!                       return $this->so->set_question($question, 
$this->is_admin());
!               }//end set question
!               
!               function set_rating($faq_id, $rating)
!               {
!                       if(address@hidden>rated[$faq_id])//only rate if not 
already done so
!                       {
!                               //make sure values are within a valid range
!                               $rating = ($rating < 1 ? 1 : $rating);
!                               $rating = ($rating > 5 ? 5 : $rating);
! 
!                               $this->so->set_rating($faq_id, $rating);
!                               $this->rated[$faq_id] = True;
!                               
$GLOBALS['phpgw']->session->appsession('rated','phpbrain', $this->rated);
!                       }
!               }//end set_rating
!               
!       }//end class bokb
!       
!       

Index: class.sokb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.sokb.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** class.sokb.inc.php  18 May 2003 07:24:33 -0000      1.14
--- class.sokb.inc.php  28 May 2003 06:22:44 -0000      1.15
***************
*** 1,404 ****
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - KnowledgeBase                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Dave Hall [skwashd AT phpgroupware DOT org]                
   *
!       * 
------------------------------------------------------------------------ *
!       * Started off as a port of phpBrain - http://vrotvrot.com/phpBrain/     
 *
!       *  but quickly became a full rewrite                                    
 *
!       * 
------------------------------------------------------------------------ *
!       *  This program is free software; you can redistribute it and/or modify 
it *
!       *  under the terms of the GNU General Public License as published by 
the   *
!       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
!       *  option) any later version.                                           
   *
!       
\**************************************************************************/
!       
!       class sokb
!       {
!               var $db;
!               
!               function sokb()
!               {
!                       $this->db = $GLOBALS['phpgw']->db;
!               }
! 
!               function delete_answer($faq_ids)
!               {
!                       if(is_array($faq_ids))
!                       {
!                               $i=0;
!                       foreach($faq_ids as $key => $val)
!                       {
!                               $this->db->query("DELETE FROM phpgw_kb_faq 
WHERE faq_id = $key", __LINE__, __FILE__);
!                               $i++;
!                       }//end foreach(q_id)
!                       }
!                       elseif(is_int($faq_ids))
!                       {
!                               $this->db->query("DELETE FROM phpgw_kb_faq 
WHERE faq_id = $faq_ids", __LINE__, __FILE__);
!                               $i = 1;
!                       }//end is_type
!                       return $i;
!               }//end delete_answer
!               
!               function delete_comment($comment_id)
!               {
!                       $this->db->query("DELETE FROM phpgw_kb_comment WHERE 
comment_id = $comment_id");
!                       //this really should only return true if rows affected 
== 1 
!                       return true;
!               }
! 
!               function delete_question($question_ids)
!               {
!                       if(is_array($question_ids))
!                       {
!                               $i=0;
!                       foreach($question_ids as $key => $val)
!                       {
!                               $this->db->query("DELETE FROM 
phpgw_kb_questions WHERE question_id = $key", __LINE__, __FILE__);
!                               $i++;
!                       }//end foreach(q_id)
!                       }
!                       elseif(is_int($question_ids))
!                       {
!                               $this->db->query("DELETE FROM 
phpgw_kb_questions WHERE question_id = $question_ids", __LINE__, __FILE__);
!                               $i = 1;
!                       }//end is_type
!                       return $i;
!               }//end delete question
! 
!               function get_stats()
!               {       
!                       $stats = array();
!                       /* how many faqs*/
!                       $this->db->query('SELECT COUNT(*) FROM phpgw_kb_faq 
WHERE published = 1 AND is_faq = 0', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_faqs'] = $this->db->f(0);
!     
!                       /* how many tutorials? */
!                       $this->db->query('SELECT COUNT(*) FROM phpgw_kb_faq 
WHERE published = 1 AND is_faq = 1', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_tutes'] = $this->db->f(0);
!     
!                       /* how many open questions? */
!                       $this->db->query('SELECT COUNT(*) FROM 
phpgw_kb_questions WHERE pending = 0', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_open'] = $this->db->f(0);
!                       
!                       return $stats;
!               }
!               
!               function get_latest()
!               {
!                       /* latest questions */
!                       $this->db->limit_query('SELECT * FROM 
phpgw_kb_questions WHERE pending = 0 ORDER BY question_id DESC', 0, __LINE__, 
__FILE__, 3);
! 
!                       $questions = array();
!                       while($this->db->next_record())
!                       {
!                               $questions[$this->db->f('question_id')] = 
$this->db->f('question', true);
!                       }
!                       return $questions;
!       }//end get latest
!               
!               function get_faq_list($cat_id = '', $unpublished = false)
!               {
!                       $where  = ((strlen($cat_id) != 0) ? "cat_id = $cat_id " 
: '');
!                       $where .= ((strlen($where) > 0) ? 'AND ' : '');
!                       $where .= ($unpublished ? 'published = 0' : 'published 
= 1'); 
!                       $this->db->query("SELECT * FROM phpgw_kb_faq WHERE 
$where", __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $faqs[$this->db->f('faq_id')] = array('title'   
=> $this->db->f('title', true),
!                                                               'text'          
=> substr($this->db->f('text', true),0,50) . ' ...',
!                                                               'modified'      
=> $this->db->f('modified'),
!                                                               'views'         
=> $this->db->f('views'),
!                                                               'votes'         
=> $this->db->f('votes'),
!                                                               'total'         
=> $this->db->f('total')
!                                                               );
!                       }
!                       return $faqs;
!               }
!               
!               function get_item($faq_id, $count_view)
!               {
!                       $this->db->query("SELECT * FROM phpgw_kb_faq WHERE 
faq_id = $faq_id", __LINE__, __FILE__);
!                       if($this->db->next_record())
!                       {
!                               $item = array('faq_id'          => 
$this->db->f('faq_id'),
!                                       'title'                 => 
$this->db->f('title', true),
!                                       'text'                  => 
$this->db->f('text', true),
!                                       'cat_id'                => (int) 
$this->db->f('cat_id', true),
!                                       'published'             => 
$this->db->f('published'),
!                                       'keywords'              => 
$this->db->f('keywords', true),
!                                       'user_id'               => (int) 
$this->db->f('user_id'),
!                                       'views'                 => (int) 
$this->db->f('views'),
!                                       'modified'              => (int) 
$this->db->f('modified'),
!                                       'type'                  => (int) 
$this->db->f('type'),
!                                       'url'                   => 
$this->db->f('url', true),
!                                       'votes'                 => (int) 
$this->db->f('votes'),
!                                       'total'                 => (int) 
$this->db->f('total')
!                                       );
! 
!                               if($count_view)
!                               {
!                                       $this->set_view($this->db->f('faq_id'));
!                               }
!                       }
!                       return $item;
!               }
!               
!               function get_comments($faq_id)
!               {
!                       $this->db->query("SELECT * FROM phpgw_kb_comment WHERE 
faq_id = $faq_id", __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $comment[$this->db->f('comment_id')] = 
array('user_id'  => $this->db->f('user_id'),
!                                                                       
'comment_text'  => $this->db->f('comment', true),
!                                                                       
'entered'       => $this->db->f('entered')
!                                                                       );
!                       }
!                       return $comment;
!               }
! 
!     function get_count($cat_id)
!     {
!       $this->db->query("SELECT COUNT(*) FROM phpgw_kb_faq WHERE cat_id = 
$cat_id AND published = 1", __LINE__, __FILE__);
!                       if($this->db->next_record())
!                       {
!                               return $this->db->f(0); 
!                       }
!                       else
!                       {
!                               return 0;
!                       }
!     }//end get count
!               
!               function get_pending()
!               {
!                       $this->db->query('SELECT faq_id, text FROM phpgw_kb_faq 
WHERE published = 0', __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $faq[$this->db->f('faq_id')] = 
$this->db->f('text', true); 
!                       }
!                       return $faq;
!               }//end get pending
! 
!               
!               function get_search_results($search, $show = null)
!               {
!                       switch 
(trim($GLOBALS['phpgw_info']['server']['db_type']))
!                       {
!                               /* This is not working - not sure why
!                               case 'mysql':
!                                       $ver = explode('-', 
mysql_get_server_info());
!                                       $ver = $ver[0];
!                                       
if($GLOBALS['phpgw']->common->cmp_version_long($ver, '3.23.23') <= 1)
!                                       {
!                                               return 
$this->search_mysql($search, $show);
!                                       }
!                                       else
!                                       {
!                                               return 
$this->search_ansisql($search, $show);
!                                       }
!                                       break;
!                               */
!                               //case 'pgsql': - //future use
!                               //case 'mssql': - //future use
!                               default:
!                                       return $this->search_ansisql($search, 
$show);
!                       }//end case db
!                               
!               }
! 
!               function get_questions($pending = false)
!               {
!                       $where = ($pending ? 'pending = 1' : 'pending = 0');
!                       $this->db->query("SELECT * FROM phpgw_kb_questions 
WHERE $where", __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $open_q[$this->db->f('question_id')] = 
$this->db->f('question', true); 
!                       }
!                       return $open_q;
!               }
!               
!               function save($faq_id, $faq, $admin)
!               {
!                       if(is_int($faq_id) && is_array($faq))
!                       {
!                               if($faq_id)//is new?
!                               {
!                                       $sql  =  'UPDATE phpgw_kb_faq';
!                                       $sql .= ' SET cat_id = ' . 
$faq['cat_id'] . ',';
!                                       $sql .= " title = '" . 
$this->db->db_addslashes($faq['title']) . "',";
!                                       $sql .= " keywords = '" . 
$this->db->db_addslashes($faq['keywords']) . "',";
!                                       $sql .= " text = '" . 
$this->db->db_addslashes($faq['text']) . "',";
!                                       $sql .= ' modified = ' . time() .',';
!                                       $sql .= ' user_id = ' . $faq['user_id'] 
.',';
!                                       $sql .= ' published = ' . ($admin ? 1 : 
0) . ', ';
!                                       $sql .= ' is_faq = ' . $faq['is_faq'] . 
', ';
!                                       $sql .= " url = '" . 
$this->db->db_addslashes(urldecode($faq['url'])) ."'";
!                                       $sql .= " WHERE faq_id = $faq_id";
!                                       $this->db->query($sql, __LINE__, 
__FILE__);
!                                       if($this->db->affected_rows() == 1)
!                                       {
!                                               return $faq_id;
!                                       }
!                                       else//something went wrong
!                                       {
!                                               return false;
!                                       } 
!                               }
!                               else//must be new
!                               {
!                                       $sql  = 'INSERT INTO phpgw_kb_faq 
(title, text, cat_id, published, keywords, user_id, views, modified, is_faq, 
url) ';
!                                       $sql .= "VALUES('" . 
$this->db->db_addslashes($faq['title']) . "', ";
!                                       $sql .= "'" . 
$this->db->db_addslashes($faq['text']) . "', ";
!                                       $sql .= $faq['cat_id'] . ", ";
!                                       $sql .= ($admin ? 1 : 0) . ', ';//admin 
is auto publish
!                                       $sql .= "'" . 
$this->db->db_addslashes($faq['keywords']) . "',";
!                                       $sql .= $faq['user_id'] . ', ';
!                                       $sql .= '0, '; //views must be 0 for 
new entries
!                                       $sql .= time() . ',  '; 
!                                       $sql .= $faq['is_faq'] . ', ';
!                                       $sql .= "'" . 
$this->db->db_addslashes(urldecode($faq['url'])) ."')";//url is decoded to make 
sure it is not encoded already
!                                       $this->db->query($sql, __LINE__, 
__FILE__);
!                                       return 
$this->db->get_last_insert_id('phpgw_kb_faq', 'faq_id');
!                               }//end is new
!                       }//end if is valid
!               }//end save
!               
!               function set_active_answer($faq_ids)
!               {
!                       $i=0;
!                       foreach($faq_ids as $key => $val)
!                       {
!                               $this->db->query("UPDATE phpgw_kb_faq SET 
published = 1 WHERE faq_id = $key", __LINE__, __FILE__);
!                               $i++;
!                       }
!                       return $i;
!               }//end set_active_answer
! 
!               function set_active_question($question_ids)
!               {
!                       $i=0;
!                       foreach($question_ids as $key => $val)
!                       {
!                               $this->db->query("UPDATE phpgw_kb_questions SET 
pending = 0 WHERE question_id = $key", __LINE__, __FILE__);
!                               $i++;
!                       }
!                       return $i;
!               }//end set_active_question
! 
!               function set_comment($comment_id, $comment_data)
!               {
!                       if(!$comment_id)//must be new
!                       {
!                       $sql  = 'INSERT INTO phpgw_kb_comment(user_id, comment, 
entered, faq_id) ';
!                       $sql .= 'VALUES(' . $comment_data['user_id'] . ', ';
!                               $sql .=  
"'".$this->db->db_addslashes($comment_data['comment']) . "'," . time() .','.  
$comment_data['faq_id'] . ')';
!                       }
!                       else//must be an edit
!                       {
!                               $sql  = 'UPDATE phpgw_kb_comment SET ';
!                               $sql .= "comment = '" . 
$this->db->db_addslashes($comment_data['comment']) . "' ";
!                               $sql .= "WHERE comment_id = $comment_id";
!                       } 
!                               $this->db->query($sql, __LINE__, __FILE__);
!               }
! 
!               
!               //generic 
!               function search_ansisql($search, $show)
!               {
!                       $select  = 'SELECT * FROM phpgw_kb_faq ';
!                       $select .= 'WHERE published = 1 ';
!                       if(is_int($show))
!                       {
!                               $select .= "AND is_faq = $show ";
!                       }
!                       $search_words = explode(' ', $search);
!                       $cycle = 0;
!                       foreach($search_words as $id => $word)
!                       {
!                               if($cycle)
!                               {
!                                       $title .= "OR title LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $keywords .= "OR keywords LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $text .= "OR text LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                               }
!                               else
!                               {
!                                       $title .= "(title LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $keywords .= "(keywords LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $text .= "(text LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                               }
!                       }
!                       $title .= ") ";
!                       $keywords .= ") ";
!                       $text .= ") ";
!                       
!                       $sql = $select . 'AND' . $title . 'OR' . $keywords . 
'OR' . $text;
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $rows[$this->db->f('faq_id')] = 
$this->db->Record;
!                               $rows[$this->db->f('faq_id')]['score'] = 0.00;
!                       }
!                       return $rows;
!               }//end search ansisql
! 
!               function search_mysql($search, $show)
!               {
!                       $sql  = 'SELECT *, ';
!                       $sql .= "MATCH text,keywords,title AGAINST('" . 
$this->db->db_addslashes($search) ."') AS score ";
!                       $sql .= 'FROM phpgw_kb_faq ';
!                       $sql .= 'WHERE published = 1 ';
!                       if(is_int($show))
!                       {
!                               $sql .= "AND is_faq = $show ";
!                       }
!                       //$sql .= 'HAVING (score > 0.25) '; //- this isn't 
working properly afaik
!                       $sql .= 'ORDER BY score DESC';
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $rows[$this->db->f('faq_id')] = 
$this->db->Record;
!                       }
!                       return $rows;
!               }//end search mysql
!               
!               function set_rating($faq_id, $rating)
!               {
!                       $this->db->query("UPDATE phpgw_kb_faq "
!                                                       ."SET votes=votes+1, 
total=total+$rating "
!                                                       ."WHERE 
faq_id=$faq_id",__LINE__, __FILE__
!                                                       );
!               }//end set rating
!               
!               function set_question($question, $admin)
!               {
!                       $sql  = 'INSERT INTO phpgw_kb_questions(question, 
pending) ';
!                       $sql .= "VALUES('" . 
$this->db->db_addslashes($question) ."', ";
!                       $sql .= ($admin ? 0 : 1) .')';
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       if($this->db->get_last_insert_id('phpgw_kb_questions', 
' question_id'))//worked
!                       {
!                               return true;
!                       }
!                       else//must have failed
!                       {
!                               return false;
!                       }//end if worked
!               }//end set question
! 
!               function set_view($faq_id)
!               {
!                       $this->db->query("UPDATE phpgw_kb_faq "
!                                                       ."SET views=views+1 "
!                                                       ."WHERE 
faq_id=$faq_id",__LINE__, __FILE__
!                                                       );
!               }
!               
!       }
! ?>
--- 1,404 ----
! <?php
!       
/**************************************************************************\
!       * phpGroupWare - KnowledgeBase                                          
   *
!       * http://www.phpgroupware.org                                           
   *
!       * Written by Dave Hall [skwashd AT phpgroupware DOT org]                
   *
!       * 
------------------------------------------------------------------------ *
!       * Started off as a port of phpBrain - http://vrotvrot.com/phpBrain/     
 *
!       *  but quickly became a full rewrite                                    
 *
!       * 
------------------------------------------------------------------------ *
!       *  This program is free software; you can redistribute it and/or modify 
it *
!       *  under the terms of the GNU General Public License as published by 
the   *
!       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
!       *  option) any later version.                                           
   *
!       
\**************************************************************************/
!       
!       class sokb
!       {
!               var $db;
!               
!               function sokb()
!               {
!                       $this->db = $GLOBALS['phpgw']->db;
!               }
! 
!               function delete_answer($faq_ids)
!               {
!                       if(is_array($faq_ids))
!                       {
!                               $i=0;
!                       foreach($faq_ids as $key => $val)
!                       {
!                               $this->db->query('DELETE FROM phpgw_kb_faq 
WHERE faq_id=' . intval($key), __LINE__, __FILE__);
!                               $i++;
!                       }//end foreach(q_id)
!                       }
!                       else
!                       {
!                               $this->db->query('DELETE FROM phpgw_kb_faq 
WHERE faq_id=' . intval($key), __LINE__, __FILE__);
!                               $i = 1;
!                       }//end is_type
!                       return $i;
!               }//end delete_answer
!               
!               function delete_comment($comment_id)
!               {
!                       $this->db->query('DELETE FROM phpgw_kb_comment WHERE 
comment_id=' . intval($comment_id));
!                       //this really should only return true if rows affected 
== 1 
!                       return true;
!               }
! 
!               function delete_question($question_ids)
!               {
!                       if(is_array($question_ids))
!                       {
!                               $i=0;
!                       foreach($question_ids as $key => $val)
!                       {
!                               $this->db->query('DELETE FROM 
phpgw_kb_questions WHERE question_id=' . intval($key), __LINE__, __FILE__);
!                               $i++;
!                       }//end foreach(q_id)
!                       }
!                       elseif(is_int($question_ids))
!                       {
!                               $this->db->query('DELETE FROM 
phpgw_kb_questions WHERE question_id =' . intval($question_ids), __LINE__, 
__FILE__);
!                               $i = 1;
!                       }//end is_type
!                       return $i;
!               }//end delete question
! 
!               function get_stats()
!               {       
!                       $stats = array();
!                       /* how many faqs*/
!                       $this->db->query('SELECT COUNT(*) FROM phpgw_kb_faq 
WHERE published = 1 AND is_faq = 0', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_faqs'] = $this->db->f(0);
!     
!                       /* how many tutorials? */
!                       $this->db->query('SELECT COUNT(*) FROM phpgw_kb_faq 
WHERE published = 1 AND is_faq = 1', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_tutes'] = $this->db->f(0);
!     
!                       /* how many open questions? */
!                       $this->db->query('SELECT COUNT(*) FROM 
phpgw_kb_questions WHERE pending = 0', __LINE__, __FILE__);
!                       $this->db->next_record();
!                       $stats['num_open'] = $this->db->f(0);
!                       
!                       return $stats;
!               }
!               
!               function get_latest()
!               {
!                       /* latest questions */
!                       $this->db->limit_query('SELECT * FROM 
phpgw_kb_questions WHERE pending = 0 ORDER BY question_id DESC', 0, __LINE__, 
__FILE__, 3);
! 
!                       $questions = array();
!                       while($this->db->next_record())
!                       {
!                               $questions[$this->db->f('question_id')] = 
$this->db->f('question', true);
!                       }
!                       return $questions;
!       }//end get latest
!               
!               function get_faq_list($cat_id = '', $unpublished = false)
!               {
!                       $where  = ((strlen($cat_id) != 0) ? 'cat_id=' . 
intval($cat_id) . ' ' : '');
!                       $where .= ((strlen($where) > 0) ? 'AND ' : '');
!                       $where .= ($unpublished ? 'published = 0' : 'published 
= 1'); 
!                       $this->db->query("SELECT * FROM phpgw_kb_faq WHERE 
$where", __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $faqs[$this->db->f('faq_id')] = array('title'   
=> $this->db->f('title', true),
!                                                               'text'          
=> substr($this->db->f('text', true),0,50) . ' ...',
!                                                               'modified'      
=> $this->db->f('modified'),
!                                                               'views'         
=> $this->db->f('views'),
!                                                               'votes'         
=> $this->db->f('votes'),
!                                                               'total'         
=> $this->db->f('total')
!                                                               );
!                       }
!                       return $faqs;
!               }
!               
!               function get_item($faq_id, $count_view)
!               {
!                       $this->db->query('SELECT * FROM phpgw_kb_faq WHERE 
faq_id=' . intval($faq_id), __LINE__, __FILE__);
!                       if($this->db->next_record())
!                       {
!                               $item = array('faq_id'          => 
$this->db->f('faq_id'),
!                                       'title'                 => 
$this->db->f('title', true),
!                                       'text'                  => 
$this->db->f('text', true),
!                                       'cat_id'                => (int) 
$this->db->f('cat_id', true),
!                                       'published'             => 
$this->db->f('published'),
!                                       'keywords'              => 
$this->db->f('keywords', true),
!                                       'user_id'               => (int) 
$this->db->f('user_id'),
!                                       'views'                 => (int) 
$this->db->f('views'),
!                                       'modified'              => (int) 
$this->db->f('modified'),
!                                       'type'                  => (int) 
$this->db->f('type'),
!                                       'url'                   => 
$this->db->f('url', true),
!                                       'votes'                 => (int) 
$this->db->f('votes'),
!                                       'total'                 => (int) 
$this->db->f('total')
!                                       );
! 
!                               if($count_view)
!                               {
!                                       $this->set_view($this->db->f('faq_id'));
!                               }
!                       }
!                       return $item;
!               }
!               
!               function get_comments($faq_id)
!               {
!                       $this->db->query('SELECT * FROM phpgw_kb_comment WHERE 
faq_id=' . intval($faq_id), __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $comment[$this->db->f('comment_id')] = 
array('user_id'  => $this->db->f('user_id'),
!                                                                       
'comment_text'  => $this->db->f('comment', true),
!                                                                       
'entered'       => $this->db->f('entered')
!                                                                       );
!                       }
!                       return $comment;
!               }
! 
!     function get_count($cat_id)
!     {
!       $this->db->query("SELECT COUNT(*) FROM phpgw_kb_faq WHERE cat_id = 
$cat_id AND published = 1", __LINE__, __FILE__);
!                       if($this->db->next_record())
!                       {
!                               return $this->db->f(0); 
!                       }
!                       else
!                       {
!                               return 0;
!                       }
!     }//end get count
!               
!               function get_pending()
!               {
!                       $this->db->query('SELECT faq_id, text FROM phpgw_kb_faq 
WHERE published = 0', __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $faq[$this->db->f('faq_id')] = 
$this->db->f('text', true); 
!                       }
!                       return $faq;
!               }//end get pending
! 
!               
!               function get_search_results($search, $show = null)
!               {
!                       switch 
(trim($GLOBALS['phpgw_info']['server']['db_type']))
!                       {
!                               /* This is not working - not sure why
!                               case 'mysql':
!                                       $ver = explode('-', 
mysql_get_server_info());
!                                       $ver = $ver[0];
!                                       
if($GLOBALS['phpgw']->common->cmp_version_long($ver, '3.23.23') <= 1)
!                                       {
!                                               return 
$this->search_mysql($search, $show);
!                                       }
!                                       else
!                                       {
!                                               return 
$this->search_ansisql($search, $show);
!                                       }
!                                       break;
!                               */
!                               //case 'pgsql': - //future use
!                               //case 'mssql': - //future use
!                               default:
!                                       return $this->search_ansisql($search, 
$show);
!                       }//end case db
!                               
!               }
! 
!               function get_questions($pending = false)
!               {
!                       $where = ($pending ? 'pending = 1' : 'pending = 0');
!                       $this->db->query("SELECT * FROM phpgw_kb_questions 
WHERE $where", __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $open_q[$this->db->f('question_id')] = 
$this->db->f('question', true); 
!                       }
!                       return $open_q;
!               }
!               
!               function save($faq_id, $faq, $admin)
!               {
!                       if(is_int($faq_id) && is_array($faq))
!                       {
!                               if($faq_id)//is new?
!                               {
!                                       $sql  =  'UPDATE phpgw_kb_faq';
!                                       $sql .= ' SET cat_id = ' . 
intval($faq['cat_id']) . ',';
!                                       $sql .= " title = '" . 
$this->db->db_addslashes($faq['title']) . "',";
!                                       $sql .= " keywords = '" . 
$this->db->db_addslashes($faq['keywords']) . "',";
!                                       $sql .= " text = '" . 
$this->db->db_addslashes($faq['text']) . "',";
!                                       $sql .= ' modified = ' . time() .',';
!                                       $sql .= ' user_id = ' . 
intval($faq['user_id']) .',';
!                                       $sql .= ' published = ' . ($admin ? 1 : 
0) . ', ';
!                                       $sql .= ' is_faq = ' . 
intval($faq['is_faq']) . ', ';
!                                       $sql .= " url = '" . 
$this->db->db_addslashes(urldecode($faq['url'])) ."'";
!                                       $sql .= " WHERE faq_id = $faq_id";
!                                       $this->db->query($sql, __LINE__, 
__FILE__);
!                                       if($this->db->affected_rows() == 1)
!                                       {
!                                               return $faq_id;
!                                       }
!                                       else//something went wrong
!                                       {
!                                               return false;
!                                       } 
!                               }
!                               else//must be new
!                               {
!                                       $sql  = 'INSERT INTO phpgw_kb_faq 
(title, text, cat_id, published, keywords, user_id, views, modified, is_faq, 
url) ';
!                                       $sql .= "VALUES('" . 
$this->db->db_addslashes($faq['title']) . "', ";
!                                       $sql .= "'" . 
$this->db->db_addslashes($faq['text']) . "', ";
!                                       $sql .= intval($faq['cat_id']) . ", ";
!                                       $sql .= ($admin ? 1 : 0) . ', ';//admin 
is auto publish
!                                       $sql .= "'" . 
$this->db->db_addslashes($faq['keywords']) . "',";
!                                       $sql .= intval($faq['user_id']) . ', ';
!                                       $sql .= '0, '; //views must be 0 for 
new entries
!                                       $sql .= time() . ',  '; 
!                                       $sql .= $faq['is_faq'] . ', ';
!                                       $sql .= "'" . 
$this->db->db_addslashes(urldecode($faq['url'])) ."')";//url is decoded to make 
sure it is not encoded already
!                                       $this->db->query($sql, __LINE__, 
__FILE__);
!                                       return 
$this->db->get_last_insert_id('phpgw_kb_faq', 'faq_id');
!                               }//end is new
!                       }//end if is valid
!               }//end save
!               
!               function set_active_answer($faq_ids)
!               {
!                       $i=0;
!                       foreach($faq_ids as $key => $val)
!                       {
!                               $this->db->query('UPDATE phpgw_kb_faq SET 
published = 1 WHERE faq_id=' intval($key), __LINE__, __FILE__);
!                               $i++;
!                       }
!                       return $i;
!               }//end set_active_answer
! 
!               function set_active_question($question_ids)
!               {
!                       $i=0;
!                       foreach($question_ids as $key => $val)
!                       {
!                               $this->db->query('UPDATE phpgw_kb_questions SET 
pending = 0 WHERE question_id=' .intval($key), __LINE__, __FILE__);
!                               $i++;
!                       }
!                       return $i;
!               }//end set_active_question
! 
!               function set_comment($comment_id, $comment_data)
!               {
!                       if(!$comment_id)//must be new
!                       {
!                       $sql  = 'INSERT INTO phpgw_kb_comment(user_id, comment, 
entered, faq_id) ';
!                       $sql .= 'VALUES(' . intval($comment_data['user_id']) . 
', ';
!                               $sql .=  
"'".$this->db->db_addslashes($comment_data['comment']) . "'," . time() .','.  
intval($comment_data['faq_id']) . ')';
!                       }
!                       else//must be an edit
!                       {
!                               $sql  = 'UPDATE phpgw_kb_comment SET ';
!                               $sql .= "comment = '" . 
$this->db->db_addslashes($comment_data['comment']) . "' ";
!                               $sql .= 'WHERE comment_id='.  
intval($comment_id);
!                       } 
!                               $this->db->query($sql, __LINE__, __FILE__);
!               }
! 
!               
!               //generic 
!               function search_ansisql($search, $show)
!               {
!                       $select  = 'SELECT * FROM phpgw_kb_faq ';
!                       $select .= 'WHERE published = 1 ';
!                       if(is_int($show))
!                       {
!                               $select .= "AND is_faq = $show ";
!                       }
!                       $search_words = explode(' ', $search);
!                       $cycle = 0;
!                       foreach($search_words as $id => $word)
!                       {
!                               if($cycle)
!                               {
!                                       $title .= "OR title LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $keywords .= "OR keywords LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $text .= "OR text LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                               }
!                               else
!                               {
!                                       $title .= "(title LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $keywords .= "(keywords LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                                       $text .= "(text LIKE '%" . 
$this->db->db_addslashes($word) . "%' ";
!                               }
!                       }
!                       $title .= ") ";
!                       $keywords .= ") ";
!                       $text .= ") ";
!                       
!                       $sql = $select . 'AND' . $title . 'OR' . $keywords . 
'OR' . $text;
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $rows[$this->db->f('faq_id')] = 
$this->db->Record;
!                               $rows[$this->db->f('faq_id')]['score'] = 0.00;
!                       }
!                       return $rows;
!               }//end search ansisql
! 
!               function search_mysql($search, $show)
!               {
!                       $sql  = 'SELECT *, ';
!                       $sql .= "MATCH text,keywords,title AGAINST('" . 
$this->db->db_addslashes($search) ."') AS score ";
!                       $sql .= 'FROM phpgw_kb_faq ';
!                       $sql .= 'WHERE published = 1 ';
!                       if(is_int($show))
!                       {
!                               $sql .= "AND is_faq = $show ";
!                       }
!                       //$sql .= 'HAVING (score > 0.25) '; //- this isn't 
working properly afaik
!                       $sql .= 'ORDER BY score DESC';
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       while($this->db->next_record())
!                       {
!                               $rows[$this->db->f('faq_id')] = 
$this->db->Record;
!                       }
!                       return $rows;
!               }//end search mysql
!               
!               function set_rating($faq_id, $rating)
!               {
!                       $this->db->query("UPDATE phpgw_kb_faq "
!                                                       .'SET votes=votes+1, 
total=total+' . intval($rating) . ' '
!                                                       .'WHERE faq_id=' . 
intval($faq_id),__LINE__, __FILE__
!                                                       );
!               }//end set rating
!               
!               function set_question($question, $admin)
!               {
!                       $sql  = 'INSERT INTO phpgw_kb_questions(question, 
pending) ';
!                       $sql .= "VALUES('" . 
$this->db->db_addslashes($question) ."', ";
!                       $sql .= ($admin ? 0 : 1) .')';
!                       $this->db->query($sql, __LINE__, __FILE__);
!                       if($this->db->get_last_insert_id('phpgw_kb_questions', 
' question_id'))//worked
!                       {
!                               return true;
!                       }
!                       else//must have failed
!                       {
!                               return false;
!                       }//end if worked
!               }//end set question
! 
!               function set_view($faq_id)
!               {
!                       $this->db->query("UPDATE phpgw_kb_faq "
!                                                       ."SET views=views+1 "
!                                                       .'WHERE faq_id=' . 
intval($faq_id),__LINE__, __FILE__
!                                                       );
!               }
!               
!       }
! ?>

Index: class.uikb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.uikb.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.uikb.inc.php  30 Apr 2003 21:42:56 -0000      1.13
--- class.uikb.inc.php  28 May 2003 06:22:44 -0000      1.14
***************
*** 1,942 ****
! <?php
! /**************************************************************************\
! * phpGroupWare - KnowledgeBase                                             *
! * http://www.phpgroupware.org                                              *
! * Written by Dave Hall [skwashd AT phpgroupware.org]                     *
! * ------------------------------------------------------------------------ *
! * Started off as a port of phpBrain - http://vrotvrot.com/phpBrain/      *
! *  but quickly became a full rewrite                                     *
! * ------------------------------------------------------------------------ *
! *  This program is free software; you can redistribute it and/or modify it *
[...1855 lines suppressed...]
!                               'li {  font-family: '.$this->theme['font'].'; 
font-size: 10pt} '. "\n".
!                               'h1   {  font-family: '.$this->theme['font'].'; 
font-size: 16pt; font-weight: bold} '. "\n".
!                               'h2   {  font-family: '.$this->theme['font'].'; 
font-size: 13pt; font-weight: bold} '. "\n".
!                               'A:link    {  font-family: 
'.$this->theme['font'].'; text-decoration: none; '.$this->theme['link'].'} '. 
"\n".
!                               'A:visited {  font-family: 
'.$this->theme['font'].'; text-decoration: none; color: 
'.$this->theme['link'].' } '. "\n".
!                               'A:hover   {  font-family: 
'.$this->theme['font'].'; text-decoration: underline; color: 
'.$this->theme['alink'].'} '. "\n".
!                               'A.small:link    {  font-family: 
'.$this->theme['font'].'; font-size: 8pt; text-decoration: none; color: 
'.$this->theme['link'].'} '. "\n".
!                               'A.small:visited {  font-family: 
'.$this->theme['font'].'; font-size: 8pt; text-decoration: none; color: 
'.$this->theme['vlink'].'} '. "\n".
!                               'A.small:hover   {  font-family: 
'.$this->theme['font'].'; font-size: 8pt; text-decoration: underline; color: 
'.$this->theme['alink'].'} '. "\n".
!                               '.nav {  font-family: '.$this->theme['font'].'; 
background-color: ' . $this->theme['bg10'] . ';} ' . "\n".
!                               '.search   {  font-family: 
'.$this->theme['font']. '; color: ' . $this->theme['navbar_text'] . '; 
background-color: '.$this->theme['navbar_bg'] . '; font-size: 9pt; border: 1px 
solid ' . $this->theme['bg_color'] . ';} '. "\n".
!                               '.navbg { font-family: 
'.$this->theme['font'].'; color: '.$this->theme['navbar_text'] .'; 
background-color: '.$this->theme['navbar_bg'] . ';} '. "\n".
!                               'a.contrlink { font-family: 
'.$this->theme['font'].'; color: '.$this->theme['navbar_text'] .'; 
text-decoration: none;} '. "\n".
!                               'a.contrlink:hover, a.stats:active { 
font-family: '.$this->theme['font'].'; color: '.$this->theme['navbar_text'] .'; 
text-decoration: underline;}' . "\n".
!                               '.faq_info {  font-family: 
'.$this->theme['font'].'; color:' . $this->theme['navbar_bg'] . '; font-size: 
8pt} ' . "\n" .
!                               'hr {background-color: ' . 
$this->theme['navbar_bg'] . '; border-width: 0px; heght: 2px;} ' . "\n" .
!                               'input, textarea {color:' . 
$this->theme['bg_text']. '; background-color:' .  $this->theme['bg_color'] . '; 
font-family: '.$this->theme['font']. '; font-size: 9pt; border: 1px solid ' . 
$this->theme['bg_text'] . ';} '. "\n".
!                               '';
!               }
!       }       





reply via email to

[Prev in Thread] Current Thread [Next in Thread]