diff --git a/checkin_notes b/checkin_notes index ceeb5ede9d..9fbf70a8ff 100755 --- a/checkin_notes +++ b/checkin_notes @@ -16973,3 +16973,65 @@ David 3 Sept 2004 app_start.C client_types.C,h cs_apps.C + +David 4 Sept 2004 + - New features for message boards (from Janus Kristensen): + Added: + - External avatars (but commented it out - + it's better to use hosted avatars) + (Tiny images under people's name) + - Hosted avatars + (Uploads and scales to 100x100 in the IMGAGE_PATH dir) + - Special users + (Project admins, devs, newcomers etc. will get a line + telling what they are under their name) + - Option to display images as links + - Option to open links in a new window + - Option to hide avatars + - Option to enable/disable attach of signature by default + - Settings for sorting is now handled using the database + instead of cookies (ie. you can change host without + having to set your preferences up again, + some users also have cookies disabled) + - Preview of signature + - Unread posts are marked as "Unread" + (if they are newer than 2 days (configurable in forum.inc) + and user hasn't visited the post) + - Interface to forum preferences and sorting methods + - Link to interface from user preferences + - Reset forum preferences button + (Some users have reported that an unusually long + signature with html could make the page unviewable. This fixes it) + - Option to sort with "Oldest first" in answers in the FAQ area + + Moved: + - Signature input in user prefs to forum prefs + + Fixed: + - Sorting in answers in the FAQ area didn't work + - minor speedups and html stuff + + DB-stuff: + - create forum_preferences & forum_logging + - transfer old settings + + NOTE: If you want to use these features, you will need to + create two new DB tables (forum_preferences and forum_logging; + just execute the commands from schema.sql) + and you'll probably want to copy existing signatures and nposts + from the user table (see html/ops/db_update.php) + + html/ + inc/ + forum.inc + forum_show.inc + user.inc + user/ + edit_forum_preferences_action.php (new) + edit_forum_preferences_form.php (new) + edit_user_info_action.php + edit_user_info_form.php + forum_forum.php + forum_post.php + forum_reply.php + forum_thread.php diff --git a/db/schema.sql b/db/schema.sql index 13ec7c7709..49113346f6 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -363,3 +363,25 @@ create table subscriptions ( userid integer not null, threadid integer not null ) type=InnoDB; + +create table forum_preferences ( + userid integer not null default 0, + signature varchar(254) not null default '', + posts integer not null default 0, + avatar varchar(254) not null default '', + avatar_type tinyint(4) not null default 0, + hide_avatars tinyint(1) unsigned not null default 0, + sorting varchar(100) not null default '', + no_signature_by_default tinyint(1) unsigned not null default 0, + images_as_links tinyint(1) unsigned not null default 0, + link_popup tinyint(1) unsigned not null default 0, + mark_as_read_timestamp integer not null default 0, + primary key (userid) +) type=MyISAM; + +create table forum_logging ( + userid integer not null default 0, + threadid integer not null default 0, + timestamp integer not null default 0, + primary key (userid,threadid) +) TYPE=MyISAM; diff --git a/html/inc/forum.inc b/html/inc/forum.inc index c79519ab08..828112f72b 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -4,6 +4,19 @@ require_once('../inc/db.inc'); require_once('../inc/sanitize_html.inc'); require_once('../inc/time.inc'); +define('AVATAR_WIDTH', 100); +define('AVATAR_HEIGHT',100); +define('ST_ADMIN', 'Project administrator'); +define('ST_MODERATOR', 'Forum moderator'); +define('ST_DEV', 'Developer'); +define('ST_VOLDEV', 'Volunteer developer'); +define('ST_SCIENT', 'Project scientist'); +define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days +define('ST_NEW', 'New member'); + + +define('FORUM_OPEN_LINK_IN_NEW_WINDOW',1); +define('MAX_FORUM_LOGGING_TIME', 172800); //3600*24*2 - 2 days define('NO_CONTROLS', 0); define('FORUM_CONTROLS', 1); define('HELPDESK_CONTROLS', 2); @@ -20,16 +33,17 @@ $forum_sort_styles['modified-old'] = "Least recent post first"; $forum_sort_styles['views-most'] = "Most views first"; $forum_sort_styles['replies-most'] = "Most posts first"; +$thread_sort_styles['timestamp'] = "Newest first"; +$thread_sort_styles['timestamp_asc'] = "Oldest first"; +$thread_sort_styles['score'] = "Highest rated first"; + $faq_sort_styles['create_time'] = "Most recent question first"; $faq_sort_styles['timestamp'] = "Most recent answer first"; $faq_sort_styles['activity'] = "Most frequently asked first"; $answer_sort_styles['score'] = "Highest score first"; $answer_sort_styles['timestamp'] = "Most recent first"; - -$thread_sort_styles['timestamp'] = "Newest first"; -$thread_sort_styles['timestamp_asc'] = "Oldest first"; -$thread_sort_styles['score'] = "Highest rated first"; +$answer_sort_styles['timestamp_asc'] = "Oldest first"; $thread_filter_styles['2'] = "\"Very helpful\""; $thread_filter_styles['1'] = "At least \"helpful\""; @@ -182,11 +196,89 @@ function getFirstPost($threadID) { } } +function getForumPreferences($user){ + $sql = "SELECT * FROM forum_preferences WHERE userid = '".$user->id."'"; + $result = mysql_query($sql); + if (mysql_num_rows($result)>0) { + $prefs=mysql_fetch_object($result); + + //Todo - find out how to simply merge two objects instead of specifying all the fields manually here + $user->avatar=$prefs->avatar; + $user->hide_avatars=$prefs->hide_avatars; + $user->sorting=$prefs->sorting; + $user->images_as_links=$prefs->images_as_links; + $user->signature=$prefs->signature; + $user->posts=$prefs->posts; + $user->avatar_type=$prefs->avatar_type; + $user->no_signature_by_default=$prefs->no_signature_by_default; + $user->link_popup=$prefs->link_popup; + $user->mark_as_read_timestamp=$prefs->mark_as_read_timestamp; + $user->forum_preferences=1; + } else { + mysql_query("insert into forum_preferences set userid='".$user->id."'"); + $user->forum_preferences=0; + } + return $user; +} + +function getSortStyle($user,$place){ + list($forum,$thread,$faq,$answer)=explode("|",$user->sorting); + return $$place; +} + +function setSortStyle($user,$place,$new_style){ + list($forum,$thread,$faq,$answer)=explode("|",$user->forum_sorting); + $$place=$new_style; + $user->forum_sorting=implode("|",array($forum,$thread,$faq,$answer)); + $sql = "UPDATE forum_preferences SET sorting = '".$user->forum_sorting."' where userid = '".$user->id."'"; + mysql_query($sql); +} + +function getThreadLastVisited($user, $thread){ + $sql = "SELECT timestamp from forum_logging where userid='".$user->id."' and threadid='".$thread->id."'"; + $result = mysql_query($sql); + if ($result) { + $data=mysql_fetch_object($result); + $user->thread_last_visited=$data->timestamp; + } else { + } + $user->thread_last_visited= max(time()-MAX_FORUM_LOGGING_TIME,$user->thread_last_visited,$user->mark_as_read_timestamp); + //echo $user->thread_last_visited." - ".time(); + return $user; +} + +function setThreadLastVisited($user, $thread, $timestamp=""){ + if ($timestamp==""){$timestamp=time();}; + $sql = "REPLACE DELAYED into forum_logging set userid='".$user->id."', threadid='".$thread->id."', timestamp='$timestamp'"; + mysql_query($sql); +} + + function incThreadViews($threadID) { $sql = "UPDATE thread SET views = views + 1 WHERE id = " . $threadID . " LIMIT 1"; mysql_query($sql); } +function cleanup_forum_log(){ + $sql = "SELECT timestamp FROM forum_logging where userid=0 and threadid=0"; + $result=mysql_query($sql); + if (mysql_num_rows($result)>0) { + $data=mysql_fetch_object($result); + if ($data->timestampid, -1, -1, $sort_style); + $logged_in_user = getThreadLastVisited($logged_in_user,$thread); + setThreadLastVisited($logged_in_user,$thread); + + $firstPost = getFirstPost($thread->id); if ($is_helpdesk) { @@ -302,22 +398,40 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS global $post_ratings; $user = lookup_user_id($post->user); - $sql = "SELECT * FROM profile WHERE userid = " . $user->id; - $result2 = mysql_query($sql); - $user->has_profile = (mysql_num_rows($result2) > 0); - + $user = getForumPreferences($user); + $data = mysql_query("SELECT userid FROM profile WHERE userid = " . $user->id); //Lookup existance of profile for user + $user->has_profile = (mysql_numrows($data) > 0); //and store this info in the user object + $user->has_avatar = ($user->avatar != ""); //for later access + $can_edit = $logged_in_user && $user->id == $logged_in_user->id; echo " - + - id > + id\"> "; echo user_links($user, URL_BASE); + + if ($user->rights) { //If this user is somehow special + if ($user->rights==1) $fstatus=ST_ADMIN; //this is displayed in the forums + if ($user->rights==2) $fstatus=ST_MODERATOR; //so that people know who they are + if ($user->rights==3) $fstatus=ST_DEV; //talking to. + if ($user->rights==4) $fstatus=ST_VOLDEV; + if ($user->rights==5) $fstatus=ST_SCIENT; + /*...*/ + } else { + if ($user->create_time>time()-ST_NEW_TIME) $fstatus=ST_NEW; + /*...*/ + } + if ($fstatus) echo "
$fstatus"; + + echo " +

"; + + if ($user->has_avatar and $logged_in_user->hide_avatars!=1) echo "avatar."\" alt=\"Avatar\">
"; echo " -

Joined: ", gmdate('M j, Y', $user->create_time), "
Posts: ", $user->posts, "

@@ -327,10 +441,17 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) { echo "
id, "\" method=\"post\">"; } + echo " - \n"; echo "\n
+ "; + + if ($post->timestamp>$logged_in_user->thread_last_visited){ + echo "\"Unread"; + } + + echo " Posted: ", pretty_time_str($post->timestamp); ; @@ -364,7 +485,22 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) { echo ""; } - echo "

