|
From: Jon O. <jon...@us...> - 2006-06-28 13:58:16
|
Update of /cvsroot/mxbb/mx_kb In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv32691/modules/mx_kb Modified Files: KnowledgeBase.pak db_upgrade.php kb.php kb_article_reader.php Added Files: kb_last_article.php Log Message: added a new "last article" block Index: KnowledgeBase.pak =================================================================== RCS file: /cvsroot/mxbb/mx_kb/KnowledgeBase.pak,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** KnowledgeBase.pak 17 Dec 2005 13:12:58 -0000 1.8 --- KnowledgeBase.pak 28 Jun 2006 13:58:07 -0000 1.9 *************** *** 12,13 **** --- 12,29 ---- block=+:=+:Demo - Article_reader=+:Demo block=+:96=+:0=+:5=+:0=+:0=+:0=+:0=+:1=+:1 function=+:0=+:0=+:0=+:endoflist=+:0=+:0 + New_function=+:---------------------------=+:0=+:0=+:0=+:0=+:0 + function=+:30=+:31=+:Last Articles=+:KB Last Articles Function=+:kb_last_article.php=+: + parameter=+:31=+:21=+:Last_Article_Align=+:Values=+:left=+:=+:0 + parameter=+:31=+:39=+:Last_Article_Display_Author=+:Boolean=+:FALSE=+:=+:0 + parameter=+:31=+:18=+:Last_Article_Display_Date=+:Boolean=+:TRUE=+:=+:0 + parameter=+:31=+:22=+:Last_Article_Display_Cat=+:Boolean=+:TRUE=+:=+:0 + parameter=+:31=+:40=+:Last_Article_Display_Icon_View=+:Boolean=+:TRUE=+:=+:0 + parameter=+:31=+:38=+:Last_Article_Display_Last_Author=+:Boolean=+:TRUE=+:=+:0 + parameter=+:31=+:37=+:Last_Article_Cat=+:Function=+:=+:get_list_multiple("{parameter_id}[]", FORUMS_TABLE, 'forum_id', 'forum_name', "{parameter_value}", TRUE)=+:0 + parameter=+:31=+:17=+:Last_Article_Number_Title=+:Number=+:15=+:=+:0 + parameter=+:31=+:20=+:Last_Article_Target=+:Values=+:_blank=+:=+:0 + parameter=+:31=+:19=+:Last_Article_Title_Length=+:Number=+:30=+:=+:0 + parameter=+:31=+:95=+:article_filter_date=+:Function=+:5=+:get_list_static("{parameter_id}[]",array("no limit", "1 day", "2 days", "3 days", "1 week", "2 weeks", "3 weeks", "1 month", "2 months", "3 months", "6 months", "1 year"),"{parameter_value}")=+:0 + parameter=+:0=+:0=+:0=+:endoflist=+:0=+:0 + block=+:=+:Demo - Last Articles=+:Demo block=+:31=+:0=+:5=+:0=+:0=+:0=+:0=+:1=+:1 + function=+:0=+:0=+:0=+:endoflist=+:0=+:0 \ No newline at end of file Index: kb.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** kb.php 17 Jun 2006 20:48:10 -0000 1.32 --- kb.php 28 Jun 2006 13:58:07 -0000 1.33 *************** *** 133,137 **** $mode = $mx_request_vars->request('mode', MX_TYPE_NO_TAGS, 'main'); $print_version = $mx_request_vars->request('print', MX_TYPE_NO_TAGS, ''); ! $reader_mode = false; // =================================================== --- 133,137 ---- $mode = $mx_request_vars->request('mode', MX_TYPE_NO_TAGS, 'main'); $print_version = $mx_request_vars->request('print', MX_TYPE_NO_TAGS, ''); ! $kb_config['reader_mode'] = false; // =================================================== --- NEW FILE: kb_last_article.php --- <?php /** * * @package mxBB Portal Module - mx_kb * @version $Id: kb_last_article.php,v 1.1 2006/06/28 13:58:07 jonohlsson Exp $ * @copyright (c) 2002-2006 mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if( !defined('IN_PORTAL') || !is_object($mx_block)) { die("Hacking attempt"); } define( 'MXBB_27x', file_exists( $mx_root_path . 'mx_login.' . $phpEx ) ); define( 'MXBB_MODULE', true ); // =================================================== // Include the constants file // =================================================== include_once( $module_root_path . 'kb/includes/kb_constants.' . $phpEx ); // // Read Block Settings // $title = $mx_block->block_info['block_title']; $template->set_filenames(array( 'body_last_msg' => 'kb_last_article.tpl') ); // // Read block Configuration // $PostNumber = $mx_block->get_parameters( 'Last_Article_Number_Title' ); $display_date = $mx_block->get_parameters( 'Last_Article_Display_Date' ); $nb_characteres = $mx_block->get_parameters( 'Last_Article_Title_Length' ); $target = $mx_block->get_parameters( 'Last_Article_Target' ); $align = $mx_block->get_parameters( 'Last_Article_Align' ); $display_forum = $mx_block->get_parameters( 'Last_Article_Display_Cat' ); $forum_lst_msg = $mx_block->get_parameters( 'Last_Article_Cat' ); if( empty($PostNumber) ) $PostNumber = 5; $display_author = $mx_block->get_parameters( 'Last_Article_Display_Author' ); $display_last_author = $mx_block->get_parameters( 'Last_Article_Display_Last_Author' ); $display_icon_view = $mx_block->get_parameters( 'Last_Article_Display_Icon_View' ); // // no limit, last day, 2 days, 3 days, week, 2 weeks, 3 weeks, month, 2 months, 3 months, 6 months, i year, // $msg_filter_time = $mx_block->get_parameters( 'article_filter_date' ); // // Authorization SQL // $auth_data_sql_msg = get_auth_forum('kb'); if ( empty($forum_lst_msg) ) { $forum_lst_msg = $auth_data_sql_msg; } if ( empty($forum_lst_msg) ) { $forum_lst_msg = -1; } $msg_start = ( isset( $HTTP_GET_VARS['kb_lmsg_start'] ) ) ? intval( $HTTP_GET_VARS['kb_lmsg_start'] ) : 0; $start_prev = ( $msg_start == 0 ) ? 0 : $msg_start - $PostNumber; $start_next = $msg_start + $PostNumber; $url_next = mx_url('kb_lmsg_start' , $start_next); $url_prev = mx_url('kb_lmsg_start' , $start_prev); $msg_today = date('mdY'); switch( $msg_filter_time ) { case '0': $msg_time_filter_lo = 'no'; break; case '1': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 1), intval(substr($msg_today, 4, 4))); break; case '2': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 1), intval(substr($msg_today, 4, 4))); break; case '3': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 1), intval(substr($msg_today, 4, 4))); break; case '4': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 7), intval(substr($msg_today, 4, 4))); break; case '5': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 14), intval(substr($msg_today, 4, 4))); break; case '6': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2) - 21), intval(substr($msg_today, 4, 4))); break; case '7': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2) - 1), intval(substr($msg_today, 2, 2)), intval(substr($msg_today, 4, 4))); break; case '8': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2) - 2), intval(substr($msg_today, 2, 2)), intval(substr($msg_today, 4, 4))); break; case '9': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2) - 3), intval(substr($msg_today, 2, 2)), intval(substr($msg_today, 4, 4))); break; case '10': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2) - 6), intval(substr($msg_today, 2, 2)), intval(substr($msg_today, 4, 4))); break; case '11': $msg_time_filter_lo = mktime(0, 0, 0 , intval(substr($msg_today, 0, 2)), intval(substr($msg_today, 2, 2)), intval(substr($msg_today, 4, 4) - 1)); break; default: $msg_time_filter_lo = 'no'; break; } $sql = "SELECT COUNT(*) AS article_num FROM " . KB_CATEGORIES_TABLE . " c, " . KB_ARTICLES_TABLE . " a WHERE a.article_category_id = c.category_id AND c.category_id in ( $forum_lst_msg ) AND c.category_id in ( $auth_data_sql_msg ) AND a.approved = 1"; if ( $msg_time_filter_lo != 'no' && !empty($msg_time_filter_lo) ) { $sql .= " AND a.article_date > " . $msg_time_filter_lo; } if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $msg_total_match_count = $row['article_num']; $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " c, " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u WHERE a.article_category_id = c.category_id AND a.article_author_id = u.user_id AND c.category_id in ( $forum_lst_msg ) AND c.category_id in ( $auth_data_sql_msg ) AND a.approved = 1"; if ( $msg_time_filter_lo != 'no' && !empty($msg_time_filter_lo) ) { $sql .= " AND a.article_date > " . $msg_time_filter_lo; } $sql .= " ORDER BY a.article_id DESC LIMIT $msg_start, $PostNumber"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query topics list', '', __LINE__, __FILE__, $sql); } $postrow = $db->sql_fetchrowset($result); $db->sql_freeresult($result); $base_url = mx_this_url(); $template->assign_vars(array( 'L_TITLE' => ( !empty($title) ? $title : 'Last Message' ), 'U_TARGET' => $target, 'U_ALIGN' => $align, 'BLOCK_SIZE' => ( !empty($block_size) ? $block_size : '100%' ), 'U_URL' => append_sid(PORTAL_URL . 'index.php' . '?block_id=' . $block_id), 'U_URL_NEXT' => $url_next, 'U_URL_PREV' => $url_prev, 'U_PHPBB_ROOT_PATH' => PHPBB_URL, 'U_PORTAL_ROOT_PATH' => PORTAL_URL, 'TEMPLATE_ROOT_PATH' => TEMPLATE_ROOT_PATH, 'L_MSG_PREV' => $lang['Previous'], 'L_MSG_NEXT' => $lang['Next'], 'PAGINATION' => mx_generate_pagination($base_url, $msg_total_match_count, $PostNumber, $msg_start, true, true, true, false, 'kb_lmsg_start'), 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor($msg_start / $PostNumber) + 1 ), ceil($msg_total_match_count / $PostNumber)) )); if ( $msg_total_match_count == 0 || $msg_total_match_count == '' ) { $template->assign_block_vars("no_row", array( 'L_NO_ITEMS' => $lang['No_items_found'] )); } for( $row_count = 0; $row_count < count($postrow); $row_count++ ) { $row_color = ( !( $row_count % 2 ) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !( $row_count % 2 ) ) ? $theme['td_class1'] : $theme['td_class2']; $message = $postrow[$row_count]['article_title']; $url = append_sid(PHPBB_URL . 'viewtopic.php?t=' . $postrow[$row_count]['article_id'] ); $folder = $images['kb_last_article_folder']; $folder_image = $folder; if ( $display_author == "TRUE" ) { $topic_author = ( $postrow[$row_count]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid(PHPBB_URL . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $postrow[$row_count]['user_id']) . '" class="gensmall">' : ''; $topic_author .= ( $postrow[$row_count]['user_id'] != ANONYMOUS ) ? $postrow[$row_count]['username'] : ( ( $postrow[$row_count]['post_username'] != '' ) ? $postrow[$row_count]['post_username'] : $lang['Guest'] ); $topic_author .= ( $postrow[$row_count]['user_id'] != ANONYMOUS ) ? '</a>' : ''; } else { $topic_author = ''; } if ( $display_last_author == "TRUE" ) { $last_post_author = ( $postrow[$row_count]['id2'] == ANONYMOUS ) ? ( ( $postrow[$row_count]['post_username'] != '' ) ? $postrow[$row_count]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid(PHPBB_URL . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $postrow[$row_count]['id2']) . '" class="gensmall">' . $postrow[$row_count]['user2'] . '</a>'; } else { $last_post_author = ''; } $message_alt = $message; if ( strlen($message) > $nb_characteres ) { $message = substr($message, 0, $nb_characteres); $position_espace = strrpos($message, ' '); $position_espace = empty($position_espace) ? $nb_characteres : $position_espace; $message = substr($message, 0, $position_espace); $message .= '...'; } if ( $display_date == "TRUE" ) { $message_date = create_date($board_config['default_dateformat'], $postrow[$row_count]['article_date'], $board_config['board_timezone']); } else { $message_date = ''; } if ( $display_forum == "TRUE" ) { $forum_name = $postrow[$row_count]['category_name']; $forum_name_alt = $forum_name; if ( strlen($forum_name) > $nb_characteres ) { $forum_name = substr($forum_name, 0, $nb_characteres); $position_espace = strrpos($forum_name, ' '); $position_espace = empty($position_espace) ? $nb_characteres : $position_espace; $forum_name = substr($forum_name, 0, $position_espace); $forum_name .= '...'; } $forum_url = append_sid(PHPBB_URL . 'viewforum.php?f=' . $postrow[$row_count]['article_id']); } else { $forum_name = ''; $forum_url = ''; } if ( $display_icon_view == "TRUE" ) { $last_post_url = '<a href="' . append_sid(PHPBB_URL . "viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$row_count]['topic_last_post_id']) . '#' . $postrow[$row_count]['topic_last_post_id'] . '"><img src="' . $images['kb_icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>'; } else { $last_post_url = ''; } $template->assign_block_vars('msg_row', array( 'ROW_COLOR' => "#" . $row_color, 'ROW_CLASS' => $row_class, 'LAST_MSG' => $message, 'LAST_MSG_ALT' => $message_alt, 'LAST_MSG_DATE' => $message_date, 'FORUM_NAME' => $forum_name, 'FORUM_NAME_ALT' => $forum_name_alt, 'U_LAST_MSG' => $url, 'U_FORUM' => $forum_url, 'LAST_POST_IMG' => $last_post_url, 'FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'LAST_POST_AUTHOR' => $last_post_author, 'L_TOPIC_FOLDER_ALT' => $folder_alt )); } $template->pparse('body_last_msg'); ?> Index: kb_article_reader.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb_article_reader.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** kb_article_reader.php 17 Jun 2006 20:48:10 -0000 1.15 --- kb_article_reader.php 28 Jun 2006 13:58:07 -0000 1.16 *************** *** 9,13 **** */ ! if ( file_exists( './viewtopic.php' ) ) // -------------------------------------------- phpBB MOD MODE { define( 'MXBB_MODULE', false ); --- 9,13 ---- */ ! if ( file_exists( './viewtopic.' . $phpEx ) ) // -------------------------------------------- phpBB MOD MODE { define( 'MXBB_MODULE', false ); *************** *** 43,47 **** // End session management ! define( 'MXBB_27x', file_exists( $mx_root_path . 'mx_login.php' ) ); if ( !isset( $HTTP_GET_VARS['print'] ) ) --- 43,47 ---- // End session management ! define( 'MXBB_27x', file_exists( $mx_root_path . 'mx_login.' . $phpEx ) ); if ( !isset( $HTTP_GET_VARS['print'] ) ) *************** *** 83,93 **** die("Hacking attempt"); } if ( MXBB_27x ) { ! mx_message_die(GENERAL_MESSAGE, 'This module does not support standalone usage. In the adminCP, add the kb block to a portal page.'); } else { ! die('no article, no redirect'); } } --- 83,94 ---- die("Hacking attempt"); } + if ( MXBB_27x ) { ! mx_message_die( GENERAL_MESSAGE, $lang['Standalone_Not_Supported'] ); } else { ! die('No article or redirect'); } } *************** *** 96,100 **** else { ! define( 'MXBB_27x', file_exists( $mx_root_path . 'mx_login.php' ) ); // --- 97,101 ---- else { ! define( 'MXBB_27x', file_exists( $mx_root_path . 'mx_login.' . $phpEx ) ); // *************** *** 118,121 **** --- 119,124 ---- // ------------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------------------------------- + // Start + // ------------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------------------------------- *************** *** 126,197 **** // =================================================== ! // Get action variable other wise set it to the main // =================================================== ! $mode = $mx_request_vars->request('mode', MX_TYPE_NO_TAGS, 'main'); ! ! if ( isset( $HTTP_POST_VARS['page_num'] ) || isset( $HTTP_GET_VARS['page_num'] ) ) ! { ! $page_num = ( isset( $HTTP_POST_VARS['page_num'] ) ) ? intval( $HTTP_POST_VARS['page_num'] ) : intval( $HTTP_GET_VARS['page_num'] ); ! $page_num = $page_num - 1; ! } ! else ! { ! $page_num = 0; ! } ! ! // ! // Print version ! // $print_version = $mx_request_vars->request('print', MX_TYPE_NO_TAGS, ''); $is_admin = ( ( $userdata['user_level'] == ADMIN ) && $userdata['session_logged_in'] ) ? true : 0; - $reader_mode = true; // =================================================== // if the database disabled give them a nice message // =================================================== ! if ( intval( $kb_config['disable'] ) ) ! { ! // mx_message_die( GENERAL_MESSAGE, $lang['pafiledb_disable'] ); ! } ! ! /* ! if ( $mode == 'article' ) ! { ! include( $module_root_path . 'includes/kb_article.' . $phpEx ); ! } ! else if ( $mode == 'rate' ) ! { ! include( $module_root_path . 'includes/kb_rate.' . $phpEx ); ! } ! else ! { ! // return; ! // DEFAULT ACTION ! $page_title = $lang['KB_title']; ! ! if ( !$is_block ) ! { ! include( $mx_root_path . 'includes/page_header.' . $phpEx ); ! } ! ! $article_id = $default_article_id; ! ! include( $module_root_path . 'includes/kb_article.' . $phpEx ); ! } ! ! $template->pparse( 'body' ); ! ! // load footer ! if ( !$reader_mode ) ! { ! include ( $module_root_path . "includes/kb_footer." . $phpEx ); ! } ! ! if ( !$is_block && !$print_version ) { ! include( $mx_root_path . 'includes/page_tail.' . $phpEx ); } - */ // =================================================== --- 129,150 ---- // =================================================== ! // Get mode variables, otherwise set it to the main // =================================================== ! $mode = $mx_request_vars->request('mode', MX_TYPE_NO_TAGS, 'article'); $print_version = $mx_request_vars->request('print', MX_TYPE_NO_TAGS, ''); + $kb_config['reader_mode'] = true; + // =================================================== + // Is admin? + // =================================================== $is_admin = ( ( $userdata['user_level'] == ADMIN ) && $userdata['session_logged_in'] ) ? true : 0; // =================================================== // if the database disabled give them a nice message // =================================================== ! if ( intval( $kb_config['module_enable'] ) ) { ! mx_message_die( GENERAL_MESSAGE, $lang['pafiledb_disable'] ); } // =================================================== *************** *** 200,216 **** $actions = array( 'article' => 'article', - 'cat' => 'cat', - 'add' => 'post', 'search' => 'search', - 'edit' => 'post', 'rate' => 'rate', 'stats' => 'stats', ! 'moderate' => 'moderator', ! 'main' => 'main' ); // =================================================== // Lets Build the page // =================================================== - if ( !$is_block && !$print_version) { --- 153,165 ---- $actions = array( 'article' => 'article', 'search' => 'search', 'rate' => 'rate', 'stats' => 'stats', ! 'post_comment' => 'post_comment', ! ); // =================================================== // Lets Build the page // =================================================== if ( !$is_block && !$print_version) { *************** *** 226,230 **** if ( !$print_version ) { ! kb_page_header( $page_title ); } --- 175,179 ---- if ( !$print_version ) { ! //kb_page_header( $page_title ); } *************** *** 236,240 **** if ( !$print_version ) { ! kb_page_footer(); } --- 185,189 ---- if ( !$print_version ) { ! //kb_page_footer(); } Index: db_upgrade.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/db_upgrade.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** db_upgrade.php 27 Jun 2006 18:13:45 -0000 1.32 --- db_upgrade.php 28 Jun 2006 13:58:07 -0000 1.33 *************** *** 115,120 **** } // validate before 2.00 ! $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "kb_config WHERE config_name = 'wysiwyg'" ); ! if ( $db->sql_numrows( $result ) == 0 ) { $upgrade_200 = 1; --- 115,119 ---- } // validate before 2.00 ! if ( !$result = $db->sql_query( "SELECT custom_id from " . $mx_table_prefix . "kb_custom" ) ) { $upgrade_200 = 1; |