AntonLV 2 лет назад
Родитель
Сommit
fc0f866493

+ 187 - 7
modules/boonex/ads/classes/BxAdsModule.php

@@ -158,12 +158,25 @@ class BxAdsModule extends BxBaseModTextModule
         if(!$iInterestId)
             return echoJson(array('msg' => _t('_bx_ads_txt_err_cannot_perform_action')));
 
-        bx_alert($this->getName(), 'doInterest', $iContentId, $iViewer, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-doInterest 'bx_ads', 'doInterest' - hook after 'interested' action was performed
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `doInterest`
+         * - $object_id - content id
+         * - $sender_id - profile id who performed the action
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `subobject_id` - [int] id of a database table record, created during the action
+         *      - `subobject_author_id` - [int] profile id who performed the action
+         *      - `object_author_id` - [int] content author profile id
+         * @hook @ref hook-bx_ads-doInterest
+         */
+        bx_alert($this->getName(), 'doInterest', $iContentId, $iViewer, [
             'subobject_id' => $iInterestId, 
             'subobject_author_id' => $iViewer, 
 
             'object_author_id' => $iContentAuthor
-        ));
+        ]);
 
         if(getParam($CNF['PARAM_USE_IIN']) == 'on')
             sendMailTemplate($CNF['ETEMPLATE_INTERESTED'], 0, $iContentAuthor, array(
@@ -1171,6 +1184,21 @@ class BxAdsModule extends BxBaseModTextModule
         if(empty($aCommodity) || !is_array($aCommodity))
             return [];
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-order_authorize 'bx_ads', 'order_authorize' - hook after the order was authorized with payment processing module
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `order_authorize`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `id` - [int] commodity id 
+         *      - `type` - [string] commodity type, 'product' or 'promotion'
+         *      - `product_id` - [int] ad (entry) id the commodity is associated with
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `count` - [int] number of items in order
+         * @hook @ref hook-bx_ads-order_authorize
+         */
         bx_alert($this->getName(), 'order_authorize', 0, false, [
             'id' => $aCommodity['id'],
             'type' => $aCommodity['type'],
@@ -1261,6 +1289,23 @@ class BxAdsModule extends BxBaseModTextModule
 
         $this->_oDb->updateEntriesBy($aUpdate, [$CNF['FIELD_ID'] => $iEntryId]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-license_register 'bx_ads', 'license_register' - hook after the payment for an ad was processed with payment processing module
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `license_register`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `id` - [int] commodity id 
+         *      - `type` - [string] commodity type, 'product' or 'promotion'
+         *      - `product_id` - [int] ad (entry) id the commodity is associated with
+         *      - `profile_id` - [int] client (buyer) profile id
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `license` - [string] license number generated for the order
+         *      - `count` - [int] number of items in order
+         * @hook @ref hook-bx_ads-license_register
+         */
         bx_alert($sModule, 'license_register', 0, false, [
             'id' => $aCommodity['id'],
             'type' => $aCommodity['type'],
@@ -1273,6 +1318,21 @@ class BxAdsModule extends BxBaseModTextModule
 
         if($bEntrySold) {
             $aParams = $this->_alertParams($aEntry);
+            
+            /**
+             * @hooks
+             * @hookdef hook-bx_ads-sold 'bx_ads', 'sold' - hook after the payment was processed with payment processing module and there is no the ad (entry) for selling anymore
+             * - $unit_name - equals `bx_ads`
+             * - $action - equals `sold`
+             * - $object_id - ad (entry) id
+             * - $sender_id - not used
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `status` - [string] content status
+             *      - `status_admin` - [string] content admin status
+             *      - `privacy_view` - [int] or [string] privacy for view content action, @see BxDolPrivacy
+             *      - `cf` - [int] content's audience filter value
+             * @hook @ref hook-bx_ads-sold
+             */
             bx_alert($sModule, 'sold', $iEntryId, false, $aParams);
         }
 
@@ -1301,6 +1361,22 @@ class BxAdsModule extends BxBaseModTextModule
         ];
 
         $bCancel = false;
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-license_register_notif 'bx_ads', 'license_register_notif' - hook before sending a notification about new license. Allows to override a notification message or cancel the notification
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `license_register_notif`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `entry_id` - [int] ad (entry) id
+         *      - `order` - [string] order number
+         *      - `recipient_id` - [int] by ref, client (buyer) profile id, can be overridden in hook processing
+         *      - `email_template` - [string] by ref, email template name, can be overridden in hook processing
+         *      - `email_params` - [array] by ref, email params array as key&value pairs, which will be parsed in email subject/body, can be overridden in hook processing
+         *      - `cancel` - [boolean] by ref, if email sending should be canceled or not, can be overridden in hook processing
+         * @hook @ref hook-bx_ads-license_register_notif
+         */
         bx_alert($sModule, 'license_register_notif', 0, false, [
             'entry_id' => $iEntryId,
             'order' => $sOrder,
@@ -1340,6 +1416,23 @@ class BxAdsModule extends BxBaseModTextModule
             $this->_oDb->updateEntriesBy($aUpdate, [$CNF['FIELD_ID'] => $iEntryId]);
         }
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-promotion_register 'bx_ads', 'promotion_register' - hook after the payment for promotion was processed with payment processing module
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `promotion_register`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `id` - [int] commodity id 
+         *      - `type` - [string] commodity type, 'product' or 'promotion'
+         *      - `product_id` - [int] ad (entry) id the commodity is associated with
+         *      - `profile_id` - [int] client (buyer) profile id
+         *      - `amount` - [float] amount paid for the promotion
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `license` - [string] license number generated for the order
+         * @hook @ref hook-bx_ads-promotion_register
+         */
         bx_alert($this->getName(), 'promotion_register', 0, false, [
             'id' => $aCommodity['id'],
             'type' => $aCommodity['type'],
@@ -1505,6 +1598,12 @@ class BxAdsModule extends BxBaseModTextModule
         if(!$this->_oDb->unregisterLicense($iClientId, $iEntryId, $sOrder, $sLicense))
             return false;
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-license_unregister 'bx_ads', 'license_unregister' - hook after the payment for ad was refunded with payment processing module
+         * It's equivalent to @ref hook-bx_ads-license_register
+         * @hook @ref hook-bx_ads-license_unregister
+         */
         bx_alert($this->getName(), 'license_unregister', 0, false, [
             'id' => $aCommodity['id'],
             'type' => $aCommodity['type'],
@@ -1531,6 +1630,12 @@ class BxAdsModule extends BxBaseModTextModule
         if(!$this->_oDb->unregisterPromotion($aEntry[$CNF['FIELD_AUTHOR']], $aCommodity['id'], $iEntryId, $sOrder, $sLicense))
             return false;
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-promotion_unregister 'bx_ads', 'promotion_unregister' - hook after the payment for promotion was refunded with payment processing module
+         * It's equivalent to @ref hook-bx_ads-promotion_register
+         * @hook @ref hook-bx_ads-promotion_unregister
+         */
         bx_alert($this->getName(), 'promotion_unregister', 0, false, [
             'id' => $aCommodity['id'],
             'type' => $aCommodity['type'],
@@ -1846,7 +1951,18 @@ class BxAdsModule extends BxBaseModTextModule
         $bModerator = $this->_isModerator();
 
         $mixedResult = null;
-        bx_alert($this->getName(), 'is_entry_active', 0, 0, ['viewer_id' => $iViewer, 'is_moderator' => $bModerator, 'content_info' => $aContentInfo, 'override_result' => &$mixedResult]);
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-is_entry_active 'bx_ads', 'is_entry_active' - hook to override whether an ad (entry) active or not
+         * It's equivalent to @ref hook-bx_base_general-is_entry_active
+         * @hook @ref hook-bx_ads-is_entry_active
+         */
+        bx_alert($this->getName(), 'is_entry_active', 0, 0, [
+            'viewer_id' => $iViewer, 
+            'is_moderator' => $bModerator, 
+            'content_info' => $aContentInfo, 
+            'override_result' => &$mixedResult
+        ]);
         if($mixedResult !== null)
             return $mixedResult;
 
@@ -2024,6 +2140,23 @@ class BxAdsModule extends BxBaseModTextModule
 
         $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo);
         $aParams['override_result'] = &$aResult;
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-offer_added 'bx_ads', 'offer_added' - hook after an offer was added. Allows to override action results.
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `offer_added`
+         * - $object_id - offer id
+         * - $sender_id - offer author profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `object_id` - [int] content id
+         *      - `object_author_id` - [int] content author profile id
+         *      - `offer_id` - [int] offer id
+         *      - `offer_author_id` - [int] offer author profile id
+         *      - `privacy_view` - [int] privacy for view action, equals to BX_DOL_PG_ALL, @see BxDolPrivacy
+         *      - `override_result` - [array] by ref, results array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_ads-offer_added
+         */
         bx_alert($this->getName(), 'offer_added', $iOfferId, $aOfferInfo[$CNF['FIELD_OFR_AUTHOR']], $aParams);
     }
 
@@ -2061,6 +2194,15 @@ class BxAdsModule extends BxBaseModTextModule
             ));
 
         $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo);
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-offer_accepted 'bx_ads', 'offer_accepted' - hook after an offer was accepted.
+         * It's equivalent to @ref hook-bx_ads-offer_added
+         * except content author profile id is passed to $sender_id and
+         * `override_result` parameter in $extra_params is missing
+         * @hook @ref hook-bx_ads-offer_accepted
+         */
         bx_alert($this->getName(), 'offer_accepted', $iOfferId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
     }
 
@@ -2092,6 +2234,13 @@ class BxAdsModule extends BxBaseModTextModule
             ));
 
         $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo);
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-offer_declined 'bx_ads', 'offer_declined' - hook after an offer was declined.
+         * It's equivalent to @ref hook-bx_ads-offer_accepted
+         * @hook @ref hook-bx_ads-offer_declined
+         */
         bx_alert($this->getName(), 'offer_declined', $iOfferId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
     }
 
@@ -2128,6 +2277,14 @@ class BxAdsModule extends BxBaseModTextModule
             ]);
 
         $aParams = $this->_alertParamsOffer($aContentInfo, $aOfferInfo);
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-offer_canceled 'bx_ads', 'offer_canceled' - hook after an offer was declined.
+         * It's equivalent to @ref hook-bx_ads-offer_added
+         * except `override_result` parameter in $extra_params is missing
+         * @hook @ref hook-bx_ads-offer_canceled
+         */
         bx_alert($this->getName(), 'offer_canceled', $iOfferId, $aOfferInfo[$CNF['FIELD_OFR_AUTHOR']], $aParams);
     }
 
@@ -2165,12 +2322,29 @@ class BxAdsModule extends BxBaseModTextModule
             ));
 
         $aParams = $this->_alertParams($mixedContent);
-        $aParams = array_merge($aParams, array(
+        $aParams = array_merge($aParams, [
             'profile_src' => $iProfileSrc,
             'profile_dst' => $iProfileDst,
             'offer_id' => $bOffer ? (int)$aOffer[$CNF['FIELD_OFR_ID']] : 0,
-        ));
+        ]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-shipped 'bx_ads', 'shipped' - hook after the ad (entry) was marked as shipped
+         * - $unit_name - equals `bx_ads`
+         * - $action - equals `shipped`
+         * - $object_id - ad (entry) id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `status` - [string] content status
+         *      - `status_admin` - [string] content admin status
+         *      - `privacy_view` - [int] or [string] privacy for view content action, @see BxDolPrivacy
+         *      - `cf` - [int] content's audience filter value
+         *      - `profile_src` - [int] sender profile id
+         *      - `profile_dst` - [int] recipient profile id
+         *      - `offer_id` - [int] offer id if the ad was sold by offer
+         * @hook @ref hook-bx_ads-shipped
+         */
         bx_alert($this->getName(), 'shipped', $iContentId, false, $aParams);
     }
 
