Vergleich inc/class_custommoderation.php - 1.8.5 - 1.8.29

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 24Zeile 24
	/**
* Get info on a tool
*

	/**
* Get info on a tool
*

	 * @param int Tool ID
* @param mixed Thread IDs
* @param mixed Post IDs
* @return mixed Returns tool data (tid, type, name, description) in an array, otherwise boolean false.

	 * @param int $tool_id Tool ID
* @return array|bool Returns tool data (tid, type, name, description) in an array, otherwise boolean false.



	 */
function tool_info($tool_id)
{
global $db;

// Get tool info

	 */
function tool_info($tool_id)
{
global $db;

// Get tool info

		$query = $db->simple_select("modtools", "*", 'tid="'.(int)$tool_id.'"');

		$query = $db->simple_select("modtools", "*", 'tid='.(int)$tool_id);

		$tool = $db->fetch_array($query);
if(!$tool['tid'])
{

		$tool = $db->fetch_array($query);
if(!$tool['tid'])
{

Zeile 49Zeile 47
	/**
* Execute Custom Moderation Tool
*

	/**
* Execute Custom Moderation Tool
*

	 * @param int Tool ID
* @param mixed Thread ID(s)
* @param mixed Post IDs

	 * @param int $tool_id Tool ID
* @param int|array Thread ID(s)
* @param int|array Post ID(s)

	 * @return string 'forum' or 'default' indicating where to redirect
*/
function execute($tool_id, $tids=0, $pids=0)

	 * @return string 'forum' or 'default' indicating where to redirect
*/
function execute($tool_id, $tids=0, $pids=0)

Zeile 59Zeile 57
		global $db;

// Get tool info

		global $db;

// Get tool info

		$query = $db->simple_select("modtools", '*', 'tid="'.(int)$tool_id.'"');

		$query = $db->simple_select("modtools", '*', 'tid='.(int)$tool_id);

		$tool = $db->fetch_array($query);
if(!$tool['tid'])
{

		$tool = $db->fetch_array($query);
if(!$tool['tid'])
{

Zeile 81Zeile 79
		$thread_options = my_unserialize($tool['threadoptions']);

// If the tool type is a post tool, then execute the post moderation

		$thread_options = my_unserialize($tool['threadoptions']);

// If the tool type is a post tool, then execute the post moderation

 
		$deleted_thread = 0;

		if($tool['type'] == 'p')
{

		if($tool['type'] == 'p')
{

			$deleted_thread = $this->execute_post_moderation($post_options, $pids, $tids);

			$deleted_thread = $this->execute_post_moderation($tids, $post_options, $pids);

		}
// Always execute thead moderation
$this->execute_thread_moderation($thread_options, $tids);

		}
// Always execute thead moderation
$this->execute_thread_moderation($thread_options, $tids);

Zeile 99Zeile 98
	/**
* Execute Inline Post Moderation
*

	/**
* Execute Inline Post Moderation
*

	 * @param array Moderation information
* @param mixed Post IDs
* @param array Thread IDs (in order of dateline ascending)


	 * @param array|int $tid Thread IDs (in order of dateline ascending). Only the first one will be used
* @param array $post_options Moderation information
* @param array $pids Post IDs
*

	 * @return boolean true
*/

	 * @return boolean true
*/

	function execute_post_moderation($post_options, $pids, $tid)

	function execute_post_moderation($tid, $post_options=array(), $pids=array())

	{

	{

		global $db, $mybb, $lang;

		global $db, $mybb, $lang, $plugins;


if(is_array($tid))


if(is_array($tid))

		{

		{

			$tid = (int)$tid[0]; // There's only 1 thread when doing inline post moderation
// The thread chosen is the first thread in the array of tids.
// It is recommended that this be the tid of the oldest post

			$tid = (int)$tid[0]; // There's only 1 thread when doing inline post moderation
// The thread chosen is the first thread in the array of tids.
// It is recommended that this be the tid of the oldest post

		}


		}


		// Get the information about thread
$thread = get_thread($tid);

		// Get the information about thread
$thread = get_thread($tid);

 
		$author = get_user($thread['uid']);

$args = array(
'post_options' => &$post_options,
'pids' => &$pids,
'thread' => &$thread,
);

$plugins->run_hooks("class_custommoderation_execute_post_moderation_start", $args);


// If deleting posts, only do that
if($post_options['deleteposts'] == 1)


// If deleting posts, only do that
if($post_options['deleteposts'] == 1)

		{

		{

			foreach($pids as $pid)
{
$this->delete_post($pid);

			foreach($pids as $pid)
{
$this->delete_post($pid);

Zeile 138Zeile 147
				foreach($delete_tids as $delete_tid)
{
$this->delete_thread($delete_tid);

				foreach($delete_tids as $delete_tid)
{
$this->delete_thread($delete_tid);

					mark_reports($delete_tid, "thread");

 
				}

				}

				// return 1 here so the code in execute() above knows to redirect to the forum
return 1;

				// return true here so the code in execute() above knows to redirect to the forum
return true;

			}
}
else

			}
}
else

Zeile 149Zeile 157
			if($post_options['mergeposts'] == 1) // Merge posts
{
$this->merge_posts($pids);

			if($post_options['mergeposts'] == 1) // Merge posts
{
$this->merge_posts($pids);

			}


			}


			if($post_options['approveposts'] == 'approve') // Approve posts
{
$this->approve_posts($pids);

			if($post_options['approveposts'] == 'approve') // Approve posts
{
$this->approve_posts($pids);

Zeile 201Zeile 209
					// Enter in a subject if a predefined one does not exist.
$post_options['splitpostsnewsubject'] = "{$lang->split_thread_subject} {$thread['subject']}";
}

					// Enter in a subject if a predefined one does not exist.
$post_options['splitpostsnewsubject'] = "{$lang->split_thread_subject} {$thread['subject']}";
}

				$new_subject = str_ireplace('{subject}', $thread['subject'], $post_options['splitpostsnewsubject']);
$new_tid = $this->split_posts($pids, $tid, $post_options['splitposts'], $new_subject);


















$find = array('{username}', '{author}', '{subject}');
$replace = array($mybb->user['username'], $author['username'], $thread['subject']);

$new_subject = str_ireplace($find, $replace, $post_options['splitpostsnewsubject']);

$args = array(
'post_options' => &$post_options,
'pids' => &$pids,
'thread' => &$thread,
'new_subject' => &$new_subject,
);

$plugins->run_hooks("class_custommoderation_splitposts", $args);

$new_thread_subject = $new_subject;
$new_tid = $this->split_posts($pids, $tid, $post_options['splitposts'], $new_thread_subject);


				if($post_options['splitpostsclose'] == 'close') // Close new thread
{
$this->close_threads($new_tid);

				if($post_options['splitpostsclose'] == 'close') // Close new thread
{
$this->close_threads($new_tid);

Zeile 212Zeile 236
					$this->stick_threads($new_tid);
}
if($post_options['splitpostsunapprove'] == 'unapprove') // Unapprove new thread

					$this->stick_threads($new_tid);
}
if($post_options['splitpostsunapprove'] == 'unapprove') // Unapprove new thread

				{

				{

					$this->unapprove_threads($new_tid, $thread['fid']);
}
if($post_options['splitthreadprefix'] != '0')

					$this->unapprove_threads($new_tid, $thread['fid']);
}
if($post_options['splitthreadprefix'] != '0')

Zeile 223Zeile 247
				{
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("insert");

				{
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("insert");

 

$find = array('{username}', '{author}', '{subject}');
$replace = array($mybb->user['username'], $author['username'], $new_thread_subject);


if(empty($post_options['splitpostsreplysubject']))


if(empty($post_options['splitpostsreplysubject']))

					{
$post_options['splitpostsreplysubject'] = 'RE: '.$new_subject;
}

					{
$new_subject = 'RE: '.$new_thread_subject;
}

					else
{

					else
{

						$post_options['splitpostsreplysubject'] = str_ireplace('{username}', $mybb->user['username'], $post_options['splitpostsreplysubject']);
$post_options['splitpostsreplysubject'] = str_ireplace('{subject}', $new_subject, $post_options['splitpostsreplysubject']);

						$new_subject = str_ireplace($find, $replace, $post_options['splitpostsreplysubject']);


					}

					}

 

$new_message = str_ireplace($find, $replace, $post_options['splitpostsaddreply']);

$args = array(
'post_options' => &$post_options,
'pids' => &$pids,
'thread' => &$thread,
'new_subject' => &$new_subject,
'new_message' => &$new_message,
);

$plugins->run_hooks("class_custommoderation_splitpostsaddreply", $args);


// Set the post data that came from the input to the $post array.
$post = array(
"tid" => $new_tid,
"fid" => $post_options['splitposts'],


// Set the post data that came from the input to the $post array.
$post = array(
"tid" => $new_tid,
"fid" => $post_options['splitposts'],

						"subject" => $post_options['splitpostsreplysubject'],
"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],
"message" => $post_options['splitpostsaddreply'],
"ipaddress" => $db->escape_binary(my_inet_pton(get_ip())),
);
// Set up the post options from the input.
$post['options'] = array(
"signature" => 1,

						"subject" => $new_subject,
"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],
"message" => $new_message,
"ipaddress" => my_inet_pton(get_ip()),
);
// Set up the post options from the input.
$post['options'] = array(
"signature" => 1,

						"emailnotify" => 0,
"disablesmilies" => 0
);

						"emailnotify" => 0,
"disablesmilies" => 0
);





					$posthandler->set_data($post);

if($posthandler->validate_post($post))

					$posthandler->set_data($post);

if($posthandler->validate_post($post))

Zeile 260Zeile 298
				}
}
}

				}
}
}

 

$args = array(
'post_options' => &$post_options,
'pids' => &$pids,
'thread' => &$thread,
);

$plugins->run_hooks("class_custommoderation_execute_post_moderation_end", $args);


		return true;
}

/**
* Execute Normal and Inline Thread Moderation
*

		return true;
}

/**
* Execute Normal and Inline Thread Moderation
*

	 * @param array Moderation information
* @param mixed Thread IDs

	 * @param array $thread_options Moderation information
* @param array Thread IDs. Only the first one will be used, but it needs to be an array

	 * @return boolean true
*/

	 * @return boolean true
*/

	function execute_thread_moderation($thread_options, $tids)

	function execute_thread_moderation($thread_options=array(), $tids=array())

	{

	{

		global $db, $mybb;


		global $db, $mybb, $plugins;


		$tid = (int)$tids[0]; // Take the first thread to get thread data from
$query = $db->simple_select("threads", 'fid', "tid='$tid'");
$thread = $db->fetch_array($query);

		$tid = (int)$tids[0]; // Take the first thread to get thread data from
$query = $db->simple_select("threads", 'fid', "tid='$tid'");
$thread = $db->fetch_array($query);

 

$args = array(
'thread_options' => &$thread_options,
'tids' => &$tids,
'thread' => &$thread,
);

$plugins->run_hooks("class_custommoderation_execute_thread_moderation_start", $args);


// If deleting threads, only do that
if($thread_options['deletethread'] == 1)


// If deleting threads, only do that
if($thread_options['deletethread'] == 1)

Zeile 387Zeile 442
			if(!empty($thread_options['addreply'])) // Add reply to thread
{
$tid_list = implode(',', $tids);

			if(!empty($thread_options['addreply'])) // Add reply to thread
{
$tid_list = implode(',', $tids);

				$query = $db->simple_select("threads", 'uid, fid, subject, tid, firstpost, closed', "tid IN ($tid_list) AND closed NOT LIKE 'moved|%'");





				$query = $db->query("
SELECT u.uid, u.username, t.fid, t.subject, t.tid, t.firstpost, t.closed FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON t.uid=u.uid
WHERE tid IN ($tid_list) AND closed NOT LIKE 'moved|%'
");

				require_once MYBB_ROOT."inc/datahandlers/post.php";

// Loop threads adding a reply to each one
while($thread = $db->fetch_array($query))
{
$posthandler = new PostDataHandler("insert");

				require_once MYBB_ROOT."inc/datahandlers/post.php";

// Loop threads adding a reply to each one
while($thread = $db->fetch_array($query))
{
$posthandler = new PostDataHandler("insert");

 

$find = array('{username}', '{author}', '{subject}');
$replace = array($mybb->user['username'], $thread['username'], $thread['subject']);


if(empty($thread_options['replysubject']))


if(empty($thread_options['replysubject']))

                    {
$new_subject = 'RE: '.$thread['subject'];
}
else
{
$new_subject = str_ireplace('{username}', $mybb->user['username'], $thread_options['replysubject']);
$new_subject = str_ireplace('{subject}', $thread['subject'], $new_subject);
}












					{
$new_subject = 'RE: '.$thread['subject'];
}
else
{
$new_subject = str_ireplace($find, $replace, $thread_options['replysubject']);
}

$new_message = str_ireplace($find, $replace, $thread_options['addreply']);

$args = array(
'thread_options' => &$thread_options,
'tids' => &$tids,
'thread' => &$thread,
'new_subject' => &$new_subject,
'new_message' => &$new_message,
);

$plugins->run_hooks("class_custommoderation_addreply", $args);





                    // Set the post data that came from the input to the $post array.
$post = array(
"tid" => $thread['tid'],
"replyto" => $thread['firstpost'],
"fid" => $thread['fid'],
"subject" => $new_subject,

					// Set the post data that came from the input to the $post array.
$post = array(
"tid" => $thread['tid'],
"replyto" => $thread['firstpost'],
"fid" => $thread['fid'],
"subject" => $new_subject,

						"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],

						"uid" => $mybb->user['uid'],
"username" => $mybb->user['username'],

						"message" => $thread_options['addreply'],
"ipaddress" => $db->escape_binary(my_inet_pton(get_ip())),

						"message" => $new_message,
"ipaddress" => my_inet_pton(get_ip()),

					);

// Set up the post options from the input.

					);

// Set up the post options from the input.

Zeile 480Zeile 553
			$tid_list = implode(',', $tids);

// For each thread, we send a PM to the author

			$tid_list = implode(',', $tids);

// For each thread, we send a PM to the author

			$query = $db->simple_select("threads", 'uid', "tid IN ($tid_list)");
while($uid = $db->fetch_field($query, 'uid'))





			$query = $db->query("
SELECT u.uid, u.username, t.subject FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON t.uid=u.uid
WHERE tid IN ($tid_list)
");
while($thread = $db->fetch_array($query))

			{

			{

 
				$find = array('{username}', '{author}', '{subject}');
$replace = array($mybb->user['username'], $thread['username'], $thread['subject']);

$pm_subject = str_ireplace($find, $replace, $thread_options['pm_subject']);
$pm_message = str_ireplace($find, $replace, $thread_options['pm_message']);

$args = array(
'thread_options' => &$thread_options,
'tids' => &$tids,
'thread' => &$thread,
'pm_subject' => &$pm_subject,
'pm_message' => &$pm_message,
);

$plugins->run_hooks("class_custommoderation_pm", $args);


				// Let's send our PM
$pm = array(

				// Let's send our PM
$pm = array(

					'subject' => $thread_options['pm_subject'],
'message' => $thread_options['pm_message'],
'touid' => $uid

					'subject' => $pm_subject,
'message' => $pm_message,
'touid' => $thread['uid']

				);
send_pm($pm, $mybb->user['uid'], 1);
}
}

				);
send_pm($pm, $mybb->user['uid'], 1);
}
}

 

$args = array(
'thread_options' => &$thread_options,
'tids' => &$tids,
'thread' => &$thread,
);

$plugins->run_hooks("class_custommoderation_execute_thread_moderation_end", $args);

		
return true;
}

		
return true;
}