public static function Add($arFields) { global $DB; if (!CForumPoints::CheckFields("ADD", $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_forum_points", $arFields); $strSql = "INSERT INTO b_forum_points(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); foreach ($arFields["LANG"] as $i => $val) { $arInsert = $DB->PrepareInsert("b_forum_points_lang", $arFields["LANG"][$i]); $strSql = "INSERT INTO b_forum_points_lang(POINTS_ID, " . $arInsert[0] . ") VALUES(" . $ID . ", " . $arInsert[1] . ")"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } return $ID; }
public static function GetUserRank($USER_ID, $strLang = false) { $USER_ID = intval($USER_ID); $arUser = false; if ($USER_ID <= 0) { return false; } if (COption::GetOptionString("forum", "SHOW_VOTES", "Y") == "Y") { $arUser = CForumUser::GetByUSER_ID($USER_ID); } else { $authorityRatingId = CRatings::GetAuthorityRating(); $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $USER_ID); if (isset($arRatingResult['CURRENT_VALUE'])) { $arUser = array('POINTS' => round(floatval($arRatingResult['CURRENT_VALUE']) / COption::GetOptionString("main", "rating_vote_weight", 1))); } } if ($arUser) { if ($strLang === false || strLen($strLang) != 2) { $db_res = CForumPoints::GetList(array("MIN_POINTS" => "DESC"), array("<=MIN_POINTS" => $arUser["POINTS"])); } else { $db_res = CForumPoints::GetListEx(array("MIN_POINTS" => "DESC"), array("<=MIN_POINTS" => $arUser["POINTS"], "LID" => $strLang)); } if ($db_res && ($ar_res = $db_res->Fetch())) { return $ar_res; } } return false; }
// PointS $db_res = CForumPoints::GetListEx(); if (!$db_res) { $arFieldsG = array(array("MIN_POINTS" => 0, "CODE" => "visitor", "VOTES" => 1, "LANG" => array()), array("MIN_POINTS" => 5, "CODE" => "resident", "VOTES" => 2, "LANG" => array()), array("MIN_POINTS" => 50, "CODE" => "user", "VOTES" => 4, "LANG" => array()), array("MIN_POINTS" => 200, "CODE" => "honored", "VOTES" => 7, "LANG" => array())); foreach ($arFieldsG as $arFields) { foreach ($arLangs as $lang) { $name = GetMessage("F_POINTS_" . strToUpper($arFields["CODE"])); if ($lang != LANGUAGE_ID) { $arMess[$lang] = __GetMessageArray($lang); if (!empty($arMess[$lang]["F_POINTS_" . strToUpper($arFields["CODE"])])) { $name = $arMess[$lang]["F_POINTS_" . strToUpper($arFields["CODE"])]; } } $arFields["LANG"][$lang] = array("LID" => $lang, "NAME" => $name); } $res = CForumPoints::Add($arFields); } } $db_res = CForumPoints2Post::GetList(); if (!($db_res && ($res = $db_res->Fetch()))) { $arFields = array("MIN_NUM_POSTS" => 1, "POINTS_PER_POST" => "0.5000"); CForumPoints2Post::Add($arFields); $arFields = array("MIN_NUM_POSTS" => 50, "POINTS_PER_POST" => "0.8000"); CForumPoints2Post::Add($arFields); } /* User */ $res = CForumUser::GetByUSER_ID(1); if (empty($res) || !is_array($res)) { $arFields = array("=LAST_VISIT" => $DB->GetNowFunction(), "USER_ID" => 1); $ID = CForumUser::Add($arUserFields); }
/** * <p>Изменяет параметры звания с кодом ID на значения, указанные в массиве arFields.</p> * * * * * @param int $ID Код звания. * * * * @param array $arFields Массив новых значений параметров звания. * * * * @return int <p>Функция возвращает код изменяемого звания или false в случае * ошибки.</p> * * @static * @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforumpoints/cforumpoints__update.a5be2bdf.php * @author Bitrix */ public static function Update($ID, $arFields) { global $DB; $ID = intVal($ID); if ($ID <= 0) return False; if (!CForumPoints::CheckFields("UPDATE", $arFields, $ID)) return false; $strUpdate = $DB->PrepareUpdate("b_forum_points", $arFields); $strSql = "UPDATE b_forum_points SET ".$strUpdate." WHERE ID = ".$ID; $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); if (is_set($arFields, "LANG")) { $DB->Query("DELETE FROM b_forum_points_lang WHERE POINTS_ID = ".$ID.""); for ($i = 0; $i<count($arFields["LANG"]); $i++) { $arInsert = $DB->PrepareInsert("b_forum_points_lang", $arFields["LANG"][$i]); $strSql = "INSERT INTO b_forum_points_lang(POINTS_ID, ".$arInsert[0].") VALUES(".$ID.", ".$arInsert[1].")"; $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); } } return $ID; }
if (COption::GetOptionString("forum", "SHOW_VOTES", "Y") == "Y") { $arHeaders[] = array("id" => "MIN_POINTS", "content" => GetMessage("FORUM_P_MIN_POINTS"), "sort" => "MIN_POINTS", "default" => true, "align" => "right"); $arHeaders[] = array("id" => "VOTES", "content" => GetMessage("FORUM_P_VOTES"), "sort" => "VOTES", "default" => true, "align" => "right"); } else { $sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto"); $arHeaders[] = array("id" => "MIN_POINTS", "content" => $sRatingWeightType == 'auto' ? GetMessage("FORUM_P_RATING_VOTES") : GetMessage("FORUM_P_RATING_VALUE"), "sort" => "MIN_POINTS", "default" => true, "align" => "right"); } $lAdmin->AddHeaders($arHeaders); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); /*******************************************************************/ while ($arForum = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arForum); $row->AddField("ID", $f_ID); $row->AddInputField("MIN_POINTS", array("size" => "4")); if (in_array("NAME", $arVisibleColumns)) { $arPointsLang = CForumPoints::GetLangByID($f_ID, LANG); $fieldShow = htmlspecialcharsbx($arPointsLang["NAME"]); $row->AddViewField("NAME", '<a title="' . GetMessage("FORUM_P_EDIT_DESC") . '" href="' . "forum_points_edit.php?ID=" . $f_ID . "&lang=" . LANG . "&" . GetFilterParams("filter_") . '">' . $fieldShow . '</a>'); } $row->AddInputField("VOTES", array("size" => "4")); $arActions = array(); if ($forumModulePermissions >= "R") { $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("FORUM_P_EDIT_DESC"), "ACTION" => $lAdmin->ActionRedirect("forum_points_edit.php?ID=" . $f_ID . "&lang=" . LANG . "&" . GetFilterParams("filter_", false) . ""), "DEFAULT" => true); } if ($forumModulePermissions >= "W") { $arActions[] = array("SEPARATOR" => true); $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("FORUM_P_DELETE_DESC"), "ACTION" => "if(confirm('" . GetMessage('FORUM_P_DELETE_CONF') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete")); } $row->AddActions($arActions); } /*******************************************************************/
<td><?php echo GetMessage("FORUM_PE_VOTES"); ?> :</td> <td> <input type="text" name="VOTES" value="<?php echo htmlspecialcharsEx($str_VOTES); ?> " size="10" /> </td> </tr> <?php } for ($i = 0; $i < count($arSysLangs); $i++) { $arPointsLang = CForumPoints::GetLangByID($ID, $arSysLangs[$i]); $str_NAME = $bInitVars ? ${"NAME_" . $arSysLangs[$i]} : $arPointsLang["NAME"]; ?> <tr class="heading"> <td colspan="2"> [<?php echo $arSysLangs[$i]; ?> ] <?php echo $arSysLangNames[$i]; ?> </td> </tr> <tr class="adm-detail-required-field"> <td> <?php