Thread: [Phpbbkb-checkins] SF.net SVN: phpbbkb: [9] root
Status: Alpha
Brought to you by:
markthedaemon
From: <mar...@us...> - 2006-10-14 02:56:39
|
Revision: 9 http://svn.sourceforge.net/phpbbkb/?rev=9&view=rev Author: markthedaemon Date: 2006-10-13 19:56:33 -0700 (Fri, 13 Oct 2006) Log Message: ----------- Added the initial commit of the install file. Obviously more queries to add to this. TODO: Change header; add queries; fix bugs. It's 4am and i've probably missed something really important out. Forgive me :P Added Paths: ----------- root/install/ root/install/kb_install.php Added: root/install/kb_install.php =================================================================== --- root/install/kb_install.php (rev 0) +++ root/install/kb_install.php 2006-10-14 02:56:33 UTC (rev 9) @@ -0,0 +1,84 @@ +<?php +/*************************************************************************** + * kb_install.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +define('IN_PHPBB', true); +$phpbb_root_path = './../'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'common.'.$phpEx); + +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_INDEX); +init_userprefs($userdata); +// +// End session management +// + + +if( !$userdata['session_logged_in'] ) +{ + $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; + header($header_location . append_sid("login.$phpEx?redirect=phpbb_sql_generator.$phpEx", true)); + exit; +} + +if( $userdata['user_level'] != ADMIN ) +{ + message_die(GENERAL_MESSAGE, 'You are not authorised to access this page'); +} + + +$page_title = 'Updating the database'; +include($phpbb_root_path . 'includes/page_header.'.$phpEx); + +echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; +echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">'; + + +$sql = array(); +$sql[] = "ALTER TABLE " . $table_prefix . "forums ADD cat_kb tinyint(1) unsigned default 0"; + +for( $i = 0; $i < count($sql); $i++ ) +{ + if( !$result = $db->sql_query ($sql[$i]) ) + { + $error = $db->sql_error(); + + echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />'; + } + else + { + echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successfull</b></font></li><br />'; + } +} + + +echo '</ul></span></td></tr><tr><td class="catBottom" height="28"> </td></tr>'; + +echo '<tr><th>End</th></tr><tr><td><span class="genmed">Installation is now finished. '; +echo 'Please be sure to delete this file now.<br />'; +echo 'If you have run into any errors, please visit the '. + '<a href="http://www.phpbbknowledgebase.com" target="_blank">phpBB Knowledge Base Forums</a> or the <a href="http://www.phpbb.com/phpBB/viewtopic.php?t=415458" target="_blank">phpBB.com topic</a> and ask someone for help.</span></td></tr>'; +echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Have a nice day, and thanks for using the phpBB Knowledge Base MODification!</a></span></td></table>'; + +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-21 15:00:57
|
Revision: 18 http://svn.sourceforge.net/phpbbkb/?rev=18&view=rev Author: softphp Date: 2006-11-21 07:00:56 -0800 (Tue, 21 Nov 2006) Log Message: ----------- - Added loads of new files. In kb.php the main site works as it is now, look at kb.softphp.dk/kb.php for example. Added Paths: ----------- root/kb/ root/kb/constants.php root/kb/functions.php root/kb.php root/language/ root/language/lang_english/ root/language/lang_english/lang_kb.php root/templates/ root/templates/subSilver/ root/templates/subSilver/kb_main.tpl Added: root/kb/constants.php =================================================================== --- root/kb/constants.php (rev 0) +++ root/kb/constants.php 2006-11-21 15:00:56 UTC (rev 18) @@ -0,0 +1,26 @@ +<?php +/*************************************************************************** + * lang_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +// All constants here +// DB Tables +define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); +define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); + +?> \ No newline at end of file Added: root/kb/functions.php =================================================================== --- root/kb/functions.php (rev 0) +++ root/kb/functions.php 2006-11-21 15:00:56 UTC (rev 18) @@ -0,0 +1,23 @@ +<?php +/*************************************************************************** + * functions.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +// Nothing yet! + +?> \ No newline at end of file Added: root/kb.php =================================================================== --- root/kb.php (rev 0) +++ root/kb.php 2006-11-21 15:00:56 UTC (rev 18) @@ -0,0 +1,163 @@ +<?php +/*************************************************************************** + * kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ +define('IN_PHPBB', true); +$phpbb_root_path = './'; +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'common.' . $phpEx); +include($phpbb_root_path . 'kb/constants.' . $phpEx); // Added these two files, yes i could just add the 10-15 lines it will end with in +include($phpbb_root_path . 'kb/functions.' . $phpEx); // the existing files, but this makes it a lot easier to install/uninstall. + +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_INDEX); +init_userprefs($userdata); +// +// End session management +// + +// File takes care of the following action set via $pid ($HTTP_GET_VARS['pid']): +// main - views categories, with subcategories listed +// view_cat - views a category, either lists subcategories or articles contained, or both ofc. +// view_article - views an article +// ucp - My idea of this is that it should be the complete possibility for users here. If they are normal users, they can see their own +// articles and if they get approved or not. They can also view their comments, and wether they are approved or not. This should +// also include mod options for admins. Approving/disapproving comments or articles, editing them, so on... +// search - the kb search engine... +// More will come whenever i figure something out. Now i'll start coding. :D // Imladris +include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_kb.' . $phpEx); +$pid = ( isset($HTTP_GET_VARS['pid']) ) ? $HTTP_GET_VARS['pid'] : "main"; + +// Making sure the install file has been removed +if(file_exists($phpbb_root_path . "kb_install." . $phpEx)) +{ + message_die(GENERAL_MESSAGE, $lang['kb_remove_installfile']); +} + +switch($pid) +{ + case "main": + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '0' + ORDER BY c.cat_order"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); + } + + $catrows = array(); + while ($row = $db->sql_fetchrow($result)) + { + $catrows[] = $row; + } + + // Start Page output + $page_title = $lang['kb_main']; + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'body' => 'kb_main.tpl') + ); + + $template->assign_vars(array( + 'L_CATEGORIES' => $lang['kb_categories'], + 'L_ARTICLES' => $lang['kb_articles']) + ); + + if($total_catrows = count($catrows)) + { + for($i = 0; $i < $total_catrows; $i++) + { + // Ok display one cat here + $template->assign_block_vars('catrow', array( + 'CAT_TITLE' => $catrows[$i]['cat_title'], + 'CAT_DESC' => $catrows[$i]['cat_desc'], + 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'L_SUBCATS' => $lang['kb_subcats'], + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); + + // Now let's look at subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' + ORDER BY c.cat_order"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while ($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; + } + + if($total_subcats = count($subcats)) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcats', array()); + + for($j = 0; $j < $total_subcats; $j++) + { + // Show the subcat + $k = $j + 1; + $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; + $template->assign_block_vars('catrow.subcatrow', array( + 'U_SUBCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], + 'SUBCAT_COMMA' => $subcat_comma) + ); + } + } + } + } + else + { + message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + } + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); + break; + + case "view_cat": + break; + + case "view_article": + break; + + case "ucp": + break; + + case "search": + break; + + default: + message_die(GENERAL_MESSAGE, 'Wrong page id defined. No page shown.'); + break; +} +?> \ No newline at end of file Added: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php (rev 0) +++ root/language/lang_english/lang_kb.php 2006-11-21 15:00:56 UTC (rev 18) @@ -0,0 +1,29 @@ +<?php +/*************************************************************************** + * lang_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +// Page titles +$lang['kb_main'] = "KnowledgeBase Home"; + +$lang['kb_categories'] = "KnowledgeBase Categories"; +$lang['kb_articles'] = "Articles"; +$lang['kb_subcats'] = "Subcategories"; +$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. KnowledgeBase won't work before that has been done!"; +$lang['No_kb_cats'] = "No knowledgebase categories has been added."; +?> \ No newline at end of file Added: root/templates/subSilver/kb_main.tpl =================================================================== --- root/templates/subSilver/kb_main.tpl (rev 0) +++ root/templates/subSilver/kb_main.tpl 2006-11-21 15:00:56 UTC (rev 18) @@ -0,0 +1,33 @@ +<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> + <tr> + <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_CATEGORIES} </th> + <th class="thCornerR" nowrap="nowrap"> {L_ARTICLES} </th> + </tr> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle"> </span></td> + <td class="rowpic" align="right"> </td> + </tr> + <!-- BEGIN catrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> + <td class="row1" width="100%" height="50"><span class="forumlink"> <a href="{catrow.U_VIEWCAT}" class="forumlink">{catrow.CAT_TITLE}</a><br /> + </span> <span class="genmed">{catrow.CAT_DESC}<br /> + </span><span class="gensmall"> + <!-- BEGIN switch_subcats --> + {catrow.L_SUBCATS}: + <!-- END switch_subcats --> + <!-- BEGIN subcatrow --> + <a href="{catrow.subcatrow.U_SUBCAT}" title="{catrow.subcatrow.SUBCAT_TITLE}">{catrow.subcatrow.SUBCAT_TITLE}</a>{catrow.subcatrow.SUBCAT_COMMA} + <!-- END subcatrow --> + </span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.CAT_ARTICLES}</span></td> + </tr> + <!-- END catrow --> +</table> + +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left"> </td> + <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> + </tr> +</table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-21 19:57:08
|
Revision: 19 http://svn.sourceforge.net/phpbbkb/?rev=19&view=rev Author: softphp Date: 2006-11-21 11:57:07 -0800 (Tue, 21 Nov 2006) Log Message: ----------- - Added possibility for viewing cats, updated the articles table and added a new template file. Modified Paths: -------------- root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php root/templates/subSilver/kb_main.tpl Added Paths: ----------- root/templates/subSilver/kb_viewcat.tpl Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-21 15:00:56 UTC (rev 18) +++ root/kb.php 2006-11-21 19:57:07 UTC (rev 19) @@ -145,6 +145,173 @@ break; case "view_cat": + $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; + if(!$cat_id) + { + message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); + } + + // Store the main cat in a variable + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $cat_id . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query the main category', '', __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + // Let's find subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '$cat_id' + ORDER BY c.cat_order"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; + } + + // Now articles, the LIKE handles multiple cats + // First handle the sorting + // default is by edit time, other options: -rating, -author, -title + if(isset($HTTP_GET_VARS['sort'])) + { + switch($HTTP_GET_VARS['sort']) + { + case "rating": + // Later + $sort = "ORDER BY article_edittime DESC"; + break; + + case "author": + // Later + $sort = "ORDER BY article_edittime DESC"; + break; + + case "title": + $sort = "ORDER BY article_title"; + break; + + case "time": + default: + $sort = "ORDER BY article_edittime DESC"; + break; + } + } + else + { + $sort = "ORDER BY article_edittime DESC"; + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE cat_id LIKE '$cat_id' + $sort"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql); + } + + $articles = array(); + while($row = $db->sql_fetchrow($result)) + { + $articles[] = $row; + } + + // Start Page output + $page_title = $lang['kb_viewcat'] . ": " . $cat['cat_title']; + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'body' => 'kb_viewcat.tpl') + ); + + // Process the whole thing + $template->assign_vars(array( + 'L_VIEWS' => $lang['Views'], + 'L_AUTHOR' => $lang['Author'], + 'L_ARTICLES' => $lang['kb_articles'], + 'L_SUBCATS' => sprintf($lang['kb_viewcat_subcats'], $cat['cat_title']), + 'L_LAST_ACTION' => $lang['kb_last_action']) + ); + + if( $total_subcats = count($subcats) ) + { + $template->assign_block_vars('switch_subcats', array()); + + // Ok it contains subcats, let's build them. + for($i = 0; $i < $total_subcats; $i++) + { + // Ok display one cat here + $template->assign_block_vars('switch_subcats.catrow', array( + 'CAT_TITLE' => $subcats[$i]['cat_title'], + 'CAT_DESC' => $subcats[$i]['cat_desc'], + 'CAT_ARTICLES' => $subcats[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$i]['cat_id']), + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); + } + } + + if( $total_articles = count($articles) ) + { + // Contains articles + for($i = 0; $i < $total_articles; $i++) + { + if($articles[$i]['article_authorname'] == "") + { + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE user_id = '" . $articles[$i]['article_author']; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query authorname', '', __LINE__, __FILE__, $sql); + } + + $user = $db->sql_fetchrow($result); + $authorname = $user['username']; + } + else + { + $authorname = $articles[$i]['article_authorname']; + } + $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE user_id = '" . $articles[$i]['article_editby']; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query last edited by\'s username.', '', __LINE__, __FILE__, $sql); + } + + $user = $db->sql_fetchrow($result); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + + $template->assign_block_vars('articlerow', array( + 'TOPIC_FOLDER_IMG' => $images['folder'], + 'ARTICLE_TITLE' => $articles[$i]['article_title'], + 'ARTICLE_DESC' => $articles[$i]['article_desc'], + 'ARTICLE_AUTHOR' => $author, + 'ARTICLE_HITS' => $articles[$i]['article_hits'], + 'ARTICLE_LAST_ACTION' => $last_action, + 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&id=" . $articles[$i]['article_id'])) + ); + } + } + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; case "view_article": @@ -156,6 +323,10 @@ case "search": break; + case "comment": + // For Adding, deleting and editing comments, this includes rating. + break; + default: message_die(GENERAL_MESSAGE, 'Wrong page id defined. No page shown.'); break; Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-21 15:00:56 UTC (rev 18) +++ root/kb_install.php 2006-11-21 19:57:07 UTC (rev 19) @@ -64,6 +64,13 @@ article_id mediumint(8) UNSIGNED NOT NULL auto_increment, cat_id mediumint(8) UNSIGNED DEFAULT '0', article_title varchar(100) NOT NULL, + article_desc varchar(255) NOT NULL, + article_author mediumint(8) UNSIGNED NOT NULL, + article_authorname varchar(50) NOT NULL, + article_edittime int(20) UNSIGNED DEFAULT '0', + article_hits mediumint(8) UNSIGNED DEFAULT '0', + article_editby mediumint(8) UNSIGNED DEFAULT '0', + article_status smallint(1) UNSIGNED DEFAULT '0', article_text text, PRIMARY KEY (article_id), KEY cat_id (cat_id) Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-21 15:00:56 UTC (rev 18) +++ root/language/lang_english/lang_kb.php 2006-11-21 19:57:07 UTC (rev 19) @@ -26,4 +26,8 @@ $lang['kb_subcats'] = "Subcategories"; $lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. KnowledgeBase won't work before that has been done!"; $lang['No_kb_cats'] = "No knowledgebase categories has been added."; + +$lang['kb_viewcat_subcats'] = "Subcategories in %s"; +$lang['kb_last_action'] = "Last action"; +$lang['kb_last_action_row'] = "Last action for this article was comitted by %s on the %s"; ?> \ No newline at end of file Modified: root/templates/subSilver/kb_main.tpl =================================================================== --- root/templates/subSilver/kb_main.tpl 2006-11-21 15:00:56 UTC (rev 18) +++ root/templates/subSilver/kb_main.tpl 2006-11-21 19:57:07 UTC (rev 19) @@ -23,6 +23,9 @@ <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.CAT_ARTICLES}</span></td> </tr> <!-- END catrow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="3" height="28"> </td> + </tr> </table> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> Added: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl (rev 0) +++ root/templates/subSilver/kb_viewcat.tpl 2006-11-21 19:57:07 UTC (rev 19) @@ -0,0 +1,51 @@ +<!-- BEGIN switch_subcats --> +<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> + <tr> + <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_SUBCATS} </th> + <th class="thCornerR" nowrap="nowrap"> {L_ARTICLES} </th> + </tr> + <!-- BEGIN catrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{switch_subcats.catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> + <td class="row1" width="100%" height="50"><span class="forumlink"> <a href="{switch_subcats.catrow.U_VIEWCAT}" class="forumlink">{switch_subcats.catrow.CAT_TITLE}</a></span><br /> + <span class="gensmall">{switch_subcats.catrow.CAT_DESC}</span><br /> + </td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{switch_subcats.catrow.CAT_ARTICLES}</span></td> + </tr> + <!-- END catrow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td> + </tr> +</table> +<!-- END switch_subcats --> +<br /> +<!-- BEGIN switch_articles --> +<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline"> + <tr> + <th colspan="2" align="center" height="25" class="thCornerL" nowrap="nowrap"> {L_ARTICLES} </th> + <th width="100" align="center" class="thTop" nowrap="nowrap"> {L_AUTHOR} </th> + <th width="50" align="center" class="thTop" nowrap="nowrap"> {L_VIEWS} </th> + <th align="center" class="thCornerR" nowrap="nowrap"> {L_LAST_ACTION} </th> + </tr> + <!-- BEGIN articlerow --> + <tr> + <td class="row1" align="center" valign="middle" width="20"><img src="{articlerow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row1" width="100%"><span class="topictitle"><a href="{articlerow.U_VIEW_ARTICLE}" class="topictitle">{articlerow.ARTICLE_TITLE}</a></span><span class="gensmall"><br /> + {articlerow.ARTICLE_DESC}</span></td> + <td class="row3" align="center" valign="middle"><span class="name">{articlerow.ARTICLE_AUTHOR}</span></td> + <td class="row2" align="center" valign="middle"><span class="postdetails">{articlerow.ARTICLE_HITS}</span></td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{articlerow.ARTICLE_LAST_ACTION}</span></td> + </tr> + <!-- END articlerow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td> + </tr> +</table> +<!-- END switch_articles --> + +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left"> </td> + <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> + </tr> +</table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-23 15:32:41
|
Revision: 20 http://svn.sourceforge.net/phpbbkb/?rev=20&view=rev Author: softphp Date: 2006-11-23 07:32:31 -0800 (Thu, 23 Nov 2006) Log Message: ----------- - Adding all sorts of stuff, generally navigation bar & the new ucp class... for adding an editing articles. Modified Paths: -------------- root/kb/functions.php root/kb.php root/language/lang_english/lang_kb.php root/templates/subSilver/kb_main.tpl root/templates/subSilver/kb_viewcat.tpl Added Paths: ----------- root/kb/ucp_class.php root/templates/subSilver/kb_article_posting.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-21 19:57:07 UTC (rev 19) +++ root/kb/functions.php 2006-11-23 15:32:31 UTC (rev 20) @@ -3,9 +3,9 @@ * functions.php * ------------------- * - * copyright: phpBB KB Group - * site: http://www.phpbbknowledgebase.com - * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb * ***************************************************************************/ @@ -18,6 +18,55 @@ * ***************************************************************************/ -// Nothing yet! - +// This function creates the navigation line based on a few parameters +function create_navigation($type = "main", $id_ary = array()) +{ + global $db, $template, $lang, $board_config, $phpEx; + + switch($type) + { + case "ucp": + // Different kind of subcategories + break; + + case "viewcat": + // View category + // id = $cat_id::$cat_name + $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + break; + + case "viewsubcat": + // View subcategory + // id = $cat_id::$cat_name::$maincat_id + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid("kb.$phpEx?pid=view_cat&id=" . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + break; + + case "viewarticle": + // Viewing an article + break; + + case "search": + // viewing search results or page + break; + + case "main": + default: + $navigation = '<span class="nav"> <a href="' . append_sid("kb.$phpEx") . '" class="nav">' . $lang['kb_main'] . '</a></span>'; + break; + } + + $template->assign_vars(array( + 'NAVIGATION' => $navigation) + ); + + return; +} ?> \ No newline at end of file Added: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php (rev 0) +++ root/kb/ucp_class.php 2006-11-23 15:32:31 UTC (rev 20) @@ -0,0 +1,230 @@ +<?php +/*************************************************************************** + * ucp_class.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +// This contains the entire ucp class, so it's seperated from the rest of kb.php +class ucp +{ + var $action = ""; + + function __construct($action, $id=0) + { + global $HTTP_POST_VARS['review']; + + $this->action = $action; + switch($this->action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + $this->article_form("post", false, $HTTP_POST_VARS['review']); + break; + + case "edit_article": + $this->article_form("edit", $id, $HTTP_POST_VARS['review']); + break; + + case "delete_article": + $this->article_delete(); + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + } + + // This is for posting articles, mostly cut out of the posting.php :) + function article_form($mode, $id, $review) + { + global $template, $board_config, $db, $userdata; + + if($mode == "post") + { + $article_title = ''; + $article_text = ''; + $article_desc = ''; + $authorname = $userdata['username']; + } + else + { + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE id = '" . $id . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); + } + $article = $db->sql_fetchrow($result); + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_desc = $article['article_desc']; + $authorname = $article['article_authorname']; + + $attach_sig = ( $article['enable_sig'] && $post_info['user_sig'] != '' ) ? TRUE : 0; + $user_sig = $userdata['user_sig']; + + $html_on = ( $article['enable_html'] ) ? true : false; + $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; + $smilies_on = ( $article['enable_smilies'] ) ? true : false; + } + + $article_text = str_replace('<', '<', $article_text); + $article_text = str_replace('>', '>', $article_text); + $article_text = str_replace('<br />', "\n", $article_text); + + // + // Signature toggle selection + // + if( $user_sig != '' ) + { + $template->assign_block_vars('switch_signature_checkbox', array()); + } + + // + // HTML toggle selection + // + if ( $board_config['allow_html'] ) + { + $html_status = $lang['HTML_is_ON']; + $template->assign_block_vars('switch_html_checkbox', array()); + } + else + { + $html_status = $lang['HTML_is_OFF']; + } + + // + // BBCode toggle selection + // + if ( $board_config['allow_bbcode'] ) + { + $bbcode_status = $lang['BBCode_is_ON']; + $template->assign_block_vars('switch_bbcode_checkbox', array()); + } + else + { + $bbcode_status = $lang['BBCode_is_OFF']; + } + + // + // Smilies toggle selection + // + if ( $board_config['allow_smilies'] ) + { + $smilies_status = $lang['Smilies_are_ON']; + $template->assign_block_vars('switch_smilies_checkbox', array()); + } + else + { + $smilies_status = $lang['Smilies_are_OFF']; + } + + // This is the template stuff we need no matter what + $template->assign_vars(array( + 'AUTHORNAME' => $authorname, + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE' => $article_text, + 'HTML_STATUS' => $html_status, + 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + 'SMILIES_STATUS' => $smilies_status, + + 'L_SUBJECT' => $lang['Subject'], + 'L_MESSAGE_BODY' => $lang['Message_body'], + 'L_OPTIONS' => $lang['Options'], + 'L_PREVIEW' => $lang['Preview'], + 'L_SPELLCHECK' => $lang['Spellcheck'], + 'L_SUBMIT' => $lang['Submit'], + 'L_CANCEL' => $lang['Cancel'], + 'L_CONFIRM_DELETE' => $lang['Confirm_delete'], + 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], + 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], + 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], + 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], + + 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], + 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], + 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], + 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], + 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], + 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], + 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], + 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], + 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], + 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], + 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], + 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], + 'L_EMPTY_MESSAGE' => $lang['Empty_message'], + + 'L_FONT_COLOR' => $lang['Font_color'], + 'L_COLOR_DEFAULT' => $lang['color_default'], + 'L_COLOR_DARK_RED' => $lang['color_dark_red'], + 'L_COLOR_RED' => $lang['color_red'], + 'L_COLOR_ORANGE' => $lang['color_orange'], + 'L_COLOR_BROWN' => $lang['color_brown'], + 'L_COLOR_YELLOW' => $lang['color_yellow'], + 'L_COLOR_GREEN' => $lang['color_green'], + 'L_COLOR_OLIVE' => $lang['color_olive'], + 'L_COLOR_CYAN' => $lang['color_cyan'], + 'L_COLOR_BLUE' => $lang['color_blue'], + 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], + 'L_COLOR_INDIGO' => $lang['color_indigo'], + 'L_COLOR_VIOLET' => $lang['color_violet'], + 'L_COLOR_WHITE' => $lang['color_white'], + 'L_COLOR_BLACK' => $lang['color_black'], + + 'L_FONT_SIZE' => $lang['Font_size'], + 'L_FONT_TINY' => $lang['font_tiny'], + 'L_FONT_SMALL' => $lang['font_small'], + 'L_FONT_NORMAL' => $lang['font_normal'], + 'L_FONT_LARGE' => $lang['font_large'], + 'L_FONT_HUGE' => $lang['font_huge'], + + 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], + 'L_STYLES_TIP' => $lang['Styles_tip'], + + 'U_VIEWTOPIC' => ( $mode == 'reply' ) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postorder=desc") : '', + 'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? append_sid("kb.$phpEx?preview=topicreview&" . POST_TOPIC_URL . "=$topic_id") : '', + + 'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', + 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', + 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', + 'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', + 'S_NOTIFY_CHECKED' => ( $notify_user ) ? 'checked="checked"' : '', + 'S_TYPE_TOGGLE' => $topic_type_toggle, + 'S_TOPIC_ID' => $topic_id, + 'S_POST_ACTION' => append_sid("posting.$phpEx"), + 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) + ); + } +} +?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-21 19:57:07 UTC (rev 19) +++ root/kb.php 2006-11-23 15:32:31 UTC (rev 20) @@ -72,6 +72,7 @@ // Start Page output $page_title = $lang['kb_main']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); + create_navigation(); $template->set_filenames(array( 'body' => 'kb_main.tpl') @@ -227,7 +228,23 @@ // Start Page output $page_title = $lang['kb_viewcat'] . ": " . $cat['cat_title']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); - + + if($cat['cat_main'] == "0") + { + create_navigation("viewcat", array( + 0 => $cat['cat_id'], + 1 => $cat['cat_title']) + ); + } + else + { + create_navigation("viewsubcat", array( + 0 => $cat_id, + 1 => $cat['cat_title'], + 2 => $cat['cat_main']) + ); + } + $template->set_filenames(array( 'body' => 'kb_viewcat.tpl') ); @@ -261,6 +278,8 @@ if( $total_articles = count($articles) ) { + $template->assign_block_vars('switch_articles', array()); + // Contains articles for($i = 0; $i < $total_articles; $i++) { @@ -294,14 +313,14 @@ $user = $db->sql_fetchrow($result); $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); - $template->assign_block_vars('articlerow', array( + $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], 'ARTICLE_TITLE' => $articles[$i]['article_title'], 'ARTICLE_DESC' => $articles[$i]['article_desc'], 'ARTICLE_AUTHOR' => $author, 'ARTICLE_HITS' => $articles[$i]['article_hits'], 'ARTICLE_LAST_ACTION' => $last_action, - 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&id=" . $articles[$i]['article_id'])) + 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) ); } } @@ -318,6 +337,15 @@ break; case "ucp": + $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; + $ucp = new ucp($action); + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; case "search": Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-21 19:57:07 UTC (rev 19) +++ root/language/lang_english/lang_kb.php 2006-11-23 15:32:31 UTC (rev 20) @@ -20,6 +20,7 @@ // Page titles $lang['kb_main'] = "KnowledgeBase Home"; +$lang['kb_viewcat'] = "Viewing Category"; $lang['kb_categories'] = "KnowledgeBase Categories"; $lang['kb_articles'] = "Articles"; Added: root/templates/subSilver/kb_article_posting.tpl =================================================================== --- root/templates/subSilver/kb_article_posting.tpl (rev 0) +++ root/templates/subSilver/kb_article_posting.tpl 2006-11-23 15:32:31 UTC (rev 20) @@ -0,0 +1,430 @@ +<script language="JavaScript" type="text/javascript"> +<!-- +// bbCode control by +// subBlue design +// www.subBlue.com + +// Startup variables +var imageTag = false; +var theSelection = false; + +// Check for Browser & Platform for PC & IE specific bits +// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html +var clientPC = navigator.userAgent.toLowerCase(); // Get client info +var clientVer = parseInt(navigator.appVersion); // Get browser version + +var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1)); +var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) + && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) + && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1)); +var is_moz = 0; + +var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); +var is_mac = (clientPC.indexOf("mac")!=-1); + +// Helpline messages +b_help = "{L_BBCODE_B_HELP}"; +i_help = "{L_BBCODE_I_HELP}"; +u_help = "{L_BBCODE_U_HELP}"; +q_help = "{L_BBCODE_Q_HELP}"; +c_help = "{L_BBCODE_C_HELP}"; +l_help = "{L_BBCODE_L_HELP}"; +o_help = "{L_BBCODE_O_HELP}"; +p_help = "{L_BBCODE_P_HELP}"; +w_help = "{L_BBCODE_W_HELP}"; +a_help = "{L_BBCODE_A_HELP}"; +s_help = "{L_BBCODE_S_HELP}"; +f_help = "{L_BBCODE_F_HELP}"; + +// Define the bbCode tags +bbcode = new Array(); +bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]'); +imageTag = false; + +// Shows the help messages in the helpline window +function helpline(help) { + document.post.helpbox.value = eval(help + "_help"); +} + + +// Replacement for arrayname.length property +function getarraysize(thearray) { + for (i = 0; i < thearray.length; i++) { + if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null)) + return i; + } + return thearray.length; +} + +// Replacement for arrayname.push(value) not implemented in IE until version 5.5 +// Appends element to the array +function arraypush(thearray,value) { + thearray[ getarraysize(thearray) ] = value; +} + +// Replacement for arrayname.pop() not implemented in IE until version 5.5 +// Removes and returns the last element of an array +function arraypop(thearray) { + thearraysize = getarraysize(thearray); + retval = thearray[thearraysize - 1]; + delete thearray[thearraysize - 1]; + return retval; +} + + +function checkForm() { + + formErrors = false; + + if (document.post.message.value.length < 2) { + formErrors = "{L_EMPTY_MESSAGE}"; + } + + if (formErrors) { + alert(formErrors); + return false; + } else { + bbstyle(-1); + //formObj.preview.disabled = true; + //formObj.submit.disabled = true; + return true; + } +} + +function emoticon(text) { + var txtarea = document.post.message; + text = ' ' + text + ' '; + if (txtarea.createTextRange && txtarea.caretPos) { + var caretPos = txtarea.caretPos; + caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; + txtarea.focus(); + } else { + txtarea.value += text; + txtarea.focus(); + } +} + +function bbfontstyle(bbopen, bbclose) { + var txtarea = document.post.message; + + if ((clientVer >= 4) && is_ie && is_win) { + theSelection = document.selection.createRange().text; + if (!theSelection) { + txtarea.value += bbopen + bbclose; + txtarea.focus(); + return; + } + document.selection.createRange().text = bbopen + theSelection + bbclose; + txtarea.focus(); + return; + } + else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) + { + mozWrap(txtarea, bbopen, bbclose); + return; + } + else + { + txtarea.value += bbopen + bbclose; + txtarea.focus(); + } + storeCaret(txtarea); +} + + +function bbstyle(bbnumber) { + var txtarea = document.post.message; + + txtarea.focus(); + donotinsert = false; + theSelection = false; + bblast = 0; + + if (bbnumber == -1) { // Close all open tags & default button names + while (bbcode[0]) { + butnumber = arraypop(bbcode) - 1; + txtarea.value += bbtags[butnumber + 1]; + buttext = eval('document.post.addbbcode' + butnumber + '.value'); + eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); + } + imageTag = false; // All tags are closed including image tags :D + txtarea.focus(); + return; + } + + if ((clientVer >= 4) && is_ie && is_win) + { + theSelection = document.selection.createRange().text; // Get text selection + if (theSelection) { + // Add tags around selection + document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; + txtarea.focus(); + theSelection = ''; + return; + } + } + else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) + { + mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]); + return; + } + + // Find last occurance of an open tag the same as the one just clicked + for (i = 0; i < bbcode.length; i++) { + if (bbcode[i] == bbnumber+1) { + bblast = i; + donotinsert = true; + } + } + + if (donotinsert) { // Close all open tags up to the one just clicked & default button names + while (bbcode[bblast]) { + butnumber = arraypop(bbcode) - 1; + txtarea.value += bbtags[butnumber + 1]; + buttext = eval('document.post.addbbcode' + butnumber + '.value'); + eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); + imageTag = false; + } + txtarea.focus(); + return; + } else { // Open tags + + if (imageTag && (bbnumber != 14)) { // Close image tag before adding another + txtarea.value += bbtags[15]; + lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list + document.post.addbbcode14.value = "Img"; // Return button back to normal state + imageTag = false; + } + + // Open tag + txtarea.value += bbtags[bbnumber]; + if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag + arraypush(bbcode,bbnumber+1); + eval('document.post.addbbcode'+bbnumber+'.value += "*"'); + txtarea.focus(); + return; + } + storeCaret(txtarea); +} + +// From http://www.massless.org/mozedit/ +function mozWrap(txtarea, open, close) +{ + var selLength = txtarea.textLength; + var selStart = txtarea.selectionStart; + var selEnd = txtarea.selectionEnd; + if (selEnd == 1 || selEnd == 2) + selEnd = selLength; + + var s1 = (txtarea.value).substring(0,selStart); + var s2 = (txtarea.value).substring(selStart, selEnd) + var s3 = (txtarea.value).substring(selEnd, selLength); + txtarea.value = s1 + open + s2 + close + s3; + return; +} + +// Insert at Claret position. Code from +// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 +function storeCaret(textEl) { + if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); +} + +//--> +</script> +<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)"> + +{ARTICLE_PREVIEW_BOX} +{ERROR_BOX} + + <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center"> + <tr> + <td align="left">{NAVIGATION}</td> + </tr> +</table> + +<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline"> + <tr> + <th class="thHead" colspan="2" height="25"><b>{L_POST_ARTICLE}</b></th> + </tr> + <tr> + <td class="row1"><span class="gen"><b>{L_AUTHORNAME}</b></span></td> + <td class="row2"><span class="genmed"><input type="text" class="post" tabindex="1" name="username" size="25" maxlength="25" value="{AUTHORNAME}" /> + </span></td> + </tr> + <tr> + <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_NAME}</b></span></td> + <td class="row2" width="78%"> <span class="gen"> + <input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{ARTICLE_TITLE}" /> + </span> </td> + </tr> + <tr> + <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_DESC}</b></span></td> + <td class="row2" width="78%"> <span class="gen"> + <textarea name="desc" cols="35" rows="5" wrap="virtual" class="post" id="desc" style="width:450px" tabindex="2">{DESC}</textarea> + </span> </td> + </tr> + <tr> + <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_CATS}</b></span></td> + <td class="row2" width="78%"><select name="cats" size="4" multiple="multiple" id="cats">{CATS_HTML} + </select> + </td> + </tr> + <tr> + <td class="row1" valign="top"> + <table width="100%" border="0" cellspacing="0" cellpadding="1"> + <tr> + <td><span class="gen"><b>{L_ARTICLE_BODY}</b></span> </td> + </tr> + <tr> + <td valign="middle" align="center"> <br /> + <table width="100" border="0" cellspacing="0" cellpadding="5"> + <tr align="center"> + <td colspan="{S_SMILIES_COLSPAN}" class="gensmall"><b>{L_EMOTICONS}</b></td> + </tr> + <!-- BEGIN smilies_row --> + <tr align="center" valign="middle"> + <!-- BEGIN smilies_col --> + <td><a href="javascript:emoticon('{smilies_row.smilies_col.SMILEY_CODE}')"><img src="{smilies_row.smilies_col.SMILEY_IMG}" border="0" alt="{smilies_row.smilies_col.SMILEY_DESC}" title="{smilies_row.smilies_col.SMILEY_DESC}" /></a></td> + <!-- END smilies_col --> + </tr> + <!-- END smilies_row --> + <!-- BEGIN switch_smilies_extra --> + <tr align="center"> + <td colspan="{S_SMILIES_COLSPAN}"><span class="nav"><a href="{U_MORE_SMILIES}" onclick="window.open('{U_MORE_SMILIES}', '_phpbbsmilies', 'HEIGHT=300,resizable=yes,scrollbars=yes,WIDTH=250');return false;" target="_phpbbsmilies" class="nav">{L_MORE_SMILIES}</a></span></td> + </tr> + <!-- END switch_smilies_extra --> + </table> + </td> + </tr> + </table> + </td> + <td class="row2" valign="top"><span class="gen"> <span class="genmed"> </span> + <table width="450" border="0" cellspacing="0" cellpadding="2"> + <tr align="center" valign="middle"> + <td><span class="genmed"> + <input type="button" class="button" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="bbstyle(0)" onMouseOver="helpline('b')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onClick="bbstyle(2)" onMouseOver="helpline('i')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onClick="bbstyle(4)" onMouseOver="helpline('u')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onClick="bbstyle(6)" onMouseOver="helpline('q')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onClick="bbstyle(8)" onMouseOver="helpline('c')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onClick="bbstyle(10)" onMouseOver="helpline('l')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onClick="bbstyle(12)" onMouseOver="helpline('o')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onClick="bbstyle(14)" onMouseOver="helpline('p')" /> + </span></td> + <td><span class="genmed"> + <input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" /> + </span></td> + </tr> + <tr> + <td colspan="9"> + <table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td><span class="genmed"> {L_FONT_COLOR}: + <select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;" onMouseOver="helpline('s')"> + <option style="color:black; background-color: {T_TD_COLOR1}" value="{T_FONTCOLOR1}" class="genmed">{L_COLOR_DEFAULT}</option> + <option style="color:darkred; background-color: {T_TD_COLOR1}" value="darkred" class="genmed">{L_COLOR_DARK_RED}</option> + <option style="color:red; background-color: {T_TD_COLOR1}" value="red" class="genmed">{L_COLOR_RED}</option> + <option style="color:orange; background-color: {T_TD_COLOR1}" value="orange" class="genmed">{L_COLOR_ORANGE}</option> + <option style="color:brown; background-color: {T_TD_COLOR1}" value="brown" class="genmed">{L_COLOR_BROWN}</option> + <option style="color:yellow; background-color: {T_TD_COLOR1}" value="yellow" class="genmed">{L_COLOR_YELLOW}</option> + <option style="color:green; background-color: {T_TD_COLOR1}" value="green" class="genmed">{L_COLOR_GREEN}</option> + <option style="color:olive; background-color: {T_TD_COLOR1}" value="olive" class="genmed">{L_COLOR_OLIVE}</option> + <option style="color:cyan; background-color: {T_TD_COLOR1}" value="cyan" class="genmed">{L_COLOR_CYAN}</option> + <option style="color:blue; background-color: {T_TD_COLOR1}" value="blue" class="genmed">{L_COLOR_BLUE}</option> + <option style="color:darkblue; background-color: {T_TD_COLOR1}" value="darkblue" class="genmed">{L_COLOR_DARK_BLUE}</option> + <option style="color:indigo; background-color: {T_TD_COLOR1}" value="indigo" class="genmed">{L_COLOR_INDIGO}</option> + <option style="color:violet; background-color: {T_TD_COLOR1}" value="violet" class="genmed">{L_COLOR_VIOLET}</option> + <option style="color:white; background-color: {T_TD_COLOR1}" value="white" class="genmed">{L_COLOR_WHITE}</option> + <option style="color:black; background-color: {T_TD_COLOR1}" value="black" class="genmed">{L_COLOR_BLACK}</option> + </select> {L_FONT_SIZE}:<select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')"> + <option value="7" class="genmed">{L_FONT_TINY}</option> + <option value="9" class="genmed">{L_FONT_SMALL}</option> + <option value="12" selected class="genmed">{L_FONT_NORMAL}</option> + <option value="18" class="genmed">{L_FONT_LARGE}</option> + <option value="24" class="genmed">{L_FONT_HUGE}</option> + </select> + </span></td> + <td nowrap="nowrap" align="right"><span class="gensmall"><a href="javascript:bbstyle(-1)" class="genmed" onMouseOver="helpline('a')">{L_BBCODE_CLOSE_TAGS}</a></span></td> + </tr> + </table> + </td> + </tr> + <tr> + <td colspan="9"> <span class="gensmall"> + <input type="text" name="helpbox" size="45" maxlength="100" style="width:450px; font-size:10px" class="helpline" value="{L_STYLES_TIP}" /> + </span></td> + </tr> + <tr> + <td colspan="9"><span class="gen"> + <textarea name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{ARTICLE}</textarea> + </span></td> + </tr> + </table> + </span></td> + </tr> + <tr> + <td class="row1" valign="top"><span class="gen"><b>{L_OPTIONS}</b></span><br /><span class="gensmall">{HTML_STATUS}<br />{BBCODE_STATUS}<br />{SMILIES_STATUS}</span></td> + <td class="row2"><span class="gen"> </span> + <table cellspacing="0" cellpadding="1" border="0"> + <!-- BEGIN switch_html_checkbox --> + <tr> + <td> + <input type="checkbox" name="disable_html" {S_HTML_CHECKED} /> + </td> + <td><span class="gen">{L_DISABLE_HTML}</span></td> + </tr> + <!-- END switch_html_checkbox --> + <!-- BEGIN switch_bbcode_checkbox --> + <tr> + <td> + <input type="checkbox" name="disable_bbcode" {S_BBCODE_CHECKED} /> + </td> + <td><span class="gen">{L_DISABLE_BBCODE}</span></td> + </tr> + <!-- END switch_bbcode_checkbox --> + <!-- BEGIN switch_smilies_checkbox --> + <tr> + <td> + <input type="checkbox" name="disable_smilies" {S_SMILIES_CHECKED} /> + </td> + <td><span class="gen">{L_DISABLE_SMILIES}</span></td> + </tr> + <!-- END switch_smilies_checkbox --> + <!-- BEGIN switch_signature_checkbox --> + <tr> + <td> + <input type="checkbox" name="attach_sig" {S_SIGNATURE_CHECKED} /> + </td> + <td><span class="gen">{L_ATTACH_SIGNATURE}</span></td> + </tr> + <!-- END switch_signature_checkbox --> + </table> + </td> + </tr> + {POLLBOX} + <tr> + <td class="catBottom" colspan="2" align="center" height="28"> {S_HIDDEN_FORM_FIELDS}<input type="submit" tabindex="5" name="preview" class="mainoption" value="{L_PREVIEW}" /> <input type="submit" accesskey="s" tabindex="6" name="post" class="mainoption" value="{L_SUBMIT}" /></td> + </tr> + </table> + + <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2"> + <tr> + <td align="left" valign="top">{NAVIGATION}</td> + <td align="right" valign="top"><span class="gensmall">{S_TIMEZONE}</span></td> + </tr> + </table> +</form> \ No newline at end of file Modified: root/templates/subSilver/kb_main.tpl =================================================================== --- root/templates/subSilver/kb_main.tpl 2006-11-21 19:57:07 UTC (rev 19) +++ root/templates/subSilver/kb_main.tpl 2006-11-23 15:32:31 UTC (rev 20) @@ -1,3 +1,10 @@ +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"> </td> + </tr> +</table> + <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> <tr> <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_CATEGORIES} </th> @@ -30,7 +37,7 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> - <td align="left"> </td> + <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> </table> \ No newline at end of file Modified: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl 2006-11-21 19:57:07 UTC (rev 19) +++ root/templates/subSilver/kb_viewcat.tpl 2006-11-23 15:32:31 UTC (rev 20) @@ -1,3 +1,10 @@ +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"> </td> + </tr> +</table> + <!-- BEGIN switch_subcats --> <table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> <tr> @@ -18,8 +25,9 @@ </tr> </table> <!-- END switch_subcats --> + +<!-- BEGIN switch_articles --> <br /> -<!-- BEGIN switch_articles --> <table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline"> <tr> <th colspan="2" align="center" height="25" class="thCornerL" nowrap="nowrap"> {L_ARTICLES} </th> @@ -29,12 +37,12 @@ </tr> <!-- BEGIN articlerow --> <tr> - <td class="row1" align="center" valign="middle" width="20"><img src="{articlerow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> - <td class="row1" width="100%"><span class="topictitle"><a href="{articlerow.U_VIEW_ARTICLE}" class="topictitle">{articlerow.ARTICLE_TITLE}</a></span><span class="gensmall"><br /> - {articlerow.ARTICLE_DESC}</span></td> - <td class="row3" align="center" valign="middle"><span class="name">{articlerow.ARTICLE_AUTHOR}</span></td> - <td class="row2" align="center" valign="middle"><span class="postdetails">{articlerow.ARTICLE_HITS}</span></td> - <td class="row3Right" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{articlerow.ARTICLE_LAST_ACTION}</span></td> + <td class="row1" align="center" valign="middle" width="20"><img src="{switch_articles.articlerow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row1" width="100%"><span class="topictitle"><a href="{switch_articles.articlerow.U_VIEW_ARTICLE}" class="topictitle">{switch_articles.articlerow.ARTICLE_TITLE}</a></span><span class="gensmall"><br /> + {switch_articles.articlerow.ARTICLE_DESC}</span></td> + <td class="row3" align="center" valign="middle"><span class="name">{switch_articles.articlerow.ARTICLE_AUTHOR}</span></td> + <td class="row2" align="center" valign="middle"><span class="postdetails">{switch_articles.articlerow.ARTICLE_HITS}</span></td> + <td class="row3Right" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{switch_articles.articlerow.ARTICLE_LAST_ACTION}</span></td> </tr> <!-- END articlerow --> <tr> @@ -45,7 +53,7 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> - <td align="left"> </td> + <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> </table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-24 00:27:20
|
Revision: 21 http://svn.sourceforge.net/phpbbkb/?rev=21&view=rev Author: softphp Date: 2006-11-23 16:27:20 -0800 (Thu, 23 Nov 2006) Log Message: ----------- Oh boy! Big commit :) List of modifications: - Added extra fields in articles table - Added support for posting articles (Not tested yet) - Added a big part of preview and edit functions.php - Added more lang variables, but didn't write them all into lang_kb.php - Added if(!defined('IN_PHPBB')) blablabla to functions.php, constants.php & ucp_class.php. (Yes i should be shot for not doing it before. - Added multiple categories support (Not tested either) Modified Paths: -------------- root/kb/constants.php root/kb/functions.php root/kb/ucp_class.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php root/templates/subSilver/kb_article_posting.tpl Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/kb/constants.php 2006-11-24 00:27:20 UTC (rev 21) @@ -18,6 +18,11 @@ * ***************************************************************************/ +if (!defined('IN_PHPBB')) +{ + die('Hacking attempt'); +} + // All constants here // DB Tables define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/kb/functions.php 2006-11-24 00:27:20 UTC (rev 21) @@ -18,6 +18,11 @@ * ***************************************************************************/ +if (!defined('IN_PHPBB')) +{ + die('Hacking attempt'); +} + // This function creates the navigation line based on a few parameters function create_navigation($type = "main", $id_ary = array()) { @@ -69,4 +74,132 @@ return; } + +function get_cats_structure() +{ + global $db; + + $cats = array(); + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '0' + ORDER BY cat_order"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cats.', '', __LINE__, __FILE__, $sql); + } + + $i = 0; + while($row = $db->sql_fetchrow($result)) + { + $cats[$i] = $row; + + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $row['cat_id'] . "' + ORDER BY cat_order"; + if( !($subcat_result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query subcats.', '', __LINE__, __FILE__, $sql); + } + + $cats[$i]['subcats'] = array(); + while($row2 = $db->sql_fetchrow($subcat_result)) + { + $cats[$i]['subcats'][] = $row2; + } + $i++; + } + + return $cats; +} + +// These vars we need for making html safe +$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); +$html_entities_replace = array('&', '<', '>', '"'); + +// +// Prepare an article for the database +// +function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) +{ + global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; + + // Check title + if (!empty($article_title)) + { + $article_title = htmlspecialchars(trim($article_title)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; + } + + // Check message + if(!empty($message)) + { + $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; + $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; + } + + // Check categories + if(!empty($cat_id) && count($cat_id) > 0) + { + $cat_id = implode(",", $cat_id); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; + + return; +} + +function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) +{ + global $board_config, $html_entities_match, $html_entities_replace; + + // + // Clean up the message + // + $message = trim($message); + + if ($html_on) + { + // If HTML is on, we try to make it safe + // This approach is quite agressive and anything that does not look like a valid tag + // is going to get converted to HTML entities + $message = stripslashes($message); + $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; + $matches = array(); + + $message_split = preg_split($html_match, $message); + preg_match_all($html_match, $message, $matches); + + $message = ''; + + foreach ($message_split as $part) + { + $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); + $message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag); + } + + $message = addslashes($message); + $message = str_replace('"', '\"', $message); + } + else + { + $message = preg_replace($html_entities_match, $html_entities_replace, $message); + } + + if($bbcode_on && $bbcode_uid != '') + { + $message = bbencode_first_pass($message, $bbcode_uid); + } + + return $message; +} ?> \ No newline at end of file Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/kb/ucp_class.php 2006-11-24 00:27:20 UTC (rev 21) @@ -18,15 +18,18 @@ * ***************************************************************************/ +if (!defined('IN_PHPBB')) +{ + die('Hacking attempt'); +} + // This contains the entire ucp class, so it's seperated from the rest of kb.php class ucp { var $action = ""; - function __construct($action, $id=0) + function generate_page($action, $id=0, $preview=false) { - global $HTTP_POST_VARS['review']; - $this->action = $action; switch($this->action) { @@ -37,11 +40,11 @@ break; case "post_article": - $this->article_form("post", false, $HTTP_POST_VARS['review']); + $this->article_form("post", false, $preview); break; case "edit_article": - $this->article_form("edit", $id, $HTTP_POST_VARS['review']); + $this->article_form("edit", $id, $preview); break; case "delete_article": @@ -62,18 +65,174 @@ } } + function generate_page_title($action) + { + global $lang; + + $title = $lang['kb_ucp']; + + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + $title .= ": " . $lang['kb_ucp_articlepost']; + break; + + case "edit_article": + + break; + + case "delete_article": + + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + + return $title; + } + // This is for posting articles, mostly cut out of the posting.php :) function article_form($mode, $id, $review) { - global $template, $board_config, $db, $userdata; + global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; - if($mode == "post") + $error_msg = ''; + + if(!empty($HTTP_POST_VARS['post'])) { + // Add the new article + // Make all the variables :) + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE; + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE; + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE; + } + + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? $HTTP_POST_VARS['desc'] : ''; + $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $article_author = $userdata['user_id']; + $article_authorname = ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname']; + $bbcode_uid = ''; + $cat_id = $HTTP_POST_VARS['cats']; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0; + + prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + + if ( $error_msg == '' ) + { + $current_time = time(); + + $sql = "INSERT INTO" . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbode, enable_smilies, article_text) VALUES + ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$enable_sig', '$enable_html', '$enable_bbcode', '$enable_smilies', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + + $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("kb.$phpEx?pid=view_article&id=" . $article_id) . '>"'; + $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>'); + } + } + + $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; + if($mode == "post" && !$preview) + { $article_title = ''; $article_text = ''; $article_desc = ''; $authorname = $userdata['username']; + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $hidden_form_fields = ""; + $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; + + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); + } + + if($preview) + { + // Do funny preview stuff + } } + elseif($preview) + { + $article_title = $HTTP_POST_VARS['title']; + $article_text = $HTTP_POST_VARS['message']; + $article_desc = $HTTP_POST_VARS['desc']; + $authorname = $HTTP_POST_VARS['authorname']; + + $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; + $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; + $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; + + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $hidden_form_fields = ""; + } else { $sql = "SELECT * @@ -90,12 +249,14 @@ $article_desc = $article['article_desc']; $authorname = $article['article_authorname']; - $attach_sig = ( $article['enable_sig'] && $post_info['user_sig'] != '' ) ? TRUE : 0; - $user_sig = $userdata['user_sig']; + $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; $html_on = ( $article['enable_html'] ) ? true : false; $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; $smilies_on = ( $article['enable_smilies'] ) ? true : false; + + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = ""; } $article_text = str_replace('<', '<', $article_text); @@ -136,6 +297,41 @@ $bbcode_status = $lang['BBCode_is_OFF']; } + // Obtain categories structure + $cats = get_cats_structure(); + + // First lets sort main cats + $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; + if($preview || $mode == "edit") + { + for($i = 0; $i < count($cats); $i++) + { + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + else + { + $var = ( $preview ) ? $HTTP_POST_VARS['cats'] : $article['cat_id']; + for($i = 0; $i < count($cats); $i++) + { + $selected = ( strstr($var, "," . $cats[$i]['cat_id'] . ",") ) ? ' selected' : ''; + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $selected = ( strstr($var, "," . $cats[$i]['subcats'][$j]['cat_id'] . ",") ) ? ' selected' : ''; + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + // // Smilies toggle selection // @@ -149,6 +345,10 @@ $smilies_status = $lang['Smilies_are_OFF']; } + $template->set_filenames(array( + 'body' => 'kb_article_posting.tpl') + ); + // This is the template stuff we need no matter what $template->assign_vars(array( 'AUTHORNAME' => $authorname, @@ -158,14 +358,19 @@ 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, - 'L_SUBJECT' => $lang['Subject'], - 'L_MESSAGE_BODY' => $lang['Message_body'], + 'L_POST_ARTICLE' => $lang['kb_post_article'], + 'L_AUTHORNAME' => $lang['kb_authorname'], + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_ARTICLE_CATS' => $lang['kb_articlecats'], + 'L_ARTICLE_BODY' => $lang['kb_articletext'], + 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], + 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? + 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], + 'L_OPTIONS' => $lang['Options'], 'L_PREVIEW' => $lang['Preview'], - 'L_SPELLCHECK' => $lang['Spellcheck'], 'L_SUBMIT' => $lang['Submit'], - 'L_CANCEL' => $lang['Cancel'], - 'L_CONFIRM_DELETE' => $lang['Confirm_delete'], 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], @@ -212,17 +417,12 @@ 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], 'L_STYLES_TIP' => $lang['Styles_tip'], - 'U_VIEWTOPIC' => ( $mode == 'reply' ) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postorder=desc") : '', - 'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? append_sid("kb.$phpEx?preview=topicreview&" . POST_TOPIC_URL . "=$topic_id") : '', - 'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', 'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', - 'S_NOTIFY_CHECKED' => ( $notify_user ) ? 'checked="checked"' : '', - 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_TOPIC_ID' => $topic_id, - 'S_POST_ACTION' => append_sid("posting.$phpEx"), + 'S_POST_ACTION' => $form_action, + 'CATS_HTML' => $s_cats, 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) ); } Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/kb.php 2006-11-24 00:27:20 UTC (rev 21) @@ -338,8 +338,15 @@ case "ucp": $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; - $ucp = new ucp($action); + include($phpbb_root_path . "kb/ucp_class.$phpEx"); + $ucp = new ucp; + // Start Page output + $page_title = $ucp->generate_page_title($action); + include($phpbb_root_path . 'includes/page_header.'.$phpEx); + + $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); + // // Generate the page // Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/kb_install.php 2006-11-24 00:27:20 UTC (rev 21) @@ -67,10 +67,15 @@ article_desc varchar(255) NOT NULL, article_author mediumint(8) UNSIGNED NOT NULL, article_authorname varchar(50) NOT NULL, + article_time int(20) UNSIGNED DEFAULT '0', article_edittime int(20) UNSIGNED DEFAULT '0', article_hits mediumint(8) UNSIGNED DEFAULT '0', article_editby mediumint(8) UNSIGNED DEFAULT '0', article_status smallint(1) UNSIGNED DEFAULT '0', + enable_sig smallint(1) UNSIGNED DEFAULT '0', + enable_html smallint(1) UNSIGNED DEFAULT '0', + enable_bbcode smallint(1) UNSIGNED DEFAULT '0', + enable_smilies smallint(1) UNSIGNED DEFAULT '0', article_text text, PRIMARY KEY (article_id), KEY cat_id (cat_id) Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-23 15:32:31 UTC (rev 20) +++ root/language/lang_english/lang_kb.php 2006-11-24 00:27:20 UTC (rev 21) @@ -21,7 +21,11 @@ // Page titles $lang['kb_main'] = "KnowledgeBase Home"; $lang['kb_viewcat'] = "Viewing Category"; +$lang['kb_ucp'] = "KB User Control Panel"; +$lang['kb_ucp_articlepost'] = "Post new article"; +$lang['kb_ucp_articleedit'] = "Edit article"; +// Normal Page $lang['kb_categories'] = "KnowledgeBase Categories"; $lang['kb_articles'] = "Articles"; $lang['kb_subcats'] = "Subcategories"; @@ -31,4 +35,15 @@ $lang['kb_viewcat_subcats'] = "Subcategories in %s"; $lang['kb_last_action'] = "Last action"; $lang['kb_last_action_row'] = "Last action for this article was comitted by %s on the %s"; + +// Posting Page +$lang['kb_post_article'] = "Post New 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"; +$lang['kb_articledesc'] = "Article Description"; +$lang['kb_articlecats'] = "Article Categories"; +$lang['kb_articletext'] = "Article Content"; +$lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; +$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use ctrl + click for multiple."; ?> \ No newline at end of file Modified: root/templates/subSilver/kb_article_posting.tpl =================================================================== --- root/templates/subSilver/kb_article_posting.tpl 2006-11-23 15:32:31 UTC (rev 20) +++ root/templates/subSilver/kb_article_posting.tpl 2006-11-24 00:27:20 UTC (rev 21) @@ -247,26 +247,27 @@ <th class="thHead" colspan="2" height="25"><b>{L_POST_ARTICLE}</b></th> </tr> <tr> - <td class="row1"><span class="gen"><b>{L_AUTHORNAME}</b></span></td> - <td class="row2"><span class="genmed"><input type="text" class="post" tabindex="1" name="username" size="25" maxlength="25" value="{AUTHORNAME}" /> + <td class="row1"><span class="gen"><b>{L_AUTHORNAME}</b></span><br /><span class="gensmall">{L_AUTHORNAME_DESC}</span></td> + <td class="row2"><span class="genmed"><input name="authorname" type="text" class="post" id="authorname" tabindex="1" value="{AUTHORNAME}" size="25" maxlength="25" /> </span></td> </tr> <tr> <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_NAME}</b></span></td> <td class="row2" width="78%"> <span class="gen"> - <input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{ARTICLE_TITLE}" /> + <input name="title" type="text" class="post" id="title" style="width:450px" tabindex="2" value="{ARTICLE_TITLE}" size="45" maxlength="60" /> </span> </td> </tr> <tr> - <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_DESC}</b></span></td> + <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_DESC}</b></span><br /><span class="gensmall">{L_ARTICLEDESC_DESC}</span></td> <td class="row2" width="78%"> <span class="gen"> <textarea name="desc" cols="35" rows="5" wrap="virtual" class="post" id="desc" style="width:450px" tabindex="2">{DESC}</textarea> </span> </td> </tr> <tr> - <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_CATS}</b></span></td> - <td class="row2" width="78%"><select name="cats" size="4" multiple="multiple" id="cats">{CATS_HTML} - </select> + <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_CATS}</b></span><br /><span class="gensmall">{L_ARTICLECATS_DESC}</span></td> + <td class="row2" width="78%"><select name="cats" size="4" multiple="multiple" id="cats"> + {CATS_HTML} + </select> </td> </tr> <tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-24 14:46:51
|
Revision: 23 http://svn.sourceforge.net/phpbbkb/?rev=23&view=rev Author: softphp Date: 2006-11-24 06:46:46 -0800 (Fri, 24 Nov 2006) Log Message: ----------- - Added a lot of missing lang vars - Finished correcting the errors Mark pointed out - Posting articles now works, not completely though TODO: - Make cat_articles go one up when you create an article - Code support for edit article & preview article NOTE: - Still no permissions at all Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php root/templates/subSilver/kb_article_posting.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb/functions.php 2006-11-24 14:46:46 UTC (rev 23) @@ -37,7 +37,7 @@ case "viewcat": // View category // id = $cat_id::$cat_name - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id='. $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewsubcat": @@ -51,7 +51,7 @@ message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); } $maincat = $db->sql_fetchrow($result); - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.'$phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.'.$phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a></span>'; break; case "viewarticle": @@ -64,7 +64,7 @@ case "main": default: - $navigation = '<span class="nav"> <a href="' . append_sid('kb.'.$phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a></span>'; break; } @@ -117,7 +117,7 @@ // These vars we need for making html safe $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); $html_entities_replace = array('&', '<', '>', '"'); - +/* // // Prepare an article for the database // @@ -126,6 +126,7 @@ global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; // Check title + $article_title = "BLABLA"; if (!empty($article_title)) { $article_title = htmlspecialchars(trim($article_title)); @@ -146,9 +147,20 @@ $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; } + // Check Desc + if (!empty($article_desc)) + { + $article_desc = htmlspecialchars(trim($article_desc)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; + } + // Check categories - if(!empty($cat_id) && count($cat_id) > 0) + if(is_array($cat_id)) { + print_r($cat_id); $cat_id = implode(",", $cat_id); } else @@ -202,4 +214,5 @@ return $message; } +*/ ?> \ No newline at end of file Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb/ucp_class.php 2006-11-24 14:46:46 UTC (rev 23) @@ -27,6 +27,8 @@ class ucp { var $action = ""; + var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + var $html_entities_replace = array('&', '<', '>', '"'); function generate_page($action, $id=0, $preview=false) { @@ -113,6 +115,7 @@ global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; $error_msg = ''; + $user_sig = $userdata['user_sig']; if(!empty($HTTP_POST_VARS['post'])) { @@ -124,7 +127,7 @@ } else { - $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE; + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; } if ( !$board_config['allow_bbcode'] ) @@ -133,7 +136,7 @@ } else { - $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE; + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; } if ( !$board_config['allow_smilies'] ) @@ -142,26 +145,26 @@ } else { - $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE; + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; } - $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? $HTTP_POST_VARS['desc'] : ''; + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; $article_author = $userdata['user_id']; $article_authorname = ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname']; $bbcode_uid = ''; $cat_id = $HTTP_POST_VARS['cats']; - $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; - prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); - + $this->prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + if ( $error_msg == '' ) { $current_time = time(); - $sql = "INSERT INTO" . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbode, enable_smilies, article_text) VALUES - ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$enable_sig', '$enable_html', '$enable_bbcode', '$enable_smilies', '$message');"; + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); @@ -169,19 +172,21 @@ $article_id = $db->sql_nextid(); - $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid('kb.'.$phpEx.'?pid=view_article&id=' . $article_id) . '>"'; - $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>'); + $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; } } $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; - if($mode == "post" && !$preview) + if($mode == "post" && !$preview && $error_msg == '') { $article_title = ''; $article_text = ''; $article_desc = ''; $authorname = $userdata['username']; - $form_action = append_sid('kb.'.$phpEx.'?pid=ucp&action=post_article'); + $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); $hidden_form_fields = ""; $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; @@ -217,7 +222,7 @@ // Do funny preview stuff } } - elseif($preview) + elseif($preview || $error_msg != '') { $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; @@ -230,8 +235,19 @@ $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); $hidden_form_fields = ""; + + if($error_msg != "") + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } } else { @@ -255,7 +271,7 @@ $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; $smilies_on = ( $article['enable_smilies'] ) ? true : false; - $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); $hidden_form_fields = ""; } @@ -354,8 +370,9 @@ 'AUTHORNAME' => $authorname, 'ARTICLE_TITLE' => $article_title, 'ARTICLE' => $article_text, + 'DESC' => $article_desc, 'HTML_STATUS' => $html_status, - 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + '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'], @@ -426,5 +443,100 @@ 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) ); } + + // + // Prepare an article for the database + // + function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) + { + global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; + + // Check title + if (!empty($article_title)) + { + $article_title = htmlspecialchars(trim($article_title)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; + } + + // Check message + if(!empty($message)) + { + $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; + $message = $this->prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; + } + + // Check Desc + if (!empty($article_desc)) + { + $article_desc = htmlspecialchars(trim($article_desc)); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; + } + + // Check categories + if(is_array($cat_id)) + { + $cat_id = implode(",", $cat_id); + } + else + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; + } + return; + } + + function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) + { + global $board_config, $html_entities_match, $html_entities_replace; + + // + // Clean up the message + // + $message = trim($message); + + if ($html_on) + { + // If HTML is on, we try to make it safe + // This approach is quite agressive and anything that does not look like a valid tag + // is going to get converted to HTML entities + $message = stripslashes($message); + $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; + $matches = array(); + + $message_split = preg_split($html_match, $message); + preg_match_all($html_match, $message, $matches); + + $message = ''; + + foreach ($message_split as $part) + { + $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); + $message .= preg_replace($this->html_entities_match, $this->html_entities_replace, $part) . clean_html($tag); + } + + $message = addslashes($message); + $message = str_replace('"', '\"', $message); + } + else + { + $message = preg_replace($this->html_entities_match, $this->html_entities_replace, $message); + } + + if($bbcode_on && $bbcode_uid != '') + { + $message = bbencode_first_pass($message, $bbcode_uid); + } + + return $message; + } } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb.php 2006-11-24 14:46:46 UTC (rev 23) @@ -23,6 +23,7 @@ include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'kb/constants.' . $phpEx); // Added these two files, yes i could just add the 10-15 lines it will end with in include($phpbb_root_path . 'kb/functions.' . $phpEx); // the existing files, but this makes it a lot easier to install/uninstall. +include($phpbb_root_path . 'includes/bbcode.'.$phpEx); // // Start session management @@ -71,7 +72,7 @@ // Start Page output $page_title = $lang['kb_main']; - include($phpbb_root_path . 'includes/page_header.'.$phpEx); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); create_navigation(); $template->set_filenames(array( @@ -92,7 +93,7 @@ 'CAT_TITLE' => $catrows[$i]['cat_title'], 'CAT_DESC' => $catrows[$i]['cat_desc'], 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), 'L_SUBCATS' => $lang['kb_subcats'], 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D ); @@ -124,7 +125,7 @@ $k = $j + 1; $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; $template->assign_block_vars('catrow.subcatrow', array( - 'U_SUBCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], 'SUBCAT_COMMA' => $subcat_comma) ); @@ -270,7 +271,7 @@ 'CAT_TITLE' => $subcats[$i]['cat_title'], 'CAT_DESC' => $subcats[$i]['cat_desc'], 'CAT_ARTICLES' => $subcats[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$i]['cat_id']), + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$i]['cat_id']), 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D ); } @@ -300,7 +301,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; $sql = "SELECT username FROM " . USERS_TABLE . " @@ -311,7 +312,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -320,7 +321,7 @@ 'ARTICLE_AUTHOR' => $author, 'ARTICLE_HITS' => $articles[$i]['article_hits'], 'ARTICLE_LAST_ACTION' => $last_action, - 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) + 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) ); } } @@ -338,12 +339,12 @@ case "ucp": $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; - include($phpbb_root_path . "kb/ucp_class.$phpEx"); + include($phpbb_root_path . "kb/ucp_class." . $phpEx); $ucp = new ucp; // Start Page output $page_title = $ucp->generate_page_title($action); - include($phpbb_root_path . 'includes/page_header.'.$phpEx); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/kb_install.php 2006-11-24 14:46:46 UTC (rev 23) @@ -62,7 +62,7 @@ $sql[] = "CREATE TABLE " . $table_prefix . "kb_articles ( article_id mediumint(8) UNSIGNED NOT NULL auto_increment, - cat_id mediumint(8) UNSIGNED DEFAULT '0', + cat_id varcharr(20) NOT NULL, article_title varchar(100) NOT NULL, article_desc varchar(255) NOT NULL, article_author mediumint(8) UNSIGNED NOT NULL, Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-24 03:21:02 UTC (rev 22) +++ root/language/lang_english/lang_kb.php 2006-11-24 14:46:46 UTC (rev 23) @@ -46,4 +46,11 @@ $lang['kb_articletext'] = "Article Content"; $lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; $lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use ctrl + click for multiple."; +$lang['kb_empty_article'] = "The article content you have submitted was empty."; +$lang['kb_empty_article_title'] = "The article title you submitted was empty."; +$lang['kb_empty_cats'] = "The article you submitted had no category defined."; +$lang['kb_empty_article_desc'] = "The article has to contain an article description."; +$lang['kb_added'] = "Your article has been submitted and is awaiting approval."; +$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"; ?> \ No newline at end of file Modified: root/templates/subSilver/kb_article_posting.tpl =================================================================== --- root/templates/subSilver/kb_article_posting.tpl 2006-11-24 03:21:02 UTC (rev 22) +++ root/templates/subSilver/kb_article_posting.tpl 2006-11-24 14:46:46 UTC (rev 23) @@ -265,7 +265,7 @@ </tr> <tr> <td class="row1" width="22%"><span class="gen"><b>{L_ARTICLE_CATS}</b></span><br /><span class="gensmall">{L_ARTICLECATS_DESC}</span></td> - <td class="row2" width="78%"><select name="cats" size="4" multiple="multiple" id="cats"> + <td class="row2" width="78%"><select name="cats[]" size="4" multiple="multiple" id="cats"> {CATS_HTML} </select> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-26 02:49:30
|
Revision: 24 http://svn.sourceforge.net/phpbbkb/?rev=24&view=rev Author: softphp Date: 2006-11-25 18:49:26 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Fairly big commit here: - Recoded the multiple categories part, and introducing a new database table. It works nice. - Corrected minor template mistake. - Corrected some other stuff in ucp_class.php, especially the categories part, now including a lot of loops, could it be done easier? TODO: - Edit Article <-- Yes I worked on it now, and the user interface part works, but the db works hasn't been done, so no testing has commenced. - Preview when posting <-- I'll add this after I've added the view article part I think. - View Article <-- Not a single line has been coded Modified Paths: -------------- root/kb/constants.php root/kb/ucp_class.php root/kb.php root/kb_install.php root/templates/subSilver/kb_viewcat.tpl Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb/constants.php 2006-11-26 02:49:26 UTC (rev 24) @@ -27,5 +27,6 @@ // DB Tables define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); +define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats ?> \ No newline at end of file Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb/ucp_class.php 2006-11-26 02:49:26 UTC (rev 24) @@ -163,15 +163,31 @@ { $current_time = time(); - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, cat_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$cat_id', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); } - + $article_id = $db->sql_nextid(); - + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + $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>'); @@ -236,8 +252,16 @@ $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; + if($mode == "edit") + { + $hidden_form_fields = ""; + } + else + { + $hidden_form_fields = ""; + } + if($error_msg != "") { $template->set_filenames(array( @@ -251,15 +275,36 @@ } else { + if(empty($id)) + { + message_die(GENERAL_ERROR, "No article defined."); + } + $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE id = '" . $id . "'"; + WHERE article_id = '$id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); } + $article = $db->sql_fetchrow($result); + // Now make an array over the cats + $sql = "SELECT cat_id + FROM " . KB_ARTICLECATS_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); + } + + $article_cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $article_cats[] = $row; + } + $article_title = $article['article_title']; $article_text = $article['article_text']; $article_desc = $article['article_desc']; @@ -316,34 +361,47 @@ // Obtain categories structure $cats = get_cats_structure(); - // First lets sort main cats + // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($preview || $mode == "edit") + if($mode == "edit") { for($i = 0; $i < count($cats); $i++) { - $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; // Sort subcats for($j = 0; $j < count($cats[$i]['subcats']); $j++) { - $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; } } } else { - $var = ( $preview ) ? $HTTP_POST_VARS['cats'] : $article['cat_id']; for($i = 0; $i < count($cats); $i++) { - $selected = ( strstr($var, "," . $cats[$i]['cat_id'] . ",") ) ? ' selected' : ''; - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; // Sort subcats for($j = 0; $j < count($cats[$i]['subcats']); $j++) { - $selected = ( strstr($var, "," . $cats[$i]['subcats'][$j]['cat_id'] . ",") ) ? ' selected' : ''; - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; } } } @@ -483,12 +541,8 @@ } // Check categories - if(is_array($cat_id)) + if(!is_array($cat_id)) { - $cat_id = implode(",", $cat_id); - } - else - { $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; } return; Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb.php 2006-11-26 02:49:26 UTC (rev 24) @@ -188,29 +188,31 @@ { case "rating": // Later - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; case "author": // Later - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; case "title": - $sort = "ORDER BY article_title"; + $sort = "ORDER BY a.article_title"; break; case "time": default: - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; break; } } else { - $sort = "ORDER BY article_edittime DESC"; + $sort = "ORDER BY a.article_edittime DESC"; } + // This has been removed due to probably not working + /* $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " WHERE cat_id LIKE '$cat_id' @@ -219,10 +221,21 @@ { message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql); } + */ + $sql = "SELECT a.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_ARTICLES_TABLE . " a + WHERE c.cat_id = '$cat_id' + AND c.article_id = a.article_id + $sort"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query articles.', '', __LINE__, __FILE__, $sql); + } + $articles = array(); while($row = $db->sql_fetchrow($result)) - { + { $articles[] = $row; } @@ -305,7 +318,7 @@ $sql = "SELECT username FROM " . USERS_TABLE . " - WHERE user_id = '" . $articles[$i]['article_editby']; + WHERE user_id = '" . $articles[$i]['article_editby'] . "'"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query last edited by\'s username.', '', __LINE__, __FILE__, $sql); Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-24 14:46:46 UTC (rev 23) +++ root/kb_install.php 2006-11-26 02:49:26 UTC (rev 24) @@ -62,7 +62,6 @@ $sql[] = "CREATE TABLE " . $table_prefix . "kb_articles ( article_id mediumint(8) UNSIGNED NOT NULL auto_increment, - cat_id varcharr(20) NOT NULL, article_title varchar(100) NOT NULL, article_desc varchar(255) NOT NULL, article_author mediumint(8) UNSIGNED NOT NULL, @@ -77,10 +76,14 @@ enable_bbcode smallint(1) UNSIGNED DEFAULT '0', enable_smilies smallint(1) UNSIGNED DEFAULT '0', article_text text, - PRIMARY KEY (article_id), - KEY cat_id (cat_id) + PRIMARY KEY (article_id) )"; +$sql[] = "CREATE TABLE " . $table_prefix . "kb_articlecats ( + article_id mediumint(8) NOT NULL DEFAULT '0', + cat_id mediumint(8) NOT NULL DEFAULT '0' +)"; + echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; echo '<tr><th>Updating the database</th></tr>'; Modified: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl 2006-11-24 14:46:46 UTC (rev 23) +++ root/templates/subSilver/kb_viewcat.tpl 2006-11-26 02:49:26 UTC (rev 24) @@ -46,7 +46,7 @@ </tr> <!-- END articlerow --> <tr> - <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td> + <td class="catBottom" align="center" valign="middle" colspan="5" height="28"> </td> </tr> </table> <!-- END switch_articles --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-27 15:50:12
|
Revision: 25 http://svn.sourceforge.net/phpbbkb/?rev=25&view=rev Author: softphp Date: 2006-11-27 07:50:04 -0800 (Mon, 27 Nov 2006) Log Message: ----------- - Edit article now works as intended - Added navigation to the 2 ucp pages - Started on view article. Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/kb_install.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb/functions.php 2006-11-27 15:50:04 UTC (rev 25) @@ -32,6 +32,19 @@ { case "ucp": // Different kind of subcategories + switch($id_ary) + { + case "post_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article') . '">' . $lang['kb_ucp_articlepost'] .'</a></span>'; + break; + + case "edit_article": + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article') . '">' . $lang['kb_ucp_articleedit'] .'</a></span>'; + break; + + default: + break; + } break; case "viewcat": Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb/ucp_class.php 2006-11-27 15:50:04 UTC (rev 25) @@ -29,6 +29,8 @@ var $action = ""; var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); var $html_entities_replace = array('&', '<', '>', '"'); + var $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); + var $unhtml_specialchars_replace = array('>', '<', '"', '&'); function generate_page($action, $id=0, $preview=false) { @@ -86,7 +88,7 @@ break; case "edit_article": - + $title .= ": " . $lang['kb_ucp_articleedit']; break; case "delete_article": @@ -119,6 +121,32 @@ if(!empty($HTTP_POST_VARS['post'])) { + if($mode == 'edit') + { + // Let's get the old article data + $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if (!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + // if user editing set status = 0, else set status = old status :) + if($userdata['user_id'] == $article_author) + { + $article_status = "0"; + } + else + { + $article_status = $article['article_status']; + } + } + // Add the new article // Make all the variables :) if ( !$board_config['allow_html'] ) @@ -151,8 +179,8 @@ $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; - $article_author = $userdata['user_id']; - $article_authorname = ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname']; + $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; + $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); $bbcode_uid = ''; $cat_id = $HTTP_POST_VARS['cats']; $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; @@ -162,35 +190,91 @@ if ( $error_msg == '' ) { $current_time = time(); - - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; - if (!$db->sql_query($sql)) + + if($mode == 'post') { - message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + $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>'); } - - $article_id = $db->sql_nextid(); - // Now make the categories - foreach($cat_id as $i => $cat) + else { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + if(!$article_id) + { + message_die(GENERAL_ERROR, 'No article to edit.'); + } + // First update the article table + $sql = "UPDATE " . KB_ARTICLES_TABLE . " + SET article_title = '$article_title', + article_desc = '$article_desc', + article_author = '$article_author', + article_authorname = '$article_authorname', + article_edittime = '$current_time', + article_editby = '" . $userdata['user_id'] . "', + article_status = '$article_status', + enable_sig = '$attach_sig', + enable_html = '$html_on', + enable_bbcode = '$bbcode_on', + enable_smilies = '$smilies_on', + article_text = '$message';"; + if (!$db->sql_query($sql)) { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); } - if (!$db->sql_query($sql2)) + // Now delete all articlecats + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); } + + // Last add them again doing the loop + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + // 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_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; } } @@ -252,16 +336,7 @@ $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - - if($mode == "edit") - { - $hidden_form_fields = ""; - } - else - { - $hidden_form_fields = ""; - } - + $hidden_form_fields = ""; if($error_msg != "") { $template->set_filenames(array( @@ -288,7 +363,14 @@ message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); } - $article = $db->sql_fetchrow($result); + if($db->sql_numrows($result) == 1) + { + $article = $db->sql_fetchrow($result); + } + else + { + message_die(GENERAL_ERROR, "Article does not exist."); + } // Now make an array over the cats $sql = "SELECT cat_id @@ -317,9 +399,14 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = ""; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; } + if ( $article['bbcode_uid'] != '' ) + { + $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); + } + $article_text = str_replace('<', '<', $article_text); $article_text = str_replace('>', '>', $article_text); $article_text = str_replace('<br />', "\n", $article_text); @@ -423,6 +510,8 @@ 'body' => 'kb_article_posting.tpl') ); + create_navigation("ucp", $this->action); + // This is the template stuff we need no matter what $template->assign_vars(array( 'AUTHORNAME' => $authorname, @@ -550,7 +639,7 @@ function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) { - global $board_config, $html_entities_match, $html_entities_replace; + global $board_config, $phpEx; // // Clean up the message @@ -571,6 +660,9 @@ $message = ''; + // Include functions_post for clean_html + include($phpbb_root_path . "includes/functions_post." . $phpEx); + foreach ($message_split as $part) { $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); @@ -592,5 +684,10 @@ return $message; } + + function unprepare_message($message) + { + return preg_replace($this->unhtml_specialchars_match, $this->unhtml_specialchars_replace, $message); + } } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb.php 2006-11-27 15:50:04 UTC (rev 25) @@ -334,7 +334,7 @@ 'ARTICLE_AUTHOR' => $author, 'ARTICLE_HITS' => $articles[$i]['article_hits'], 'ARTICLE_LAST_ACTION' => $last_action, - 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=viewarticle&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) + 'U_VIEW_ARTICLE' => append_sid("kb." . $phpEx . "?pid=view_article&cid=" . $cat_id . "&id=" . $articles[$i]['article_id'])) ); } } @@ -348,6 +348,22 @@ break; 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']; + + if(!$cid || !$id) + { + message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); + } + break; case "ucp": Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-11-26 02:49:26 UTC (rev 24) +++ root/kb_install.php 2006-11-27 15:50:04 UTC (rev 25) @@ -71,6 +71,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, enable_sig smallint(1) UNSIGNED DEFAULT '0', enable_html smallint(1) UNSIGNED DEFAULT '0', enable_bbcode smallint(1) UNSIGNED DEFAULT '0', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-11-29 23:28:50
|
Revision: 26 http://svn.sourceforge.net/phpbbkb/?rev=26&view=rev Author: softphp Date: 2006-11-29 15:28:36 -0800 (Wed, 29 Nov 2006) Log Message: ----------- -- Added a very simple page for viewing articles -- Fixed a bug that made the author id delete when you edited an article. Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/language/lang_english/lang_kb.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/functions.php 2006-11-29 23:28:36 UTC (rev 26) @@ -69,6 +69,23 @@ case "viewarticle": // Viewing an article + if($id_ary[2] == 0) + { + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } + else + { + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } break; case "search": Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/ucp_class.php 2006-11-29 23:28:36 UTC (rev 26) @@ -128,7 +128,7 @@ $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -351,19 +351,170 @@ $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + // Get naughty words :) + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if(!$cid || !$id) { message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); } - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + $sql = "SELECT a.*, u.* + FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u + WHERE a.article_id = '$id' + AND a.article_author = u.user_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); } + $article = $db->sql_fetchrow($result); + + $sql = "SELECT c.*, ca.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_CATEGORIES_TABLE . " ca + WHERE c.article_id = '$id' + AND ca.cat_id = c.cat_id"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article categories.', '', __LINE__, __FILE__, $sql); + } + + // + // These vars are for later use + // + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + + if($row['cat_id'] == $cid) + { + $current_cat['cat_title'] = $row['cat_title']; + $current_cat['cat_id'] = $row['cat_id']; + $current_cat['cat_main'] = $row['cat_main']; + } + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_bbcode_uid = $article['bbcode_uid']; + + $user_sig = ( $article['enable_sig'] && $article['user_sig'] != '' && $board_config['allow_sig'] ) ? $article['user_sig'] : ''; + $user_sig_bbcode_uid = $article['user_sig_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 ( !$board_config['allow_html'] || !$userdata['user_allowhtml']) + { + if ( $user_sig != '' ) + { + $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); + } + + if ( $article['enable_html'] ) + { + $article_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $article_text); + } + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($user_sig != '' && $user_sig_bbcode_uid != '') + { + $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig); + } + + if ($article_bbcode_uid != '') + { + $article_text = ($board_config['allow_bbcode']) ? bbencode_second_pass($article_text, $article_bbcode_uid) : preg_replace("/\:$article_bbcode_uid/si", '', $article_text); + } + + if ( $user_sig != '' ) + { + $user_sig = make_clickable($user_sig); + } + $article_text = make_clickable($article_text); + + // + // Parse smilies + // + if ( $board_config['allow_smilies'] ) + { + if ( $article['user_allowsmile'] && $user_sig != '' ) + { + $user_sig = smilies_pass($user_sig); + } + + if ( $article['enable_smilies'] ) + { + $article_text = smilies_pass($article_text); + } + } + + // + // Replace naughty words + // + if (count($orig_word)) + { + $article_title = preg_replace($orig_word, $replacement_word, $article_title); + + if ($user_sig != '') + { + $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); + } + + $article_text = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $article_text . '<'), 1, -1)); + } + + // + // Replace newlines (we use this rather than nl2br because + // till recently it wasn't XHTML compliant) + // + if ( $user_sig != '' ) + { + $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig); + } + + $article_text = str_replace("\n", "\n<br />\n", $article_text); + + // Start Page output + $page_title = $lang['kb_viewarticle'] . " : " . $article_title; + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + $template->set_filenames(array( + 'body' => 'kb_viewarticle.tpl') + ); + + create_navigation("viewarticle", array( + 0 => $current_cat['cat_id'], + 1 => $current_cat['cat_title'], + 2 => $current_cat['cat_main'], + 3 => $article['article_id'], + 4 => $article_title) + ); + + $posted_by = sprintf($lang['kb_posted_by'], '<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&u=' . $article['article_author']) . '">' . $article['article_authorname'] . '</a>', create_date($board_config['default_dateformat'], $article['article_time'], $board_config['board_timezone']), create_date($board_config['default_dateformat'], $article['article_edittime'], $board_config['board_timezone'])); + + $template->assign_vars(array( + 'U_VIEW_ARTICLE' => append_sid('kb.' . $phpEx . '?pid=view_article&cid=' . $cid . '&id=' . $article['article_id']), + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE_TEXT' => $article_text, + 'POSTED_BY' => $posted_by, + 'SIGNATURE' => $user_sig) + ); + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; case "ucp": Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/language/lang_english/lang_kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -21,6 +21,7 @@ // Page titles $lang['kb_main'] = "KnowledgeBase Home"; $lang['kb_viewcat'] = "Viewing Category"; +$lang['kb_viewarticle'] = "Viewing Article"; $lang['kb_ucp'] = "KB User Control Panel"; $lang['kb_ucp_articlepost'] = "Post new article"; $lang['kb_ucp_articleedit'] = "Edit article"; @@ -53,4 +54,5 @@ $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; $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_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-12-12 03:04:26
|
Revision: 27 http://svn.sourceforge.net/phpbbkb/?rev=27&view=rev Author: markthedaemon Date: 2006-12-11 19:04:25 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Few changes, nothing major. Added some notes to kb.php as i was reading through it with possible changes. Code looks good thus far, Alpha 1 here we come :-D Modified Paths: -------------- root/kb/constants.php root/kb.php root/language/lang_english/lang_kb.php Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/kb/constants.php 2006-12-12 03:04:25 UTC (rev 27) @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * lang_kb.php + * constants.php * ------------------- * * copyright: phpBB KB Group Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/kb.php 2006-12-12 03:04:25 UTC (rev 27) @@ -150,7 +150,7 @@ $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; if(!$cat_id) { - message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); + message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); // this needs to be in a $lang entry } // Store the main cat in a variable @@ -314,7 +314,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; + $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; //hardcoded PHP extension. $sql = "SELECT username FROM " . USERS_TABLE . " @@ -325,7 +325,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); // hardcoded PHP extension. $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -358,7 +358,7 @@ if(!$cid || !$id) { - message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); + message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); // Hmm, is this a error that is worthy of being a hardcoded one? } $sql = "SELECT a.*, u.* Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-29 23:28:36 UTC (rev 26) +++ root/language/lang_english/lang_kb.php 2006-12-12 03:04:25 UTC (rev 27) @@ -19,7 +19,7 @@ ***************************************************************************/ // Page titles -$lang['kb_main'] = "KnowledgeBase Home"; +$lang['kb_main'] = "Knowledge Base Home"; $lang['kb_viewcat'] = "Viewing Category"; $lang['kb_viewarticle'] = "Viewing Article"; $lang['kb_ucp'] = "KB User Control Panel"; @@ -27,11 +27,11 @@ $lang['kb_ucp_articleedit'] = "Edit article"; // Normal Page -$lang['kb_categories'] = "KnowledgeBase Categories"; +$lang['kb_categories'] = "Knowledge Base Categories"; $lang['kb_articles'] = "Articles"; -$lang['kb_subcats'] = "Subcategories"; -$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. KnowledgeBase won't work before that has been done!"; -$lang['No_kb_cats'] = "No knowledgebase categories has been added."; +$lang['kb_subcats'] = "Sub categories"; +$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; +$lang['No_kb_cats'] = "No knowledge base categories has been added."; $lang['kb_viewcat_subcats'] = "Subcategories in %s"; $lang['kb_last_action'] = "Last action"; @@ -46,7 +46,7 @@ $lang['kb_articlecats'] = "Article Categories"; $lang['kb_articletext'] = "Article Content"; $lang['kb_articledesc_desc'] = "Description of your article, max. 255 characters."; -$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use ctrl + click for multiple."; +$lang['kb_articlecats_desc'] = "Choose what categories your article will appear in, use Ctrl & Click for multiple."; $lang['kb_empty_article'] = "The article content you have submitted was empty."; $lang['kb_empty_article_title'] = "The article title you submitted was empty."; $lang['kb_empty_cats'] = "The article you submitted had no category defined."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-12 22:17:59
|
Revision: 28 http://svn.sourceforge.net/phpbbkb/?rev=28&view=rev Author: softphp Date: 2006-12-12 14:17:54 -0800 (Tue, 12 Dec 2006) Log Message: ----------- - Just some small changes and the introduction of an acp file. I don't know if Prince of PhpBB already has begun his work? If so... commit away! Modified Paths: -------------- root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/admin/ root/admin/admin_kb.php Added: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php (rev 0) +++ root/admin/admin_kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -0,0 +1,49 @@ +<?php +/*************************************************************************** + * admin_kb.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +define('IN_PHPBB', 1); + +if( !empty($setmodules) ) +{ + $file = basename(__FILE__); + $module['KB']['Categories'] = "$file?mode=cats"; + return; +} + +$mode = $HTTP_GET_VARS['mode']; + +switch($mode) +{ + case "articles": + break; + + case "cats": + break; + + case "permissions": // For later use + break; + + case "files": // For later use + break; + + default: // General settings here + break; +} + Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-12 03:04:25 UTC (rev 27) +++ root/kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -150,7 +150,7 @@ $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false; if(!$cat_id) { - message_die(GENERAL_MESSAGE, "The chosen category doesn't exist."); // this needs to be in a $lang entry + message_die(GENERAL_MESSAGE, $lang['kb_cat_noexist']); } // Store the main cat in a variable @@ -211,18 +211,6 @@ $sort = "ORDER BY a.article_edittime DESC"; } - // This has been removed due to probably not working - /* - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE cat_id LIKE '$cat_id' - $sort"; - if( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql); - } - */ - $sql = "SELECT a.* FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_ARTICLES_TABLE . " a WHERE c.cat_id = '$cat_id' @@ -314,7 +302,7 @@ { $authorname = $articles[$i]['article_authorname']; } - $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; //hardcoded PHP extension. + $author = "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>"; $sql = "SELECT username FROM " . USERS_TABLE . " @@ -325,7 +313,7 @@ } $user = $db->sql_fetchrow($result); - $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); // hardcoded PHP extension. + $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile." . $phpEx . "?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone'])); $template->assign_block_vars('switch_articles.articlerow', array( 'TOPIC_FOLDER_IMG' => $images['folder'], @@ -356,11 +344,6 @@ $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); - if(!$cid || !$id) - { - message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); // Hmm, is this a error that is worthy of being a hardcoded one? - } - $sql = "SELECT a.*, u.* FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u WHERE a.article_id = '$id' Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-12 03:04:25 UTC (rev 27) +++ root/language/lang_english/lang_kb.php 2006-12-12 22:17:54 UTC (rev 28) @@ -32,6 +32,7 @@ $lang['kb_subcats'] = "Sub categories"; $lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; $lang['No_kb_cats'] = "No knowledge base categories has been added."; +$lang['kb_cat_noexist'] = "The category you chose does not exist."; $lang['kb_viewcat_subcats'] = "Subcategories in %s"; $lang['kb_last_action'] = "Last action"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-14 00:13:55
|
Revision: 29 http://svn.sourceforge.net/phpbbkb/?rev=29&view=rev Author: softphp Date: 2006-12-13 16:13:52 -0800 (Wed, 13 Dec 2006) Log Message: ----------- -Added acp structure for categories and did a bit of untested code :) Please note that I'm probably restructuring the ucp_class very shortly, so it's not a class, due to several problems I've encountered. Modified Paths: -------------- root/admin/admin_kb.php Added Paths: ----------- root/templates/subSilver/admin/ root/templates/subSilver/admin/kb_editcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-12 22:17:54 UTC (rev 28) +++ root/admin/admin_kb.php 2006-12-14 00:13:52 UTC (rev 29) @@ -27,6 +27,12 @@ return; } +// Get constants and functions +include($phpbb_root_path . "kb/constants." . $phpEx); +include($phpbb_root_path . "kb/functions." . $phpEx); + +// And language +include($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/lang_kb." . $phpEx); $mode = $HTTP_GET_VARS['mode']; switch($mode) @@ -35,6 +41,98 @@ break; case "cats": + $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; + $delete = isset($HTTP_GET_VARS['delete']) ? $HTTP_GET_VARS['delete'] : false; + $add = isset($HTTP_POST_VARS['add']) ? true : false; + $sort = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : false; + + if($edit != false) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = ""; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'CAT_DESC' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + + } + } + + if($delete != false) + { + + } + + if($add) + { + if(!isset($HTTP_POST_VARS['submit'])) + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_addcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_addcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx) + ); + + $template->pparse('body'); + } + else + { + + } + } + + if($sort != false) + { + + } + + // Show categories as list break; case "permissions": // For later use @@ -47,3 +145,26 @@ break; } + +////////////////// +/// FUNCTIONS /// +////////////////// +function generate_cat_parents($selected = false) +{ + global $db; + + $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); + } + + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + } + + $parent = ""; +} +?> Added: root/templates/subSilver/admin/kb_editcat.tpl =================================================================== --- root/templates/subSilver/admin/kb_editcat.tpl (rev 0) +++ root/templates/subSilver/admin/kb_editcat.tpl 2006-12-14 00:13:52 UTC (rev 29) @@ -0,0 +1,29 @@ + +<h1>{L_HEADER}</h1> + +<p>{L_EXPLAIN}</p> + +<form action="{S_FORUM_ACTION}" method="post"> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">{L_CAT_SETTINGS}</th> + </tr> + <tr> + <td class="row1">{L_CAT_TITLE}</td> + <td class="row2"><input type="text" size="25" name="forumname" value="{CAT_TITLE}" class="post" /></td> + </tr> + <tr> + <td class="row1">{L_CAT_DESCRIPTION}</td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="forumdesc" class="post">{DESCRIPTION}</textarea></td> + </tr> + <tr> + <td class="row1">{L_CAT_PARENT}</td> + <td class="row2">{S_PARENT}</td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td> + </tr> + </table> +</form> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-15 14:33:37
|
Revision: 30 http://svn.sourceforge.net/phpbbkb/?rev=30&view=rev Author: softphp Date: 2006-12-15 06:33:32 -0800 (Fri, 15 Dec 2006) Log Message: ----------- -Removed the ucp class and just using functions.php now. Further things added in admin_kb.php. Hoping to work more on it sunday or later tonight. Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php Removed Paths: ------------- root/kb/ucp_class.php Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/admin/admin_kb.php 2006-12-15 14:33:32 UTC (rev 30) @@ -151,9 +151,11 @@ ////////////////// function generate_cat_parents($selected = false) { - global $db; + global $db, $lang; - $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + $sql = "SELECT cat_id, cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); @@ -165,6 +167,36 @@ $cats[] = $row; } - $parent = ""; + if(!$selected) + { + $parent = '<select name="parent">\n<option value="0" selected="selected">' . $lang['kb_main'] . '</option>\n'; + } + else + { + $parent = '<select name="parent">\n<option value="0">' . $lang['kb_main'] . '</option>\n'; + } + + for($i = 0; $i < count($cats); $i++) + { + if(!$selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + if($cats[$i]['cat_id'] == $selected) + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '" selected="selected">' . $cats[$i]['cat_title'] . '</option>\n'; + } + else + { + $parent .= '<option value="' . $cats[$i]['cat_id'] . '">' . $cats[$i]['cat_title'] . '</option>\n'; + } + } + } + + $parent .= "</select>"; + + return $parent; } ?> Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb/functions.php 2006-12-15 14:33:32 UTC (rev 30) @@ -144,10 +144,494 @@ return $cats; } -// These vars we need for making html safe +//////////////////////////////////////// +/// UCP FUNCTIONS /// +//////////////////////////////////////// $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); $html_entities_replace = array('&', '<', '>', '"'); -/* +$unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); +$unhtml_specialchars_replace = array('>', '<', '"', '&'); + +// This is for posting articles, mostly cut out of the posting.php :) +function ucp_article_form($mode, $id, $review) +{ + global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; + + $error_msg = ''; + $user_sig = $userdata['user_sig']; + + if(!empty($HTTP_POST_VARS['post'])) + { + if($mode == 'edit') + { + // Let's get the old article data + $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$article_id'"; + if (!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); + } + + $article = $db->sql_fetchrow($result); + + // if user editing set status = 0, else set status = old status :) + if($userdata['user_id'] == $article_author) + { + $article_status = "0"; + } + else + { + $article_status = $article['article_status']; + } + } + + // Add the new article + // Make all the variables :) + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; + } + + $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; + $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); + $bbcode_uid = ''; + $cat_id = $HTTP_POST_VARS['cats']; + $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; + + prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); + + if ( $error_msg == '' ) + { + $current_time = time(); + + if($mode == 'post') + { + $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES + ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); + } + + $article_id = $db->sql_nextid(); + // Now make the categories + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + $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>'); + } + else + { + if(!$article_id) + { + message_die(GENERAL_ERROR, 'No article to edit.'); + } + + // First update the article table + $sql = "UPDATE " . KB_ARTICLES_TABLE . " + SET article_title = '$article_title', + article_desc = '$article_desc', + article_author = '$article_author', + article_authorname = '$article_authorname', + article_edittime = '$current_time', + article_editby = '" . $userdata['user_id'] . "', + article_status = '$article_status', + enable_sig = '$attach_sig', + enable_html = '$html_on', + enable_bbcode = '$bbcode_on', + enable_smilies = '$smilies_on', + article_text = '$message';"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); + } + + // Now delete all articlecats + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); + } + + // Last add them again doing the loop + foreach($cat_id as $i => $cat) + { + $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; + + if (!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); + } + + if (!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); + } + } + + // Message here somewhere + } + return; + } + } + + $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; + if($mode == "post" && !$preview && $error_msg == '') + { + $article_title = ''; + $article_text = ''; + $article_desc = ''; + $authorname = $userdata['username']; + $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); + $hidden_form_fields = ""; + $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; + + if ( !$board_config['allow_html'] ) + { + $html_on = 0; + } + else + { + $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); + } + + if ( !$board_config['allow_bbcode'] ) + { + $bbcode_on = 0; + } + else + { + $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); + } + + if ( !$board_config['allow_smilies'] ) + { + $smilies_on = 0; + } + else + { + $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); + } + + if($preview) + { + // Do funny preview stuff + } + } + elseif($preview || $error_msg != '') + { + $article_title = $HTTP_POST_VARS['title']; + $article_text = $HTTP_POST_VARS['message']; + $article_desc = $HTTP_POST_VARS['desc']; + $authorname = $HTTP_POST_VARS['authorname']; + + $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; + $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; + $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; + + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + $hidden_form_fields = ""; + if($error_msg != "") + { + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + } + } + else + { + if(empty($id)) + { + message_die(GENERAL_ERROR, "No article defined."); + } + + $sql = "SELECT * + FROM " . KB_ARTICLES_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); + } + + if($db->sql_numrows($result) == 1) + { + $article = $db->sql_fetchrow($result); + } + else + { + message_die(GENERAL_ERROR, "Article does not exist."); + } + + // Now make an array over the cats + $sql = "SELECT cat_id + FROM " . KB_ARTICLECATS_TABLE . " + WHERE article_id = '$id'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); + } + + $article_cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $article_cats[] = $row; + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_desc = $article['article_desc']; + $authorname = $article['article_authorname']; + + $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; + + $html_on = ( $article['enable_html'] ) ? true : false; + $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; + $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="' . $id . '" />'; + } + + if ( $article['bbcode_uid'] != '' ) + { + $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); + } + + $article_text = str_replace('<', '<', $article_text); + $article_text = str_replace('>', '>', $article_text); + $article_text = str_replace('<br />', "\n", $article_text); + + // + // Signature toggle selection + // + if( $user_sig != '' ) + { + $template->assign_block_vars('switch_signature_checkbox', array()); + } + + // + // HTML toggle selection + // + if ( $board_config['allow_html'] ) + { + $html_status = $lang['HTML_is_ON']; + $template->assign_block_vars('switch_html_checkbox', array()); + } + else + { + $html_status = $lang['HTML_is_OFF']; + } + + // + // BBCode toggle selection + // + if ( $board_config['allow_bbcode'] ) + { + $bbcode_status = $lang['BBCode_is_ON']; + $template->assign_block_vars('switch_bbcode_checkbox', array()); + } + else + { + $bbcode_status = $lang['BBCode_is_OFF']; + } + + // Obtain categories structure + $cats = get_cats_structure(); + + // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S + $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; + if($mode == "edit") + { + for($i = 0; $i < count($cats); $i++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $selected = ''; + for($k = 0; $k < count($article_cats); $k++) + { + if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) + { + $selected = ' selected="selected"'; + } + } + $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + else + { + for($i = 0; $i < count($cats); $i++) + { + $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; + + // Sort subcats + for($j = 0; $j < count($cats[$i]['subcats']); $j++) + { + $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; + } + } + } + + // + // Smilies toggle selection + // + if ( $board_config['allow_smilies'] ) + { + $smilies_status = $lang['Smilies_are_ON']; + $template->assign_block_vars('switch_smilies_checkbox', array()); + } + else + { + $smilies_status = $lang['Smilies_are_OFF']; + } + + $template->set_filenames(array( + 'body' => 'kb_article_posting.tpl') + ); + + create_navigation("ucp", $action); + + // This is the template stuff we need no matter what + $template->assign_vars(array( + 'AUTHORNAME' => $authorname, + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE' => $article_text, + 'DESC' => $article_desc, + 'HTML_STATUS' => $html_status, + '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_AUTHORNAME' => $lang['kb_authorname'], + 'L_ARTICLE_NAME' => $lang['kb_articlename'], + 'L_ARTICLE_DESC' => $lang['kb_articledesc'], + 'L_ARTICLE_CATS' => $lang['kb_articlecats'], + 'L_ARTICLE_BODY' => $lang['kb_articletext'], + 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], + 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? + 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], + + 'L_OPTIONS' => $lang['Options'], + 'L_PREVIEW' => $lang['Preview'], + 'L_SUBMIT' => $lang['Submit'], + 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], + 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], + 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], + 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], + + 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], + 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], + 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], + 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], + 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], + 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], + 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], + 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], + 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], + 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], + 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], + 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], + 'L_EMPTY_MESSAGE' => $lang['Empty_message'], + + 'L_FONT_COLOR' => $lang['Font_color'], + 'L_COLOR_DEFAULT' => $lang['color_default'], + 'L_COLOR_DARK_RED' => $lang['color_dark_red'], + 'L_COLOR_RED' => $lang['color_red'], + 'L_COLOR_ORANGE' => $lang['color_orange'], + 'L_COLOR_BROWN' => $lang['color_brown'], + 'L_COLOR_YELLOW' => $lang['color_yellow'], + 'L_COLOR_GREEN' => $lang['color_green'], + 'L_COLOR_OLIVE' => $lang['color_olive'], + 'L_COLOR_CYAN' => $lang['color_cyan'], + 'L_COLOR_BLUE' => $lang['color_blue'], + 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], + 'L_COLOR_INDIGO' => $lang['color_indigo'], + 'L_COLOR_VIOLET' => $lang['color_violet'], + 'L_COLOR_WHITE' => $lang['color_white'], + 'L_COLOR_BLACK' => $lang['color_black'], + + 'L_FONT_SIZE' => $lang['Font_size'], + 'L_FONT_TINY' => $lang['font_tiny'], + 'L_FONT_SMALL' => $lang['font_small'], + 'L_FONT_NORMAL' => $lang['font_normal'], + 'L_FONT_LARGE' => $lang['font_large'], + 'L_FONT_HUGE' => $lang['font_huge'], + + 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], + 'L_STYLES_TIP' => $lang['Styles_tip'], + + 'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', + 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', + 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', + 'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', + 'S_POST_ACTION' => $form_action, + 'CATS_HTML' => $s_cats, + 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) + ); +} + // // Prepare an article for the database // @@ -156,7 +640,6 @@ global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; // Check title - $article_title = "BLABLA"; if (!empty($article_title)) { $article_title = htmlspecialchars(trim($article_title)); @@ -170,7 +653,7 @@ if(!empty($message)) { $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; - $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); + $message = prepare_article_text(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); } else { @@ -188,21 +671,16 @@ } // Check categories - if(is_array($cat_id)) + if(!is_array($cat_id)) { - print_r($cat_id); - $cat_id = implode(",", $cat_id); - } - else - { $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; } return; } -function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) +function prepare_article_text($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) { - global $board_config, $html_entities_match, $html_entities_replace; + global $board_config, $phpEx; // // Clean up the message @@ -223,6 +701,9 @@ $message = ''; + // Include functions_post for clean_html + include($phpbb_root_path . "includes/functions_post." . $phpEx); + foreach ($message_split as $part) { $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); @@ -244,5 +725,9 @@ return $message; } -*/ + +function unprepare_message($message) +{ + return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message); +} ?> \ No newline at end of file Deleted: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb/ucp_class.php 2006-12-15 14:33:32 UTC (rev 30) @@ -1,693 +0,0 @@ -<?php -/*************************************************************************** - * ucp_class.php - * ------------------- - * - * copyright: phpBB KB Group - * site: http://www.phpbbknowledgebase.com - * SF Project Page: http://www.sourceforge.net/projects/phpbbkb - * - ***************************************************************************/ - -/*************************************************************************** - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - ***************************************************************************/ - -if (!defined('IN_PHPBB')) -{ - die('Hacking attempt'); -} - -// This contains the entire ucp class, so it's seperated from the rest of kb.php -class ucp -{ - var $action = ""; - var $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); - var $html_entities_replace = array('&', '<', '>', '"'); - var $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); - var $unhtml_specialchars_replace = array('>', '<', '"', '&'); - - function generate_page($action, $id=0, $preview=false) - { - $this->action = $action; - switch($this->action) - { - case "articles": - break; - - case "comments": - break; - - case "post_article": - $this->article_form("post", false, $preview); - break; - - case "edit_article": - $this->article_form("edit", $id, $preview); - break; - - case "delete_article": - $this->article_delete(); - break; - - case "post_comment": // Only input - break; - - case "edit_comment": - break; - - case "delete_comment": - break; - - default: - break; - } - } - - function generate_page_title($action) - { - global $lang; - - $title = $lang['kb_ucp']; - - switch($action) - { - case "articles": - break; - - case "comments": - break; - - case "post_article": - $title .= ": " . $lang['kb_ucp_articlepost']; - break; - - case "edit_article": - $title .= ": " . $lang['kb_ucp_articleedit']; - break; - - case "delete_article": - - break; - - case "post_comment": // Only input - break; - - case "edit_comment": - break; - - case "delete_comment": - break; - - default: - break; - } - - return $title; - } - - // This is for posting articles, mostly cut out of the posting.php :) - function article_form($mode, $id, $review) - { - global $template, $board_config, $db, $userdata, $lang, $phpbb_root_path, $phpEx, $HTTP_POST_VARS; - - $error_msg = ''; - $user_sig = $userdata['user_sig']; - - if(!empty($HTTP_POST_VARS['post'])) - { - if($mode == 'edit') - { - // Let's get the old article data - $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; - - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$article_id'"; - if (!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); - } - - $article = $db->sql_fetchrow($result); - - // if user editing set status = 0, else set status = old status :) - if($userdata['user_id'] == $article_author) - { - $article_status = "0"; - } - else - { - $article_status = $article['article_status']; - } - } - - // Add the new article - // Make all the variables :) - if ( !$board_config['allow_html'] ) - { - $html_on = 0; - } - else - { - $html_on = ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : 1; - } - - if ( !$board_config['allow_bbcode'] ) - { - $bbcode_on = 0; - } - else - { - $bbcode_on = ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : 1; - } - - if ( !$board_config['allow_smilies'] ) - { - $smilies_on = 0; - } - else - { - $smilies_on = ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : 1; - } - - $article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; - $article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; - $message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; - $article_author = ($mode == 'edit') ? $article['article_author'] : $userdata['user_id']; - $article_authorname = ( $mode == 'edit' ) ? ( ( empty($HTTP_POST_VARS['authorname']) ) ? $article['article_authorname'] : $HTTP_POST_VARS['authorname'] ) : ( ( empty($HTTP_POST_VARS['authorname']) ) ? $userdata['username'] : $HTTP_POST_VARS['authorname'] ); - $bbcode_uid = ''; - $cat_id = $HTTP_POST_VARS['cats']; - $attach_sig = ( !empty($HTTP_POST_VARS['attach_sig']) ) ? 1 : 0; - - $this->prepare_article($bbcode_on, $html_on, $smilies_on, $error_msg, $bbcode_uid, $article_title, $article_desc, $message, $cat_id); - - if ( $error_msg == '' ) - { - $current_time = time(); - - if($mode == 'post') - { - $sql = "INSERT INTO " . KB_ARTICLES_TABLE . " (article_id, article_title, article_desc, article_author, article_authorname, article_time, article_edittime, article_hits, article_editby, article_status, bbcode_uid, enable_sig, enable_html, enable_bbcode, enable_smilies, article_text) VALUES - ('', '$article_title', '$article_desc', '$article_author', '$article_authorname', '$current_time', '$current_time', '0', '" . $userdata['user_id'] . "', '0', '$bbcode_uid', '$attach_sig', '$html_on', '$bbcode_on', '$smilies_on', '$message');"; - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding article', '', __LINE__, __FILE__, $sql); - } - - $article_id = $db->sql_nextid(); - // Now make the categories - foreach($cat_id as $i => $cat) - { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); - } - - if (!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); - } - } - - $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>'); - } - else - { - if(!$article_id) - { - message_die(GENERAL_ERROR, 'No article to edit.'); - } - - // First update the article table - $sql = "UPDATE " . KB_ARTICLES_TABLE . " - SET article_title = '$article_title', - article_desc = '$article_desc', - article_author = '$article_author', - article_authorname = '$article_authorname', - article_edittime = '$current_time', - article_editby = '" . $userdata['user_id'] . "', - article_status = '$article_status', - enable_sig = '$attach_sig', - enable_html = '$html_on', - enable_bbcode = '$bbcode_on', - enable_smilies = '$smilies_on', - article_text = '$message';"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in editing article', '', __LINE__, __FILE__, $sql); - } - - // Now delete all articlecats - $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '$article_id'"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in deleting articlecat entries.', '', __LINE__, __FILE__, $sql); - } - - // Last add them again doing the loop - foreach($cat_id as $i => $cat) - { - $sql = "INSERT INTO " . KB_ARTICLECATS_TABLE . " VALUES ('$article_id', '$cat');\n"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_articles = cat_articles + 1 WHERE cat_id = '$cat';\n"; - - if (!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Error in adding articles categories.', '', __LINE__, __FILE__, $sql); - } - - if (!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, 'Error in adding updating categories articles count.', '', __LINE__, __FILE__, $sql); - } - } - - // Message here somewhere - } - return; - } - } - - $preview = ( !empty($HTTP_POST_VARS['preview']) ) ? true : false; - if($mode == "post" && !$preview && $error_msg == '') - { - $article_title = ''; - $article_text = ''; - $article_desc = ''; - $authorname = $userdata['username']; - $form_action = append_sid('kb.' . $phpEx . '?pid=ucp&action=post_article'); - $hidden_form_fields = ""; - $attach_sig = ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig']; - - if ( !$board_config['allow_html'] ) - { - $html_on = 0; - } - else - { - $html_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] ); - } - - if ( !$board_config['allow_bbcode'] ) - { - $bbcode_on = 0; - } - else - { - $bbcode_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] ); - } - - if ( !$board_config['allow_smilies'] ) - { - $smilies_on = 0; - } - else - { - $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); - } - - if($preview) - { - // Do funny preview stuff - } - } - elseif($preview || $error_msg != '') - { - $article_title = $HTTP_POST_VARS['title']; - $article_text = $HTTP_POST_VARS['message']; - $article_desc = $HTTP_POST_VARS['desc']; - $authorname = $HTTP_POST_VARS['authorname']; - - $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; - - $html_on = ( $HTTP_POST_VARS['disable_html'] ) ? false : true; - $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; - $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; - if($error_msg != "") - { - $template->set_filenames(array( - 'reg_header' => 'error_body.tpl') - ); - $template->assign_vars(array( - 'ERROR_MESSAGE' => $error_msg) - ); - $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); - } - } - else - { - if(empty($id)) - { - message_die(GENERAL_ERROR, "No article defined."); - } - - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); - } - - if($db->sql_numrows($result) == 1) - { - $article = $db->sql_fetchrow($result); - } - else - { - message_die(GENERAL_ERROR, "Article does not exist."); - } - - // Now make an array over the cats - $sql = "SELECT cat_id - FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$id'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); - } - - $article_cats = array(); - while($row = $db->sql_fetchrow($result)) - { - $article_cats[] = $row; - } - - $article_title = $article['article_title']; - $article_text = $article['article_text']; - $article_desc = $article['article_desc']; - $authorname = $article['article_authorname']; - - $attach_sig = ( $article['enable_sig'] ) ? TRUE : 0; - - $html_on = ( $article['enable_html'] ) ? true : false; - $bbcode_on = ( $article['enable_bbcode'] ) ? true : false; - $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="' . $id . '" />'; - } - - if ( $article['bbcode_uid'] != '' ) - { - $article_text = preg_replace('/\:(([a-z0-9]:)?)' . $article['bbcode_uid'] . '/s', '', $article_text); - } - - $article_text = str_replace('<', '<', $article_text); - $article_text = str_replace('>', '>', $article_text); - $article_text = str_replace('<br />', "\n", $article_text); - - // - // Signature toggle selection - // - if( $user_sig != '' ) - { - $template->assign_block_vars('switch_signature_checkbox', array()); - } - - // - // HTML toggle selection - // - if ( $board_config['allow_html'] ) - { - $html_status = $lang['HTML_is_ON']; - $template->assign_block_vars('switch_html_checkbox', array()); - } - else - { - $html_status = $lang['HTML_is_OFF']; - } - - // - // BBCode toggle selection - // - if ( $board_config['allow_bbcode'] ) - { - $bbcode_status = $lang['BBCode_is_ON']; - $template->assign_block_vars('switch_bbcode_checkbox', array()); - } - else - { - $bbcode_status = $lang['BBCode_is_OFF']; - } - - // Obtain categories structure - $cats = get_cats_structure(); - - // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S - $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($mode == "edit") - { - for($i = 0; $i < count($cats); $i++) - { - $selected = ''; - for($k = 0; $k < count($article_cats); $k++) - { - if($article_cats[$k]['cat_id'] == $cats[$i]['cat_id']) - { - $selected = ' selected="selected"'; - } - } - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['cat_id'] . '"> --' . $cats[$i]['cat_title'] . '</option>'; - - // Sort subcats - for($j = 0; $j < count($cats[$i]['subcats']); $j++) - { - $selected = ''; - for($k = 0; $k < count($article_cats); $k++) - { - if($article_cats[$k]['cat_id'] == $cats[$i]['subcats'][$j]['cat_id']) - { - $selected = ' selected="selected"'; - } - } - $s_cats .= '<option' . $selected . ' value="' . $cats[$i]['subcats'][$j]['cat_id'] . '"> --' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; - } - } - } - else - { - for($i = 0; $i < count($cats); $i++) - { - $s_cats .= '<option value="' . $cats[$i]['cat_id'] . '">--' . $cats[$i]['cat_title'] . '</option>'; - - // Sort subcats - for($j = 0; $j < count($cats[$i]['subcats']); $j++) - { - $s_cats .= '<option value="' . $cats[$i]['subcats'][$j]['cat_id'] . '">--' . $cats[$i]['subcats'][$j]['cat_title'] . '</option>'; - } - } - } - - // - // Smilies toggle selection - // - if ( $board_config['allow_smilies'] ) - { - $smilies_status = $lang['Smilies_are_ON']; - $template->assign_block_vars('switch_smilies_checkbox', array()); - } - else - { - $smilies_status = $lang['Smilies_are_OFF']; - } - - $template->set_filenames(array( - 'body' => 'kb_article_posting.tpl') - ); - - create_navigation("ucp", $this->action); - - // This is the template stuff we need no matter what - $template->assign_vars(array( - 'AUTHORNAME' => $authorname, - 'ARTICLE_TITLE' => $article_title, - 'ARTICLE' => $article_text, - 'DESC' => $article_desc, - 'HTML_STATUS' => $html_status, - '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_AUTHORNAME' => $lang['kb_authorname'], - 'L_ARTICLE_NAME' => $lang['kb_articlename'], - 'L_ARTICLE_DESC' => $lang['kb_articledesc'], - 'L_ARTICLE_CATS' => $lang['kb_articlecats'], - 'L_ARTICLE_BODY' => $lang['kb_articletext'], - 'L_AUTHORNAME_DESC' => $lang['kb_authorname_desc'], - 'L_ARTICLEDESC_DESC' => $lang['kb_articledesc_desc'], // Funny one eh? - 'L_ARTICLECATS_DESC' => $lang['kb_articlecats_desc'], - - 'L_OPTIONS' => $lang['Options'], - 'L_PREVIEW' => $lang['Preview'], - 'L_SUBMIT' => $lang['Submit'], - 'L_DISABLE_HTML' => $lang['Disable_HTML_post'], - 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'], - 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'], - 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], - - 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'], - 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'], - 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'], - 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'], - 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'], - 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'], - 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'], - 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'], - 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'], - 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'], - 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'], - 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], - 'L_EMPTY_MESSAGE' => $lang['Empty_message'], - - 'L_FONT_COLOR' => $lang['Font_color'], - 'L_COLOR_DEFAULT' => $lang['color_default'], - 'L_COLOR_DARK_RED' => $lang['color_dark_red'], - 'L_COLOR_RED' => $lang['color_red'], - 'L_COLOR_ORANGE' => $lang['color_orange'], - 'L_COLOR_BROWN' => $lang['color_brown'], - 'L_COLOR_YELLOW' => $lang['color_yellow'], - 'L_COLOR_GREEN' => $lang['color_green'], - 'L_COLOR_OLIVE' => $lang['color_olive'], - 'L_COLOR_CYAN' => $lang['color_cyan'], - 'L_COLOR_BLUE' => $lang['color_blue'], - 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'], - 'L_COLOR_INDIGO' => $lang['color_indigo'], - 'L_COLOR_VIOLET' => $lang['color_violet'], - 'L_COLOR_WHITE' => $lang['color_white'], - 'L_COLOR_BLACK' => $lang['color_black'], - - 'L_FONT_SIZE' => $lang['Font_size'], - 'L_FONT_TINY' => $lang['font_tiny'], - 'L_FONT_SMALL' => $lang['font_small'], - 'L_FONT_NORMAL' => $lang['font_normal'], - 'L_FONT_LARGE' => $lang['font_large'], - 'L_FONT_HUGE' => $lang['font_huge'], - - 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'], - 'L_STYLES_TIP' => $lang['Styles_tip'], - - 'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', - 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', - 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', - 'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', - 'S_POST_ACTION' => $form_action, - 'CATS_HTML' => $s_cats, - 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) - ); - } - - // - // Prepare an article for the database - // - function prepare_article(&$bbcode_on, &$html_on, &$smilies_on, &$error_msg, &$bbcode_uid, &$article_title, &$article_desc, &$message, &$cat_id) - { - global $board_config, $userdata, $lang, $phpEx, $phpbb_root_path; - - // Check title - if (!empty($article_title)) - { - $article_title = htmlspecialchars(trim($article_title)); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_title'] : $lang['kb_empty_article_title']; - } - - // Check message - if(!empty($message)) - { - $bbcode_uid = ($bbcode_on) ? make_bbcode_uid() : ''; - $message = $this->prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article'] : $lang['kb_empty_article']; - } - - // Check Desc - if (!empty($article_desc)) - { - $article_desc = htmlspecialchars(trim($article_desc)); - } - else - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_article_desc'] : $lang['kb_empty_article_desc']; - } - - // Check categories - if(!is_array($cat_id)) - { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kb_empty_cats'] : $lang['kb_empty_cats']; - } - return; - } - - function prepare_message($message, $html_on, $bbcode_on, $smile_on, $bbcode_uid = 0) - { - global $board_config, $phpEx; - - // - // Clean up the message - // - $message = trim($message); - - if ($html_on) - { - // If HTML is on, we try to make it safe - // This approach is quite agressive and anything that does not look like a valid tag - // is going to get converted to HTML entities - $message = stripslashes($message); - $html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#'; - $matches = array(); - - $message_split = preg_split($html_match, $message); - preg_match_all($html_match, $message, $matches); - - $message = ''; - - // Include functions_post for clean_html - include($phpbb_root_path . "includes/functions_post." . $phpEx); - - foreach ($message_split as $part) - { - $tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2])); - $message .= preg_replace($this->html_entities_match, $this->html_entities_replace, $part) . clean_html($tag); - } - - $message = addslashes($message); - $message = str_replace('"', '\"', $message); - } - else - { - $message = preg_replace($this->html_entities_match, $this->html_entities_replace, $message); - } - - if($bbcode_on && $bbcode_uid != '') - { - $message = bbencode_first_pass($message, $bbcode_uid); - } - - return $message; - } - - function unprepare_message($message) - { - return preg_replace($this->unhtml_specialchars_match, $this->unhtml_specialchars_replace, $message); - } -} -?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-14 00:13:52 UTC (rev 29) +++ root/kb.php 2006-12-15 14:33:32 UTC (rev 30) @@ -502,7 +502,7 @@ case "ucp": $action = ( isset($HTTP_GET_VARS['action']) ) ? $HTTP_GET_VARS['action'] : ""; - include($phpbb_root_path . "kb/ucp_class." . $phpEx); + /*include($phpbb_root_path . "kb/ucp_class." . $phpEx); $ucp = new ucp; // Start Page output @@ -510,7 +510,47 @@ include($phpbb_root_path . 'includes/page_header.' . $phpEx); $ucp->generate_page($action, $HTTP_GET_VARS['id'], $HTTP_GET_VARS['preview']); + */ + // The above have been removed and changed to functions.php + $id = isset($HTTP_GET_VARS['id']) ? $HTTP_GET_VARS['id'] : 0; + $preview = isset($HTTP_POST_VARS['preview']) ? true : false; + $page_title = ucp_generate_page_title($action); + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + ucp_article_form("post", false, $preview); + break; + + case "edit_article": + ucp_article_form("edit", $id, $preview); + break; + + case "delete_article": + ucp_article_delete(); + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + // // Generate the page // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-16 00:23:57
|
Revision: 31 http://svn.sourceforge.net/phpbbkb/?rev=31&view=rev Author: softphp Date: 2006-12-15 16:23:56 -0800 (Fri, 15 Dec 2006) Log Message: ----------- - Added some sorting code, and finished editing and adding categories, all needs testing of course. Modified Paths: -------------- root/admin/admin_kb.php root/templates/subSilver/admin/kb_editcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-15 14:33:32 UTC (rev 30) +++ root/admin/admin_kb.php 2006-12-16 00:23:56 UTC (rev 31) @@ -50,7 +50,9 @@ { if(!isset($HTTP_POST_VARS['submit'])) { - $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $edit . "'"; + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); @@ -62,7 +64,7 @@ ); $parent = generate_cat_parents($cat['cat_main']); - $s_hidden_fields = ""; + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; $template->assign_vars(array( 'L_HEADER' => $lang['kbadm_header_editcat'], @@ -85,7 +87,88 @@ } else { + $error_msg = ''; + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $sql = "SELECT * + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $edit . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get category from categories table", "", __LINE__, __FILE__, $sql); + } + $cat = $db->sql_fetchrow($result); + + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = "<input type=\"hidden\" name=\"oldparent\" value=\"" . $cat['cat_main'] . "\">"; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'CAT_TITLE' => $cat['cat_title'], + 'CAT_DESC' => $cat['cat_desc'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_main = '" . $parent . "', + cat_title = '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', + cat_desc = '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "' + WHERE cat_id = '" . $edit . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't edit category.", "", __LINE__, __FILE__, $sql); + } + + if($HTTP_POST_VARS['oldparent'] != $HTTP_POST_VARS['parent']) + { + // Parent category changed, alter the order + sort_cats("edit", $edit, 0, array(0 => $HTTP_POST_VARS['parent'], 1 => $HTTP_POST_VARS['oldparent'])); + } + + // And a message here somewhere + } } } @@ -123,13 +206,80 @@ } else { + $error_msg = ''; + if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") + { + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + } + + if($error_msg != '') + { + $template->set_filenames(array( + 'body' => 'admin/kb_editcat.tpl') + ); + + $parent = generate_cat_parents($cat['cat_main']); + $s_hidden_fields = ""; + + $template->set_filenames(array( + 'reg_header' => 'error_body.tpl') + ); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $error_msg) + ); + + $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); + + $template->assign_vars(array( + 'L_HEADER' => $lang['kbadm_header_editcat'], + 'L_EXPLAIN' => $lang['kbadm_explain_editcat'], + 'L_CAT_SETTINGS' => $lang['kbadm_cat_settings'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + ); + + $template->pparse('body'); + } + else + { + $parent = isset($HTTP_POST_VARS['parent']) ? $HTTP_POST_VARS['parent'] : 0; + + $sql = "INSERT INTO " . KB_CATEGORIES_TABLE . " (cat_id, cat_main, cat_title, cat_desc, cat_articles, cat_order) + VALUES ('', '" . $parent . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['title'])) . "', '" . trim(htmlspecialchars($HTTP_POST_VARS['desc'])) . "', '0', '9999');"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't insert new category.", "", __LINE__, __FILE__, $sql); + } + + sort_cats("add", $db->sql_nextid(), 0, $parent); + + // And a message here somewhere + } } } if($sort != false) { + $sort = explode("|", $sort); + // ok so ?sort=id|up(1)/down(-1) + sort_cats("", $sort[0], $sort[1]); + + // And yes yet another message here } // Show categories as list @@ -199,4 +349,89 @@ return $parent; } + +function sort_cats($type = "", $id = 0, $dir = 0, $level = 0) +{ + if($type == "add") + { + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number + 1 . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + elseif($type == "edit") + { + // First clean up in the old level where it is gone from + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[1] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $sql = ""; + $i = 0; + while($old_cat = $db->sql_fetchrow($result)) + { + $i++; + $sql .= "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $i . "' + WHERE cat_id = '" . $old_cat['cat_id'] . "';\n"; + } + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); + } + + // Ok insert it in the back of the new one :) + $sql = "SELECT cat_id + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_main = '" . $level[0] . "' + ORDER BY cat_order ASC"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve order data from cat table.", "", __LINE__, __FILE__, $sql); + } + + $cat_number = $db->sql_numrows($result); + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number + 1 . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + + return; + } + else + { + return; + } +} ?> Modified: root/templates/subSilver/admin/kb_editcat.tpl =================================================================== --- root/templates/subSilver/admin/kb_editcat.tpl 2006-12-15 14:33:32 UTC (rev 30) +++ root/templates/subSilver/admin/kb_editcat.tpl 2006-12-16 00:23:56 UTC (rev 31) @@ -3,6 +3,7 @@ <p>{L_EXPLAIN}</p> +{ERROR_BOX} <form action="{S_FORUM_ACTION}" method="post"> <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> <tr> @@ -10,11 +11,11 @@ </tr> <tr> <td class="row1">{L_CAT_TITLE}</td> - <td class="row2"><input type="text" size="25" name="forumname" value="{CAT_TITLE}" class="post" /></td> + <td class="row2"><input type="text" size="25" name="title" value="{CAT_TITLE}" class="post" /></td> </tr> <tr> <td class="row1">{L_CAT_DESCRIPTION}</td> - <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="forumdesc" class="post">{DESCRIPTION}</textarea></td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="desc" class="post">{DESCRIPTION}</textarea></td> </tr> <tr> <td class="row1">{L_CAT_PARENT}</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-19 20:14:57
|
Revision: 32 http://svn.sourceforge.net/phpbbkb/?rev=32&view=rev Author: softphp Date: 2006-12-19 12:14:53 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php root/kb_install.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/kb/auth.php Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/admin/admin_kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -37,8 +37,12 @@ switch($mode) { + /* + NOTE: All article editing, deleting, approving and so on will be featured in the ucp for the admin as well, + might integrate it here later but i like it better in ucp. case "articles": break; + */ case "cats": $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; @@ -91,12 +95,12 @@ if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; } if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; } if($error_msg != '') @@ -168,13 +172,63 @@ } // And a message here somewhere + $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } } } if($delete != false) { + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + if(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $delete . '" />'; + $l_confirm = $lang['kbadm_confirm_deletecat']; + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?delete=true"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + } + elseif($confirm) // Double check user confirmed + { + $cat_id = $HTTP_POST_VARS['cat_id']; + + // Need lang vars for the errors? + $sql = "DELETE FROM " . KB_CATEGORIES_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from categories table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? + message_die(GENERAL_MESSAGE, $message); + } } if($add) @@ -210,12 +264,12 @@ if(!isset($HTTP_POST_VARS['title']) || $HTTP_POST_VARS['title'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_title'] : $lang['admkb_empty_cat_title']; } if(!isset($HTTP_POST_VARS['desc']) || $HTTP_POST_VARS['desc'] == "") { - $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['admkb_empty_cat_title'] : $lang['admkb_empty_cat_title']; + $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['kbadm_empty_cat_desc'] : $lang['admkb_empty_cat_title']; } if($error_msg != '') @@ -245,7 +299,7 @@ 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], - 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) @@ -268,6 +322,9 @@ sort_cats("add", $db->sql_nextid(), 0, $parent); // And a message here somewhere + $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } } } @@ -276,16 +333,19 @@ { $sort = explode("|", $sort); - // ok so ?sort=id|up(1)/down(-1) - sort_cats("", $sort[0], $sort[1]); + // ok so ?sort=id|id2|up/down + sort_cats("", $sort[0], $sort[2], $sort[1]); // Put id2 in the level argument, nvm that :) // And yes yet another message here + $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + + message_die(GENERAL_MESSAGE, $message); } // Show categories as list break; - case "permissions": // For later use + case "auth": // For later use break; case "files": // For later use @@ -431,6 +491,34 @@ } else { + if($dir == "up") + { + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order - 1 + WHERE cat_id = '" . $id . "'; + UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order + 1 + WHERE cat_id = '" . $dir . "';"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + } + elseif($dir == "down") + { + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order + 1 + WHERE cat_id = '" . $id . "'; + UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = cat_order - 1 + WHERE cat_id = '" . $dir . "';"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } + } return; } } Added: root/kb/auth.php =================================================================== --- root/kb/auth.php (rev 0) +++ root/kb/auth.php 2006-12-19 20:14:53 UTC (rev 32) @@ -0,0 +1,28 @@ +<?php +/*************************************************************************** + * auth.php + * ------------------- + * + * copyright: phpBB KB Group + * site: http://www.phpbbknowledgebase.com + * SF Project Page: http://www.sourceforge.net/projects/phpbbkb + * + ***************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +// This file holds the kb_auth functions, very similar to the phpBB auth functions, but differs certain places :) +function kb_auth($type, $cat_id, $userdata) +{ + + return $auth; +} + +?> Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb/functions.php 2006-12-19 20:14:53 UTC (rev 32) @@ -632,6 +632,57 @@ ); } +// Delete an article +function ucp_article_delete($id, $confirm) +{ + global $lang, $db, $phpEx, $template; + + if(!$confirm) + { + $s_hidden_fields = '<input type="hidden" name="article_id" value="' . $id . '" />'; + $l_confirm = $lang['kb_confirm_deletearticle']; + + // + // Output confirmation page + // + $template->set_filenames(array( + 'confirm_body' => 'confirm_body.tpl') + ); + + $template->assign_vars(array( + 'MESSAGE_TITLE' => $lang['Information'], + 'MESSAGE_TEXT' => $l_confirm, + + 'L_YES' => $lang['Yes'], + 'L_NO' => $lang['No'], + + 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete"), + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $template->pparse('confirm_body'); + } + elseif($confirm) // Double check they actually confirmed + { + $article_id = $HTTP_POST_VARS['article_id']; + + // Need lang vars for the error messages? + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articles table.", "", __LINE__, __FILE__, $sql); + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE article_id = '" . $article_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete article from articlecats table.", "", __LINE__, __FILE__, $sql); + } + + // Message + } +} + // // Prepare an article for the database // Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -535,7 +535,8 @@ break; case "delete_article": - ucp_article_delete(); + $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; + ucp_article_delete($id, $confirm); break; case "post_comment": // Only input Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/kb_install.php 2006-12-19 20:14:53 UTC (rev 32) @@ -85,6 +85,23 @@ cat_id mediumint(8) NOT NULL DEFAULT '0' )"; +$sql[] = "CREATE TABLE " . $table_prefix . "kb_auth_access ( + `group_id` mediumint(8) NOT NULL default '0', + `cat_id` smallint(5) unsigned NOT NULL default '0', + `auth_view` tinyint(1) NOT NULL default '0', + `auth_add` tinyint(1) NOT NULL default '0', + `auth_edit` tinyint(1) NOT NULL default '0', + `auth_delete` tinyint(1) NOT NULL default '0', + `auth_mod` tinyint(1) NOT NULL default '0', + `auth_comment` tinyint(1) NOT NULL default '0', + `auth_rate` tinyint(1) NOT NULL default '0', + `auth_a` tinyint(1) NOT NULL default '0', + `auth_attachments` tinyint(1) NOT NULL default '0', + KEY `group_id` (`group_id`), + KEY `cat_id` (`cat_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +)"; + echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; echo '<tr><th>Updating the database</th></tr>'; Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-16 00:23:56 UTC (rev 31) +++ root/language/lang_english/lang_kb.php 2006-12-19 20:14:53 UTC (rev 32) @@ -56,4 +56,24 @@ $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_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; + +// Admin +$lang['kbadm_header_editcat'] +$lang['kbadm_explain_editcat'] +$lang['kbadm_cat_settings'] +$lang['kbadm_cat_title'] +$lang['kbadm_cat_desc'] +$lang['kbadm_cat_parent'] +$lang['kbadm_empty_cat_title'] +$lang['kbadm_empty_cat_desc'] +$lang['kbadm_confirm_deletecat'] +$lang['kbadm_Click_return_catadmin'] +$lang['kbadm_header_addcat'] +$lang['kbadm_explain_addcat'] +$lang['kbadm_addcat'] + +$lang['kbadm_delcat_success'] +$lang['kbadm_editcat_success'] +$lang['kbadm_addcat_success'] +$lang['kbadm_sortcat_success'] ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-28 01:47:25
|
Revision: 33 http://svn.sourceforge.net/phpbbkb/?rev=33&view=rev Author: softphp Date: 2006-12-27 17:47:23 -0800 (Wed, 27 Dec 2006) Log Message: ----------- - Introduced the auth system, haven't implemented it completely into the kb.php, but I'm working on it, still waiting to be tested. Along with the admin panel and a lot of other stuff. Modified Paths: -------------- root/kb/auth.php root/kb/constants.php root/kb.php root/kb_install.php Modified: root/kb/auth.php =================================================================== --- root/kb/auth.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb/auth.php 2006-12-28 01:47:23 UTC (rev 33) @@ -18,10 +18,170 @@ * ***************************************************************************/ -// This file holds the kb_auth functions, very similar to the phpBB auth functions, but differs certain places :) +// This file holds the kb auth functions, very similar to the phpBB auth functions, but differs certain places :) +// As of now, the articles auth is handles out from which category it is selected through, therefore an article +// can have different kinds of auth, all depending on through which category it is viewed. This solution might seem +// stupid, but it is the best I can come up with, and I think admins will just take that into consideration when creating +// category permissions. + +// +// This function returns info on whether the user is allowed to do the supplied argument(s) all dependant on the given category id +// function kb_auth($type, $cat_id, $userdata) { + switch($type) + { + case "view": + $sql = "a.auth_view"; + $auth_fields = array('auth_view'); + break; + + case "add": + $sql = "a.auth_add"; + $auth_fields = array('auth_add'); + break; + + case "edit": + $sql = "a.auth_edit"; + $auth_fields = array('auth_edit'); + break; + + case "delete": + $sql = "a.auth_delete"; + $auth_fields = array('auth_delete'); + break; + + case "mod": + $sql = "a.auth_mod"; + $auth_fields = array('auth_mod'); + break; + + case "comment": + $sql = "a.auth_comment"; + $auth_fields = array('auth_comment'); + break; + + case "rate": + $sql = "a.auth_rate"; + $auth_fields = array('auth_rate'); + break; + + case "attach": + $sql = "a.auth_attach"; + $auth_fields = array('auth_attach'); + break; + + // Returns array containing everything above + case "all": + $sql = "a.auth_view, a.auth_add, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate', 'auth_attach'); + break; + + // Returns array containing article related auth + case "article": + $sql = "a.auth_view, a.auth_edit, a.auth_delete, a.auth_mod, a.auth_comment, a.auth_rate"; + $auth_fields = array('auth_view', 'auth_edit', 'auth_delete', 'auth_mod', 'auth_comment', 'auth_rate'); + break; + + // Returns array containing category related auth + case "cat": + $sql = "a.auth_view, a.auth_add, a.auth_attach"; + $auth_fields = array('auth_view', 'auth_add', 'auth_attach'); + break; + } + $sql = "SELECT a.cat_id, $sql + FROM " . KB_CATEGORIES_TABLE . " a + WHERE a.cat_id = '" . $cat_id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_MESSAGE, 'Could not retrieve categorys auth info.', '', __LINE__, __FILE__, $sql); + } + + $f_access = $db->sql_fetchrow($result); + + // + // If user is logged in we need to see if he is in any usergroups that changes his auth info, else just return it + // + if($userdata['session_logged_in']) + { + // Check if the user is present in a group that changes his permissions + $sql = "SELECT a.cat_id, $sql, a.auth_mod + FROM " . KB_AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug + WHERE ug.user_id = ".$userdata['user_id']. " + AND ug.user_pending = 0 + AND a.group_id = ug.group_id + AND a.cat_id = '" . $cat_id . "'"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Failed obtaining category access control lists', '', __LINE__, __FILE__, $sql); + } + + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $u_access[] = $row; + } + while( $row = $db->sql_fetchrow($result) ); + } + $db->sql_freeresult($result); + } + + $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; + + $auth = array(); + for($i = 0; $i < count($auth_fields); $i++) + { + $key = $auth_fields[$i]; + + // + // If the user is logged on and the forum type is either ALL or REG then the user has access + // + // If the type if ACL, MOD or ADMIN then we need to see if the user has specific permissions + // to do whatever it is they want to do ... to do this we pull relevant information for the + // user (and any groups they belong to) + // + // Now we compare the users access level against the forums. We assume here that a moderator + // and admin automatically have access to an ACL forum, similarly we assume admins meet an + // auth requirement of MOD + // + $value = $f_access[$key]; + + switch( $value ) + { + case AUTH_ALL: + $auth[$key] = TRUE; + $auth[$key . '_type'] = $lang['Auth_Anonymous_Users']; + break; + + case AUTH_REG: + $auth_user[$key] = ( $userdata['session_logged_in'] ) ? TRUE : 0; + $auth_user[$key . '_type'] = $lang['Auth_Registered_Users']; + break; + + case AUTH_ACL: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_ACL, $key, $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Users_granted_access']; + break; + + case AUTH_MOD: + $auth[$key] = ( $userdata['session_logged_in'] ) ? auth_check_user(AUTH_MOD, 'auth_mod', $u_access, $is_admin) : 0; + $auth[$key . '_type'] = $lang['Auth_Moderators']; + break; + + case AUTH_ADMIN: + $auth[$key] = $is_admin; + $auth[$key . '_type'] = $lang['Auth_Administrators']; + break; + + default: + $auth[$key] = 0; + break; + } + } + return $auth; } Modified: root/kb/constants.php =================================================================== --- root/kb/constants.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb/constants.php 2006-12-28 01:47:23 UTC (rev 33) @@ -28,5 +28,6 @@ define('KB_CATEGORIES_TABLE', $table_prefix . "kb_categories"); define('KB_ARTICLES_TABLE', $table_prefix . "kb_articles"); define('KB_ARTICLECATS_TABLE', $table_prefix . "kb_articlecats"); // For Multiple cats +define('KB_AUTH_ACCESS', $table_prefix . "kb_auth_access"); ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb.php 2006-12-28 01:47:23 UTC (rev 33) @@ -88,51 +88,61 @@ { for($i = 0; $i < $total_catrows; $i++) { - // Ok display one cat here - $template->assign_block_vars('catrow', array( - 'CAT_TITLE' => $catrows[$i]['cat_title'], - 'CAT_DESC' => $catrows[$i]['cat_desc'], - 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], - 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), - 'L_SUBCATS' => $lang['kb_subcats'], - 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D - ); + $auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); - // Now let's look at subcats - $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order - FROM " . KB_CATEGORIES_TABLE . " c - WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' - ORDER BY c.cat_order"; - if( !($result = $db->sql_query($sql)) ) + if($auth['auth_view']) { - message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); - } - - $subcats = array(); - while ($row = $db->sql_fetchrow($result)) - { - $subcats[] = $row; - } - - if($total_subcats = count($subcats)) - { - // Contains subcats, show them - $template->assign_block_vars('catrow.switch_subcats', array()); + // Ok display one cat here + $template->assign_block_vars('catrow', array( + 'CAT_TITLE' => $catrows[$i]['cat_title'], + 'CAT_DESC' => $catrows[$i]['cat_desc'], + 'CAT_ARTICLES' => $catrows[$i]['cat_articles'], + 'U_VIEWCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $catrows[$i]['cat_id']), + 'L_SUBCATS' => $lang['kb_subcats'], + 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D + ); - for($j = 0; $j < $total_subcats; $j++) + // Now let's look at subcats + $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order + FROM " . KB_CATEGORIES_TABLE . " c + WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' + ORDER BY c.cat_order"; + if( !($result = $db->sql_query($sql)) ) { - // Show the subcat - $k = $j + 1; - $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; - $template->assign_block_vars('catrow.subcatrow', array( - 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), - 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], - 'SUBCAT_COMMA' => $subcat_comma) - ); + message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); + } + + $subcats = array(); + while ($row = $db->sql_fetchrow($result)) + { + $subcats[] = $row; } - } - } - } + + if($total_subcats = count($subcats)) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcats', array()); + + for($j = 0; $j < $total_subcats; $j++) + { + $auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + + if($auth['auth_view']) + { + // Show the subcat + $k = $j + 1; + $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; + $template->assign_block_vars('catrow.subcatrow', array( + 'U_SUBCAT' => append_sid("kb." . $phpEx . "?pid=view_cat&id=" . $subcats[$j]['cat_id']), + 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], + 'SUBCAT_COMMA' => $subcat_comma) + ); + } // if auth view + } // for subcats + } // if subcats + } // auth view + } // for cats + }// total cats else { message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); @@ -367,6 +377,7 @@ // // These vars are for later use // + $in_cat = false; $cats = array(); while($row = $db->sql_fetchrow($result)) { @@ -374,12 +385,21 @@ if($row['cat_id'] == $cid) { + $in_cat = true; $current_cat['cat_title'] = $row['cat_title']; $current_cat['cat_id'] = $row['cat_id']; $current_cat['cat_main'] = $row['cat_main']; } } + // + // Check that the given category is true + // + if(!$in_cat) + { + message_die(GENERAL_MESSAGE, "The category specified in GET variables did not exist along with this article in the database."); + } + $article_title = $article['article_title']; $article_text = $article['article_text']; $article_bbcode_uid = $article['bbcode_uid']; Modified: root/kb_install.php =================================================================== --- root/kb_install.php 2006-12-19 20:14:53 UTC (rev 32) +++ root/kb_install.php 2006-12-28 01:47:23 UTC (rev 33) @@ -56,6 +56,14 @@ cat_desc varchar(255) NOT NULL, cat_articles mediumint(8) UNSIGNED DEFAULT '0', cat_order mediumint(8) UNSIGNED NOT NULL, + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', PRIMARY KEY (cat_id), KEY cat_order (cat_order) )"; @@ -86,20 +94,18 @@ )"; $sql[] = "CREATE TABLE " . $table_prefix . "kb_auth_access ( - `group_id` mediumint(8) NOT NULL default '0', - `cat_id` smallint(5) unsigned NOT NULL default '0', - `auth_view` tinyint(1) NOT NULL default '0', - `auth_add` tinyint(1) NOT NULL default '0', - `auth_edit` tinyint(1) NOT NULL default '0', - `auth_delete` tinyint(1) NOT NULL default '0', - `auth_mod` tinyint(1) NOT NULL default '0', - `auth_comment` tinyint(1) NOT NULL default '0', - `auth_rate` tinyint(1) NOT NULL default '0', - `auth_a` tinyint(1) NOT NULL default '0', - `auth_attachments` tinyint(1) NOT NULL default '0', - KEY `group_id` (`group_id`), - KEY `cat_id` (`cat_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + group_id mediumint(8) NOT NULL default '0', + cat_id smallint(5) unsigned NOT NULL default '0', + auth_view tinyint(1) NOT NULL default '0', + auth_add tinyint(1) NOT NULL default '0', + auth_edit tinyint(1) NOT NULL default '0', + auth_delete tinyint(1) NOT NULL default '0', + auth_mod tinyint(1) NOT NULL default '0', + auth_comment tinyint(1) NOT NULL default '0', + auth_rate tinyint(1) NOT NULL default '0', + auth_attach tinyint(1) NOT NULL default '0', + KEY group_id (group_id), + KEY cat_id (cat_id) )"; echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-12-29 23:45:12
|
Revision: 34 http://svn.sourceforge.net/phpbbkb/?rev=34&view=rev Author: softphp Date: 2006-12-29 15:45:05 -0800 (Fri, 29 Dec 2006) Log Message: ----------- - Added more to the acp, still buggy though, especially the sort function - Gotta fix some bbcode, some links here and there, need a native englishman to look the lang vars over and we're ready to go alpha. Modified Paths: -------------- install.xml root/admin/admin_kb.php root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/templates/subSilver/admin/kb_cats.tpl Modified: install.xml =================================================================== --- install.xml 2006-12-28 01:47:23 UTC (rev 33) +++ install.xml 2006-12-29 23:45:05 UTC (rev 34) @@ -41,6 +41,13 @@ <username>ToonArmy</username> <contributions /> </author> + <author> + <realname>Andreas Nielsen</realname> + <email>Lor...@ho...</email> + <username>Imladris</username> + <homepage>http://blog.softphp.dk</homepage> + <contributions /> + </author> </author-group> <mod-version> <major>0</major> @@ -58,5 +65,17 @@ </installation> <meta name="generator" content="Phpbb.ModTeam.Tools (c#)" /> </header> - <action-group /> + <action-group> + <open src="language/lang_english/lang_admin.php"> + <edit> + <find>// +// That's all Folks! +// ------------------------------------------------- + +?></find> + <action type="before-add">$lang['KB'] = "Knowledge Base"; +$lang['Categories'] = "Category Management";</action> + </edit> + </open> + </action-group> </mod> \ No newline at end of file Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/admin/admin_kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -27,6 +27,10 @@ return; } +$phpbb_root_path = "./../"; +require($phpbb_root_path . 'extension.inc'); +require('./pagestart.' . $phpEx); + // Get constants and functions include($phpbb_root_path . "kb/constants." . $phpEx); include($phpbb_root_path . "kb/functions." . $phpEx); @@ -79,15 +83,18 @@ 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], 'CAT_TITLE' => $cat['cat_title'], - 'CAT_DESC' => $cat['cat_desc'], + 'DESCRIPTION' => $cat['cat_desc'], 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -140,15 +147,18 @@ 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], 'CAT_TITLE' => $cat['cat_title'], - 'CAT_DESC' => $cat['cat_desc'], + 'DESCRIPTION' => $cat['cat_desc'], 'S_SUBMIT_VALUE' => $lang['kbadm_editcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -172,7 +182,7 @@ } // And a message here somewhere - $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_editcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } @@ -201,11 +211,14 @@ 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], - 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?delete=true"), + 'S_CONFIRM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=true"), 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); $template->pparse('confirm_body'); + + include('./page_footer_admin.'.$phpEx); + exit; } elseif($confirm) // Double check user confirmed { @@ -224,7 +237,7 @@ message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); } - $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? message_die(GENERAL_MESSAGE, $message); @@ -253,10 +266,13 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "mode=cats")) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -299,13 +315,19 @@ 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + 'CAT_TITLE' => $HTTP_POST_VARS['title'], + 'DESCRIPTION' => $HTTP_POST_VARS['desc'], + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?edit=" . $edit) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) ); $template->pparse('body'); + + include('./page_footer_admin.'.$phpEx); + exit; } else { @@ -322,7 +344,7 @@ sort_cats("add", $db->sql_nextid(), 0, $parent); // And a message here somewhere - $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_addcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } @@ -333,16 +355,103 @@ { $sort = explode("|", $sort); - // ok so ?sort=id|id2|up/down - sort_cats("", $sort[0], $sort[2], $sort[1]); // Put id2 in the level argument, nvm that :) + // ok so ?sort=id,id2|up/down|level + sort_cats("", $sort[0], $sort[1], $sort[2]); // Put id2 in the level argument, nvm that :) // And yes yet another message here - $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx) . '?mode=cats">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message = $lang['kbadm_sortcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } // Show categories as list + $cats = get_cats_structure(); + + $template->set_filenames(array( + 'body' => 'admin/kb_cats.tpl') + ); + + $template->assign_vars(array( + 'L_CATEGORIES' => $lang['kb_categories'], + 'L_EDITCAT' => $lang['kbadm_editcat'], + 'L_MOVECAT_UP' => $lang['kbadm_movecatup'], + 'L_MOVECAT_DOWN' => $lang['kbadm_movecatdown'], + 'L_DELCAT' => $lang['kbadm_delcat'], + 'L_HEADER' => $lang['Categories'], + 'L_EXPLAIN' => $lang['kbadm_maincat_explain']) + ); + + if($total_catrows = count($cats)) + { + for($i = 0; $i < $total_catrows; $i++) + { + //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Ok display one cat here + $template->assign_block_vars('catrow', array( + // Name 'nd stuff + 'CAT_TITLE' => $cats[$i]['cat_title'], + 'CAT_DESC' => $cats[$i]['cat_desc'], + + // Links + 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), + 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), + // sort=id,id2|up/down|level + 'U_MOVECAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i - 1]['cat_id'] . "|up|" . $cats[$i]['cat_main']), + 'U_MOVECAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i + 1]['cat_id'] . "|down|" . $cats[$i]['cat_main']), + + // Image + 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D + ); + + if($total_subcats = count($cats[$i]['subcats'])) + { + // Contains subcats, show them + $template->assign_block_vars('catrow.switch_subcat', array( + 'L_SUBCATS' => $lang['kb_subcats']) + ); + + for($j = 0; $j < $total_subcats; $j++) + { + //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + + // auth not included in alpha + //if($auth['auth_view']) + //{ + // Show the subcat + $template->assign_block_vars('catrow.subcatrow', array( + 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], + 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], + + // Links + 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), + 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), + // sort=id,id2|up/down|level + 'U_MOVESUBCAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j - 1]['cat_id'] . "|up|" . $cats[$i]['subcats'][$j]['cat_main']), + 'U_MOVESUBCAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j + 1]['cat_id'] . "|down|" . $cats[$i]['subcats'][$j]['cat_main']), + + 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D + ); + //} // if auth view + } // for subcats + + $template->assign_block_vars('catrow.switch_subcat_close', array()); + } // if subcats + //} // auth view + } // for cats + + $template->pparse('body'); + }// total cats + else + { + message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + } + + include('./page_footer_admin.'.$phpEx); + exit; break; case "auth": // For later use @@ -412,6 +521,8 @@ function sort_cats($type = "", $id = 0, $dir = 0, $level = 0) { + global $db; + if($type == "add") { $sql = "SELECT cat_id @@ -493,31 +604,49 @@ { if($dir == "up") { + $ids = explode(",", $id); + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order - 1 - WHERE cat_id = '" . $id . "'; - UPDATE " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $ids[0] . "';"; + + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order + 1 - WHERE cat_id = '" . $dir . "';"; + WHERE cat_id = '" . $ids[1] . "' + AND cat_main = '" . $level . "';"; // to ensure they are in the same level. if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); } + + if(!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } } elseif($dir == "down") { + $ids = explode(",", $id); + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order + 1 - WHERE cat_id = '" . $id . "'; - UPDATE " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $ids[0] . "';"; + + $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = cat_order - 1 - WHERE cat_id = '" . $dir . "';"; + WHERE cat_id = '" . $ids[1] . "' + AND cat_main = '" . $level . "';"; // to ensure they are in the same level if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); } + + if(!$db->sql_query($sql2)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + } } return; } Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -88,10 +88,11 @@ { for($i = 0; $i < $total_catrows; $i++) { - $auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); - if($auth['auth_view']) - { + // auth not included in alpha + //if($auth['auth_view']) + //{ // Ok display one cat here $template->assign_block_vars('catrow', array( 'CAT_TITLE' => $catrows[$i]['cat_title'], @@ -125,10 +126,11 @@ for($j = 0; $j < $total_subcats; $j++) { - $auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); - if($auth['auth_view']) - { + // auth not included in alpha + //if($auth['auth_view']) + //{ // Show the subcat $k = $j + 1; $subcat_comma = ( isset($subcats[$k]) ) ? ", " : "."; @@ -137,10 +139,10 @@ 'SUBCAT_TITLE' => $subcats[$j]['cat_title'], 'SUBCAT_COMMA' => $subcat_comma) ); - } // if auth view + //} // if auth view } // for subcats } // if subcats - } // auth view + //} // auth view } // for cats }// total cats else Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-28 01:47:23 UTC (rev 33) +++ root/language/lang_english/lang_kb.php 2006-12-29 23:45:05 UTC (rev 34) @@ -29,7 +29,7 @@ // Normal Page $lang['kb_categories'] = "Knowledge Base Categories"; $lang['kb_articles'] = "Articles"; -$lang['kb_subcats'] = "Sub categories"; +$lang['kb_subcats'] = "Subcategories"; $lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. Knowledge Base won't work before that has been done!"; $lang['No_kb_cats'] = "No knowledge base categories has been added."; $lang['kb_cat_noexist'] = "The category you chose does not exist."; @@ -58,22 +58,28 @@ $lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; // Admin -$lang['kbadm_header_editcat'] -$lang['kbadm_explain_editcat'] -$lang['kbadm_cat_settings'] -$lang['kbadm_cat_title'] -$lang['kbadm_cat_desc'] -$lang['kbadm_cat_parent'] -$lang['kbadm_empty_cat_title'] -$lang['kbadm_empty_cat_desc'] -$lang['kbadm_confirm_deletecat'] -$lang['kbadm_Click_return_catadmin'] -$lang['kbadm_header_addcat'] -$lang['kbadm_explain_addcat'] -$lang['kbadm_addcat'] +$lang['kbadm_header_editcat'] = "Edit Category"; +$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category adn description."; +$lang['kbadm_cat_settings'] = "Category Properties"; +$lang['kbadm_cat_title'] = "Category Title"; +$lang['kbadm_cat_desc'] = "Category Description"; +$lang['kbadm_cat_parent'] = "Parent Category"; +$lang['kbadm_empty_cat_title'] = "The Category Title submitted was empty."; +$lang['kbadm_empty_cat_desc'] = "The Category Description submitted was empty."; +$lang['kbadm_confirm_deletecat'] = "Are you sure you want to delete this category?"; +$lang['kbadm_Click_return_catadmin'] = "Click %shere%s to return to category administration."; +$lang['kbadm_header_addcat'] = "Add Category"; +$lang['kbadm_explain_addcat'] = "From here you can add a new category."; +$lang['kbadm_addcat'] = "Add"; +$lang['kbadm_editcat'] = "Edit"; -$lang['kbadm_delcat_success'] -$lang['kbadm_editcat_success'] -$lang['kbadm_addcat_success'] -$lang['kbadm_sortcat_success'] +$lang['kbadm_movecatup'] = "Move Up"; +$lang['kbadm_movecatdown'] = "Move Down"; +$lang['kbadm_delcat'] = "Delete"; +$lang['kbadm_maincat_explain'] = "This is the place where you can move categories up and down, create new ones and edit the already existant."; + +$lang['kbadm_delcat_success'] = "The category has been deleted successfully."; +$lang['kbadm_editcat_success'] = "The category has been edited successfully."; +$lang['kbadm_addcat_success'] = "Your new category has been added."; +$lang['kbadm_sortcat_success'] = "The category has been moved as specified."; ?> \ No newline at end of file Added: root/templates/subSilver/admin/kb_cats.tpl =================================================================== --- root/templates/subSilver/admin/kb_cats.tpl (rev 0) +++ root/templates/subSilver/admin/kb_cats.tpl 2006-12-29 23:45:05 UTC (rev 34) @@ -0,0 +1,52 @@ +<h1>{L_HEADER}</h1> + +<p>{L_EXPLAIN}</p> + +<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> + <tr> + <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_CATEGORIES} </th> + <th class="thCornerR" colspan="4" nowrap="nowrap"> </th> + </tr> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle"> </span></td> + <td class="rowpic" colspan="4" align="right"> </td> + </tr> + <!-- BEGIN catrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> + <td class="row1" width="100%" height="50">{catrow.CAT_TITLE}<br /> + </span> <span class="genmed">{catrow.CAT_DESC}</td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_UP}">{L_MOVECAT_UP}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- BEGIN switch_subcat --> + <tr> + <td class="catLeft" colspan="2" height="28"><span class="cattitle">{catrow.switch_subcat.L_SUBCATS}</span></td> + <td class="rowpic" colspan="4" align="right"> </td> + </tr> + <!-- END switch_subcat --> + <!-- BEGIN subcatrow --> + <tr> + <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row1" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> + <span class="genmed">{catrow.subcatrow.SUBCAT_DESC}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_EDITSUBCAT}">{L_EDITCAT}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_UP}">{L_MOVECAT_UP}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_DELSUBCAT}">{L_DELCAT}</a></span></td> + </tr> + <!-- END subcatrow --> + <!-- BEGIN switch_subcat_close --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> + </tr> + <!-- END switch_subcat_close --> + <!-- END catrow --> + <tr> + <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> + </tr> +</table> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-06 11:14:44
|
Revision: 35 http://svn.sourceforge.net/phpbbkb/?rev=35&view=rev Author: softphp Date: 2007-01-06 03:14:40 -0800 (Sat, 06 Jan 2007) Log Message: ----------- - ACP now thoroughly tested and should be working 100%. - Alpha 1 is almost ready, need to implement some links here and there, and insert some auth here and there. Also preview function isn't coded yet. Besides that some native englishman just needs to look through the lang files and it's ready to go. Modified Paths: -------------- root/admin/admin_kb.php root/kb/functions.php root/kb.php root/language/lang_english/lang_kb.php root/templates/subSilver/admin/kb_cats.tpl root/templates/subSilver/kb_main.tpl root/templates/subSilver/kb_viewcat.tpl Modified: root/admin/admin_kb.php =================================================================== --- root/admin/admin_kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/admin/admin_kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -52,6 +52,10 @@ $edit = isset($HTTP_GET_VARS['edit']) ? $HTTP_GET_VARS['edit'] : false; $delete = isset($HTTP_GET_VARS['delete']) ? $HTTP_GET_VARS['delete'] : false; $add = isset($HTTP_POST_VARS['add']) ? true : false; + if(!$add) + { + $add = isset($HTTP_GET_VARS['add']) ? true : false; + } $sort = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : false; if($edit != false) @@ -192,8 +196,14 @@ if($delete != false) { $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false; - if(!$confirm) + $cancel = isset($HTTP_POST_VARS['cancel']) ? true : false; + if($cancel) { + // Redirect back to cat page + + } + elseif(!$confirm) + { $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $delete . '" />'; $l_confirm = $lang['kbadm_confirm_deletecat']; @@ -237,6 +247,13 @@ message_die(GENERAL_ERROR, "Couldn't delete category from articlecats table.", "", __LINE__, __FILE__, $sql); } + // Delete subcats + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE cat_main = '" . $cat_id . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete subcategories from articlecats table.", "", __LINE__, __FILE__, $sql); + } + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? @@ -266,7 +283,7 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "mode=cats")) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) ); $template->pparse('body'); @@ -294,8 +311,8 @@ 'body' => 'admin/kb_editcat.tpl') ); - $parent = generate_cat_parents($cat['cat_main']); - $s_hidden_fields = ""; + $parent = generate_cat_parents($HTTP_POST_VARS['parent']); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; $template->set_filenames(array( 'reg_header' => 'error_body.tpl') @@ -321,7 +338,7 @@ 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], 'S_PARENT' => $parent, 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $edit)) + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) ); $template->pparse('body'); @@ -355,7 +372,7 @@ { $sort = explode("|", $sort); - // ok so ?sort=id,id2|up/down|level + // ok so ?sort=id|up/down|level sort_cats("", $sort[0], $sort[1], $sort[2]); // Put id2 in the level argument, nvm that :) // And yes yet another message here @@ -374,8 +391,6 @@ $template->assign_vars(array( 'L_CATEGORIES' => $lang['kb_categories'], 'L_EDITCAT' => $lang['kbadm_editcat'], - 'L_MOVECAT_UP' => $lang['kbadm_movecatup'], - 'L_MOVECAT_DOWN' => $lang['kbadm_movecatdown'], 'L_DELCAT' => $lang['kbadm_delcat'], 'L_HEADER' => $lang['Categories'], 'L_EXPLAIN' => $lang['kbadm_maincat_explain']) @@ -385,69 +400,111 @@ { for($i = 0; $i < $total_catrows; $i++) { - //$auth = kb_auth("view", $catrows[$i]['cat_id'], $userdata); + // Check if the cat is at the top and therefore cant be moved up + if(($cats[$i - 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i - 1]['cat_id']) == 0)) + { + $movecat_up = $lang['kbadm_movecatup']; + } + else + { + $movecat_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|up|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatup'] . '</a>'; + } - // auth not included in alpha - //if($auth['auth_view']) - //{ - // Ok display one cat here - $template->assign_block_vars('catrow', array( - // Name 'nd stuff - 'CAT_TITLE' => $cats[$i]['cat_title'], - 'CAT_DESC' => $cats[$i]['cat_desc'], - - // Links - 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), - 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), - // sort=id,id2|up/down|level - 'U_MOVECAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i - 1]['cat_id'] . "|up|" . $cats[$i]['cat_main']), - 'U_MOVECAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['cat_id'] . "," . $cats[$i + 1]['cat_id'] . "|down|" . $cats[$i]['cat_main']), - - // Image - 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D - ); + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i + 1]['cat_main'] != $cats[$i]['cat_main']) || (strlen($cats[$i + 1]['cat_id']) == 0)) + { + $movecat_down = $lang['kbadm_movecatdown']; + } + else + { + $movecat_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['cat_id'] . '|down|' . $cats[$i]['cat_main']) . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Ok display one cat here + $template->assign_block_vars('catrow', array( + // Name 'nd stuff + 'CAT_TITLE' => $cats[$i]['cat_title'], + 'CAT_DESC' => $cats[$i]['cat_desc'], - if($total_subcats = count($cats[$i]['subcats'])) + // Links + 'U_EDITCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['cat_id']), + 'U_DELCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['cat_id']), + // sort=id,id2|up/down|level + 'MOVECAT_UP' => $movecat_up, + 'MOVECAT_DOWN' => $movecat_down, + + // Image + 'FORUM_FOLDER_IMG' => "../" . $images['forum']) // Stolen :D + ); + + if($total_subcats = count($cats[$i]['subcats'])) + { + // Contains subcats, show them + //$template->assign_block_vars('catrow.switch_subcat', array( + //'L_SUBCATS' => $lang['kb_subcats']) + //); + + for($j = 0; $j < $total_subcats; $j++) { - // Contains subcats, show them - $template->assign_block_vars('catrow.switch_subcat', array( - 'L_SUBCATS' => $lang['kb_subcats']) - ); + if(($cats[$i]['subcats'][$j - 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j - 1]['cat_id']) == 0)) + { + $subcatmove_up = $lang['kbadm_movecatup']; + } + else + { + $subcatmove_up = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|up') . '">' . $lang['kbadm_movecatup'] . '</a>'; + } - for($j = 0; $j < $total_subcats; $j++) + // Check if the cat is at the bottom and therefore cant be moved down + if(($cats[$i]['subcats'][$j + 1]['cat_main'] != $cats[$i]['subcats'][$j]['cat_main']) || (strlen($cats[$i]['subcats'][$j + 1]['cat_id']) == 0)) { - //$auth = kb_auth("view", $subcats[$j]['cat_id'], $userdata); + $subcatmove_down = $lang['kbadm_movecatdown']; + } + else + { + $subcatmove_down = '<a href="' . append_sid('admin_kb.' . $phpEx . '?mode=cats&s=' . $cats[$i]['subcats'][$j]['cat_id'] . '|down') . '">' . $lang['kbadm_movecatdown'] . '</a>'; + } + + // Show the subcat + $template->assign_block_vars('catrow.subcatrow', array( + 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], + 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], - // auth not included in alpha - //if($auth['auth_view']) - //{ - // Show the subcat - $template->assign_block_vars('catrow.subcatrow', array( - 'SUBCAT_TITLE' => $cats[$i]['subcats'][$j]['cat_title'], - 'SUBCAT_DESC' => $cats[$i]['subcats'][$j]['cat_desc'], - - // Links - 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), - 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), - // sort=id,id2|up/down|level - 'U_MOVESUBCAT_UP' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j - 1]['cat_id'] . "|up|" . $cats[$i]['subcats'][$j]['cat_main']), - 'U_MOVESUBCAT_DOWN' => append_sid("admin_kb." . $phpEx . "?mode=cats&s=" . $cats[$i]['subcats'][$j]['cat_id'] . "," . $cats[$i]['subcats'][$j + 1]['cat_id'] . "|down|" . $cats[$i]['subcats'][$j]['cat_main']), - - 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D - ); - //} // if auth view - } // for subcats - - $template->assign_block_vars('catrow.switch_subcat_close', array()); - } // if subcats - //} // auth view + // Links + 'U_EDITSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&edit=" . $cats[$i]['subcats'][$j]['cat_id']), + 'U_DELSUBCAT' => append_sid("admin_kb." . $phpEx . "?mode=cats&delete=" . $cats[$i]['subcats'][$j]['cat_id']), + // sort=id,id2|up/down|level + 'MOVESUBCAT_UP' => $subcatmove_up, + 'MOVESUBCAT_DOWN' => $subcatmove_down, + + 'TOPIC_FOLDER_IMG' => "../" . $images['folder']) // Stolen :D + ); + } // for subcats + + //$template->assign_block_vars('catrow.switch_subcat_close', array()); + } // if subcats } // for cats + $parent = generate_cat_parents(); + $s_hidden_fields = '<input type="hidden" name="add" value="1">'; + + $template->assign_vars(array( + 'L_CAT_SETTINGS' => $lang['kbadm_addcat'], + 'L_CAT_TITLE' => $lang['kbadm_cat_title'], + 'L_CAT_DESCRIPTION' => $lang['kbadm_cat_desc'], + 'L_CAT_PARENT' => $lang['kbadm_cat_parent'], + + 'S_SUBMIT_VALUE' => $lang['kbadm_addcat'], + 'S_PARENT' => $parent, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FORUM_ACTION' => append_sid("admin_kb." . $phpEx . "?mode=cats")) + ); + $template->pparse('body'); }// total cats else { - message_die(GENERAL_MESSAGE, $lang['No_kb_cats']); + message_die(GENERAL_MESSAGE, sprintf($lang['No_kbadm_cats'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats&add=1") . '">', '</a>')); } include('./page_footer_admin.'.$phpEx); @@ -474,7 +531,8 @@ $sql = "SELECT cat_id, cat_title FROM " . KB_CATEGORIES_TABLE . " - WHERE cat_main = '0' ORDER BY cat_order"; // At the moment only one level of subcats + WHERE cat_main = '0' + ORDER BY cat_order ASC"; // At the moment only one level of subcats if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't get categories from categories table", "", __LINE__, __FILE__, $sql); @@ -537,8 +595,8 @@ $cat_number = $db->sql_numrows($result); - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = '" . $cat_number + 1 . "' + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat_number . "' WHERE cat_id = '" . $id . "'"; if(!$db->sql_query($sql)) @@ -566,16 +624,15 @@ while($old_cat = $db->sql_fetchrow($result)) { $i++; - $sql .= "UPDATE " . KB_CATEGORIES_TABLE . " + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " SET cat_order = '" . $i . "' WHERE cat_id = '" . $old_cat['cat_id'] . "';\n"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); + } } - if(!$db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Couldn't sort old level order in cat table.", "", __LINE__, __FILE__, $sql); - } - // Ok insert it in the back of the new one :) $sql = "SELECT cat_id FROM " . KB_CATEGORIES_TABLE . " @@ -590,7 +647,7 @@ $cat_number = $db->sql_numrows($result); $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = '" . $cat_number + 1 . "' + SET cat_order = '" . $cat_number . "' WHERE cat_id = '" . $id . "'"; if(!$db->sql_query($sql)) @@ -602,52 +659,68 @@ } else { + $sql = "SELECT cat_order, cat_main + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id . "'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); + } + + $cat = $db->sql_fetchrow($result); + if($dir == "up") { - $ids = explode(",", $id); + $num = $cat['cat_order'] - 1; - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order - 1 - WHERE cat_id = '" . $ids[0] . "';"; - - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order + 1 - WHERE cat_id = '" . $ids[1] . "' - AND cat_main = '" . $level . "';"; // to ensure they are in the same level. - - if(!$db->sql_query($sql)) + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; + + if(!$result = $db->sql_query($sql)) { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); } - if(!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); - } + $cat2 = $db->sql_fetchrow($result); } elseif($dir == "down") { - $ids = explode(",", $id); + $num = $cat['cat_order'] + 1; - $sql = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order + 1 - WHERE cat_id = '" . $ids[0] . "';"; + $sql = "SELECT cat_id, cat_order + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_order = '" . $num . "' + AND cat_main = '" . $cat['cat_main'] . "'"; - $sql2 = "UPDATE " . KB_CATEGORIES_TABLE . " - SET cat_order = cat_order - 1 - WHERE cat_id = '" . $ids[1] . "' - AND cat_main = '" . $level . "';"; // to ensure they are in the same level - - if(!$db->sql_query($sql)) + if(!$result = $db->sql_query($sql)) { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, "Couldn't retrieve categories order data.", "", __LINE__, __FILE__, $sql); } - if(!$db->sql_query($sql2)) - { - message_die(GENERAL_ERROR, "Couldn't alter categories order.", "", __LINE__, __FILE__, $sql); - } + $cat2 = $db->sql_fetchrow($result); } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat2['cat_order'] . "' + WHERE cat_id = '" . $id . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + + $sql = "UPDATE " . KB_CATEGORIES_TABLE . " + SET cat_order = '" . $cat['cat_order'] . "' + WHERE cat_id = '" . $cat2['cat_id'] . "'"; + + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't alter categories order data.", "", __LINE__, __FILE__, $sql); + } + return; } } Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/kb/functions.php 2007-01-06 11:14:40 UTC (rev 35) @@ -113,7 +113,7 @@ $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '0' - ORDER BY cat_order"; + ORDER BY cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query cats.', '', __LINE__, __FILE__, $sql); @@ -127,7 +127,7 @@ $sql = "SELECT * FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '" . $row['cat_id'] . "' - ORDER BY cat_order"; + ORDER BY cat_order ASC"; if( !($subcat_result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcats.', '', __LINE__, __FILE__, $sql); @@ -147,10 +147,45 @@ //////////////////////////////////////// /// UCP FUNCTIONS /// //////////////////////////////////////// -$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); -$html_entities_replace = array('&', '<', '>', '"'); -$unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); -$unhtml_specialchars_replace = array('>', '<', '"', '&'); +function ucp_generate_page_title($action) +{ + global $lang; + + $title = $lang['kb_ucp']; + switch($action) + { + case "articles": + break; + + case "comments": + break; + + case "post_article": + $title .= ": " . $lang['kb_ucp_articlepost']; + break; + + case "edit_article": + $title .= ": " . $lang['kb_ucp_articleedit']; + break; + + case "delete_article": + break; + + case "post_comment": // Only input + break; + + case "edit_comment": + break; + + case "delete_comment": + break; + + default: + break; + } + + return $title; +} // This is for posting articles, mostly cut out of the posting.php :) function ucp_article_form($mode, $id, $review) @@ -160,6 +195,12 @@ $error_msg = ''; $user_sig = $userdata['user_sig']; + // This is instead of authentication which will be featured after alpha + if(!$userdata['session_logged_in']) + { + message_die(GENERAL_MESSAGE, 'Not authenticated!'); + } + if(!empty($HTTP_POST_VARS['post'])) { if($mode == 'edit') @@ -737,6 +778,8 @@ // Clean up the message // $message = trim($message); + $html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#'); + $html_entities_replace = array('&', '<', '>', '"'); if ($html_on) { @@ -779,6 +822,9 @@ function unprepare_message($message) { + $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); + $unhtml_specialchars_replace = array('>', '<', '"', '&'); + return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $message); } ?> \ No newline at end of file Modified: root/kb.php =================================================================== --- root/kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -58,7 +58,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '0' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); @@ -79,9 +79,16 @@ 'body' => 'kb_main.tpl') ); + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + $template->assign_vars(array( 'L_CATEGORIES' => $lang['kb_categories'], - 'L_ARTICLES' => $lang['kb_articles']) + 'L_ARTICLES' => $lang['kb_articles'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) ); if($total_catrows = count($catrows)) @@ -107,7 +114,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '" . $catrows[$i]['cat_id'] . "' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); @@ -179,7 +186,7 @@ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order FROM " . KB_CATEGORIES_TABLE . " c WHERE c.cat_main = '$cat_id' - ORDER BY c.cat_order"; + ORDER BY c.cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql); @@ -263,13 +270,20 @@ 'body' => 'kb_viewcat.tpl') ); + if($userdata['session_logged_in']) + { + $template->assign_block_vars('switch_add_article', array()); + } + // Process the whole thing $template->assign_vars(array( 'L_VIEWS' => $lang['Views'], 'L_AUTHOR' => $lang['Author'], 'L_ARTICLES' => $lang['kb_articles'], 'L_SUBCATS' => sprintf($lang['kb_viewcat_subcats'], $cat['cat_title']), - 'L_LAST_ACTION' => $lang['kb_last_action']) + 'L_LAST_ACTION' => $lang['kb_last_action'], + 'L_ADD_ARTICLE' => $lang['kb_ucp_articlepost'], + 'U_ADD_ARTICLE' => append_sid("kb." . $phpEx . "?pid=ucp&action=post_article")) ); if( $total_subcats = count($subcats) ) Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-12-29 23:45:05 UTC (rev 34) +++ root/language/lang_english/lang_kb.php 2007-01-06 11:14:40 UTC (rev 35) @@ -59,7 +59,7 @@ // Admin $lang['kbadm_header_editcat'] = "Edit Category"; -$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category adn description."; +$lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category and description."; $lang['kbadm_cat_settings'] = "Category Properties"; $lang['kbadm_cat_title'] = "Category Title"; $lang['kbadm_cat_desc'] = "Category Description"; @@ -82,4 +82,6 @@ $lang['kbadm_editcat_success'] = "The category has been edited successfully."; $lang['kbadm_addcat_success'] = "Your new category has been added."; $lang['kbadm_sortcat_success'] = "The category has been moved as specified."; + +$lang['No_kbadm_cats'] = "No knowledge base categories has been added. Click %shere%s to create a new one."; ?> \ No newline at end of file Modified: root/templates/subSilver/admin/kb_cats.tpl =================================================================== --- root/templates/subSilver/admin/kb_cats.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/admin/kb_cats.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -16,37 +16,51 @@ <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td> <td class="row1" width="100%" height="50">{catrow.CAT_TITLE}<br /> </span> <span class="genmed">{catrow.CAT_DESC}</td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_UP}">{L_MOVECAT_UP}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_MOVECAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_EDITCAT}">{L_EDITCAT}</a></span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_UP}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.MOVECAT_DOWN}</span></td> + <td class="row1" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.U_DELCAT}">{L_DELCAT}</a></span></td> </tr> - <!-- BEGIN switch_subcat --> - <tr> - <td class="catLeft" colspan="2" height="28"><span class="cattitle">{catrow.switch_subcat.L_SUBCATS}</span></td> - <td class="rowpic" colspan="4" align="right"> </td> - </tr> - <!-- END switch_subcat --> <!-- BEGIN subcatrow --> <tr> - <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> - <td class="row1" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> + <td class="row2" align="center" valign="middle" height="50"><img src="{catrow.subcatrow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td> + <td class="row2" width="100%" height="50">{catrow.subcatrow.SUBCAT_TITLE}<br /> <span class="genmed">{catrow.subcatrow.SUBCAT_DESC}</span></td> <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_EDITSUBCAT}">{L_EDITCAT}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_UP}">{L_MOVECAT_UP}</a></span></td> - <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_MOVESUBCAT_DOWN}">{L_MOVECAT_DOWN}</a></span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_UP}</span></td> + <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed">{catrow.subcatrow.MOVESUBCAT_DOWN}</span></td> <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"><span class="genmed"><a href="{catrow.subcatrow.U_DELSUBCAT}">{L_DELCAT}</a></span></td> </tr> <!-- END subcatrow --> - <!-- BEGIN switch_subcat_close --> - <tr> - <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> - </tr> - <!-- END switch_subcat_close --> <!-- END catrow --> <tr> <td class="catBottom" align="center" valign="middle" colspan="6" height="28"> </td> </tr> </table> +<br clear="all" /> + +<form action="{S_FORUM_ACTION}" method="post"> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">{L_CAT_SETTINGS}</th> + </tr> + <tr> + <td class="row1">{L_CAT_TITLE}</td> + <td class="row2"><input type="text" size="25" name="title" value="" class="post" /></td> + </tr> + <tr> + <td class="row1">{L_CAT_DESCRIPTION}</td> + <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="desc" class="post"></textarea></td> + </tr> + <tr> + <td class="row1">{L_CAT_PARENT}</td> + <td class="row2">{S_PARENT}</td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td> + </tr> + </table> +</form> + <br clear="all" /> \ No newline at end of file Modified: root/templates/subSilver/kb_main.tpl =================================================================== --- root/templates/subSilver/kb_main.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/kb_main.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -1,5 +1,8 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> </tr> @@ -36,7 +39,10 @@ </table> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> Modified: root/templates/subSilver/kb_viewcat.tpl =================================================================== --- root/templates/subSilver/kb_viewcat.tpl 2006-12-29 23:45:05 UTC (rev 34) +++ root/templates/subSilver/kb_viewcat.tpl 2007-01-06 11:14:40 UTC (rev 35) @@ -1,5 +1,8 @@ <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"> </td> </tr> @@ -52,7 +55,10 @@ <!-- END switch_articles --> <table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> - <tr> + <tr> + <!-- BEGIN switch_add_article --> + <td align="left" valign="middle" width="50"><a class="nav" href="{U_ADD_ARTICLE}">{L_ADD_ARTICLE}</a></td> + <!-- END switch_add_article --> <td align="left">{NAVIGATION}</td> <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-07 01:10:02
|
Revision: 36 http://svn.sourceforge.net/phpbbkb/?rev=36&view=rev Author: softphp Date: 2007-01-06 17:09:59 -0800 (Sat, 06 Jan 2007) Log Message: ----------- - Added the viewarticle tpl file, that i apparently had forgotten. - Added some basic auth that will work for Alpha 1. - Corrected minor language vars here and there, and other minor bugs. Modified Paths: -------------- root/kb/functions.php root/kb.php root/language/lang_english/lang_kb.php Added Paths: ----------- root/templates/subSilver/kb_viewarticle.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/kb/functions.php 2007-01-07 01:09:59 UTC (rev 36) @@ -169,6 +169,7 @@ break; case "delete_article": + $title .= ": " . $lang['kb_ucp_articledelete']; break; case "post_comment": // Only input @@ -195,7 +196,7 @@ $error_msg = ''; $user_sig = $userdata['user_sig']; - // This is instead of authentication which will be featured after alpha + // Simple auth for Alpha 1 if(!$userdata['session_logged_in']) { message_die(GENERAL_MESSAGE, 'Not authenticated!'); @@ -219,7 +220,7 @@ $article = $db->sql_fetchrow($result); // if user editing set status = 0, else set status = old status :) - if($userdata['user_id'] == $article_author) + if($userdata['user_id'] == $article['article_author']) { $article_status = "0"; } @@ -227,6 +228,12 @@ { $article_status = $article['article_status']; } + + // Simple Auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_edit_noauth']; + } } // Add the new article @@ -356,8 +363,15 @@ } // 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; + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); } } @@ -678,6 +692,12 @@ { global $lang, $db, $phpEx, $template; + // Simple auth for alpha 1 + if(($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $article['article_author'])) + { + message_die(GENERAL_MESSAGE, $lang['kb_delete_noauth']; + } + if(!$confirm) { $s_hidden_fields = '<input type="hidden" name="article_id" value="' . $id . '" />'; @@ -697,7 +717,7 @@ 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], - 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete"), + 'S_CONFIRM_ACTION' => append_sid("kb." . $phpEx . "?mode=ucp&action=delete_article"), 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); @@ -721,6 +741,14 @@ } // 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>'); + + $template->assign_vars(array( + 'META' => $meta) + ); + + message_die(GENERAL_MESSAGE, $return_message); } } Modified: root/kb.php =================================================================== --- root/kb.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/kb.php 2007-01-07 01:09:59 UTC (rev 36) @@ -525,9 +525,19 @@ 'ARTICLE_TITLE' => $article_title, 'ARTICLE_TEXT' => $article_text, 'POSTED_BY' => $posted_by, - 'SIGNATURE' => $user_sig) + 'SIGNATURE' => $user_sig, + 'L_EDITARTICLE' => $lang['kb_ucp_articleedit'], + 'L_DELETEARTICLE' => $lang['kb_ucp_articledelete'], + + 'U_EDITARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=edit_article&id=' . $id), + 'U_DELETEARTICLE' => append_sid('kb.' . $phpEx . '?pid=ucp&action=delete_article&id=' . $id)) ); + if(($userdata['user_level'] == ADMIN) || ($userdata['user_id'] == $article['article_author'])) + { + $template->assign_block_vars('switch_mod', array()); + } + // // Generate the page // @@ -591,7 +601,10 @@ // // Generate the page // - $template->pparse('body'); + if($action != "delete_article") + { + $template->pparse('body'); + } include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2007-01-06 11:14:40 UTC (rev 35) +++ root/language/lang_english/lang_kb.php 2007-01-07 01:09:59 UTC (rev 36) @@ -25,6 +25,7 @@ $lang['kb_ucp'] = "KB User Control Panel"; $lang['kb_ucp_articlepost'] = "Post new article"; $lang['kb_ucp_articleedit'] = "Edit article"; +$lang['kb_ucp_articledelete'] = "Delete article"; // Normal Page $lang['kb_categories'] = "Knowledge Base Categories"; @@ -53,10 +54,17 @@ $lang['kb_empty_cats'] = "The article you submitted had no category defined."; $lang['kb_empty_article_desc'] = "The article has to contain an article description."; $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_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?"; +// Auth +$lang['kb_edit_noauth'] = "You are not allowed to edit this article."; +$lang['kb_delete_noauth'] = "You are not allowed to delete this article."; + // Admin $lang['kbadm_header_editcat'] = "Edit Category"; $lang['kbadm_explain_editcat'] = "Here you can edit the chosen category, specifying its name, parent category and description."; Added: root/templates/subSilver/kb_viewarticle.tpl =================================================================== --- root/templates/subSilver/kb_viewarticle.tpl (rev 0) +++ root/templates/subSilver/kb_viewarticle.tpl 2007-01-07 01:09:59 UTC (rev 36) @@ -0,0 +1,39 @@ +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"> </td> + </tr> +</table> + +<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> + <tr> + <th colspan="2" class="thRight" nowrap="nowrap"><a class="maintitle" href="{U_VIEW_ARTICLE}">{ARTICLE_TITLE}</a></th> + </tr> + <tr> + <td align="left" class="catHead" height="28"><span class="gensmall">{POSTED_BY}</span></td> + <td align="right" class="catHead" height="28"><span class="gensmall"> + <!-- switch_mod BEGIN --> + <a href="{U_EDITARTICLE}">{L_EDITARTICLE}</a> <a href="{U_DELETEARTICLE}">{L_DELETEARTICLE}</a> + <!-- switch_mod END --> + </span></td> + </tr> + <tr> + <td colspan="2" class="row1" width="100%" height="28"><span class="postbody">{ARTICLE_TEXT}{SIGNATURE}</span></td> + </tr> + <tr> + <td colspan="2" class="row1" width="150" align="left" valign="middle"><span class="nav"><a href="#top" class="nav">{L_BACK_TO_TOP}</a></span></td> + </tr> + <tr> + <td colspan="2" class="spaceRow" height="1"><img src="templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td> + </tr> + <tr> + <td colspan="2" class="catBottom" height="28"></td> + </tr> +</table> + +<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2"> + <tr> + <td align="left">{NAVIGATION}</td> + <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td> + </tr> +</table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2007-01-07 22:19:24
|
Revision: 37 http://svn.sourceforge.net/phpbbkb/?rev=37&view=rev Author: softphp Date: 2007-01-07 14:19:22 -0800 (Sun, 07 Jan 2007) Log Message: ----------- - Another quick commit, added the preview function, which means, testing, correcting my english and we're ready for Alpha 1. Modified Paths: -------------- root/kb/functions.php Added Paths: ----------- root/templates/subSilver/kb_previewarticle.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-07 01:09:59 UTC (rev 36) +++ root/kb/functions.php 2007-01-07 22:19:22 UTC (rev 37) @@ -1,4 +1,4 @@ -<?php + <?php /*************************************************************************** * functions.php * ------------------- @@ -207,7 +207,7 @@ if($mode == 'edit') { // Let's get the old article data - $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + $article_id = $id; $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " @@ -412,17 +412,13 @@ { $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); } - - if($preview) - { - // Do funny preview stuff - } } elseif($preview || $error_msg != '') { $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; $article_desc = $HTTP_POST_VARS['desc']; + $article_cats = $HTTP_POST_VARS['cats']; $authorname = $HTTP_POST_VARS['authorname']; $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; @@ -431,8 +427,17 @@ $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; + if($mode == 'edit') + { + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + } + else + { + $hidden_form_fields = ""; + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + } + if($error_msg != "") { $template->set_filenames(array( @@ -443,17 +448,40 @@ ); $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); } + + if($preview) + { + // Create the preview box + $preview_article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $preview_article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $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)); + + $template->set_filenames(array( + 'preview_box' => 'kb_articlepreview.tpl') + ); + + $template->assign_vars(array( + 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, + 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, + 'MESSAGE' => $preview_message) + ); + + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview'); + } } else { - if(empty($id)) + if(empty($article_id)) { message_die(GENERAL_ERROR, "No article defined."); } $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query article data.', '', __LINE__, __FILE__, $sql); @@ -471,7 +499,7 @@ // Now make an array over the cats $sql = "SELECT cat_id FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); @@ -495,7 +523,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="' . $id . '" />'; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; } if ( $article['bbcode_uid'] != '' ) @@ -546,7 +574,7 @@ // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($mode == "edit") + if($mode == "edit" || $preview) { for($i = 0; $i < count($cats); $i++) { @@ -848,7 +876,7 @@ return $message; } -function unprepare_message($message) +function unprepare_article_text($message) { $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); $unhtml_specialchars_replace = array('>', '<', '"', '&'); Added: root/templates/subSilver/kb_previewarticle.tpl =================================================================== --- root/templates/subSilver/kb_previewarticle.tpl (rev 0) +++ root/templates/subSilver/kb_previewarticle.tpl 2007-01-07 22:19:22 UTC (rev 37) @@ -0,0 +1,23 @@ + +<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0"> + <tr> + <th height="25" class="thHead">{L_PREVIEW}</th> + </tr> + <tr> + <td class="row1"><img src="templates/subSilver/images/icon_minipost.gif" alt="{L_POST}" /><span class="postdetails">{L_ARTICLE_NAME}: {PREVIEW_ARTICLE_TITLE} {L_ARTICLE_DESC}: {PREVIEW_ARTICLE_DESC}</span></td> + </tr> + <tr> + <td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> + <span class="postbody">{MESSAGE}</span> + </td> + </tr> + </table></td> + </tr> + <tr> + <td class="spaceRow" height="1"><img src="templates/subSilver/images/spacer.gif" width="1" height="1" /></td> + </tr> +</table> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |