当前位置: 首页>>代码示例>>PHP>>正文


PHP CRatings::GetByID方法代码示例

本文整理汇总了PHP中CRatings::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CRatings::GetByID方法的具体用法?PHP CRatings::GetByID怎么用?PHP CRatings::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRatings的用法示例。


在下文中一共展示了CRatings::GetByID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isset

    }
}
$bTypeChange = isset($_POST["action"]) && $_POST["action"] == 'type_changed' ? true : false;
$str_NAME = isset($_REQUEST["NAME"]) ? htmlspecialcharsbx($_REQUEST["NAME"]) : GetMessage("RATING_DEF_NAME");
$str_ENTITY_ID = isset($_REQUEST["ENTITY_ID"]) ? htmlspecialcharsbx($_REQUEST["ENTITY_ID"]) : 'USER';
$str_CALCULATION_METHOD = isset($_REQUEST["CALCULATION_METHOD"]) ? IntVal($_REQUEST["CALCULATION_METHOD"]) : '1';
$str_ACTIVE = isset($_REQUEST["ACTIVE"]) && $_REQUEST["ACTIVE"] == 'Y' ? 'Y' : 'N';
$str_POSITION = isset($_REQUEST["POSITION"]) && $_REQUEST["POSITION"] == 'Y' ? 'Y' : 'N';
$str_AUTHORITY = isset($_REQUEST["AUTHORITY"]) && $_REQUEST["AUTHORITY"] == 'Y' ? 'Y' : 'N';
$str_CONFIGS = null;
if ($ID == 0 && empty($_POST)) {
    $str_ACTIVE = 'Y';
    $str_POSITION = 'Y';
}
if ($ID > 0 && !$bTypeChange) {
    $raging = CRatings::GetByID($ID);
    if (!($raging_arr = $raging->ExtractFields("str_"))) {
        $ID = 0;
    }
    $str_CONFIGS = unserialize(htmlspecialcharsback($str_CONFIGS));
}
$sDocTitle = $ID > 0 ? GetMessage("MAIN_RATING_EDIT_RECORD", array("#ID#" => $ID)) : GetMessage("MAIN_RATING_NEW_RECORD");
$APPLICATION->SetTitle($sDocTitle);
$APPLICATION->SetAdditionalCSS("/bitrix/themes/.default/ratings.css");
require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("RATING_LIST"), "TITLE" => GetMessage("RATING_LIST_TITLE"), "LINK" => "rating_list.php?lang=" . LANG, "ICON" => "btn_list"));
if ($ID > 0) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("RATING_EDIT_ADD"), "TITLE" => GetMessage("RATING_EDIT_ADD_TITLE"), "LINK" => "rating_edit.php?lang=" . LANG, "ICON" => "btn_new");
    $aMenu[] = array("TEXT" => GetMessage("RATING_EDIT_DEL"), "TITLE" => GetMessage("RATING_EDIT_DEL_TITLE"), "LINK" => "javascript:if(confirm('" . GetMessage("RATING_EDIT_DEL_CONF") . "')) window.location='rating_list.php?ID=" . $ID . "&action=delete&lang=" . LANG . "&" . bitrix_sessid_get() . "';", "ICON" => "btn_delete");
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:rating_edit.php

示例2: foreach

 if ($arParams["SHOW_RATING"] == 'Y' && array_key_exists("RATING_ID", $arParams)) {
     if (is_array($arParams["RATING_ID"]) && count($arParams["RATING_ID"]) > 0) {
         $arParams["RATING_ID_ARR"] = $arParams["RATING_ID"];
         $arParams["RATING_ID"] = $arParams["RATING_ID_ARR"][0];
         foreach ($arParams["RATING_ID_ARR"] as $rating_id) {
             if (intval($rating_id) > 0) {
                 $db_rating = CRatings::GetByID($rating_id);
                 if ($arRating = $db_rating->GetNext()) {
                     $arResult["RatingMultiple"][$rating_id] = array("NAME" => $arRating["NAME"]);
                 }
                 $arListParams["SELECT"][] = "RATING_" . $rating_id;
             }
         }
         $arResult["Rating"]["NAME"] = $arResult["RatingMultiple"][$arParams["RATING_ID"]]["NAME"];
     } elseif (intval($arParams["RATING_ID"]) > 0) {
         $db_rating = CRatings::GetByID($arParams["RATING_ID"]);
         if ($arRating = $db_rating->GetNext()) {
             $arResult["Rating"]["NAME"] = $arRating["NAME"];
         }
         $arListParams["SELECT"][] = "RATING_" . $arParams["RATING_ID"];
     }
     $dbUser = CUser::GetList($by = "id", $order = "asc", array("ID_EQUAL_EXACT" => $arParams["ID"]), $arListParams);
     $arResult["User"] = $dbUser->GetNext();
 } else {
     $dbUser = CUser::GetByID($arParams["ID"]);
     $arResult["User"] = $dbUser->GetNext();
 }
 if (!is_array($arResult["User"])) {
     $arResult["FatalError"] = GetMessage("SONET_P_USER_NO_USER") . ". ";
 } else {
     if (CModule::IncludeModule('extranet') && !CExtranet::IsProfileViewable($arResult["User"]) && $arResult["User"]["ID"] != $USER->GetID()) {
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例3: BuildRating

	public static function BuildRating($ID)
	{
		global $DB;

		$ID = intval($ID);
		$err_mess = (CRatings::err_mess())."<br>Function: BuildRating<br>Line: ";

		$resRating = CRatings::GetByID($ID);
		$arRating = $resRating->Fetch();
		if ($arRating && $arRating['ACTIVE'] == 'Y') {
			$DB->Query("UPDATE b_rating SET CALCULATED = 'C' WHERE id = ".$ID, false, $err_mess.__LINE__);

			// Insert new results
			$sqlFunc = ($arRating['CALCULATION_METHOD'] == 'SUM') ? 'SUM' : 'AVG';
			$strSql  = "
				INSERT INTO b_rating_results
					(RATING_ID, ENTITY_TYPE_ID, ENTITY_ID, CURRENT_VALUE, PREVIOUS_VALUE)
				SELECT
					".$ID." RATING_ID,
					'".$arRating['ENTITY_ID']."' ENTITY_TYPE_ID,
					RC.ENTITY_ID,
					".$sqlFunc."(RC.CURRENT_VALUE) CURRENT_VALUE,
					0 PREVIOUS_VALUE
				FROM
					b_rating_component_results RC LEFT JOIN b_rating_results RR ON RR.RATING_ID = RC.RATING_ID and RR.ENTITY_ID = RC.ENTITY_ID
				WHERE
					RC.RATING_ID = ".$ID." and RR.ID IS NULL
				GROUP BY RC.ENTITY_ID";
			$res = $DB->Query($strSql, false, $err_mess.__LINE__);

			// Update current results
			$strSql =  "
					UPDATE
						b_rating_results RR,
						(	SELECT '".$arRating['ENTITY_ID']."' ENTITY_TYPE_ID,	RC.ENTITY_ID, ".$sqlFunc."(RC.CURRENT_VALUE) CURRENT_VALUE
							FROM b_rating_component_results RC INNER JOIN b_rating_results RR on RR.RATING_ID = RC.RATING_ID and RR.ENTITY_ID = RC.ENTITY_ID
							WHERE RC.RATING_ID = ".$ID."
							GROUP BY RC.ENTITY_ID
						) as RCR
					SET
						RR.PREVIOUS_VALUE = IF(RR.CURRENT_VALUE = RCR.CURRENT_VALUE, RR.PREVIOUS_VALUE, RR.CURRENT_VALUE),
						RR.CURRENT_VALUE = RCR.CURRENT_VALUE
					WHERE
						RR.RATING_ID=".$ID."
					and	RR.ENTITY_TYPE_ID = RCR.ENTITY_TYPE_ID
					and	RR.ENTITY_ID = RCR.ENTITY_ID
					";
			$res = $DB->Query($strSql, false, $err_mess.__LINE__);

			// Calculation position in rating
			if ($arRating['POSITION'] == 'Y') {
				$strSql =  "
					UPDATE
						b_rating_results RR,
						(	SELECT ENTITY_TYPE_ID, ENTITY_ID, CURRENT_VALUE, @nPos:=@nPos+1  as POSITION
							FROM b_rating_results, (select @nPos:=0) tmp
							WHERE RATING_ID = ".$ID."
							ORDER BY CURRENT_VALUE DESC
						) as RP
					SET
						RR.PREVIOUS_POSITION = IF(RR.CURRENT_POSITION = RP.POSITION, RR.PREVIOUS_POSITION, RR.CURRENT_POSITION),
						RR.CURRENT_POSITION = RP.POSITION
					WHERE
						RR.RATING_ID=".$ID."
					and	RR.ENTITY_TYPE_ID = RP.ENTITY_TYPE_ID
					and	RR.ENTITY_ID = RP.ENTITY_ID
					";
				$res = $DB->Query($strSql, false, $err_mess.__LINE__);
			}

			// Insert new user rating prop
			$strSql  = "
				INSERT INTO b_rating_user
					(RATING_ID, ENTITY_ID)
				SELECT
					".$ID." RATING_ID,
					U.ID as ENTITY_ID
				FROM
					b_user U LEFT JOIN b_rating_user RU ON RU.RATING_ID = ".$ID." and RU.ENTITY_ID = U.ID
				WHERE RU.ID IS NULL	";
			$res = $DB->Query($strSql, false, $err_mess.__LINE__);
			// authority calc
			if ($arRating['AUTHORITY'] == 'Y')
			{
				$sRatingAssignType = COption::GetOptionString("main", "rating_assign_type", "manual");
				if ($sRatingAssignType == 'auto')
				{
					// auto assign for rating group
					$assignRatingGroup = COption::GetOptionString("main", "rating_assign_rating_group", 0);
					$assignRatingValueAdd = COption::GetOptionString("main", "rating_assign_rating_group_add", 1);
					$assignRatingValueDelete = COption::GetOptionString("main", "rating_assign_rating_group_delete", 1);

					CRatings::AutoAssignGroup($assignRatingGroup, $assignRatingValueAdd, $assignRatingValueDelete);

					// auto assign for authority group
					$assignAuthorityGroup = COption::GetOptionString("main", "rating_assign_authority_group", 0);
					$assignAuthorityValueAdd = COption::GetOptionString("main", "rating_assign_authority_group_add", 2);
					$assignAuthorityValueDelete = COption::GetOptionString("main", "rating_assign_authority_group_delete", 2);

					CRatings::AutoAssignGroup($assignAuthorityGroup, $assignAuthorityValueAdd, $assignAuthorityValueDelete);
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:ratings.php


注:本文中的CRatings::GetByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。