本文整理汇总了PHP中CForumUser::GetUserPoints方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumUser::GetUserPoints方法的具体用法?PHP CForumUser::GetUserPoints怎么用?PHP CForumUser::GetUserPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumUser
的用法示例。
在下文中一共展示了CForumUser::GetUserPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetStat
public static function SetStat($USER_ID = 0, $arParams = array())
{
$USER_ID = intVal($USER_ID);
if ($USER_ID <= 0) {
return 0;
}
$bNeedCreateUser = false;
$arUser = array();
$arUserFields = array();
$arParams = is_array($arParams) ? $arParams : array();
$arMessage = is_array($arParams["MESSAGE"]) ? $arParams["MESSAGE"] : array();
$arMessage = $arMessage["AUTHOR_ID"] != $USER_ID ? array() : $arMessage;
if (!empty($arMessage)) {
$arParams["ACTION"] = $arParams["ACTION"] == "DECREMENT" || $arParams["ACTION"] == "UPDATE" ? $arParams["ACTION"] : "INCREMENT";
if ($arParams["ACTION"] == "UPDATE") {
$arParams["ACTION"] = $arMessage["APPROVED"] == "Y" ? "INCREMENT" : "DECREMENT";
$arMessage["APPROVED"] = "Y";
}
$arParams["POSTS"] = intVal($arParams["POSTS"] > 0 ? $arParams["POSTS"] : 1);
$arUser = CForumUser::GetByUSER_ID($USER_ID);
}
if (empty($arMessage)) {
// full recount;
} elseif ($arMessage["APPROVED"] != "Y") {
return true;
} elseif (empty($arUser)) {
$bNeedCreateUser = true;
// full recount;
} elseif ($arParams["ACTION"] == "DECREMENT" && $arMessage["ID"] >= $arUser["LAST_POST"]) {
// full recount;
} elseif ($arParams["ACTION"] == "DECREMENT") {
$arUserFields = array("=NUM_POSTS" => "NUM_POSTS-" . $arParams["POSTS"], "POINTS" => intVal(CForumUser::GetUserPoints($USER_ID, array("DECREMENT" => $arParams["POSTS"]))));
} elseif ($arParams["ACTION"] == "INCREMENT" && $arMessage["ID"] < $arUser["LAST_POST"]) {
$arUserFields = array("=NUM_POSTS" => "NUM_POSTS+" . $arParams["POSTS"], "POINTS" => intVal(CForumUser::GetUserPoints($USER_ID, array("INCREMENT" => $arParams["POSTS"]))));
} elseif ($arParams["ACTION"] == "INCREMENT") {
$arUserFields["IP_ADDRESS"] = $arMessage["AUTHOR_IP"];
$arUserFields["REAL_IP_ADDRESS"] = $arMessage["AUTHOR_REAL_IP"];
$arUserFields["LAST_POST"] = intVal($arMessage["ID"]);
$arUserFields["LAST_POST_DATE"] = $arMessage["POST_DATE"];
$arUserFields["=NUM_POSTS"] = "NUM_POSTS+" . $arParams["POSTS"];
$arUserFields["POINTS"] = intVal(CForumUser::GetUserPoints($USER_ID, array("INCREMENT" => $arParams["POSTS"])));
}
if (empty($arUserFields)) {
$arUserFields = array("LAST_POST" => false, "LAST_POST_DATE" => false);
if ($bNeedCreateUser == false) {
$arUser = CForumUser::GetByUSER_IDEx($USER_ID);
}
if (empty($arUser) || $bNeedCreateUser == true) {
$bNeedCreateUser = true;
$arUser = CForumMessage::GetList(array(), array("AUTHOR_ID" => $USER_ID, "APPROVED" => "Y"), "cnt_and_last_mid");
$arUser = is_array($arUser) ? $arUser : array();
}
$arMessage = CForumMessage::GetByID($arUser["LAST_MESSAGE_ID"], array("FILTER" => "N"));
if ($arMessage) {
$arUserFields["IP_ADDRESS"] = $arMessage["AUTHOR_IP"];
$arUserFields["REAL_IP_ADDRESS"] = $arMessage["AUTHOR_REAL_IP"];
$arUserFields["LAST_POST"] = intVal($arMessage["ID"]);
$arUserFields["LAST_POST_DATE"] = $arMessage["POST_DATE"];
}
$arUserFields["NUM_POSTS"] = intVal($arUser["CNT"]);
$arUserFields["POINTS"] = intVal(CForumUser::GetUserPoints($USER_ID, array("NUM_POSTS" => $arUserFields["NUM_POSTS"])));
}
if ($bNeedCreateUser) {
$arUserFields["USER_ID"] = $USER_ID;
$arUser = CForumUser::Add($arUserFields);
} else {
CForumUser::Update($USER_ID, $arUserFields, false, true);
}
return $USER_ID;
}