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

+ 7 - 7
modules/base/general/classes/BxBaseModGeneralDb.php

@@ -82,7 +82,7 @@ class BxBaseModGeneralDb extends BxDolModuleDb
                 
                 /**
                  * @hooks
-                 * @hookdef hook-system-search_ids 'system', 'search_ids' - hook to modify a list found content ids
+                 * @hookdef hook-system-search_ids 'system', 'search_ids' - hook to modify a list of found content ids
                  * - $unit_name - equals `system`
                  * - $action - equals `search_ids`
                  * - $object_id - not used
@@ -90,12 +90,12 @@ class BxBaseModGeneralDb extends BxDolModuleDb
                  * - $extra_params - array of additional params with the following array keys:
                  *      - `module_name` - [string] content's module name
                  *      - `params` - [array] by ref, override search params
-                 *      - `select_clause` - [string] by ref, select part of MySQL query, can be overridden in hook processing
-                 *      - `join_clause` - [string] by ref, join part of MySQL query, can be overridden in hook processing
-                 *      - `where_clause` - [string] by ref, where part of MySQL query, can be overridden in hook processing
-                 *      - `order_clause` - [string] by ref, order part of MySQL query, can be overridden in hook processing
-                 *      - `limit_clause` - [string] by ref, limit part of MySQL query, can be overridden in hook processing
-                 *      - `bindings` - [array] by ref, bindings of MySQL query, 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
+                 *      - `bindings` - [array] by ref, bindings of SQL query, can be overridden in hook processing
                  * @hook @ref hook-system-search_ids
                  */
                 bx_alert('system', 'search_ids', 0, 0, [

+ 2 - 2
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -2811,7 +2811,7 @@ class BxBaseModGeneralModule extends BxDolModule
 
         /**
          * @hooks
-         * @hookdef hook-system-check_allowed_view 'system', 'check_allowed_view' - hook to override the result of checking whether 'view' action allowed or not to specified profile
+         * @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
@@ -2846,7 +2846,7 @@ class BxBaseModGeneralModule extends BxDolModule
         $mixedResult = null;
         /**
          * @hooks
-         * @hookdef hook-system-check_allowed_browse 'system', 'check_allowed_browse' - hook to override the result of checking whether 'browse' action allowed or not to currently logged in profile
+         * @hookdef hook-system-check_allowed_browse 'system', 'check_allowed_browse' - hook to override the result of checking whether 'browse' action is allowed or not to currently logged in profile
          * It's equivalent to @ref hook-system-check_allowed_view 
          * except `content_info` parameter in $extra_params is missing
          * @hook @ref hook-system-check_allowed_browse

+ 16 - 0
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -68,6 +68,22 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
         ], $aParams);
 
         $sContent = false;
+        /**
+         * @hooks
+         * @hookdef hook-system-get_js_code 'system', 'get_js_code' - hook to override an instance of JavaScript class associate with the page
+         * - $unit_name - equals `system`
+         * - $action - equals `get_js_code`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `mask` - [string] by ref, a mask to generate JS code, can be overridden in hook processing
+         *      - `mask_markers` - [array] by ref, an array of markers to be parsed in the mask, can be overridden in hook processing
+         *      - `object` - [string] by ref, a string with JS object name, can be overridden in hook processing
+         *      - `class` - [string] by ref, a string with JS class name, can be overridden in hook processing
+         *      - `params` - [array] by ref, an array of parameters as key&value pairs which will be passed to constructor, can be overridden in hook processing
+         *      - `override_result` - [string] or [boolean] by ref, if string is returned then it will be used as resulting JS code, can be overridden in hook processing
+         * @hook @ref hook-system-get_js_code
+         */
         bx_alert('system', 'get_js_code', 0, 0, [
             'mask' => &$sMask,
             'mask_markers' => &$aMaskMarkers,

+ 8 - 2
modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

@@ -176,10 +176,16 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
         if(bx_is_api())
             return bx_api_get_block('redirect', ['uri' => '/' . BxDolPermalinks::getInstance()->permalink($sUrl), 'timeout' => 1000]);
 
-        bx_alert($this->_oModule->getName(), 'redirect_after_edit', 0, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_groups-redirect_after_edit '{module_name}', 'redirect_after_edit' - hook to override redirect URL which is used after content changing
+         * It's equivalent to @ref hook-bx_base_general-redirect_after_edit
+         * @hook @ref hook-bx_base_groups-redirect_after_edit
+         */
+        bx_alert($this->_oModule->getName(), 'redirect_after_edit', 0, false, [
             'content' => $aContentInfo,
             'override_result' => &$sUrl,
-        ));
+        ]);
 
         $this->_redirectAndExit($sUrl);
     }

+ 210 - 20
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -469,7 +469,24 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         // send invitation to the group 
         $sModule = $this->getName();
         if ($bSendInviteOnly && !$oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && bx_get_logged_profile_id() != $iProfileId) {
-            bx_alert($sModule, 'join_invitation', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-join_invitation '{module_name}', 'join_invitation' - hook before adding (sending) new join to context invitation
+             * - $unit_name - module name
+             * - $action - equals `join_invitation`
+             * - $object_id - context id
+             * - $sender_id - context profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `content` - [array] context info array as key&value pairs
+             *      - `entry_title` - [string] context title
+             *      - `entry_url` - [string] context URL
+             *      - `group_profile` - [int] context profile id
+             *      - `profile` - [int] profile id who was invited
+             *      - `notification_subobject_id` - [int] profile id who was invited
+             *      - `object_author_id` - [int] context profile id
+             * @hook @ref hook-bx_base_groups-join_invitation
+             */
+            bx_alert($sModule, 'join_invitation', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
                 'content' => $aContentInfo, 
                 'entry_title' => $sEntryTitle, 
                 'entry_url' => $sEntryUrl, 
@@ -477,22 +494,50 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
                 'profile' => $iProfileId, 
                 'notification_subobject_id' => $iProfileId, 
                 'object_author_id' => $iGroupProfileId
-            ));
+            ]);
 
             /**
              * 'Invitation Received' alert for Notifications module.
              * Note. It's essential to use Recipient ($iInitiatorId) in 'object_author_id' parameter. 
              * In this case notification will be received by Recipient profile.
              */
-            bx_alert($sModule, 'join_invitation_notif', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-join_invitation_notif '{module_name}', 'join_invitation_notif' - hook before adding new join to context invitation. Is needed for Notifications module.
+             * - $unit_name - module name
+             * - $action - equals `join_invitation_notif`
+             * - $object_id - context id
+             * - $sender_id - context profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `object_author_id` - [int] profile id who was invited
+             *      - `privacy_view` - [int] or [string] privacy for view context action, @see BxDolPrivacy
+             * @hook @ref hook-bx_base_groups-join_invitation_notif
+             */
+            bx_alert($sModule, 'join_invitation_notif', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
                 'object_author_id' => $iInitiatorId, 
                 'privacy_view' => isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) ? $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] : 3, 
-            ));
+            ]);
         }
         // send notification to group's admins that new connection is pending confirmation 
         elseif (!$bSendInviteOnly && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && $aContentInfo['join_confirmation']) {
-
-            bx_alert($this->getName(), 'join_request', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-join_request '{module_name}', 'join_request' - hook before adding new join to context request
+             * - $unit_name - module name
+             * - $action - equals `join_request`
+             * - $object_id - context id
+             * - $sender_id - context profile id
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `object_author_id` - [int] context profile id
+             *      - `performer_id` - [int] profile id who wants to join
+             *      - `content` - [array] context info array as key&value pairs
+             *      - `entry_title` - [string] context title
+             *      - `entry_url` - [string] context URL
+             *      - `group_profile` - [int] context profile id
+             *      - `profile` - [int] profile id who wants to join
+             * @hook @ref hook-bx_base_groups-join_request
+             */
+            bx_alert($this->getName(), 'join_request', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
             	'object_author_id' => $iGroupProfileId,
             	'performer_id' => $iProfileId, 
 
@@ -502,11 +547,17 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
             	'group_profile' => $iGroupProfileId, 
             	'profile' => $iProfileId
-            ));
+            ]);
         }
         // send notification that join request was accepted 
         else if (!$bSendInviteOnly && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id(), true) && $oGroupProfile->getModule() != $this->getName() && bx_get_logged_profile_id() != $iProfileId) {
-            bx_alert($this->getName(), 'join_request_accepted', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-join_request_accepted '{module_name}', 'join_request_accepted' - hook before accepting join to context request
+             * It's equivalent to @ref hook-bx_base_groups-join_request
+             * @hook @ref hook-bx_base_groups-join_request_accepted
+             */
+            bx_alert($this->getName(), 'join_request_accepted', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
             	'object_author_id' => $iGroupProfileId,
             	'performer_id' => $iProfileId,
 
@@ -516,7 +567,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
             	'group_profile' => $iGroupProfileId, 
             	'profile' => $iProfileId
-            ));
+            ]);
         }
 
         // new fan was added
@@ -528,8 +579,14 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             else{
                  $this->addFollower((int)$iInitiatorId, $oGroupProfile->id()); 
             }
-            
-            bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
+
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-fan_added '{module_name}', 'fan_added' - hook before adding (registering) new context member
+             * It's equivalent to @ref hook-bx_base_groups-join_request
+             * @hook @ref hook-bx_base_groups-fan_added
+             */
+            bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
             	'object_author_id' => $iGroupProfileId,
             	'performer_id' => $iProfileId,
 
@@ -539,8 +596,8 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
             	'group_profile' => $iGroupProfileId, 
             	'profile' => $iProfileId,
-            ));
-            
+            ]);
+
             $this->doAudit($iGroupProfileId, $iInitiatorId, '_sys_audit_action_group_join_request_accepted');
             
             return false;
@@ -1529,13 +1586,26 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     {
         $mixedResult = $this->_modGroupsCheckAllowedFanAdd($aDataEntry, $isPerformAction);
 
-        // call alert to allow custom checks
-        bx_alert('system', 'check_allowed_fan_add', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_fan_add 'system', 'check_allowed_fan_add' - hook to override the result of checking whether 'fan add' to context action is allowed or not to currently logged in user
+         * - $unit_name - equals `system`
+         * - $action - equals `check_allowed_fan_add`
+         * - $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] context info array as key&value pairs
+         *      - `profile_id` - [int] currently logged in 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_fan_add
+         */
+        bx_alert('system', 'check_allowed_fan_add', 0, 0, [
             'module' => $this->getName(), 
             'content_info' => $aDataEntry, 
             'profile_id' => bx_get_logged_profile_id(), 
             'override_result' => &$mixedResult
-        ));
+        ]);
 
         return $mixedResult;
     }
@@ -1625,7 +1695,25 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             }
         }
 
-        // call alert to allow custom checks
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_action_by_role 'system', 'check_allowed_action_by_role' - hook to override the result of checking whether an action is allowed or not to context member by his role in the context
+         * - $unit_name - equals `system`
+         * - $action - equals `check_allowed_action_by_role`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] module name
+         *      - `multi_roles` - [boolean] whether multi roles are enabled in context or not
+         *      - `action` - [string] action to be checked
+         *      - `action_module` - [string] module name which the action belongs to
+         *      - `content_profile_id` - [int] context profile id
+         *      - `content_info` - [array] context info array as key&value pairs
+         *      - `profile_id` - [int] profile id to be checked the availability of the action to
+         *      - `profile_role` - [int] profile role in the context
+         *      - `override_result` - [boolean] by ref, check action result, can be overridden in hook processing.
+         * @hook @ref hook-system-check_allowed_action_by_role
+         */
         bx_alert('system', 'check_allowed_action_by_role', 0, 0, [
             'module' => $this->getName(), 
             'multi_roles' => $this->_oConfig->isMultiRoles(),
@@ -1774,13 +1862,26 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     {
         $mixedResult = $this->_modGroupsCheckAllowedSubscribeAdd($aDataEntry, $isPerformAction);
 
-        // call alert to allow custom checks
-        bx_alert('system', 'check_allowed_subscribe_add', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_subscribe_add 'system', 'check_allowed_subscribe_add' - hook to override the result of checking whether currently logged in user can subscribe (follow) the context or not
+         * - $unit_name - equals `system`
+         * - $action - equals `check_allowed_subscribe_add`
+         * - $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] context info array as key&value pairs
+         *      - `profile_id` - [int] currently logged in 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_subscribe_add
+         */
+        bx_alert('system', 'check_allowed_subscribe_add', 0, 0, [
             'module' => $this->getName(), 
             'content_info' => $aDataEntry, 
             'profile_id' => bx_get_logged_profile_id(), 
             'override_result' => &$mixedResult
-        ));
+        ]);
 
         return $mixedResult;
     }
@@ -1862,6 +1963,26 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         ];
 
         if(!empty($aField2Method[$sFiledName]))
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-context_picture_changed '{module_name}', 'context_picture_changed' - hook after context picture was changed
+             * - $unit_name - module name
+             * - $action - equals `context_picture_changed`
+             * - $object_id - context id
+             * - $sender_id - profile id who performed the action
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `status` - [string] context status
+             *      - `status_admin` - [string] context admin status
+             *      - `privacy_view` - [int] or [string] privacy for view context action, @see BxDolPrivacy
+             *      - `cf` - [int] context's audience filter value
+             * @hook @ref hook-bx_base_groups-context_picture_changed
+             */
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_groups-context_cover_changed '{module_name}', 'context_cover_changed' - hook after context cover was changed
+             * It's equivalent to @ref hook-bx_base_groups-context_picture_changed 
+             * @hook @ref hook-bx_base_groups-context_cover_changed
+             */
             bx_alert($this->getName(), 'context_' . $aField2Method[$sFiledName] . '_changed', $iContentId, $iProfileId, $this->_alertParams($aContentInfo));
     }
 
@@ -1890,6 +2011,21 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
         $sModule = $this->getName();
         $aParams = $this->_alertParams($aContentInfo);
+        /**
+         * @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] by ref, action, can be overridden in hook processing
+         *      - `object_id` - [int] by ref, object id, can be overridden in hook processing
+         *      - `sender_id` - [int] by ref, action performer profile id, can be overridden in hook processing
+         *      - `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'=> $sModule, 
             'action' => &$sAction, 
@@ -1897,6 +2033,26 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             'sender_id' => &$iAuthorId, 
             'extras' => &$aParams
         ]);
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_groups-added '{module_name}', 'added' - hook after context was added (published)
+         * - $unit_name - module name
+         * - $action - equals `added`
+         * - $object_id - context id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `status` - [string] context status
+         *      - `status_admin` - [string] context admin status
+         *      - `privacy_view` - [int] or [string] privacy for view context action, @see BxDolPrivacy
+         *      - `cf` - [int] context's audience filter value
+         * @hook @ref hook-bx_base_groups-added
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_groups-deferred '{module_name}', 'deferred' - hook after context was added with pending approval status
+         * It's equivalent to @ref hook-bx_base_groups-added
+         * @hook @ref hook-bx_base_groups-deferred
+         */
         bx_alert($sModule, $sAction, $iId, false, $aParams);
 
         $this->_processModerationNotifications($aContentInfo);
@@ -2057,6 +2213,23 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             ), BX_EMAIL_NOTIFY);
         }
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_groups-set_role '{module_name}', 'set_role' - hook after 'set role' action was applied to context member
+         * - $unit_name - module name
+         * - $action - equals `set_role`
+         * - $object_id - context id
+         * - $sender_id - context profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `object_author_id` - [int] context profile id
+         *      - `performer_id` - [int] performer profile id
+         *      - `fan_id` - [int] context member profile id
+         *      - `content` - [array] context info array as key&value pairs
+         *      - `role` - [int] or [array] role or an array of roles to be set
+         *      - `group_profile` - [int] context profile id
+         *      - `profile` - [int] performer profile id
+         * @hook @ref hook-bx_base_groups-set_role
+         */
         bx_alert($this->getName(), 'set_role', $aGroupProfileInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
             'object_author_id' => $iGroupProfileId,
             'performer_id' => $iProfileId, 
@@ -2105,6 +2278,23 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         $oGroupProfile = BxDolProfile::getInstance($iGroupProfileId);
         $aGroupProfileInfo = $this->_oDb->getContentInfoById((int)$oGroupProfile->getContentId());
 
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_groups-set_role '{module_name}', 'set_role' - hook after 'set role' action was applied to context member
+         * - $unit_name - module name
+         * - $action - equals `set_role`
+         * - $object_id - context id
+         * - $sender_id - context profile id
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `object_author_id` - [int] context profile id
+         *      - `performer_id` - [int] performer profile id
+         *      - `fan_id` - [int] context member profile id
+         *      - `content` - [array] context info array as key&value pairs
+         *      - `role` - [int] or [array] role or an array of roles to be set
+         *      - `group_profile` - [int] context profile id
+         *      - `profile` - [int] performer profile id
+         * @hook @ref hook-bx_base_groups-set_role
+         */
         bx_alert($this->getName(), 'set_role', $aGroupProfileInfo[$CNF['FIELD_ID']], $iGroupProfileId, array(
             'object_author_id' => $iGroupProfileId,
             'performer_id' => $iProfileId, 

+ 18 - 1
modules/base/payment/classes/BxBaseModPaymentModule.php

@@ -353,7 +353,24 @@ class BxBaseModPaymentModule extends BxBaseModGeneralModule
         $sSystem = 'system';
         $sModule = $this->getName();
         foreach([$sSystem, $sModule] as $sUnit)
-            bx_alert($sUnit, $sAction, $iObjectId, $iSender, ($sUnit == $sSystem ? array_merge(array('module' => $sModule), $aExtras) : $aExtras));
+            /**
+             * @hooks
+             * @hookdef hook-system-bx_payment_action 'system', '{payment_action}' - hook after some payment related action happened
+             * - $unit_name - equals `system`
+             * - $action - action (Finalize Checkout, Register Payment, Refund Payment, etc)
+             * - $object_id - object id, not used in most cases
+             * - $sender_id - action performer profile id
+             * - $extra_params - array of additional params including currently active payment processing module name
+             * @hook @ref hook-system-bx_payment_action
+             */
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_payment-bx_payment_action '{payment_module_name}', '{payment_action}' - hook after some payment related action happened
+             * It's equivalent to @ref hook-system-bx_payment_action
+             * except `module` parameter in $extra_params is missing
+             * @hook @ref hook-bx_base_payment-bx_payment_action
+             */
+            bx_alert($sUnit, $sAction, $iObjectId, $iSender, ($sUnit == $sSystem ? array_merge(['module' => $sModule], $aExtras) : $aExtras));
     }
 
     public function callGetPaymentData($mixedModule)

+ 20 - 0
modules/base/profile/classes/BxBaseModProfileAlertsResponse.php

@@ -27,12 +27,32 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
         if ($CNF['OBJECT_STORAGE'] == $oAlert->sUnit && 'file_deleted' == $oAlert->sAction && isset($CNF['FIELD_PICTURE'])) {
             $bResult = (int)$this->_oModule->_oDb->resetContentPictureByFileId($oAlert->iObject, $CNF['FIELD_PICTURE']) > 0;
             if($bResult)
+                /**
+                 * @hooks
+                 * @hookdef hook-bx_base_profile-profile_picture_deleted '{module_name}', 'profile_picture_deleted' - hook after profile picture was deleted
+                 * - $unit_name - module name
+                 * - $action - equals `profile_picture_deleted`
+                 * - $object_id - context id
+                 * - $sender_id - not used
+                 * - $extra_params - not used
+                 * @hook @ref hook-bx_base_profile-profile_picture_deleted
+                 */
                 bx_alert($sModule, 'profile_picture_deleted', $oAlert->iObject);
         }
 
         if ($CNF['OBJECT_STORAGE_COVER'] == $oAlert->sUnit && 'file_deleted' == $oAlert->sAction && isset($CNF['FIELD_COVER'])) {
             $bResult = (int)$this->_oModule->_oDb->resetContentPictureByFileId($oAlert->iObject, $CNF['FIELD_COVER']) > 0;
             if($bResult)
+                /**
+                 * @hooks
+                 * @hookdef hook-bx_base_profile-profile_cover_deleted '{module_name}', 'profile_cover_deleted' - hook after profile cover was deleted
+                 * - $unit_name - module name
+                 * - $action - equals `profile_cover_deleted`
+                 * - $object_id - context id
+                 * - $sender_id - not used
+                 * - $extra_params - not used
+                 * @hook @ref hook-bx_base_profile-profile_cover_deleted
+                 */
                 bx_alert($sModule, 'profile_cover_deleted', $oAlert->iObject);
         }
 

+ 14 - 1
modules/base/profile/classes/BxBaseModProfileCmts.php

@@ -25,7 +25,20 @@ class BxBaseModProfileCmts extends BxTemplCmts
     {
     	$bCheckResult = $this->_isPostAllowed ($isPerformAction);
 
-        bx_alert($this->_sModule, 'comment_post_allowed', $this->getId(), false, array('check_result' => &$bCheckResult));
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-comment_post_allowed '{module_name}', 'comment_post_allowed' - hook to override the result of checking whether comment posting action allowed or not
+         * - $unit_name - module name
+         * - $action - equals `comment_post_allowed`
+         * - $object_id - content id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `check_result` - [boolean] by ref, check action result, can be overridden in hook processing.
+         * @hook @ref hook-bx_base_profile-comment_post_allowed
+         */
+        bx_alert($this->_sModule, 'comment_post_allowed', $this->getId(), false, [
+            'check_result' => &$bCheckResult
+        ]);
 
         return $bCheckResult;
     }

+ 66 - 7
modules/base/profile/classes/BxBaseModProfileDb.php

@@ -21,17 +21,53 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
 
     public function getContentInfoById ($iContentId)
     {
-        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `c`.`id` = ?", $this->_oConfig->getName(), $iContentId);
-        $aInfo = $this->getRow($sQuery);
-        bx_alert('profile', 'content_info_by_id', $iContentId, 0, array('module' => $this->_oConfig->getName(), 'info' => &$aInfo));
+        $aInfo = $this->getRow("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = :type) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `c`.`id` = :id", [
+            'type' => $this->_oConfig->getName(),
+            'id' => $iContentId
+        ]);
+        
+        /**
+         * @hooks
+         * @hookdef hook-profile-content_info_by_id 'profile', 'content_info_by_id' - hook to modify profile info retrieved by content id
+         * - $unit_name - equals `profile`
+         * - $action - equals `content_info_by_id`
+         * - $object_id - content id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] profile module name
+         *      - `info` - [array] by ref, profile info array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-profile-content_info_by_id
+         */
+        bx_alert('profile', 'content_info_by_id', $iContentId, 0, [
+            'module' => $this->_oConfig->getName(), 
+            'info' => &$aInfo
+        ]);
         return $aInfo;
     }
 
     public function getContentInfoByProfileId ($iProfileId)
     {
-        $sQuery = $this->prepare ("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `p`.`id` = ?", $this->_oConfig->getName(), $iProfileId);
-        $aInfo = $this->getRow($sQuery);
-        bx_alert('profile', 'content_info_by_profile_id', $iProfileId, 0, array('module' => $this->_oConfig->getName(), 'info' => &$aInfo));
+        $aInfo = $this->getRow("SELECT `c`.*, `p`.`account_id`, `p`.`id` AS `profile_id`, `a`.`email` AS `profile_email`, `a`.`active` AS `profile_last_active`, `a`.`ip` AS `profile_ip`, `p`.`status` AS `profile_status` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = :type) INNER JOIN `sys_accounts` AS `a` ON (`p`.`account_id` = `a`.`id`) WHERE `p`.`id` = :profile_id", [
+            'type' => $this->_oConfig->getName(),
+            'profile_id' => $iProfileId
+        ]);
+        
+        /**
+         * @hooks
+         * @hookdef hook-profile-content_info_by_profile_id 'profile', 'content_info_by_profile_id' - hook to modify profile info retrieved by profile id
+         * - $unit_name - equals `profile`
+         * - $action - equals `content_info_by_profile_id`
+         * - $object_id - profile id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] profile module name
+         *      - `info` - [array] by ref, profile info array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-profile-content_info_by_profile_id
+         */
+        bx_alert('profile', 'content_info_by_profile_id', $iProfileId, 0, [
+            'module' => $this->_oConfig->getName(), 
+            'info' => &$aInfo
+        ]);
         return $aInfo;
     }
 
@@ -83,7 +119,30 @@ class BxBaseModProfileDb extends BxBaseModGeneralDb
 
         $sOrderBy = $this->prepareAsString(" ORDER BY `a`.`logged` DESC LIMIT ?", (int)$iLimit);
 
-        bx_alert('profile', 'search_by_term', 0, 0, array('module' => $this->_oConfig->getName(), 'table' => $this->_oConfig->CNF['TABLE_ENTRIES'], 'select' => &$sSelect,  'join' => &$sJoin, 'where' => &$sWhere, 'order_by' => &$sOrderBy));
+        /**
+         * @hooks
+         * @hookdef hook-profile-search_by_term 'profile', 'search_by_term' - hook to modify a list of profiles found by term
+         * - $unit_name - equals `profile`
+         * - $action - equals `search_by_term`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] profile module name
+         *      - `table` - [string] db table name
+         *      - `select` - [string] by ref, select part of SQL query, can be overridden in hook processing
+         *      - `join` - [string] by ref, join part of SQL query, can be overridden in hook processing
+         *      - `where` - [string] by ref, where part of SQL query, can be overridden in hook processing
+         *      - `order_by` - [string] by ref, order part of SQL query, can be overridden in hook processing
+         * @hook @ref hook-profile-search_by_term
+         */
+        bx_alert('profile', 'search_by_term', 0, 0, [
+            'module' => $this->_oConfig->getName(), 
+            'table' => $this->_oConfig->CNF['TABLE_ENTRIES'], 
+            'select' => &$sSelect,  
+            'join' => &$sJoin, 
+            'where' => &$sWhere, 
+            'order_by' => &$sOrderBy
+        ]);
         
         return $this->getAll("SELECT " . $sSelect . " FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` " . $sJoin . " WHERE " . $sWhere . $sOrderBy, $aBindings);
     }

+ 150 - 15
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -524,7 +524,23 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             return false;
         
         $sDisplayName = $this->getProfileName($aContentInfo);
-        bx_alert($this->getName(), 'profile_name', $aContentInfo['profile_id'], 0, array('info' => $aContentInfo, 'display_name' => &$sDisplayName));
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-profile_name '{module_name}', 'profile_name' - hook to override profile display name
+         * - $unit_name - module name
+         * - $action - equals `profile_name`
+         * - $object_id - profile id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `info` - [array] profile info array as key&value pairs
+         *      - `display_name` - [string] by ref, profile display name, can be overridden in hook processing
+         * @hook @ref hook-bx_base_profile-profile_name
+         */
+        bx_alert($this->getName(), 'profile_name', $aContentInfo['profile_id'], 0, [
+            'info' => $aContentInfo, 
+            'display_name' => &$sDisplayName
+        ]);
         
         return $sDisplayName;
     }
@@ -622,10 +638,22 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
                 $aRet[] = $iConnectedProfileId;
         }*/
 
-        bx_alert('system', 'get_participating_profiles', $iProfileId, false, array(
+        /**
+         * @hooks
+         * @hookdef hook-system-get_participating_profiles 'system', 'get_participating_profiles' - hook to override context participants list
+         * - $unit_name - equals `system`
+         * - $action - equals `get_participating_profiles`
+         * - $object_id - context profile id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] module name
+         *      - `profiles` - [array] by ref, a list of participating profiles ids, can be overridden in hook processing
+         * @hook @ref hook-system-get_participating_profiles
+         */
+        bx_alert('system', 'get_participating_profiles', $iProfileId, false, [
             'module' => $this->_oConfig->getName(),
             'profiles' => &$aRet
-        ));
+        ]);
 
         return $aRet;
     }
@@ -638,8 +666,23 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
      * @return array which is ready to use for particular module
      */ 
     public function servicePrepareFields ($aFieldsProfile)
-    {        
-        bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsProfile, 'fields_result' => &$aFieldsProfile));
+    {
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-prepare_fields '{module_name}', 'prepare_fields' - hook to override prepared profile fields
+         * - $unit_name - module name
+         * - $action - equals `prepare_fields`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `fields_orig` - [array] original fields array as key&value pairs
+         *      - `fields_result` - [array] by ref, resulting fields array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_base_profile-prepare_fields
+         */
+        bx_alert($this->getName(), 'prepare_fields', 0, 0, [
+            'fields_orig' => $aFieldsProfile, 
+            'fields_result' => &$aFieldsProfile
+        ]);
 
         return $aFieldsProfile;
     }
@@ -662,8 +705,23 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             if ($k != $v && !isset($aMap[$v]))
                 unset($aFieldsProfile[$v]);
         }
-        
-        bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsOrig, 'fields_result' => &$aFieldsProfile));
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-prepare_fields '{module_name}', 'prepare_fields' - hook to override prepared profile fields
+         * - $unit_name - module name
+         * - $action - equals `prepare_fields`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `fields_orig` - [array] original fields array as key&value pairs
+         *      - `fields_result` - [array] by ref, resulting fields array as key&value pairs, can be overridden in hook processing
+         * @hook @ref hook-bx_base_profile-prepare_fields
+         */
+        bx_alert($this->getName(), 'prepare_fields', 0, 0, [
+            'fields_orig' => $aFieldsOrig, 
+            'fields_result' => &$aFieldsProfile
+        ]);
 
         return $aFieldsProfile;
     }
