MyBB Community Forums

Full Version: thread open close your self plugin error after upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
thread open close your self plugin error  after upload anyone know how to fix 

help me 


[Image: Screenshot_368.png]

<?php
/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups)  && $mybb->settings['tcloseopen_yourself_power'] ==1){
$tid = $mybb->input['tid'];
$thread = get_thread($tid);
if(!$thread['tid']){
error($lang->error_invalidthread);
}
if ($thread['uid'] != $mybb->user['uid']){
error("You do not have permissions to close another's thread.");
}
verify_post_check($mybb->input['my_post_key']);
$openclose = $lang->closed;
$redirect = $lang->redirect_closethread;
$moderation->close_threads($tid);
$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
$modlogdata['tid'] = $tid;
log_moderator_action($modlogdata, $lang->mod_process);
moderation_redirect(get_thread_link($thread['tid']), $redirect);
break;
}
if($mybb->input['action'] == "openty"  && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
$tid = $mybb->input['tid'];
$thread = get_thread($tid);
if(!$thread['tid']){
error($lang->error_invalidthread);
}
if ($thread['uid'] != $mybb->user['uid']){
error("You do not have permissions to close another's thread.");
}
verify_post_check($mybb->input['my_post_key']);
$openclose = $lang->opened;
$redirect = $lang->redirect_openthread;
$moderation->open_threads($tid);
$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
$modlogdata['tid'] = $tid;
log_moderator_action($modlogdata, $lang->mod_process);
moderation_redirect(get_thread_link($thread['tid']), $redirect);
break;
}
}
?>
You must be running PHP 7+. Using PHP 7 and higher, a break statement is no longer permitted outside a for, foreach or switch statement and gives a fatal error. This is corrected by replacing 'break' with 'return'. See the corrected below and hopefully it fixes the issue you are seeing:

/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\'tid\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\'tid\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
	global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
	$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
	$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

	if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->closed;
		$redirect = $lang->redirect_closethread;
		$moderation->close_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
	if($mybb->input['action'] == "openty" && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->opened;
		$redirect = $lang->redirect_openthread;
		$moderation->open_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
}
(2019-11-29, 03:16 PM)Skyon Archer Wrote: [ -> ]You must be running PHP 7+.  Using PHP 7 and higher, a break statement is no longer permitted outside a for, foreach or switch statement and gives a fatal error.  This is corrected by replacing 'break' with 'return'.  See the corrected below and hopefully it fixes the issue you are seeing:

/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\'tid\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\'tid\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
	global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
	$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
	$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

	if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->closed;
		$redirect = $lang->redirect_closethread;
		$moderation->close_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
	if($mybb->input['action'] == "openty" && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->opened;
		$redirect = $lang->redirect_openthread;
		$moderation->open_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
}

yes its worked bro but when try to activate plugin its given this error 

[Image: Screenshot_372.png]
Okay, try this instead:

/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
	global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
	$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
	$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

	if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->closed;
		$redirect = $lang->redirect_closethread;
		$moderation->close_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
	if($mybb->input['action'] == "openty" && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->opened;
		$redirect = $lang->redirect_openthread;
		$moderation->open_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
}
(2019-11-29, 03:45 PM)Skyon Archer Wrote: [ -> ]Okay, try this instead:

/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
	global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
	$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
	$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

	if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->closed;
		$redirect = $lang->redirect_closethread;
		$moderation->close_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
	if($mybb->input['action'] == "openty" && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->opened;
		$redirect = $lang->redirect_openthread;
		$moderation->open_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
}
wow its working Thank you bro ..

(2019-11-29, 03:45 PM)Skyon Archer Wrote: [ -> ]Okay, try this instead:

