1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
<?php
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('report_do_report_end', 'reportthread_dopost');
function reportthread_info()
{
return array(
"name" => "Report To Thread",
"description" => "Opens a discussion thread about the reported item when a user reports a post.",
"website" => "http://forumgods.com/",
"author" => "Tony Hudgins",
"authorsite" => "http://forumgods.com/forums/member.php?160-Syke",
"version" => "0.1.3",
"compatibility" => "16*",
"guid" => "8624478eb178c6eb37a503e960c267ec"
);
}
function reportthread_install()
{
global $db;
$reported_group = array('gid' => 'NULL',
'name' => 'reportthread',
'title' => 'Report to Thread',
'description' => 'Configure the Report to Thread plugin.',
'disporder' => '1');
$db->insert_query("settinggroups", $reported_group);
$gid = $db->insert_id();
$reported_setting1 = array('sid' => 'NULL',
'name' => 'rtt_enabled',
'title' => 'Enabled',
'description' => 'Whether or not to create new discussion threads for reported items.',
'optionscode' => 'yesno',
'value' => 'yes',
'disporder' => '1',
'gid' => intval($gid));
$reported_setting2 = array('sid' => 'NULL',
'name' => 'rtt_fid',
'title' => 'Forum ID',
'description' => 'The forum to post report threads to.',
'optionscode' => 'text',
'value' => '1',
'disporder' => '2',
'gid' => intval($gid));
$db->insert_query('settings', $reported_setting1);
$db->insert_query('settings', $reported_setting2);
rebuild_settings();
}
function reportthread_is_installed()
{
global $db;
$group = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settinggroups` WHERE `name` = 'reportthread' LIMIT 1;");
$s1 = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_enabled' LIMIT 1;");
$s2 = $db->query("SELECT `name` FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_fid' LIMIT 1;");
if( $db->num_rows($group) >= 1 && $db->num_rows($s1) >= 1 && $db->num_rows($s2) )
return true;
else
return false;
}
function reportthread_uninstall()
{
global $db;
$db->query("DELETE FROM `" . TABLE_PREFIX . "settinggroups` WHERE `name` = 'reportthread' LIMIT 1;");
$db->query("DELETE FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_enabled' LIMIT 1;");
$db->query("DELETE FROM `" . TABLE_PREFIX . "settings` WHERE `name` = 'rtt_fid' LIMIT 1;");
rebuild_settings();
}
function reportthread_activate()
{
global $db;
$db->query("UPDATE `" . TABLE_PREFIX . "settings` SET `value` = 'yes' WHERE `name` = 'rtt_enabled' LIMIT 1;");
}
function reportthread_deactivate()
{
global $db;
$db->query("UPDATE `" . TABLE_PREFIX . "settings` SET `value` = 'no' WHERE `name` = 'rtt_enabled' LIMIT 1;");
}
function reportthread_dopost()
{
require_once(MYBB_ROOT . "inc/datahandlers/post.php");
global $db, $mybb;
if(intval($mybb->settings['rtt_enabled']) == 1 || preg_replace("/[^a-z]/i", "", $mybb->settings['rtt_enabled']) == "yes")
{
$post = get_post($mybb->input['pid']);
$thread = get_thread($post['tid']);
$forum = get_forum($thread['fid']);
$tlink = get_post_link($mybb->input['pid'],$post['tid'])."#pid".$mybb->input['pid'];
$flink = get_forum_link($thread['fid']);
$post_data = $mybb->user['username'] . " hat einen Beitrag gemeldet!
Original Thread: [url=" . $mybb->settings['bburl'] . "/$tlink]" . $thread['subject'] . "[/url]
Forum: [url=" . $mybb->settings['bburl'] . "/$flink]" . $forum['name'] . "[/url]
Uploader: [url={$mybb->settings['bburl']}/member.php?action=profile&uid=".($post['uid'])."]{$post['username']}[/url]
Angegebener Grund:
[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $mybb->input['reason'] . "[/quote]
Beitrags Inhalt:
[quote=\"" . $post['username'] . "\" pid=\"" . $post['pid'] . "\" dateline=\"" . $post['dateline'] . "\"]" . $post['message'] . "[/quote]";
$new_thread = array(
"fid" => $mybb->settings['rtt_fid'],
"prefix" => 0,
"subject" => "[Meldung] Downfile: @" . $post['username'],
"icon" => 0,
"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],
"message" => $post_data,
"ipaddress" => get_ip(),
"posthash" => md5($mybb->user['uid'] . random_str()),
);
$posthandler = new PostDataHandler("insert");
$posthandler->action = "thread";
$posthandler->set_data($new_thread);
if($posthandler->validate_thread())
$thread_info = $posthandler->insert_thread();
}
}
?>
|