@@ -1561,7 +1619,19 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
         // check alert to allow custom checks
         $mixedResult = null;
-        bx_alert('system', 'check_allowed_post', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
+
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_post 'system', 'check_allowed_post' - hook to override the result of checking whether 'post' action is allowed or not to specified profile
+         * It's equivalent to @ref hook-system-check_allowed_view
+         * @hook @ref hook-system-check_allowed_post
+         */
+        bx_alert('system', 'check_allowed_post', 0, 0, [
+            'module' => $this->getName(), 
+            'content_info' => $aDataEntry, 
+            'profile_id' => $iProfileId, 
+            'override_result' => &$mixedResult
+        ]);
         if($mixedResult !== null)
             return $mixedResult;
 
@@ -1585,13 +1655,18 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
     {
         $mixedResult = $this->_serviceCheckAllowedContactForProfile($aDataEntry, $isPerformAction, $iProfileId);
 
-        // call alert to allow custom checks
-        bx_alert('system', 'check_allowed_contact', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_contact 'system', 'check_allowed_contact' - hook to override the result of checking whether 'contact' action is allowed or not to specified profile
+         * It's equivalent to @ref hook-system-check_allowed_view
+         * @hook @ref hook-system-check_allowed_contact
+         */
+        bx_alert('system', 'check_allowed_contact', 0, 0, [
             'module' => $this->getName(), 
             'content_info' => $aDataEntry, 
             'profile_id' => $iProfileId, 
             'override_result' => &$mixedResult
-        ));
+        ]);
 
         return $mixedResult;
     }
@@ -1841,13 +1916,18 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
     {
         $mixedResult = $this->_modProfileCheckAllowedSubscribeAdd($aDataEntry, $isPerformAction);
 
-        // call alert to allow custom checks
-        bx_alert('system', 'check_allowed_subscribe_add', 0, 0, array(
+        /**
+         * @hooks
+         * @hookdef hook-system-check_allowed_subscribe_add 'system', 'check_allowed_subscribe_add' - hook to override the result of checking whether 'subscribe' action is allowed or not to currently logged in user
+         * It's equivalent to @ref hook-system-check_allowed_view
+         * @hook @ref hook-system-check_allowed_subscribe_add
+         */
+        bx_alert('system', 'check_allowed_subscribe_add', 0, 0, [
             'module' => $this->getName(), 
             'content_info' => $aDataEntry, 
             'profile_id' => bx_get_logged_profile_id(), 
             'override_result' => &$mixedResult
-        ));
+        ]);
 
         return $mixedResult;
     }
@@ -1961,6 +2041,25 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         ];
 
         if(!empty($aField2Method[$sFiledName]))
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-profile_picture_changed '{module_name}', 'profile_picture_changed' - hook after profile picture was changed
+             * - $unit_name - module name
+             * - $action - equals `profile_picture_changed`
+             * - $object_id - image id
+             * - $sender_id - profile id who performed the action
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `object_author_id` - [int] profile id
+             *      - `content` - [int] profile content id
+             *      - `field` - [string] field name
+             * @hook @ref hook-bx_base_profile-profile_picture_changed
+             */
+            /**
+             * @hooks
+             * @hookdef hook-bx_base_profile-profile_cover_changed '{module_name}', 'profile_cover_changed' - hook after profile cover was changed
+             * It's equivalent to @ref hook-bx_base_profile-profile_picture_changed
+             * @hook @ref hook-bx_base_profile-profile_cover_changed
+             */
             bx_alert($sModule, 'profile_' . $aField2Method[$sFiledName] . '_changed', $sFiledValue, $iProfileId, [
                 'object_author_id' => $iProfileId, 
                 'content' => $iContentId, 
@@ -1993,6 +2092,20 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
 
         $aParams = $this->_alertParams($aContentInfo);
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-added '{module_name}', 'added' - hook after profile was added
+         * - $unit_name - module name
+         * - $action - equals `added`
+         * - $object_id - profile content id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `status` - [string] context status
+         *      - `status_admin` - [string] context admin status
+         *      - `privacy_view` - [int] or [string] privacy for view context action, @see BxDolPrivacy
+         * @hook @ref hook-bx_base_profile-added
+         */
         bx_alert($this->getName(), 'added', $iContentId, false, $aParams);
     }
 
@@ -2004,10 +2117,32 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
 
         $aParams = $this->_alertParams($aContentInfo);
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-edited '{module_name}', 'edited' - hook after profile was changed
+         * It's equivalent to @ref hook-bx_base_profile-added
+         * @hook @ref hook-bx_base_profile-edited
+         */
         bx_alert($sModule, 'edited', $iContentId, false, $aParams);
 
         $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sModule);
-        bx_alert('profile', 'edit', $oProfile->id(), 0, array('content' => $iContentId, 'module' => $sModule));
+        
+        /**
+         * @hooks
+         * @hookdef hook-profile-edit 'profile', 'edit' - hook after profile was changed
+         * - $unit_name - equals `profile`
+         * - $action - equals `edit`
+         * - $object_id - profile id
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `content` - [int] profile content id
+         *      - `module` - [string] module name
+         * @hook @ref hook-profile-added
+         */
+        bx_alert('profile', 'edit', $oProfile->id(), 0, [
+            'content' => $iContentId, 
+            'module' => $sModule
+        ]);
     }
 
     public function getProfileByCurrentUrl ()

+ 79 - 10
modules/base/profile/classes/BxBaseModProfileTemplate.php

@@ -79,7 +79,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
 
         $aVars = $this->unitVars($aData, $isCheckPrivateContent, $mixedTemplate, $aParams);
         
