Hack Name: Auto PM to Thread Starter on Moderation
Hack Version: 0.23
Hack Author: Kall (admin@nzboards.com)
Release: 8 September 2004
Description: When a thread is Opened/Closed, Stuck/Unstuck, Moved, Split, merged, or a Post is deleted, a PM will be automatically sent to the Poster to inform them of this.
Requested by: Several people on vb.org
    : 1981
****************************************
     : 1 
(/postings.php)

     SQL: 9
*************************************
 :    9     
SQL
 
PhpMyAdmin :

INSERT INTO `setting` (`varname`, `grouptitle`, `value`, `defaultvalue`, `optioncode`, `displayorder`, `advanced`, `volatile`) VALUES ('modpmfrom', 'posting', '1', '1', '', 140, 0, 0);

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0', 'setting_modpmfrom_title', 'User Who Sends Automatic PM on Moderation', '5000');

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0',  'setting_modpmfrom_desc', 'Enter the user ID of the person whose account you\'d like to be used when sending Auto Moderation PMs.', '5000');


INSERT INTO `setting` (`varname`, `grouptitle`, `value`, `defaultvalue`, `optioncode`, `displayorder`, `advanced`, `volatile`) VALUES ('modpmtext', 'posting', 'Hi $username,\r\n\r\nThis message is to advise that your $type titled "$threadinfo"  has been $action.\r\n\r\nThe $type is located at this URL $url\r\n\r\nIf you have any questions, you can ask an administrator for assistance\r\n\r\nSincerely,\r\nThe $bbtitle staff.', 'Hi $username,\r\n\r\nThis message is to advise that your $type titled "$threadinfo"  has been $action by $modby.\r\n\r\nThe $type is located at this URL $url\r\n\r\nIf you have any questions, you can ask an administrator for assistance\r\n\r\nSincerely,\r\nThe $bbtitle staff.', 'textarea', 150, 0, 0);

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0', 'setting_modpmtext_title', 'Auto PM on Moderation Text', '5000');

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0',  'setting_modpmtext_desc', 'Set the text of the PM sent to users on Moderation.<br />\r<br />\rNote: You can use the following variables to specify the <b>user\'s</b> information: $bbtitle, $username, $type, $action, $userid, $threadinfo, $modby.', '5000');

INSERT INTO `setting` (`varname`, `grouptitle`, `value`, `defaultvalue`, `optioncode`, `displayorder`, `advanced`, `volatile`) VALUES ('modpmtitle', 'posting', 'Your $type "$threadinfo" has been $action', 'Your $type "$threadinfo" has been $action', '', 160, 0, 0);

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0', 'setting_modpmtitle_title', 'Title Of the PM That is Sent on Thread Moderation', '5000');

INSERT INTO phrase (phraseid, languageid, varname, `text`, phrasetypeid) VALUES (NULL, '0',  'setting_modpmtitle_desc', 'Set the title of the PM that is sent to users when threads are moderated. You can use the same variables as  above.', '5000');

************************************************
  :
 /postings.php

1)   :

$_REQUEST['forceredirect'] = 1;
	$url = "showthread.php?$session[sessionurl]t=$threadid";
	eval(print_standard_redirect('redirect_openclose'));

  :

// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "$vboptions[bburl]/showthread.php?$session[sessionurl]t=$threadid";
		$action = $action;
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			 '$modby' => $bbuserinfo['username'],
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
		// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall
****************************************************

2)   :

	
eval(print_standard_redirect('redirect_deletethread'));

}

  :

	// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "  ";
		$type = "";
		$modby	=	$bbuserinfo['username'];

		
		
	$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the new owner a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
		// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall
*************************************

3)   :

eval(print_standard_redirect('redirect_deleteposts'));

}


  :

// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "  ";
		$action = "  ";
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall
************************************************

4)   :

eval(print_standard_redirect('redirect_movethread'));
}


  :

// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "$vboptions[bburl]/showthread.php?$session[sessionurl]t=$threadid";
		$action = "  ";
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall
***********************************************

5)   :

eval(print_standard_redirect('redirect_mergethread'));

}

  :

// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "$vboptions[bburl]/showthread.php?$session[sessionurl]t=$threadid";
		$action = "     ";
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall

***************************************
6)   :

eval(print_standard_redirect('redirect_splitthread'));
}


  :

// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
		
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "$vboptions[bburl]/showthread.php?$session[sessionurl]t=$newthreadid";
		$action = "  ";
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall

*********************************************

7)   :

eval(print_standard_redirect('redirect_sticky'));
}


  :
// # AUTOSEND PM ON THREAD MODERATION HACK by Kall
	
		$username = $threadinfo['postusername'];
		$threadinfo['title'] = unhtmlspecialchars($threadinfo['title']);
		$postinfo['title'] = unhtmlspecialchars($postinfo['title']);
		$newurl = "$vboptions[bburl]/showthread.php?$session[sessionurl]t=$threadid";
		$action = "$action";
		$type	=	"";
		$modby	=	$bbuserinfo['username'];

				
		$vars = array(
			'$bbtitle' => $vboptions['bbtitle'], 
			'$username' => $username,
			'$threadinfo'  => $threadinfo['title'],
			'$url'	=>	$newurl,
			'$userid' => $threadinfo['postuserid'],
			'$action' => $action,
			'$type'	=>	$type,
			'$modby' => $bbuserinfo['username'],
			 
		);
		
		$pmoptions['modpmtext'] = $vboptions['modpmtext'];
		$pmoptions['modpmtitle'] = $vboptions['modpmtitle'];
		$pmoptions['modpmfrom'] = $vboptions['modpmfrom'];
		
		
		
		foreach($vars AS $_key => $_value)
		{
			$pmoptions['modpmtext'] = str_replace($_key, $_value, $pmoptions['modpmtext']);
			$pmoptions['modpmtitle'] = str_replace($_key, $_value, $pmoptions['modpmtitle']);
		}

		$get_pm_from = $DB_site->query_first("SELECT username,userid FROM " . TABLE_PREFIX . "user WHERE userid=$pmoptions[modpmfrom]");
		
		// Send the Poster a PM
		$DB_site->query(
			"INSERT INTO " . TABLE_PREFIX . "pmtext
			(
				fromuserid,
				fromusername,
				title,
				message,
				touserarray,
				iconid,
				dateline,
				showsignature,
				allowsmilie
			)
			VALUES
			(
				$get_pm_from[userid],
				'" . addslashes($get_pm_from['username']) . "',
				'" . addslashes($pmoptions['modpmtitle']) . "',
				'" . addslashes($pmoptions['modpmtext']) . "',
				'" . addslashes(serialize(array($userid => $username))) . "',
				0,
				" . TIMENOW . ",
				1,
				1
			)"
		);
		
		$pmtextid = $DB_site->insert_id();
		
		$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$threadinfo[postuserid]");
		$DB_site->query(
		"INSERT INTO " . TABLE_PREFIX . "pm 
			(
				pmtextid, 
				userid, 
				folderid, 
				messageread
			) 
			VALUES 
			(
				'$pmtextid', 
				'$threadinfo[postuserid]', 
				'0', 
				'0'
			)"
		);
// # END AUTOSEND PM ON THREAD MODERATION HACK by Kall
*********************************************

  ...
*********************
  :
 http://yoursite/admincp/options.php?dogroup=posting&do=options
  ((  ))            :
vBulletin Options
   :
Auto PM on Moderation Text
      
*********************

 ....

*******************************************
             :
********************************

  :

  : $type	=	"";
    : $modby	=	$bbuserinfo['username'];

  : $type	=	"";
    : $modby	=	$bbuserinfo['username'];

  : '$type'	=>	$type,
    : '$modby' => $bbuserinfo['username'],

 $modby
  vBulletin Options

**************************************************

    : 1981
