[Phpbbkb-checkins] SF.net SVN: phpbbkb: [32] root
Status: Alpha
Brought to you by:
markthedaemon
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. |