I don't know how much of this information will be use full for my question but:

I have a drupal 4.7 installation, and am using flexinode for different content types.

I am using PHPBB for my forums, and currently it is a separate install, not integrated with Drupal.

I would like to automagically create a new forum topic in PHPBB every time a new node is submitted, not when a node is edited. I want to use the node title as the PHPBB topic title, and insert text and a link to the node in the body of the topic.

I am able to connect to the database, and I know what tables to edit, what I don't know is which hook to use in Drupal, or where to put the php code in drupal.

Any help on this would be appreciated.

Comments

ymmatt’s picture

I believe that this code can be made to work when posting content from drupal, and I'm sure that I can do the coding.

http://www.phpbb.com/phpBB/viewtopic.php?t=15708&highlight=autopost

All I need is for someone who is more familiar with drupal to tell me where to put it. Does it go in the submit_hook, or some other hook?

redmonp’s picture

You could try using the ImportExportAPI module. You would have to write your own module to utilize it, but you should be able to install that module, set your variables, and hook into the API.

ymmatt’s picture

I've looked into writing my own module before, but for what I'm trying to do it seems to be a lot of work.

It seems like I can create a custom submit_hook that includes a function to add the forum topic to phpbb.

I may be asking for too much here, and I know I am not using Drupal terminology but this is how I see it happening:
After the user has created their content and clicks submit:
All of the usual Drupal stuff is done and just before it is saved:
A new forum topic is created in PHPBB with a teaser and link back to the new node
A variable in the new node is changed to link to the new PHPBB forum topic

I need to make sure that this function goes in the right place, i.e. it is able to reference the new nodes variables ($nid, $teaser) as well as able to change a variable in the new node ($node->flexinode_9) to reference the new forum link.

ymmatt’s picture

I've tested my function, and it works, now I want to do the following:

if ($variable) {
include('curl_phpbb.class.php');

// PHPBB forum location The ending backslash is required.
$phpbb = new curl_phpbb('http://www.mydomain.com/forum/');

// Log in (User, Password)
$phpbb->login('user', 'password');

$forumBody  = $node->teaser
$forumBody .= ' To read the full article click [url=http://www.mydomain.com/node/'.node->nid.'] here[/url]';

// Post a topic (forumID, Body, Subject)
$topic = $phpbb->new_topic('1', $forumBody, $node->title);

//Log out
$phpbb->logout();

//
$node->flexinode_8 = '<a href="http://www.mydomain.com/phpbb/viewtopic.php?p='.$topic.'">Discuss this article here</a>';
}

I believe that the best place to do this would be right before the node is saved to the database, but when/where is that!?

Cross_and_Flame’s picture

did you ever get this to work?

ymmatt’s picture

Sorry for the late response, I had this in several threads, but this one is the one that received the most responses:

http://drupal.org/node/112131

I am in the slow process of transitioning this into a module, I've got to remove/add some features, but hopefully I will have a bare bones version ready soon.