[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.5,1.6 class.so
From: |
Dave Hall <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.5,1.6 class.sokb.inc.php,1.4,1.5 class.uikb.inc.php,1.6,1.7 |
Date: |
Sat, 22 Mar 2003 03:01:19 -0500 |
Update of /cvsroot/phpgroupware/phpbrain/inc
In directory subversions:/tmp/cvs-serv4060/inc
Modified Files:
class.bokb.inc.php class.sokb.inc.php class.uikb.inc.php
Log Message:
fixed (well added) add comment function and some minor bugs
Index: class.bokb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.bokb.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.bokb.inc.php 22 Mar 2003 03:10:19 -0000 1.5
--- class.bokb.inc.php 22 Mar 2003 08:01:17 -0000 1.6
***************
*** 5,10 ****
* 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 *
--- 5,10 ----
* 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 *
***************
*** 27,30 ****
--- 27,31 ----
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))
***************
*** 42,49 ****
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);
--- 43,51 ----
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);
***************
*** 201,204 ****
--- 203,211 ----
return $this->so->set_active_question($question_ids);
}//end set active question
+
+ function set_comment($faq_id, $comment)
+ {
+ $this->so->set_comment($faq_id, $comment,
$GLOBALS['phpgw_info']['user']['account_id']);
+ }//end set comment
function set_question($question)
Index: class.sokb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.sokb.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.sokb.inc.php 17 Mar 2003 04:30:38 -0000 1.4
--- class.sokb.inc.php 22 Mar 2003 08:01:17 -0000 1.5
***************
*** 1,370 ****
! <?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");
! $i++;
! }//end foreach(q_id)
! }
! elseif(is_int($faq_ids))
! {
! $this->db->query("DELETE FROM phpgw_kb_faq
WHERE faq_id = $faq_ids");
! $i = 1;
! }//end is_type
! return $i;
! }//end delete_answer
!
! 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");
! $i++;
! }//end foreach(q_id)
! }
! elseif(is_int($question_ids))
! {
! $this->db->query("DELETE FROM
phpgw_kb_questions WHERE question_id = $question_ids");
! $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)
! {
! $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'
=> $this->db->f('cat_id', true),
! 'published'
=> $this->db->f('published'),
! 'keywords'
=> $this->db->f('keywords', true),
! 'user_id'
=> $this->db->f('user_id'),
! 'views'
=> $this->db->f('views'),
! 'modified'
=> $this->db->f('modified'),
! 'type'
=> $this->db->f('type'),
! 'url'
=> $this->db->f('url', true),
! 'votes'
=> $this->db->f('votes'),
! 'total'
=> $this->db->f('total')
! );
!
! $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');
! 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']))
! {
! 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 .= ' keyword = "' .
$this->db->db_addslashes($faq['keyword']) . '",';
! $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 .= " WHERE faq_id = $faq_id";
! $this->db->query($sql);
! if($this->db->affected_rows() == 1)
! {
! return $faq_id;
! }
! else//some 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 .= "1, '" .
$this->db->db_addslashes($faq['keywords']) . "',";
! $sql .= $faq['user_id'] . ', ';
! $sql .= '0, ' . time() . ', ' .
$faq['is_faq'] . ", '')";//url is empty for now
! $this->db->query($sql);
! 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
!
!
! //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 = expode(' ', $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);
! 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)
! {
! $sql = 'SELECT *, ';
! $sql .= "MATCH text,keywords,title AGAINST('" .
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) '; //- this isn't working
properly afaik
! $sql .= 'ORDER BY score DESC';
! $this->db->query($sql);
! 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,377 ----
! <?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");
! $i++;
! }//end foreach(q_id)
! }
! elseif(is_int($faq_ids))
! {
! $this->db->query("DELETE FROM phpgw_kb_faq
WHERE faq_id = $faq_ids");
! $i = 1;
! }//end is_type
! return $i;
! }//end delete_answer
!
! 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");
! $i++;
! }//end foreach(q_id)
! }
! elseif(is_int($question_ids))
! {
! $this->db->query("DELETE FROM
phpgw_kb_questions WHERE question_id = $question_ids");
! $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)
! {
! $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' =>
$this->db->f('cat_id', true),
! 'published' =>
$this->db->f('published'),
! 'keywords' =>
$this->db->f('keywords', true),
! 'user_id' =>
$this->db->f('user_id'),
! 'views' =>
$this->db->f('views'),
! 'modified' =>
$this->db->f('modified'),
! 'type' =>
$this->db->f('type'),
! 'url' =>
$this->db->f('url', true),
! 'votes' =>
$this->db->f('votes'),
! 'total' =>
$this->db->f('total')
! );
!
! $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');
! 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']))
! {
! 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 .= ' keyword = "' .
$this->db->db_addslashes($faq['keyword']) . '",';
! $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 .= " WHERE faq_id = $faq_id";
! $this->db->query($sql);
! if($this->db->affected_rows() == 1)
! {
! return $faq_id;
! }
! else//some 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 .= "1, '" .
$this->db->db_addslashes($faq['keywords']) . "',";
! $sql .= $faq['user_id'] . ', ';
! $sql .= '0, ' . time() . ', ' .
$faq['is_faq'] . ", '')";//url is empty for now
! $this->db->query($sql);
! 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($faq_id, $comment, $user_id)
! {
! $sql = 'INSERT INTO phpgw_kb_comment(user_id, comment,
entered, faq_id) ';
! $sql .= "VALUES($user_id, '" .
$this->db->db_addslashes($comment) . "', ". time() .", $faq_id)";
! $this->db->query($sql);
! }
!
!
! //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 = expode(' ', $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);
! 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)
! {
! $sql = 'SELECT *, ';
! $sql .= "MATCH text,keywords,title AGAINST('" .
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) '; //- this isn't working
properly afaik
! $sql .= 'ORDER BY score DESC';
! $this->db->query($sql);
! 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__
! );
! }
!
! }
! ?>
Index: class.uikb.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpbrain/inc/class.uikb.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.uikb.inc.php 22 Mar 2003 03:10:19 -0000 1.6
--- class.uikb.inc.php 22 Mar 2003 08:01:17 -0000 1.7
***************
*** 23,26 ****
--- 23,27 ----
var $public_functions = array('index' => True,
'add' => True,
+ 'add_comment' => True,
'add_question' => True,
'browse' => True,
***************
*** 64,67 ****
--- 65,90 ----
$GLOBALS['phpgw']->common->phpgw_exit();
}//end add
+
+ function add_comment()
+ {
+
+ $faq_id = (int) (isset($_POST['faq_id']) ?
trim($_POST['faq_id']) : 0);
+ $comment = (isset($_POST['comment']) ?
trim($_POST['comment']) : '');
+ $link['menuaction'] = 'phpbrain.uikb.view';
+ if($faq_id && $comment)
+ {
+ $this->bo->set_comment($faq_id, $comment);
+ $link['faq_id'] = $faq_id;
+ $link['msg'] = 'comment_added';
+ }
+ else
+ {
+ $link['msg'] = 'comment_invalid';
+ }
+
+ header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+
+ }//end add comment
function add_question()
***************
*** 159,164 ****
$this->t->set_var('cat_link',$GLOBALS['phpgw']->link('/index.php',
!
array('menuaction' => 'phpbrain.uikb.browse',
!
'cat_id' => $cat_key)
)
);
--- 182,187 ----
$this->t->set_var('cat_link',$GLOBALS['phpgw']->link('/index.php',
!
array('menuaction' => 'phpbrain.uikb.browse',
!
'cat_id' => $cat_key)
)
);
***************
*** 220,224 ****
}//end browse
! function build_form($form_target, $title, $input_descr,
$hidden_input=false, $allow_anon=false)
{
--- 243,247 ----
}//end browse
! function build_form($form_target, $title, $input_descr,
$input_hidden=false, $allow_anon=false)
{
***************
*** 228,238 ****
if(!$this->bo->is_anon())
{
! $tpl->set_var(array('form_url' =>
$GLOBALS['phpgw']->link('/index.php',
!
array('menuaction' =>
"phpbrain.uikb.$form_target")),
! 'lang_title'
=> lang($title),
! 'lang_input_descr'
=> lang($input_descr),
! 'lang_submit_val'
=> lang('add')
! )
! );
$tpl->set_block('form', 'hidden_var',
'hidden_vars');
--- 251,261 ----
if(!$this->bo->is_anon())
{
! $tpl->set_var(array('form_url' =>
$GLOBALS['phpgw']->link('/index.php',
!
array('menuaction' => "phpbrain.uikb.$form_target")),
! 'lang_title' => lang($title),
! 'lang_input_descr' =>
lang($input_descr),
! 'lang_submit_val' => lang('add')
! )
! );
$tpl->set_block('form', 'hidden_var',
'hidden_vars');
***************
*** 291,304 ****
$lang = array('lang_add_answer' =>
lang('add_answer'),
! 'lang_check_before_submit'
=> lang('check_before_submit'),
! 'lang_not_submit_qs_warn'
=> lang('not_submit_qs_warn'),
! 'lang_inspire_by_suggestions'=>
lang('inspire_by_suggestions'),
! 'lang_title'
=> lang('title'),
! 'lang_keywords'
=> lang('keywords'),
! 'lang_category'
=> lang('category'),
! 'lang_text'
=> lang('text'),
! 'lang_save'
=> lang('save'),
! 'lang_reset'
=> lang('reset')
! );
$this->t->set_var($lang);
--- 314,327 ----
$lang = array('lang_add_answer' =>
lang('add_answer'),
! 'lang_check_before_submit' =>
lang('check_before_submit'),
! 'lang_not_submit_qs_warn' =>
lang('not_submit_qs_warn'),
! 'lang_inspire_by_suggestions'=>
lang('inspire_by_suggestions'),
! 'lang_title'
=> lang('title'),
! 'lang_keywords'
=> lang('keywords'),
! 'lang_category'
=> lang('category'),
! 'lang_text'
=> lang('text'),
! 'lang_save'
=> lang('save'),
! 'lang_reset'
=> lang('reset')
! );
$this->t->set_var($lang);
***************
*** 699,713 ****
{
$this->t->set_file('showitem', 'showitem.tpl');
! $lang = array('msg'
=> ($msg ? lang($msg) : ''),
! 'lang_submitted_by'
=> lang('submitted_by'),
! 'lang_views'
=> lang('views'),
! 'lang_rating'
=> lang('rating'),
! 'lang_title'
=> lang('title'),
! 'lang_text'
=> lang('text'),
! 'lang_poor'
=> lang('poor'),
! 'lang_excellent'
=> lang('excellent'),
! 'lang_rate_why_explain'
=> lang('improve_by_rate'),
! 'lang_comments'
=> lang('comments')
! );
$this->t->set_block('showitem', 'click_rating',
'click_ratings');
$rate_url =
$GLOBALS['phpgw']->link('/index.php' , array('menuaction' =>
'phpbrain.uikb.rate',
--- 722,736 ----
{
$this->t->set_file('showitem', 'showitem.tpl');
! $lang = array('msg' => ($msg ?
lang($msg) : ''),
! 'lang_submitted_by' =>
lang('submitted_by'),
! 'lang_views' =>
lang('views'),
! 'lang_rating' =>
lang('rating'),
! 'lang_title' =>
lang('title'),
! 'lang_text' => lang('text'),
! 'lang_poor' => lang('poor'),
! 'lang_excellent' =>
lang('excellent'),
! 'lang_rate_why_explain' =>
lang('improve_by_rate'),
! 'lang_comments' =>
lang('comments')
! );
$this->t->set_block('showitem', 'click_rating',
'click_ratings');
$rate_url =
$GLOBALS['phpgw']->link('/index.php' , array('menuaction' =>
'phpbrain.uikb.rate',
***************
*** 771,780 ****
$this->t->set_var('comment_form',
$this->build_form('add_comment', 'add_comments', 'comment',
!
array('hidden_var' =>'faq_id',
!
'hidden_name' =>$faq_id
!
)
!
)
! );
!
$this->t->set_var($lang);
$this->t->set_var($item);
--- 794,803 ----
$this->t->set_var('comment_form',
$this->build_form('add_comment', 'add_comments', 'comment',
!
array('hidden_name' =>'faq_id',
!
'hidden_val' => $faq_id
!
)
!
)
! );
!
$this->t->set_var($lang);
$this->t->set_var($item);
***************
*** 791,812 ****
{
return 'th { font-family: '.$this->theme['font'].';
font-size: 10pt; font-weight: bold; background-color: #D3DCE3;} '. "\n".
! 'td { font-family:
'.$this->theme['font'].'; font-size: 10pt;} '. "\n".
! 'p { font-family:
'.$this->theme['font'].'; font-size: 10pt} '. "\n".
! '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" .
'';
}
--- 814,835 ----
{
return 'th { font-family: '.$this->theme['font'].';
font-size: 10pt; font-weight: bold; background-color: #D3DCE3;} '. "\n".
! 'td { font-family: '.$this->theme['font'].';
font-size: 10pt;} '. "\n".
! 'p { font-family: '.$this->theme['font'].';
font-size: 10pt} '. "\n".
! '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" .
'';
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.5,1.6 class.sokb.inc.php,1.4,1.5 class.uikb.inc.php,1.6,1.7,
Dave Hall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.4,1.5 class.uikb.inc.php,1.5,1.6
- Next by Date:
[Phpgroupware-cvs] CVS: phpbrain/templates/default form.tpl,1.1.1.1,1.2
- Previous by thread:
[Phpgroupware-cvs] CVS: phpbrain/inc class.bokb.inc.php,1.4,1.5 class.uikb.inc.php,1.5,1.6
- Next by thread:
[Phpgroupware-cvs] CVS: phpbrain/templates/default form.tpl,1.1.1.1,1.2
- Index(es):