From 2786169a291e7fcb5df8174e8ef40947f753ff89 Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Mon, 5 Jan 2009 21:01:06 +0100 Subject: [PATCH] [svn r17540] Logic Changes - Fixed little bugs founded in forum see FS#3416 --- main/forum/forumfunction.inc.php | 124 ++++++++++++++++--------------- main/forum/index.php | 33 ++++++-- main/forum/viewforum.php | 6 +- 3 files changed, 93 insertions(+), 70 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index af094686e3..a86904f0b5 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -104,8 +104,9 @@ function handle_forum_and_forumcategories() { show_add_forum_form($inputvalues); } // Edit a forum category - if (($action_forum_cat=='edit' && $_GET['content']=='forumcategory' && $get_id) || $post_submit_cat ) { - $forum_category=get_forum_categories(strval(intval($get_id))); // note: this has to be cleaned first + if (($action_forum_cat=='edit' && $_GET['content']=='forumcategory' && isset($_GET['id'])) || $_POST['SubmitEditForumCategory'] ) + { + $forum_category=get_forum_categories(strval(intval($_GET['id']))); // note: this has to be cleaned first show_edit_forumcategory_form($forum_category); } // Delete a forum category @@ -234,8 +235,8 @@ function show_add_forum_form($inputvalues=array()) { document.getElementById('plus').innerHTML=' \"\" ".get_lang('AddAnAttachment')."'; }*/ - $form->addElement('static','Group','

