powerful_rogue
05-30-2009, 09:10 PM
Hi,
I couldn't really think of a title that made sense without making it super long! Im just getting my head around php, however now I need to use a bit of SQL and was hoping for a bit of advice!
I created a mod that creates a thread when someone makes a paid subscription. Someone has asked if there is a way to have it make threads for people that made a paid subscription prior to the mod being installed.
Ive had a look through the database and I believe it has something to do with the following as this seems to list the userids of those that have made a payment.
SELECT `userid`
FROM `paymentinfo`
Im thinking i'll need to add a button in the ACP, that when an admin clicks it, it will run a script creating threads for older paid subscriptions, however this is where im a bit stuck!
Im guessing the SQL code will have to go above this php that creates the thread -
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = fetch_foruminfo($foruminfo['forumid']);
$threadinfo = array();
$username = $vbulletin->userinfo['username'];
$forumid = $vbulletin->options['subthread_fid'];
eval('$title = "' . addslashes($vbulletin->options['subthread_title']) . '";');
$userid = $vbulletin->options['subthread_toid'];
eval('$pagetext = "' . addslashes($vbulletin->options['subthread_content']) . '";');
$posticon = $vbulletin->options['subthread_posticon'];
$allowsmilie = '1';
$visible = '1';
$threaddm->set_info('forum', $foruminfo);
$threaddm->set_info('thread', $threadinfo);
$threaddm->setr('forumid', $forumid);
$threaddm->setr('userid', $userid);
$threaddm->setr('pagetext', $pagetext);
$threaddm->setr('title', $title);
$threaddm->set('iconid', $posticon);
$threaddm->set('allowsmilie', $allowsmilie);
$threaddm->set('visible', $visible);
$threaddm->pre_save();
if(count($threaddm->errors) < 1)
{
$threadid = $threaddm->save();
unset($threaddm);
build_thread_counters($threaddm);
}
build_forum_counters($forumid);
Im presuming it would have to be a seperate script, as you wouldnt be able to define a hook location, as it would be a manual action when the admin clicks the button.
I know ive posted a few threads recently, however I am trying to work things out before I ask. Any help/advice is greatly appreciated.
Thanks
Dave
I couldn't really think of a title that made sense without making it super long! Im just getting my head around php, however now I need to use a bit of SQL and was hoping for a bit of advice!
I created a mod that creates a thread when someone makes a paid subscription. Someone has asked if there is a way to have it make threads for people that made a paid subscription prior to the mod being installed.
Ive had a look through the database and I believe it has something to do with the following as this seems to list the userids of those that have made a payment.
SELECT `userid`
FROM `paymentinfo`
Im thinking i'll need to add a button in the ACP, that when an admin clicks it, it will run a script creating threads for older paid subscriptions, however this is where im a bit stuck!
Im guessing the SQL code will have to go above this php that creates the thread -
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = fetch_foruminfo($foruminfo['forumid']);
$threadinfo = array();
$username = $vbulletin->userinfo['username'];
$forumid = $vbulletin->options['subthread_fid'];
eval('$title = "' . addslashes($vbulletin->options['subthread_title']) . '";');
$userid = $vbulletin->options['subthread_toid'];
eval('$pagetext = "' . addslashes($vbulletin->options['subthread_content']) . '";');
$posticon = $vbulletin->options['subthread_posticon'];
$allowsmilie = '1';
$visible = '1';
$threaddm->set_info('forum', $foruminfo);
$threaddm->set_info('thread', $threadinfo);
$threaddm->setr('forumid', $forumid);
$threaddm->setr('userid', $userid);
$threaddm->setr('pagetext', $pagetext);
$threaddm->setr('title', $title);
$threaddm->set('iconid', $posticon);
$threaddm->set('allowsmilie', $allowsmilie);
$threaddm->set('visible', $visible);
$threaddm->pre_save();
if(count($threaddm->errors) < 1)
{
$threadid = $threaddm->save();
unset($threaddm);
build_thread_counters($threaddm);
}
build_forum_counters($forumid);
Im presuming it would have to be a seperate script, as you wouldnt be able to define a hook location, as it would be a manual action when the admin clicks the button.
I know ive posted a few threads recently, however I am trying to work things out before I ask. Any help/advice is greatly appreciated.
Thanks
Dave