[Phpbbkb-checkins] SF.net SVN: phpbbkb: [38] root
Status: Alpha
Brought to you by:
markthedaemon
From: <so...@us...> - 2007-01-09 06:31:42
|
Revision: 38 http://svn.sourceforge.net/phpbbkb/?rev=38&view=rev Author: softphp Date: 2007-01-08 22:31:38 -0800 (Mon, 08 Jan 2007) Log Message: ----------- - Corrected various bugs Modified Paths: -------------- root/kb/constants.php root/kb/functions.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb/constants.php 2007-01-09 06:31:38 UTC (rev 38) @@ -30,4 +30,11 @@ define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access"); +// Article Status +define('KB_STATUS_NOT_ASSIGNED', 0); +define('KB_STATUS_ASSIGNED', 1); +define('KB_STATUS_REVIEW_IN_PROGRESS', 3); +define('KB_STATUS_ACCEPTED', 4); +define('KB_STATUS_REJECTED', 5); + ?> \ No newline at end of file Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb/functions.php 2007-01-09 06:31:38 UTC (rev 38) @@ -1,4 +1,4 @@ - <?php +<?php /*************************************************************************** * functions.php * ------------------- @@ -144,6 +144,32 @@ return $cats; } +function get_kb_config() +{ + // Using normal db table with kb_prefix + global $db; + + $sql = "SELECT * + FROM " . CONFIG_TABLE; + if(!$result = $db->sql_query($sql)) + { + message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql); + } + + $config = array(); + while($row = $db->fetchrow($result)) + { + // Detect if it has a kb_ in it and strip it + if(strstr('kb_', $row['config_name'])) + { + $name = str_replace("kb_", "", $row['config_name']); + $config[$name] = $row['config_value']; + } + } + + return $config; +} + //////////////////////////////////////// /// UCP FUNCTIONS /// //////////////////////////////////////// @@ -189,7 +215,7 @@ } // This is for posting articles, mostly cut out of the posting.php :) -function ucp_article_form($mode, $id, $review) +function ucp_article_form($mode, $id, $preview) { global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; @@ -207,7 +233,11 @@ if($mode == 'edit') { // Let's get the old article data - $article_id = $id; + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; + if(!$article_id) + { + message_die(MESSAGE_DIE, 'No article id defined.'); + } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " @@ -232,7 +262,7 @@ // Simple Auth for alpha 1 if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) { - message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']; + message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']); } } @@ -308,10 +338,11 @@ } $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_added'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } else { + $article_id = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : false; if(!$article_id) { message_die(GENERAL_ERROR, 'No article to edit.'); @@ -330,7 +361,8 @@ enable_html = '$html_on', enable_bbcode = '$bbcode_on', enable_smilies = '$smilies_on', - article_text = '$message';"; + article_text = '$message' + WHERE article_id = '$article_id'"; if (!$db->sql_query($sql)) { @@ -364,7 +396,7 @@ // Message here somewhere $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_edited'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); } $template->assign_vars(array( @@ -375,7 +407,6 @@ } } - $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; if($mode == "post" && !$preview && $error_msg == '') { $article_title = ''; @@ -415,6 +446,7 @@ } elseif($preview || $error_msg != '') { + $article_id = $HTTP_POST_VARS['id']; $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; $article_desc = $HTTP_POST_VARS['desc']; @@ -457,31 +489,78 @@ $preview_message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; - $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($preview_message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$html_on ) + { + $preview_message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $preview_message); + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($bbcode_uid != '') + { + $preview_message = ($bbcode_on) ? bbencode_second_pass($preview_message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $preview_message); + } + + $preview_message = make_clickable($preview_message); + + // + // Parse smilies + // + if ( $smilies_on ) + { + $preview_message = smilies_pass($preview_message); + } + + // + // Replace naughty words + // + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if (count($orig_word)) + { + $preview_article_title = preg_replace($orig_word, $replacement_word, $preview_article_title); + $preview_article_desc = preg_replace($orig_word, $replacement_word, $preview_article_desc); + $preview_message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $preview_message . '<'), 1, -1)); + } + + $preview_message = str_replace("\n", "\n<br />\n", $preview_message); + + $template->set_filenames(array( - 'preview_box' => 'kb_articlepreview.tpl') + 'preview_box' => 'kb_previewarticle.tpl') ); $template->assign_vars(array( + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_PREVIEW' => $lang['kb_articlepreview'], 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, 'MESSAGE' => $preview_message) ); - $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview'); + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview_box'); } } else { - if(empty($article_id)) + if(empty($id)) { message_die(GENERAL_ERROR, "No article defined."); } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$article_id'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); @@ -499,7 +578,7 @@ // Now make an array over the cats $sql = "SELECT cat_id FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$article_id'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); @@ -523,7 +602,7 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; } if ( $article['bbcode_uid'] != '' ) @@ -635,6 +714,7 @@ ); create_navigation("ucp", $action); + $post_article = ($mode == 'edit') ? $lang['kb_edit_article'] : $lang['kb_post_article']; // This is the template stuff we need no matter what $template->assign_vars(array( @@ -646,7 +726,7 @@ 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq." . $phpEx . "?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, - 'L_POST_ARTICLE' => $lang['kb_post_article'], + 'L_POST_ARTICLE' => $post_article, 'L_AUTHORNAME' => $lang['kb_authorname'], 'L_ARTICLE_NAME' => $lang['kb_articlename'], 'L_ARTICLE_DESC' => $lang['kb_articledesc'], @@ -723,7 +803,7 @@ // Simple auth for alpha 1 if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) { - message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']; + message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']); } if(!$confirm) @@ -770,7 +850,7 @@ // Message $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '>"'; - $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); + $return_message = $lang['kb_deleted'] . '<br /><br />' . sprintf($lang['kb_click_view_article'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=view_article&id=' . $article_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['kb_click_return_ucp'], '<a href="' . append_sid('kb.' . $phpEx . '?pid=ucp') . '">', '</a>'); $template->assign_vars(array( 'META' => $meta) Modified: root/kb.php =================================================================== --- root/kb.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb.php 2007-01-09 06:31:38 UTC (rev 38) @@ -363,7 +363,7 @@ case "view_article": $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; - $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + $id = ( empty($HTTP_GET_VARS['id']) ) ? false : $HTTP_GET_VARS['id']; // Get naughty words :) $orig_word = array(); @@ -482,6 +482,7 @@ if (count($orig_word)) { $article_title = preg_replace($orig_word, $replacement_word, $article_title); + $article_desc = preg_replace($orig_word, $replacement_word, $article_desc); if ($user_sig != '') { Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/kb_install.php 2007-01-09 06:31:38 UTC (rev 38) @@ -79,7 +79,7 @@ article_hits mediumint(8) UNSIGNED DEFAULT '0', article_editby mediumint(8) UNSIGNED DEFAULT '0', article_status smallint(1) UNSIGNED DEFAULT '0', - bbcode_uid varcharr(10) NOT NULL, + bbcode_uid varchar(10) NOT NULL, enable_sig smallint(1) UNSIGNED DEFAULT '0', enable_html smallint(1) UNSIGNED DEFAULT '0', enable_bbcode smallint(1) UNSIGNED DEFAULT '0', Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2007-01-07 22:19:22 UTC (rev 37) +++ root/language/lang_english/lang_kb.php 2007-01-09 06:31:38 UTC (rev 38) @@ -41,6 +41,7 @@ // Posting Page $lang['kb_post_article'] = "Post New Article"; +$lang['kb_edit_article'] = "Edit Article"; $lang['kb_authorname'] = "Author Name"; $lang['kb_authorname_desc'] = "This is the name that will be displayed, just leave your username there if you want, but you might wanted to change it."; $lang['kb_articlename'] = "Article Name"; @@ -56,10 +57,11 @@ $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; $lang['kb_deleted'] = "Your article has been deleted and is now nonexistant."; $lang['kb_edited'] = "Your article has been edited and is awaiting reapproval."; -$lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. -$lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; +$lang['kb_click_view_article'] = "Click %shere%s to view you article."; // Change this later on, they can't view the article yet. +$lang['kb_click_return_ucp'] = "Click %shere%s to go back to the user control panel"; $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; $lang['kb_confirm_deletearticle'] = "Are you sure you want to delete this article?"; +$lang['kb_articlepreview'] = "Article Preview"; // Auth $lang['kb_edit_noauth'] = "You are not allowed to edit this article."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |