function ForumActions($action, $arFields, &$strErrorMessage, &$strOKMessage) { $result = false; $sError = ""; $sNote = ""; if (empty($action)) { $sError = GetMessage("FORUM_NO_ACTION"); } else { switch ($action) { case "REPLY": $result = ForumAddMessage("REPLY", $arFields["FID"], $arFields["TID"], 0, $arFields, $sError, $sNote, false, $arFields["captcha_word"], 0, $arFields["captcha_code"], $arFields["NAME_TEMPLATE"]); break; case "DEL": $result = ForumDeleteMessage($arFields["MID"], $sError, $sNote, $arFields); break; case "SHOW": case "HIDE": $result = ForumModerateMessage($arFields["MID"], $action, $sError, $sNote, $arFields); break; case "VOTE4USER": $result = ForumVote4User($arFields["UID"], $arFields["VOTES"], $arFields["VOTE"], $sError, $sNote, $arFields); break; case "FORUM_MESSAGE2SUPPORT": $result = ForumMoveMessage2Support($arFields["MID"], $sError, $sNote, $arFields); break; case "FORUM_SUBSCRIBE": case "TOPIC_SUBSCRIBE": case "FORUM_SUBSCRIBE_TOPICS": $result = ForumSubscribeNewMessagesEx($arFields["FID"], $arFields["TID"], $arFields["NEW_TOPIC_ONLY"], $sError, $sNote); break; case "SET_ORDINARY": case "SET_TOP": case "ORDINARY": case "TOP": if ($action == "SET_ORDINARY") { $action = "ORDINARY"; } elseif ($action == "SET_TOP") { $action = "TOP"; } $result = ForumTopOrdinaryTopic($arFields["TID"], $action, $sError, $sNote, $arFields); break; case "DEL_TOPIC": $result = ForumDeleteTopic($arFields["TID"], $sError, $sNote, $arFields); break; case "OPEN": case "CLOSE": case "STATE_Y": case "STATE_N": if ($action == "STATE_Y") { $action = "OPEN"; } elseif ($action == "STATE_N") { $action = "CLOSE"; } $result = ForumOpenCloseTopic($arFields["TID"], $action, $sError, $sNote, $arFields); break; case "SHOW_TOPIC": case "HIDE_TOPIC": $db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $arFields["TID"], "APPROVED" => $action == "HIDE_TOPIC" ? "Y" : "N")); $message = array(); if ($db_res && ($res = $db_res->Fetch())) { do { $message[] = $res["ID"]; } while ($res = $db_res->Fetch()); } if (!empty($message)) { $s = ""; $result = ForumModerateMessage($message, $action == "HIDE_TOPIC" ? "HIDE" : "SHOW", $sError, $s, $arFields); } else { $result = true; } CForumEventLog::Log("topic", $action == "HIDE_TOPIC" ? "unapprove" : "approve", $arFields["TID"], serialize(CForumTopic::GetByID($arFields["TID"]))); break; case "SPAM_TOPIC": $result = ForumSpamTopic($arFields["TID"], $sError, $sNote, $arFields); break; case "SPAM": $result = ForumSpamMessage($arFields["MID"], $sError, $sNote, $arFields); break; default: $sError = GetMessage("FORUM_NO_ACTION") . " (" . htmlspecialcharsbx($action) . ")"; break; } } $strErrorMessage = $sError; $strOKMessage = $sNote; return $result; }
/** * @deprecated */ public static function Remove($taskId, $commentId, $userId, $arParams) { global $DB; if (self::CanRemoveComment($taskId, $commentId, $userId, $arParams) !== true) { throw new TasksException('', TasksException::TE_ACCESS_DENIED); } $strErrorMessage = $strOKMessage = ''; $result = ForumDeleteMessage($commentId, $strErrorMessage, $strOKMessage, array('PERMISSION' => 'Y')); if ($result) { if (CModule::IncludeModule("socialnetwork")) { $oTask = CTaskItem::getInstance($taskId, CTasksTools::GetCommanderInChief()); $arTask = $oTask->getData(); $bCrmTask = isset($arTask["UF_CRM_TASK"]) && (is_array($arTask["UF_CRM_TASK"]) && (isset($arTask["UF_CRM_TASK"][0]) && strlen($arTask["UF_CRM_TASK"][0]) > 0) || !is_array($arTask["UF_CRM_TASK"]) && strlen($arTask["UF_CRM_TASK"]) > 0); $dbRes = CSocNetLogComments::GetList(array(), array('EVENT_ID' => $bCrmTask ? array('crm_activity_add_comment') : array('tasks_comment'), 'SOURCE_ID' => $commentId), false, false, array('ID')); if ($arRes = $dbRes->Fetch()) { CSocNetLogComments::Delete($arRes['ID']); } } $occurAsUserId = CTasksTools::getOccurAsUserId(); if (!$occurAsUserId) { $occurAsUserId = $userId ? $userId : 1; } // Tasks log $arLogFields = array('TASK_ID' => $taskId, 'USER_ID' => $occurAsUserId, '~CREATED_DATE' => $DB->CurrentTimeFunction(), 'FIELD' => 'COMMENT_REMOVE'); $log = new CTaskLog(); $log->Add($arLogFields); } return $result; }
case "STATE_Y": case "STATE_N": if ($action == "STATE_Y") { $action = "OPEN"; $state = "Y"; } else { $action = "CLOSE"; $state = "N"; } if (ForumOpenCloseTopic($TID, $action, $strErrorMessage, $strOKMessage)) { $arTopic["STATE"] = $state; } LocalRedirect("read.php?FID=" . $FID . "&TID=" . $TID); break; case "DEL": if (ForumDeleteMessage($MID, $strErrorMessage, $strOKMessage)) { $arTopic = CForumTopic::GetByID($TID); if (!$arTopic) { LocalRedirect("list.php?FID=" . $FID); } } LocalRedirect("read.php?FID=" . $FID . "&TID=" . $TID); break; } global $HTTP_GET_VARS; unset($_GET["MID"]); unset($HTTP_GET_VARS["MID"]); unset($_GET["ACTION"]); unset($HTTP_GET_VARS["ACTION"]); } elseif ($_SERVER["REQUEST_METHOD"] == "POST" && check_bitrix_sessid()) { $message = explode(",", $_POST["MID_ARRAY"]);