straightvisions

Hooks

Recommended Posts

With IPBWI 4, you are able to handle hooks triggered by IPS 4.

Configuration

IPBWI PHP Wrapper

  1. set ipbwi_ACTIVATE_HOOKS in /ipbwi-api/config.inc.php to true
  2. rename file /ipbwi-api/lib/hooks.php.dist to hooks.php
  3. edit file hooks.php and fill methods with your custom code

SSO Hooks

SSO Hooks are based on IPS.connect and automatically fire to all slaves regardless of the settings below.

IPBWI IPS App

screenshot-dev.straightvisions.com 2017-02-09 18-43-31.png

After you've installed the App

  1. Go to IPS ACP -> IPBWI -> Advanced -> Hooks
  2. Activate Default Hooks. We will describe how to add custom hooks later

You may want to activate hooks going to be sent to all IPS connect slaves, a custom URL and/or via email. In all cases, data is sent as json-string.

Default Hooks

The following Hooks are triggered for Topics and Posts when Default Hooks has been activated.

set_pp_main_photo

IPS\\ipbwi_hook_ipbwi_member::set_pp_main_photo

Whenever a profile photo of a member has been changed.

The delivered data object contains the photopath and the updated member object

save

IPS\\forums\\ipbwi_hook_ipbwi_forums_topic::save
IPS\\forums\\Topic\\ipbwi_hook_ipbwi_forums_topic_post::save

Whenever Topic Data has been created or changed - great if you are caching topic information on your site and want to get a refresh trigger.

The delivered data object contains the field item with detailed informations about the item.

modAction

IPS\\forums\\ipbwi_hook_ipbwi_forums_topic::modAction
IPS\\forums\\Topic\\ipbwi_hook_ipbwi_forums_topic_post::modAction

Whenever a mod action has been performed, the data object contains a field action which informs about the type of action performed:

  • feature
  • unfeature
  • pin
  • unpin
  • hide
  • unhide
  • lock
  • unlock
  • move
  • merge
  • delete
  • approve

Additionally, information about the member who has performed the action as well as a reason and item information are delivered in data object.

Custom Hooks

You can create your own, custom hooks utilizing the Code Hooks feature of IPS.

Snippet:

if(isset(\IPS\Settings::i()->ipbwi_hooks_activate_default) && \IPS\Settings::i()->ipbwi_hooks_activate_default == 1 && isset($this) && is_object($this) && method_exists($this, 'apiOutput')){
	$hooks					= new \IPS\ipbwi\modules\admin\advanced\hooks;
	$hooks->send(__METHOD__,array('item' => $this->apiOutput()));
}

 

Share this post


Link to post
Share on other sites