2011-06-28, 08:20 PM
I have installed a plugin to user close and open your topics,
but the button has located in rating, who to move to left edit button.
but the button has located in rating, who to move to left edit button.
Quote:<?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*" );
}
function tcloseopen_yourself_activate(){
global $db, $mybb;
$tcloseopen_yourself_group = array( "gid" => "NULL", "name" => "tcloseopen_yourself", "title" => "Thread Close Open Yourself", "description" => "Settings for the plugin.", "disporder" => "1", "isdefault" => "no", );
$db->insert_query("settinggroups", $tcloseopen_yourself_group);
$gid = $db->insert_id();
$tcloseopen_yourself_setting_1 = array( "sid" => "NULL", "name" => "tcloseopen_yourself_power", "title" => "Power", "description" => "Select Yes if you really wants this plugin to run.", "optionscode" => "yesno", "value" => "1", "disporder" => "1", "gid" => intval($gid), );
$db->insert_query("settings", $tcloseopen_yourself_setting_1);
$tcloseopen_yourself_setting_2 = array( "sid" => "NULL", "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" => intval($gid), );
$db->insert_query("settings", $tcloseopen_yourself_setting_2);
$tcloseopen_yourself_setting_3 = array( "sid" => "NULL", "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" => intval($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 ($power != "0"){
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;
if($mybb->input['action'] == "closety"){
$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"){
$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;
}
}
?>