Ejemplo n.º 1
0
        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__);
    $arParams = array();
    $arParams['DEFAULT_CONFIG_NEW_USER'] = '******';
    CRatings::SetAuthorityDefaultValue($arParams);
    CRatings::Calculate($authorityId, true);
    CRatings::Calculate($ratingId, true);
    $ratingArray = 'array(1 => "' . $ratingId . '", 2 => "' . $authorityId . '")';
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/forum/index.php", array("SHOW_RATING" => 'Y'));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/forum/index.php", array("RATING_ID" => $ratingArray));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/people/index.php", array("RATING_ID" => $ratingId));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/people/user.php", array("RATING_ID" => $ratingArray));
    CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/groups/group.php", array("RATING_ID" => $ratingId));
    COption::SetOptionString("socialnetwork", "tooltip_rating_id", serialize(array($ratingId, $authorityId)), "", WIZARD_SITE_ID);
    COption::SetOptionString("socialnetwork", "tooltip_show_rating", "Y", "", WIZARD_SITE_ID);
    COption::SetOptionString("main", "rating_normalization", 10);
    COption::SetOptionString("forum", "SHOW_VOTES", "N");
    COption::SetOptionString("main", "rating_vote_type", 'like');
}