From 3720cde9137cefa6c2ad42fff6313592bc636e5e Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Wed, 17 Dec 2008 16:54:42 +0100 Subject: [PATCH] [svn r17355] minor - logic changes - Fixed Hide the link add a forum if there are no categories see FS#3369 (by cvargas) --- main/forum/forumfunction.inc.php | 28 ++++++++++++++++------------ main/forum/index.php | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index d7de94e286..5adcdeeddd 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -618,24 +618,28 @@ function delete_forum_forumcategory_thread($content, $id) { $tool_constant=TOOL_FORUM_CATEGORY; $return_message=get_lang('ForumCategoryDeleted'); - $sql="SELECT forum_id FROM ". $table_forums . "WHERE forum_category='".$id."'"; - $result = api_sql_query($sql, __FILE__, __LINE__); - $row = Database::fetch_array($result); - foreach ($row as $arr_forum) { - $forum_id = $arr_forum['forum_id']; - api_item_property_update($_course,'forum',$forum_id,'delete',api_get_user_id()); + if (!empty($forum_list)){ + $sql="SELECT forum_id FROM ". $table_forums . "WHERE forum_category='".$id."'"; + $result = api_sql_query($sql, __FILE__, __LINE__); + $row = Database::fetch_array($result); + foreach ($row as $arr_forum) { + $forum_id = $arr_forum['forum_id']; + api_item_property_update($_course,'forum',$forum_id,'delete',api_get_user_id()); + } } } if ($content=='forum') { $tool_constant=TOOL_FORUM; $return_message=get_lang('ForumDeleted'); - $sql="SELECT thread_id FROM". $table_forum_thread . "WHERE forum_id='".$id."'"; - $result = api_sql_query($sql, __FILE__, __LINE__); - $row = mysql_fetch_array($result); - foreach ($row as $arr_forum) { - $forum_id = $arr_forum['thread_id']; - api_item_property_update($_course,'forum_thread',$forum_id,'delete',api_get_user_id()); + if (!empty($number_threads)){ + $sql="SELECT thread_id FROM". $table_forum_thread . "WHERE forum_id='".$id."'"; + $result = api_sql_query($sql, __FILE__, __LINE__); + $row = mysql_fetch_array($result); + foreach ($row as $arr_forum) { + $forum_id = $arr_forum['thread_id']; + api_item_property_update($_course,'forum_thread',$forum_id,'delete',api_get_user_id()); + } } } if ($content=='thread') { diff --git a/main/forum/index.php b/main/forum/index.php index fc5ba7fb38..f3d81753d9 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -191,7 +191,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'notify' AND isset($_GET['conte echo ''.search_link().''; if (api_is_allowed_to_edit(false,true)) { echo ' '.Display::return_icon('forum_category_new.gif', get_lang('AddForumCategory')).' '.get_lang('AddForumCategory').''; - if (is_array($forum_categories_list)) { + if (is_array($forum_categories_list) and !empty($forum_categories_list)) { echo ' '.Display::return_icon('forum_new.gif', get_lang('AddForum')).' '.get_lang('AddForum').''; } //echo ' | '.get_lang('MigrateForum').'';