<?php
/*
Plugin "Thread solved"
2008 (c) MyBBoard.de
*/
// Disallow direct access to this file for security reasons
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("forumdisplay_thread", "threadsolved");
$plugins->add_hook("search_results_thread", "threadsolved");
//$plugins->add_hook("search_results_post", "threadsolved");
$plugins->add_hook("showthread_linear", "threadsolved");
$plugins->add_hook("showthread_threaded", "threadsolved");
function threadsolved_info() {
return array(
"name" => "Thema erledigt",
"description" => "Themen können als erledigt markiert werden.",
"website" => "https://www.mybb.de",
"author" => "MyBBoard.de",
"authorsite" => "https://www.mybb.de",
"version" => "1.0.2",
);
}
function threadsolved_activate() {
global $db;
$db->query("ALTER TABLE `".TABLE_PREFIX."threads` ADD `threadsolved` INT( 1 ) NOT NULL DEFAULT '0';");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("forumdisplay_thread", '#{\$gotounread}#', "{\$gotounread} {\$threadsolved} ");
find_replace_templatesets("search_results_threads_thread", '#{\$gotounread}#', "{\$gotounread} {\$threadsolved} ");
find_replace_templatesets("search_results_posts_post", '#{\$lang->post_thread}#', "{\$lang->post_thread} {\$threadsolved}");
find_replace_templatesets("showthread", '#{\$rating}#', "{\$rating} {\$threadsolved}");
find_replace_templatesets("showthread", '#{\$newreply}#', "{\$threadsolved_button}{\$newreply}");
}
function threadsolved_deactivate() {
global $db;
$db->query("ALTER TABLE `".TABLE_PREFIX."threads` DROP `threadsolved`;");
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("forumdisplay_thread", '# {\$threadsolved} #', "", 0);
find_replace_templatesets("search_results_threads_thread", '# {\$threadsolved} #', "", 0);
find_replace_templatesets("search_results_posts_post", '# {\$threadsolved}#', "", 0);
find_replace_templatesets("showthread", '# {\$threadsolved}#', "", 0);
find_replace_templatesets("showthread", '#{\$threadsolved_button}#', "", 0);
}
function threadsolved() {
global $threadsolved, $thread, $post, $templates, $mybb, $threadsolved_button, $db, $theme;
if($mybb->user['uid'] != "0" && ($mybb->user['uid'] == $thread['uid'] || $mybb->user['usergroup'] == "4" || $mybb->user['usergroup'] == "3")) {
if($mybb->input['marksolved'] == "1") {
$db->query("UPDATE ".TABLE_PREFIX."threads SET threadsolved = '1' WHERE tid = '".$thread['tid']."';");
$thread['threadsolved'] = "1";
}
if($mybb->input['marksolved'] == "0") {
$db->query("UPDATE ".TABLE_PREFIX."threads SET threadsolved = '0' WHERE tid = '".$thread['tid']."';");
$thread['threadsolved'] = "0";
}
}
$threadsolved = $threadsolved_button = "";
if($thread['threadsolved'] == "1") {
$threadsolved = "<img src=\"images/solved.png\" border=\"0\" alt=\"\" style=\"vertical-align: middle;\" />";
}
if(basename($_SERVER['PHP_SELF']) == "showthread.php") {
if($thread['threadsolved'] != "1" && ($mybb->user['uid'] != "0" && ($mybb->user['uid'] == $thread['uid'] || $mybb->user['usergroup'] == "4" || $mybb->user['usergroup'] == "3"))) {
$threadsolved_button = "<a href=\"showthread.php?tid=".$thread['tid']."&marksolved=1\"><img src=\"".$theme['imglangdir']."/solved.gif\" border=\"0\" alt=\"\" /></a> ";
}
if($thread['threadsolved'] == "1" && ($mybb->user['uid'] != "0" && ($mybb->user['uid'] == $thread['uid'] || $mybb->user['usergroup'] == "4" || $mybb->user['usergroup'] == "3"))) {
$threadsolved_button = "<a href=\"showthread.php?tid=".$thread['tid']."&marksolved=0\"><img src=\"".$theme['imglangdir']."/notsolved.gif\" border=\"0\" alt=\"\" /></a> ";
}
}
}
?>