Skip to content

Commit

Permalink
Update for #1
Browse files Browse the repository at this point in the history
Added some more settings and funktions for selecting forum
  • Loading branch information
SvePu committed Jan 17, 2022
1 parent 7db9d6b commit 2007b5e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 9 deletions.
6 changes: 6 additions & 0 deletions UPLOAD/inc/languages/deutsch_du/moderatefirstpost.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
$l['setting_group_moderatefirstpost_desc'] = "Einstellungen des Moderate First Post Plugins";
$l['setting_moderatefirstpost_enable'] = "Moderate First Post Aktivieren?";
$l['setting_moderatefirstpost_enable_desc'] = "Wähle JA, um die Funktionen des Moderate First Post Plugins zu aktivieren!";
$l['setting_moderatefirstpost_forums'] = "Forenauswahl";
$l['setting_moderatefirstpost_forums_desc'] = "Wähle die Foren aus, in denen der erste Benutzerbeitrag moderiert werden soll!";
$l['setting_moderatefirstpost_forums_type'] = "Art der Moderation";
$l['setting_moderatefirstpost_forums_type_desc'] = "Wähle die Art der Moderation des ersten Benutzerbeitrags innerhalb der oben gewählten Foren aus. (Bei nur einem ausgewählten Forum ist diese Einstellung unwichtig!)";
$l['setting_moderatefirstpost_forums_type_1'] = "Universelle Moderation unabhängig vom Forum";
$l['setting_moderatefirstpost_forums_type_2'] = "Individuelle Moderation in jedem Forum";

// Forum
$l['moderatefirstpost_moderation_user_posts'] = "<br/>Diese Vorgehensweise haben wir aus Spamschutzgründen voreingestellt.<br/>Sobald der erste Beitrag von dir im Forum sichtbar ist, wird diese Kontrolloption automatisch deaktiviert.";
6 changes: 6 additions & 0 deletions UPLOAD/inc/languages/deutsch_sie/moderatefirstpost.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
$l['setting_group_moderatefirstpost_desc'] = "Einstellungen des Moderate First Post Plugins";
$l['setting_moderatefirstpost_enable'] = "Moderate First Post Plugin Aktivieren?";
$l['setting_moderatefirstpost_enable_desc'] = "Wähle Sie JA, um die Funktionen des Moderate First Post Plugins zu aktivieren!";
$l['setting_moderatefirstpost_forums'] = "Forenauswahl";
$l['setting_moderatefirstpost_forums_desc'] = "Wählen Sie die Foren aus, in denen der erste Benutzerbeitrag moderiert werden soll!";
$l['setting_moderatefirstpost_forums_type'] = "Art der Moderation";
$l['setting_moderatefirstpost_forums_type_desc'] = "Wählen Sie die Art der Moderation des ersten Benutzerbeitrags innerhalb der oben gewählten Foren aus. (Bei nur einem ausgewählten Forum ist diese Einstellung unwichtig!)";
$l['setting_moderatefirstpost_forums_type_1'] = "Universelle Moderation unabhängig vom Forum";
$l['setting_moderatefirstpost_forums_type_2'] = "Individuelle Moderation in jedem Forum";

// Forum
$l['moderatefirstpost_moderation_user_posts'] = "<br/>Diese Vorgehensweise haben wir aus Spamschutzgründen voreingestellt.<br/>Sobald der erste Beitrag von dir im Forum sichtbar ist, wird diese Kontrolloption automatisch deaktiviert.";
6 changes: 6 additions & 0 deletions UPLOAD/inc/languages/english/moderatefirstpost.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
$l['setting_group_moderatefirstpost_desc'] = "Settings of Moderate First Post plugin";
$l['setting_moderatefirstpost_enable'] = "Activate Moderate First Post plugin?";
$l['setting_moderatefirstpost_enable_desc'] = "Select YES to activate the functions of the Moderate First Post plugin!";
$l['setting_moderatefirstpost_forums'] = "Forum Select";
$l['setting_moderatefirstpost_forums_desc'] = "Select the forums where the first user post should be moderated!";
$l['setting_moderatefirstpost_forums_type'] = "Type of Moderation";
$l['setting_moderatefirstpost_forums_type_desc'] = "Select the type of moderation of the first user post within the forums selected above. (This setting is not important if there is only one selected forum!)";
$l['setting_moderatefirstpost_forums_type_1'] = "Universal moderation independent of the forum";
$l['setting_moderatefirstpost_forums_type_2'] = "Individual moderation in each forum";

// Forum
$l['moderatefirstpost_moderation_user_posts'] = "<br/>We have preset this procedure for spam protection reasons.<br/>As soon as your first post is visible in the forum, this control option is automatically deactivated.";
93 changes: 84 additions & 9 deletions UPLOAD/inc/plugins/moderatefirstpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

if(defined('IN_ADMINCP'))
{
$plugins->add_hook('admin_config_settings_begin', 'moderatefirstpost_acp_lang');
$plugins->add_hook("admin_config_settings_begin",'moderatefirstpost_settings_page');
$plugins->add_hook("admin_page_output_footer",'moderatefirstpost_settings_peeker');
}
else
{
Expand All @@ -29,19 +30,31 @@

function moderatefirstpost_info()
{
global $db, $lang;
global $db, $plugins_cache, $lang;
$lang->load('moderatefirstpost', true);

return array(
$info = array(
'name' => $db->escape_string($lang->moderatefirstpost),
'description' => $db->escape_string($lang->moderatefirstpost_desc),
"website" => "https://github.com/SvePu/MyBB-Moderate-First-Post",
"author" => "SvePu",
"authorsite" => "https://github.com/SvePu",
"version" => "1.0",
"version" => "1.1",
"codename" => "moderatefirstpost",
"compatibility" => "18*"
);

if(is_array($plugins_cache) && is_array($plugins_cache['active']) && $plugins_cache['active']['moderatefirstpost'])
{
$gid_result = $db->simple_select('settinggroups', 'gid', "name = 'moderatefirstpost'", array('limit' => 1));
$settings_group = $db->fetch_array($gid_result);
if(!empty($settings_group['gid']))
{
$info['description'] = "<span class=\"float_right\"><a href=\"index.php?module=config-settings&action=change&gid=".$settings_group['gid']."\"><img src=\"./styles/default/images/icons/custom.png\" title=\"".$db->escape_string($lang->setting_group_moderatefirstpost)."\" alt=\"settings_icon\" width=\"16\" height=\"16\" /></a></span>" .$info['description'];
}
}

return $info;
}

function moderatefirstpost_install()
Expand Down Expand Up @@ -69,6 +82,20 @@ function moderatefirstpost_install()
'optionscode' => 'yesno',
'value' => 1,
'disporder' => 1
),
'moderatefirstpost_forums' => array(
'title' => $db->escape_string($lang->setting_moderatefirstpost_forums),
'description' => $db->escape_string($lang->setting_moderatefirstpost_forums_desc),
'optionscode' => 'forumselect',
'value' => '-1',
'disporder' => 2
),
'moderatefirstpost_forums_type' => array(
'title' => $db->escape_string($lang->setting_moderatefirstpost_forums_type),
'description' => $db->escape_string($lang->setting_moderatefirstpost_forums_type_desc),
'optionscode' => 'radio \n1='. $db->escape_string($lang->setting_moderatefirstpost_forums_type_1). '\n2='. $db->escape_string($lang->setting_moderatefirstpost_forums_type_2),
'value' => '1',
'disporder' => 3
)
);

Expand Down Expand Up @@ -117,23 +144,71 @@ function moderatefirstpost_deactivate()

}

function moderatefirstpost_acp_lang()
function moderatefirstpost_settings_page()
{
global $lang;
global $db, $mybb, $lang, $mfp_settings_peeker;
$lang->load('moderatefirstpost', true);
$query = $db->simple_select("settinggroups", "gid", "name='moderatefirstpost'", array('limit' => 1));
$group = $db->fetch_array($query);
$mfp_settings_peeker = ($mybb->input["gid"] == $group["gid"]) && ($mybb->request_method != "post");
}

function moderatefirstpost_settings_peeker()
{
global $mfp_settings_peeker;
if($mfp_settings_peeker)
{
echo '<script type="text/javascript">
$(document).ready(function(){
new Peeker($(".setting_moderatefirstpost_enable"), $("#row_setting_moderatefirstpost_forums, #row_setting_moderatefirstpost_forums_type"), 1, true),
new Peeker($(".setting_moderatefirstpost_forums_forums_groups_check"), $("#row_setting_moderatefirstpost_forums_type"), "custom", true);
});
</script>';
}
}

function moderatefirstpost_run()
{
global $mybb, $lang;
global $mybb, $fid, $lang;
$lang->load('moderatefirstpost');

if(!$mybb->user['uid'] || $mybb->settings['moderatefirstpost_enable'] != 1)
if(!$mybb->user['uid'] || $mybb->usergroup['canmodcp'] == 1 || $mybb->settings['moderatefirstpost_enable'] != 1 || $mybb->settings['moderatefirstpost_forums'] == '')
{
return;
}

if($mybb->user['postnum'] < 1 && $mybb->usergroup['canmodcp'] != 1)
if($mybb->settings['moderatefirstpost_forums'] == '-1' && $mybb->user['postnum'] < 1)
{
$moderatefirstpost = true;
}
elseif($mybb->settings['moderatefirstpost_forums'] != '-1' && in_array($fid, explode(',', $mybb->settings['moderatefirstpost_forums'])))
{
global $db;
$mfp_cache=array();
$query = $db->simple_select("posts", "fid, pid", "fid IN ({$mybb->settings['moderatefirstpost_forums']}) AND uid='{$mybb->user['uid']}' AND visible=1");
while($result=$db->fetch_array($query))
{
$mfp_cache[$result['fid']][] = $result['pid'];
}
if(!array_key_exists($fid, $mfp_cache))
{
$moderatefirstpost = true;
if($mybb->settings['moderatefirstpost_forums_type'] != "2")
{
if(!empty($mfp_cache))
{
$moderatefirstpost = false;
}
}
}
unset($mfp_cache);
}
else
{
$moderatefirstpost = false;
}

if($moderatefirstpost)
{
$mybb->user['moderateposts'] = 1;
$lang->moderation_user_posts = $lang->moderation_user_posts . $lang->moderatefirstpost_moderation_user_posts;
Expand Down

0 comments on commit 2007b5e

Please sign in to comment.