1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
eventmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Forum\Comments;
4use \Bitrix\Main\Loader;
6{
7 public static function init()
8 {
9 if (IsModuleInstalled("iblock"))
10 {
11 AddEventHandler("forum", "onAfterMessageAdd", array(__CLASS__, "updateIBlockPropertyAfterAddingMessage"));
12 AddEventHandler("forum", "onMessageModerate", array(__CLASS__, "updateIBlockProperty"));
13 AddEventHandler("forum", "onAfterMessageDelete", array(__CLASS__, "updateIBlockPropertyAfterDeletingMessage"));
14 }
15 AddEventHandler("forum", "onMessageIsIndexed", array(__CLASS__, "onMessageIsIndexed"));
16 }
17
18 public static function updateIBlockPropertyAfterAddingMessage($ID, $arFields, $arTopic = array())
19 {
20 if ($ID > 0 && $arFields["PARAM1"] != "IB" && $arFields["APPROVED"] == "Y")
21 {
22 self::updateIBlockProperty($ID, "SHOW", $arFields, $arTopic);
23 }
24 }
25
27 {
28 if ($ID > 0 && $arFields["PARAM1"] != "IB" && $arFields["APPROVED"] == "Y")
29 {
30 self::updateIBlockProperty($ID, "HIDE", $arFields);
31 }
32 }
33
34 public static function updateIBlockProperty($ID, $TYPE, $arMessage, $arTopic = array())
35 {
36 if ($ID > 0 && $arMessage["PARAM1"] != "IB" && IsModuleInstalled("iblock"))
37 {
38 $arTopic = (empty($arTopic) ? \CForumTopic::GetByID($arMessage["TOPIC_ID"]) : $arTopic);
39 if (!empty($arTopic) && $arTopic["XML_ID"] == "IBLOCK_".$arMessage["PARAM2"] && \CModule::IncludeModule("iblock"))
40 {
41 \CIBlockElement::SetPropertyValuesEx($arMessage["PARAM2"], 0, array(
42 "FORUM_MESSAGE_CNT" => array(
43 "VALUE" => \CForumMessage::GetList(array(), array("TOPIC_ID" => $arMessage["TOPIC_ID"], "APPROVED" => "Y", "!PARAM1" => "IB"), true),
44 "DESCRIPTION" => "",
45 )
46 ));
47 }
48 }
49 }
50
58 public static function onMessageIsIndexed($id, array $message, array &$index)
59 {
60 if (!empty($message["PARAM1"]) && !empty($message["PARAM2"]))
61 return false;
62
63 if (isset($message["XML_ID"]) && !empty($message["XML_ID"]))
64 {
65 if (
66 ($protoEntity = Entity::getEntityByXmlId($message["XML_ID"])) &&
67 (!is_null($protoEntity)) &&
68 (empty($protoEntity["moduleId"]) || Loader::includeModule($protoEntity["moduleId"])) &&
69 is_callable(array($protoEntity["className"], "onmessageisindexed"))
70 )
71 {
72 $b = call_user_func_array(
73 array($protoEntity["className"], "onmessageisindexed"),
74 array($id, $message, &$index)
75 );
76 if ($b === false)
77 return false;
78 }
79 }
80 return true;
81 }
82}
static getEntityByXmlId($xmlId="")
Определения entity.php:225
static updateIBlockPropertyAfterDeletingMessage($ID, $arFields)
Определения eventmanager.php:26
static onMessageIsIndexed($id, array $message, array &$index)
Определения eventmanager.php:58
static updateIBlockProperty($ID, $TYPE, $arMessage, $arTopic=array())
Определения eventmanager.php:34
static updateIBlockPropertyAfterAddingMessage($ID, $arFields, $arTopic=array())
Определения eventmanager.php:18
static includeModule($moduleName)
Определения loader.php:67
static GetByID($ID, $arAddParams=array())
Определения topic.php:431
static GetList($arOrder=Array("ID"=>"ASC"), $arFilter=Array(), $bCount=false, $iNum=0, $arAddParams=array())
Определения message.php:193
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if($ajaxMode) $ID
Определения get_user.php:27
IsModuleInstalled($module_id)
Определения tools.php:5301
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
Определения tools.php:5165
$message
Определения payment.php:8
$TYPE
Определения rss.php:27