فهرست منبع

#328 Intercom integration module

Alex Trofimov 10 سال پیش
والد
کامیت
ca31c45b29

+ 37 - 0
modules/boonex/intercom/classes/BxIntercomAlerts.php

@@ -0,0 +1,37 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomAlerts extends BxDolAlertsResponse
+{
+    protected $_oModule;
+    function __construct()
+    {
+        parent::__construct();
+        $this->_oModule = BxDolModule::getInstance('bx_intercom');
+    }
+
+    public function response($o)
+    {        
+        if ('account' == $o->sUnit && 'delete' == $o->sAction) {
+            $this->_oModule->serviceRemoveAccount($o->iObject);
+        }
+        
+        if ('account' != $o->sUnit && ('deleted' == $o->sAction || 'edited' == $o->sAction || 'added' == $o->sAction)) {
+            $oProfile = BxDolProfile::getInstanceByContentAndType($o->iObject, $o->sUnit);
+            $oAccount = $oProfile ? $oProfile->getAccountObject() : null;
+            
+            if ($oAccount)
+                $this->_oModule->serviceUpdateAccount($oAccount->id());
+        }
+    }    
+}
+
+/** @} */

+ 20 - 0
modules/boonex/intercom/classes/BxIntercomConfig.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomConfig extends BxDolModuleConfig
+{
+    function __construct($aModule)
+    {
+        parent::__construct($aModule);
+    }
+}
+
+/** @} */

+ 32 - 0
modules/boonex/intercom/classes/BxIntercomDb.php

@@ -0,0 +1,32 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomDb extends BxDolModuleDb
+{
+    function __construct(&$oConfig)
+    {
+        parent::__construct($oConfig);
+    }
+
+    public function getInitialUsers($iLimit = 1000)
+    {
+        return $this->getColumn("SELECT `id` FROM `sys_accounts` ORDER BY `added` DESC LIMIT " . (int)$iLimit);
+    }
+
+    public function getSessionRowByAccountId($iAccountId)
+    {
+        return $this->getRow("SELECT * FROM `sys_sessions` WHERE `user_id` = :account ORDER BY `date` DESC LIMIT 1", array(
+            'account' => $iAccountId,
+        ));
+    }
+}
+
+/** @} */

+ 311 - 0
modules/boonex/intercom/classes/BxIntercomModule.php

