本文整理汇总了PHP中CForumNew::CheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumNew::CheckFields方法的具体用法?PHP CForumNew::CheckFields怎么用?PHP CForumNew::CheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumNew
的用法示例。
在下文中一共展示了CForumNew::CheckFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
function Add($arFields)
{
global $DB;
if (!CForumNew::CheckFields("ADD", $arFields)) {
return false;
}
/***************** Event onBeforeForumAdd **************************/
foreach (GetModuleEvents("forum", "onBeforeForumAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
/***************** /Event ******************************************/
if (empty($arFields)) {
return false;
}
$arInsert = $DB->PrepareInsert("b_forum", $arFields);
$strSql = "INSERT INTO b_forum(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = intVal($DB->LastID());
if ($ID > 0) {
foreach ($arFields["SITES"] as $key => $value) {
$DB->Query("INSERT INTO b_forum2site (FORUM_ID, SITE_ID, PATH2FORUM_MESSAGE) VALUES(" . $ID . ", '" . $DB->ForSql($key, 2) . "', '" . $DB->ForSql($value, 250) . "')", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
if (is_set($arFields, "GROUP_ID") && is_array($arFields["GROUP_ID"])) {
CForumNew::SetAccessPermissions($ID, $arFields["GROUP_ID"]);
}
}
/***************** Event onAfterForumAdd ***************************/
foreach (GetModuleEvents("forum", "onAfterForumAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields));
}
/***************** /Event ******************************************/
return $ID;
}
示例2: SetStat
function SetStat($ID = 0, $arParams = array())
{
global $DB;
$ID = intVal($ID);
if ($ID <= 0) {
return false;
}
$arParams = is_array($arParams) ? $arParams : array();
$arMessage = is_array($arParams["MESSAGE"]) ? $arParams["MESSAGE"] : array();
if ($arMessage["FORUM_ID"] != $ID) {
$arMessage = array();
}
$arForum = CForumNew::GetByID($ID);
$arParams["ACTION"] = $arParams["ACTION"] == "DECREMENT" || $arParams["ACTION"] == "UPDATE" ? $arParams["ACTION"] : "INCREMENT";
$arParams["POSTS"] = intVal($arParams["POSTS"] > 0 ? $arParams["POSTS"] : 1);
$arFields = array();
if (empty($arMessage)) {
// full recount
} elseif ($arParams["ACTION"] == "INCREMENT") {
if ($arMessage["ID"] > $arForum["ABS_LAST_MESSAGE_ID"]) {
$arFields["ABS_LAST_POSTER_ID"] = intVal($arMessage["AUTHOR_ID"]) > 0 ? $arMessage["AUTHOR_ID"] : false;
$arFields["ABS_LAST_POSTER_NAME"] = $arMessage["AUTHOR_NAME"];
$arFields["ABS_LAST_POST_DATE"] = $arMessage["POST_DATE"];
$arFields["ABS_LAST_MESSAGE_ID"] = $arMessage["ID"];
if ($arMessage["APPROVED"] == "Y") {
$arFields["LAST_POSTER_ID"] = $arFields["ABS_LAST_POSTER_ID"];
$arFields["LAST_POSTER_NAME"] = $arFields["ABS_LAST_POSTER_NAME"];
$arFields["LAST_POST_DATE"] = $arFields["ABS_LAST_POST_DATE"];
$arFields["LAST_MESSAGE_ID"] = $arFields["ABS_LAST_MESSAGE_ID"];
}
}
if ($arMessage["APPROVED"] == "Y") {
$arFields["=POSTS"] = "POSTS+1";
if ($arMessage["NEW_TOPIC"] == "Y") {
$arFields["=TOPICS"] = "TOPICS+1";
}
} else {
$arFields["=POSTS_UNAPPROVED"] = "POSTS_UNAPPROVED+1";
}
} elseif ($arMessage["ID"] > $arForum["ABS_LAST_MESSAGE_ID"]) {
// full recount
} elseif ($arParams["ACTION"] == "DECREMENT" && ($arMessage["ID"] == $arForum["ABS_LAST_MESSAGE_ID"] || $arMessage["ID"] == $arForum["LAST_MESSAGE_ID"])) {
// full recount
} elseif ($arParams["ACTION"] == "DECREMENT") {
if ($arMessage["APPROVED"] == "Y") {
$arFields["=POSTS"] = "POSTS-1";
if ($arMessage["NEW_TOPIC"] == "Y") {
$arFields["=TOPICS"] = "TOPICS-1";
}
} else {
$arFields["=POSTS_UNAPPROVED"] = "POSTS_UNAPPROVED-1";
}
} elseif ($arParams["ACTION"] == "UPDATE") {
if ($arMessage["APPROVED"] == "Y") {
if ($arMessage["ID"] > $arForum["LAST_MESSAGE_ID"]) {
$arFields["LAST_POSTER_ID"] = intVal($arMessage["AUTHOR_ID"]) > 0 ? $arMessage["AUTHOR_ID"] : false;
$arFields["LAST_POSTER_NAME"] = $arMessage["AUTHOR_NAME"];
$arFields["LAST_POST_DATE"] = $arMessage["POST_DATE"];
$arFields["LAST_MESSAGE_ID"] = $arMessage["ID"];
}
$arFields["=POSTS"] = "POSTS+1";
$arFields["=POSTS_UNAPPROVED"] = "POSTS_UNAPPROVED-1";
if ($arMessage["NEW_TOPIC"] == "Y") {
$arFields["=TOPICS"] = "TOPICS+1";
}
} elseif ($arMessage["ID"] != $arForum["LAST_MESSAGE_ID"]) {
$arFields["=POSTS"] = "POSTS-1";
$arFields["=POSTS_UNAPPROVED"] = "POSTS_UNAPPROVED+1";
if ($arMessage["NEW_TOPIC"] == "Y") {
$arFields["=TOPICS"] = "TOPICS-1";
}
}
}
if (empty($arFields)) {
$res = CForumMessage::GetList(array(), array("FORUM_ID" => $ID), "cnt_not_approved");
$res = is_array($res) ? $res : array();
$res["CNT"] = intVal($res["CNT"]) - intVal($res["CNT_NOT_APPROVED"]);
$res["CNT"] = $res["CNT"] > 0 ? $res["CNT"] : 0;
$arFields = array("TOPICS" => CForumTopic::GetList(array(), array("FORUM_ID" => $ID, "APPROVED" => "Y"), true), "POSTS" => $res["CNT"], "LAST_POSTER_ID" => false, "LAST_POSTER_NAME" => false, "LAST_POST_DATE" => false, "LAST_MESSAGE_ID" => intVal($res["LAST_MESSAGE_ID"]), "POSTS_UNAPPROVED" => intVal($res["CNT_NOT_APPROVED"]), "ABS_LAST_POSTER_ID" => false, "ABS_LAST_POSTER_NAME" => false, "ABS_LAST_POST_DATE" => false, "ABS_LAST_MESSAGE_ID" => intVal($res["ABS_LAST_MESSAGE_ID"]));
if ($arFields["ABS_LAST_MESSAGE_ID"] > 0) {
$res = CForumMessage::GetByID($arFields["ABS_LAST_MESSAGE_ID"], array("FILTER" => "N"));
$arFields["ABS_LAST_POSTER_ID"] = intVal($res["AUTHOR_ID"]) > 0 ? $res["AUTHOR_ID"] : false;
$arFields["ABS_LAST_POSTER_NAME"] = $res["AUTHOR_NAME"];
$arFields["ABS_LAST_POST_DATE"] = $res["POST_DATE"];
if (intVal($arFields["LAST_MESSAGE_ID"]) > 0) {
if ($arFields["LAST_MESSAGE_ID"] < $arFields["ABS_LAST_MESSAGE_ID"]) {
$res = CForumMessage::GetByID($arFields["LAST_MESSAGE_ID"], array("FILTER" => "N"));
}
$arFields["LAST_POSTER_ID"] = intVal($res["AUTHOR_ID"]) > 0 ? $res["AUTHOR_ID"] : false;
$arFields["LAST_POSTER_NAME"] = $res["AUTHOR_NAME"];
$arFields["LAST_POST_DATE"] = $res["POST_DATE"];
}
}
}
if (!CForumNew::CheckFields("UPDATE", $arFields)) {
return false;
}
$strUpdate = $DB->PrepareUpdate("b_forum", $arFields);
if (!empty($arFields)) {
$res = array();
//.........这里部分代码省略.........