<?php
/* This plugin is made by sunjava1
* Sidebarmybb for MyBB 1.6.x
* Copyright © 2011 Sunjava1, All Rights Reserved!
* Website: http://www.vubscs.tk
* License:
* "This plugin is offered "as is" with no guarantees.
* You may redistribute it provided the code and credits
* remain intact with no changes. This is not distributed
* under GPL, so you may NOT re-use the code in any other
* module, plugin, or program.
* Free for non-commercial purposes!"
* Thank you, for your understanding!!
*/
if(!defined("IN_MYBB"))
{
die ("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("index_start","sidebarmybb");
function sidebarmybb_info()
{
return array(
"name"=> "Side bar for mybb",
"description"=> "This plugin will add a side bar in your index page",
"website"=> "http://www.vubscs.tk",
"author"=> "sunjava1",
"authorsite"=> "http://www.facebook.com/sunjava1",
"version"=> "1.0",
"guid" => "9ca49b02c1045d7d1b658624bde22a5b",
);
}
function sidebarmybb_activate(){
global $db, $mybb, $sidebarmybb_template;
$sidebarmybb_group = array(
"name" => "sidebarmybb",
"title" => "Side bar on index",
"description" => "Display side bar on index page .",
"disporder" => "401",
"isdefault" => "no",
);
$group['gid'] = $db->insert_query("settinggroups", $sidebarmybb_group);
$gid = $db->insert_id();
$sidebarmybb_set = array(
"name" => "sidebarmybb_numb",
"title" => "Number of Sidebars",
"description" => "Select the number of sidebars you want",
"optionscode" => "select \n30=1 Sidebar\n20=2 Sidebars",
"value" => "30",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $sidebarmybb_set);
$sidebarmybb_table_title_1 = array(
"name" => "sidebarmybb_title_1",
"title" => "Title (First Sidebar)",
"description" => "Add the title of first sidebar",
"optionscode" => "text",
"value" => "my first sidebar title",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $sidebarmybb_table_title_1);
$sidebarmybb_table_messege_1 = array(
"name" => "sidebarmybb_messege_1",
"title" => "Content (First Sidebar)",
"description" => "Add the first sidebar content i.e. your adds, facebook badges etc",
"optionscode" => "textarea",
"value" => "this is my first side bar default content",
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query("settings", $sidebarmybb_table_messege_1);
$sidebarmybb_table_title_2 = array(
"name" => "sidebarmybb_title_2",
"title" => "Title (second sidebar)",
"description" => "Add the title of second sidebar (NOTE Leave this blank if you have not select 2 sidebars from first option)",
"optionscode" => "text",
"value" => "",
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query("settings", $sidebarmybb_table_title_2);
$sidebarmybb_table_messege_2 = array(
"name" => "sidebarmybb_messege_2",
"title" => "Content (Second sidebar)",
"description" => "Add the content of second sidebar. (NOTE Leave this blank if you have not select 2 sidebars from first option)",
"optionscode" => "textarea",
"value" => "",
"disporder" => "5",
"gid" => intval($gid),
);
$db->insert_query("settings", $sidebarmybb_table_messege_2);
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote('{$forums}')."#i", '<table width=\'100%\'><tr><td valign=\'top\'>{$forums}</td>{$sidebarmybb}');
rebuild_settings();
}
function sidebarmybb_deactivate(){
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='sidebarmybb'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebarmybb_title_1'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebarmybb_numb'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebarmybb_messege_1'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebarmybb_title_2'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebarmybb_messege_2'");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote('<table width=\'100%\'><tr><td valign=\'top\'>{$forums}</td>{$sidebarmybb}')."#i", '{$forums}');
// Rebuilding settings
rebuild_settings();
}
function sidebarmybb(){
global $sidebarmybb, $mybb;
if ($mybb->settings['sidebarmybb_numb']==20)
{
$sidebarmybb='<td valign="top" align="right">
<script src="jscripts/sidebarmybb.js"></script>
<table><tr><td>
<table class="tborder" ><tr><th align="right" class="thead">
<a href="#" onclick="sidebarmybb_container();" id="sidebarmybb_toggle"> <img src="images/minus.png"></a></th>
<tr><td style="background:#fff;">
<div id="sidebarmybb_content" style="display:block">
<table class="tborder">
<tr class="tcat"><td><strong> '. $mybb->settings['sidebarmybb_title_1'] .' </strong> <span style="float:right;"> <a id="sidebarmybb_toggle_1" href="#" onclick="sidebarmybb_func_1();"> <img src="images/minus.png"></a></span></tr>
<tr ><td colspan="2" style="background:#fff;">
<div id="sidebarmybb_1" style="display:block"> '. $mybb->settings['sidebarmybb_messege_1'] .' </div>
</td></tr>
</table>
<br>
<table class="tborder">
<tr class="tcat"><td > <strong> '. $mybb->settings['sidebarmybb_title_2'] .' </strong><span style="float:right"> <a id="sidebarmybb_toggle_2" href="#" onclick="sidebarmybb_func_2();"> <img src="images/minus.png"></a></span></td></tr>
<tr ><td colspan="2" style="background:#fff;">
<div id="sidebarmybb_2" style="display:block"> '. $mybb->settings['sidebarmybb_messege_2'] .' </div>
</td></tr>
</table>
</div>
</td></tr>
</table>
</td></tr></table>
</td></tr></table>';
}
else
{
$sidebarmybb='<td valign="top" align="right">
<script src="jscripts/sidebarmybb.js"></script>
<table><tr><td>
<table class="tborder" ><tr><th align="right" class="thead">
<a href="#" onclick="sidebarmybb_container();" id="sidebarmybb_toggle"> <img src="images/minus.png"></a></th>
<tr><td style="background:#fff;">
<div id="sidebarmybb_content" style="display:block">
<table class="tborder">
<tr class="tcat"><td > <strong> '. $mybb->settings['sidebarmybb_title_1'] .' </strong> <span style="float:right"> <a id="sidebarmybb_toggle_1" href="#" onclick="sidebarmybb_func_1();"> <img src="images/minus.png"></a></span></td></tr>
<tr ><td colspan="2" style="background:#fff;"> <div id="sidebarmybb_1" style="display:block"> '. $mybb->settings['sidebarmybb_messege_1'] .' </div>
</td></tr>
</table>
</div>
</td></tr>
</table>
</td></tr></table>
</td></tr></table>';
}
}
?>