@@ -0,0 +1,311 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomModule extends BxDolModule
+{
+    protected $sHostnameAPI = 'https://api.intercom.io';
+
+    function __construct(&$aModule)
+    {
+        parent::__construct($aModule);
+    }
+
+    public function serviceIntegrationCode ()
+    {
+        $sAppId = getParam('bx_intercom_option_app_id');
+        if (!$sAppId)
+            return '';
+
+        $aSettings = array(
+            'app_id' => $sAppId,
+        );
+
+        if (isLogged() && ($oProfile = BxDolProfile::getInstance()) && ($oAccountObject = $oProfile->getAccountObject())) {
+            $aInfo = $oAccountObject->getInfo();
+	        $aSettings['user_id'] = $oAccountObject->id();
+	        $aSettings['name'] = $oProfile->getDisplayName();
+	        $aSettings['email'] = $oAccountObject->getEmail();
+	        $aSettings['created_at'] = $aInfo['added'];
+        }
+        
+        $sSettings = json_encode($aSettings);
+
+        return <<<EOS
+
+        <!-- BEGIN Intercom integration -->
+        <script>
+            window.intercomSettings = $sSettings;
+        </script>
+        <script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/{$sAppId}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
+        <!-- END Intercom integration -->
+
+EOS;
+    }
+
+    /**
+     * remove user from intercom by email or account id
+     */      
+    public function serviceRemoveAccount($mixed)
+    {
+        if (!$mixed)
+            return false;
+
+        if ($mixed && !(int)$mixed) {
+            $sId = BxDolAccount::getID($mixed);
+        } else {
+            $sId = (int)$mixed;
+        }
+        
+        $s = $this->_request('/users?user_id=' . $sId, 'DELETE', array(), $sErrorCurl);
+        if ($sErrorJson = $this->_checkForErrors($s, $sErrorCurl))
+            return false;
+    
+        return true;
+    }
+
+    /**
+     * update user by email or account id
+     */      
+    public function serviceUpdateAccount($sEmail)
+    {
+        if (!$sEmail || !($oAccount = BxDolAccount::getInstance($sEmail)))
+            return false;
+
+        $aUserInfo = $this->_prepareUser($oAccount);
+
+        $s = $this->_request('/users', 'POST', $aUserInfo, $sErrorCurl);
+        if ($sErrorJson = $this->_checkForErrors($s, $sErrorCurl))
+            return false;
+
+        return true;
+    }
+    
+    /**
+     * remove user from intercom by email or account id
+     */      
+    public function actionAccountRemove($sEmail)
+    {
+        if (!isAdmin())
+            die('{}');
+
+        if (!$this->serviceRemoveAccount($sEmail))
+            die(json_encode(array('error' => true, 'message' => "Delete failed")));
+
+        echo json_encode(array('message' => "User was successfully deleted"));
+    }
+
+    /**
+     * update user by email or account id
+     */  
+    public function actionAccountUpdate($sEmail)
+    {
+        if (!isAdmin())
+            die('{}');
+
+        if (!$this->serviceUpdateAccount($sEmail))
+            die(json_encode(array('error' => true, 'message' => "Update failed")));
+
+        echo json_encode(array('message' => "User was successfully updated"));
+    }
+
+    /**
+     * Add members in bulk from local database to Intercom
+     */      
+    public function actionBulkAdd($iLimit = 2)
+    {
+        if (!isAdmin())
+            die('{}');
+
+        set_time_limit(3600);
+        $aIds = $this->_oDb->getInitialUsers($iLimit);
+        $aChunks = array_chunk($aIds, 50);
+        $iTotal = count($aIds);
+        $iCounter = 0;
+        foreach ($aChunks as $aIds) {
+            $aUsers = array();
+            foreach ($aIds as $iAccountId) {
+                if (!($oAccount = BxDolAccount::getInstance($iAccountId)))
+                    continue;
+                if (!($aUserInfo = $this->_prepareUser($oAccount)))
+                    continue;
+                $aUsers[] = $aUserInfo;
+            }
+            $s = $this->_request('/users/bulk', 'POST', array('users' => $aUsers), $sErrorCurl);
+            if (trim($s) && $sErrorJson = $this->_checkForErrors($s, $sErrorCurl))
+                die($sErrorJson);
+            $iCounter += count($aUsers);
+            header('X-Users-Processed: ' . $iCounter . '/' . $iTotal);
+            flush();
+            sleep(1);
+        }
+        echo json_encode(array('message' => "{$iCounter} users were successfully added"));
+    }
+
+    /**
+     * Test query to return number of users registered in intercom
+     */     
+    public function actionNum()
+    {
+        if (!isAdmin())
+            die('{}');
+
+        $s = $this->_request('/users', 'GET', array(), $sErrorCurl);
+        if ($sErrorJson = $this->_checkForErrors($s, $sErrorCurl))
+            die($sErrorJson);
+
+        $a = json_decode($s);
+        
+        echo json_encode(array(
+            'type' => $a->type,
+            'total_count' => $a->total_count,
+        ));
+    }
+
+    protected function _prepareUser($oAccount)
+    {
+        $oProfile = BxDolProfile::getInstanceByAccount($oAccount->id());
+        if (!$oProfile)
+            return false;
+
+        $aInfoProfile = $oProfile->getInfo();
+        $aInfoAccount = $oAccount->getInfo();
+        $aInfoSession = $this->_oDb->getSessionRowByAccountId($oAccount->id());
+        $aProfilesIds = $oAccount->getProfilesIds();
+
+        // membership
+        $aMembership = BxDolAcl::getInstance()->getMemberMembershipInfo($oProfile->id());
+
+        // profiles
+        $sProfiles = '';
+        foreach ($aProfilesIds as $iId) {
+            if (!($o = BxDolProfile::getInstance($iId)))
+                continue;
+            $sProfiles .= $o->getDisplayName() . ', ';
+        }
+        $sProfiles = trim($sProfiles, ', ');
+
+        return array (
+            'user_id' => $oAccount->id(),
+            'name' => $oProfile->getDisplayName(),
+            'email' => $oAccount->getEmail(),
+            'unsubscribed_from_emails' => !$aInfoAccount['receive_news'],
+            'signed_up_at' => $aInfoAccount['added'],
+            //'last_seen_ip' => ?,
+            'last_request_at' => isset($aInfoSession['date']) ? $aInfoSession['date'] : $aInfoAccount['logged'],
+            'custom_attributes' => array (
+                'link' => $oProfile->getUrl(),
+
+                'email_confirmed' => $aInfoAccount['email_confirmed'] ? 'yes' : 'no',
+                'email_receive_news' => $aInfoAccount['receive_news'] ? 'yes' : 'no',
+                'email_receive_updates' => $aInfoAccount['receive_updates'] ? 'yes' : 'no',
+                
+                'membership' => _t($aMembership['name']) . (isset($aMembership['date_expires']) && $aMembership['date_expires'] ? ' (expires:' . bx_time_utc($aMembership['date_expires']) . ')' : ''),
+                'status' => $aInfoProfile['status'],
+                'type' => $aInfoProfile['type'],
+
+                'all profiles' => $sProfiles,
+            ),
+        );
+    }
+
+    /**
+     * @return json error object on error or empty string on success
+     */
+    protected function _checkForErrors($s, $sErrorCurl, $sReturnType = 'json')
+    {
+        if (!$s)
+            return $this->_returnErrors(array('error' => 'curl error: ' . $sErrorCurl), $sReturnType);
+
+        $a = json_decode($s);
+        if (null === $a)
+            return $this->_returnErrors(array('error' => 'json decode failed:' . htmlspecialchars($s)), $sReturnType);
+
+        if (0 === strncmp('error', $a->type, 5)) {
+            $sError = '';
+            foreach ($a->errors as $o)
+                $sError .= $o->code . ": " . $o->message . "\n";
+            return $this->_returnErrors(array('error' => $sError), $sReturnType);
+        }
+
+        return '';
+    }
+
+    protected function _returnErrors($mixed, $sReturnType = 'json')
+    {
+        switch ($sReturnType) {
+            case 'array':
+                return $mixed;
+            case 'json':
+            default:
+                return json_encode($mixed);
+        }
+    }
+
+    /**
+     * Perform JSON request to the API endpoint and get JSON response
+     * @return false on error
+     */
+    protected function _request($sURI, $sMethod = 'GET', $aData = array(), &$sError)
+    {
+        $sAppId = getParam('bx_intercom_option_app_id');
+        $sApiKey = getParam('bx_intercom_option_api_key');
+        if (!$sAppId || !$sApiKey) {
+            $sError = "No App ID or API Key";
+            return false;
+        }
+        
+        $r = curl_init();
+    
+        $aHeaders = array(
+            'Accept: application/json',
+        );
+
+        curl_setopt($r, CURLOPT_USERPWD, $sAppId . ":" . $sApiKey);
+        curl_setopt($r, CURLOPT_TIMEOUT, 10);
+        curl_setopt($r, CURLOPT_URL, $this->sHostnameAPI . $sURI);
+        curl_setopt($r, CURLOPT_HEADER, 0);
+        curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($r, CURLOPT_FOLLOWLOCATION, 1);
+
+        if ('POST' == $sMethod) {
+
+            $sDataJson = json_encode($aData); 
+
+            curl_setopt($r, CURLOPT_POST, true);
+            curl_setopt($r, CURLOPT_POSTFIELDS, $sDataJson);
+
+            $aHeaders = array_merge($aHeaders, array(
+                'Content-Type: application/json',
+                'Content-Length: ' . strlen($sDataJson)
+            )); 
+
+        } elseif ('DELETE' == $sMethod) {
+
+            curl_setopt($r, CURLOPT_CUSTOMREQUEST, "DELETE");
+
+        }
+
+        curl_setopt($r, CURLOPT_HTTPHEADER, $aHeaders); 
+
+        $sResult = curl_exec($r);        
+
+        if (false === $sResult) {
+            $sError = curl_error ($r);
+            curl_close($r);
+            return false;
+        }
+
+        curl_close($r);
+        return $sResult;
+    }
+}
+
+/** @} */

