2004-09-04 23:37:49 +00:00
|
|
|
<?php
|
2006-06-16 23:53:56 +00:00
|
|
|
/**
|
|
|
|
* This page commits the chanegs made in edit_forum_preferences_form.php to
|
|
|
|
* the database.
|
|
|
|
**/
|
|
|
|
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2005-01-06 11:47:44 +00:00
|
|
|
require_once("../inc/forum.inc");
|
2006-06-16 23:53:56 +00:00
|
|
|
require_once("../inc/image.inc"); // Avatar scaling
|
|
|
|
require_once("../inc/forum_std.inc");
|
2005-01-06 11:47:44 +00:00
|
|
|
|
2004-12-20 18:29:15 +00:00
|
|
|
db_init();
|
2006-06-16 23:53:56 +00:00
|
|
|
$user = re_get_logged_in_user();
|
|
|
|
|
|
|
|
// If the user has requested a total reset of preferences:
|
|
|
|
$dbhandler = $mainFactory->getDatabaseHandler();
|
|
|
|
if (post_str("action", true)=="reset"){
|
|
|
|
$post_count = $user->getPostcount();
|
|
|
|
$special_user = $user->getSpecialUser();
|
|
|
|
$dbhandler->deleteUserPrefs($user);
|
|
|
|
$user->resetPrefs();
|
2006-09-19 12:57:57 +00:00
|
|
|
$user->setPostcount($post_count); // Recreate postcount
|
2006-06-16 23:53:56 +00:00
|
|
|
$user->setSpecialUser($special_user); // And recreate special user bitfield
|
|
|
|
Header("Location: edit_forum_preferences_form.php");
|
|
|
|
exit;
|
2006-04-14 22:25:55 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$avatar_type = post_int("avatar_select");
|
|
|
|
$newfile=IMAGE_PATH.$user->getID()."_avatar.jpg";
|
|
|
|
|
|
|
|
// Update the user avatar
|
2004-12-20 18:29:15 +00:00
|
|
|
if ($avatar_type<0 or $avatar_type>3) $avatar_type=0;
|
|
|
|
if ($avatar_type==0){
|
|
|
|
if (file_exists($newfile)){
|
2006-06-16 23:53:56 +00:00
|
|
|
unlink($newfile); //Delete the file on the server if the user
|
|
|
|
//decides not to use an avatar
|
|
|
|
// - or should it be kept?
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
|
|
|
$avatar_url="";
|
|
|
|
} elseif ($avatar_type==2){
|
|
|
|
if ($_FILES['picture']['tmp_name']!=""){
|
2006-04-13 22:17:23 +00:00
|
|
|
$file=$_FILES['picture']['tmp_name'];
|
2004-12-20 18:29:15 +00:00
|
|
|
$size = getImageSize($file);
|
|
|
|
if ($size[2]!=2 and $size[2]!=3){
|
|
|
|
//Not the right kind of file
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("Error: Not the right kind of file, only PNG and JPEG are supported.");
|
2004-09-14 21:29:52 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
$width = $size[0];
|
|
|
|
$height = $size[1];
|
|
|
|
$image2 = intelligently_scale_image($file, 100, 100);
|
|
|
|
ImageJPEG($image2, $newfile);
|
|
|
|
}
|
|
|
|
if (file_exists($newfile)){
|
2006-06-16 23:53:56 +00:00
|
|
|
$avatar_url=IMAGE_URL.$user->getID()."_avatar.jpg"; //$newfile;
|
2004-12-20 18:29:15 +00:00
|
|
|
} else {
|
|
|
|
//User didn't upload a compatible file or it went lost on the server
|
2004-09-14 21:29:52 +00:00
|
|
|
$avatar_url="";
|
2004-09-04 23:37:49 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
$user->setAvatar($avatar_url);
|
2004-10-10 03:04:29 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Update some simple prefs that are either on or off
|
2006-09-19 12:57:57 +00:00
|
|
|
$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"]!="");
|
2006-06-16 23:53:56 +00:00
|
|
|
$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);
|
|
|
|
|
|
|
|
// Update the rating thresholds for display of posts
|
|
|
|
$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
|
2006-12-23 15:35:49 +00:00
|
|
|
$signature = stripslashes($_POST["signature"]);
|
2004-12-20 18:29:15 +00:00
|
|
|
if (strlen($signature)>250) {
|
2006-06-16 23:53:56 +00:00
|
|
|
error_page("Your signature was too long, please keep it less than 250 chars");
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
$user->setSignature($signature);
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// 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);
|
2004-12-20 18:29:15 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Add users to the ignore list if any users are defined
|
2006-09-19 12:57:57 +00:00
|
|
|
$add_user_to_filter = ($_POST["add_user_to_filter"]!="");
|
2006-04-13 22:17:23 +00:00
|
|
|
if ($add_user_to_filter){
|
2006-09-19 12:57:57 +00:00
|
|
|
$user_to_add = trim($_POST["forum_filter_user"]);
|
2005-01-06 11:47:44 +00:00
|
|
|
if ($user_to_add!="" and $user_to_add==strval(intval($user_to_add))){
|
2006-09-19 12:57:57 +00:00
|
|
|
$user->addIgnoredUser(newUser($user_to_add));
|
2005-01-06 11:47:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Or remove some from the ignore list
|
|
|
|
$ignored_users = $user->getIgnorelist();
|
|
|
|
for ($i=0;$i<sizeof($ignored_users);$i++){
|
2006-09-19 12:57:57 +00:00
|
|
|
if ($_POST["remove".trim($ignored_users[$i])]!=""){
|
|
|
|
//this user will be removed and no longer ignored
|
|
|
|
$user->removeIgnoredUser(newUser($ignored_users[$i]));
|
2006-04-14 22:25:55 +00:00
|
|
|
}
|
2004-12-20 18:29:15 +00:00
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
// 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 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.
|
|
|
|
Header("Location: edit_forum_preferences_form.php");
|
2004-09-04 23:37:49 +00:00
|
|
|
|
|
|
|
?>
|