|
From: Jon O. <jon...@us...> - 2006-08-01 21:00:42
|
Update of /cvsroot/mxbb/mx_kb/kb/modules In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21873/modules/mx_kb/kb/modules Modified Files: kb_article.php kb_cat.php kb_main.php kb_post.php kb_post_comment.php kb_search.php kb_stats.php Added Files: kb_mcp.php Removed Files: kb_moderator.php Log Message: Index: kb_stats.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_stats.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** kb_stats.php 5 Jul 2006 22:48:26 -0000 1.5 --- kb_stats.php 1 Aug 2006 21:00:38 -0000 1.6 *************** *** 36,40 **** $stats = $mx_request_vars->request('stats', MX_TYPE_NO_TAGS, ''); ! $this->generate_jumpbox( 'auth_view', 0, 0, true ); $template->set_filenames( array( 'body' => 'kb_stats_body.tpl' ) ); --- 36,41 ---- $stats = $mx_request_vars->request('stats', MX_TYPE_NO_TAGS, ''); ! //$this->generate_jumpbox( 'auth_view', 0, 0, true ); ! $this->generate_jumpbox( 0, 0, array( $_GET['cat'] => 1 )); $template->set_filenames( array( 'body' => 'kb_stats_body.tpl' ) ); *************** *** 70,74 **** $this->display_stats( $start, $stats ); - //$this->display_stats( $stats, '1', 'articlerow', $start, $kb_config['pagination'] ); // --- 71,74 ---- *************** *** 88,92 **** // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 'auth_view', 0, 0, true ); } --- 88,93 ---- // Get footer quick dropdown jumpbox // ! //$this->generate_jumpbox( 'auth_view', 0, 0, true ); ! $this->generate_jumpbox( 0, 0, array( $_GET['cat'] => 1 )); } --- kb_moderator.php DELETED --- Index: kb_post.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_post.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** kb_post.php 5 Jul 2006 22:48:26 -0000 1.8 --- kb_post.php 1 Aug 2006 21:00:38 -0000 1.9 *************** *** 27,34 **** function main( $action ) { ! global $template, $mx_kb_functions, $lang, $board_config, $phpEx, $kb_config, $db, $images, $userdata, $_POST; ! global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars, $theme; ! global $HTTP_POST_VARS; // --- 27,33 ---- function main( $action ) { ! global $template, $mx_kb_functions, $lang, $board_config, $phpEx, $kb_config, $db, $images, $userdata; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars, $theme; ! global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; // *************** *** 36,92 **** // $article_id = $mx_request_vars->request('k', MX_TYPE_INT, ''); $kb_post_mode = empty( $article_id ) ? 'add' : 'edit'; //Main mode toggle $this->page_title = $kb_post_mode == 'add' ? $lang['Add_article'] : $lang['Edit_article']; $delete = $mx_request_vars->request('delete', MX_TYPE_NO_TAGS, ''); - $submit = $mx_request_vars->is_request('article_submit'); $preview = $mx_request_vars->is_request('preview'); $cancel = $mx_request_vars->is_request('cancel'); ! if ( $mx_request_vars->is_request('cat') ) ! { ! $category_id = $mx_request_vars->request('cat', MX_TYPE_INT, 0); ! ! } ! else if( $kb_post_mode == 'edit') { ! $category_id = $this->get_cat_id($article_id); } else { ! mx_message_die( GENERAL_MESSAGE, $lang['Category_not_exsist'] ); } // ! // First (re)declare basic variables // ! $kb_row = array(); ! if ( $kb_post_mode == 'edit' ) { ! $sql = "SELECT * ! FROM " . KB_ARTICLES_TABLE . " ! WHERE article_id = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, "Could not obtain article data", '', __LINE__, __FILE__, $sql ); } ! $kb_row = $db->sql_fetchrow( $result ); } ! $kb_title = $preview || isset($HTTP_POST_VARS['article_name']) ? $HTTP_POST_VARS['article_name'] : $kb_row['article_title']; ! $kb_desc = $preview || isset($HTTP_POST_VARS['article_desc']) ? $HTTP_POST_VARS['article_desc'] : $kb_row['article_description']; ! $kb_text = $preview || isset($HTTP_POST_VARS['message']) ? $HTTP_POST_VARS['message'] : $kb_row['article_body']; ! $bbcode_uid = $preview ? '' : $kb_row['bbcode_uid']; ! $username = $preview || isset($HTTP_POST_VARS['username']) ? $HTTP_POST_VARS['username'] : $kb_row['username']; ! $type_id = $preview || isset($HTTP_POST_VARS['type_id']) ? intval($HTTP_POST_VARS['type_id']) : $kb_row['article_type']; // // Instatiate custom fields (only used in kb_article) // ! include_once( $module_root_path . 'kb/includes/functions_field.' . $phpEx ); ! $mx_kb_custom_field = new mx_kb_custom_field(); $mx_kb_custom_field->init(); --- 35,166 ---- // $article_id = $mx_request_vars->request('k', MX_TYPE_INT, ''); + $cat_id = $mx_request_vars->request('cat', MX_TYPE_INT, 0); + + $do = ( isset( $_REQUEST['do'] ) ) ? intval( $_REQUEST['do'] ) : ''; $kb_post_mode = empty( $article_id ) ? 'add' : 'edit'; //Main mode toggle $this->page_title = $kb_post_mode == 'add' ? $lang['Add_article'] : $lang['Edit_article']; $delete = $mx_request_vars->request('delete', MX_TYPE_NO_TAGS, ''); $preview = $mx_request_vars->is_request('preview'); $cancel = $mx_request_vars->is_request('cancel'); ! // ! // Main Auth ! // ! if ( !empty( $cat_id ) ) { ! if ( !$this->auth_user[$cat_id]['auth_post'] ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_post'] ); ! } } else { ! $dropmenu = ( !$cat_id ) ? $this->generate_jumpbox( 0, 0, '', true, true, 'auth_post' ) : $this->generate_jumpbox( 0, 0, array( $cat_id => 1 ), true, true, 'auth_post' ); ! ! if ( empty( $dropmenu ) ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_post'] ); ! } } // ! // Load article info...if $article_id is set // ! if ( $article_id ) { ! $sql = 'SELECT * ! FROM ' . KB_ARTICLES_TABLE . " ! WHERE article_id = '" . $article_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt query Article data', '', __LINE__, __FILE__, $sql ); } ! $article_data = $db->sql_fetchrow( $result ); ! ! $db->sql_freeresult( $result ); } ! // ! // Further security. ! // Reset vars if no related data exist. ! // ! if ( $article_id && !$article_data['article_category_id'] ) ! { ! $article_id = 0; ! } ! if ( $cat_id && !$this->cat_rowset[$cat_id]['category_id'] ) ! { ! $cat_id = 0; ! } ! ! // ======================================================= ! // Delete ! // ======================================================= ! if ( $do == 'delete' && $article_id) ! { ! if ( ( $this->auth_user[$article_data['article_category_id']]['auth_delete'] && $article_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$article_data['article_category_id']]['auth_mod'] ) ! { ! // ! // Notification ! // ! $this->update_add_item_notify($article_id, 'delete'); ! ! // ! // Comments ! // ! if ($this->comments[$article_data['article_category_id']]['activated'] && $kb_config['del_topic']) ! { ! if ( $this->comments[$article_data['article_category_id']]['internal_comments'] ) ! { ! $sql = 'DELETE FROM ' . KB_COMMENTS_TABLE . " ! WHERE article_id = '" . $article_id . "'"; ! ! if ( !( $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); ! } ! } ! else ! { ! if ( $article_data['topic_id'] ) ! { ! include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); ! $mx_kb_comments = new mx_kb_comments(); ! $mx_kb_comments->init( $article_data, 'phpbb'); ! $mx_kb_comments->post('delete_all', $article_data['topic_id']); ! } ! } ! } ! ! $this->delete_items( $article_id ); ! $this->_kb(); ! $message = $lang['Articledeleted'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "mode=cat&cat=" . $article_data['article_category_id'] ) ) . '">', '</a>' ); ! mx_message_die( GENERAL_MESSAGE, $message ); ! } ! else ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_delete'] ); ! } ! } ! ! // ! // Define more vars ! // ! $kb_title = $preview || isset($_POST['article_name']) ? $_POST['article_name'] : $article_data['article_title']; ! $kb_desc = $preview || isset($_POST['article_desc']) ? $_POST['article_desc'] : $article_data['article_description']; ! $kb_text = $preview || isset($_POST['message']) ? $_POST['message'] : $article_data['article_body']; ! $bbcode_uid = $preview ? '' : $article_data['bbcode_uid']; ! ! $username = $preview || isset($_POST['username']) ? $_POST['username'] : $article_data['username']; ! $type_id = $preview || isset($_POST['type_id']) ? intval($_POST['type_id']) : $article_data['article_type']; // // Instatiate custom fields (only used in kb_article) // ! $mx_kb_custom_field = new mx_custom_field(KB_CUSTOM_TABLE, KB_CUSTOM_DATA_TABLE); $mx_kb_custom_field->init(); *************** *** 127,131 **** // Instantiate the mx_text and mx_text_formatting classes // - include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); $mx_text = new mx_text(); $mx_text->init($html_on, $bbcode_on, $smilies_on); --- 201,204 ---- *************** *** 140,146 **** // ! // post article ----------------------------------------------------------------------------ADD/EDIT // ! if ( $submit ) { if ( !$mx_request_vars->is_request('article_name') || !$mx_request_vars->is_request('article_desc') || !$mx_request_vars->is_request('message') ) --- 213,219 ---- // ! // IF submit then upload the article and update the sql for it // ! if ( isset( $_POST['submit'] ) && $cat_id ) { if ( !$mx_request_vars->is_request('article_name') || !$mx_request_vars->is_request('article_desc') || !$mx_request_vars->is_request('message') ) *************** *** 162,182 **** $author_id = $userdata['user_id'] > 0 ? intval( $userdata['user_id'] ) : '-1'; ! switch ( $kb_post_mode ) { ! case 'edit': // UPDATE Article ------------------------------------------- ! if ( !($this->auth_user[$category_id]['auth_edit'] || $this->auth_user[$category_id]['auth_mod']) ) { ! $message = $lang['No_edit'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); ! mx_message_die( GENERAL_MESSAGE, $message ); } // // Approve // ! $approve = $this->auth_user[$category_id]['auth_mod'] || $this->auth_user[$category_id]['auth_approval_edit'] ? 1 : 2; // approved $sql = "UPDATE " . KB_ARTICLES_TABLE . " ! SET article_category_id = '$category_id', article_title = '" . str_replace( "\'", "''", $article_title ) . "', article_description = '" . str_replace( "\'", "''", $article_description ) . "', --- 235,290 ---- $author_id = $userdata['user_id'] > 0 ? intval( $userdata['user_id'] ) : '-1'; ! if ( !$article_id ) { ! if ( $this->auth_user[$cat_id]['auth_post'] || $this->auth_user[$cat_id]['auth_mod'] ) ! { ! // ! // Approve ! // ! $approve = $this->auth_user[$cat_id]['auth_approval'] || $this->auth_user[$cat_id]['auth_mod'] ? 1 : 0; // approved ! $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " ( article_category_id , article_title , article_description , article_date , article_author_id , username , bbcode_uid , article_body , article_type , approved, views ) ! VALUES ( '$cat_id', '" . str_replace( "\'", "''", $article_title ) . "', '" . str_replace( "\'", "''", $article_description ) . "', '$date', '$author_id', '" . str_replace( "\'", "''", $username ) . "', '$bbcode_uid', '" . str_replace( "\'", "''", $article_text ) . "', '$type_id', '$approve', '0')"; ! ! if ( !( $results = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, "Could not submit aritcle", '', __LINE__, __FILE__, $sql ); ! } ! ! // ! // Get new article id ! // ! $sql = "SELECT MAX(article_id) AS new_id FROM " . KB_ARTICLES_TABLE; ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't find max article_id", "", __LINE__, __FILE__, $sql); } + $temp_row = $db->sql_fetchrow($result); + $article_id = $temp_row['new_id']; // + // Update custom fields + // + $mx_kb_custom_field->file_update_data( $article_id ); + + $this->modified( true ); + $this->_kb(); + } + else + { + $message = $lang['Sorry_auth_post']; + } + } + else + { + if ( ($this->auth_user[$cat_id]['auth_edit'] && $article_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$cat_id]['auth_mod'] ) + { + // // Approve // ! $approve = $this->auth_user[$cat_id]['auth_mod'] || $this->auth_user[$cat_id]['auth_approval_edit'] ? 1 : 0; // approved $sql = "UPDATE " . KB_ARTICLES_TABLE . " ! SET article_category_id = '$cat_id', article_title = '" . str_replace( "\'", "''", $article_title ) . "', article_description = '" . str_replace( "\'", "''", $article_description ) . "', *************** *** 193,253 **** } - $this->modified( true ); - - break; - - case 'add': // ADD NEW --------------------------------------------------------------------------------- - - if ( !($this->auth_user[$category_id]['auth_post'] || $this->auth_user[$category_id]['auth_mod']) ) - { - $message = $lang['No_add'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); - mx_message_die( GENERAL_MESSAGE, $message ); - } - - // - // Approve // ! $approve = $this->auth_user[$category_id]['auth_approval'] || $this->auth_user[$category_id]['auth_mod'] ? 1 : 0; // approved ! ! $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " ( article_category_id , article_title , article_description , article_date , article_author_id , username , bbcode_uid , article_body , article_type , approved, views ) ! VALUES ( '$category_id', '" . str_replace( "\'", "''", $article_title ) . "', '" . str_replace( "\'", "''", $article_description ) . "', '$date', '$author_id', '" . str_replace( "\'", "''", $username ) . "', '$bbcode_uid', '" . str_replace( "\'", "''", $article_text ) . "', '$type_id', '$approve', '0')"; ! ! if ( !( $results = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not submit aritcle", '', __LINE__, __FILE__, $sql ); ! } ! ! // ! // Get new article id // ! $sql = "SELECT MAX(article_id) AS new_id FROM " . KB_ARTICLES_TABLE; ! if( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, "Couldn't find max article_id", "", __LINE__, __FILE__, $sql); ! } ! $temp_row = $db->sql_fetchrow($result); ! $article_id = $temp_row['new_id']; $this->modified( true ); ! ! break; } // - // Update custom fields - // - $mx_kb_custom_field->file_update_data( $article_id ); - - $this->_kb(); - - // // Notification // ! $this->update_add_article_notify($article_id, $kb_post_mode); // // Auto comment // ! if ( $this->comments[$category_id]['activated'] && $this->comments[$category_id]['autogenerate_comments'] ) { // --- 301,327 ---- } // ! // Update custom fields // ! $mx_kb_custom_field->file_update_data( $article_id ); $this->modified( true ); ! $this->_kb(); ! } ! else ! { ! $message = $lang['Sorry_auth_edit']; ! } } // // Notification // ! $this->update_add_item_notify($article_id, $kb_post_mode); // // Auto comment // ! if ( $this->comments[$cat_id]['activated'] && $this->comments[$cat_id]['autogenerate_comments'] ) { // *************** *** 272,404 **** $message = $lang['Article_submitted_Approve'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); } - mx_message_die( GENERAL_MESSAGE, $message ); - } ! // ---------------------------------------------------------------------------------------------------------- MAIN FORM ! // ---------------------------------------------------------------------------------------------------------- ! // ---------------------------------------------------------------------------------------------------------- ! ! // ! // PreText HIDE/SHOW ! // ! if ( $kb_config['show_pretext'] ) ! { ! // Pull Header/Body info. ! $pt_header = $kb_config['pt_header']; ! $pt_body = $kb_config['pt_body']; ! ! $template->set_filenames( array( 'pretext' => 'kb_post_pretext.tpl' ) ); ! ! $template->assign_vars( array( ! 'PRETEXT_HEADER' => $pt_header, ! 'PRETEXT_BODY' => $pt_body ) ); ! ! $template->assign_var_from_handle( 'KB_PRETEXT_BOX', 'pretext' ); } ! ! // ! // Security ! // ! if ( !$this->auth_user[$category_id]['auth_mod'] ) { ! if ( $kb_post_mode == 'edit' && !$this->auth_user[$category_id]['auth_edit'] ) { ! $message = $lang['No_edit'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); ! mx_message_die( GENERAL_MESSAGE, $message ); } ! ! if ( $kb_post_mode == 'add' && ( !$this->auth_user[$category_id]['auth_post'] || $kb_config['enable_module'] == 0 ) ) { ! $message = $lang['No_add'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); ! mx_message_die( GENERAL_MESSAGE, $message ); } - } - if ( $preview ) - { // ! // Encode for preview // ! $preview_title = $mx_text->encode_preview_simple($kb_title); ! $preview_desc = $mx_text->encode_preview_simple($kb_desc); ! $preview_text = $mx_text->encode_preview($kb_text); ! ! if (!$kb_config['allow_images'] || !$kb_config['allow_links']) { ! $preview_text = $mx_text_formatting->remove_images_links( $preview_text, $kb_config['allow_images'], $kb_config['no_image_message'], $kb_config['allow_links'], $kb_config['no_link_message'] ); } ! $template->set_filenames( array( 'preview' => 'kb_post_preview.tpl' ) ); ! $template->assign_vars( array( ! 'L_PREVIEW' => $lang['Preview'], ! 'ARTICLE_TITLE' => $preview_title, ! 'ARTICLE_DESC' => $preview_desc, ! 'ARTICLE_BODY' => $preview_text, ! 'PREVIEW_MESSAGE' => $preview_text ) ! ); ! $template->assign_var_from_handle( 'KB_PREVIEW_BOX', 'preview' ); // ! // Decode for form editing // ! $kb_title = $mx_text->decode_simple($kb_title, true); ! $kb_desc = $mx_text->decode_simple($kb_desc, true); ! $kb_text = $mx_text->decode($kb_text, '', true); ! } ! else ! { // ! // Decode for form editing // ! $kb_title = $mx_text->decode_simple($kb_title, true); ! $kb_desc = $mx_text->decode_simple($kb_desc, true); ! $kb_text = $mx_text->decode($kb_text, $bbcode_uid, true); ! ! } ! ! // ! // show article form - MAIN ! // ! if ( $kb_post_mode == 'edit' ) ! { ! $s_hidden_vars = '<input type="hidden" name="k" value="' . $article_id . '"><input type="hidden" name="bbcode_uid" value="' . $bbcode_uid . '"><input type="hidden" name="author_id" value="' . $author_id . '">'; ! } ! else ! { ! $s_hidden_vars = '<input type="hidden" name="cat" value="' . $category_id . '">'; ! } ! ! // ! // Toggle selection ! // ! $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; ! $bbcode_status = ( $bbcode_on ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF']; ! $smilies_status = ( $smilies_on ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF']; ! $links_status = ( $links_on ) ? $lang['Links_are_ON'] : $lang['Links_are_OFF']; ! $images_status = ( $images_on ) ? $lang['Images_are_ON'] : $lang['Images_are_OFF']; ! // ! // set up page ! // ! $template->set_filenames( array( 'body' => 'kb_post_body.tpl' ) ); ! if ( !$userdata['session_logged_in'] ) ! { ! $template->assign_block_vars( 'switch_name', array() ); ! } ! $kb_action_url = $kb_post_mode == 'add' ? $this->this_mxurl( 'mode=add' ) : $this->this_mxurl( 'mode=edit' ); ! $custom_data = $kb_post_mode == 'add' ? $mx_kb_custom_field->display_edit() : $mx_kb_custom_field->display_edit( $article_id ); ! if ( $custom_data ) ! { ! $template->assign_block_vars( 'custom_data_fields', array( ! 'L_ADDTIONAL_FIELD' => $lang['Addtional_field'] ! )); ! } ! $template->assign_vars( array( 'S_ACTION' => $kb_action_url, 'S_HIDDEN_FIELDS' => $s_hidden_vars, --- 346,479 ---- $message = $lang['Article_submitted_Approve'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $mx_root_path . "index.$phpEx" ) . '">', '</a>' ); } ! mx_message_die( GENERAL_MESSAGE, $message ); } ! else ! // ======================================================= ! // IF not submit then load data MAIN form ! // ======================================================= { ! if ( !$article_id ) { ! if ( !$this->auth_user[$article_data['article_category_id']]['auth_post'] ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_post'] ); ! } } ! else { ! $cat_id = $article_data['article_category_id']; ! if ( !( ( $this->auth_user[$article_data['article_category_id']]['auth_edit'] && $article_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$article_data['article_category_id']]['auth_mod'] ) ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_edit'] ); ! } } // ! // PreText HIDE/SHOW // ! if ( $kb_config['show_pretext'] ) { ! // ! // Pull Header/Body info. ! // ! $pt_header = $kb_config['pt_header']; ! $pt_body = $kb_config['pt_body']; ! ! $template->set_filenames( array( 'pretext' => 'kb_post_pretext.tpl' ) ); ! ! $template->assign_vars( array( ! 'PRETEXT_HEADER' => $pt_header, ! 'PRETEXT_BODY' => $pt_body ) ); ! ! $template->assign_var_from_handle( 'KB_PRETEXT_BOX', 'pretext' ); } ! if ( $preview ) ! { ! // ! // Encode for preview ! // ! $preview_title = $mx_text->encode_preview_simple($kb_title); ! $preview_desc = $mx_text->encode_preview_simple($kb_desc); ! $preview_text = $mx_text->encode_preview($kb_text); ! if (!$kb_config['allow_images'] || !$kb_config['allow_links']) ! { ! $preview_text = $mx_text_formatting->remove_images_links( $preview_text, $kb_config['allow_images'], $kb_config['no_image_message'], $kb_config['allow_links'], $kb_config['no_link_message'] ); ! } ! $template->set_filenames( array( 'preview' => 'kb_post_preview.tpl' ) ); ! ! $template->assign_vars( array( ! 'L_PREVIEW' => $lang['Preview'], ! 'ARTICLE_TITLE' => $preview_title, ! 'ARTICLE_DESC' => $preview_desc, ! 'ARTICLE_BODY' => $preview_text, ! 'PREVIEW_MESSAGE' => $preview_text ) ! ); ! ! $template->assign_var_from_handle( 'KB_PREVIEW_BOX', 'preview' ); ! ! // ! // Decode for form editing ! // ! $kb_title = $mx_text->decode_simple($kb_title, true); ! $kb_desc = $mx_text->decode_simple($kb_desc, true); ! $kb_text = $mx_text->decode($kb_text, '', true); ! } ! else ! { ! // ! // Decode for form editing ! // ! $kb_title = $mx_text->decode_simple($kb_title, true); ! $kb_desc = $mx_text->decode_simple($kb_desc, true); ! $kb_text = $mx_text->decode($kb_text, $bbcode_uid, true); ! ! } // ! // show article form - MAIN // ! if ( $kb_post_mode == 'edit' ) ! { ! $s_hidden_vars = '<input type="hidden" name="k" value="' . $article_id . '"><input type="hidden" name="bbcode_uid" value="' . $bbcode_uid . '"><input type="hidden" name="author_id" value="' . $author_id . '">'; ! } ! else ! { ! $s_hidden_vars = '<input type="hidden" name="cat" value="' . $cat_id . '">'; ! } ! // ! // Toggle selection // ! $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; ! $bbcode_status = ( $bbcode_on ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF']; ! $smilies_status = ( $smilies_on ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF']; ! $links_status = ( $links_on ) ? $lang['Links_are_ON'] : $lang['Links_are_OFF']; ! $images_status = ( $images_on ) ? $lang['Images_are_ON'] : $lang['Images_are_OFF']; ! // ! // set up page ! // ! $template->set_filenames( array( 'body' => 'kb_post_body.tpl' ) ); ! if ( !$userdata['session_logged_in'] ) ! { ! $template->assign_block_vars( 'switch_name', array() ); ! } ! $kb_action_url = $kb_post_mode == 'add' ? $this->this_mxurl( 'mode=add' ) : $this->this_mxurl( 'mode=edit' ); ! $custom_data = $kb_post_mode == 'add' ? $mx_kb_custom_field->display_edit() : $mx_kb_custom_field->display_edit( $article_id ); ! if ( $custom_data ) ! { ! $template->assign_block_vars( 'custom_data_fields', array( ! 'L_ADDTIONAL_FIELD' => $lang['Addtional_field'] ! )); ! } ! $template->assign_vars( array( 'S_ACTION' => $kb_action_url, 'S_HIDDEN_FIELDS' => $s_hidden_vars, *************** *** 489,523 **** 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'] ! ) ); ! ! $mx_kb_functions->get_kb_type_list( $type_id ); ! if ( $kb_post_mode == 'edit' ) ! { ! $template->assign_block_vars( 'switch_edit', array( ! 'CAT_LIST' => $this->generate_jumpbox( 'auth_edit', $category_id, $category_id, true ) ! )); ! } ! if ( $bbcode_on ) ! { ! $template->assign_block_vars( 'switch_bbcodes', array()); ! } ! // =================================================== ! // assign var for top navigation ! // =================================================== ! $this->generate_navigation( $category_id ); ! // ! // User authorisation levels output ! // ! $this->auth_can($category_id); ! // ! // Get footer quick dropdown jumpbox ! // ! $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } --- 564,598 ---- 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'] + ) ); ! $mx_kb_functions->get_kb_type_list( $type_id ); ! if ( $kb_post_mode == 'edit' ) ! { ! $template->assign_block_vars( 'switch_edit', array( ! 'CAT_LIST' => $this->generate_jumpbox( 0, 0, array( $cat_id => 1 ), false, true, 'auth_edit') ! )); ! } ! if ( $bbcode_on ) ! { ! $template->assign_block_vars( 'switch_bbcodes', array()); ! } ! // =================================================== ! // assign var for top navigation ! // =================================================== ! $this->generate_navigation( $cat_id ); ! // ! // User authorisation levels output ! // ! $this->auth_can( $cat_id ); ! // ! // Get footer quick dropdown jumpbox ! // ! $this->generate_jumpbox( 0, 0, array( $cat_id => 1 )); ! } } } --- NEW FILE: kb_mcp.php --- <?php /** * * @package mxBB Portal Module - mx_kb * @version $Id: kb_mcp.php,v 1.1 2006/08/01 21:00:38 jonohlsson Exp $ * @copyright (c) 2002-2006 [Mohd Basri, PHP Arena, linkdb, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /** * Enter description here... * */ class mx_kb_mcp extends mx_kb_public { /** * Enter description here... * * @param unknown_type $action */ function main( $action ) { global $db, $lang, $userdata, $board_config, $phpEx, $images, $debug; global $mx_root_path, $phpbb_root_path, $module_root_path, $is_block, $phpEx; global $mx_kb_functions, $template, $kb_config; $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; $id = ( isset( $_REQUEST['id'] ) ) ? intval( $_REQUEST['id'] ) : 0; $ids = ( isset( $_POST['ids'] ) ) ? array_map( 'intval', $_POST['ids'] ) : array(); $start = ( isset( $_REQUEST['start'] ) ) ? intval( $_REQUEST['start'] ) : 0; $mode = $mode_notification = ( isset( $_REQUEST['mode_mcp'] ) ) ? htmlspecialchars( $_REQUEST['mode_mcp'] ) : 'all'; $do_mode = ( isset( $_REQUEST['do_mode'] ) ) ? htmlspecialchars( $_REQUEST['do_mode'] ) : ''; $do_mode = ( isset( $_POST['do_approve'] ) ) ? 'do_approve' : $do_mode; $do_mode = ( isset( $_POST['do_unapprove'] ) ) ? 'do_unapprove' : $do_mode; $do_mode = ( isset( $_POST['do_delete'] ) ) ? 'do_delete' : $do_mode; // =================================================== // Auth for mcp // =================================================== if ( !($this->auth_user[$cat_id]['auth_mod']) && $mode == 'cat') { $message = sprintf( $lang['Sorry_auth_mcp'], $this->auth_user[$cat_id]['auth_mod'] ); mx_message_die( GENERAL_MESSAGE, $message ); } // // Determine all categories in which user is moderator // $moderator_cat_ids = ''; if ( isset( $this->cat_rowset ) ) { foreach( $this->cat_rowset as $auth_cat_id => $cat_row ) { if ($this->auth_user[$auth_cat_id]['auth_mod']) { $moderator_cat_ids .= !empty($moderator_cat_ids) ? ',' . $auth_cat_id : $auth_cat_id; } } } if (empty($moderator_cat_ids)) { mx_message_die( GENERAL_MESSAGE, 'Sorry, you have no moderator permissions...' ); } if ( isset( $_REQUEST['sort_method'] ) ) { switch ( $_REQUEST['sort_method'] ) { case 'Alphabetic': $sort_method = 'article_title'; break; case 'Latest': $sort_method = 'article_date'; break; case 'Views': $sort_method = 'views'; break; case 'Rating': $sort_method = 'rating'; break; default: $sort_method = $kb_config['sort_method']; } } else { $sort_method = $kb_config['sort_method']; } if ( isset( $_REQUEST['sort_order'] ) ) { switch ( $_REQUEST['sort_order'] ) { case 'ASC': $sort_order = 'ASC'; break; case 'DESC': $sort_order = 'DESC'; break; default: $sort_order = $kb_config['sort_order']; } } else { $sort_order = $kb_config['sort_order']; } $s_actions = array( 'unapproved' => $lang['Unapproved_items'], 'cat' => $lang['Item_cat'], 'all' => $lang['All_items'] ); switch ( $mode ) { case '': case 'unapproved': case 'cat': case 'all': default: $template_item = 'kb_mcp.tpl'; $l_title = $lang['MCP_title']; $l_explain = $lang['MCP_title_explain']; break; } // // Approve/Unapprove // if ( $do_mode == 'do_approve' || $do_mode == 'do_unapprove' ) { if ( is_array( $ids ) && !empty( $ids ) ) { foreach( $ids as $temp_id ) { $this->approve_item( $do_mode, $temp_id ); } // // Notification // $this->update_add_item_notify($ids, $do_mode); } else { $this->approve_item( $do_mode, $id ); // // Notification // $this->update_add_item_notify($id, $do_mode); } $this->_kb(); } // // Delete // else if ( $do_mode == 'do_delete' ) { if ( is_array( $ids ) && !empty( $ids ) ) { foreach( $ids as $temp_id ) { $sql = 'SELECT * FROM ' . KB_ARTICLES_TABLE . " WHERE article_id = $temp_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $item_info = $db->sql_fetchrow( $result ); // // Notification // $this->update_add_item_notify($temp_id, 'delete'); // // Comments // if ($this->comments[$item_info['article_category_id']]['activated'] && $kb_config['del_topic']) { if ( $this->comments[$item_info['article_category_id']]['internal_comments'] ) { $sql = 'DELETE FROM ' . KB_COMMENTS_TABLE . " WHERE article_id = '" . $temp_id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $item_info['topic_id'] ) { include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); $mx_kb_comments = new mx_kb_comments(); $mx_kb_comments->init( $item_info, 'phpbb'); $mx_kb_comments->post('delete_all', $item_info['topic_id']); } } } $this->delete_items( $temp_id ); } } else { $sql = 'SELECT * FROM ' . KB_ARTICLES_TABLE . " WHERE article_id = $id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $item_info = $db->sql_fetchrow( $result ); // // Notification // $this->update_add_item_notify($id, 'delete'); // // Comments // if ($this->comments[$item_info['article_category_id']]['activated'] && $kb_config['del_topic']) { if ( $this->comments[$item_info['article_category_id']]['internal_comments'] ) { $sql = 'DELETE FROM ' . KB_COMMENTS_TABLE . " WHERE article_id = '" . $id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $item_info['topic_id'] ) { include( $module_root_path . 'kb/includes/functions_comment.' . $phpEx ); $mx_kb_comments = new mx_kb_comments(); $mx_kb_comments->init( $item_info, 'phpbb'); $mx_kb_comments->post('delete_all', $item_info['topic_id']); } } } $this->delete_items( $id ); } $this->_kb(); } $template->set_filenames( array( 'body' => $template_item ) ); if ($mode == 'cat') { //$s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $cat_id . '">'; } $template->assign_vars( array( 'ARTICLES' => $kb_config['module_name'], 'U_ARTICLES' => append_sid( $this->this_mxurl() ), 'L_MCP_TITLE' => $l_title, 'L_MCP_EXPLAIN' => $l_explain, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ACTION' => append_sid( $this->this_mxurl( "mode=mcp" ) ) )); // // Lets start displaying... // if ( in_array( $mode, array( 'unapproved', 'cat', 'all' ) ) ) { // // All items (or all items in cat) // if ( $mode == 'all' || $mode == 'cat' ) { $where_sql = ($mode == 'cat') ? "AND article_category_id = '$cat_id'" : ''; $sql = "SELECT article_title, approved, article_id FROM " . KB_ARTICLES_TABLE . " as f1 WHERE approved = '1' ".$where_sql." AND article_category_id IN (".$moderator_cat_ids.") ORDER BY article_date DESC"; if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $total_num = $db->sql_numrows( $result ); if ( !( $result = $mx_kb_functions->sql_query_limit( $sql, $kb_config['pagination'], $start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $all_rowset[] = $row; } } // // Unapproved files only // if ( $mode == 'unapproved' || $mode == 'all' || $mode == 'cat') { $sql = "SELECT article_title, approved, article_id FROM " . KB_ARTICLES_TABLE . " WHERE approved = '0' AND article_category_id IN (".$moderator_cat_ids.") ORDER BY article_date DESC"; if ($mode == 'unapproved') { if ( !( $result = $mx_kb_functions->sql_query_limit( $sql, $kb_config['pagination'], $start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $total_num = $db->sql_numrows( $result ); } else { if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } } while ( $row = $db->sql_fetchrow( $result ) ) { $unapproved_rowset[] = $row; } } // // Ensure $total_num nonzero to validate pagination // $total_num = empty($total_num) ? 1 : $total_num; // // Define display sets // if ( $mode == '' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'all' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'cat' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'unapproved' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ) ); } // // Generate Select dropdown navigation // $s_list = ''; foreach( $s_actions as $item_mode => $lang_var ) { $s = ''; if ( $mode == $item_mode ) { $s = ' selected="selected"'; } $s_list .= '<option value="' . $item_mode . '"' . $s . '>' . $lang_var . '</option>'; } $cat_list = '<select name="cat_id">'; if ( !$this->cat_rowset[$cat_id]['cat_parent'] ) { $cat_list .= '<option value="0" selected>' . $lang['None'] . '</option>\n'; } else { $cat_list .= '<option value="0">' . $lang['None'] . '</option>\n'; } $cat_list .= $this->generate_jumpbox( 0, 0, array( $cat_id => 1 ), false, true, 'auth_mod' ); $cat_list .= '</select>'; $template->assign_vars( array( 'L_EDIT' => $lang['Edit_article'], // Module specific 'L_DELETE' => $lang['Delete_article'], // Module specific 'L_CATEGORY' => $lang['Category'], 'L_MODE' => $lang['View'], 'L_GO' => $lang['Go'], 'L_DELETE_ITEM' => $lang['Delete_selected'], 'L_APPROVE' => $lang['Approve'], 'L_UNAPPROVE' => $lang['Unapprove'], 'L_APPROVE_ITEM' => $lang['Approve_selected'], 'L_UNAPPROVE_ITEM' => $lang['Unapprove_selected'], 'L_NO_ITEMS' => $lang['No_item'], 'PAGINATION' => generate_pagination( append_sid( $this->this_mxurl( "mode=mcp&mode_mcp=$mode&sort_method=$sort_method&sort_order=$sort_order" ) . ($mode == 'cat' ? "&cat_id=$cat_id" : '') ), $total_num, $kb_config['pagination'], $start ), 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $kb_config['pagination'] ) + 1 ), ceil( $total_num / $kb_config['pagination'] ) ), 'S_CAT_LIST' => $cat_list, 'S_MODE_SELECT' => $s_list ) ); foreach( $global_array as $data ) { $approve = false; $unapprove = false; if ( $data['approval'] == 'both' ) { $approve = $unapprove = true; } elseif ( $data['approval'] == 'approve' ) { $approve = true; } elseif ( $data['approval'] == 'unapprove' ) { $unapprove = true; } $template->assign_block_vars( 'mcp_mode', array( 'L_MODE' => $data['lang_var'], 'DATA' => ( isset( $data['row_set'] ) ) ? true : false, 'APPROVE' => $approve, 'UNAPPROVE' => $unapprove ) ); if ( isset( $data['row_set'] ) ) { $i = ( $mode == 'unapproved' || ( count($global_array) > 1 && $data['approval'] == 'unapprove' ) ) ? $start + 1 : '1'; foreach( $data['row_set'] as $item_data ) { $approve_mode = ( $item_data['approved'] ) ? 'do_unapprove' : 'do_approve'; $template->assign_block_vars( 'mcp_mode.row', array( 'NAME' => $item_data['article_title'], 'NUMBER' => $i++, 'ID' => $item_data['article_id'], 'U_EDIT' => append_sid( $this->this_mxurl( "mode=edit&k={$item_data['article_id']}" ) ), 'U_DELETE' => append_sid( $this->this_mxurl( "mode=mcp&mode_mcp=$mode&do_mode=do_delete&id={$item_data['article_id']}" ) ), 'U_APPROVE' => append_sid( $this->this_mxurl( "mode=mcp&mode_mcp=$mode&do_mode=$approve_mode&id={$item_data['article_id']}" ) . ($mode == 'cat' ? "&cat_id=$cat_id" : '') ), 'L_APPROVE' => ( $item_data['approved'] ) ? $lang['Unapprove'] : $lang['Approve'] ) ); } } else { $template->assign_block_vars( 'mcp_mode.no_data', array()); } } } // // Notification // $itemId = !empty($id) ? $id : $ids; $this->update_add_item_notify($itemId, $mode_notification); $template->assign_vars( array( 'ERROR' => ( sizeof( $this->error ) ) ? implode( '<br />', $this->error ) : '' ) ); $this->_kb(); } } ?> Index: kb_main.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_main.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** kb_main.php 7 Jun 2006 20:28:54 -0000 1.3 --- kb_main.php 1 Aug 2006 21:00:38 -0000 1.4 *************** *** 33,39 **** $template->set_filenames( array( 'body' => 'kb_index_body.tpl' )); $template->assign_vars( array( ! 'L_CATEGORY' => $lang['Category'], ! 'L_ARTICLES' => $lang['Articles'] ) ); --- 33,42 ---- $template->set_filenames( array( 'body' => 'kb_index_body.tpl' )); + // + // Assign vars + // $template->assign_vars( array( ! 'L_CATEGORY' => $lang['Category'], ! 'L_ARTICLES' => $lang['Articles'] ) ); *************** *** 46,50 **** // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 'auth_view', 0, 0, true ); } } --- 49,53 ---- // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 0, 0, array( $_GET['cat'] => 1 )); } } Index: kb_search.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_search.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** kb_search.php 5 Jul 2006 22:48:26 -0000 1.6 --- kb_search.php 1 Aug 2006 21:00:38 -0000 1.7 *************** *** 592,596 **** if ( !isset( $_POST['submit'] ) || ( $search_author == '' && $search_keywords == '' && !$search_id ) ) { ! $dropmenu = $this->generate_jumpbox( 'auth_view', 0, 0, true ); $template->set_filenames( array( 'body' => 'kb_search_body.tpl' ) ); --- 592,597 ---- if ( !isset( $_POST['submit'] ) || ( $search_author == '' && $search_keywords == '' && !$search_id ) ) { ! //$dropmenu = $this->generate_jumpbox( 'auth_view', 0, 0, true ); ! $dropmenu = $this->generate_jumpbox( 0, 0, array( $_GET['cat'] => 1 )); $template->set_filenames( array( 'body' => 'kb_search_body.tpl' ) ); *************** *** 638,642 **** // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 'auth_view', 0, 0, true ); } } --- 639,644 ---- // Get footer quick dropdown jumpbox // ! //$this->generate_jumpbox( 'auth_view', 0, 0, true ); ! $this->generate_jumpbox( 0, 0, array( $_GET['cat'] => 1 )); } } Index: kb_cat.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_cat.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** kb_cat.php 5 Jul 2006 22:48:26 -0000 1.6 --- kb_cat.php 1 Aug 2006 21:00:38 -0000 1.7 *************** *** 41,44 **** --- 41,91 ---- } + // + // Sorting of items + // + if ( isset( $_REQUEST['sort_method'] ) ) + { + switch ( $_REQUEST['sort_method'] ) + { + case 'Id': + $this->sort_method = 't.article_id'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + case 'Latest': + $this->sort_method = 't.article_date'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + case 'Toprated': + $this->sort_method = 'rating'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + case 'Most_popular': + $this->sort_method = 't.views'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + case 'Userrank': + $this->sort_method = 'u.user_rank'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + case 'Alphabetic': + $this->sort_method = 't.article_title'; + $this->sort_method_extra = 't.article_type' . " DESC, " ; + break; + } + } + + if ( isset( $_REQUEST['sort_order'] ) ) + { + switch ( $_REQUEST['sort_order'] ) + { + case 'ASC': + $this->sort_order = 'ASC'; + break; + case 'DESC': + $this->sort_order = 'DESC'; + break; + } + } + // ======================================================= // If user not allowed to view article listing (read) and there is no sub Category *************** *** 95,122 **** $template->set_filenames( array( 'body' => 'kb_cat_body.tpl' ) ); - // - // Pagination - // - $sql_pag = "SELECT count(article_id) AS total - FROM " . KB_ARTICLES_TABLE . " - WHERE "; - $sql_pag .= " article_category_id = '$category_id'"; - - if ( !( $result = $db->sql_query( $sql_pag ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Error getting total articles', '', __LINE__, __FILE__, $sql ); - } - - if ( $total = $db->sql_fetchrow( $result ) ) - { - $total_articles = $total['total']; - $pagination = generate_pagination( $this->this_mxurl( "mode=cat&cat=$category_id" ), $total_articles, $kb_config['pagination'], $start ) . ' '; - } - - if ( $total_articles > 0 ) - { - $template->assign_block_vars( 'pagination', array() ); - } - $template->assign_vars( array( 'PAGINATION' => $pagination, --- 142,145 ---- *************** *** 159,169 **** // Get articles // ! $this->display_articles( $start, $category_id ); ! //$this->display_articles( $category_id, '1', 'articlerow', $start, $kb_config['pagination'] ); // // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); } } --- 182,192 ---- // Get articles // ! $this->display_items( $start, $category_id ); // // Get footer quick dropdown jumpbox // ! //$this->generate_jumpbox( 'auth_view', $category_id, $category_id, true ); ! $this->generate_jumpbox( 0, 0, array( $category_id => 1 )); } } Index: kb_article.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_article.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** kb_article.php 5 Jul 2006 22:48:26 -0000 1.10 --- kb_article.php 1 Aug 2006 21:00:38 -0000 1.11 *************** *** 103,107 **** $approved = $kb_row['approved']; $date = create_date( $board_config['default_dateformat'], $kb_row['article_date'], $board_config['board_timezone'] ); ! $type = $kb_row['type']; $new_views = $kb_row['views'] + 1; --- 103,109 ---- $approved = $kb_row['approved']; $date = create_date( $board_config['default_dateformat'], $kb_row['article_date'], $board_config['board_timezone'] ); ! ! $article_type = isset($lang['KB_type_' . $kb_row['type']]) ? $lang['KB_type_' . $kb_row['type']] : $kb_row['type']; ! $new_views = $kb_row['views'] + 1; *************** *** 125,129 **** // Instantiate the mx_text and mx_text_formatting classes // - include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); $mx_text = new mx_text(); $mx_text->init($html_on, $bbcode_on, $smilies_on); // Note: allowed_html_tags is altered above --- 127,130 ---- *************** *** 220,224 **** // If this is an allowed article, go ahead and display it // ! if ( !$this->auth_user[$article_category_id]['auth_view'] || !$article_title || ( !$approved && !$this->auth_user[$article_category_id]['auth_mod'] ) || ( !$this->ns_auth_cat( $article_category_id ) && !$print_version ) ) { $message = $lang['Article_not_exsist'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $phpbb_root_path . "index.$phpEx" ) . '">', '</a>' ); --- 221,225 ---- // If this is an allowed article, go ahead and display it // ! if ( !$this->auth_user[$article_category_id]['auth_view'] || !$article_title || ( !$approved && !$this->auth_user[$article_category_id]['auth_mod'] ) ) { $message = $lang['Article_not_exsist'] . '<br /><br />' . sprintf( $lang['Click_return_kb'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_index'], '<a href="' . append_sid( $phpbb_root_path . "index.$phpEx" ) . '">', '</a>' ); *************** *** 272,276 **** 'ARTICLE_DESCRIPTION' => $article_description, 'ARTICLE_DATE' => $date, ! 'ARTICLE_TYPE' => $type, 'EDIT_IMG' => $edit_img, 'EDIT' => $edit, --- 273,277 ---- 'ARTICLE_DESCRIPTION' => $article_description, 'ARTICLE_DATE' => $date, ! 'ARTICLE_TYPE' => $article_type, 'EDIT_IMG' => $edit_img, 'EDIT' => $edit, *************** *** 361,368 **** // ! // Instantiate custom fields (only used in kb_article) // ! include_once( $module_root_path . 'kb/includes/functions_field.' . $phpEx ); ! $mx_kb_custom_field = new mx_kb_custom_field(); $mx_kb_custom_field->init(); $mx_kb_custom_field->display_data( $article_id ); --- 362,368 ---- // ! // Instantiate custom fields // ! $mx_kb_custom_field = new mx_custom_field(KB_CUSTOM_TABLE, KB_CUSTOM_DATA_TABLE); $mx_kb_custom_field->init(); $mx_kb_custom_field->display_data( $article_id ); *************** *** 373,377 **** if ( $this->ratings[$article_category_id]['activated'] ) { ! $article_rating = ( $kb_row['rating'] != 0 ) ? round( $kb_row['rating'] / $kb_row['total_votes'], 2 ) . ' / 10' : $lang['No_votes']; if ( $this->auth_user[$article_category_id]['auth_rate'] ) --- 373,377 ---- if ( $this->ratings[$article_category_id]['activated'] ) { ! $article_rating = ( $kb_row['rating'] != 0 ) ? round( $kb_row['rating'], 2 ) . '/10' : $lang['No_votes']; if ( $this->auth_user[$article_category_id]['auth_rate'] ) *************** *** 384,388 **** 'L_RATE' => $lang['Rate'], 'L_VOTES' => $lang['Votes'], ! 'FILE_VOTES' => $kb_row['article_totalvotes'], 'RATING' => $article_rating, --- 384,389 ---- 'L_RATE' => $lang['Rate'], 'L_VOTES' => $lang['Votes'], ! 'DO_RATE' => $this->auth_user[$article_category_id]['auth_rate'] ? $lang['ADD_RATING'] : '', ! 'VOTES' => $kb_row['total_votes'], 'RATING' => $article_rating, *************** *** 398,402 **** // Comments // ! if ( $this->comments[$article_category_id]['activated'] && $this->auth_user[$article_category_id]['auth_comment']) { $comments_type = $this->comments[$article_category_id]['internal_comments'] ? 'internal' : 'phpbb'; --- 399,403 ---- // Comments // ! if ( $this->comments[$article_category_id]['activated'] && $this->auth_user[$article_category_id]['auth_view_comment']) { $comments_type = $this->comments[$article_category_id]['internal_comments'] ? 'internal' : 'phpbb'; *************** *** 424,428 **** // Get footer quick dropdown jumpbox // ! $this->generate_jumpbox( 'auth_view', $article_category_id, $article_category_id, true ); } } --- 425,430 ---- // Get footer quick dropdown jumpbox // ! //$this->generate_jumpbox( 'auth_view', $article_category_id, $article_category_id, true ); ! $this->generate_jumpbox( 0, 0, array( $article_category_id => 1 )); } } Index: kb_post_comment.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/modules/kb_post_comment.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** kb_post_comment.php 5 Jul 2006 22:48:26 -0000 1.8 --- kb_post_comment.php 1 Aug 2006 21:00:38 -0000 1.9 *************** *** 66,70 **** $db->sql_freeresult( $result ); ! if ( ( !$this->auth_user[$article_data['article_category_id']]['auth_comment'] ) ) { if ( !$userdata['session_logged_in'] ) --- 66,70 ---- $db->sql_freeresult( $result ); ! if ( ( !$this->auth_user[$article_data['article_category_id']]['auth_post_comment'] ) ) { if ( !$userdata['session_logged_in'] ) *************** *** 135,139 **** // Instantiate the mx_text and mx_text_formatting classes // - include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); $mx_text = new mx_text(); $mx_text->init($html_on, $bbcode_on, $smilies_on); --- 135,138 ---- *************** *** 161,165 **** $article_info = $db->sql_fetchrow( $result ); ! if ( ( $this->auth_user[$article_info['article_category_id']]['auth_comment'] && $article_info['article_author_id'] == $userdata['user_id'] ) || $this->auth_user[$article_info['article_category_id']]['auth_mod'] ) { if ( $this->comments[$article_data['article_category_id']]['internal_comments'] ) --- 160,164 ---- $article_info = $db->sql_fetchrow( $result ); ! if ( ( $this->auth_user[$article_info['article_category_id']]['auth_delete_comment'] && $article_info['article_author_id'] == $userdata['user_id'] ) || $this->auth_user[$article_info['article_category_id']]['auth_mod'] ) { if ( $this->comments[$article_data['article_category_id']]['internal_comments'] ) *************** *** 210,214 **** // Generate smilies listing for page output // ! $mx_kb_functions->kb_generate_smilies( 'inline', PAGE_POSTING ); $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; --- 209,213 ---- // Generate smilies listing for page output // ! $mx_kb_functions->generate_smilies( 'inline', PAGE_POSTING ); $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; |