@@ -2204,12 +2378,18 @@ class BxAdsModule extends BxBaseModTextModule
             ));
 
         $aParams = $this->_alertParams($mixedContent);
-        $aParams = array_merge($aParams, array(
+        $aParams = array_merge($aParams, [
             'profile_src' => $iProfileSrc,
             'profile_dst' => $iProfileDst,
             'offer_id' => $bOffer ? (int)$aOffer[$CNF['FIELD_OFR_ID']] : 0,
-        ));
+        ]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_ads-received 'bx_ads', 'received' - hook after the ad (entry) was marked as received
+         * It's equivalent to @ref hook-bx_ads-shipped
+         * @hook @ref hook-bx_ads-received
+         */
         bx_alert($this->getName(), 'received', $iContentId, false, $aParams);
     }
 

+ 25 - 3
modules/boonex/channels/classes/BxCnlModule.php

@@ -121,15 +121,37 @@ class BxCnlModule extends BxBaseModGroupsModule
             )
         ));
 
-        $aParams = array(
+        $aParams = [
             'object_author_id' => $iAuthorId, 
             'privacy_view' => -$iCnlProfileId, 
             'subobject_id' => $iId,
             'content_module' => $sModuleName,
             'content_id' => $iContentId,
             'content_author_id' => $iAuthorId
-        );
-        bx_alert('system', 'prepare_alert_params', 0, 0, array('unit'=> $this->_aModule['name'], 'action' => 'hashtag_added_notif', 'object_id' => $mixedCnlId, 'sender_id' => $iCnlProfileId, 'extras' => &$aParams));
+        ];
+        /**
+         * @hooks
+         * @hookdef hook-system-prepare_alert_params 'system', 'prepare_alert_params' - hook to override alert (hook) params
+         * - $unit_name - equals `system`
+         * - $action - equals `prepare_alert_params`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `unit` - [string] unit name
+         *      - `action` - [string] equals to 'hashtag_added_notif'
+         *      - `object_id` - [int] object id
+         *      - `sender_id` - [int] action performer profile id
+         *      - `extras` - [array] by ref, extra params array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-system-prepare_alert_params
+         */
+        bx_alert('system', 'prepare_alert_params', 0, 0, [
+            'unit'=> $this->_aModule['name'], 
+            'action' => 'hashtag_added_notif', 
+            'object_id' => $mixedCnlId, 
+            'sender_id' => $iCnlProfileId, 
+            'extras' => &$aParams
+        ]);
+        
         /**
          * @hooks
          * @hookdef hook-bx_channels-hashtag_added_notif 'bx_channels', 'hashtag_added_notif' - hook on after found hashtag in content

+ 152 - 12
modules/boonex/credits/classes/BxCreditsModule.php

@@ -111,6 +111,20 @@ class BxCreditsModule extends BxBaseModGeneralModule
         $this->updateProfileBalance($iBuyerId, $iSellerId, -$fAmount, BX_CREDITS_TRANSFER_TYPE_CHECKOUT, $sOrder, $sInfo, $sData);
         $this->updateProfileBalance($iSellerId, $iBuyerId, $fAmount, BX_CREDITS_TRANSFER_TYPE_CHECKOUT, $sOrder, $sInfo, $sData);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-checkout 'bx_credits', 'checkout' - hook after checkout with creadits was performed
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `checkout`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `seller` - [int] seller profile id
+         *      - `buyer` - [int] buyer profile id
+         *      - `amount` - [float] amount was paid
+         *      - `order` - [string] order number for processed checkout action
+         * @hook @ref hook-bx_credits-checkout
+         */
         bx_alert($this->getName(), 'checkout', 0, false, [
             'seller' => $iSellerId,
             'buyer' => $iBuyerId,
@@ -145,24 +159,40 @@ class BxCreditsModule extends BxBaseModGeneralModule
         $sCustomer = 'bx_cus_' . $sUnique;
         $sSubscription = 'bx_sub_' . $sUnique;
 
-        bx_alert($this->getName(), 'subscribe', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-subscribe 'bx_credits', 'subscribe' - hook after subscription was registered
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `subscribe`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `seller` - [int] seller profile id
+         *      - `buyer` - [int] buyer profile id
+         *      - `amount` - [float] amount was paid
+         *      - `trial` - [boolean] if trial period is available or not
+         *      - `customer` - [string] unique customer id for newly registered subscription
+         *      - `subscription` - [string] unique subscription id
+         * @hook @ref hook-bx_credits-subscribe
+         */
+        bx_alert($this->getName(), 'subscribe', 0, false, [
             'seller' => $iSellerId,
             'buyer' => $iBuyerId,
             'amount' => $fAmount, 
             'trial' => $aData['trial'],
             'customer' => $sCustomer,
             'subscription' => $sSubscription
-        ));
+        ]);
 
-        return echoJson(array(
+        return echoJson([
             'code' => 0,
-            'redirect' => bx_append_url_params($aData['return_data_url'], array(
+            'redirect' => bx_append_url_params($aData['return_data_url'], [
                 'cs' => $sCustomer, 
                 'sb' => $sSubscription,
                 'tr' => $aData['trial'],
                 'c' => $aData['custom']
-            ))
-        ));
+            ])
+        ]);
     }
 
     public function serviceGetSafeServices()
@@ -871,14 +901,30 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!$iHistoryId)
             return false;
 
-        bx_alert($this->getName(), 'update_balance', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-update_balance 'bx_credits', 'update_balance' - hook after profile's credits balance was updated (credits were transferred from one profile to another)
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `update_balance`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `first_pid` - [int] first profile id
+         *      - `second_pid` - [int] second profile id
+         *      - `amount` - [float] amount was transferred
+         *      - `type` - [string] transfer type: purchase, checkout, cancellation, grant, send, withdraw, service
+         *      - `direction` - [string] transfer direction: in or out
+         *      - `order` - [string] unique order number associated with the transfer
+         * @hook @ref hook-bx_credits-update_balance
+         */
+        bx_alert($this->getName(), 'update_balance', 0, false, [
             'first_pid' => $iFirstPid,
             'second_pid' => $iSecondPid,
             'amount' => $fAmountAbs,
             'type' => $sType,
             'direction' => $sDirection,
             'order' => $sOrder,
-        ));
+        ]);
 
         $oSecondProfile = BxDolProfile::getInstanceMagic($iSecondPid);
         sendMailTemplate($CNF['ETEMPLATE_' . strtoupper($sDirection)], 0, $iFirstPid, array(
@@ -907,6 +953,18 @@ class BxCreditsModule extends BxBaseModGeneralModule
             'message' => $sMessage
         ]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-granted 'bx_credits', 'granted' - hook after some amount of credits was granted to a profile
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `granted`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile` - [int] recipient profile id
+         *      - `amount` - [float] amount was granted
+         * @hook @ref hook-bx_credits-granted
+         */
         bx_alert($this->getName(), 'granted', 0, false, [
             'profile' => $iProfileId,
             'amount' => $fAmount,
@@ -951,6 +1009,20 @@ class BxCreditsModule extends BxBaseModGeneralModule
             'message' => $sMessage
         ]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-sent 'bx_credits', 'sent' - hook after some amount of credits was sent from one profile to another
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `sent`
+         * - $object_id - not used
+         * - $sender_id - sender profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `performer` - [int] sender profile id
+         *      - `profile` - [int] recipient profile id
+         *      - `amount` - [float] amount was sent
+         *      - `order` - [string] unique order number associated with 'sent' action
+         * @hook @ref hook-bx_credits-sent
+         */
         bx_alert($this->getName(), 'sent', 0, $iUserId, [
             'performer' => $iUserId,
             'profile' => $iProfileId,
@@ -1010,6 +1082,19 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, [], BX_EMAIL_SYSTEM, 'html', false, [], true))
             return $aResult;
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-withdraw_requested 'bx_credits', 'withdraw_requested' - hook after a profile requested to withdraw some amount of credits from his balance
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `withdraw_requested`
+         * - $object_id - not used
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile` - [int] performer profile id
+         *      - `amount` - [float] amount to withdraw
+         *      - `rate` - [float] withdraw conversion rate
+         * @hook @ref hook-bx_credits-withdraw_requested
+         */
         bx_alert($this->getName(), 'withdraw_requested', 0, $iProfileId, [
             'profile' => $iProfileId,
             'amount' => $fAmount,
@@ -1041,6 +1126,19 @@ class BxCreditsModule extends BxBaseModGeneralModule
             'message' => $sMessage
         ]);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-withdraw_sent 'bx_credits', 'withdraw_sent' - hook after the amount of credits requested to withdraw was sent
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `withdraw_sent`
+         * - $object_id - not used
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile` - [int] performer profile id
+         *      - `amount` - [float] amount to withdraw
+         *      - `rate` - [float] withdraw conversion rate
+         * @hook @ref hook-bx_credits-withdraw_sent
+         */
         bx_alert($this->getName(), 'withdraw_sent', 0, $iUserId, [
             'performer' => $iUserId,
             'profile' => $iProfileId,
@@ -1100,7 +1198,32 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!$this->updateProfileBalance($iClientId, 0, $fAmount, BX_CREDITS_TRANSFER_TYPE_PURCHASE, '', $sInfo))
             return array();
 
-        bx_alert($this->getName(), 'order_' . $sAction, 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-order_register 'bx_credits', 'order_register' - hook after the payment for a bundle of credits was processed with payment processing module
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `order_register`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile_id` - [int] client (buyer) profile id
+         *      - `bundle_id` - [int] bundle id
+         *      - `product_id` - [int] bundle id
+         *      - `count` - [int] number of items in order
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `license` - [string] license number provided with payment processing module
+         *      - `type` - [string] payment type ('single' or 'recurring'), current version supports 'single' type payments for bundles only
+         *      - `duration` - [string] isn't supported
+         *      - `trial` - [string] isn't supported
+         * @hook @ref hook-bx_credits-order_register
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-order_prolong 'bx_credits', 'order_prolong' - hook isn't currently used because 'single' type payments for bundles are only supported
+         * It's equivalent to @ref hook-bx_credits-order_register
+         * @hook @ref hook-bx_credits-order_prolong
+         */
+        bx_alert($this->getName(), 'order_' . $sAction, 0, false, [
             'profile_id' => $iClientId,
             'bundle_id' => $iItemId,
             'product_id' => $iItemId,   //--- Alias for 'bundle_id'
@@ -1110,7 +1233,7 @@ class BxCreditsModule extends BxBaseModGeneralModule
             'type' => $sType,
             'duration' => $sDuration,
             'trial' => $iTrial
-        ));
+        ]);
 
         $oClient = BxDolProfile::getInstanceMagic($iClientId);
         $oSeller = BxDolProfile::getInstanceMagic($iSellerId);
@@ -1148,7 +1271,24 @@ class BxCreditsModule extends BxBaseModGeneralModule
         if(!empty($aProfile) && is_array($aProfile))
             $this->_oDb->updateProfile(array('balance' => (float)$aProfile['balance'] - $fAmount), array('id' => $aProfile['id']));
 
-        bx_alert($this->getName(), 'order_unregister', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_credits-order_unregister 'bx_credits', 'order_unregister' - hook after the payment for a bundle of credits was refunded with payment processing module
+         * - $unit_name - equals `bx_credits`
+         * - $action - equals `order_unregister`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile_id` - [int] client (buyer) profile id
+         *      - `bundle_id` - [int] bundle id
+         *      - `product_id` - [int] bundle id
+         *      - `count` - [int] number of items in order
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `license` - [string] license number provided with payment processing module
+         *      - `type` - [string] payment type ('single' or 'recurring'), current version supports 'single' type payments for bundles only
+         * @hook @ref hook-bx_credits-order_unregister
+         */
+        bx_alert($this->getName(), 'order_unregister', 0, false, [
             'profile_id' => $iClientId,
             'bundle_id' => $iItemId,
             'product_id' => $iItemId,   //--- Alias for 'bundle_id'
@@ -1156,7 +1296,7 @@ class BxCreditsModule extends BxBaseModGeneralModule
             'order' => $sOrder,
             'license' => $sLicense,
             'type' => $sType,
-        ));
+        ]);
 
         return true;
     }

+ 27 - 4
modules/boonex/donations/classes/BxDonationsModule.php

@@ -244,14 +244,30 @@ class BxDonationsModule extends BxBaseModGeneralModule
         if(!$this->_oDb->registerEntry($iClientId, $iItemId, $iItemCount, $sOrder, $sLicense))
             return array();
 
-        bx_alert($this->getName(), 'donation_register', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_donations-donation_register 'bx_donations', 'donation_register' - hook after the donation payment was processed with payment processing module
+         * - $unit_name - equals `bx_donations`
+         * - $action - equals `donation_register`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `donation_id` - [int] donation id
+         *      - `profile_id` - [int] donator profile id
+         *      - `order` - [string] order number provided with payment processing module
+         *      - `type` - [string] payment type ('single' or 'recurring')
+         *      - `amount` - [float] donated amount
+         *      - `count` - [int] number of items in order
+         * @hook @ref hook-bx_donations-donation_register
+         */
+        bx_alert($this->getName(), 'donation_register', 0, false, [
             'donation_id' => $iItemId,
             'profile_id' => $iClientId,
             'order' => $sOrder,
             'type' => $sType,
             'amount' => (float)$aItem['price_' . $sType],
             'count' => $iItemCount
-        ));
+        ]);
 
         $oClient = BxDolProfile::getInstanceMagic($iClientId);
         sendMailTemplate($CNF['ETEMPLATE_DONATED'], 0, $iClientId, array(
@@ -266,13 +282,20 @@ class BxDonationsModule extends BxBaseModGeneralModule
     	if(!$this->_oDb->unregisterEntry($iClientId, $iItemId, $sOrder, $sLicense))
             return false;
 
-        bx_alert($this->getName(), 'donation_unregister', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_donations-donation_unregister 'bx_donations', 'donation_unregister' - hook after the donation payment was refunded with payment processing module
+         * It's equivalent to @ref hook-bx_donations-donation_register
+         * except `amount` parameter in $extra_params is missing
+         * @hook @ref hook-bx_donations-donation_unregister
+         */
+        bx_alert($this->getName(), 'donation_unregister', 0, false, [
             'donation_id' => $iItemId,
             'profile_id' => $iClientId,
             'order' => $sOrder,
             'type' => $sType,
             'count' => $iItemCount
-        ));
+        ]);
 
     	return true;
     }

+ 16 - 2
modules/boonex/donations/classes/BxDonationsTemplate.php

@@ -150,11 +150,25 @@ class BxDonationsTemplate extends BxBaseModGeneralTemplate
         );
 
         $sResult = null;
-        bx_alert($this->_oConfig->getName(), 'donate', 0, 0, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_donations-donate 'bx_donations', 'donate' - hook to override the content of donate block
+         * - $unit_name - equals `bx_donations`
+         * - $action - equals `donate`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `tmpl_name` - [string] by ref, template name, can be overridden in hook processing
+         *      - `tmpl_vars` - [array] by ref, template parsable variables as key&value pairs, can be overridden in hook processing
+         *      - `override_result` - [string] by ref, string with HTML code to be output, if null the default template parsing function will be used, can be overridden in hook processing
+         * @hook @ref hook-bx_donations-donate
+         */
+        bx_alert($this->_oConfig->getName(), 'donate', 0, 0, [
             'tmpl_name' => &$sTmplName,
             'tmpl_vars' => &$aTmplVars,
             'override_result' => &$sResult
-        ));
+        ]);
         if($sResult !== null)
             return $sResult;
 

+ 59 - 1
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -70,6 +70,17 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 
     public function getEvents($aParams, $bReturnCount = false)
     {
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-get_events_before 'bx_notifications', 'get_events_before' - hook to override params which are used to get events
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `get_events_before`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `params` - [array] by ref, params array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-get_events_before
+         */
         bx_alert($this->_oConfig->getName(), 'get_events_before', 0, 0, [
             'params' => &$aParams,
         ]);
@@ -133,6 +144,31 @@ class BxNtfsDb extends BxBaseModNotificationsDb
          * PO - notifications related to Owner's content
          * PC - notifications related to Connections' content
          */
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-get_events 'bx_notifications', 'get_events' - hook to override events list which will be received from database
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `get_events`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `browse` - [string] browsing type
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `table` - [string] datatbase table name
+         *      - `method` - [string] by ref, database class method name, @see BxDolDb, can be overridden in hook processing
+         *      - `select_clause` - [string] by ref, 'select' part of SQL query, can be overridden in hook processing
+         *      - `join_clause_po` - [string] by ref, 'join' part of Owner's SQL query, can be overridden in hook processing
+         *      - `join_clause_pc` - [string] by ref, 'join' part of Connections' SQL query, can be overridden in hook processing
+         *      - `where_clause_po` - [string] by ref, 'where' part of Owner's SQL query, can be overridden in hook processing
+         *      - `where_clause_pc` - [string] by ref, 'where' part of Connections' SQL query, can be overridden in hook processing
+         *      - `order_clause_po` - [string] by ref, 'order' part of Owner's SQL query, can be overridden in hook processing
+         *      - `order_clause_pc` - [string] by ref, 'order' part of Connections' SQL query, can be overridden in hook processing
+         *      - `order_clause` - [string] by ref, 'order' part of SQL query, can be overridden in hook processing
+         *      - `limit_clause` - [string] by ref, 'limit' part of SQL query, can be overridden in hook processing
+         *      - `query_po` - [string] by ref, Owner's SQL query, can be overridden in hook processing
+         *      - `query_pc` - [string] by ref, Connections' SQL query, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-get_events
+         */
         bx_alert($this->_oConfig->getName(), 'get_events', 0, 0, [
             'browse' => $aParams['browse'],
             'params' => $aAlertParams,
@@ -261,7 +297,7 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 
                     $sWhereClauseType = '';
                     if(!empty($aQueryParts['fields']['added']))
-                        $sWhereClauseType = "AND `{$this->_sTable}`.`date` > " . $aQueryParts['fields']['added'];
+                        $sWhereClauseType = "AND `{$this->_sTable}`.`date` >= " . $aQueryParts['fields']['added'];
 
                     list($aModulesProfiles, $aModulesContexts) = $this->_oConfig->getProfileBasedModules();
                     $sJoinClause .= $this->prepareAsString(" INNER JOIN `{$this->_sTableSettings}` ON `{$this->_sTableHandlers}`.`id`=`{$this->_sTableSettings}`.`handler_id` AND `{$this->_sTableSettings}`.`delivery`='" . BX_BASE_MOD_NTFS_DTYPE_SITE . "' AND `{$this->_sTableSettings}`.`active`='1' AND ((`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesProfiles) . ")) || (`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesContexts) . ")))", BX_NTFS_STYPE_FOLLOW_MEMBER, BX_NTFS_STYPE_FOLLOW_CONTEXT);
