本文整理匯總了PHP中CRatings::Add方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRatings::Add方法的具體用法?PHP CRatings::Add怎麽用?PHP CRatings::Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRatings
的用法示例。
在下文中一共展示了CRatings::Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
$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__);
$arParams = array();
$arParams['DEFAULT_CONFIG_NEW_USER'] = 'Y';
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);
示例2: dirname
##############################################
require_once dirname(__FILE__) . "/../include/prolog_admin_before.php";
ClearVars();
if (!$USER->CanDoOperation('edit_ratings')) {
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
IncludeModuleLangFile(__FILE__);
$ID = intval($ID);
$message = null;
$bVarsFromForm = false;
if ($_SERVER['REQUEST_METHOD'] == "POST" && ($_POST['save'] != "" || $_POST['apply'] != "") && check_bitrix_sessid()) {
$arFields = array("ACTIVE" => isset($_POST['ACTIVE']) ? $_POST['ACTIVE'] : 'N', "NAME" => $_POST['NAME'], "ENTITY_ID" => $_POST['ENTITY_ID'], "CALCULATION_METHOD" => $_POST['CALCULATION_METHOD'], "CONFIGS" => $_POST['CONFIGS'], "POSITION" => isset($_POST['POSITION']) ? 'Y' : 'N', "AUTHORITY" => isset($_POST['AUTHORITY']) ? 'Y' : 'N', "NEW_CALC" => isset($_POST['NEW_CALC']) ? 'Y' : 'N');
if ($ID > 0) {
$res = CRatings::Update($ID, $arFields);
} else {
$ID = CRatings::Add($arFields);
$res = $ID > 0;
}
if ($res) {
if ($apply != "") {
$_SESSION["SESS_ADMIN"]["RATING_EDIT_MESSAGE"] = array("MESSAGE" => GetMessage("RATING_EDIT_SUCCESS"), "TYPE" => "OK");
LocalRedirect("rating_edit.php?ID=" . $ID . "&lang=" . LANG);
} else {
LocalRedirect($_REQUEST["addurl"] != "" ? $_REQUEST["addurl"] : "rating_list.php?lang=" . LANG);
}
} else {
if ($e = $APPLICATION->GetException()) {
$message = new CAdminMessage(GetMessage("RATING_EDIT_ERROR"), $e);
}
$bVarsFromForm = true;
}