Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as PHP by registered user atmaca ( 1 month ago )
<?php
foreach ((array)$this->info['dbtech_usertag']['mention'] AS $usertaginfo)
{
	// Write tags
	if ($usertaginfo['userid'] != $userinfo['userid'] AND (in_array($post['forumid'], USERTAG::forumIds($usertaginfo)) OR $type == 'blog'))
	{
		$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET dbtech_usertag_mentioncount = dbtech_usertag_mentioncount + 1, dbtech_usertag_mentions = dbtech_usertag_mentions + 1 WHERE userid = " . intval($usertaginfo['userid']));

		$cansendemail = ($vbulletin->options['enableemail'] AND ($userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember']) AND !($vbulletin->options['dbtech_usertag_disabledemails'] & 1));
		$canreceiveemail = (($usertaginfo['adminemail'] OR $usertaginfo['showemail']) AND ($vbulletin->options['dbtech_usertag_emaildefault'] ? !($usertaginfo['dbtech_usertag_settings'] & 128) : ($usertaginfo['dbtech_usertag_settings'] & 128)));
		if ($cansendemail AND $canreceiveemail)
		{
			// Send the mail
			eval(fetch_email_phrases('dbtech_usertag_mention_received_email', $usertaginfo['languageid']));
			require_once(DIR . '/includes/class_bbcode_alt.php');
			$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list());
			$plaintext_parser->set_parsing_language($usertaginfo['languageid']);
			$message = $plaintext_parser->parse($message, 'privatemessage');
			vbmail($usertaginfo['email'], $subject, $message, true);
		}
	}
	$vbulletin->db->query_write("
		INSERT IGNORE INTO " . TABLE_PREFIX . "dbtech_usertag_mention
			(userid, mentionedid, postid, type, dateline)
		VALUES (
			" . $vbulletin->db->sql_prepare($userinfo['userid']) . ",
			" . $vbulletin->db->sql_prepare($usertaginfo['userid']) . ",
			" . $vbulletin->db->sql_prepare($post['postid']) . ",
			" . $vbulletin->db->sql_prepare($type) . ",
			" . $vbulletin->db->sql_prepare(TIMENOW) . "
		)
	");
	$mentionId = $vbulletin->db->insert_id();

	if (!empty($vbulletin->products['dbtech_vbshout']) AND class_exists('VBSHOUT'))
	{
		foreach ((array)VBSHOUT::$cache['instance'] as $instanceid => $instance)
		{
			// Initialise BBCode Permissions
			$permarray = array(
				'bbcode' => (method_exists('VBSHOUT', 'loadInstanceBbcodePermissions') ? VBSHOUT::loadInstanceBbcodePermissions($instance, $userinfo) : VBSHOUT::load_instance_bbcodepermissions($instance, $userinfo))
			);

			// Fix AOP
			VBSHOUT::set_aop('usertags_' . $usertaginfo['userid'] . '_', $instanceid, false, true);

			if ((int)$permarray['bbcode']['bit'] & 64)
			{
				switch ($type)
				{
					case 'post':
						$text = '[post=' . $post['postid'] . ']' . $title . '[/post]';
						break;

					case 'blog':
						$text = 'Blog: [URL="' . $vbulletin->options['bburl'] . '/blog.php?blogtextid=' . intval($post['postid']) . '"]' . $title . '[/URL]';
						break;
				}
			}
			else
			{
				$text = $title;
			}

			// Init the Shout DM
			$shout = VBSHOUT::initDataManager('Shout', $vbulletin, ERRTYPE_SILENT);
				$shout->set_info('automated', true);
				$shout->set('message', construct_phrase($vbphrase['dbtech_usertag_me_mentioned_y_in_z'],
					$usertaginfo['username'],
					$text
				))
				->set('userid', $userinfo['userid'])
				->set('id', $usertaginfo['userid'])
				->set('type', VBSHOUT::$shouttypes['mention'])
				->set('instanceid', $instanceid);

			// Get the shout id
			$shoutid = $shout->save();
			unset($shout);
		}
	}

	if (!empty($vbulletin->products['notification_vbsocial']) AND class_exists('vBSocial_Notification_Core'))
	{
		$manager = vBSocial_Notification_Core::getNotificationManager('dbtech_usertag_mention');
		if (is_object($manager))
		{
			$manager->info = array(
				'source' => $userinfo,
				'target' => $usertaginfo,
				'contentid' => $mentionId,
				'type' => $type,
				'title' => $title
			);
			$manager->notify();
		}
	}

	($hook = vBulletinHook::fetch_hook('dbtech_usertag_mention_postsave')) ? eval($hook) : false;
}
?>

 

Revise this Paste

Your Name: Code Language: