本文整理汇总了PHP中CSocNetLogComments::SendEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetLogComments::SendEvent方法的具体用法?PHP CSocNetLogComments::SendEvent怎么用?PHP CSocNetLogComments::SendEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetLogComments
的用法示例。
在下文中一共展示了CSocNetLogComments::SendEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
function Add($arFields, $bSetSource = false, $bSendEvent = true, $bSetLogUpDate = true)
{
global $DB;
$arFields1 = array();
foreach ($arFields as $key => $value)
{
if (substr($key, 0, 1) == "=")
{
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (
$bSetSource
&& strlen($arFields["EVENT_ID"]) > 0)
{
$arCommentEvent = CSocNetLogTools::FindLogCommentEventByID($arFields["EVENT_ID"]);
if (
!$arCommentEvent
|| !array_key_exists("ADD_CALLBACK", $arCommentEvent)
|| !is_callable($arCommentEvent["ADD_CALLBACK"])
)
{
$bSetSource = false;
}
}
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogCommentAdd");
while ($arEvent = $db_events->Fetch())
{
if (ExecuteModuleEventEx($arEvent, array(&$arFields))===false)
{
return false;
}
}
if ($bSetSource)
{
$arSource = CSocNetLogComments::SetSource($arFields);
if (
$arSource["NO_SOURCE"] == "Y"
|| intval($arSource["SOURCE_ID"]) > 0
)
{
if ($arSource["NO_SOURCE"] == "Y")
$bSetSource = false;
else
$arFields["SOURCE_ID"] = $arSource["SOURCE_ID"];
if (
array_key_exists("RATING_ENTITY_ID", $arSource)
&& array_key_exists("RATING_TYPE_ID", $arSource)
&& intval($arSource["RATING_ENTITY_ID"]) > 0
&& strlen($arSource["RATING_TYPE_ID"]) > 0
)
{
$arFields["RATING_TYPE_ID"] = $arSource["RATING_TYPE_ID"];
$arFields["RATING_ENTITY_ID"] = $arSource["RATING_ENTITY_ID"];
}
if (isset($arSource["MESSAGE"]) && strlen($arSource["MESSAGE"]) > 0)
$arFields["MESSAGE"] = $arSource["MESSAGE"];
if (isset($arSource["TEXT_MESSAGE"]) && strlen($arSource["TEXT_MESSAGE"]) > 0)
$arFields["TEXT_MESSAGE"] = $arSource["TEXT_MESSAGE"];
if (isset($arSource["URL"]) && strlen($arSource["URL"]) > 0)
$arFields["URL"] = $arSource["URL"];
if (
isset($arSource["UF"])
&& isset($arSource["UF"]["FILE"])
)
{
if (!is_array($arSource["UF"]["FILE"]))
$arSource["UF"]["FILE"] = array($arSource["UF"]["FILE"]);
$arFields["UF_SONET_COM_FILE"] = $arSource["UF"]["FILE"];
}
if (
isset($arSource["UF"])
&& isset($arSource["UF"]["DOC"])
)
{
if (!is_array($arSource["UF"]["DOC"]))
$arSource["UF"]["DOC"] = array($arSource["UF"]["DOC"]);
$arFields["UF_SONET_COM_DOC"] = $arSource["UF"]["DOC"];
}
}
else
{
$strMessage =
(
array_key_exists("ERROR", $arSource) && strlen($arSource["ERROR"]) > 0
? $arSource["ERROR"] :
(
//.........这里部分代码省略.........
示例2: Add
function Add($arFields, $bSetSource = false, $bSendEvent = true, $bSetLogUpDate = true)
{
global $DB;
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CSocNetLogComments::CheckFields("ADD", $arFields)) {
return false;
}
$arCommentEvent = CSocNetLogTools::FindLogCommentEventByID($arFields["EVENT_ID"]);
if (!$arCommentEvent || !array_key_exists("ADD_CALLBACK", $arCommentEvent) || !is_callable($arCommentEvent["ADD_CALLBACK"])) {
$bSetSource = false;
}
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogCommentAdd");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
if ($bSetSource) {
$arSource = CSocNetLogComments::SetSource($arFields);
if (intval($arSource["SOURCE_ID"]) > 0) {
$arFields["SOURCE_ID"] = $arSource["SOURCE_ID"];
if (array_key_exists("RATING_ENTITY_ID", $arSource) && array_key_exists("RATING_TYPE_ID", $arSource) && intval($arSource["RATING_ENTITY_ID"]) > 0 && strlen($arSource["RATING_TYPE_ID"]) > 0) {
$arFields["RATING_TYPE_ID"] = $arSource["RATING_TYPE_ID"];
$arFields["RATING_ENTITY_ID"] = $arSource["RATING_ENTITY_ID"];
}
if (isset($arSource["MESSAGE"]) && strlen($arSource["MESSAGE"]) > 0) {
$arFields["MESSAGE"] = $arSource["MESSAGE"];
}
if (isset($arSource["TEXT_MESSAGE"]) && strlen($arSource["TEXT_MESSAGE"]) > 0) {
$arFields["TEXT_MESSAGE"] = $arSource["TEXT_MESSAGE"];
}
} else {
$strMessage = array_key_exists("ERROR", $arSource) && strlen($arSource["ERROR"]) > 0 ? $arSource["ERROR"] : (array_key_exists("NOTES", $arSource) && strlen($arSource["NOTES"]) > 0 ? $arSource["NOTES"] : "");
}
}
if (!$bSetSource || is_array($arSource) && array_key_exists("SOURCE_ID", $arFields) && intval($arFields["SOURCE_ID"]) > 0) {
$arInsert = $DB->PrepareInsert("b_sonet_log_comment", $arFields);
foreach ($arFields1 as $key => $value) {
if (strlen($arInsert[0]) > 0) {
$arInsert[0] .= ", ";
}
$arInsert[0] .= $key;
if (strlen($arInsert[1]) > 0) {
$arInsert[1] .= ", ";
}
$arInsert[1] .= $value;
}
$ID = false;
if (strlen($arInsert[0]) > 0) {
$strSql = "INSERT INTO b_sonet_log_comment(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
if ($ID > 0) {
if (!array_key_exists("RATING_TYPE_ID", $arFields) || empty($arFields["RATING_TYPE_ID"])) {
CSocNetLogComments::Update($ID, array("RATING_TYPE_ID" => "LOG_COMMENT", "RATING_ENTITY_ID" => $ID));
}
CSocNetLogFollow::Set($arFields["USER_ID"], "L" . $arFields["LOG_ID"], "Y");
$rsLog = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "USER_ID"));
if (($arLog = $rsLog->Fetch()) && intval($arLog["USER_ID"]) > 0) {
$default_follow = CSocNetLogFollow::GetDefaultValue($arLog["USER_ID"]);
if ($default_follow != "Y") {
$rsLogFollow = CSocNetLogFollow::GetList(array("USER_ID" => $arLog["USER_ID"], "CODE" => "L" . $arFields["LOG_ID"]), array("TYPE"));
$arLogFoillow = $rsLogFollow->Fetch();
if (!$arLogFoillow) {
CSocNetLogFollow::Set($arLog["USER_ID"], "L" . $arFields["LOG_ID"], "Y");
}
}
}
if ($bSendEvent) {
CSocNetLogComments::SendEvent($ID, "SONET_NEW_EVENT");
}
CSocNetLogComments::UpdateLogData($arFields["LOG_ID"], $bSetLogUpDate);
$db_events = GetModuleEvents("socialnetwork", "OnAfterSocNetLogCommentAdd");
while ($arEvent = $db_events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("SONET_LOG_" . $arFields["LOG_ID"]);
}
}
}
CSocNetLogTools::SetCacheLastLogID("comment", $ID);
return $ID;
} elseif ($bSetSource && strlen($strMessage) > 0) {
return array("ID" => false, "MESSAGE" => $strMessage);
} else {
return false;
}
}