<?php
// 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("newthread_start", "search_used");
$plugins->add_hook("newreply_start", "search_used");
function search_used_info()
{
return array(
"name" => "Regelbestätigung",
"description" => "Zeigt eine Abfrage beim Erstellen eines neuen Threads oder einer Antwort, ob die Suche benutzt wurde.",
"website" => "https://www.mybb.de",
"author" => "David Kleinmann aka Dave",
"authorsite" => "mailto:david@kleinmann-berlin.de",
"version" => "1.0",
);
}
function search_used_activate()
{
global $db, $lang;
$search_used_group = array(
"gid" => "NULL",
"name" => "search_used",
"title" => "Regelbestätigung",
"description" => "Zeigt eine Abfrage beim Erstellen eines neuen Threads oder einer Antwort, ob die Suche benutzt wurde.",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $search_used_group);
$gid = $db->insert_id();
$search_used_heading = array(
"sid" => "NULL",
"name" => "search_used_heading",
"title" => "Überschrift",
"description" => "Die Überschrift der Tabelle",
"value" => "Regelbestätigung",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_heading);
$search_used_text = array(
"sid" => "NULL",
"name" => "search_used_text",
"title" => "Formular-Text",
"description" => "Der Text, der in der Abfrage angezeigt wird.",
"value" => "Auf dieser Seite musst du bestätigen, dass du bereits die Suche im Forum selbst und auf unserer Webseite genutzt hast. Du erlaubst den Moderatoren/Administratoren dieses Forums dein Thema zu entfernen, wenn deine Frage(n) schon mehrfach beantwortet wurde(n).",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_text);
$search_used_yes_text = array(
"sid" => "NULL",
"name" => "search_used_yes_text",
"title" => "Formular-Text 2",
"description" => "Der Text, der hinter der Checkbox steht.",
"value" => "Hiermit bestätige ich, dass ich die Suche benutzt habe und keine Antwort(en) auf meine Frage(n) gefunden habe.",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_yes_text);
$search_used_yes_text_2 = array(
"sid" => "NULL",
"name" => "search_used_yes_text_2",
"title" => "Formular-Text 3",
"description" => "Der Text, der hinter der Checkbox steht.",
"value" => "Hiermit bestätige ich, dass ich die Suche benutzt habe und keine Antwort(en) auf meine Frage(n) gefunden habe.",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_yes_text_2);
$search_used_submit = array(
"sid" => "NULL",
"name" => "search_used_submit",
"title" => "Button-Text",
"description" => "Der Text des Submit-Buttons",
"value" => "Abschicken",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_submit);
$search_used_fids = array(
"sid" => "NULL",
"name" => "search_used_fids",
"title" => "Die Foren IDs",
"description" => "Die IDs der Foren, in denen die Abfrage angezeigt werden soll. Bitte die IDs mit Komma getrennt eintragen.",
"optionscode" => "text",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $search_used_fids);
$templatearray = array(
"tid" => "NULL",
"title" => "search_used",
"template" => "
<html>
<head>
<title>{\$title}</title>
{\$headerinclude}
</head>
<body>
{\$header}
<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" class=\"tborder\">
<tr>
<td class=\"thead\"><span class=\"smalltext\"><strong>{\$search_used_heading}</strong></span>
</td>
</tr>
<tr>
<td class=\"trow1\">{\$search_used_text}<br /><br />
<form action=\"newthread.php?fid={\$mybb->input[fid]}\" method=\"post\">
<input type=\"checkbox\" name=\"search_used\" value=\"yes\" /> <label for=\"search_used\"><strong>{\$search_used_yes_text}</strong></label><br />
<input type=\"checkbox\" name=\"search_used_2\" value=\"yes\" /> <label for=\"search_used_2\"><strong>{\$search_used_yes_text_2}</strong></label><br />
<div style=\"text-align: center;\"><input type=\"submit\" name=\"submit\" value=\"{\$search_used_submit}\" /></div>
</form>
</td>
</tr>
</table>
{\$footer}
</body>
</html>",
"sid" => "-1",
);
$db->insert_query("templates", $templatearray);
}
function search_used_deactivate()
{
global $db;
$query = $db->write_query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='search_used'");
$g = $db->fetch_array($query);
$db->write_query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
$db->write_query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
$db->write_query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='search_used'");
}
function search_used()
{
global $mybb, $templates, $headerinclude, $header, $footer, $theme, $lang;
$search_used_fids = explode(',',$mybb->settings['search_used_fids']);
if($mybb->input['action'] == "newthread" OR $mybb->input['action'] == "newreply" && !$mybb->input['previewpost'] && $mybb->input['search_used'] != "yes" && $mybb->input['search_used_2'] != "yes" && !$mybb->input['newattachment'] && !$mybb->input['rem'] && in_array($mybb->input['fid'],$search_used_fids)) {
if($mybb->user['language'] == "english") {
$title = htmlspecialchars_uni($mybb->settings['bbname'])." - New Thread";
}
elseif($mybb->user['language'] == "deutsch_sie") {
$title = htmlspecialchars_uni($mybb->settings['bbname'])." - Neues Thema";
}
else {
$title = htmlspecialchars_uni($mybb->settings['bbname'])." - Neues Thema";
}
$search_used_heading = $mybb->settings['search_used_heading'];
$search_used_text = $mybb->settings['search_used_text'];
$search_used_yes_text = $mybb->settings['search_used_yes_text'];
$search_used_yes_text_2 = $mybb->settings['search_used_yes_text_2'];
$search_used_submit = $mybb->settings['search_used_submit'];
eval("\$search_used = \"".$templates->get("search_used")."\";");
output_page($search_used);
exit;
}
}
?>