-        $aExtras = array(
+        $aExtras = [
             'module' => $oModule->getName(),
             'data' => $aData,
             'check_private_content' => $isCheckPrivateContent,
@@ -87,8 +87,33 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
             'params' => $aParams,
             'tmpl_name' => &$sTemplate,
             'tmpl_vars' => &$aVars
-        );
+        ];
+        
+        /**
+         * @hooks
+         * @hookdef hook-profile-unit 'profile', 'unit' - hook to override profile browsing unit
+         * - $unit_name - equals `profile`
+         * - $action - equals `unit`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `module` - [string] module name
+         *      - `data` - [array] profile info array as key&value pairs
+         *      - `check_private_content` - [boolean] check if it's a provate profile
+         *      - `template` - [string] or [array] with template for profile unit
+         *      - `params` - [array] additional params array as key&value pairs
+         *      - `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
+         * @hook @ref hook-profile-unit
+         */
         bx_alert('profile', 'unit', 0, 0, $aExtras);
+        
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_profile-unit '{module_name}', 'unit' - hook to override profile browsing unit
+         * It's equivalent to @ref hook-profile-unit
+         * @hook @ref hook-bx_base_profile-unit
+         */
         bx_alert($aExtras['module'], 'unit', 0, 0, $aExtras);
  
         return $this->parseHtmlByName($sTemplate, $aVars);
@@ -351,12 +376,34 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
 
             $sAddClassCover = "";
             if(isset($CNF['FIELD_COVER']) && isset($CNF['OBJECT_UPLOADERS_COVER']) && isset($CNF['OBJECT_STORAGE_COVER']) && isset($CNF['OBJECT_IMAGES_TRANSCODER_COVER'])){
-                bx_alert('system', 'image_editor', 0, 0, array(
+                /**
+                 * @hooks
+                 * @hookdef hook-system-image_editor 'system', 'image_editor' - hook to override profile cover editor
+                 * - $unit_name - equals `system`
+                 * - $action - equals `image_editor`
+                 * - $object_id - not used
+                 * - $sender_id - not used
+                 * - $extra_params - array of additional params with the following array keys:
+                 *      - `module` - [string] module name
+                 *      - `content_id` - [int] profile content id
+                 *      - `is_allow_edit` - [boolean] if edit action is allowed to current user
+                 *      - `image_type` - [string] image type equals to `cover`
+                 *      - `image_url` - [string] image URL
+                 *      - `uploader` - [string] uploader name
+                 *      - `storage` - [string] storage name
+                 *      - `transcoder` - [string] transcoder name
+                 *      - `field` - [string] field name
+                 *      - `is_background` - [boolean] if image is used as background, always `true`
+                 *      - `add_class` - [string] by ref, class to add, can be overridden in hook processing
+                 *      - `add_code` - [array] by ref, code to add, can be overridden in hook processing
+                 * @hook @ref hook-system-image_editor
+                 */
+                bx_alert('system', 'image_editor', 0, 0, [
                    'module' => $oModule->getName(),
-                   'image_type' => 'cover',
+                   'content_id' => $aData[$CNF['FIELD_ID']],
                    'is_allow_edit' => $bIsAllowEditCover,
+                   'image_type' => 'cover',
                    'image_url' => $aData[$CNF['FIELD_COVER']] ? $sUrlCover : '',
-                   'content_id' => $aData[$CNF['FIELD_ID']],
                    'uploader' => $CNF['OBJECT_UPLOADERS_COVER'][0],
                    'storage' => $CNF['OBJECT_STORAGE_COVER'],
                    'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_COVER'],
@@ -364,7 +411,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
                    'is_background' => true,
                    'add_class' => &$sAddClassCover,
                    'add_code' => &$sAddCode
-                ));
+                ]);
             }
             
             $sCoverTweak = '';
@@ -402,12 +449,34 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
 
             $sAddClassPicture = "";
             if(isset($CNF['FIELD_PICTURE']) && isset($CNF['OBJECT_UPLOADERS_PICTURE']) && isset($CNF['OBJECT_STORAGE']) && isset($CNF['OBJECT_IMAGES_TRANSCODER_THUMB'])){
-                bx_alert('system', 'image_editor', 0, 0, array(
+                /**
+                 * @hooks
+                 * @hookdef hook-system-image_editor 'system', 'image_editor' - hook to override profile avatar editor
+                 * - $unit_name - equals `system`
+                 * - $action - equals `image_editor`
+                 * - $object_id - not used
+                 * - $sender_id - not used
+                 * - $extra_params - array of additional params with the following array keys:
+                 *      - `module` - [string] module name
+                 *      - `content_id` - [int] profile content id
+                 *      - `is_allow_edit` - [boolean] if edit action is allowed to current user
+                 *      - `image_type` - [string] image type equals to `avatar`
+                 *      - `image_url` - [string] image URL
+                 *      - `uploader` - [string] uploader name
+                 *      - `storage` - [string] storage name
+                 *      - `transcoder` - [string] transcoder name
+                 *      - `field` - [string] field name
+                 *      - `is_background` - [boolean] if image used is as background, always `false`
+                 *      - `add_class` - [string] by ref, class to add, can be overridden in hook processing
+                 *      - `add_code` - [array] by ref, code to add, can be overridden in hook processing
+                 * @hook @ref hook-system-image_editor
+                 */
+                bx_alert('system', 'image_editor', 0, 0, [
                    'module' => $oModule->getName(),
-                   'image_type' => 'avatar',
+                   'content_id' => $aData[$CNF['FIELD_ID']],
                    'is_allow_edit' => $bIsAllowEditPicture,
+                   'image_type' => 'avatar',
                    'image_url' =>  $aData[$CNF['FIELD_PICTURE']] ? $sUrlPicture : '',
-                   'content_id' => $aData[$CNF['FIELD_ID']],
                    'uploader' => $CNF['OBJECT_UPLOADERS_PICTURE'][0],
                    'storage' => $CNF['OBJECT_STORAGE'],
                    'transcoder' => $CNF['OBJECT_IMAGES_TRANSCODER_AVATAR_BIG'],
@@ -415,7 +484,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
                    'is_background' => false,
                    'add_class' => &$sAddClassPicture,
                    'add_code' => &$sAddCode
-                )); 
+                ]); 
             }
             
             $sPictureTweak = '';

