Cold Assassin
Customer
We should all know what the post thank you hack is by now so moving on..
I was trying to create an addon that would post a notification when someone pushes the "thanks" button. Anyway been working on this all morning, and currently stuck at getting the code to give me the thread title.
This is what I've done so far:
Added Phrase for notification:
name: dbtech_vbshout_notif_thanks
type: global
product: vbShout
text: has given thanks to {1} for their post in {2}!
Next I added a plugin to require the php file:
Product: vBshout
Hook Location: post_thanks_function_add_thanks_end
Title: Notification: Post Thanks
Execution Order: 5
Plugin PHP Code:
Then I created newthanks_complete.php and placed it in the location above and this is the context:
I can get the threadid to showup using post['threadid']... but cant get it to tell me the title... wish there was a way...
BTW: I did add 'thanks' to the notification column on the database, so thats not it.
I was trying to create an addon that would post a notification when someone pushes the "thanks" button. Anyway been working on this all morning, and currently stuck at getting the code to give me the thread title.
This is what I've done so far:
Added Phrase for notification:
name: dbtech_vbshout_notif_thanks
type: global
product: vbShout
text: has given thanks to {1} for their post in {2}!
Next I added a plugin to require the php file:
Product: vBshout
Hook Location: post_thanks_function_add_thanks_end
Title: Notification: Post Thanks
Execution Order: 5
Plugin PHP Code:
PHP:
require(DIR . '/dbtech/vbshout/includes/hooks/newthanks_complete.php');
Then I created newthanks_complete.php and placed it in the location above and this is the context:
PHP:
<?php
if (
!$vbulletin->userinfo['dbtech_vbshout_banned']
)
{
if ($vbulletin->options['dbtech_vbshout_allowed_bbcode'] & 64)
{
// We can use BBCode
$usern = $postinfo[username];
//lets get thread title
$findit = $vbulletin->db->query_read("
SELECT title
FROM ". TABLE_PREFIX ."thread
WHERE threadid = " . $postinfo['threadid'] . "
");
$threadtitle = $findit['title'];
$notif = '[post=' . $postinfo['postid'] . ']' . $threadtitle . '[/post]';
}
else
{
// We can't, so don't even bother
$notif = $threadinfo['title'];
}
// Insert the notification
$vbulletin->db->query_write("
INSERT INTO " . TABLE_PREFIX . "dbtech_vbshout_shout
(userid, dateline, message, type, notification)
VALUES (
" . $vbulletin->userinfo['userid'] . ",
" . TIMENOW . ",
'" . $vbulletin->db->escape_string(
construct_phrase(
$vbphrase["dbtech_vbshout_notif_thanks"],
$usern,
unhtmlspecialchars($notif)
) . "',
8,
'thanks'
)
");
// Get the shout id
$shoutid = $vbulletin->db->insert_id();
($hook = vBulletinHook::fetch_hook('dbtech_vbshout_shout_notification')) ? eval($hook) : false;
// Set the latest AOP time
switch ($vbulletin->options['dbtech_vbshout_optimisation'])
{
case 1:
// File system
touch(DIR . '/dbtech/vbshout/aop.php');
break;
case 2:// Database
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "datastore
SET data = IF(data < " . TIMENOW . ", " . TIMENOW . ", data)
WHERE title = 'dbtech_vbshout_aoptime'
");
break;
}
}
?>
I can get the threadid to showup using post['threadid']... but cant get it to tell me the title... wish there was a way...
BTW: I did add 'thanks' to the notification column on the database, so thats not it.