本文整理汇总了PHP中CRatings::CancelRatingVote方法的典型用法代码示例。如果您正苦于以下问题:PHP CRatings::CancelRatingVote方法的具体用法?PHP CRatings::CancelRatingVote怎么用?PHP CRatings::CancelRatingVote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRatings
的用法示例。
在下文中一共展示了CRatings::CancelRatingVote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddRatingVote
/**
* <p>Метод добавляет голос к рейтинговому голосованию. Динамичный метод.</p>
*
*
* @param array $Param Массив значений параметров. В качестве ключей данного массива
* допустимо использовать: <ul> <li> <b>ENTITY_TYPE_ID</b> – объект голосования.
* Например: FORUM_TOPIC для тем форума, FORUM_POST для сообщений форума, BLOG_POST
* для постов в блоге, BLOG_COMMENT для комментариев в блоге. Сам список
* кодов не регламентирован, можно использовать любой удобный.</li> <li>
* <b>ENTITY_ID</b> – идентификатор объекта голосования</li> <li> <b>VALUE</b> –
* выставленная оценка</li> <li> <b>USER_ID</b> – идентификатор
* пользователя</li> <li> <b>USER_IP</b> – IP-адрес пользователя</li> </ul> Все поля
* являются обязательными.
*
* @return bool
*
* <h4>Example</h4>
* <pre>
* <?
* // добавляем теме отрицательную оценку.
* $arAddVote = array(
* "ENTITY_TYPE_ID" => "FORUM_TOPIC",
* "ENTITY_ID" => 38,
* "VALUE" => -1,
* "USER_ID" => 1,
* "USER_IP" => '127.0.0.1',
* );
* CRatings::AddRatingVote($arAddVote);
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/main/reference/cratings/addratingvote.php
* @author Bitrix
*/
public static function AddRatingVote($arParam)
{
global $DB, $CACHE_MANAGER;
if (isset($_SESSION['RATING_VOTE_COUNT']) && $arParam['ENTITY_TYPE_ID'] == 'USER') {
if ($_SESSION['RATING_VOTE_COUNT'] >= $_SESSION['RATING_USER_VOTE_COUNT']) {
return false;
} else {
$_SESSION['RATING_VOTE_COUNT']++;
}
}
$arParam['ENTITY_TYPE_ID'] = substr($arParam['ENTITY_TYPE_ID'], 0, 50);
CRatings::CancelRatingVote($arParam);
$err_mess = CRatings::err_mess() . "<br>Function: AddRatingVote<br>Line: ";
$votePlus = $arParam['VALUE'] >= 0 ? true : false;
$ratingId = CRatings::GetAuthorityRating();
$arRatingUserProp = CRatings::GetRatingUserProp($ratingId, $arParam['USER_ID']);
$voteUserWeight = $arRatingUserProp['VOTE_WEIGHT'];
$sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto");
if ($sRatingWeightType == 'auto') {
if ($arParam['ENTITY_TYPE_ID'] == 'USER') {
$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);
$arParam['VALUE'] = $arParam['VALUE'] * ($communitySize * ($voteUserWeight / $voteWeight) / $communityAuthority);
}
} else {
$arParam['VALUE'] = $arParam['VALUE'] * $voteUserWeight;
}
} else {
$arParam['VALUE'] = $arParam['VALUE'] * $voteUserWeight;
}
$arFields = array('ACTIVE' => "'Y'", 'TOTAL_VOTES' => "TOTAL_VOTES+1", 'TOTAL_VALUE' => "TOTAL_VALUE" . ($votePlus ? '+' : '') . floatval($arParam['VALUE']), 'LAST_CALCULATED' => $DB->GetNowFunction());
$arFields[$votePlus ? 'TOTAL_POSITIVE_VOTES' : 'TOTAL_NEGATIVE_VOTES'] = $votePlus ? 'TOTAL_POSITIVE_VOTES+1' : 'TOTAL_NEGATIVE_VOTES+1';
// GetOwnerDocument
$arParam['OWNER_ID'] = 0;
foreach (GetModuleEvents("main", "OnGetRatingContentOwner", true) as $arEvent) {
$result = ExecuteModuleEventEx($arEvent, array($arParam));
if ($result !== false) {
$arParam['OWNER_ID'] = IntVal($result);
}
}
$rowAffected = $DB->Update("b_rating_voting", $arFields, "WHERE ENTITY_TYPE_ID='" . $DB->ForSql($arParam['ENTITY_TYPE_ID']) . "' AND ENTITY_ID='" . intval($arParam['ENTITY_ID']) . "'", $err_mess . __LINE__);
if ($rowAffected > 0) {
$rsRV = $DB->Query("SELECT ID, TOTAL_POSITIVE_VOTES FROM b_rating_voting WHERE ENTITY_TYPE_ID='" . $DB->ForSql($arParam['ENTITY_TYPE_ID']) . "' AND ENTITY_ID='" . intval($arParam['ENTITY_ID']) . "'", false, $err_mess . __LINE__);
$arRV = $rsRV->Fetch();
$arParam['RATING_VOTING_ID'] = $arRV['ID'];
$arParam['TOTAL_POSITIVE_VOTES'] = $arRV['TOTAL_POSITIVE_VOTES'];
} else {
$arFields = array("ENTITY_TYPE_ID" => "'" . $DB->ForSql($arParam["ENTITY_TYPE_ID"]) . "'", "ENTITY_ID" => intval($arParam['ENTITY_ID']), "OWNER_ID" => intval($arParam['OWNER_ID']), "ACTIVE" => "'Y'", "CREATED" => $DB->GetNowFunction(), "LAST_CALCULATED" => $DB->GetNowFunction(), "TOTAL_VOTES" => 1, "TOTAL_VALUE" => floatval($arParam['VALUE']), "TOTAL_POSITIVE_VOTES" => $votePlus ? 1 : 0, "TOTAL_NEGATIVE_VOTES" => $votePlus ? 0 : 1);
$arParam['RATING_VOTING_ID'] = $DB->Insert("b_rating_voting", $arFields, $err_mess . __LINE__);
$arParam['TOTAL_POSITIVE_VOTES'] = $votePlus ? 1 : 0;
}
$arFields = array("RATING_VOTING_ID" => intval($arParam['RATING_VOTING_ID']), "ENTITY_TYPE_ID" => "'" . $DB->ForSql($arParam["ENTITY_TYPE_ID"]) . "'", "ENTITY_ID" => intval($arParam['ENTITY_ID']), "VALUE" => floatval($arParam['VALUE']), "ACTIVE" => "'Y'", "CREATED" => $DB->GetNowFunction(), "USER_ID" => intval($arParam['USER_ID']), "USER_IP" => "'" . $DB->ForSql($arParam["USER_IP"]) . "'", "OWNER_ID" => intval($arParam['OWNER_ID']));
$ID = $DB->Insert("b_rating_vote", $arFields, $err_mess . __LINE__);
foreach (GetModuleEvents("main", "OnAddRatingVote", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(intval($ID), $arParam));
}
if (CModule::IncludeModule('pull')) {
CPullStack::AddShared(array('module_id' => 'main', 'command' => 'rating_vote', 'params' => array("TYPE" => "ADD", "USER_ID" => intval($arParam['USER_ID']), "ENTITY_TYPE_ID" => $arParam["ENTITY_TYPE_ID"], "ENTITY_ID" => intval($arParam['ENTITY_ID']), "TOTAL_POSITIVE_VOTES" => $arParam['TOTAL_POSITIVE_VOTES'], "RESULT" => $votePlus ? 'PLUS' : 'MINUS')));
}
if (CACHED_b_rating_vote !== false) {
$bucket_size = intval(CACHED_b_rating_bucket_size);
//.........这里部分代码省略.........
示例2: array
$arParams['TOTAL_NEGATIVE_VOTES'] = 0;
$arParams['USER_HAS_VOTED'] = 'N';
$arParams['USER_VOTE'] = '0';
}
$arAllowVote = CRatings::CheckAllowVote($arParams);
if ($arAllowVote['RESULT']) {
$APPLICATION->RestartBuffer();
$action = 'list';
if ($_POST['RATING_VOTE_ACTION'] == 'plus' || $_POST['RATING_VOTE_ACTION'] == 'minus') {
$arAdd = array("ENTITY_TYPE_ID" => $_POST['RATING_VOTE_TYPE_ID'], "ENTITY_ID" => intval($_POST['RATING_VOTE_ENTITY_ID']), "VALUE" => $_POST['RATING_VOTE_ACTION'] == 'plus' ? 1 : -1, "USER_IP" => $_SERVER['REMOTE_ADDR'], "USER_ID" => $USER->GetId());
CRatings::AddRatingVote($arAdd);
$action = $_POST['RATING_VOTE_ACTION'];
} else {
if ($_POST['RATING_VOTE_ACTION'] == 'cancel') {
$arCancel = array("ENTITY_TYPE_ID" => $_POST['RATING_VOTE_TYPE_ID'], "ENTITY_ID" => intval($_POST['RATING_VOTE_ENTITY_ID']), "USER_ID" => $USER->GetId());
CRatings::CancelRatingVote($arCancel);
$action = $_POST['RATING_VOTE_ACTION'];
}
}
$ar = array("ENTITY_TYPE_ID" => $_POST['RATING_VOTE_TYPE_ID'], "ENTITY_ID" => intval($_POST['RATING_VOTE_ENTITY_ID']), "LIST_LIMIT" => 0, "LIST_TYPE" => isset($_POST['RATING_VOTE_ACTION']) && $_POST['RATING_VOTE_ACTION'] == 'minus' ? 'minus' : 'plus');
$arVoteList = CRatings::GetRatingVoteList($ar);
if ($_POST['RATING_RESULT'] == 'Y') {
$arVoteResult = GetVoteResult($_POST['RATING_VOTE_TYPE_ID'], $_POST['RATING_VOTE_ENTITY_ID']);
$arVoteList = array_merge($arVoteList, $arVoteResult);
}
$arVoteList['action'] = $action;
Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo CUtil::PhpToJsObject($arVoteList);
}
} else {
if ($_POST['RATING_RESULT'] == 'Y' && strlen($_POST['RATING_VOTE_TYPE_ID']) > 0 && intval($_POST['RATING_VOTE_ENTITY_ID']) > 0 && check_bitrix_sessid()) {