Questions/Comments on "A guide to the SMF integration hooks"

Started by Orstio, May 26, 2007, 05:19:48 PM

Previous topic - Next topic

jjgallow

Orstio,

Thank you very much for these hooks!

My bridge is now stable, and I have used the hooks extensively for it.

I do think that these hooks could be useful beyond integration, though.

After working with Wordpress...which uses hooks exclusively for all plugins, I feel like having both hooks and xml available for plugins would be the best way to go.

If SMF had a "plugins" folder, and all files in it were included within index.php (this is sort of how my bridge is structured), you would essentially be giving hook access to all plugin developers.

This could significantly limit the amount of code alterations in plugins, increase compatibility, and simply make them easier to write.  For example, my plugin can now completely integrate SMF users with Wordpress, no simple task:  but I only needed to add 3 lines of code to do it.

Essentially, plugins developers would still have the xml power to alter code, but the availability of hooks would allow them to write their plugins without altering any code whenever possible.

I feel like plugin developers would be getting the best of both worlds, and it would require very minimal alteration to accomplish.

Anyway,

Thanks, the hooks really did it for me!

puredemo

Orstio,

I've read through the different hooks, I'm wondering is there a hook to simply create a new thread?

I want to write a php function that will create a new thread and put a single post in it.

Thantos

puredemo,
You can use the createPost() function in Subs-Post.php to create a topic and/or post.

A hook would be used to call a function when a topic was made.

puredemo

Thantos,

Thanks for the quick response. Best... sigline... ever.








mikeschroeder

I've been looking at these integration hooks but I'm not sure if what I need is possible, can anyone clarify this?

Right now we have a base SMF installation, and we use a CRM system which provides all of our member management as well as our website to these members, ecommerce etc.

Since our website already establishes unique username and passwords, I would like to have SMF first query its database to check if the user is an SMF user, and if so log the user in as usual. However if the user is not found would it be possible for SMF then to query our existing database using its xml interface, and look for the user there. Then if the user exists log them into SMF as well as create a record for them in SMF so the multiple queries would not be required all the time.

This way our existing users would gain access to SMF as well as our moderately large existing forum user base to continue uninterrupted use.

It seems like these integration hooks might work, but it almost seems like i might have to modify the core?

Am i on the right track or totally off base?

Thanks

Orstio

No, you wouldn't need to modify the SMF core.

You would use the integrate_validate_login hook.

In your hook function, you would first check to see if the user already exists in SMF.  If the user does not exist in SMF, you would check to see if the user exists in the CRM system.  If the user does exist, you would write that user into SMF, and then return the function.

Sordell Media

Can these hooks be used when SMF and the other application are physically located on seperate servers? And what would be the best bridge example to get an idea of how best to use the hooks? Have been wondering for some time how I could link SMF to my sites in-house authentication system to make it easier for my members to keep up-to-date on the forum and this looks like the answer to my problems, just not 100% sure how to implement.

Also one last Q, will these work with SMF 2.0 as they do currently?

Orstio

QuoteCan these hooks be used when SMF and the other application are physically located on seperate servers?

They can, but I would never recommend it.  XSS (cross-site scripting) is asking for script-kiddie trouble.  It is always best to keep connected scripts on the same physical server.

QuoteAnd what would be the best bridge example to get an idea of how best to use the hooks?

The simplest would be the iGamingCMS bridge.  The Mambo bridge has some more advanced integration.

QuoteHave been wondering for some time how I could link SMF to my sites in-house authentication system to make it easier for my members to keep up-to-date on the forum and this looks like the answer to my problems,

It's actually just the opposite.  The hooks use SMF's authentication system to register and login, etc. to other scripts.

QuoteAlso one last Q, will these work with SMF 2.0 as they do currently?

The same integration hooks will exist in SMF 2.0.  There may be more functionality added to the system overall, however, that may require changes to integrations as well.


Sordell Media

Quote from: Orstio on August 29, 2007, 08:54:57 PM
It's actually just the opposite.  The hooks use SMF's authentication system to register and login, etc. to other scripts.

Hmm, so maybe this wouldnt help me? Basically what I'm looking for is a way that when someone registers on my site, I can create a forum account for them, and similarly when they login to my site they can be logged into the forum without them having to enter their details twice. Is this not what I'm looking for?

Thanks for the quick response ;D

Oldiesmann

You would simply need to pass the registration info to SMF's registerMember function in Subs-Members.php to register them in SMF. Not sure exactly how you'd handle the login.
Michael Eshom
Christian Metal Fans

doktor_x

hxxp:www.hemsirelersitesi.com [nonactive]
hxxp:www.ciltbakim.net [nonactive]
hxxp:www.hemsirelersitesi.net [nonactive]
hxxp:www.hemsirelersitesi.com [nonactive]
hxxp:www.hemsirelersitesi.com [nonactive]
hxxp:www.hemsirelersitesi.com [nonactive]
hxxp:www.hemsirelersitesi.com [nonactive]
hxxp:www.hemsirelersitesi.com [nonactive]

Mike Bobbitt

Great guide... I'm attempting to expand my Who's Online to cover other parts of my site. I've created a simple whos_online_function function so far for testing:


function whos_online_function($actions) {

return ('whoadmin_dumpdb');
}


I'm just trying to test at this point, I would have expected everyone's status to flip to "Backing up the database to file." but it didn't. I've added what I believe is the correct row to my settings table. Here's an export of it:

INSERT INTO `smf_settings` (`variable`, `value`) VALUES
('integrate_whos_online', 'whos_online_function');


Any advice? I'm sure I'm missing something simple.


Thanks
Mike

Orstio

Where did you put the function?  Is it in Who.php?

What you have there will return the text 'whoadmin_dumpdb'.  If you want it from the language file, it needs to be $txt['whoadmin_dumpdb'].

Mike Bobbitt

Thanks Orstio, I included the function in a global PHP file that I include for all pages. So I should be returning the actual text I want displayed in Who's online? I.E. return ("testing a customized Who's Online message."); for example?

Orstio

QuoteThanks Orstio, I included the function in a global PHP file that I include for all pages.

So, from where exactly is it included?  It will need to be in the workflow before Who.php is executed.

QuoteSo I should be returning the actual text I want displayed in Who's online? I.E. return ("testing a customized Who's Online message."); for example?

Yes.

Mike Bobbitt

It's included in global.php, it's the first include call made in the script and one of the first things to be done for all pages (forum and non-forum).

I changed the return value as above, but it still doesn't have any effect. I have the gallery mod installed which defines parts of SMF_INTEGRATION_SETTINGS already (but not integrate_whos_online). It doesn't seem like setting is taking for some reason though.

Any help is appreciated, thanks.

Orstio

QuoteIt's included in global.php, it's the first include call made in the script and one of the first things to be done for all pages (forum and non-forum).

In what line of what file is it included?  I need some details on where the include occurs in the workflow.

Mike Bobbitt

Sorry, I'm not trying to be vague, honest. :) When a non-forum page is loaded, the first thing it does is inclide_once global.php. global.php sets a couple of variables and then includes functions.php, which contains the whos_online_function function. It then includes SSI.php. Is that the workflow you're looking for?

BTW I noticed something odd... although my test status never shows up in who's online for my test user, a call to determineActions (in Who.php) will actually show them with the new status. So it's "almost" working.

Thanks!
Mike

Orstio

QuoteSorry, I'm not trying to be vague, honest.  When a non-forum page is loaded, the first thing it does is inclide_once global.php. global.php sets a couple of variables and then includes functions.php, which contains the whos_online_function function. It then includes SSI.php. Is that the workflow you're looking for?

Perfect.

So, that function is never included when the forum is loaded.

When you are looking at your Who's Online page, you have the forum loaded.

The whos_online_function needs to be in the workflow that produces the Who's Online page.

The easiest way to accomplish that if you haven't built a bridge up front is to tag it onto the end of SMF's Who.php.

Mike Bobbitt

Ah, that makes perfect sense! So I add the include for functions.php to Who.php then, and the forums already know when to call it?

Advertisement: