<?php
/*
Threadstarter
(c) 2011 by redparkz
Website: http://www.redparkz.de
*/
if(!defined('IN_MYBB')) {
die('Direct initialization of this file is not allowed. Please make sure IN_MYBB is defined.');
}
$plugins->add_hook('postbit', 'threadstarter');
//Informationen zum Plugin
function threadstarter_info()
{
return array(
"name" => "Threadstarter",
"description" => "Ads a note like \"(Threadstarter)\" to the postbit if the postauthor is the threadstarter.",
"website" => "http://redparkz.de",
"author" => "RedParkz",
"authorsite" => "http://redparkz.de",
"version" => "0.9",
"compatibility" => "16*"
);
}
// Aktivierung
function threadstarter_activate() {
global $db;
// Variablen für dieses Plugin einfügen
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("postbit", '#{\$post[\'userstars\']}#', '{\$post[\'threadstarter\']}{\$post[\'userstars\']}');
find_replace_templatesets("postbit_classic", '#{\$post[\'userstars\']}#', '{\$post[\'threadstarter\']}{\$post[\'userstars\']}');
// Einstellungsgruppe hinzufügen
// Einstellungsgruppe hinzufügen
$ts_group = array(
"gid" => "NULL",
"name" => "Threadstarter",
"title" => "Threadstarter",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $ts_group);
$gid = $db->insert_id();
// Einstellungen hinzufügen
$ts_1 = array(
"sid" => "NULL",
"name" => "ts_text",
"title" => "Activate/Deactivate",
"description" => "Text to be displayed for the Threadstarter-Note (Default=\"(Threadstarter)\")",
"optionscode" => "text",
"value" => "",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $ts_1);
$ts_2 = array(
"sid" => "NULL",
"name" => "ts_uselink",
"title" => "Link to first Post?",
"description" => "Do you want to link to the first post? (Default=Yes)",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $ts_2);
// settings.php erneuern
rebuild_settings();
}
// Deaktivierung
function threadstarter_deactivate() {
global $db;
// Variablen von dieses Plugin entfernen
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("postbit", "#{\$post['threadstarter']}#", "", 0);
find_replace_templatesets("postbit_classic", "#{\$post['threadstarter']}#", "", 0);
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='Threadstarter'");
$g = $db->fetch_array($query);
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
// Einstellungen löschen
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
// Rebuilt settings.php
rebuild_settings();
}
function threadstarter($post) {
global $thread, $mybb, $postcounter;
$ts = $mybb->settings['ts_text'];
if($ts == "") $ts="(Threadstarter)";
$url = $mybb->settings['bburl'];
$url .= "/";
$url .= get_thread_link($thread['tid']);
$post['threadstarter'] = "";
$post['tsmobile'] = "";
if ($post['uid'] == $thread ['uid'] && $postcounter != 1)
{
if($mybb->settings['ts_uselink'] != 0){
$post['threadstarter'] = "<a href=\"".$url."\">".$ts."</a><br />";
}
else{
$post['threadstarter'] = "".$ts."<br />";
}
}
}
// Einstellungen erneuern
if(!function_exists("rebuild_settings")) {
function rebuild_settings() {
global $db;
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."settings ORDER BY title ASC");
while($setting = $db->fetch_array($query)) {
$setting['value'] = addslashes($setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
}
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";
$file = fopen(MYBB_ROOT."/inc/settings.php", "w");
fwrite($file, $settings);
fclose($file);
}
}
?>