/*********************************************************************************************
+ Thread Close Open Yourself v0.2 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function tcloseopen_yourself_info(){
return array(
"name" => "Thread Close Open Yourself",
"description" => "Allows selective groups to close their own threads. It also allows other selective groups to open once they closed it.",
"website" => "http://yaldaram.com",
"author" => "Yaldaram",
"authorsite" => "http://yaldaram.com",
"version" => "0.2",
"compatibility" => "14*,16*,18*"
);
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array(
"name" => "tcloseopen_yourself",
"title" => "Thread Close Open Yourself",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$gid = $db->insert_query("settinggroups", $tcloseopen_yourself_group);

$tcloseopen_yourself_setting_1 = array(
"name" => "tcloseopen_yourself_power",
"title" => "Power",
"description" => "Select Yes if you really wants this plugin to run.",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_1);

$tcloseopen_yourself_setting_2 = array(
"name" => "tcloseopen_yourself_cgroup",
"title" => "Allowed_Groups_to_Close",
"description" => "Specify usergroups who can close their own threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "2",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_2);

$tcloseopen_yourself_setting_3 = array(
"name" => "tcloseopen_yourself_ogroup",
"title" => "Allowed_Groups_to_Open",
"description" => "Specify usergroups who can open their own Closed threads. Separate with , if more then one.",
"optionscode" => "text",
"value" => "2,3,4,6,8",
"disporder" => "3",
"gid" => $gid,
);
$db->insert_query("settings", $tcloseopen_yourself_setting_3);

    rebuild_settings();
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "tclose_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=closety&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/closety.gif" title="Close your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
$template = array(
"title" => "topen_yourself",
"template" => '<span style="float: right;"><a href="moderation.php?action=openty&tid={$thread[\\\'tid\\\']}&my_post_key={$mybb->post_code}">
<img src="images/english/openty.gif" title="Open your thread.">
</a></span>',
"sid" => -1
);
$db->insert_query("templates", $template);
find_replace_templatesets("showthread", "#".preg_quote('{$ratethread}')."#i", '{\$ratethread}{\$tcloseopen}');
}
function tcloseopen_yourself_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tcloseopen_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_cgroup'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tcloseopen_yourself_ogroup'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("showthread", "#".preg_quote('{$tcloseopen}')."#i", '', 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='tclose_yourself'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='topen_yourself'");
    rebuild_settings();
}
$plugins->add_hook("showthread_start", "tcloseopen_button");
function tcloseopen_button(){
global $mybb, $thread, $templates, $tcloseopen;
$power = $mybb->settings['tcloseopen_yourself_power'];
$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);
if ($mybb->settings['tcloseopen_yourself_power'] ==1){
if (in_array($mybb->user['usergroup'],$cgroups) && !$thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('tclose_yourself')."\";");
}
else if (in_array($mybb->user['usergroup'],$ogroups) && $thread['closed'] && $mybb->user['uid'] == $thread['uid']){
eval("\$tcloseopen = \"".$templates->get('topen_yourself')."\";");
}
}
}
$plugins->add_hook("moderation_start", "tcloseopen_action");
function tcloseopen_action()
{
	global $db, $mybb, $lang, $thread, $moderation, $modlogdata;
	$cgroups = explode(",",$mybb->settings['tcloseopen_yourself_cgroup']);
	$ogroups = explode(",",$mybb->settings['tcloseopen_yourself_ogroup']);

	if($mybb->input['action'] == "closety" && in_array($mybb->user['usergroup'],$cgroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->closed;
		$redirect = $lang->redirect_closethread;
		$moderation->close_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
	if($mybb->input['action'] == "openty" && in_array($mybb->user['usergroup'],$ogroups) && $mybb->settings['tcloseopen_yourself_power'] ==1){
		$tid = $mybb->input['tid'];
		$thread = get_thread($tid);
		if(!$thread['tid']){
			error($lang->error_invalidthread);
		}
		if ($thread['uid'] != $mybb->user['uid']){
			error("You do not have permissions to close another's thread.");
		}
		verify_post_check($mybb->input['my_post_key']);
		$openclose = $lang->opened;
		$redirect = $lang->redirect_openthread;
		$moderation->open_threads($tid);
		$lang->mod_process = $lang->sprintf($lang->mod_process, $openclose);
		$modlogdata['tid'] = $tid;
		log_moderator_action($modlogdata, $lang->mod_process);
		moderation_redirect(get_thread_link($thread['tid']), $redirect);
		return false;
	}
}
please look it on this thread too 


https://community.mybb.com/thread-225527.html