@@ -317,6 +353,28 @@ class BxNtfsDb extends BxBaseModNotificationsDb
         $aAlertParams = $aParams;
         unset($aAlertParams['type'], $aAlertParams['owner_id']);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-get_list_by_type 'bx_notifications', 'get_list_by_type' - hook to override SQL query parts which are used to get events list
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `get_list_by_type`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] a type of events list
+         *      - `owner_id` - [int] owner profile id
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `table` - [string] datatbase table name
+         *      - `join_clause` - [string] by ref, 'join' part of SQL query, can be overridden in hook processing
+         *      - `where_clause` - [string] by ref, 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_start_from` - [string] by ref, 'start_from' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_status` - [string] by ref, 'status' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_modules` - [string] by ref, 'modules' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_new` - [string] by ref, 'new' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_settings` - [string] by ref, 'settings' conditions in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_type` - [string] by ref, 'type' condition in 'where' part of SQL query, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-get_list_by_type
+         */
         bx_alert($this->_oConfig->getName(), 'get_list_by_type', 0, 0, [
             'type' => $aParams['type'],
             'owner_id' => $aParams['owner_id'],

+ 60 - 6
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -434,10 +434,24 @@ class BxNtfsModule extends BxBaseModNotificationsModule
                 continue;
 
             $bEventCanceled = false;
+            
+            /**
+             * @hooks
+             * @hookdef hook-bx_notifications-is_notification 'bx_notifications', 'is_notification' - hook to override checking if an event is available or not
+             * - $unit_name - equals `bx_notifications`
+             * - $action - equals `is_notification`
+             * - $object_id - not used
+             * - $sender_id - not used
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `browse_params` - [array] browse params array as key&value pairs
+             *      - `event` - [array] by ref, array with event data as key&value pairs, can be overridden in hook processing
+             *      - `event_canceled` - [boolean] by ref, if event is canceled (not available) or not, can be overridden in hook processing
+             * @hook @ref hook-bx_notifications-is_notification
+             */
             bx_alert($sModule, 'is_notification', 0, 0, [
+                'browse_params' => $aBrowseParams,
                 'event' => &$aEvent, 
-                'event_canceled' => &$bEventCanceled,
-                'browse_params' => $aBrowseParams
+                'event_canceled' => &$bEventCanceled
             ]);
 
             if($bEventCanceled)
@@ -609,7 +623,28 @@ class BxNtfsModule extends BxBaseModNotificationsModule
             $aTemplateMarkers = array_merge($aTemplateMarkers, $aSettings['markers']);              
 
         $aTemplate = null;
-        bx_alert($this->_aModule['name'], 'before_parse_email_template', 0, 0, array('profile_id' => $iProfile, 'template' => $sTemplate, 'markers' => $aTemplateMarkers, 'notification' => $aNotification, 'override_result' => &$aTemplate));
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-before_parse_email_template 'bx_notifications', 'before_parse_email_template' - hook to override email template
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `before_parse_email_template`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile_id` - [int] recipient profile id
+         *      - `template` - [string] email template name
+         *      - `markers` - [array] parsable variables array as key&value pairs
+         *      - `notification` - [array] notification data array as key&value pairs
+         *      - `override_result` - [array] by ref, email template (subject and body), if null, then default one will be used, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-before_parse_email_template
+         */
+        bx_alert($this->_aModule['name'], 'before_parse_email_template', 0, 0, [
+            'profile_id' => $iProfile, 
+            'template' => $sTemplate, 
+            'markers' => $aTemplateMarkers, 
+            'notification' => $aNotification, 
+            'override_result' => &$aTemplate
+        ]);
         if(is_null($aTemplate))
             $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate($sTemplate, $aTemplateMarkers, 0, $iProfile);
         if(!$aTemplate)
@@ -627,11 +662,30 @@ class BxNtfsModule extends BxBaseModNotificationsModule
 
         $aContent = &$aNotification['content'];
         $aSettings = &$aNotification['settings'];
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-before_send_notification_push 'bx_notifications', 'before_send_notification_push' - hook to override push message
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `before_send_notification_push`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `profile_id` - [int] recipient profile id
+         *      - `content` - [array] by ref, push message params array as key&value pairs, can be overridden in hook processing
+         *      - `setting` - [array] by ref, push settings array as key&value pairs, can be overridden in hook processing
+         *      - `subject` - [string] by ref, push message subject, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-before_send_notification_push
+         */
+        bx_alert($this->_aModule['name'], 'before_send_notification_push', 0, 0, [
+            'profile_id' => $iProfile, 
+            'content' => &$aContent, 
+            'setting' => &$aSettings, 
+            'subject' => &$sSubject
+        ]);
 
         $sSubject = !empty($aSettings['subject']) ? $aSettings['subject'] : _t('_bx_ntfs_push_new_event_subject', getParam('site_title'));
-        
-        bx_alert($this->_aModule['name'], 'before_send_notification_push', 0, 0, array('profile_id' => $iProfile, 'content' => &$aContent, 'setting' => &$aSettings, 'subject' => &$sSubject));
-   
+
         return BxDolPush::getInstance()->send($iProfile, array(
             'contents' => array(
                 'en' => $aContent['message']

+ 15 - 2
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -25,11 +25,24 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
      */
     public function response($oAlert)
     {
-        bx_alert($this->_oModule->getName(), 'before_register_alert', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-before_register_alert 'bx_notifications', 'before_register_alert' - hook to override alert (hook) before processing
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `before_register_alert`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `unit` - [string] alert (hook) unit
+         *      - `action` - [string] alert (hook) action
+         *      - `alert` - [array] by ref, an instance of alert (hook), @see BxDolAlerts, can be overridden in hook processing        
+         * @hook @ref hook-bx_notifications-before_register_alert
+         */
+        bx_alert($this->_oModule->getName(), 'before_register_alert', 0, 0, [
             'unit' => $oAlert->sUnit,
             'action' => $oAlert->sAction,
             'alert' => &$oAlert,
-        ));
+        ]);
 
     	$iObjectPrivacyView = $this->_getObjectPrivacyView($oAlert->aExtras);
         if($iObjectPrivacyView == BX_DOL_PG_HIDDEN)

+ 33 - 4
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -220,13 +220,30 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
 
         $bEventParsed = false;
         $bEventCanceled = false;
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-get_notification 'bx_notifications', 'get_notification' - hook to override notification or even cancel it
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `get_notification`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `browse_params` - [array] browse params array as key&value pairs
+         *      - `event` - [array] by ref, event data array, can be overridden in hook processing        
+         *      - `event_parsed` - [boolean] by ref, if event was already parsed (ready to display), can be overridden in hook processing
+         *      - `event_canceled` - [boolean] by ref, if event was canceled, can be overridden in hook processing
+         *      - `owner` - [object] by ref, an instance of owner profile, @see BxDolProfile, can be overridden in hook processing
+         *      - `owner_unit` - [string] by ref, profile unit HTML code, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-get_notification
+         */
         bx_alert($this->_oConfig->getName(), 'get_notification', 0, 0, [
+            'browse_params' => $aBrowseParams,
             'event' => &$aEvent, 
             'event_parsed' => &$bEventParsed, 
             'event_canceled' => &$bEventCanceled,
             'owner' => &$oOwner, 
-            'owner_unit' => &$sOwnerUnit, 
-            'browse_params' => $aBrowseParams
+            'owner_unit' => &$sOwnerUnit
         ]);
         
         if ($bEventCanceled)
@@ -379,10 +396,22 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
         if(empty($aContent) || !is_array($aContent)) 
             return;
 
-        bx_alert($this->_oConfig->getName(), 'get_content', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_notifications-get_content 'bx_notifications', 'get_content' - hook to override notification content
+         * - $unit_name - equals `bx_notifications`
+         * - $action - equals `get_content`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `event` - [array] by ref, event data array, can be overridden in hook processing        
+         *      - `override_result` - [array] by ref, event content array, can be overridden in hook processing
+         * @hook @ref hook-bx_notifications-get_content
+         */
+        bx_alert($this->_oConfig->getName(), 'get_content', 0, 0, [
             'event' => $aEvent,
             'override_result' => &$aContent
-        ));
+        ]);
 
         $aSet = array();
         if(!empty($aContent['entry_author'])) {

+ 20 - 2
modules/boonex/payment/classes/BxPaymentProviderChargebee.php

@@ -421,10 +421,28 @@ class BxPaymentProviderChargebee extends BxBaseModPaymentProvider implements iBx
 
     public function onDeleteSubscription($sSubscriptionId, $aSubscription)
     {
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_cancel_subscription', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-chargebee_cancel_subscription 'bx_payment', 'chargebee_cancel_subscription' - hook after a subscription was canceled
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `chargebee_cancel_subscription`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `subscription_id` - [string] unique subscription id
+         *      - `subscription_info` - [array] subscription info
+         * @hook @ref hook-bx_payment-chargebee_cancel_subscription
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-chargebee_v3_cancel_subscription 'bx_payment', 'chargebee_v3_cancel_subscription' - hook after a subscription was canceled
+         * It's equivalent to @ref hook-bx_payment-chargebee_cancel_subscription
+         * @hook @ref hook-bx_payment-chargebee_v3_cancel_subscription
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_cancel_subscription', 0, false, [
             'subscription_id' => $sSubscriptionId,
             'subscription_info' => $aSubscription
-        ));
+        ]);
     }
 
 

+ 30 - 4
modules/boonex/payment/classes/BxPaymentProviderChargebeeV3.php

@@ -294,10 +294,22 @@ class BxPaymentProviderChargebeeV3 extends BxPaymentProviderChargebee
     public function getJsCode($aParams = array())
     {
     	$sSite = '';
-    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_js_code', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-chargebee_v3_get_js_code 'bx_payment', 'chargebee_v3_get_js_code' - hook to override JavaScript code
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `chargebee_v3_get_js_code`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `site` - [string] by ref, site name from ChargeBee account, can be overridden in hook processing
+         *      - `params` - [array] by ref, params array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-chargebee_v3_get_js_code
+         */
+    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_js_code', 0, 0, [
             'site' => &$sSite,
             'params' => &$aParams
-    	));
+    	]);
 
     	return $this->_oModule->_oTemplate->getJsCode($this->_sName, array_merge(array(
             'sProvider' => $this->_sName,
@@ -368,11 +380,25 @@ class BxPaymentProviderChargebeeV3 extends BxPaymentProviderChargebee
     protected function _getButtonJs($sType, $iClientId, $iVendorId, $aParams = array())
     {
         $sSite = '';
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-chargebee_v3_get_button 'bx_payment', 'chargebee_v3_get_button' - hook to override checkout/subscibe button
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `chargebee_v3_get_button`
+         * - $object_id - not used
+         * - $sender_id - client (buyer) profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] by ref, payment type ('single' or 'recurring'), can be overridden in hook processing
+         *      - `site` - [string] by ref, site name from ChargeBee account, can be overridden in hook processing
+         *      - `params` - [array] by ref, params array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-chargebee_v3_get_button
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, [
             'type' => &$sType, 
             'site' => &$sSite,
             'params' => &$aParams
-        ));
+        ]);
 
         $sJsMethod = '';
         $sJsObject = $this->getJsObject($aParams);

+ 14 - 2
modules/boonex/payment/classes/BxPaymentProviderCredits.php

@@ -165,10 +165,22 @@ class BxPaymentProviderCredits extends BxBaseModPaymentProvider implements iBxBa
 
     public function cancelRecurring($iPendingId, $sCustomerId, $sSubscriptionId)
     {
-        bx_alert($this->MODULE, $this->_sName . '_cancel_subscription', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-credits_cancel_subscription 'bx_payment', 'credits_cancel_subscription' - hook after a subscription was canceled
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `credits_cancel_subscription`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `pending_id` - [string] pending transaction id
+         *      - `subscription_id` - [string] unique subscription id
+         * @hook @ref hook-bx_payment-credits_cancel_subscription
+         */
+        bx_alert($this->MODULE, $this->_sName . '_cancel_subscription', 0, false, [
             'pending_id' => $iPendingId,
             'subscription_id' => $sSubscriptionId,
-        ));
+        ]);
 
         return true;
     }

+ 116 - 12
modules/boonex/payment/classes/BxPaymentProviderStripe.php

@@ -163,14 +163,30 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
     {
         $sCode = $this->_getVerificationCodeCharge($iVendorId, $iCustomerId, $fAmount, $sCurrency);
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_charge', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_get_code_charge 'bx_payment', 'stripe_get_code_charge' - hook to override verification code for 'charge' action
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_get_code_charge`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `provider` - [object] an instance of provider, @see BxBaseModPaymentProvider
+         *      - `vendor_id` - [int] vendor (seller) profile id
+         *      - `customer_id` - [int] customer (buyer) profile id
+         *      - `amount` - [float] charge amount
+         *      - `currency` - [string] charge currency code
+         *      - `override_result` - [string] by ref, verification code, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_get_code_charge
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_charge', 0, false, [
             'provider' => $this,
             'vendor_id' => $iVendorId, 
             'customer_id' => $iCustomerId,
             'amount' => $fAmount,
             'currency' => $sCurrency,
             'override_result' => &$sCode
-        ));
+        ]);
 
         return $sCode;
     }
@@ -179,6 +195,21 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
     {
         $bCheckResult = $this->_checkVerificationCodeCharge($iVendorId, $iCustomerId, $aResult);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_verify_charge 'bx_payment', 'stripe_verify_charge' - hook to override code verification for 'charge' action
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_verify_charge`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `provider` - [object] an instance of provider, @see BxBaseModPaymentProvider
+         *      - `vendor_id` - [int] vendor (seller) profile id
+         *      - `customer_id` - [int] customer (buyer) profile id
+         *      - `result` - [array] results array received from payment provider
+         *      - `override_result` - [boolean] by ref, is verification passed or not, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_verify_charge
+         */
         bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_verify_charge', 0, false, array(
             'provider' => $this,
             'vendor_id' => $iVendorId, 
@@ -194,14 +225,30 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
     {
         $sCode = $this->_getVerificationCodeSubscription($iVendorId, $iCustomerId, $sSubscription, $sCurrency);
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_subscription', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_get_code_subscription 'bx_payment', 'stripe_get_code_subscription' - hook to override verification code for 'subscribe' action
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_get_code_subscription`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `provider` - [object] an instance of provider, @see BxBaseModPaymentProvider
+         *      - `vendor_id` - [int] vendor (seller) profile id
+         *      - `customer_id` - [int] customer (buyer) profile id
+         *      - `subscription` - [string] unique subscription id
+         *      - `currency` - [string] charge currency code
+         *      - `override_result` - [string] by ref, verification code, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_get_code_subscription
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_subscription', 0, false, [
             'provider' => $this,
             'vendor_id' => $iVendorId, 
             'customer_id' => $iCustomerId,
             'subscription' => $sSubscription,
             'currency' => $sCurrency,
             'override_result' => &$sCode
-        ));
+        ]);
 
         return $sCode;
     }
@@ -210,6 +257,12 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
     {
         $bCheckResult = $this->_checkVerificationCodeSubscription($iVendorId, $iCustomerId, $aResult);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_verify_subscription 'bx_payment', 'stripe_verify_subscription' - hook to override code verification for 'subscribe' action
+         * It's equivalent to @ref hook-bx_payment-stripe_verify_charge
+         * @hook @ref hook-bx_payment-stripe_verify_subscription
+         */
         bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_verify_subscription', 0, false, array(
             'provider' => $this,
             'vendor_id' => $iVendorId, 
@@ -241,11 +294,24 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
             'email' => !empty($aClient['email']) ? $aClient['email'] : ''
         );
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_customer', 0, $aClient['id'], array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_create_customer 'bx_payment', 'stripe_create_customer' - hook to override customer data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_create_customer`
+         * - $object_id - not used
+         * - $sender_id - client (buyer) profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] payment type: single or recurring
+         *      - `customer_object` - [object] by ref, an instance of customer, redurned by payment provider, can be overridden in hook processing
+         *      - `customer_params` - [array] by ref, array with customer parameters, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_create_customer
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_customer', 0, $aClient['id'], [
             'type' => $sType,
             'customer_object' => &$oCustomer, 
             'customer_params' => &$aCustomer
-        ));
+        ]);
 
         try {
             $this->_oCustomer = !empty($oCustomer) ? $oCustomer : \Stripe\Customer::create($aCustomer);
@@ -281,10 +347,22 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
             )
         );
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_charge', $iPendingId, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_create_charge 'bx_payment', 'stripe_create_charge' - hook to override charge data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_create_charge`
+         * - $object_id - pending transaction id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `charge_object` - [object] by ref, an instance of charge, redurned by payment provider, can be overridden in hook processing
+         *      - `charge_params` - [array] by ref, array with charge parameters, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_create_charge
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_charge', $iPendingId, false, [
             'charge_object' => &$oCharge, 
             'charge_params' => &$aCharge
-        ));
+        ]);
 
         try {
             if(empty($oCharge))
@@ -336,11 +414,24 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
             )
         );
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_subscription', $iPendingId, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_create_subscription 'bx_payment', 'stripe_create_subscription' - hook to override subscription data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_create_subscription`
+         * - $object_id - pending transaction id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `customer` - [object] by ref, an instance of customer, can be overridden in hook processing
+         *      - `subscription_object` - [object] by ref, an instance of subscription, redurned by payment provider, can be overridden in hook processing
+         *      - `subscription_params` - [array] by ref, array with subscription parameters, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_create_subscription
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_subscription', $iPendingId, false, [
             'customer' => &$this->_oCustomer,
             'subscription_object' => &$oSubscription, 
             'subscription_params' => &$aSubscription
-        ));
+        ]);
 
         try {
             if(empty($oSubscription))
@@ -410,10 +501,23 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
             $sClientEmail = $oClient->getAccountObject()->getEmail();
 
         $sPublicKey = '';
-    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_get_button 'bx_payment', 'stripe_get_button' - hook to override checkout/subscibe button
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_get_button`
+         * - $object_id - not used
+         * - $sender_id - client (buyer) profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] by ref, payment type ('single' or 'recurring'), can be overridden in hook processing
+         *      - `public_key` - [string] by ref, Stripe public key, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_get_button
+         */
+    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, [
             'type' => &$sType, 
             'public_key' => &$sPublicKey
-        ));
+        ]);
 
         $sJsMethod = '';
         $sJsObject = $this->getJsObject($aParams);

+ 79 - 8
modules/boonex/payment/classes/BxPaymentProviderStripeBasic.php

@@ -356,11 +356,25 @@ class BxPaymentProviderStripeBasic extends BxBaseModPaymentProvider
     protected function _retrieveCustomer($sType, $sId)
     {
         $oCustomer = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_customer', 0, false, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_retrieve_customer 'bx_payment', 'stripe_retrieve_customer' - hook to override customer data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_retrieve_customer`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] payment type: single or recurring
+         *      - `customer_id` - [string] by ref, unique customer id, can be overridden in hook processing
+         *      - `customer_object` - [object] by ref, an instance of customer, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_retrieve_customer
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_customer', 0, false, [
             'type' => $sType,
             'customer_id' => &$sId,
             'customer_object' => &$oCustomer
-        ));
+        ]);
 
         try {
             if(empty($oCustomer))
@@ -376,10 +390,30 @@ class BxPaymentProviderStripeBasic extends BxBaseModPaymentProvider
     protected function _retrieveCharge($sId)
     {
         $oCharge = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_charge', 0, false, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_retrieve_charge 'bx_payment', 'stripe_retrieve_charge' - hook to override charge data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_retrieve_charge`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] payment type: single or recurring
+         *      - `charge_id` - [string] by ref, unique charge id, can be overridden in hook processing
+         *      - `charge_object` - [object] by ref, an instance of charge, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_retrieve_charge
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_charge 'bx_payment', 'stripe_v3_retrieve_charge' - hook to override charge data retrieved from payment provider
+         * It's equivalent to @ref hook-bx_payment-stripe_retrieve_charge
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_charge
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_charge', 0, false, [
             'charge_id' => &$sId,
             'charge_object' => &$oCharge
-        ));
+        ]);
 
         try {
             if(empty($oCharge))
@@ -415,10 +449,28 @@ class BxPaymentProviderStripeBasic extends BxBaseModPaymentProvider
                 return $this->_processException('Cancel Subscription Error: ', $oException);
         }
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_cancel_subscription', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_cancel_subscription 'bx_payment', 'stripe_cancel_subscription' - hook after a subscription was canceled
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_cancel_subscription`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `subscription_id` - [string] unique subscription id
+         *      - `subscription_object` - [object] an instance of subscription, redurned by payment provider
+         * @hook @ref hook-bx_payment-stripe_cancel_subscription
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_cancel_subscription 'bx_payment', 'stripe_v3_cancel_subscription' - hook after a subscription was canceled
+         * It's equivalent to @ref hook-bx_payment-stripe_cancel_subscription
+         * @hook @ref hook-bx_payment-stripe_v3_cancel_subscription
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_cancel_subscription', 0, false, [
             'subscription_id' => $sSubscriptionId,
             'subscription_object' => &$oSubscription
-        ));
+        ]);
 
         return $oSubscription;
     }
@@ -431,10 +483,29 @@ class BxPaymentProviderStripeBasic extends BxBaseModPaymentProvider
     protected function _retrieveProduct($sId)
     {
         $oProduct = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_product', 0, false, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_retrieve_product 'bx_payment', 'stripe_retrieve_product' - hook to override product data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_retrieve_product`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `product_id` - [string] by ref, unique product id, can be overridden in hook processing
+         *      - `product_object` - [object] by ref, an instance of product, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_retrieve_product
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_product 'bx_payment', 'stripe_v3_retrieve_product' - hook to override product data retrieved from payment provider
+         * It's equivalent to @ref hook-bx_payment-stripe_retrieve_product
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_product
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_product', 0, false, [
             'product_id' => &$sId,
             'product_object' => &$oProduct
-        ));
+        ]);
 
         if(!empty($oProduct))
             return $oProduct;

+ 178 - 25
modules/boonex/payment/classes/BxPaymentProviderStripeV3.php

@@ -439,10 +439,22 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
             'inclusive' => $bInclusive,
         ];
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_tax', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_create_tax 'bx_payment', 'stripe_v3_create_tax' - hook to override tax data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_create_tax`
+         * - $object_id - pending transaction id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `tax_object` - [object] by ref, an instance of tax, redurned by payment provider, can be overridden in hook processing
+         *      - `tax_params` - [array] by ref, array with tax parameters, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_create_tax
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_tax', 0, false, [
             'tax_object' => &$oTax, 
             'tax_params' => &$aTax
-        ));
+        ]);
 
         try {
             if(empty($oTax))
@@ -462,10 +474,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     public function retrieveTax($sId)
     {
         $oTax = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_tax', 0, false, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_tax 'bx_payment', 'stripe_v3_retrieve_tax' - hook to override tax data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_retrieve_tax`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `tax_id` - [string] by ref, unique tax id, can be overridden in hook processing
+         *      - `tax_object` - [object] by ref, an instance of tax, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_tax
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_tax', 0, false, [
             'tax_id' => &$sId,
             'tax_object' => &$oTax
-        ));
+        ]);
 
         try {
             if(empty($oTax))
@@ -482,14 +507,30 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     {
         $sCode = $this->_getVerificationCodeSession($iVendorId, $iCustomerId, $fAmount, $sCurrency);
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_session', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_get_code_session 'bx_payment', 'stripe_v3_get_code_session' - hook to override session verification code
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_get_code_session`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `provider` - [object] an instance of provider, @see BxBaseModPaymentProvider
+         *      - `vendor_id` - [int] vendor (seller) profile id
+         *      - `customer_id` - [int] customer (buyer) profile id
+         *      - `amount` - [float] session amount
+         *      - `currency` - [string] session currency code
+         *      - `override_result` - [string] by ref, verification code, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_get_code_session
+         */        
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_code_session', 0, false, [
             'provider' => $this,
             'vendor_id' => $iVendorId, 
             'customer_id' => $iCustomerId,
             'amount' => $fAmount,
             'currency' => $sCurrency,
             'override_result' => &$sCode
-        ));
+        ]);
 
         return $sCode;
     }
@@ -498,13 +539,28 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     {
         $bCheckResult = $this->_checkVerificationCodeSession($iVendorId, $iCustomerId, $aResult);
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_verify_session', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_verify_session 'bx_payment', 'stripe_v3_verify_session' - hook to override checking of session verification code
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_verify_session`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `provider` - [object] an instance of provider, @see BxBaseModPaymentProvider
+         *      - `vendor_id` - [int] vendor (seller) profile id
+         *      - `customer_id` - [int] customer (buyer) profile id
+         *      - `result` - [array] results array received from payment provider
+         *      - `override_result` - [boolean] by ref, is verification passed or not, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_verify_session
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_verify_session', 0, false, [
             'provider' => $this,
             'vendor_id' => $iVendorId, 
             'customer_id' => $iCustomerId,
             'result' => $aResult,
             'override_result' => &$bCheckResult
-        ));
+        ]);
 
         return $bCheckResult;
     }
@@ -523,11 +579,18 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _retrieveCustomer($sType, $sId)
     {
         $oCustomer = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_customer', 0, false, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_customer 'bx_payment', 'stripe_v3_retrieve_customer' - hook to override customer data retrieved from payment provider
+         * It's equivalent to @ref hook-bx_payment-stripe_retrieve_customer
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_customer
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_customer', 0, false, [
             'type' => $sType,
             'customer_id' => &$sId,
             'customer_object' => &$oCustomer
-        ));
+        ]);
 
         try {
             if(empty($oCustomer))
@@ -671,10 +734,22 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
             }
         }
 
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_session', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_create_session 'bx_payment', 'stripe_v3_create_session' - hook to override session data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_create_session`
+         * - $object_id - pending transaction id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `session_object` - [object] by ref, an instance of session, redurned by payment provider, can be overridden in hook processing
+         *      - `session_params` - [array] by ref, array with session parameters, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_create_session
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_session', 0, false, [
             'session_object' => &$oSession, 
             'session_params' => &$aSession