+ 27 - 0
modules/boonex/intercom/classes/BxIntercomStudioPage.php

@@ -0,0 +1,27 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomStudioPage extends BxTemplStudioModule
+{
+    function getHelp ()
+    {
+        return _t('_bx_intercom_information_block');
+    }
+
+    protected function getPageCaptionHelp()
+    {
+        $oTemplate = BxDolStudioTemplate::getInstance();
+        $sContent = '<a href="' . BX_DOL_URL_STUDIO . 'module.php?name=bx_intercom&page=help">' . _t('_bx_intercom_information') . "</a>";
+        return $oTemplate->parseHtmlByName('page_caption_help.html', array('content' => $sContent));
+    }
+}
+
+/** @} */

+ 20 - 0
modules/boonex/intercom/classes/BxIntercomTemplate.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomTemplate extends BxDolModuleTemplate
+{
+    function __construct(&$oConfig, &$oDb)
+    {
+        parent::__construct($oConfig, $oDb);
+    }
+}
+
+/** @} */

+ 66 - 0
modules/boonex/intercom/install/config.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_intercom',
+    'title' => 'Intercom',
+    'note' => 'Intercom integration.',
+    'version' => '9.0.0.DEV',
+    'vendor' => 'BoonEx',
+	'help_url' => 'http://feed.boonex.com/?section={module_name}',
+
+    'compatible_with' => array(
+        '9.0.x'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/intercom/',
+    'home_uri' => 'intercom',
+
+    'db_prefix' => 'bx_intercom_',
+    'class_prefix' => 'BxIntercom',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Intercom',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+);

+ 20 - 0
modules/boonex/intercom/install/installer.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxIntercomInstaller extends BxDolStudioInstaller
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}
+
+/** @} */

