MyPlaza Development - Module Format and Layout

MyPlaza modules are very similar to MyBB plugins. This was to make the transition from developing MyBB plugins, to MyPlaza modules as smooth as possible. In fact, MyBB plugins should run fine as a MyPlaza module, with one exception...
MyPlaza modules, by design, may be include'd at various locations. Also, many simple modules will not need to be include'd on every page, unlike MyBB plugins are - this is done to save some time parsing the extra code.
Because of this, I have made a special _plugin() function, in which you should place everything that is to be executed, like a MyBB plugin (ie plugin hooks). Obviously, code outside any functions will be executed when the file is include'd, however, MyPlaza will not include modules which do not have a _plugin() function, as a MyBB plugin.
In other words, if you add a blank _plugin() function, ie function myplugin_plugin(){} to an existing MyBB plugin, it should run fine as a MyPlaza module (with some minor exceptions).

Module Functions

These functions can be supplied in modules and may be executed by MyPlaza. Note that the only required function is the _info() function.

_info()

This function is almost identical to the _info() function for MyBB plugins. Basically, it's a required function, which returns information about the plugin. MyPlaza extends MyBB's _info() with a few extra optional fields: compatibility is simply an array of versions of MyPlaza which the module is compatible with - this is just used to present the compatibility warning in the AdminCP; update_check_url is the URL which MyPlaza accesses if checking if a newer version of the module is available; update_download_url is the URL from which MyPlaza downloads updates for the module (more information about automatic updating may be provided in a later version of this documentation).

_activate()

This is identical to the _activate() function in MyBB plugins. This function is called when a user activates the module/plugin in the AdminCP.

_deactivate()

This is identical to the _deactivate() function in MyBB plugins. This function is called when a user deactivates the module/plugin in the AdminCP.

_plugin()

If this function is included, MyPlaza will run the module as a MyBB plugin, executing the contents of this function on each page. Generally, you should just add your plugin hooks inside this function. See above for more information on why this approach was taken.

_lang()

This function defines language variables for the module. This function is used instead of a separate .lang.php file, mainly to reduce clutter and keep everything related to a module to a single file. As a module developer, you may still want to use separate .lang.php files if you wish. This function is automatically called when myplaza_langload() is called (which is done automatically at various places to make things more convenient).

_lang_admin()

As with above, but defines language vars for the AdminCP.

_run($item)

This function is called when an item, linked to this module, is purchased. The item which has been purchased is passed, as an array, via the $item variable. You'll need to return a boolean value with this function, indicating success (true) or failure (false).

_admin($process)

This function is called when a user clicks the Options button next to a module under AdminCP -> MyPlaza -> Modules. Usually, you would just display any settings related to the module. The $process variable is true when settings should be processed, or false otherwise.

_page()

This function allows a module to have custom page(s), without having to make another file in the forum root directory. The page is accessible via /plaza.php?action=page&p=[name of module]. You should return the template that you want to display - this is done so that variables can be eval'd at a global scope.

_htmlextra()

This function is called when any variables in htmlextra fields need to be evaluated. Basically, this allows a module to evaluate variables that show up in the plaza. Note that this function will only ever be called once - not each time an item needs to be displayed. Also note that this function will only be called if an item belonging to the module is to be displayed.

Module Templates

To be done later...