-        ));
+        ]);
 
         try {
             if(empty($oSession))
@@ -735,10 +810,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _retrieveSession($sId)
     {
         $oSession = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_session', 0, false, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_session 'bx_payment', 'stripe_v3_retrieve_session' - hook to override session data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_retrieve_session`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `session_id` - [string] by ref, unique session id, can be overridden in hook processing
+         *      - `session_object` - [object] by ref, an instance of session, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_session
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_session', 0, false, [
             'session_id' => &$sId,
             'session_object' => &$oSession
-        ));
+        ]);
 
         try {
             if(empty($oSession))
@@ -758,10 +846,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _retrieveSetupIntent($sId)
     {
         $oSetupIntent = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_setup_intent', 0, false, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_setup_intent 'bx_payment', 'stripe_v3_retrieve_setup_intent' - hook to override SetupIntent data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_retrieve_setup_intent`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `setup_intent_id` - [string] by ref, unique SetupIntent id, can be overridden in hook processing
+         *      - `setup_intent_object` - [object] by ref, an instance of SetupIntent, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_setup_intent
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_setup_intent', 0, false, [
             'setup_intent_id' => &$sId,
             'setup_intent_object' => &$oSetupIntent
-        ));
+        ]);
 
         try {
             if(empty($oSetupIntent))
@@ -780,10 +881,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _createPaymentIntent($sSetupIntentId, $fAmount, $sCurrency, $bConfirm = true)
     {
         $oPaymentIntent = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_payment_intent', 0, false, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_create_payment_intent 'bx_payment', 'stripe_v3_create_payment_intent' - hook to override PaymentIntent data redurned by payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_create_payment_intent`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `setup_intent_id` - [string] by ref, unique SetupIntent id, can be overridden in hook processing
+         *      - `payment_intent_object` - [object] by ref, an instance of PaymentIntent, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_create_payment_intent
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_create_payment_intent', 0, false, [
             'setup_intent_id' => &$sSetupIntentId,
             'payment_intent_object' => &$oPaymentIntent
-        ));
+        ]);
 
         try {
             if(empty($oPaymentIntent)) {
@@ -817,10 +931,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _retrievePaymentIntent($sId)
     {
         $oPaymentIntent = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_payment_intent', 0, false, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_payment_intent 'bx_payment', 'stripe_v3_retrieve_payment_intent' - hook to override PaymentIntent data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_retrieve_payment_intent`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `payment_intent_id` - [string] by ref, unique PaymentIntent id, can be overridden in hook processing
+         *      - `payment_intent_object` - [object] by ref, an instance of PaymentIntent, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_payment_intent
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_payment_intent', 0, false, [
             'payment_intent_id' => &$sId,
             'payment_intent_object' => &$oPaymentIntent
-        ));
+        ]);
 
         try {
             if(empty($oPaymentIntent))
@@ -839,10 +966,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
     protected function _retrieveSubscription($sCustomerId, $sSubscriptionId)
     {
         $oSubscription = null;
-        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_subscription', 0, false, array(
-            'subscription_id' => &$sId,
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_retrieve_subscription 'bx_payment', 'stripe_v3_retrieve_subscription' - hook to override subscription data retrieved from payment provider
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_retrieve_subscription`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `subscription_id` - [string] by ref, unique subscription id, can be overridden in hook processing
+         *      - `subscription_object` - [object] by ref, an instance of subscription, redurned by payment provider, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_retrieve_subscription
+         */
+        bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_retrieve_subscription', 0, false, [
+            'subscription_id' => &$sSubscriptionId,
             'subscription_object' => &$oSubscription
-        ));
+        ]);
 
         try {
             if(empty($oSubscription))
@@ -938,10 +1078,23 @@ class BxPaymentProviderStripeV3 extends BxPaymentProviderStripeBasic implements
             $sClientEmail = $oClient->getAccountObject()->getEmail();
 
         $sPublicKey = '';
-    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_payment-stripe_v3_get_button 'bx_payment', 'stripe_v3_get_button' - hook to override checkout/subscibe button
+         * - $unit_name - equals `bx_payment`
+         * - $action - equals `stripe_v3_get_button`
+         * - $object_id - not used
+         * - $sender_id - client (buyer) profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] by ref, payment type ('single' or 'recurring'), can be overridden in hook processing
+         *      - `public_key` - [string] by ref, public key from Stripe account, can be overridden in hook processing
+         * @hook @ref hook-bx_payment-stripe_v3_get_button
+         */
+    	bx_alert($this->_oModule->_oConfig->getName(), $this->_sName . '_get_button', 0, $iClientId, [
             'type' => &$sType, 
             'public_key' => &$sPublicKey
-        ));
+        ]);
 
         $sJsMethod = '';
         $sJsObject = $this->getJsObject($aParams);

+ 17 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -737,7 +737,23 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
     public function getCacheTableCheckFields()
     {
         $mixedResult = null;
-        bx_alert($this->getName(), 'cache_table_check_fields', 0, 0, ['check_fields' => $this->_aCacheTableCheckFields, 'override_result' => &$mixedResult]);
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-cache_table_check_fields 'bx_timeline', 'cache_table_check_fields' - hook to override cache table fields, which should be checked
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `cache_table_check_fields`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `check_fields` - [array] an array with fields which are checked by default
+         *      - `override_result` - [array] by ref, new check fields array or null to use the dafault one, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-cache_table_check_fields
+         */
+        bx_alert($this->getName(), 'cache_table_check_fields', 0, 0, [
+            'check_fields' => $this->_aCacheTableCheckFields, 
+            'override_result' => &$mixedResult
+        ]);
         if($mixedResult !== null)
             return $mixedResult;
         

+ 59 - 0
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -633,6 +633,17 @@ class BxTimelineDb extends BxBaseModNotificationsDb
 
     public function getEvents($aParams)
     {
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_events_before 'bx_timeline', 'get_events_before' - hook to override params which are used to get events
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_events_before`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `params` - [array] by ref, params array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_events_before
+         */
         bx_alert($this->_oConfig->getName(), 'get_events_before', 0, 0, [
             'params' => &$aParams,
         ]);
@@ -655,6 +666,26 @@ class BxTimelineDb extends BxBaseModNotificationsDb
         $aAlertParams = $aParams;
         unset($aAlertParams['browse']);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_events 'bx_timeline', 'get_events' - hook to override events list which will be received from database
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_events`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `browse` - [string] browsing type
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `table` - [string] datatbase table name
+         *      - `table_alias` - [string] datatbase table alias
+         *      - `method` - [string] by ref, database class method name, @see BxDolDb, can be overridden in hook processing
+         *      - `select_clause` - [string] by ref, 'select' part of SQL query, can be overridden in hook processing
+         *      - `join_clause` - [string] by ref, 'join' part of SQL query, can be overridden in hook processing
+         *      - `where_clause` - [string] by ref, 'where' part of SQL query, can be overridden in hook processing
+         *      - `order_clause` - [string] by ref, 'order' part of SQL query, can be overridden in hook processing
+         *      - `limit_clause` - [string] by ref, 'limit' part of SQL query, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_events
+         */
         bx_alert($this->_oConfig->getName(), 'get_events', 0, 0, [
             'browse' => $aParams['browse'],
             'params' => $aAlertParams,
@@ -1346,6 +1377,34 @@ class BxTimelineDb extends BxBaseModNotificationsDb
         $aAlertParams = $aParams;
         unset($aAlertParams['type'], $aAlertParams['owner_id']);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_list_by_type 'bx_timeline', 'get_list_by_type' - hook to override SQL query parts which are used to get events list
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_list_by_type`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] a type of events list
+         *      - `owner_id` - [int] owner profile id
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `table` - [string] datatbase table name
+         *      - `table_alias` - [string] datatbase table alias
+         *      - `join_clause` - [string] by ref, 'join' part of SQL query, can be overridden in hook processing
+         *      - `join_subclause` - [string] or [array] by ref, 'join subclause' part of SQL query, string is attached to 'join' part, array is used to create query with UNIONs, can be overridden in hook processing
+         *      - `where_clause` - [string] by ref, 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_status` - [string] by ref, 'status' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_filter` - [string] by ref, 'filter' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_timeline` - [string] by ref, 'timeline' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_modules` - [string] by ref, 'modules' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_hidden` - [string] by ref, 'hidden' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_medias` - [string] by ref, 'medias' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_muted` - [string] by ref, 'muted' conditions in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_unpublished` - [string] by ref, 'unpublished' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_clause_cf` - [string] by ref, 'cf' condition in 'where' part of SQL query, can be overridden in hook processing
+         *      - `where_subclause` - [string] or [array] by ref, 'where subclause' part of SQL query, string is attached to 'where' part, array is used to create query with UNIONs, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_list_by_type
+         */
         bx_alert($this->_oConfig->getName(), 'get_list_by_type', 0, 0, [
             'type' => $aParams['type'],
             'owner_id' => $aParams['owner_id'],

+ 414 - 58
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -279,11 +279,30 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $this->rebuildSlice();
 
-        bx_alert($this->_oConfig->getObject('alert'), $sAction . 'd', $iId, (int)$this->getUserId(), array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-promoted 'bx_timeline', 'promoted' - hook after an event was promoted
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `promoted`
+         * - $object_id - event id
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `owner_id` - [int] owner profile id
+         *      - `object_id` - [int] object id
+         *      - `object_author_id` - [int] object author profile id
+         * @hook @ref hook-bx_timeline-promoted
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-unpromoted 'bx_timeline', 'unpromoted' - hook after an event was unpromoted
+         * It's equivalent to @ref hook-bx_timeline-promoted
+         * @hook @ref hook-bx_timeline-unpromoted
+         */
+        bx_alert($this->_oConfig->getObject('alert'), $sAction . 'd', $iId, (int)$this->getUserId(), [
             'owner_id' => $aEvent['owner_id'],
             'object_id' => $aEvent['object_id'],
             'object_author_id' => $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id']
-        ));
+        ]);
         
         bx_audit(
             $iId, 
@@ -344,11 +363,24 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(!$this->getConnectionMuteObject()->addConnection($this->_iProfileId, $iAuthor))
             return echoJson(array('code' => 2));
 
-        bx_alert($this->_oConfig->getObject('alert'), 'muted', $iAuthor, $this->_iProfileId, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-muted 'bx_timeline', 'muted' - hook after an event author was muted
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `muted`
+         * - $object_id - event author profile id
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `owner_id` - [int] owner profile id
+         *      - `object_id` - [int] object id
+         *      - `object_author_id` - [int] object author profile id
+         * @hook @ref hook-bx_timeline-muted
+         */
+        bx_alert($this->_oConfig->getObject('alert'), 'muted', $iAuthor, $this->_iProfileId, [
             'owner_id' => $aEvent['owner_id'],
             'object_id' => $aEvent['object_id'],
             'object_author_id' => $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id']
-        ));
+        ]);
 
         echoJson(array('code' => 0, 'message' => _t('_bx_timeline_txt_msg_performed_action'), 'reload' => 1));
     }
@@ -585,6 +617,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             'eval' => $sJsObject . "._onGetPost(oData)"
         ];
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-on_get_post 'bx_timeline', 'on_get_post' - hook to override just created direct post (update)
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `on_get_post`
+         * - $object_id - event author profile id
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `override_result` - [array] by ref, result array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-on_get_post
+         */
         bx_alert($this->getName(), 'on_get_post', 0, 0, [
             'params' => $aParams,
             'override_result' => &$aResult,
@@ -1269,6 +1313,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $oForm = $this->getFormPostObject($aParams);
 
+        /**
+         * @hooks
+         * @hookdef hook-system-get_object_form 'system', 'get_object_form' - hook to override an object of create content form, @see BxDolForm
+         * - $unit_name - equals `system`
+         * - $action - equals `get_object_form`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] module name
+         *      - `type` - [string] 'add', 'edit', 'view' or 'delete' form display type
+         *      - `params` - [array] form params array as key&value pairs
+         *      - `form` - [object] by ref, an object of create content form, @see BxDolForm, can be overridden in hook processing
+         * @hook @ref hook-system-get_object_form
+         */
         bx_alert('system', 'get_object_form', 0, 0, array(
             'module' => $this->_oConfig->getName(),
             'type' => $sType,
@@ -4191,7 +4249,27 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         // check alert to allow custom checks
         $mixedResult = null;
-        bx_alert('system', 'check_allowed_view', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
+
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_view 'system', 'check_allowed_view' - hook to override the result of checking whether 'view' action is allowed or not to specified profile
+         * - $unit_name - equals `system`
+         * - $action - equals `check_allowed_view`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] module name
+         *      - `content_info` - [array] content info array as key&value pairs
+         *      - `profile_id` - [boolean] or [int] profile id to be checked the availability of the action to
+         *      - `override_result` - [string] or [int] by ref, check action result, can be overridden in hook processing. Return string with an error if action isn't allowed or CHECK_ACTION_RESULT_ALLOWED, @see BxDolAcl
+         * @hook @ref hook-system-check_allowed_view
+         */
+        bx_alert('system', 'check_allowed_view', 0, 0, [
+            'module' => $this->getName(), 
+            'content_info' => $aDataEntry, 
+            'profile_id' => $iProfileId, 
+            'override_result' => &$mixedResult
+        ]);
         if($mixedResult !== null)
             return $mixedResult;
 
@@ -4229,7 +4307,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if($oProfileOwner->checkAllowedPostInProfile($this->_iOwnerId, $this->getName()) !== CHECK_ACTION_RESULT_ALLOWED)
                 return _t('_sys_txt_access_denied');
 
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_post '{profile_module_name}', 'timeline_post' - hook to override the result of checking whether 'post in profile' action is allowed or not
+             * - $unit_name - profile module name
+             * - $action - equals `timeline_post`
+             * - $object_id - timeline owner profile id
+             * - $sender_id - performer profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `check_result` - [array] by ref, check action result, can be overridden in hook processing.
+             * @hook @ref hook-bx_base_profile-timeline_post
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_post', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
         }
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
@@ -4278,7 +4369,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'edit_any')) === CHECK_ACTION_RESULT_ALLOWED)
                 return true;
 
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_edit '{profile_module_name}', 'timeline_edit' - hook to override the result of checking whether 'edit' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_edit
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
         }
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
@@ -4303,7 +4402,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'delete_any')) === CHECK_ACTION_RESULT_ALLOWED)
                 return true;
 
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_delete '{profile_module_name}', 'timeline_delete' - hook to override the result of checking whether 'delete' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_delete
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
         }
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
@@ -4339,7 +4446,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_view_counter '{profile_module_name}', 'timeline_view_counter' - hook to override the result of checking whether 'view counter' action is allowed or not
+             * - $unit_name - profile module name
+             * - $action - equals `timeline_view_counter`
+             * - $object_id - timeline owner profile id
+             * - $sender_id - performer profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `result` - [boolean] by ref, check action result, can be overridden in hook processing.
+             * @hook @ref hook-bx_base_profile-timeline_view_counter
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view_counter', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4357,8 +4477,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             return false;
 
         $bResult = true;
+        
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_vote '{profile_module_name}', 'timeline_vote' - hook to override the result of checking whether 'vote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_vote
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4377,7 +4506,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_vote_view '{profile_module_name}', 'timeline_vote_view' - hook to override the result of checking whether 'vote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_vote_view
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote_view', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4396,7 +4533,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_reaction '{profile_module_name}', 'timeline_reaction' - hook to override the result of checking whether 'give reaction vote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_reaction
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4415,7 +4560,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_reaction_view '{profile_module_name}', 'timeline_reaction_view' - hook to override the result of checking whether 'view reactions' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_reaction_view
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction_view', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4434,7 +4587,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_score', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_score '{profile_module_name}', 'timeline_score' - hook to override the result of checking whether 'give score vote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_score
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_score', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4453,7 +4614,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_report '{profile_module_name}', 'timeline_report' - hook to override the result of checking whether 'give score vote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_view_counter
+             * @hook @ref hook-bx_base_profile-timeline_report
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_report', $oProfileOwner->id(), (int)$this->getUserId(), [
+                'result' => &$bResult
+            ]);
 
         return $bResult;
     }
@@ -4462,6 +4631,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
         $mixedResult = $this->_isAllowedRepost($aEvent, $bPerform);
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-is_allowed_repost 'bx_timeline', 'is_allowed_repost' - hook to override the result of checking whether 'repost' action is allowed or not
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `is_allowed_repost`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `content_info` - [array] content info array as key&value pairs
+         *      - `override_result` - [string] or [int] by ref, check action result, can be overridden in hook processing. Return string with an error if action isn't allowed or CHECK_ACTION_RESULT_ALLOWED, @see BxDolAcl
+         * @hook @ref hook-bx_timeline-is_allowed_repost
+         */
         bx_alert($this->getName(), 'is_allowed_repost', 0, 0, [
             'content_info' => $aEvent, 
             'override_result' => &$mixedResult
@@ -4484,7 +4665,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $aCheckResult = checkActionModule($iUserId, 'send', $this->getName(), $bPerform);
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_send '{profile_module_name}', 'timeline_send' - hook to override the result of checking whether 'send' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_send
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_send', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }
@@ -4699,15 +4888,46 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $this->rebuildSlice();
 
-        //--- Event -> Post/Defer for Alerts Engine ---//
         $sAction = ($aEvent[$CNF['FIELD_STATUS']] == BX_TIMELINE_STATUS_AWAITING ? 'defer' : 'post') . '_' . $sPostType;
-        bx_alert($this->_oConfig->getObject('alert'), $sAction, $iContentId, $iSenderId, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-post_system 'bx_timeline', 'post_system' - hook after system post was added and published
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `post_system`
+         * - $object_id - content id
+         * - $sender_id - content author profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `source` - [string] unique source 
+         *      - `owner_id` - [int] owner profile id
+         *      - `object_author_id` - [int] object author profile id
+         *      - `privacy_view` - [int] or [string] privacy for view content action, @see BxDolPrivacy
+         * @hook @ref hook-bx_timeline-post_system
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-post_common 'bx_timeline', 'post_common' - hook after common post was added and published
+         * It's equivalent to @ref hook-bx_timeline-post_system
+         * @hook @ref hook-bx_timeline-post_common
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-defer_system 'bx_timeline', 'defer_system' - hook after system post was added
+         * It's equivalent to @ref hook-bx_timeline-post_system
+         * @hook @ref hook-bx_timeline-defer_system
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-defer_common 'bx_timeline', 'defer_common' - hook after common post was added
+         * It's equivalent to @ref hook-bx_timeline-post_system
+         * @hook @ref hook-bx_timeline-defer_common
+         */
+        bx_alert($this->_oConfig->getObject('alert'), $sAction, $iContentId, $iSenderId, [
             'source' => $this->_oConfig->getName() . '_' . $iContentId,
             'owner_id' => $aEvent['owner_id'],
             'object_author_id' => $iObjectAuthorId,
             'privacy_view' => $aEvent['object_privacy_view'],
-        ));
-        //--- Event -> Post for Alerts Engine ---//
+        ]);
     }
 
     public function onPublished($iContentId)
@@ -4737,13 +4957,24 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             $iSenderId = $iObjectAuthorId = (int)$aEvent['object_id'];
         }
 
-        //--- Event -> Fail for Alerts Engine ---//
-        bx_alert($this->_oConfig->getObject('alert'), 'fail_' . $sPostType, $iContentId, $iSenderId, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-fail_system 'bx_timeline', 'fail_system' - hook after system post failed to publish
+         * It's equivalent to @ref hook-bx_timeline-post_system
+         * @hook @ref hook-bx_timeline-fail_system
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-fail_common 'bx_timeline', 'fail_common' - hook after common post failed to publish
+         * It's equivalent to @ref hook-bx_timeline-post_system
+         * @hook @ref hook-bx_timeline-fail_common
+         */
+        bx_alert($this->_oConfig->getObject('alert'), 'fail_' . $sPostType, $iContentId, $iSenderId, [
+            'source' => $this->_oConfig->getName() . '_' . $iContentId,
             'owner_id' => $aEvent['owner_id'],
             'object_author_id' => $iObjectAuthorId,
             'privacy_view' => $aEvent['object_privacy_view'],
-        ));
-        //--- Event -> Post for Alerts Engine ---//
+        ]);
     }
 
     public function onRepost($iContentId, $aReposted = array())
@@ -4766,13 +4997,24 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $this->rebuildSlice();
 
-        //--- Timeline -> Update for Alerts Engine ---//
-        bx_alert($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
-            'privacy_view' => $aEvent['object_privacy_view'],
-            'object_author_id' => $aReposted['owner_id'],
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-repost 'bx_timeline', 'repost' - hook after repost was added (published)
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `repost`
+         * - $object_id - reposted content id
+         * - $sender_id - performer profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `repost_id` - [int] repost id
+         *      - `object_author_id` - [int] reposted content author profile id
+         *      - `privacy_view` - [int] or [string] privacy for view content action, @see BxDolPrivacy
+         * @hook @ref hook-bx_timeline-repost
+         */
+        bx_alert($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, [
             'repost_id' => $iContentId,
-        ));
-        //--- Timeline -> Update for Alerts Engine ---//
+            'object_author_id' => $aReposted['owner_id'],
+            'privacy_view' => $aEvent['object_privacy_view'],
+        ]);
     }
 
     public function onHide($aEvent)
@@ -4801,9 +5043,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
             $this->_oDb->updateRepostTrack(['active' => 0], ['event_id' => $aRepostEvent[$CNF['FIELD_ID']]]);
 
-            bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-hide_repost 'bx_timeline', 'hide_repost' - hook after repost was hidden
+             * - $unit_name - equals `bx_timeline`
+             * - $action - equals `hide_repost`
+             * - $object_id - content id
+             * - $sender_id - performer profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `repost_id` - [int] repost id
+             * @hook @ref hook-bx_timeline-hide_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         }
 
         //--- Delete associated meta for Common events.
@@ -4820,12 +5073,32 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         //--- Event -> Hide for Alerts Engine ---//
         if($bRepost)
-            bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-hide_repost 'bx_timeline', 'hide_repost' - hook after repost was hidden
+             * - $unit_name - equals `bx_timeline`
+             * - $action - equals `hide_repost`
+             * - $object_id - content id
+             * - $sender_id - performer profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `repost_id` - [int] repost id
+             * @hook @ref hook-bx_timeline-hide_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'hide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         else
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-hide 'bx_timeline', 'hide' - hook after post (event) was hidden
+             * - $unit_name - equals `bx_timeline`
+             * - $action - equals `hide`
+             * - $object_id - content id
+             * - $sender_id - performer profile id
+             * - $extra_params - not used
+             * @hook @ref hook-bx_timeline-hide
+             */
             bx_alert($this->_oConfig->getObject('alert'), 'hide', $aEvent[$CNF['FIELD_ID']], $iUserId);
-        //--- Event -> Hide for Alerts Engine ---//
     }
 
     public function onUnhide($aEvent)
@@ -4854,9 +5127,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
             $this->_oDb->updateRepostTrack(['active' => 1], ['event_id' => $aRepostEvent[$CNF['FIELD_ID']]]);
 
-            bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-unhide_repost 'bx_timeline', 'unhide_repost' - hook after repost was unhidden
+             * It's equivalent to @ref hook-bx_timeline-hide_repost
+             * @hook @ref hook-bx_timeline-unhide_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         }
 
         //--- Process meta for Common events.
@@ -4869,14 +5148,24 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         //--- Rebuild cache table.
         $this->rebuildSlice();
 
-        //--- Event -> Unhide for Alerts Engine ---//
         if($bRepost)
-            bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-unhide_repost 'bx_timeline', 'unhide_repost' - hook after repost was unhidden
+             * It's equivalent to @ref hook-bx_timeline-hide_repost
+             * @hook @ref hook-bx_timeline-unhide_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'unhide_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         else
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-unhide 'bx_timeline', 'unhide' - hook after post (event) was unhidden
+             * It's equivalent to @ref hook-bx_timeline-hide
+             * @hook @ref hook-bx_timeline-unhide
+             */
             bx_alert($this->_oConfig->getObject('alert'), 'unhide', $aEvent[$CNF['FIELD_ID']], $iUserId);
-        //--- Event -> Unhide for Alerts Engine ---//
     }
 
     public function onDelete($aEvent)
@@ -4928,9 +5217,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if($oComments !== false)
                 $oComments->onObjectDelete($aRepostEvent[$CNF['FIELD_ID']]);
 
-            bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-delete_repost 'bx_timeline', 'delete_repost' - hook after repost was deleted
+             * It's equivalent to @ref hook-bx_timeline-hide_repost
+             * @hook @ref hook-bx_timeline-delete_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aRepostEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         }
 
         //--- Delete associated meta for Common events.
@@ -4945,12 +5240,23 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         //--- Rebuild cache table.
         $this->rebuildSlice();
 
-        //--- Event -> Delete for Alerts Engine ---//
         if($bRepost)
-            bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-delete_repost 'bx_timeline', 'delete_repost' - hook after repost was deleted
+             * It's equivalent to @ref hook-bx_timeline-hide_repost
+             * @hook @ref hook-bx_timeline-delete_repost
+             */
+            bx_alert($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted[$CNF['FIELD_ID']], $iUserId, [
                 'repost_id' => $aEvent[$CNF['FIELD_ID']],
-            ));
+            ]);
         else
+            /**
+             * @hooks
+             * @hookdef hook-bx_timeline-delete 'bx_timeline', 'delete' - hook after post (event) was deleted
+             * It's equivalent to @ref hook-bx_timeline-hide
+             * @hook @ref hook-bx_timeline-delete
+             */
             bx_alert($this->_oConfig->getObject('alert'), 'delete', $aEvent[$CNF['FIELD_ID']], $iUserId);
         //--- Event -> Delete for Alerts Engine ---//
     }
@@ -5437,9 +5743,27 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         );
 
         $sContent = '';
-        bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), array('override_content' => &$sContent, 'params' => &$aParams, 'menu' => &$aMenu));
 
-        $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu));
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-timeline_view '{profile_module_name}', 'timeline_view' - hook to override view timeline block
+         * - $unit_name - profile module name
+         * - $action - equals `timeline_view`
+         * - $object_id - timeline owner profile id
+         * - $sender_id - currently logged in profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `params` - [array] browsing params array as key&value pairs
+         *      - `menu` - [array] block submenu items array
+         *      - `override_content` - [string] by ref, block content, can be overridden in hook processing
+         * @hook @ref hook-bx_base_profile-timeline_view
+         */
+        bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_view', $this->_iOwnerId, $this->getUserId(), [
+            'params' => &$aParams,
+            'menu' => &$aMenu,
+            'override_content' => &$sContent,
+        ]);
+
+        $oMenu = new BxTemplMenuInteractive(['template' => 'menu_interactive_vertical.html', 'menu_id'=> $sView . '-view-all', 'menu_items' => $aMenu]);
         $oMenu->setSelected('', $sView . '-view-all');
 
         if (!$sContent)
@@ -5512,7 +5836,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $aCheckResult = checkActionModule($iUserId, 'repost', $this->getName(), $bPerform);
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_repost '{profile_module_name}', 'timeline_repost' - hook to override the result of checking whether 'repost' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_repost
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_repost', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }
@@ -5533,17 +5865,25 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$iUserId = (int)$this->getUserId();
     	if($iUserId == 0)
-    		return false;
+            return false;
 
-		if(isAdmin() || (int)$aEvent['owner_id'] == $iUserId || ((int)$aEvent['owner_id'] == 0 && $this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && (int)$aEvent['object_id'] == $iUserId))
+        if(isAdmin() || (int)$aEvent['owner_id'] == $iUserId || ((int)$aEvent['owner_id'] == 0 && $this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && (int)$aEvent['object_id'] == $iUserId))
            return true;
 
         $aCheckResult = checkActionModule($iUserId, 'pin', $this->getName(), $bPerform);
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false) {
-            if (BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'pin')) === CHECK_ACTION_RESULT_ALLOWED) {
+            if(bx_srv($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'pin')) === CHECK_ACTION_RESULT_ALLOWED)
                 return true;
-            }
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_pin '{profile_module_name}', 'timeline_pin' - hook to override the result of checking whether 'pin' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_pin
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_pin', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
         }
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
@@ -5553,14 +5893,22 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$iUserId = (int)$this->getUserId();
     	if($iUserId == 0)
-    		return false;
+            return false;
 
     	if(isAdmin())
-    		return true;
+            return true;
 
     	$aCheckResult = checkActionModule($iUserId, 'stick', $this->getName(), $bPerform);
     	if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_stick', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_stick '{profile_module_name}', 'timeline_stick' - hook to override the result of checking whether 'stick' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_stick
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_stick', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
     
     	return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }
@@ -5576,7 +5924,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $aCheckResult = checkActionModule($iUserId, 'promote', $this->getName(), $bPerform);
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
-            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_promote', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-timeline_promote '{profile_module_name}', 'timeline_promote' - hook to override the result of checking whether 'promote' action is allowed or not
+             * It's equivalent to @ref hook-bx_base_profile-timeline_post
+             * @hook @ref hook-bx_base_profile-timeline_promote
+             */
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_promote', $oProfileOwner->id(), $iUserId, [
+                'check_result' => &$aCheckResult
+            ]);
 
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }

+ 90 - 8
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -398,6 +398,20 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             $aLiveUpdateParams[] = $iEvent;
 
         $sLiveUpdateCode = null;
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-add_live_update 'bx_timeline', 'add_live_update' - hook to override params and/or code for live updates
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `add_live_update`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `browse_params` - [array] browse params array as key&value pairs
+         *      - `live_update_params` - [array] by ref, live update params array as key&value pairs, can be overridden in hook processing
+         *      - `override_result` - [string] by ref, live update code, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-add_live_update
+         */
         bx_alert($sModuleName, 'add_live_update', 0, 0, [
             'browse_params' => $aParams,
             'live_update_params' => &$aLiveUpdateParams,
@@ -426,7 +440,26 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'mask_markers' => array('object' => $sJsObject)
         )) . $this->getJsCode('repost');
 
-        bx_alert($sModuleName, 'get_view', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_view 'bx_timeline', 'get_view' - hook to override elements of view timeline block
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_view`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `params` - [array] browse params array as key&value pairs
+         *      - `event_first` - [int] the first event id
+         *      - `back` - [string] by ref, back link code, can be overridden in hook processing
+         *      - `empty` - [string] by ref, empty message code, can be overridden in hook processing
+         *      - `content_before` - [string] by ref, code for before content section, can be overridden in hook processing
+         *      - `content` - [string] by ref, content itself, can be overridden in hook processing
+         *      - `content_after` - [string] by ref, code for after content section, can be overridden in hook processing
+         *      - `load_more` - [string] by ref, load more link code, can be overridden in hook processing
+         *      - `js_content` - [string] by ref, JavaScript code, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_view
+         */
+        bx_alert($sModuleName, 'get_view', 0, 0, [
             'params' => $aParams,
             'event_first' => $iEvent,
             'back' => &$sBack,
@@ -436,7 +469,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'content_after' => &$sContentAfter,
             'load_more' => &$sLoadMore,
             'js_content' => &$sJsContent
-        ));
+        ]);
 
         return $this->parseHtmlByName('block_view.html', array(
             'style_prefix' => $this->_oConfig->getPrefix('style'),
@@ -870,6 +903,19 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 $aParams['event_index'] = $iEventIndex;
 
                 $mixedExternalPost = false;
+                
+                /**
+                 * @hooks
+                 * @hookdef hook-bx_timeline-get_external_post 'bx_timeline', 'get_external_post' - hook to override (add) external post(s) in timeline
+                 * - $unit_name - equals `bx_timeline`
+                 * - $action - equals `get_external_post`
+                 * - $object_id - not used
+                 * - $sender_id - not used
+                 * - $extra_params - array of additional params with the following array keys:
+                 *      - `params` - [array] browse params array as key&value pairs
+                 *      - `override_result` - [string] or [array] by ref, code to be added to events list, can be overridden in hook processing
+                 * @hook @ref hook-bx_timeline-get_external_post
+                 */
                 bx_alert($this->_oConfig->getName(), 'get_external_post', 0, 0, [
                     'params' => $aParams,
                     'override_result' => &$mixedExternalPost,
@@ -1217,11 +1263,24 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 'user_unit' => $oModule->getObjectUser($iUserId)->getUnit()
             );
 
-        bx_alert($this->_oConfig->getName(), 'get_reposted_by', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_reposted_by 'bx_timeline', 'get_reposted_by' - hook to override a list of users reposted a content
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_reposted_by`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `content_id` - [int] reposted content id
+         *      - `user_ids` - [array] an array with reposters' profile ids
+         *      - `users` - [array] by ref, an array with variables (keys) which will be used to parse HTML template, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_reposted_by
+         */
+        bx_alert($this->_oConfig->getName(), 'get_reposted_by', 0, 0, [
             'content_id' => $iId,
             'user_ids' => $aUserIds,
             'users' => &$aTmplUsers
-        ));
+        ]);
         
         if(empty($aTmplUsers))
             $aTmplUsers = MsgBox(_t('_Empty'));
@@ -1920,13 +1979,29 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             self::$$sVariable = $this->getHtml('item_' . $aBrowseParams['view'] . '.html');
 
         $sTmplCode = self::$$sVariable;
-        bx_alert($this->_oConfig->getName(), 'get_post', 0, 0, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_post 'bx_timeline', 'get_post' - hook to override a post (event) before output
+         * - $unit_name - equals `bx_timeline`
+         * - $action - equals `get_post`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `type` - [string] post type: post or repost
+         *      - `event` - [array] event data array as key&value pairs
+         *      - `browse_params` - [array] browse params array as key&value pairs
+         *      - `tmpl_code` - [string] by ref, template HTML code, can be overridden in hook processing
+         *      - `tmpl_vars` - [array] by ref, template parsable variables as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_timeline-get_post
+         */
+        bx_alert($this->_oConfig->getName(), 'get_post', 0, 0, [
             'type' => $sType,
             'event' => $aEvent,
             'browse_params' => $aBrowseParams,
             'tmpl_code' => &$sTmplCode,
             'tmpl_vars' => &$aTmplVars
-        ));
+        ]);
 
         return $this->parseHtmlByContent($sTmplCode, $aTmplVars);
     }
@@ -2031,13 +2106,20 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             self::$$sVariable = $this->getHtml('type_' . $sType . '.html');
 
         $sTmplCode = self::$$sVariable;
-        bx_alert($this->_oConfig->getName(), 'get_post_content', 0, 0, array(
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_timeline-get_post_content 'bx_timeline', 'get_post_content' - hook to override a post's content before output
+         * It's equivalent to @ref hook-bx_timeline-get_post
+         * @hook @ref hook-bx_timeline-get_post_content
+         */
+        bx_alert($this->_oConfig->getName(), 'get_post_content', 0, 0, [
             'type' => $sType,
             'event' => $aEvent,
             'browse_params' => $aBrowseParams,
             'tmpl_code' => &$sTmplCode,
             'tmpl_vars' => &$aTmplVars
-        ));
+        ]);
 
         return $this->parseHtmlByContent($sTmplCode, $aTmplVars);
     }