+ 16 - 0
modules/boonex/intercom/install/langs/en.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources name="en" flag="gb" title="English">
+	<string name="_sys_module_intercom"><![CDATA[Intercom]]></string>
+	<string name="_bx_intercom"><![CDATA[Intercom]]></string>
+
+	<string name="_bx_intercom_setting"><![CDATA[Intercom Setting]]></string>
+    <string name="_bx_intercom_adm_stg_cpt_type"><![CDATA[Intercom]]></string>
+    <string name="_bx_intercom_adm_stg_cpt_category_general"><![CDATA[General]]></string>
+    <string name="_bx_intercom_option_app_id"><![CDATA[Intercom App ID]]></string>
+    <string name="_bx_intercom_option_api_key"><![CDATA[Intercom API Key]]></string>
+
+	<string name="_bx_intercom_information"><![CDATA[Information]]></string>
+    <string name="_bx_intercom_information_block"><![CDATA[
+        This module add Intercom services to your website. <br />
+        To enable this module, you need to get Intercom App ID from <a target="_blank" href="https://www.intercom.io">www.intercom.io</a>.]]></string>
+</resources>

+ 15 - 0
modules/boonex/intercom/install/sql/disable.sql

@@ -0,0 +1,15 @@
+
+-- Settings
+
+DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name` = 'bx_intercom';
+
+-- Injections
+
+DELETE FROM `sys_injections` WHERE `name` = 'bx_intercom';
+
+-- Alerts
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers` WHERE `name` = 'bx_intercom');
+
+DELETE FROM `sys_alerts_handlers` WHERE `id`  = @iHandlerId;
+DELETE FROM `sys_alerts` WHERE `handler_id` =  @iHandlerId ;

+ 36 - 0
modules/boonex/intercom/install/sql/enable.sql

@@ -0,0 +1,36 @@
+
+-- Settings
+
+SET @iTypeOrder = (SELECT MAX(`order`) FROM `sys_options_types` WHERE `group` = 'modules');
+INSERT INTO `sys_options_types` (`group`, `name`, `caption`, `icon`, `order`) VALUES 
+('modules', 'bx_intercom', '_bx_intercom_adm_stg_cpt_type', 'bx_intercom@modules/boonex/intercom/|std-mi.png', IF(NOT ISNULL(@iTypeOrder), @iTypeOrder + 1, 1));
+SET @iTypeId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order` )  
+VALUES (@iTypeId, 'bx_intercom_general', '_bx_intercom_adm_stg_cpt_category_general', 1);
+SET @iCategId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `order`, `extra`) VALUES
+('bx_intercom_option_app_id', '', @iCategId, '_bx_intercom_option_app_id', 'digit', '', '', 10, ''),
+('bx_intercom_option_api_key', '', @iCategId, '_bx_intercom_option_api_key', 'digit', '', '', 20, '');
+
+-- Injections
+
+INSERT INTO `sys_injections` (`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES
+('bx_intercom', 0, 'injection_footer', 'service', 'a:2:{s:6:"module";s:11:"bx_intercom";s:6:"method";s:16:"integration_code";}', 0, 1);
+
+-- Alerts
+
+INSERT INTO `sys_alerts_handlers` SET `name` = 'bx_intercom', `class` = 'BxIntercomAlerts', `file` = 'modules/boonex/intercom/classes/BxIntercomAlerts.php';
+
+SET @iHandlerId := (SELECT `id` FROM `sys_alerts_handlers`  WHERE `name` = 'bx_intercom');
+
+INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
+('account', 'delete', @iHandlerId),
+('bx_persons', 'deleted', @iHandlerId),
+('bx_persons', 'edited', @iHandlerId),
+('bx_persons', 'added', @iHandlerId),
+('bx_organizations', 'deleted', @iHandlerId),
+('bx_organizations', 'edited', @iHandlerId),
+('bx_organizations', 'added', @iHandlerId);
+

+ 14 - 0
modules/boonex/intercom/install/sql/install.sql

@@ -0,0 +1,14 @@
+
+-- Studio page and widget
+
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, 'bx_intercom', '_bx_intercom', '_bx_intercom', 'bx_intercom@modules/boonex/intercom/|std-pi.png');
+SET @iPageId = LAST_INSERT_ID();
+
+SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
+SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
+INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
+(@iPageId, 'bx_intercom', '{url_studio}module.php?name=bx_intercom', '', 'bx_intercom@modules/boonex/intercom/|std-wi.png', '_bx_intercom', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
+INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
+(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));
+

+ 7 - 0
modules/boonex/intercom/install/sql/uninstall.sql

@@ -0,0 +1,7 @@
+
+-- Studio page and widget
+
+DELETE FROM `tp`, `tw`, `tpw`
+USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
+WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = 'bx_intercom';
+

+ 20 - 0
modules/boonex/intercom/request.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Intercom Intercom integration module
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+check_logged();
+
+if ( empty($aRequest) || empty($aRequest[0]) ) {
+    BxDolRequest::processAsFile($aModule, $aRequest);
+} else {
+    BxDolRequest::processAsAction($aModule, $aRequest);
+}
+
+/** @} */

BIN
modules/boonex/intercom/template/images/icons/std-mi.png


BIN
modules/boonex/intercom/template/images/icons/std-pi.png


BIN
modules/boonex/intercom/template/images/icons/std-si.png


BIN
modules/boonex/intercom/template/images/icons/std-wi.png