'.get_lang('AdvancedParameters').'
'); - $form->addElement('html',''); + // The OK button $form->addElement('submit', 'SubmitForum', get_lang('OK')); // setting the rules @@ -416,7 +416,7 @@ function delete_forum_image($forum_id) */ function show_edit_forumcategory_form($inputvalues=array()) { // initiate the object - $form = new FormValidator('forumcategory'); + $form = new FormValidator('forumcategory','post'); // settting the form elements $form->addElement('header', '', get_lang('EditForumCategory')); @@ -426,10 +426,10 @@ function show_edit_forumcategory_form($inputvalues=array()) { $form->addElement('submit', 'SubmitEditForumCategory',get_lang('OK')); global $charset; // setting the default values - $defaultvalues['forum_category_id']=isset($inputvalues['cat_id'])?$inputvalues['cat_id']:null; + $defaultvalues['forum_category_id']=$inputvalues['cat_id']; - $defaultvalues['forum_category_title']=prepare4display(html_entity_decode(isset($inputvalues['cat_title'])?$inputvalues['cat_title']:null,ENT_QUOTES,$charset)); - $defaultvalues['forum_category_comment']=prepare4display(isset($inputvalues['cat_comment'])?$inputvalues['cat_comment']:null); + $defaultvalues['forum_category_title']=prepare4display(html_entity_decode($inputvalues['cat_title'],ENT_QUOTES,$charset)); + $defaultvalues['forum_category_comment']=prepare4display($inputvalues['cat_comment']); $form->setDefaults($defaultvalues); // setting the rules @@ -527,7 +527,7 @@ function store_forum($values) { } // remove existing picture if asked - if (isset($values['remove_picture'])) { + if (!empty($_POST['remove_picture'])) { delete_forum_image($values['forum_id']); } @@ -561,28 +561,32 @@ function store_forum($values) { if (isset($values['forum_id'])) { $sql_image=isset($sql_image)?$sql_image:''; $new_file_name=isset($new_file_name) ? $new_file_name:''; - if ($image_moved) { - $sql_image=" forum_image='".Database::escape_string($new_file_name)."', "; - delete_forum_image($values['forum_id']); - } + if ($image_moved) { + if(empty($_FILES['picture']['name'])){ + $sql_image=" "; + } else { + $sql_image=" forum_image='".Database::escape_string($new_file_name)."', "; + delete_forum_image($values['forum_id']); + } + } - // storing an edit - $sql="UPDATE ".$table_forums." SET - forum_title='".$clean_title."', - ".$sql_image." - forum_comment='".Database::escape_string($values['forum_comment'])."', - forum_category='".Database::escape_string($values['forum_category'])."', - allow_anonymous='".Database::escape_string(isset($values['allow_anonymous_group']['allow_anonymous'])?$values['allow_anonymous_group']['allow_anonymous']:null)."', - allow_edit='".Database::escape_string($values['students_can_edit_group']['students_can_edit'])."', - approval_direct_post='".Database::escape_string(isset($values['approval_direct_group']['approval_direct'])?$values['approval_direct_group']['approval_direct']:null)."', - allow_attachments='".Database::escape_string(isset($values['allow_attachments_group']['allow_attachments'])?$values['allow_attachments_group']['allow_attachments']:null)."', - allow_new_threads='".Database::escape_string($values['allow_new_threads_group']['allow_new_threads'])."', - forum_group_public_private='".Database::escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."', - default_view='".Database::escape_string($values['default_view_type_group']['default_view_type'])."', - forum_of_group='".Database::escape_string($values['group_forum'])."' - WHERE forum_id='".Database::escape_string($values['forum_id'])."'"; - api_sql_query($sql,__FILE__,__LINE__); - $return_message=get_lang('ForumEdited'); + // storing an edit + $sql="UPDATE ".$table_forums." SET + forum_title='".$clean_title."', + ".$sql_image." + forum_comment='".Database::escape_string($values['forum_comment'])."', + forum_category='".Database::escape_string($values['forum_category'])."', + allow_anonymous='".Database::escape_string(isset($values['allow_anonymous_group']['allow_anonymous'])?$values['allow_anonymous_group']['allow_anonymous']:null)."', + allow_edit='".Database::escape_string($values['students_can_edit_group']['students_can_edit'])."', + approval_direct_post='".Database::escape_string(isset($values['approval_direct_group']['approval_direct'])?$values['approval_direct_group']['approval_direct']:null)."', + allow_attachments='".Database::escape_string(isset($values['allow_attachments_group']['allow_attachments'])?$values['allow_attachments_group']['allow_attachments']:null)."', + allow_new_threads='".Database::escape_string($values['allow_new_threads_group']['allow_new_threads'])."', + forum_group_public_private='".Database::escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."', + default_view='".Database::escape_string($values['default_view_type_group']['default_view_type'])."', + forum_of_group='".Database::escape_string($values['group_forum'])."' + WHERE forum_id='".Database::escape_string($values['forum_id'])."'"; + api_sql_query($sql,__FILE__,__LINE__); + $return_message=get_lang('ForumEdited'); } else { $sql_image=''; if ($image_moved) { diff --git a/main/forum/index.php b/main/forum/index.php index dcda6575ac..a027953857 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -55,6 +55,18 @@ $htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; // the section (tabs) $this_section=SECTION_COURSES; @@ -317,13 +329,20 @@ if (isset($_GET['action']) && $_GET['action'] == 'notify' AND isset($_GET['conte echo "\t\n"; // Showing the image - echo "\t\t"; + echo "\t\t"; if(!empty($forum['forum_image'])) { - echo ''; - } - echo "\n"; - - + $image_path = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/forum/images/'.$forum['forum_image']; + $image_size = @getimagesize($image_path); + $img_attributes = ''; + if (!empty($image_size)) { + if ($image_size[0] > 100 || $image_size[1] > 100) { + //limit display width and height to 100px + $img_attributes = 'width="100" height="100"'; + } + echo ""; + } + } + echo "\n"; echo "\t\t"; if ($forum['forum_of_group']!=='0') { @@ -402,7 +421,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'notify' AND isset($_GET['conte } if (count($forum_list)==0) { - echo "\t".get_lang('NoForumInThisCategory')."".(api_is_allowed_to_edit(false,true)?'':'')."\n"; + echo "\t".get_lang('NoForumInThisCategory')."".(api_is_allowed_to_edit(false,true)?'':'')."\n"; } } } diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index d79b36d751..6ca36fca5d 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -169,7 +169,7 @@ if ($my_action == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) { if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND $userinf['status']=='1') { - switch(isset($_GET['list'])) { + switch($_GET['list']) { case "qualify": $student_list=get_thread_users_qualify($_GET['id']); $nrorow3 =-2; @@ -362,9 +362,9 @@ if(is_array($threads)) { } if($origin != 'learnpath') { - echo "\t\t".display_user_link($row['user_id'], $name)."\n"; + echo "\t\t".display_user_link($row['user_id'], $row['firstname'].' '.$row['lastname'])."\n"; } else { - echo "\t\t".$name."\n"; + echo "\t\t".$row['firstname'].' '.$row['lastname']."\n"; } // if the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread