As the entry title says, this blog entry describes changes and improvements to the hooks functionality in IP.Board, and is aimed mainly at modification authors.
New Data hook access points
Several new data hooks have been added for IP.Board and the addons. Here a list of the ones added in 3.1.3:
- topicViewQuery: allows you to add new fields for the members table in the query, and add new joins when posts are retrieved from the database. This will allow you to select additional fields in the members table if you need to, or join in other database tables to retrieve additional information for your modification. The main use for this would be to retrieve additional data to show in the userInfoPane template.
- incrementUsersPostCount: several modifications need to execute code when the post count for a user is incremented (example: popular points modifications). This new data hook will allow you to do so.
- Add Calendar Event
- Edit Calendar Event
- Add New Blog
- Add Blog Entry: Entry
- Add Blog Entry: Poll Data
- Edit Blog Entry: Entry Data
- Edit Blog Entry: Added Poll
- Edit Blog Entry: Updated Poll
- Add Blog Entry Comment
- Edit Blog Entry Comment
- Add Download
- Edit Download
- Update Downloads Category Info
- Rebuild Downloads Statistics Cache
- Add Download Comment
- Edit Download Comment
The other applications, such as IP.Gallery, will all see new data hooks as well.
Library hooks support
In IP.Board 3.1.0, we introduced a new type of hook: Library Hooks. This hook type is a powerful tool for modification authors, allowing you to overload the libraries and extend virtually any function in the IP.Board code. Initially, the support for library hooks was limited and often times a class loaded from different areas of the code would sometimes load any library hooks associated with it, and sometimes would not; for IP.Board 3.1.3 we have added support for them in a lot more areas of the code. All of our addon applications have been updated to use them too!
While IP.Board 3.1.3 is a major improvement in terms of library hook support, we will continue working on implementing the library hook support throughout all of IP.Board, with the expectation that IP.Board 3.2 will support library hooks in 100% of locations that can utilize them.
New function IPSLib::loadActionOverloader()
Action overloaders are usually executed automatically by the code but unfortunately that happens only when those classes are executed directly; when those classes are loaded and executed manually like in the code below the overload doesn't apply:
require_once( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php' ); $langLib = new admin_core_languages_manage_languages( $this->registry );
To resolve this issue, we have added a new function in IPSLib that works similarly to IPSLib::loadLibrary(). This function however accepts only 2 parameters: the first one is the path to the file itself while the second parameter is the class you are overloading. This is an example based on the code above:
$classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' ); $langLib = new $classToLoad( $this->registry );
Support for usercpFormsExt plugin dropped Starting with IP.Board 3.1.3, we have discontinued support for the plugin usercpFormsExt.php. This is a plugin that we introduced in the 3.0 version of IP.Board to extend the user control panel tabs when library hooks didn't exist. It has now been replaced with a much more flexible library hook that allows for infinite extensions and you won't even need to upload a file as everything is done with a simple hook. If any developers were using this functionality, be sure to update your code to use the new library hook method. This below is the current code in the public_core_usercp_manualResolver class, for reference:
//----------------------------------------- // Begin initilization routine for extension //----------------------------------------- $classToLoad = IPSLib::loadLibrary( $EXT_DIR . '/usercpForms.php', 'usercpForms_' . $_TAB, $_TAB ); $usercp_module = new $classToLoad();
We appreciate the feedback of our developers, and hope that these small changes make it easier to extend IP.Board and create useful and creative addons for our products.