本文整理汇总了PHP中CRatings::GetAuthorityRating方法的典型用法代码示例。如果您正苦于以下问题:PHP CRatings::GetAuthorityRating方法的具体用法?PHP CRatings::GetAuthorityRating怎么用?PHP CRatings::GetAuthorityRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRatings
的用法示例。
在下文中一共展示了CRatings::GetAuthorityRating方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subordinateCheck
function subordinateCheck($arConfigs)
{
global $DB, $USER_FIELD_MANAGER;
$err_mess = "File: " . __FILE__ . "<br>Function: subordinateCheck<br>Line: ";
$ratingId = CRatings::GetAuthorityRating();
if ($ratingId == 0) {
return true;
}
$maxVotes = $arConfigs['CONDITION_CONFIG']['SUBORDINATE']['MAX_VOTES'];
$type = $arConfigs['CONDITION_CONFIG']['SUBORDINATE']['TYPE'];
$iblockId = COption::GetOptionInt('intranet', 'iblock_structure', 0);
global $DB;
$table = 'b_utm_user';
$columns = array('FIELD_ID', 'VALUE_INT', 'VALUE_ID');
if (!$DB->IndexExists($table, $columns)) {
$DB->Query("create index " . substr("ix_" . mt_rand(0, 1000000) . "_" . $table . "_" . implode("_", $columns), 0, 30) . " on " . $table . "(" . implode(", ", $columns) . ")", true);
}
$table = 'b_uts_iblock_' . $iblockId . '_section';
$columns = array('UF_HEAD');
if (!$DB->IndexExists($table, $columns)) {
$DB->Query("create index " . substr("ix_" . mt_rand(0, 1000000) . "_" . $table . "_" . implode("_", $columns), 0, 30) . " on " . $table . "(" . implode(", ", $columns) . ")", true);
}
$fieldId = 0;
$arUserFields = $USER_FIELD_MANAGER->GetUserFields("USER");
if (isset($arUserFields["UF_DEPARTMENT"]["ID"])) {
$fieldId = intval($arUserFields["UF_DEPARTMENT"]["ID"]);
}
if ($iblockId > 0 && $fieldId > 0) {
// truncate table first
$DB->Query("TRUNCATE TABLE b_rating_subordinate", false, $err_mess . __LINE__);
$squery = "\n\t\t\t\tINSERT INTO b_rating_subordinate (RATING_ID, ENTITY_ID, VOTES)\n\t\t\t\tSELECT '" . intval($ratingId) . "' RATING_ID, U2U.USER_ID ENTITY_ID, (case when U2U.ID > 0 then SUM(" . $DB->IsNull("RU.BONUS", "RUS.BONUS") . ") else RUS.BONUS end) VOTES\n\t\t\t\tFROM\n\t\t\t\t(\n\t\t\t\t\tSELECT DISTINCT U.ID USER_ID, UP.VALUE_ID SUBORDINATE_ID, UD.ID\n\t\t\t\t\tFROM\n\t\t\t\t\tb_user U\n\t\t\t\t\tLEFT JOIN b_utm_user UD ON UD.VALUE_ID = U.ID AND UD.FIELD_ID = " . $fieldId . "\n\t\t\t\t\tLEFT JOIN b_uts_iblock_" . $iblockId . "_section BSSV on BSSV.UF_HEAD = U.ID\n\t\t\t\t\tLEFT JOIN b_iblock_section BS ON BS.ID = BSSV.VALUE_ID\n\t\t\t\t\tLEFT JOIN b_iblock_section BsubS on BsubS.IBLOCK_ID = BS.IBLOCK_ID AND BsubS.LEFT_MARGIN >= BS.LEFT_MARGIN AND BsubS.RIGHT_MARGIN <= BS.RIGHT_MARGIN\n\t\t\t\t\tLEFT JOIN b_uts_iblock_" . $iblockId . "_section NACH_PODOTD on NACH_PODOTD.VALUE_ID = BsubS.ID\n\t\t\t\t\tLEFT JOIN b_utm_user UP on (UP.VALUE_INT = BsubS.ID) OR (UP.VALUE_ID = NACH_PODOTD.UF_HEAD) AND UP.FIELD_ID = " . $fieldId . "\n\t\t\t\t\tLEFT JOIN b_user U2 on U2.ID = UP.VALUE_ID\n\t\t\t\t\tWHERE (U2.ACTIVE = 'Y' OR U2.ID IS NULL) AND U.ACTIVE = 'Y'\n\t\t\t\t) U2U\n\t\t\t\tLEFT JOIN b_rating_user RU on RU.RATING_ID = " . intval($ratingId) . " and RU.ENTITY_ID = U2U.SUBORDINATE_ID\n\t\t\t\tLEFT JOIN b_rating_user RUS on RUS.RATING_ID = " . intval($ratingId) . " and RUS.ENTITY_ID = U2U.USER_ID\n\t\t\t\tGROUP BY U2U.USER_ID, U2U.ID, RU.BONUS, RUS.BONUS";
$DB->Query($squery, false, $err_mess . __LINE__);
}
return true;
}
示例2: voteCheck
function voteCheck($arConfigs)
{
global $DB;
$err_mess = "File: " . __FILE__ . "<br>Function: voteCheck<br>Line: ";
$ratingId = CRatings::GetAuthorityRating();
if ($ratingId == 0) {
return true;
}
// 1. UPDATE OLD VOTE (< 90 day)
$strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_vote\n\t\t\tSET\n\t\t\t\tACTIVE = 'N',\n\t\t\t\tUSER_ID = 0\n\t\t\tWHERE \n\t\t\t\tENTITY_TYPE_ID = 'USER' and CREATED < DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 2. INSERT NEW VOTE FOR AUTHORITY
$sRatingUser = "";
$sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto");
if ($sRatingWeightType == 'auto') {
$sRatingAuthrorityWeight = COption::GetOptionString("main", "rating_authority_weight_formula", 'Y');
if ($sRatingAuthrorityWeight == 'Y') {
$communitySize = COption::GetOptionString("main", "rating_community_size", 1);
$communityAuthority = COption::GetOptionString("main", "rating_community_authority", 1);
$voteWeight = COption::GetOptionString("main", "rating_vote_weight", 1);
$sValue = "({$communitySize}*(RR.VOTE_WEIGHT/" . round($voteWeight, 4) . ")/" . round($communityAuthority) . ") as VALUE";
$ratingId = CRatings::GetAuthorityRating();
$sRatingUser = "LEFT JOIN b_rating_user RR ON RR.RATING_ID = " . intval($ratingId) . " AND RR.ENTITY_ID = RV.USER_ID";
} else {
$sValue = "1 as VALUE";
}
} else {
$ratingId = CRatings::GetAuthorityRating();
$sRatingUser = "LEFT JOIN b_rating_user RR ON RR.RATING_ID = " . intval($ratingId) . " AND RR.ENTITY_ID = RV.USER_ID";
$sValue = "RR.VOTE_WEIGHT as VALUE";
}
$strSql = "\n\t\t\tINSERT INTO b_rating_vote (RATING_VOTING_ID, VALUE, ACTIVE, CREATED, USER_ID, USER_IP, ENTITY_TYPE_ID, ENTITY_ID, OWNER_ID)\n\t\t\tSELECT \n\t\t\t\t0 as RATING_VOTING_ID,\n\t\t\t {$sValue},\n\t\t\t\t'N' as ACTIVE,\n\t\t \t" . $DB->GetNowFunction() . " as CREATED,\n\t\t\t\tRV.USER_ID, \n\t\t\t\t'auto' as USER_IP, \n\t\t\t\t'USER' as ENTITY_TYPE_ID,\n\t\t\t\tRV.OWNER_ID as ENTITY_ID, \n\t\t\t\tRV.OWNER_ID\n\t\t\tFROM \n\t\t\t\tb_rating_vote RV \n\t\t\t\t{$sRatingUser}\n\t\t\t\tLEFT JOIN b_rating_vote RV2 ON RV2.USER_ID = RV.USER_ID AND RV2.ENTITY_TYPE_ID = 'USER' AND RV2.ENTITY_ID = RV.OWNER_ID\n\t\t\tWHERE \n\t\t\t\tRV.CREATED > DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t\tand RV.VALUE > 0 and RV2.VALUE IS NULL and RV.OWNER_ID > 0\n\t\t\tGROUP BY RV.USER_ID, RV.OWNER_ID\n\t\t\tHAVING \n\t\t\t\tSUM(case\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'FORUM_TOPIC' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_FORUM_TOPIC']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'FORUM_POST' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_FORUM_POST']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'BLOG_POST' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_BLOG_POST']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_BLOG_COMMENT']) . "\n\t\t\t\telse 0 end) >= " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_RESULT']) . "\n\t\t";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 3.INSERT NEW VOTING GROUP (FROM STEP 2)
$strSql = "\n\t\t\tINSERT INTO b_rating_voting (ENTITY_TYPE_ID, ENTITY_ID, ACTIVE, CREATED, LAST_CALCULATED, TOTAL_VALUE, TOTAL_VOTES, TOTAL_POSITIVE_VOTES, TOTAL_NEGATIVE_VOTES, OWNER_ID)\n\t\t\tSELECT \n\t\t\t\tRV.ENTITY_TYPE_ID, \n\t\t\t\tRV.ENTITY_ID,\n\t\t\t\t'Y' as ACTIVE,\n\t\t\t\t" . $DB->GetNowFunction() . " as CREATED,\n\t\t\t\t" . $DB->GetNowFunction() . " as LAST_CALCULATED, \n\t\t\t\tSUM(VALUE) as TOTAL_VALUE,\n\t\t\t\tSUM(1) as TOTAL_VOTES,\n\t\t\t\tSUM(case when RV.VALUE > '0' then 1 else 0 end) as TOTAL_POSITIVE_VOTES, \t\n\t\t\t\tSUM(case when RV.VALUE > '0' then 0 else 1 end) as TOTAL_NEGATIVE_VOTES, \t\t\n\t\t\t\tRV.ENTITY_ID as OWNER_ID\n\t\t\tFROM \n\t\t\t\tb_rating_vote RV \n\t\t\t\tLEFT JOIN b_rating_voting RVG ON RVG.ENTITY_TYPE_ID = RV.ENTITY_TYPE_ID AND RVG.ENTITY_ID = RV.ENTITY_ID\n\t\t\tWHERE \n\t\t\t\tRATING_VOTING_ID = 0\n\t\t\tand RV.CREATED > DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t\tand RVG.ID IS NULL and RV.OWNER_ID > 0\n\t\t\tGROUP BY RV.ENTITY_TYPE_ID, RV.ENTITY_ID\n\t\t";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 4 UPDATE FIELD RATING_VOTE_ID (FROM STEP 3)
$strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_vote RV,\n\t\t\t\tb_rating_voting RVG\n\t\t\tSET\n\t\t\t\tRV.RATING_VOTING_ID = RVG.ID,\n\t\t\t\tRV.ACTIVE = 'Y'\n\t\t\tWHERE \n\t\t\t\tRV.ENTITY_TYPE_ID = RVG.ENTITY_TYPE_ID\n\t\t\tand RV.ENTITY_ID = RVG.ENTITY_ID\n\t\t\tand RV.RATING_VOTING_ID = 0";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 5 INSERT TEMP TABLE VOTE RESULTS
$DB->Query("TRUNCATE b_rating_voting_prepare", false, $err_mess . __LINE__);
$strSql = "\n\t\t\tINSERT INTO b_rating_voting_prepare (RATING_VOTING_ID, TOTAL_VALUE, TOTAL_VOTES, TOTAL_POSITIVE_VOTES, TOTAL_NEGATIVE_VOTES)\n\t\t\tSELECT \t\t\t\t\n\t\t\t\tRV.RATING_VOTING_ID,\n\t\t\t\tSUM(RV.VALUE) as TOTAL_VALUE,\n\t\t\t\tSUM(1) as TOTAL_VOTES,\n\t\t\t\tSUM(case when RV.VALUE > '0' then 1 else 0 end) as TOTAL_POSITIVE_VOTES, \t\n\t\t\t\tSUM(case when RV.VALUE > '0' then 0 else 1 end) as TOTAL_NEGATIVE_VOTES \t\t\n\t\t\tFROM \n\t\t\t\tb_rating_vote RV \n\t\t\tWHERE \n\t\t\t\tRV.RATING_VOTING_ID IN (SELECT DISTINCT RV0.RATING_VOTING_ID FROM b_rating_vote RV0 WHERE RV0.ACTIVE='N')\n\t\t\tand RV.USER_ID > 0\n\t\t\tGROUP BY RV.RATING_VOTING_ID";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 6 UPDATE VOTE_RESULTS FROM TEMP TABLE
$strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_voting RVG,\n\t\t\t\tb_rating_voting_prepare RVG0\n\t\t\tSET\n\t\t\t\tRVG.TOTAL_VALUE = RVG0.TOTAL_VALUE,\n\t\t\t\tRVG.TOTAL_VOTES = RVG0.TOTAL_VOTES,\n\t\t\t\tRVG.TOTAL_POSITIVE_VOTES = RVG0.TOTAL_POSITIVE_VOTES,\n\t\t\t\tRVG.TOTAL_NEGATIVE_VOTES = RVG0.TOTAL_NEGATIVE_VOTES\n\t\t\tWHERE \n\t\t\t\tRVG.ID = RVG0.RATING_VOTING_ID";
$DB->Query($strSql, false, $err_mess . __LINE__);
// 7 DELETE OLD POST
$strSql = "DELETE FROM b_rating_vote WHERE ENTITY_TYPE_ID = 'USER' and CREATED < DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)";
$DB->Query($strSql, false, $err_mess . __LINE__);
return true;
}
示例3: ratingCheckInterval
function ratingCheckInterval($arConfigs)
{
global $DB;
$err_mess = "File: " . __FILE__ . "<br>Function: ratingCheckInterval<br>Line: ";
$ruleId = IntVal($arConfigs['ID']);
if (isset($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL'])) {
$ratingValueFrom = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_VALUE_FROM']);
$ratingValueTo = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_VALUE_TO']);
$ratingId = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_ID']);
} else {
$ratingVoteWeight = COption::GetOptionString("main", "rating_vote_weight", 1);
$ratingValueFrom = IntVal($arConfigs['CONDITION_CONFIG']['AUTHORITY_INTERVAL']['RATING_VALUE_FROM']) * $ratingVoteWeight;
$ratingValueTo = IntVal($arConfigs['CONDITION_CONFIG']['AUTHORITY_INTERVAL']['RATING_VALUE_TO']) * $ratingVoteWeight;
$ratingId = CRatings::GetAuthorityRating();
}
$strSql = "INSERT INTO b_rating_rule_vetting (RULE_ID, ENTITY_TYPE_ID, ENTITY_ID)\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t'{$ruleId}' as RULE_ID,\n\t\t\t\t\t\trr.ENTITY_TYPE_ID as ENTITY_TYPE_ID,\n\t\t\t\t\t\trr.ENTITY_ID as ENTITY_ID\n\t\t\t\t\tFROM b_rating_results rr\n\t\t\t\t\tWHERE rr.RATING_ID = {$ratingId}\n\t\t\t\t\t AND rr.CURRENT_VALUE BETWEEN {$ratingValueFrom} AND {$ratingValueTo}";
$res = $DB->Query($strSql, false, $err_mess . __LINE__);
return true;
}
示例4: BuildRSS
//.........这里部分代码省略.........
$arImages = Array();
$dbImages = CBlogImage::GetList(Array(), Array("BLOG_ID" => $blogID, "POST_ID" => $postID, "IS_COMMENT" => "Y", "!COMMENT_ID" => false));
while($arI = $dbImages->Fetch())
$arImages[$arI["ID"]] = $arI["FILE_ID"];
while ($arComments = $dbComments->Fetch())
{
$arDate = ParseDateTime($arComments["DATE_CREATE"], CSite::GetDateFormat("FULL", $arGroup["SITE_ID"]));
$date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
if(strpos($url, "?") !== false)
$url1 = $url."&";
else
$url1 = $url."?";
$url1 .= "commentId=".$arComments["ID"]."#".$arComments["ID"];
$authorURL = "";
if(IntVal($arComments["AUTHOR_ID"]) > 0)
{
$author = CBlogUser::GetUserName($arComments["BLOG_USER_ALIAS"], $arComments["USER_NAME"], $arComments["USER_LAST_NAME"], $arComments["USER_LOGIN"], $arComments["USER_SECOND_NAME"]);
if(strLen($arPathTemplate["PATH_TO_USER"])>0)
$authorURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_USER"], array("user_id"=>$arComments["AUTHOR_ID"])));
else
$authorURL = htmlspecialcharsbx("http://".$serverName.CBlogUser::PreparePath($arComments["AUTHOR_ID"], $arGroup["SITE_ID"]));
}
else
$author = $arComments["AUTHOR_NAME"];
$arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N");
if($arPathTemplate["NO_URL_IN_COMMENTS"] == "L" || (IntVal($arComments["AUTHOR_ID"]) <= 0 && $arPathTemplate["NO_URL_IN_COMMENTS"] == "A"))
$arAllow["CUT_ANCHOR"] = "Y";
if($arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComments["AUTHOR_ID"]) > 0)
{
$authorityRatingId = CRatings::GetAuthorityRating();
$arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComments["AUTHOR_ID"]);
if($arRatingResult["CURRENT_VALUE"] < $arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY"])
$arAllow["CUT_ANCHOR"] = "Y";
}
$text = $parser->convert_to_rss($arComments["POST_TEXT"], $arImages, $arAllow, false, $arParserParams);
$title = GetMessage("BLG_GCM_COMMENT_TITLE", Array("#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"]), "#COMMENT_AUTHOR#" => htmlspecialcharsEx($author)));
/*$title = str_replace(
array("&", "<", ">", "\""),
array("&", "<", ">", """),
$title);
*/
//$text1 = HTMLToTxt($text, "", Array("\ "), 60);
$text = "<![CDATA[".$text."]]>";
if ($type == "rss.92")
{
$rssText .= " <item>\n";
$rssText .= " <title>".$title."</title>\n";
$rssText .= " <description>".$text."</description>\n";
$rssText .= " <link>".$url1."</link>\n";
$rssText .= " </item>\n";
$rssText .= "\n";
}
elseif ($type == "rss2.0")
{
$rssText .= " <item>\n";
$rssText .= " <title>".$title."</title>\n";
$rssText .= " <description>".$text."</description>\n";
$rssText .= " <link>".$url1."</link>\n";
示例5: array
if ($arResult["IDEA_MODERATOR"] && $arResult["Perm"] >= BLOG_PERMS_FULL) {
$arComment["urlToBind"] = $APPLICATION->GetCurPageParam("bind_comment_id=" . $arComment["ID"], $arRemoveUriParams);
}
if ($arResult["IDEA_MODERATOR"] && $arResult["Perm"] >= BLOG_PERMS_FULL) {
$arComment["urlToUnBind"] = $APPLICATION->GetCurPageParam("unbind_comment_id=" . $arComment["ID"], $arRemoveUriParams);
}
}
$arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y");
if (COption::GetOptionString("blog", "allow_video", "Y") != "Y" || $arParams["ALLOW_VIDEO"] != "Y") {
$arAllow["VIDEO"] = "N";
}
if ($arParams["NO_URL_IN_COMMENTS"] == "L" || IntVal($arComment["AUTHOR_ID"]) <= 0 && $arParams["NO_URL_IN_COMMENTS"] == "A") {
$arAllow["CUT_ANCHOR"] = "Y";
}
if ($arParams["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComment["AUTHOR_ID"]) > 0) {
$authorityRatingId = CRatings::GetAuthorityRating();
$arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComment["AUTHOR_ID"]);
if ($arRatingResult["CURRENT_VALUE"] < $arParams["NO_URL_IN_COMMENTS_AUTHORITY"]) {
$arAllow["CUT_ANCHOR"] = "Y";
}
}
$arComment["TextFormated"] = $p->convert($arComment["~POST_TEXT"], false, array(), $arAllow, $arParserParams);
$arComment["DateFormated"] = FormatDate($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arComment["DATE_CREATE"], CSite::GetDateFormat("FULL")));
if ($bUseTitle) {
if (strlen($arComment["TITLE"]) > 0) {
$arComment["TitleFormated"] = $p->convert($arComment["TITLE"], false);
}
if (strpos($arComment["TITLE"], "RE") === false) {
$subj = "RE: " . $arComment["TITLE"];
} else {
if (strpos($arComment["TITLE"], "RE") == 0) {
示例6: OnAfterUserRegister
public static function OnAfterUserRegister($arFields)
{
global $DB;
$err_mess = CRatings::err_mess() . "<br>Function: OnAfterUserRegister<br>Line: ";
$userId = isset($arFields["USER_ID"]) ? intval($arFields["USER_ID"]) : (isset($arFields["ID"]) ? intval($arFields["ID"]) : 0);
if ($userId > 0) {
$authorityRatingId = CRatings::GetAuthorityRating();
$ratingStartValue = COption::GetOptionString("main", "rating_start_authority", 3);
$ratingCountVote = COption::GetOptionString("main", "rating_count_vote", 10);
$arParam = array('RATING_ID' => $authorityRatingId, 'ENTITY_ID' => $userId, 'BONUS' => intval($ratingStartValue), 'VOTE_WEIGHT' => intval($ratingStartValue) * COption::GetOptionString("main", "rating_vote_weight", 1), 'VOTE_COUNT' => intval($ratingCountVote) + intval($ratingStartValue));
CRatings::UpdateRatingUserBonus($arParam);
if (IsModuleInstalled("intranet")) {
$strSql = "INSERT INTO b_rating_subordinate (RATING_ID, ENTITY_ID, VOTES) VALUES ('" . $authorityRatingId . "', '" . $userId . "', '" . (intval($ratingCountVote) + intval($ratingStartValue)) . "')";
$DB->Query($strSql, false, $err_mess . __LINE__);
}
$sRatingAssignType = COption::GetOptionString("main", "rating_assign_type", 'manual');
if ($sRatingAssignType == 'auto') {
$assignRatingGroup = COption::GetOptionString("main", "rating_assign_rating_group", 0);
$assignAuthorityGroup = COption::GetOptionString("main", "rating_assign_authority_group", 0);
if ($assignRatingGroup == 0 && $assignAuthorityGroup == 0) {
return false;
}
$arGroups = array();
$res = CUser::GetUserGroupList($userId);
while ($res_arr = $res->Fetch()) {
$arGroups[] = array("GROUP_ID" => $res_arr["GROUP_ID"], "DATE_ACTIVE_FROM" => $res_arr["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $res_arr["DATE_ACTIVE_TO"]);
}
if ($assignRatingGroup > 0) {
$arGroups[] = array("GROUP_ID" => intval($assignRatingGroup));
}
if ($assignAuthorityGroup > 0 && $assignRatingGroup != $assignAuthorityGroup) {
$arGroups[] = array("GROUP_ID" => intval($assignAuthorityGroup));
}
CUser::SetUserGroup($userId, $arGroups);
}
if (CACHED_b_rating_vote !== false) {
global $CACHE_MANAGER;
$bucket_size = intval(CACHED_b_rating_bucket_size);
if ($bucket_size <= 0) {
$bucket_size = 100;
}
$bucket = intval($userId / $bucket_size);
$CACHE_MANAGER->Clean("b_rvu_" . $authorityRatingId . $bucket, "b_rating_user");
}
}
}
示例7: GetUserRank
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;
}
示例8: AutoAssignGroup
public static function AutoAssignGroup($groupId, $authorityValueAdd, $authorityValueDelete)
{
global $DB;
$err_mess = (CRatings::err_mess())."<br>Function: AutoAssignGroup<br>Line: ";
$groupId = IntVal($groupId);
if ($groupId == 0)
return false;
$ratingId = CRatings::GetAuthorityRating();
$ratingValueAdd = IntVal($authorityValueAdd);
$ratingValueDelete = IntVal($authorityValueDelete);
$sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto");
if ($sRatingWeightType == 'auto') {
$ratingValueAdd = $ratingValueAdd*COption::GetOptionString("main", "rating_vote_weight", 1);
$ratingValueDelete = $ratingValueDelete*COption::GetOptionString("main", "rating_vote_weight", 1);
}
// remove the group from all users who it is, but you need to remove it
$strSql = "
DELETE ug
FROM b_user_group ug
INNER JOIN (
SELECT
rr.ENTITY_ID as USER_ID
FROM
b_rating_results rr
WHERE
rr.RATING_ID = $ratingId
AND rr.CURRENT_VALUE < $ratingValueDelete
) R ON
ug.USER_ID = R.USER_ID AND ug.GROUP_ID = $groupId";
$DB->Query($strSql, false, $err_mess.__LINE__);
// add a group to all users who do not, but you need to add it
$strSql = "
INSERT INTO b_user_group (USER_ID, GROUP_ID)
SELECT
rr.ENTITY_ID, '$groupId'
FROM
b_rating_results rr
LEFT JOIN b_user_group ug ON ug.GROUP_ID = $groupId AND ug.USER_ID = rr.ENTITY_ID
WHERE
rr.RATING_ID = $ratingId
and rr.CURRENT_VALUE >= $ratingValueAdd
and ug.USER_ID IS NULL";
$DB->Query($strSql, false, $err_mess.__LINE__);
return true;
}
示例9: AutoAssignGroup
function AutoAssignGroup($groupId, $authorityValueAdd, $authorityValueDelete)
{
global $DB;
$err_mess = CRatings::err_mess() . "<br>Function: AutoAssignGroup<br>Line: ";
$groupId = IntVal($groupId);
if ($groupId == 0) {
return false;
}
$ratingId = CRatings::GetAuthorityRating();
$ratingValueAdd = IntVal($authorityValueAdd);
$ratingValueDelete = IntVal($authorityValueDelete);
$sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto");
if ($sRatingWeightType == 'auto') {
$ratingValueAdd = $ratingValueAdd * COption::GetOptionString("main", "rating_vote_weight", 1);
$ratingValueDelete = $ratingValueDelete * COption::GetOptionString("main", "rating_vote_weight", 1);
}
// remove the group from all users who it is, but you need to remove it
$strSql = "\n\t\t\tDELETE ug\n\t\t\tFROM b_user_group ug\n\t\t\tINNER JOIN (\n\t\t\t\tSELECT\n\t\t\t\t\trr.ENTITY_ID as USER_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_rating_results rr\n\t\t\t\tWHERE\n\t\t\t\t\trr.RATING_ID = {$ratingId}\n\t\t\t\tAND rr.CURRENT_VALUE < {$ratingValueDelete}\n\t\t\t) R ON\n\t\t\tug.USER_ID = R.USER_ID AND ug.GROUP_ID = {$groupId}";
$DB->Query($strSql, false, $err_mess . __LINE__);
// add a group to all users who do not, but you need to add it
$strSql = "\n\t\t\tINSERT INTO b_user_group (USER_ID, GROUP_ID)\n\t\t\tSELECT\n\t\t\t\trr.ENTITY_ID, '{$groupId}'\n\t\t\tFROM\n\t\t\t\tb_rating_results rr\n\t\t\t\tLEFT JOIN b_user_group ug ON ug.GROUP_ID = {$groupId} AND ug.USER_ID = rr.ENTITY_ID\n\t\t\tWHERE\n\t\t\t\trr.RATING_ID = {$ratingId}\n\t\t\tand rr.CURRENT_VALUE >= {$ratingValueAdd}\n\t\t\tand ug.USER_ID IS NULL";
$DB->Query($strSql, false, $err_mess . __LINE__);
return true;
}
示例10: GetUserAnswerStat
public static function GetUserAnswerStat($arSort = array(), $arFilter = array(), $arParams = array())
{
global $DB, $USER;
$err_mess = self::err_mess() . "<br>Function: GetUserAnswerStat<br>Line: ";
$arFilter = is_array($arFilter) ? $arFilter : array();
if (!is_array($arSort) && $arSort > 0) {
$arFilter["VOTE_ID"] = $arSort;
$arFilter["VALID"] = "Y";
$arSort = array();
}
$arFilter["bGetMemoStat"] = $arFilter["bGetMemoStat"] == "N" ? "N" : "Y";
$arSqlSelect = $arSqlSearch = $arSqlGroup = array();
$strSqlSelect = $strSqlSearch = $strSqlGroup = "";
foreach ($arFilter as $key => $val) {
$key_res = VoteGetFilterOperation($key);
$strNegative = $key_res["NEGATIVE"];
$strOperation = $key_res["OPERATION"];
$key = strtoupper($key_res["FIELD"]);
switch ($key) {
case "ID":
case "VOTE_ID":
case "QUESTION_ID":
case "ANSWER_ID":
case "USER_ID":
case "AUTH_USER_ID":
switch ($key) {
case "ID":
case "VOTE_ID":
$key = "VE." . $key;
break;
case "QUESTION_ID":
$key = "VEQ." . $key;
break;
case "ANSWER_ID":
$key = "VEA." . $key;
break;
case "USER_ID":
case "AUTH_USER_ID":
$key = "VU.AUTH_USER_ID";
break;
}
$str = ($strNegative == "Y" ? "NOT" : "") . "(" . $key . " IS NULL OR " . $key . "<=0)";
if (!empty($val)) {
$str = ($strNegative == "Y" ? " " . $key . " IS NULL OR NOT " : "") . "(" . $key . " " . $strOperation . " " . intVal($val) . ")";
if ($strOperation == "IN") {
$val = array_unique(array_map("intval", is_array($val) ? $val : explode(",", $val)), SORT_NUMERIC);
if (!empty($val)) {
$str = ($strNegative == "Y" ? " NOT " : "") . "(" . $key . " IN (" . implode(",", $val) . "))";
}
}
}
$arSqlSearch[] = $str;
break;
case "VALID":
if (empty($val)) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(VE." . $key . " IS NULL OR LENGTH(VE." . $key . ")<=0)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " VE." . $key . " IS NULL OR NOT " : "") . "(VE." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
}
break;
case "BGETMEMOSTAT":
if ($val == "Y") {
$arSqlGroup[] = $arSqlSelect[] = "VEA.MESSAGE";
$arSqlSearch[] = "VEA.MESSAGE != ' '";
}
break;
case "BGETVOTERS":
$arSqlSearch[] = "VU.AUTH_USER_ID > 0";
$arFilter["bGetVoters"] = intval($val === "Y" ? $USER->GetID() : $val);
break;
case "BGETEVENTRESULTS":
$arFilter["bGetEventResults"] = intval($arFilter["bGetEventResults"]);
if ($arFilter["bGetEventResults"] > 0) {
$arSqlSelect[] = "MAX(CASE WHEN VE.ID=" . $arFilter["bGetEventResults"] . " THEN VEA.ANSWER_ID ELSE NULL END) AS RESTORED_ANSWER_ID";
}
break;
}
}
if (!empty($arSqlSearch)) {
$strSqlSearch = " AND (" . implode(") AND (", $arSqlSearch) . ") ";
}
if (!empty($arSqlSelect)) {
$strSqlSelect = ", " . implode(", ", $arSqlSelect);
}
if (!empty($arSqlGroup)) {
$strSqlGroup = ", " . implode(", ", $arSqlGroup);
}
$strSql = "SELECT VEQ.QUESTION_ID, VEA.ANSWER_ID, COUNT(VEA.ID) as COUNTER, " . "MIN(TIMESTAMPDIFF(SECOND, VE.DATE_VOTE, NOW())) AS LAST_VOTE" . $strSqlSelect . " FROM b_vote_event VE " . " INNER JOIN b_vote_event_question VEQ ON (VEQ.EVENT_ID = VE.ID) " . " INNER JOIN b_vote_event_answer VEA ON (VEA.EVENT_QUESTION_ID = VEQ.ID) " . " LEFT JOIN b_vote_user VU ON (VU.ID = VE.VOTE_USER_ID)" . " WHERE 1=1 " . $strSqlSearch . " GROUP BY VEQ.QUESTION_ID, VEA.ANSWER_ID" . $strSqlGroup . " ORDER BY COUNTER DESC";
if (isset($arFilter["bGetVoters"])) {
$strSql = "SELECT COUNT(VEG.COUNTER) AS CNT FROM (" . "SELECT 'x' AS COUNTER " . " FROM b_vote_event VE " . " INNER JOIN b_vote_event_question VEQ ON (VEQ.EVENT_ID = VE.ID) " . " INNER JOIN b_vote_event_answer VEA ON (VEA.EVENT_QUESTION_ID = VEQ.ID) " . " LEFT JOIN b_vote_user VU ON (VU.ID = VE.VOTE_USER_ID)" . " WHERE 1=1 " . $strSqlSearch . " GROUP BY VEQ.QUESTION_ID, VEA.ANSWER_ID, VU.AUTH_USER_ID" . $strSqlGroup . ") VEG";
$db_res = $DB->Query($strSql);
if ($db_res && ($res = $db_res->Fetch())) {
$strSql = "SELECT VEQ.QUESTION_ID, VEA.ANSWER_ID, VU.AUTH_USER_ID, COUNT(DISTINCT VEA.ID) as COUNTER, \n\t" . "MIN(TIMESTAMPDIFF(SECOND, VE.DATE_VOTE, NOW())) AS LAST_VOTE, \n\t" . ($arFilter["bGetVoters"] > 0 ? "SUM(case when RV0.ID is not null then 1 else 0 end) RANK" : "0 as RANK") . $strSqlSelect . "\n" . "FROM b_vote_event VE \n\t" . "INNER JOIN b_vote_event_question VEQ ON (VEQ.EVENT_ID = VE.ID) \n\t" . "INNER JOIN b_vote_event_answer VEA ON (VEA.EVENT_QUESTION_ID = VEQ.ID) \n\t" . "LEFT JOIN b_vote_user VU ON (VU.ID = VE.VOTE_USER_ID)\n\t" . "LEFT JOIN b_rating_user RV ON (RV.ENTITY_ID = VU.AUTH_USER_ID AND RV.RATING_ID = " . intval(CRatings::GetAuthorityRating()) . ")\n" . ($arFilter["bGetVoters"] > 0 ? "\tLEFT JOIN b_rating_vote RV0 ON (RV0.USER_ID = " . $arFilter["bGetVoters"] . " AND RV0.OWNER_ID = VU.AUTH_USER_ID) \n" : "") . " WHERE 1=1 " . $strSqlSearch . "\n" . " GROUP BY VEQ.QUESTION_ID, VEA.ANSWER_ID, VU.AUTH_USER_ID" . $strSqlGroup . "\n" . " ORDER BY " . (IsModuleInstalled("intranet") ? "RV.VOTE_WEIGHT DESC, RANK DESC" : "RANK DESC, RV.VOTE_WEIGHT DESC") . ", VU.AUTH_USER_ID ASC";
$db_res = new CDBResult();
$db_res->NavQuery($strSql, $res["CNT"], $arParams);
}
} else {
$db_res = $DB->Query($strSql, false, $err_mess . __LINE__);
}
return $db_res;
//.........这里部分代码省略.........