add settings of privacy protection forums (#135)

add settings of privacy protection forums

Co-authored-by: kongrui <me@rey.ink>
This commit is contained in:
Rey
2022-11-24 20:34:13 +08:00
committed by GitHub
parent af67dd868b
commit 83e8cd61e0
8 changed files with 41 additions and 3 deletions

View File

@@ -539,6 +539,7 @@ if ($action == "viewtopic")
$hlcolor = $arr['hlcolor'];
$views = $arr['views'];
$forumid = $arr["forumid"];
$base_posterid = $arr['userid'];
$row = get_forum_row($forumid);
//------ Get forum name, moderators
@@ -672,6 +673,18 @@ if ($action == "viewtopic")
$lpr = get_last_read_post_id($topicid);
if ($Advertisement->enable_ad())
$forumpostad=$Advertisement->get_ad('forumpost');
//check if privacy protection enabled in this forum
$protected_forums = Nexus\Database\NexusDB::remember("setting_protected_forum", 600, function () {
return \App\Models\Setting::getByName('misc.protected_forum');
});
if ($protected_forums and in_array(strval($forumid),explode(",",$protected_forums))){
$protected_enabled=true;
}else{
$protected_enabled=false;
}
foreach ($allPosts as $arr)
{
if ($pn>=1)
@@ -738,7 +751,16 @@ if ($action == "viewtopic")
print("</table></div>\n");
print("<table class=\"main\" width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
//hidden content applied to second or higher floor post (for whose user class below Ad , not poster , not mods ,not reply's author)
if ($protected_enabled && $pn+$offset>1 && get_user_class()<UC_ADMINISTRATOR && $userid != $base_posterid && $posterid!=$userid && !$is_forummod){
//enable content protection
$bodyContent = format_comment($lang_forums["text_post_protected"]);
}else{
//display normal content
$bodyContent = format_comment($arr["body"]);
}
$body = "<div id=\"pid".$postid."body\">";
$bodyContent = format_comment($arr["body"]);
if ($highlight){

View File

@@ -288,9 +288,12 @@ elseif ($action == 'savesettings_advertisement') // save advertisement
elseif ($action == 'savesettings_misc')
{
stdhead($lang_settings['row_misc_settings']);
$validConfig = array('donation_custom', );
$validConfig = array('donation_custom', 'protected_forum',);
GetVar($validConfig);
$data = [];
if (!empty($protected_forum) && !preg_match("/^[,\\d]*[\\d]+$/",$protected_forum)){
stderr($lang_settings['std_error'],$lang_settings['forum_format_error'].'<br>'.$lang_settings['std_click']."<a class=\"altlink\" href=\"settings.php\">".$lang_settings['std_here']."</a>".$lang_settings['std_to_go_back'],false,false);
}
foreach($validConfig as $config) {
$data[$config] = $$config ?? null;
}
@@ -923,7 +926,8 @@ elseif ($action == 'miscsettings')
print ($notice);
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_misc'>");
tr($lang_settings['row_misc_donation_custom'],"<textarea cols=\"100\" rows=\"10\" name='donation_custom'>".($misc['donation_custom'] ?? '')."</textarea><br/>".$lang_settings['text_donation_custom_note'], 1);
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
tr($lang_settings['row_protected_forum'], "<input type='text' style=\"width: 100px\" name='protected_forum' value='".($misc["protected_forum"] ??'')."'> ".$lang_settings['text_protected_forum'], 1);
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
print ("</form>");
}
elseif ($action == 'showmenu') // settings main page