diff --git a/checkin_notes b/checkin_notes index fdae3ad123..8345110ca0 100644 --- a/checkin_notes +++ b/checkin_notes @@ -10853,3 +10853,14 @@ Rom 13 Nov 2007 curl/mswin/ + +David 13 Nov 2007 + - user web: change forum prefs editing to use new DB interface + + html/ + inc/ + forum.inc + forum_db.inc + user/ + edit_forum_preferences_action.php + edit_forum_preferences_forum.php diff --git a/html/inc/forum.inc b/html/inc/forum.inc index 3343d8899c..e8e207c7ba 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -370,6 +370,10 @@ function show_posts( } } +function get_ignored_list($user) { + return explode("|", $user->prefs->ignorelist); +} + function add_ignored_user($user, $other_user) { $list = explode("|", $user->prefs->ignorelist); foreach ($list as $key=>$userid) { diff --git a/html/inc/forum_db.inc b/html/inc/forum_db.inc index 7a06084615..b2ff6ebaa2 100644 --- a/html/inc/forum_db.inc +++ b/html/inc/forum_db.inc @@ -121,6 +121,10 @@ class BoincForumPrefs { $clause = "$clause where userid=$this->userid"; return $db->update_aux('forum_preferences', $clause); } + function delete() { + $db = BoincDb::get(); + return $db->delete_aux('forum_preferences', "userid=$this->userid"); + } } class BoincForumLogging { diff --git a/html/user/edit_forum_preferences_action.php b/html/user/edit_forum_preferences_action.php index 22a2595e53..768ef614d7 100644 --- a/html/user/edit_forum_preferences_action.php +++ b/html/user/edit_forum_preferences_action.php @@ -1,51 +1,44 @@ id); $rpc = true; } else { - $user = re_get_logged_in_user(); + $user = get_logged_in_user(); $rpc = false; } +BoincForumPrefs::lookup($user); // If the user has requested a total reset of preferences: -$dbhandler = $mainFactory->getDatabaseHandler(); +// if (post_str("action", true)=="reset"){ - $post_count = $user->getPostcount(); - $banished_until = $user->getBanishedUntil(); - $special_user = $user->getSpecialUser(); - $dbhandler->deleteUserPrefs($user); - $user->resetPrefs(); - $user->setPostcount($post_count); // Recreate postcount - $user->setSpecialUser($special_user); // And recreate special user bitfield - $user->setBanishedUntil($banished_until); + $posts = $user->prefs->posts; + $banished_until = $user->prefs->banished_until; + $special_user = $user->prefs->special_user; + $user->prefs->delete(); + BoincForumPrefs::lookup($user); + $user->prefs->update("posts=$posts, banished_until=$banished_until, special_user=$special_user"); Header("Location: edit_forum_preferences_form.php"); exit; } $avatar_type = post_int("avatar_select"); -$newfile=IMAGE_PATH.$user->getID()."_avatar.jpg"; +$newfile=IMAGE_PATH.$user->id."_avatar.jpg"; // Update the user avatar if ($avatar_type<0 or $avatar_type>3) $avatar_type=0; if ($avatar_type==0){ if (file_exists($newfile)){ - unlink($newfile); //Delete the file on the server if the user - //decides not to use an avatar - // - or should it be kept? + // Delete the file on the server if the user + // decides not to use an avatar + // + unlink($newfile); } $avatar_url=""; } elseif ($avatar_type==2){ @@ -75,75 +68,68 @@ if ($avatar_type==0){ } // Update some simple prefs that are either on or off -$images_as_links = ($_POST["forum_images_as_links"]!=""); -$link_externally = ($_POST["forum_link_externally"]!=""); -$hide_avatars = ($_POST["forum_hide_avatars"]!=""); -$hide_signatures = ($_POST["forum_hide_signatures"]!=""); -$jump_to_unread = ($_POST["forum_jump_to_unread"]!=""); -$ignore_sticky_posts = ($_POST["forum_ignore_sticky_posts"]!=""); -$signature_by_default = ($_POST["signature_enable"]!=""); -$pm_notification = ($_POST["pm_notification"]!=""); -$user->setImagesAsLinks($images_as_links); -$user->setLinkPopup($link_externally); -$user->setHideAvatars($hide_avatars); -$user->setHideSignatures($hide_signatures); -$user->setJumpToUnread($jump_to_unread); -$user->setIgnoreStickyPosts($ignore_sticky_posts); -$user->setSignatureByDefault($signature_by_default); -$user->setEnabledPMNotification($pm_notification); - -// Update avatar -$user->setAvatar($avatar_url); - -// Update the rating thresholds for display of posts +$images_as_links = ($_POST["forum_images_as_links"]!="")?1:0; +$link_popup = ($_POST["forum_link_popup"]!="")?1:0; +$hide_avatars = ($_POST["forum_hide_avatars"]!="")?1:0; +$hide_signatures = ($_POST["forum_hide_signatures"]!="")?1:0; +$jump_to_unread = ($_POST["forum_jump_to_unread"]!="")?1:0; +$ignore_sticky_posts = ($_POST["forum_ignore_sticky_posts"]!="")?1:0; +$no_signature_by_default = ($_POST["signature_by_default"]!="")?0:1; +$pm_notification = ($_POST["pm_notification"]!="")?1:0; $low_rating_threshold = post_int("forum_low_rating_threshold"); $high_rating_threshold = post_int("forum_high_rating_threshold"); -$user->setLowRatingThreshold($low_rating_threshold); -$user->setHighRatingThreshold($high_rating_threshold); - -// Update the signature for this user $signature = stripslashes($_POST["signature"]); if (strlen($signature)>250) { - error_page("Your signature was too long, please keep it less than 250 chars"); + error_page( + "Your signature was too long, please keep it less than 250 chars" + ); } -$user->setSignature($signature); - -// Sorting styles for different forum areas $forum_sort = post_int("forum_sort"); $thread_sort = post_int("thread_sort"); -$user->setForumSortStyle($forum_sort); -$user->setThreadSortStyle($thread_sort); +$minimum_wrap_postcount = post_int("forum_minimum_wrap_postcount"); +$display_wrap_postcount = post_int("forum_display_wrap_postcount"); +if ($minimum_wrap_postcount<0) $minimum_wrap_postcount=0; +if ($display_wrap_postcount>$minimum_wrap_postcount) { + $display_wrap_postcount=round($minimum_wrap_postcount/2); +} +if ($display_wrap_postcount<5) $display_wrap_postcount=5; + +$signature = BoincDb::escape_string($signature); + +$user->prefs->update("images_as_links=$images_as_links, link_popup=$link_popup, hide_avatars=$hide_avatars, hide_signatures=$hide_signatures, jump_to_unread=$jump_to_unread, ignore_sticky_posts=$ignore_sticky_posts, no_signature_by_default=$no_signature_by_default, pm_notification=$pm_notification, avatar='$avatar_url', low_rating_threshold=$low_rating_threshold, high_rating_threshold=$high_rating_threshold, signature='$signature', forum_sorting=$forum_sort, thread_sorting=$thread_sort, minimum_wrap_postcount=$minimum_wrap_postcount, display_wrap_postcount=$display_wrap_postcount"); + -// Add users to the ignore list if any users are defined $add_user_to_filter = ($_POST["add_user_to_filter"]!=""); if ($add_user_to_filter){ $user_to_add = trim($_POST["forum_filter_user"]); if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){ - $user->addIgnoredUser(newUser($user_to_add)); + $other_user = BoincUser::lookup_id($user_to_add); + if (!$other_user) { + echo "No such user: $other_user"; + } else { + add_ignored_user($user, $other_user); + } } } // Or remove some from the ignore list -$ignored_users = $user->getIgnorelist(); +// +$ignored_users = get_ignored_list($user); for ($i=0;$iremoveIgnoredUser(newUser($ignored_users[$i])); + $other_user = BoincUser::lookup_id($user_to_add); + if (!$other_user) { + echo "No such user: $other_user"; + } else { + remove_ignored_user($user, $other_user); + } } } -// Update preferences for the "Display only the Y last posts if there are more than X posts in the thread" feature -$minimum_wrap_postcount = post_int("forum_minimum_wrap_postcount"); -$display_wrap_postcount = post_int("forum_display_wrap_postcount"); -if ($minimum_wrap_postcount<0) $minimum_wrap_postcount=0; -if ($display_wrap_postcount>$minimum_wrap_postcount) $display_wrap_postcount=round($minimum_wrap_postcount/2); -if ($display_wrap_postcount<5) $display_wrap_postcount=5; -$user->setMinimumWrapPostcount($minimum_wrap_postcount); -$user->setDisplayWrapPostcount($display_wrap_postcount); if ($rpc == false) { - // If we get down here everything went ok so let's redirect the user to the setup page again - // so that they can view their new preferences in action in the previews. + // If we get down here everything went ok + // so redirect the user to the setup page again Header("Location: edit_forum_preferences_form.php"); } else { echo "\n"; diff --git a/html/user/edit_forum_preferences_form.php b/html/user/edit_forum_preferences_form.php index c48673698b..fa9462aa69 100644 --- a/html/user/edit_forum_preferences_form.php +++ b/html/user/edit_forum_preferences_form.php @@ -1,17 +1,13 @@ @@ -34,7 +30,7 @@ row1("Reset preferences"); row2("Use this button to reset preferences to the defaults", "
"); echo "
"; -if ($user->hasAvatar()){ +if (strlen($user->prefs->avatar)){ $two_select="checked=\"true\""; } else { $zero_select="checked=\"true\""; @@ -48,34 +44,50 @@ row2("The virtual representation of you on the message boards
" ); -if ($user->hasAvatar()){ +if (strlen($user->prefs->avatar)){ row2("Avatar preview
This is how your avatar will look", - "getAvatar()."\" width=\"100\" height=\"100\">"); + "prefs->avatar."\" width=\"100\" height=\"100\">"); } row1("Sort styles"); row2("How to sort the replies in the message board and Q&A areas", " - - + +
Message threadlist:".select_from_array("forum_sort", $forum_sort_styles, $user->getForumSortStyle())."
Message posts:".select_from_array("thread_sort", $thread_sort_styles, $user->getThreadSortStyle())."
Message threadlist:".select_from_array("forum_sort", $forum_sort_styles, $user->prefs->forum_sorting)."
Message posts:".select_from_array("thread_sort", $thread_sort_styles, $user->prefs->thread_sorting)."
" ); -if ($user->hasLinkPopup()){$forum_link_externally="checked=\"checked\"";} else {$forum_link_externally="";} -if ($user->hasImagesAsLinks()){$forum_image_as_link="checked=\"checked\"";} else {$forum_image_as_link="";} -if ($user->hasJumpToUnread()){$forum_jump_to_unread="checked=\"checked\"";} else {$forum_jump_to_unread="";} -if ($user->hasIgnoreStickyPosts()){$forum_ignore_sticky_posts="checked=\"checked\"";} else {$forum_ignore_sticky_posts="";} +if ($user->prefs->link_popup){ + $forum_link_popup="checked=\"checked\""; +} else { + $forum_link_popup=""; +} +if ($user->prefs->images_as_links){ + $forum_image_as_link="checked=\"checked\""; +} else { + $forum_image_as_link=""; +} +if ($user->prefs->jump_to_unread){ + $forum_jump_to_unread="checked=\"checked\""; +} else { + $forum_jump_to_unread=""; +} +if ($user->prefs->ignore_sticky_posts){ + $forum_ignore_sticky_posts="checked=\"checked\""; +} else { + $forum_ignore_sticky_posts=""; +} -$forum_minimum_wrap_postcount = intval($user->getMinimumWrapPostcount()); -$forum_display_wrap_postcount = intval($user->getDisplayWrapPostcount()); +$forum_minimum_wrap_postcount = intval($user->minimum_wrap_postcount); +$forum_display_wrap_postcount = intval($user->display_wrap_postcount); row1("Display and Behavior"); row2( "
How to treat links and images in the forum
and how to act on unread posts
", "
Show images as links
- Open links in new window/tab
+ Open links in new window/tab
Jump to first new post in thread automatically
Do not reorder sticky posts

@@ -84,16 +96,28 @@ row2(
" ); -if ($user->hasEnabledPMNotification()){$pm_notification="checked=\"checked\"";} else {$pm_notification="";} +if ($user->prefs->pm_notification){ + $pm_notification="checked=\"checked\""; +} else { + $pm_notification=""; +} row2("Private message email notification", "
"); -if ($user->hasHideAvatars()){$forum_hide_avatars="checked=\"checked\"";} else {$forum_hide_avatars="";} -if ($user->hasHideSignatures()){$forum_hide_signatures="checked=\"checked\"";} else {$forum_hide_signatures="";} -$forum_low_rating_threshold= $user->getLowRatingThreshold(); -$forum_high_rating_threshold= $user->getHighRatingThreshold(); +if ($user->prefs->hide_avatars){ + $forum_hide_avatars = "checked=\"checked\""; +} else { + $forum_hide_avatars = ""; +} +if ($user->prefs->hide_signatures){ + $forum_hide_signatures = "checked=\"checked\""; +} else { + $forum_hide_signatures = ""; +} +$forum_low_rating_threshold = $user->prefs->low_rating_threshold; +$forum_high_rating_threshold = $user->prefs->high_rating_threshold; row1("Filtering"); row2( @@ -112,11 +136,15 @@ row2( " ); -$filtered_userlist=$user->getIgnorelist(); -for ($i=0;$igetID()."\" value=\"Remove\"> ".$filtered_user->getID()." - ".re_user_links($filtered_user,URL_BASE)."
"; +$filtered_userlist = get_ignored_list($user); +for ($i=0; $iid."\" value=\"Remove\"> ".$filtered_user->id." - ".user_links($filtered_user)."
"; } } row2("Filtered users". @@ -134,8 +162,12 @@ row2("Filtered users". " ); -if ($user->hasSignatureByDefault()){$enable_signature="checked=\"checked\"";} else {$enable_signature="";} -$signature=stripslashes($user->getSignature()); +if (!$user->prefs->no_signature_by_default){ + $signature_by_default="checked=\"checked\""; +} else { + $signature_by_default=""; +} +$signature=stripslashes($user->prefs->signature); $maxlen=250; row1("Signature"); row2(html_info(). @@ -144,12 +176,12 @@ row2(html_info().
chars remaining -
Attach signature by default +
Attach signature by default "); -if ($user->getSignature()!=""){ +if ($user->prefs->signature!=""){ row2("Signature preview". "
This is how your signature will look in the forums", - output_transform($user->getSignature()) + output_transform($user->prefs->signature) ); } row1(" "); @@ -157,4 +189,6 @@ row2("", ""); echo "\n"; end_table(); page_tail(); + +$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?>