<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("forum")) { return; } $arForum = array(); $db_res = CForumNew::GetList(array(), array()); if ($db_res && ($res = $db_res->GetNext())) { do { $arForum[intVal($res["ID"])] = $res["NAME"]; } while ($res = $db_res->GetNext()); } $arComponentParameters = array("GROUPS" => array("URL_TEMPLATES" => array("NAME" => GetMessage("F_URL_TEMPLATES"))), "PARAMETERS" => array("FID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_FID"), "TYPE" => "LIST", "VALUES" => $arForum, "DEFAULT" => '0'), "TID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_TID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["TID"]}'), "MID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_MID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["MID"]}'), "SOCNET_GROUP_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_SOCNET_GROUP_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["SOCNET_GROUP_ID"]}'), "USER_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_USER_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["USER_ID"]}'), "URL_TEMPLATES_TOPIC_LIST" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_LIST_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic_list.php"), "URL_TEMPLATES_TOPIC" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_READ_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic.php?TID=#TID#"), "URL_TEMPLATES_TOPIC_EDIT" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_TOPIC_NEW_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic_edit.php?TID=#TID#&MID=#MID#"), "URL_TEMPLATES_MESSAGE" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_MESSAGE_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "message.php?TID=#TID#&MID=#MID#"), "URL_TEMPLATES_PROFILE_VIEW" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_PROFILE_VIEW_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "profile_view.php?UID=#UID#"), "PAGEN" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGEN"), "TYPE" => "STRING", "DEFAULT" => intVal($GLOBALS["NavNum"] + 1)), "PAGE_NAVIGATION_TEMPLATE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => ""), "PAGE_NAVIGATION_WINDOW" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_WINDOW"), "TYPE" => "STRING", "DEFAULT" => "11"), "PAGE_NAVIGATION_SHOW_ALL" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_SHOW_ALL"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "PATH_TO_SMILE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_DEFAULT_PATH_TO_SMILE"), "TYPE" => "STRING", "DEFAULT" => "/bitrix/images/forum/smile/"), "WORD_LENGTH" => CForumParameters::GetWordLength(), "IMAGE_SIZE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_IMAGE_SIZE"), "TYPE" => "STRING", "DEFAULT" => 500), "MESSAGES_PER_PAGE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_MESSAGES_PER_PAGE"), "TYPE" => "STRING", "DEFAULT" => COption::GetOptionString("forum", "MESSAGES_PER_PAGE", "10")), "DATE_FORMAT" => CForumParameters::GetDateFormat(GetMessage("F_DATE_FORMAT"), "ADDITIONAL_SETTINGS"), "DATE_TIME_FORMAT" => CForumParameters::GetDateTimeFormat(GetMessage("F_DATE_TIME_FORMAT"), "ADDITIONAL_SETTINGS"), "AJAX_TYPE" => CForumParameters::GetAjaxType(), "SET_TITLE" => array(), "CACHE_TIME" => array())); $arComponentParameters["PARAMETERS"]["SHOW_RATING"] = array("NAME" => GetMessage("SHOW_RATING"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("SHOW_RATING_CONFIG"), "Y" => GetMessage("MAIN_YES"), "N" => GetMessage("MAIN_NO")), "MULTIPLE" => "N", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS", "REFRESH" => "Y"); if ($arCurrentValues["SHOW_RATING"] != "N") { $arRatingsList = array(); $db_res = CRatings::GetList($aSort = array("ID" => "ASC"), array("ACTIVE" => "Y", "ENTITY_ID" => "USER")); while ($res = $db_res->Fetch()) { $arRatingsList[$res["ID"]] = "[ " . $res["ID"] . " ] " . $res["NAME"]; } $arComponentParameters["PARAMETERS"]["RATING_ID"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_RATING_ID"), "TYPE" => "LIST", "VALUES" => $arRatingsList, "DEFAULT" => "", "REFRESH" => "N"); $arComponentParameters["PARAMETERS"]["RATING_TYPE"] = array("NAME" => GetMessage("RATING_TYPE"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("RATING_TYPE_CONFIG"), "like" => GetMessage("RATING_TYPE_LIKE_TEXT"), "like_graphic" => GetMessage("RATING_TYPE_LIKE_GRAPHIC"), "standart_text" => GetMessage("RATING_TYPE_STANDART_TEXT"), "standart" => GetMessage("RATING_TYPE_STANDART_GRAPHIC")), "MULTIPLE" => "N", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS"); }
public static function GetAuthorityRating() { global $DB; $authorityRatingId = COption::GetOptionString("main", "rating_authority_rating", null); if (is_null($authorityRatingId)) { $db_res = CRatings::GetList(array("ID" => "ASC"), array("ENTITY_ID" => "USER", "AUTHORITY" => "Y")); $res = $db_res->Fetch(); $authorityRatingId = intval($res['ID']); COption::SetOptionString("main", "rating_authority_rating", $authorityRatingId); } return $authorityRatingId; }
if ($arRes['ACTIVE'] == 'N') { CRatings::Delete($arRes['ID']); } else { $ratingId = $arRes['ID']; } } if ($ratingId == false) { $arConfig = array(); $arConfig['MAIN'] = array('RATING' => array('BONUS' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1'))); $arConfig['FORUM'] = array('VOTE' => array('TOPIC' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '0.5', 'LIMIT' => '30'), 'POST' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '0.1', 'LIMIT' => '30')), 'RATING' => array('ACTIVITY' => array('ACTIVE' => 'Y', 'TODAY_TOPIC_COEF' => '0.4', 'WEEK_TOPIC_COEF' => '0.2', 'MONTH_TOPIC_COEF' => '0.1', 'ALL_TOPIC_COEF' => '0', 'TODAY_POST_COEF' => '0.2', 'WEEK_POST_COEF' => '0.1', 'MONTH_POST_COEF' => '0.05', 'ALL_POST_COEF' => '0'))); $arConfig['BLOG'] = array('VOTE' => array('POST' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1', 'LIMIT' => '30'), 'COMMENT' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1', 'LIMIT' => '30')), 'RATING' => array('ACTIVITY' => array('ACTIVE' => 'Y', 'TODAY_POST_COEF' => '0.4', 'WEEK_POST_COEF' => '0.2', 'MONTH_POST_COEF' => '0.1', 'ALL_POST_COEF' => '0', 'TODAY_COMMENT_COEF' => '0.2', 'WEEK_COMMENT_COEF' => '0.1', 'MONTH_COMMENT_COEF' => '0.05', 'ALL_COMMENT_COEF' => '0'))); $arAddRating = array('ACTIVE' => 'Y', 'NAME' => GetMessage('MAIN_RATING_NAME'), 'ENTITY_ID' => 'USER', 'CALCULATION_METHOD' => 'SUM', 'POSITION' => 'Y', 'AUTHORITY' => 'N', 'CONFIGS' => $arConfig); $ratingId = CRatings::Add($arAddRating); } $authorityId = false; $rsData = CRatings::GetList(array('ID' => 'ASC'), array('AUTHORITY' => 'Y')); if ($arRes = $rsData->Fetch()) { if ($arRes['ACTIVE'] == 'N') { CRatings::Delete($arRes['ID']); } else { $authorityId = $arRes['ID']; } } if ($authorityId == false) { $arConfig = array(); $arConfig['MAIN'] = array('VOTE' => array('USER' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1', 'LIMIT' => '30')), 'RATING' => array('BONUS' => array('ACTIVE' => 'Y', 'COEFFICIENT' => '1'))); $arAddRating = array('ACTIVE' => 'Y', 'NAME' => GetMessage('MAIN_RATING_AUTHORITY'), 'ENTITY_ID' => 'USER', 'CALCULATION_METHOD' => 'SUM', 'POSITION' => 'Y', 'AUTHORITY' => 'Y', 'CONFIGS' => $arConfig); $authorityId = CRatings::Add($arAddRating); } $strSql = "\n\t\t\tINSERT INTO b_rating_user (ENTITY_ID, RATING_ID)\n\t\t\tSELECT \n\t\t\t\tu.ID, '{$authorityId}'\n\t\t\tFROM \n\t\t\t\tb_user u \n\t\t\t\tLEFT JOIN b_rating_user ru ON ru.RATING_ID = {$authorityId} AND ru.ENTITY_ID = u.ID \n\t\t\tWHERE \n\t\t\t\tru.ENTITY_ID IS NULL"; $DB->Query($strSql, false, $err_mess . __LINE__);
$bCreateRule = true; $rsData = $DB->Query("SELECT ID, ACTIVE FROM b_rating_rule WHERE CONDITION_MODULE = 'intranet'"); while ($arRule = $rsData->Fetch()) { if ($arRule["ACTIVE"] == "N") { $DB->Query("DELETE FROM b_rating_rule WHERE ID = " . $arRule["ID"], true); } else { COption::SetOptionString("intranet", "ratingSubordinateId", $arRule['ID']); CRatingRule::Apply($arRule['ID']); $bCreateRule = false; } } // после авторитета if ($bCreateRule) { $dbRes = CLanguage::GetList($by = 'sort', $order = 'asc'); while ($arRes = $dbRes->Fetch()) { if (file_exists(dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php')) { require dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php'; } } $arFields = array("ACTIVE" => "Y", "NAME" => $MESS['INTR_INSTALL_RATING_RULE'], "ENTITY_TYPE_ID" => "USER", "CONDITION_NAME" => "SUBORDINATE", "CONDITION_MODULE" => "intranet", "CONDITION_CLASS" => "CRatingRulesIntranet", "CONDITION_METHOD" => "subordinateCheck", "CONDITION_CONFIG" => array("SUBORDINATE" => array()), "ACTION_NAME" => "empty", "ACTION_CONFIG" => array(), "ACTIVATE" => "N", "ACTIVATE_CLASS" => "empty", "ACTIVATE_METHOD" => "empty", "DEACTIVATE" => "N", "DEACTIVATE_CLASS" => "empty ", "DEACTIVATE_METHOD" => "empty", "~CREATED" => $DB->GetNowFunction(), "~LAST_MODIFIED" => $DB->GetNowFunction()); $arFields["CONDITION_CONFIG"] = serialize($arFields["CONDITION_CONFIG"]); $arFields["ACTION_CONFIG"] = serialize($arFields["ACTION_CONFIG"]); $ID = $DB->Add("b_rating_rule", $arFields, array("ACTION_CONFIG", "CONDITION_CONFIG")); COption::SetOptionString("intranet", "ratingSubordinateId", $ID); CRatingRule::Apply($ID); } // recount ratings $rsData = CRatings::GetList(array('ID' => 'ASC'), array()); while ($arRes = $rsData->Fetch()) { CRatings::Calculate($arRes['ID'], true); }
<td width="50%"><?php echo GetMessage('RATING_SETTINGS_FRM_RATING_WEIGHT_TYPE'); ?> :</td> <td> <?php echo InputType("radio", 'RATING_WEIGHT_TYPE', 'auto', $sRatingWeightType, false, GetMessage('RATING_SETTINGS_FRM_TYPE_AUTO'), "onclick=\"jsTypeChanged('form1')\""); ?> <?php echo InputType("radio", 'RATING_WEIGHT_TYPE', 'manual', $sRatingWeightType, false, GetMessage('RATING_SETTINGS_FRM_TYPE_MANUAL'), "onclick=\"jsTypeChanged('form1')\""); ?> </td> </tr> <? $arRatingsList = array(); $db_res = CRatings::GetList(array("ID" => "ASC"), array("ENTITY_ID" => "USER")); while ($res = $db_res->Fetch()) { $arRatingsList['reference'][] = "[ ".$res["ID"]." ] ".$res["NAME"]; $arRatingsList['reference_id'][] = $res["ID"]; } ?> <tr> <td width="50%"><?php echo GetMessage('RATING_SETTINGS_FRM_RATING_ID'); ?> :</td> <td><?php echo SelectBoxFromArray("RATING_ID", $arRatingsList, $ratingId, "", "onChange=\"jsTypeChanged('form1')\""); ?> </td>
public static function SetAuthorityDefaultValue($arParams) { global $DB; $rsRatings = CRatings::GetList(array('ID' => 'ASC'), array('ENTITY_ID' => 'USER')); while ($arRatingsTmp = $rsRatings->GetNext()) $arRatingList[] = $arRatingsTmp['ID']; if (isset($arParams['DEFAULT_USER_ACTIVE']) && $arParams['DEFAULT_USER_ACTIVE'] == 'Y' && IsModuleInstalled("forum") && is_array($arRatingList) && !empty($arRatingList)) { $ratingStartValue = 0; if (isset($arParams['DEFAULT_CONFIG_NEW_USER']) && $arParams['DEFAULT_CONFIG_NEW_USER'] == 'Y') $ratingStartValue = COption::GetOptionString("main", "rating_start_authority", 3); $strSql = "UPDATE b_rating_user SET BONUS = $ratingStartValue WHERE RATING_ID IN (".implode(',', $arRatingList).")"; $res = $DB->Query($strSql, false, $err_mess.__LINE__); $strSql = " UPDATE b_rating_user RU, ( SELECT TO_USER_ID as ENTITY_ID, COUNT(*) as CNT FROM b_forum_user_points FUP GROUP BY TO_USER_ID ) as RP SET RU.BONUS = ".$DB->IsNull('RP.CNT', '0')."+".$ratingStartValue." WHERE RU.RATING_ID IN (".implode(',', $arRatingList).") and RU.ENTITY_ID = RP.ENTITY_ID "; $res = $DB->Query($strSql, false, $err_mess.__LINE__); } else if (isset($arParams['DEFAULT_CONFIG_NEW_USER']) && $arParams['DEFAULT_CONFIG_NEW_USER'] == 'Y' && is_array($arRatingList) && !empty($arRatingList)) { $ratingStartValue = COption::GetOptionString("main", "rating_start_authority", 3); $strSql = "UPDATE b_rating_user SET BONUS = ".$ratingStartValue." WHERE RATING_ID IN (".implode(',', $arRatingList).")"; $res = $DB->Query($strSql, false, $err_mess.__LINE__); } return true; }
continue; switch($_REQUEST['action']) { case "recalculate": if(!CRatings::Calculate($ID, true)) $lAdmin->AddGroupError(GetMessage("RATING_LIST_ERR_CAL"), $ID); break; case "delete": if(!CRatings::Delete($ID)) $lAdmin->AddGroupError(GetMessage("RATING_LIST_ERR_DEL"), $ID); break; } } } $rsData = CRatings::GetList(array($by=>$order), $arFilter); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("RATING_LIST_NAV"))); $aHeaders = array( array("id"=>"ID", "content"=>"ID", "sort"=>"id", "default"=>true), array("id"=>"NAME", "content"=>GetMessage("RATING_NAME"), "sort"=>"name", "default"=>true), array("id"=>"ACTIVE", "content"=>GetMessage("RATING_ACTIVE"), "sort"=>"active", "default"=>true), array("id"=>"CREATED", "content"=>GetMessage("RATING_CREATED"), "sort"=>"created", "default"=>false), array("id"=>"LAST_MODIFIED", "content"=>GetMessage("RATING_LAST_MODIFIED"), "sort"=>"last_modified", "default"=>true), array("id"=>"LAST_CALCULATED", "content"=>GetMessage("RATING_LAST_CALCULATED"), "sort"=>"last_calculated", "default"=>true), array("id"=>"CALCULATED", "content"=>GetMessage("RATING_STATUS"), "sort"=>"status", "default"=>true), array("id"=>"ENTITY_ID", "content"=>GetMessage("RATING_ENTITY_ID"), "sort"=>"entity_id", "default"=>false), );
$tabControl->AddEditField("WORK_CITY", GetMessage('USER_CITY'), false, array("size"=>30, "maxlength"=>255), $str_WORK_CITY); $tabControl->AddEditField("WORK_ZIP", GetMessage('USER_ZIP'), false, array("size"=>30, "maxlength"=>255), $str_WORK_ZIP); $tabControl->AddTextField("WORK_STREET", GetMessage("USER_STREET"), $str_WORK_STREET, array("cols"=>40, "rows"=>3)); $tabControl->AddEditField("WORK_MAILBOX", GetMessage('USER_MAILBOX'), false, array("size"=>30, "maxlength"=>255), $str_WORK_MAILBOX); $tabControl->AddTextField("WORK_NOTES", GetMessage("USER_NOTES"), $str_WORK_NOTES, array("cols"=>40, "rows"=>5)); $tabControl->BeginNextFormTab(); $tabControl->BeginCustomField("RATING_BOX", GetMessage("USER_RATING_INFO"), false); ?> <tr> <td width="100%" colspan="100%"> <? $i = 1; $aTabs2 = array(); $arRatings = array(); $rsRatings = CRatings::GetList(array('ID' => 'ASC'), array('ACTIVE' => 'Y', 'ENTITY_ID' => 'USER')); while ($arRatingsTmp = $rsRatings->GetNext()) { if ($arRatingsTmp['AUTHORITY'] == 'Y') $arRatingsTmp['NAME'] = '<span class="required">[A]</span> '.$arRatingsTmp['NAME']; $aTabs2[] = array("DIV"=>"rating_".$i, "TAB" => $arRatingsTmp['NAME'], "TITLE" => GetMessage('RATING_TAB_INFO')); $arRatings[$arRatingsTmp['ID']] = $arRatingsTmp; $i++; } if (is_array($arRatings) && !empty($arRatings)) { $ratingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto"); $authorityRatingId = CRatings::GetAuthorityRating(); $arAuthorityUserProp = CRatings::GetRatingUserPropEx($authorityRatingId, $ID);