|
From: Jon O. <jon...@us...> - 2007-04-28 19:59:42
|
Update of /cvsroot/mxbb/mx_kb/kb/includes
In directory sc8-pr-cvs16:/tmp/cvs-serv25305/kb/includes
Modified Files:
functions.php functions_kb.php
Log Message:
fixes
Index: functions.php
===================================================================
RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** functions.php 14 Aug 2006 10:46:05 -0000 1.15
--- functions.php 28 Apr 2007 19:59:04 -0000 1.16
***************
*** 764,767 ****
--- 764,768 ----
default:
+ /* Bug 50
$sql = "SELECT a.*, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, c.category_id, c.category_name
FROM " . KB_ARTICLES_TABLE . " AS a, " . KB_CATEGORIES_TABLE . " AS c
***************
*** 771,774 ****
--- 772,783 ----
AND a.article_id = '" . $item_id . "'
GROUP BY a.article_id";
+ */
+ $sql = "SELECT a.*, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, c.category_id, c.category_name
+ FROM " . KB_ARTICLES_TABLE . " AS a
+ LEFT JOIN " . KB_CATEGORIES_TABLE . " AS c ON c.category_id = a.article_category_id
+ LEFT JOIN " . KB_VOTES_TABLE . " AS r ON a.article_id = r.votes_article
+ LEFT JOIN " . USERS_TABLE . " AS u ON a.article_author_id = u.user_id
+ WHERE a.article_id = '" . $item_id . "'
+ GROUP BY a.article_id ";
break;
}
Index: functions_kb.php
===================================================================
RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_kb.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** functions_kb.php 15 Aug 2006 19:42:50 -0000 1.19
--- functions_kb.php 28 Apr 2007 19:59:05 -0000 1.20
***************
*** 156,160 ****
$this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id'] = $cat_rowset[$i]['comments_forum_id'] < 1 ? ( intval($kb_config['comments_forum_id']) ) : ( intval($cat_rowset[$i]['comments_forum_id']) ); // phpBB target forum (only used for phpBB comments)
! if (!$this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] && intval($this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']) < 1)
{
mx_message_die(GENERAL_ERROR, 'Init Failure, phpBB comments with no target forum_id :(<br> Category: ' . $cat_rowset[$i]['category_name'] . ' Forum_id: ' . $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']);
--- 156,160 ----
$this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id'] = $cat_rowset[$i]['comments_forum_id'] < 1 ? ( intval($kb_config['comments_forum_id']) ) : ( intval($cat_rowset[$i]['comments_forum_id']) ); // phpBB target forum (only used for phpBB comments)
! if ($this->comments[$cat_rowset[$i]['category_id']]['activated'] && !$this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] && intval($this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']) < 1)
{
mx_message_die(GENERAL_ERROR, 'Init Failure, phpBB comments with no target forum_id :(<br> Category: ' . $cat_rowset[$i]['category_name'] . ' Forum_id: ' . $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']);
***************
*** 210,213 ****
--- 210,214 ----
$this->reader_mode = $kb_config['reader_mode'];
+ $this->app_mode = $kb_config['app_mode'];
}
***************
*** 485,488 ****
--- 486,728 ----
/**
+ * Jump menu function.
+ *
+ * @param unknown_type $cat_id to handle parent cat_id
+ * @param unknown_type $depth related to function to generate tree
+ * @param unknown_type $default the cat you wanted to be selected
+ * @param unknown_type $for_file TRUE high category ids will be -1
+ * @param unknown_type $check_upload if true permission for upload will be checked
+ * @return unknown
+ */
+ function generate_app_tree( $current_article_id = '', $cat_id = 0, $pre = '', $default = '', $for_file = false, $check_upload = true, $auth = 'auth_view' )
+ {
+ global $article_path, $page_id;
+ //static $cat_rowset = false;
+
+ if ( !is_array( $cat_rowset ) )
+ {
+ if ( $check_upload )
+ {
+ if ( !empty( $this->cat_rowset ) )
+ {
+ foreach( $this->cat_rowset as $row )
+ {
+ if ( $this->auth_user[$row['category_id']][$auth] )
+ {
+ $cat_rowset[$row['category_id']] = $row;
+ }
+ }
+ }
+ }
+ else
+ {
+ $cat_rowset = $this->cat_rowset;
+ }
+ }
+
+ $cat_list .= '';
+
+ $temp_cat_rowset = $cat_rowset;
+
+ if ( !empty( $temp_cat_rowset ) )
+ {
+ foreach ( $temp_cat_rowset as $temp_cat_id => $cat )
+ {
+ if ( $cat['parent'] == $cat_id )
+ {
+ if ( is_array( $default ) )
+ {
+ if ( isset( $default[$cat['category_id']] ) )
+ {
+ $sel = ' selected="selected"';
+ }
+ else
+ {
+ $sel = '';
+ }
+ }
+
+ $sub_cat_id = ( $for_file ) ? ( ( !$cat['cat_allow_file'] ) ? -1 : $cat['category_id'] ) : $cat['category_id'];
+ $cat_list .= sprintf('<div onselectstart="return false" class="folder" id="tree-%s">%s', $pre . $sub_cat_id, $cat['category_name']);
+ $cat_list .= $this->generate_app_tree( $current_article_id, $cat['category_id'], $pre . $cat['category_id'] . '/', $default, $for_file, $check_upload );
+
+ //
+ // Load items
+ //
+ $cat_list .= $this->list_items($sub_cat_id, $pre, $current_article_id);
+
+ $cat_list .= '</div>';
+ }
+ }
+ //$this->jumpbox = $cat_list;
+ return $cat_list;
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ /**
+ * display items.
+ *
+ * @param unknown_type $start
+ * @param unknown_type $cat_id
+ * @param unknown_type $block_name
+ * @param unknown_type $approve
+ */
+ function list_items( $cat_id = false, $pre = '', $current_article_id = '', $sql_xtra = '' )
+ {
+ global $db, $kb_config, $template, $board_config;
+ global $images, $lang, $theme, $phpEx, $mx_kb_functions;
+ global $phpbb_root_path, $mx_root_path, $module_root_path, $is_block, $phpEx;
+ global $article_path;
+
+ $filelist = false;
+
+ $file_rowset = array();
+ $total_file = 0;
+
+ //
+ // Category SQL
+ //
+ if (!$cat_id)
+ {
+ $cat_where = "AND t.article_category_id IN (" . $this->gen_cat_ids( '0' ) . ")";
+ }
+ else
+ {
+ $cat_where = "AND t.article_category_id = $cat_id";
+ }
+
+ switch ( SQL_LAYER )
+ {
+ case 'oracle':
+ $sql = "SELECT t.*, t.article_id, r.votes_article, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, typ.type
+ FROM " . KB_ARTICLES_TABLE . " AS t, " . KB_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . KB_CATEGORIES_TABLE . " AS cat, " . KB_TYPES_TABLE . " AS typ
+ WHERE t.article_id = r.votes_article(+)
+ AND t.article_type = typ.id(+)
+ AND t.article_author_id = u.user_id(+)
+ AND t.approved = '1'
+ AND t.article_category_id = cat.category_id
+ $cat_where
+ $sql_xtra
+ GROUP BY t.article_id
+ ORDER BY " . $this->sort_method_extra . $this->sort_method . " " . $this->sort_order;
+ break;
+
+ default:
+ $sql = "SELECT t.*, t.article_id, r.votes_article, IF(COUNT(r.rate_point)>0,AVG(r.rate_point),0) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, typ.type
+ FROM " . KB_ARTICLES_TABLE . " AS t
+ LEFT JOIN " . KB_VOTES_TABLE . " AS r ON t.article_id = r.votes_article
+ LEFT JOIN " . KB_TYPES_TABLE . " AS typ ON t.article_type = typ.id
+ LEFT JOIN " . USERS_TABLE . " AS u ON t.article_author_id = u.user_id
+ LEFT JOIN " . KB_CATEGORIES_TABLE . " AS cat ON t.article_category_id = cat.category_id
+ WHERE t.approved = '1'
+ $cat_where
+ $sql_xtra
+ GROUP BY t.article_id
+ ORDER BY " . $this->sort_method_extra . $this->sort_method . " " . $this->sort_order;
+ break;
+ }
+
+ if ( !( $result = $mx_kb_functions->sql_query_limit( $sql, $kb_config['pagination'], $start ) ) )
+ {
+ mx_message_die( GENERAL_ERROR, 'Couldn\'t get article info for this category', '', __LINE__, __FILE__, $sql );
+ }
+
+ $file_rowset = array();
+
+ while ( $row = $db->sql_fetchrow( $result ) )
+ {
+ if ( $this->auth_user[$row['article_category_id']]['auth_view'] )
+ {
+ $file_rowset[] = $row;
+ }
+ }
+
+ $db->sql_freeresult( $result );
+
+ $filelist = false;
+ if (count( $file_rowset ) > 0)
+ {
+ $filelist = true;
+ }
+
+ $item_list = '';
+ for ( $i = 0; $i < count( $file_rowset ); $i++ )
+ {
+ // ===================================================
+ // Format the date for the given file
+ // ===================================================
+ //$article_date = create_date( $board_config['default_dateformat'], $file_rowset[$i]['article_date'], $board_config['board_timezone'] );
+
+ //
+ // If the file is new then put a new image in front of it
+ //
+ $is_new = FALSE;
+ if (time() - ($kb_config['settings_newdays'] * 24 * 60 * 60) < $file_rowset[$i]['article_date'])
+ {
+ $is_new = TRUE;
+ }
+
+ //$cat_name = ( empty( $cat_id ) ) ? $this->cat_rowset[$file_rowset[$i]['file_catid']]['category_name'] : '';
+ //$cat_url = append_sid( $this->this_mxurl( 'action=category&cat_id=' . $file_rowset[$i]['article_category_id'] ) );
+
+ $article_description = $file_rowset[$i]['article_description'] ;
+ //$article_cat_id = $file_rowset[$i]['article_category_id'];
+ $article_approved = $file_rowset[$i]['approved'];
+
+ //
+ // type
+ //
+ $article_type = isset($lang['KB_type_' . $file_rowset[$i]['type']]) ? $lang['KB_type_' . $file_rowset[$i]['type']] : $file_rowset[$i]['type'];
+
+ //
+ // author information
+ //
+ $author = ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid( $phpbb_root_path . 'profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $file_rowset[$i]['user_id'] ) . '" target=_blank>' : '';
+ $author .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? $file_rowset[$i]['username'] : $file_rowset[$i]['post_username'] . '(' . $lang['Guest'] . ')';
+ $author .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
+
+ $article_id = $file_rowset[$i]['article_id'];
+ $views = $file_rowset[$i]['views'];
+
+ $article_title = $file_rowset[$i]['article_title'];
+ $article_url = append_sid( $this->this_mxurl( "mode=article&k=$article_id" ) );
+
+ if ( $is_new )
+ {
+ //$template->assign_block_vars( "ARTICLELIST.articlerow.is_new_file", array() );
+ }
+
+ $item_list .= sprintf('<div class="doc" id="tree-%s">%s</div>', $pre . $cat_id . '/' . $article_id, $article_title);
+
+ // Tweak to define the ajax history url
+ if ($article_id == $current_article_id)
+ {
+ $article_path = $pre . $cat_id . '/' . $article_id;
+ }
+ }
+
+ if ( $filelist )
+ {
+ //
+ }
+ else
+ {
+ if ($this->cat_rowset[$cat_id]['cat_allow_file'])
+ {
+ //$template->assign_block_vars( 'no_articles', array(
+ // 'L_NO_ARTICLES' => $lang['No_articles'],
+ // 'L_NO_ARTICLES_CAT' => $lang['No_Articles']
+ //) );
+ }
+ }
+
+ return $item_list;
+ }
+
+ /**
* get_sub_cat.
*
|