", nl2br(stripslashes($post->content)), "

"; + + $posttext=nl2br(stripslashes($post->content)); + //echo $logged_in_user->images_as_links; + + if ($logged_in_user->images_as_links==1){ + $posttext=image_as_link($posttext); + } + //echo $logged_in_user->link_popup; + if ($logged_in_user->link_popup==1){ + $posttext=externalize_links($posttext); + } + + echo "

", $posttext, "

"; + + + echo ""; $x = time_diff_str($thread->timestamp, time()); + + $logged_in_user=getThreadLastVisited($logged_in_user,$thread); + if ($thread->timestamp>$logged_in_user->thread_last_visited){ + $unread="Unread post(s): "; + } else { + $unread=""; + } if ($category->is_helpdesk) { if ($thread->replies == 0) $x = "---"; echo " - + "; } diff --git a/html/inc/user.inc b/html/inc/user.inc index 3e51de6327..fc6aed5b13 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -69,10 +69,10 @@ function show_user_info_private($user) { row2("URL", $x); row2("Country", $user->country); row2("Postal code", $user->postal_code); - if ($user->signature) { +/* if ($user->signature) { $x = "
".htmlspecialchars($user->signature)."
"; row2("Forums signature", $x); - } + }*/ row2("", "Edit account info"); row1("Profile"); @@ -94,6 +94,9 @@ function show_user_info_private($user) { row2(PROJECT."
control project's resource share and customize screensaver graphics", "View or edit" ); + row2("Forum
configure features and the appearance of the forum", + "View or edit" + ); } // show summary of dynamic and static info (public) diff --git a/html/ops/db_update.php b/html/ops/db_update.php index c5e70940e8..8c36c3c0cb 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -89,6 +89,11 @@ function update_7_08_2004() { ); } -//update_6_15_2004(); +function update_9_04_2004() { + mysql_query( + "insert into forum_preferences (userid, signature, posts) select user.id, user.signature, user.posts from user where user.posts > 0 or user.signature<>''"); +} + +//update_9_04_2004(); ?> diff --git a/html/user/edit_forum_preferences_action.php b/html/user/edit_forum_preferences_action.php new file mode 100644 index 0000000000..c78b5ece99 --- /dev/null +++ b/html/user/edit_forum_preferences_action.php @@ -0,0 +1,93 @@ +id."_avatar.jpg"; + if ($avatar_type<0 or $avatar_type>3) $avatar_type=0; + if ($avatar_type==0){ + if (file_exists($newfile)){ + unset($newfile); //Delete the file on the server if the user + //decides not to use an avatar + // - or should it be kept? + } + $avatar_url=""; + } elseif ($avatar_type==2){ + if ($_FILES['picture']['tmp_name']!=""){ + $file=$_FILES['picture']['tmp_name']; + $size = getImageSize($file); + // print_r($size);flush(); + switch($size[2]) { + case '2': // JPEG + $image = imageCreateFromJPEG($file); + break; + case '3': // PNG + $image = imageCreateFromPNG($file); + break; + default: + //Not the right kind of file + Echo "Error: Not the right kind of file"; + exit(); + } + $width = $size[0]; + $height = $size[1]; + if ($width!=100||$height!=100){ + $image2 = scale_image($image, $width, $height, 100, 100); + } else { + $image2=$image; + } + ImageJPEG($image2, $newfile); + } + if (file_exists($newfile)){ + $avatar_url=IMAGE_URL.$user->id."_avatar.jpg"; //$newfile; + } else { + //User didn't upload a compatible file or it went lost on the server + $avatar_url=""; + } + } + + $image_as_link = ($HTTP_POST_VARS["forum_images_as_links"]!=""); + $link_externally = ($HTTP_POST_VARS["forum_link_externally"]!=""); + $hide_avatars = ($HTTP_POST_VARS["forum_hide_avatars"]!=""); + + $no_signature_by_default=($HTTP_POST_VARS["signature_enable"]==""); + $signature = mysql_escape_string($HTTP_POST_VARS["signature"]); + + $forum_sort = $HTTP_POST_VARS["forum_sort"]; + $thread_sort = $HTTP_POST_VARS["thread_sort"]; + $faq_sort = $HTTP_POST_VARS["faq_sort"]; + $answer_sort = $HTTP_POST_VARS["answer_sort"]; + $forum_sorting=mysql_escape_string(implode("|",array($forum_sort,$thread_sort,$faq_sort,$answer_sort))); + $has_prefs=mysql_query("select * from forum_preferences where userid='".$user->id."'"); + + $result = mysql_query( + "update forum_preferences set + avatar_type='".$avatar_type."', + avatar='".$avatar_url."', + images_as_links='".$image_as_link."', + link_popup='".$link_externally."', + hide_avatars='".$hide_avatars."', + no_signature_by_default='".$no_signature_by_default."', + sorting='".$forum_sorting."', + signature='$signature' + where userid=$user->id"); + if ($result) { + echo mysql_error(); + Header("Location: home.php"); + } else { + page_head("Forum preferences update"); + echo "Couldn't update forum preferences.
\n"; + echo mysql_error(); + page_tail(); + } + +?> diff --git a/html/user/edit_forum_preferences_form.php b/html/user/edit_forum_preferences_form.php new file mode 100644 index 0000000000..309dab3e6d --- /dev/null +++ b/html/user/edit_forum_preferences_form.php @@ -0,0 +1,79 @@ +Use this button to reset preferences to the defaults", + ""); +echo ""; + + + +if ($user->avatar_type==0){ + $zero_select="checked=true"; +} elseif($user->avatar_type==1){ + $one_select="checked=true"; + $avatar_url=$user->avatar; +} elseif($user->avatar_type==2){ + $two_select="checked=true"; +} + +row2("Avatar
The virtual representation of you on the message boards
Note: Forced size of 100x100 pixels
format: jpg/png - size: at most 4k
", + " +
ID: ", $post->id; @@ -398,6 +534,39 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS /* utility functions */ +function externalize_links($text){ + $i=0;$linkpos=true; + while (true){ //Find a link + $linkpos=strpos($text,"",$imgpos)+1; //Or the end of the tag + if ($temp1<$temp2){ //If source was found within tag + $temp3=strpos($text,"\"",$temp1); //Find the end of source + $out.=substr($text,$temp1,$temp3-$temp1); //output the source + } + $out.=">[Image link]"; + $i=$temp2; //Now move to end of tag to continue + } + $out.=substr($text,$i); //Output the rest + return $out; +} + + function start_forum_table($headings, $span=NULL) { echo "

