minimoo

  • Posts: 2
Hooks
« on January 6th, 2013, 03:19 PM »
[@Mods - Apologies if this is the wrong place to post this - it seemed somewhat appropriate but please move if required]

I've recently put in a pull request against SMF [ https://github.com/SimpleMachines/SMF2.1/pull/242 ] to add some hooks for a plugin that I'm gradually writing to authenticate and add other functionality around a game.

Whilst I've only just signed up, I've been keeping an eye on SMF + forks progress and it seems that despite only two people wedge is currently moving forwards at the fastest rate.

On that basis;

  • How similar are the integration hooks between SMF + Wedge at this point in time?
  • Is there functionality in the current version of wedge that provides the equivalent to the git pull request for SMF above? If not, let me know and i'll add a post for a feature request if appropriate.
  • Between Dragooon's mods on github [https://github.com/Dragooon] and some others, I'm hoping that there's enough example code to be able to work on a mod prior to the public release of wedge. I have however been able to find any 'developer' documentation - I assume that is because it does not exist at this stage - is that correct?

Paul

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Hooks
« Reply #1, on January 6th, 2013, 04:10 PM »
Well, there are a number of differences, though I can only compare to how SMF 2.0 hooks work because I don't generally trawl their Git repo.

But, functions on a hook can be assigned a priority, hooks can load files for their functions and no plugin should be manually forcing hooks to be registered. There is a whole separate architecture that validates a plugin exists and only attaches that plugin's hooks to the stack at page load. Slower but offers all sorts of benefits like you can just rename or remove a folder and things don't come crashing down.

There are no changes to the hooks for registration at this time, so the proposed changes could likely be added easily.

There is not much in the way of developer documentation because it works best if you have the core code available to work with. Though some of the mechanics of the plugin manager are documented.

What exactly are you trying to do? There is a plugin underway that may overlap what you're doing.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

minimoo

  • Posts: 2
Re: Hooks
« Reply #2, on January 6th, 2013, 06:33 PM »
Thanks for the reply - Currently using smf with a mod that allows forum authentication to be checked against game accounts [for eve online] - https://code.google.com/p/temars-eve-api/

The above mod is not the most secure/cleanest/bug-free bit of code, and the original author no longer plays the game. This changes the registration screen to require extra custom data, and validate it. In SMF - IMO one of the hooks is really in the wrong place to be useful, as per it's description.

So I'm pretty sure my end-aim won't be something that will overlap with existing plugins :)

There's obviously been an amount of politics around SMF over last few years, I'm trying to work out whether I would be best basing a plugin for eve around SMF2/2.1 or whether a better gamble would be to look at the public wedge alpha when that gets released shortly, and consider a migration.

The rough idea in any case is:
* customise registration page
* add a few profile pages to store 'api keys'
* add a few pages to view api data

So apart from needing a  registration hook in the right sort of places [to allow 3rd party content to be displayed on the page and validate it before creating a user], there's nothing here that I can't code whilst waiting for the alpha release and use either smf/wedge as appropriate.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Hooks
« Reply #3, on January 6th, 2013, 06:38 PM »
Eh, needs more hooks in Wedge for that. I don't believe there are any hooks for managing extra data, though of course there are already custom profile fields ;) I've been thinking about extending the registration page with extra functionality for a while, for other things that require it, but not gotten around to that yet.

Adding API data can be very simplistic (just storing the fields, and just have a very simple page that requires little effort to set up) or you can get more exotic and validate it with your own code which is a fair amount more complicated.
Re: Hooks
« Reply #4, on January 7th, 2013, 04:36 AM »
OK, so I've looked properly at the patch now, and I'm not entirely convinced it actually would work properly in SMF, let alone Wedge.

The return value of a called hook, particularly one where multiple functions might be hooked, is not what you think is. I might expect to see an array returned, sure...

Code: [Select]
array(
  'my_func_name' => array('error_key' => error details)
)

In every case of calling a hook, it's done through building up an array where the return value delineates what hooked function returned what by referencing the name of the function that was called.[1] Aside from keeping things separated from accidental collision, it does mean you can't rely on $hook_errors being empty, because it should return an array of functions that have been called, even if those individual items are empty.
 1. Yup, it's not really any different in Wedge, the exact syntax is a shade different in our call_hook vs SMF's call_integration_function, but the principle is the same, having a variable accepting the result of call_user_func_array() and putting it into an array.