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


PHP CRatings::AutoAssignGroup方法代码示例

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


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

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