From 73fb361ac3cc8e4bf22f8e993394431cc697e2d1 Mon Sep 17 00:00:00 2001 From: Isaac Flores Date: Wed, 10 Dec 2008 16:45:43 +0100 Subject: [PATCH] [svn r17206] minor - style changes - defined variable --- main/forum/index.php | 59 +++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/main/forum/index.php b/main/forum/index.php index 08881a2c43..5a187bb78a 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -96,9 +96,10 @@ if(!api_is_allowed_to_edit(false,true)) { Header ----------------------------------------------------------- */ -$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools); +$search_forum=isset($_GET['search']) ? Security::remove_XSS($_GET['search']) : ''; +$interbreadcrumb[]=array("url" => "index.php?search=".$search_forum,"name" => $nameTools); -if ($_GET['action']=='add' ) { +if (isset($_GET['action']) && $_GET['action']=='add' ) { switch ($_GET['content']) { case 'forum': $interbreadcrumb[] = array ("url" => api_get_self().'?'.api_get_cidreq().'&action=add&content=forum', 'name' => get_lang('AddForum')); break; @@ -107,14 +108,14 @@ if ($_GET['action']=='add' ) { } } -Display :: display_header(null); +Display :: display_header(''); api_display_tool_title($nameTools); //echo ''; // tool introduction Display::display_introduction_section(TOOL_FORUM,'left'); - +$form_count=0; /* @@ -122,18 +123,18 @@ Display::display_introduction_section(TOOL_FORUM,'left'); ACTIONS ------------------------------------------------------------------------------------------------------ */ +$get_actions=isset($_GET['action']) ? $_GET['action'] : ''; if (api_is_allowed_to_edit(false,true)) { $fck_attribute['ToolbarSet'] = 'ForumLight'; handle_forum_and_forumcategories(); } // notification -if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) { +if (isset($_GET['action']) && $_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) { $return_message = set_notification($_GET['content'],$_GET['id']); Display :: display_confirmation_message($return_message,false); } - -if ($_GET['action']!='add' && $_GET['action']!='edit' ) { +if ($get_actions!='add' && $get_actions!='edit' ) { get_whats_new(); $whatsnew_post_info = array(); $whatsnew_post_info = $_SESSION['whatsnew_post_info']; @@ -184,6 +185,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { ACTION LINKS ------------------------------------------------------------------------------------------------------ */ + $session_id=isset($_SESSION['id_session']) ? $_SESSION['id_session'] : false; //if (api_is_allowed_to_edit() and !$_GET['action']) echo '
'; echo ''.search_link().''; @@ -220,7 +222,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { echo "\n"; echo ''; - if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($_SESSION['id_session'])!=0)) { + if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($session_id)!=0)) { echo "".icon('../img/edit.gif',get_lang('Edit')).""; echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('forumcategory', prepare4display($forum_category['cat_id']), prepare4display($forum_category['visibility'])); @@ -248,15 +250,17 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { foreach ($forum_list as $key=>$forum) { // Here we clean the whatnew_post_info array a little bit because to display the icon we // test if $whatsnew_post_info[$forum['forum_id']] is empty or not. - if(is_array($whatsnew_post_info[$forum['forum_id']])) { - foreach ($whatsnew_post_info[$forum['forum_id']] as $key_thread_id => $new_post_array) { - if (empty($whatsnew_post_info[$forum['forum_id']][$key_thread_id])) { - unset($whatsnew_post_info[$forum['forum_id']][$key_thread_id]); - unset($_SESSION['whatsnew_post_info'][$forum['forum_id']][$key_thread_id]); + if (!empty($whatsnew_post_info)) { + if (is_array($whatsnew_post_info[$forum['forum_id']])) { + foreach ($whatsnew_post_info[$forum['forum_id']] as $key_thread_id => $new_post_array) { + if (empty($whatsnew_post_info[$forum['forum_id']][$key_thread_id])) { + unset($whatsnew_post_info[$forum['forum_id']][$key_thread_id]); + unset($_SESSION['whatsnew_post_info'][$forum['forum_id']][$key_thread_id]); + } } - } + } } - + // note: this can be speeded up if we transform the $forum_list to an array that uses the forum_category as the key. if (prepare4display($forum['forum_category'])==prepare4display($forum_category['cat_id'])) { // the forum has to be showed if @@ -326,10 +330,12 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { echo icon('../img/forumgroup.gif', get_lang('GroupForum')); } } else { - if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']])) { - echo icon('../img/forum.gif', get_lang('Forum')); - } else { - echo icon('../img/forum.gif'); + if (!empty($whatsnew_post_info)) { + if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']])) { + echo icon('../img/forum.gif', get_lang('Forum')); + } else { + echo icon('../img/forum.gif'); + } } } echo "\n"; @@ -348,8 +354,10 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { echo "\t\t".prepare4display($forum['forum_title']).$session_displayed.''.$forum_title_group_addition.'
'.prepare4display($forum['forum_comment'])."\n"; //$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated // the number of topics and posts - echo "\t\t".$forum['number_of_threads']."\n"; - echo "\t\t".$forum['number_of_posts']."\n"; + $number_threads=isset($forum['number_of_threads']) ? $forum['number_of_threads'] : null; + $number_posts =isset($forum['number_of_posts']) ? $forum['number_of_posts'] : null; + echo "\t\t".$number_threads."\n"; + echo "\t\t".$number_posts."\n"; // the last post in the forum if ($forum['last_poster_name']<>'') { $name=$forum['last_poster_name']; @@ -364,10 +372,8 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { echo $forum['last_post_date']."
".get_lang('By').' '.display_user_link($poster_id, $name); } echo "\n"; - - echo "\t\t"; - if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($_SESSION['id_session'])!=0)) { + if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($session_id)!=0)) { echo "".icon('../img/edit.gif',get_lang('Edit')).""; echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('forum',$forum['forum_id'], $forum['visibility']); @@ -375,8 +381,9 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' ) { display_up_down_icon('forum',$forum['forum_id'], $forums_in_category); } $iconnotify = 'send_mail.gif'; - if (is_array($_SESSION['forum_notification']['forum'])) { - if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) { + $session_forum_noti=isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false; + if (is_array($session_forum_noti)) { + if (in_array($forum['forum_id'],$session_forum_noti)) { $iconnotify = 'send_mail_checked.gif'; } }