+ 51 - 1
modules/base/text/classes/BxBaseModTextModule.php

@@ -821,7 +821,50 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
             $sAction = 'deferred';
 
         $aParams = $this->_alertParamsAdd($aContentInfo);
-        bx_alert('system', 'prepare_alert_params', 0, 0, array('unit'=> $this->getName(), 'action' => &$sAction, 'object_id' => &$iId, 'sender_id' => &$iAuthorId, '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] by ref, action, can be overridden in hook processing
+         *      - `object_id` - [int] by ref, object id, can be overridden in hook processing
+         *      - `sender_id` - [int] by ref, action performer profile id, can be overridden in hook processing
+         *      - `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->getName(), 
+            'action' => &$sAction, 
+            'object_id' => &$iId, 
+            'sender_id' => &$iAuthorId, 
+            'extras' => &$aParams
+        ]);
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_text-added '{module_name}', 'added' - hook after content was added (published)
+         * - $unit_name - module name
+         * - $action - equals `added`
+         * - $object_id - content id
+         * - $sender_id - content author profile id
+         * - $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_base_text-added
+         */
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_text-deferred '{module_name}', 'deferred' - hook after content was added with pending approval status
+         * It's equivalent to @ref hook-bx_base_text-added
+         * @hook @ref hook-bx_base_text-deferred
+         */
         bx_alert($this->getName(), $sAction, $iId, $iAuthorId, $aParams);
 
         $this->_processModerationNotifications($aContentInfo);
@@ -834,6 +877,13 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         $iId = (int)$aContentInfo[$CNF['FIELD_ID']];
 
         $aParams = $this->_alertParamsEdit($aContentInfo);
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_text-edited '{module_name}', 'edited' - hook after content was changed
+         * It's equivalent to @ref hook-bx_base_text-added
+         * @hook @ref hook-bx_base_text-edited
+         */
         bx_alert($this->getName(), 'edited', $iId, false, $aParams);
     }
 

+ 44 - 5
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -54,14 +54,31 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
             return $sResult;            
 
         $aTemplateVars = $this->getUnit($aData, $aParams);
-        bx_alert($this->getModule()->getName(), 'unit', 0, 0, array(
+
+        /**
+         * @hooks
+         * @hookdef hook-bx_base_text-unit '{module_name}', 'unit' - hook to override content browsing unit
+         * - $unit_name - module name
+         * - $action - equals `unit`
+         * - $object_id - not used
+         * - $sender_id - not used
+         * - $extra_params - array of additional params with the following array keys:
+         *      - `data` - [array] content info array as key&value pairs
+         *      - `check_private_content` - [boolean] check if it's a provate content
+         *      - `template` - [string] or [array] with template for content unit
+         *      - `params` - [array] additional params array as key&value pairs
+         *      - `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
+         * @hook @ref hook-bx_base_text-unit
+         */
+        bx_alert($this->getModule()->getName(), 'unit', 0, 0, [
             'data' => $aData,
             'check_private_content' => $isCheckPrivateContent,
             'template' => $sTemplateName,
             'params' => $aParams,
             'tmpl_name' => &$sTemplateName,
             'tmpl_vars' => &$aTemplateVars
-        ));
+        ]);
 
         return $this->parseHtmlByName($sTemplateName, $aTemplateVars);
     }
@@ -656,12 +673,34 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         $bIsAllowEditPicture =  CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData);
 
         if(isset($CNF['FIELD_THUMB']) && isset($CNF['OBJECT_UPLOADERS']) && isset($CNF['OBJECT_STORAGE']) && isset($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'])){
-            bx_alert('system', 'image_editor', 0, 0, array(
+            /**
+             * @hooks
+             * @hookdef hook-system-image_editor 'system', 'image_editor' - hook to override content header image editor
+             * - $unit_name - equals `system`
+             * - $action - equals `image_editor`
+             * - $object_id - not used
+             * - $sender_id - not used
+             * - $extra_params - array of additional params with the following array keys:
+             *      - `module` - [string] module name
+             *      - `content_id` - [int] profile content id
+             *      - `is_allow_edit` - [boolean] if edit action is allowed to current user
+             *      - `image_type` - [string] image type equals to `header_image`
+             *      - `image_url` - [string] image URL
+             *      - `uploader` - [string] uploader name
+             *      - `storage` - [string] storage name
+             *      - `transcoder` - [string] transcoder name
+             *      - `field` - [string] field name
+             *      - `is_background` - [boolean] if image is used as background, always `false`
+             *      - `add_class` - [string] by ref, class to add, can be overridden in hook processing
+             *      - `add_code` - [array] by ref, code to add, can be overridden in hook processing
+             * @hook @ref hook-system-image_editor
+             */
+            bx_alert('system', 'image_editor', 0, 0, [
                 'module' => $oModule->getName(),
                 'content_id' => $aData[$CNF['FIELD_ID']],
+                'is_allow_edit' => $bIsAllowEditPicture,
                 'image_type' => 'header_image',
                 'image_url' => $sImage,
-                'is_allow_edit' => $bIsAllowEditPicture,
                 'uploader' => !empty($CNF['OBJECT_UPLOADERS']) && is_array($CNF['OBJECT_UPLOADERS']) ? $CNF['OBJECT_UPLOADERS'][0] : '',
                 'storage' => isset($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
                 'transcoder' => isset($CNF['OBJECT_IMAGES_TRANSCODER_COVER']) ? $CNF['OBJECT_IMAGES_TRANSCODER_COVER'] : '',
@@ -669,7 +708,7 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
                 'is_background' => false,
                 'add_class' => &$sAddClassPicture,
                 'add_code' => &$sAddCode
-            )); 
+            ]); 
         }
 
         $sImageTweak = '';