@@ -422,17 +591,22 @@ function end_forum_table() { // generate a "select" element from an array of values // -function show_select_from_array($name, $array, $selection) { - echo ""; foreach ($array as $key => $value) { - echo ""; + $out.= "value=\"". $key. "\">". $value. ""; } - echo ""; + $out.= ""; + return $out; +} + +function show_select_from_array($name, $array, $selection) { + echo select_from_array($name,$array,$selection); } function show_forum_title($forum=NULL, $thread=NULL, $helpdesk=false) { diff --git a/html/inc/forum_show.inc b/html/inc/forum_show.inc index 475135d142..0ba264e17b 100644 --- a/html/inc/forum_show.inc +++ b/html/inc/forum_show.inc @@ -74,7 +74,7 @@ function show_page_nav($forum) { return $gotoStr; } -function show_forum($category, $forum, $start, $sort_style) { +function show_forum($category, $forum, $start, $sort_style, $logged_in_user) { global $threads_per_page; $gotoStr = show_page_nav($forum); if ($category->is_helpdesk) { @@ -105,6 +105,13 @@ function show_forum($category, $forum, $start, $sort_style) { echo "

@@ -117,7 +124,7 @@ function show_forum($category, $forum, $start, $sort_style) { ", $thread->replies+1, " ", user_links($user), " ", $thread->views, "", $x, "", $unread, " ", $x, "
+ + + +
Don't use an avatar
Use this uploaded avatar:
+ " +); +row2("Sort styles
How to sort the replies in the message board and Q&A areas", + " + + + + + +
Message threadlist:".select_from_array("forum_sort", $forum_sort_styles, getSortStyle($user,"forum"))."
Message posts:".select_from_array("thread_sort", $thread_sort_styles, getSortStyle($user,"thread"))."
Q&A questionlist:".select_from_array("faq_sort", $faq_sort_styles, getSortStyle($user,"faq"))."
Q&A questions:".select_from_array("answer_sort", $answer_sort_styles, getSortStyle($user,"answer"))."
" +); + +if ($user->link_popup==1){$forum_link_externally="checked=\"true\"";} else {$forum_link_externally="";} +if ($user->images_as_links==1){$forum_image_as_link="checked=\"true\"";} else {$forum_image_as_link="";} +if ($user->hide_avatars==1){$forum_hide_avatars="checked=\"true\"";} else {$forum_hide_avatars="";} + +row2("Links and images". + "
How to treat links and images in the forum", + " + Open links in new window/tab
+ Show images as links
+ Hide avatar images
+ " +); + +if ($user->no_signature_by_default==0){$enable_signature="checked=\"true\"";} else {$enable_signature="";} +row2("Signature for message boards". + "
May contain HTML tags", + " + +
Attach signature by default" +); +if ($user->signature!=""){ +row2("Signature preview". + "
This is how your signature will look in the forums", + sanitize_html(stripslashes($user->signature)) +); +} +row2("", ""); +end_table(); +echo "\n"; +page_tail(); + +?> diff --git a/html/user/edit_user_info_action.php b/html/user/edit_user_info_action.php index 1c1ef7c421..1f1a1dfa0a 100644 --- a/html/user/edit_user_info_action.php +++ b/html/user/edit_user_info_action.php @@ -10,9 +10,9 @@ $url = $HTTP_POST_VARS["url"]; $country = $HTTP_POST_VARS["country"]; $postal_code = $HTTP_POST_VARS["postal_code"]; - $signature = $HTTP_POST_VARS["signature"]; + //$signature = $HTTP_POST_VARS["signature"]; - $result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code', signature='$signature' where id=$user->id"); + $result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code' where id=$user->id"); if ($result) { Header("Location: home.php"); } else { diff --git a/html/user/edit_user_info_form.php b/html/user/edit_user_info_form.php index f8f7c77ba3..bc6bcd37ce 100644 --- a/html/user/edit_user_info_form.php +++ b/html/user/edit_user_info_form.php @@ -26,12 +26,13 @@ row2("Postal (ZIP) code
Optional", "" ); +/* $x = ""; row2("Signature for message boards". "
May contain HTML tags". "
Optional", $x -); +);*/ row2("", ""); end_table(); echo "\n"; diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 17d3e2d185..8a19eb9724 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -26,18 +26,20 @@ $category = getCategory($forum->category); if ($category->is_helpdesk) { $sort_style = $_GET['sort']; if (!$sort_style) { - $sort_style = $_COOKIE['hd_sort_style']; + $sort_style = getSortStyle($logged_in_user,"faq"); } else { - setcookie('hd_sort_style', $sort_style, time()+3600*24*365); + setSortStyle($logged_in_user,"faq",$sort_style); } if (!$sort_style) $sort_style = 'activity'; page_head('Help Desk'); } else { $sort_style = $_GET['sort']; if (!$sort_style) { - $sort_style = $_COOKIE['forum_sort_style']; + $sort_style = getSortStyle($logged_in_user,"forum"); + //$sort_style = $_COOKIE['forum_sort_style']; } else { - setcookie('forum_sort_style', $sort_style, time()+3600*24*365); + setSortStyle($logged_in_user, "forum",$sort_style); + //setcookie('forum_sort_style', $sort_style, time()+3600*24*365); } if (!$sort_style) $sort_style = 'modified-new'; page_head('Message boards : '.$forum->title); @@ -73,7 +75,7 @@ echo "
\n"; -show_forum($category, $forum, $start, $sort_style); +show_forum($category, $forum, $start, $sort_style, $logged_in_user); page_tail(); diff --git a/html/user/forum_post.php b/html/user/forum_post.php index baac4aca13..7d7c8083a4 100644 --- a/html/user/forum_post.php +++ b/html/user/forum_post.php @@ -4,15 +4,17 @@ require_once('../inc/forum.inc'); require_once('../inc/util.inc'); require_once('../inc/subscribe.inc'); -if (!empty($_GET['id']) && !empty($_POST['title']) && !empty($_POST['content'])) { - $_GET['id'] = stripslashes(strip_tags($_GET['id'])); +$logged_in_user = get_logged_in_user(true); +$logged_in_user = getForumPreferences($logged_in_user); + +if (!empty($_GET['id']) && !empty($_POST['title']) && !empty($_POST['content'])) { + $_GET['id'] = stripslashes(strip_tags($_GET['id'])); - $user = get_logged_in_user(true); if ($_POST['add_signature']=="add_it") { - $forum_signature = "\n".$user->signature; + $forum_signature = "\n".$logged_in_user->signature; } - $threadID = createThread($_GET['id'], $user->id, $_POST['title'], $_POST['content'].$forum_signature); + $threadID = createThread($_GET['id'], $logged_in_user->id, $_POST['title'], $_POST['content'].$forum_signature); if (!$threadID) { page_head("Can't create thread"); echo "Title is possibly missing"; @@ -31,7 +33,6 @@ if (!empty($_GET['id'])) { exit(); } -$logged_in_user = get_logged_in_user(true); // TODO: Write a function to do this. @@ -97,8 +98,9 @@ if ($category->is_helpdesk) { $y = ""; +if ($logged_in_user->no_signature_by_default==0){$enable_signature="checked=\"true\"";} else {$enable_signature="";} row2($x, $y); -row2("", "Add my signature to this post"); +row2("", "Add my signature to this post"); row2("", ""); end_forum_table(); diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index 396020bc46..422059869f 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -4,6 +4,10 @@ require_once('../inc/forum.inc'); require_once('../inc/util.inc'); require_once('../inc/subscribe.inc'); +$logged_in_user = get_logged_in_user(true); +$logged_in_user = getForumPreferences($logged_in_user); + + if (!empty($_GET['thread']) && !empty($_POST['content'])) { $_GET['thread'] = stripslashes($_GET['thread']); @@ -13,18 +17,15 @@ if (!empty($_GET['thread']) && !empty($_POST['content'])) { $parent_post = NULL; } - $user = get_logged_in_user(true); - if ($_POST['add_signature']=="add_it"){ - $forum_signature = "\n".$user->signature; + $forum_signature = "\n".$logged_in_user->signature; } - replyToThread($_GET['thread'], $user->id, $_POST['content'].$forum_signature, $parent_post); + replyToThread($_GET['thread'], $logged_in_user->id, $_POST['content'].$forum_signature, $parent_post); notify_subscribers($_GET['thread']); header('Location: forum_thread.php?id='.$_GET['thread']); } -$logged_in_user = get_logged_in_user(true); if (empty($_GET['thread'])) { // TODO: Standard error page. @@ -94,10 +95,11 @@ function show_message_row($thread, $category, $post=NULL) { echo "' method=post>

    - Add my signature to this reply + Add my signature to this reply "; diff --git a/html/user/forum_thread.php b/html/user/forum_thread.php index a38cb45e79..24571e5415 100644 --- a/html/user/forum_thread.php +++ b/html/user/forum_thread.php @@ -26,17 +26,25 @@ $forum = getForum($thread->forum); $category = getCategory($forum->category); $logged_in_user = get_logged_in_user(false); - -if (!$sort_style) { - $sort_style = $_COOKIE['thread_sort_style']; -} else { - setcookie('thread_sort_style', $sort_style, time()+3600*24*365); -} +$logged_in_user = getForumPreferences($logged_in_user); if ($category->is_helpdesk) { page_head(PROJECT.': Questions and problems'); + if (!$sort_style) { + $sort_style = getSortStyle($logged_in_user,"answer"); + } else { + setSortStyle($logged_in_user,"answer", $sort_style); + //);setcookie('thread_sort_style', $sort_style, time()+3600*24*365); + } + } else { page_head(PROJECT.': Message boards'); + if (!$sort_style) { + $sort_style = getSortStyle($logged_in_user,"thread"); + } else { + setSortStyle($logged_in_user,"thread", $sort_style); + //);setcookie('thread_sort_style', $sort_style, time()+3600*24*365); + } } // TODO: Constant for default sort style and filter values. @@ -91,7 +99,7 @@ echo ""; echo ""; if ($category->is_helpdesk) { - show_select_from_array("sort", $answer_sort_styles, $sort_styles); + show_select_from_array("sort", $answer_sort_styles, $sort_style); } else { echo "Sort "; show_select_from_array("sort", $thread_sort_styles, $sort_style);