Exemplo n.º 1
0
	function CalcUserBonus($arConfigs)
	{
		global $DB;

		$err_mess = (CRatings::err_mess())."<br>Function: CalcUserBonus<br>Line: ";

		$communityLastVisit = COption::GetOptionString("main", "rating_community_last_visit", '90');

		CRatings::AddComponentResults($arConfigs);

		$strSql = "DELETE FROM b_rating_component_results WHERE RATING_ID = '".IntVal($arConfigs['RATING_ID'])."' AND COMPLEX_NAME = '".$DB->ForSql($arConfigs['COMPLEX_NAME'])."'";
		$res = $DB->Query($strSql, false, $err_mess.__LINE__);

		$strSql = "INSERT INTO b_rating_component_results (RATING_ID, MODULE_ID, RATING_TYPE, NAME, COMPLEX_NAME, ENTITY_ID, ENTITY_TYPE_ID, CURRENT_VALUE)
					SELECT
						'".IntVal($arConfigs['RATING_ID'])."'  RATING_ID,
						'".$DB->ForSql($arConfigs['MODULE_ID'])."'  MODULE_ID,
						'".$DB->ForSql($arConfigs['RATING_TYPE'])."'  RATING_TYPE,
						'".$DB->ForSql($arConfigs['NAME'])."'  NAME,
						'".$DB->ForSql($arConfigs['COMPLEX_NAME'])."'  COMPLEX_NAME,
						RB.ENTITY_ID as ENTITY_ID,
						'".$DB->ForSql($arConfigs['ENTITY_ID'])."'  ENTITY_TYPE_ID,
						RB.BONUS*".floatval($arConfigs['CONFIG']['COEFFICIENT'])."  CURRENT_VALUE
					FROM
						b_rating_user RB
						LEFT JOIN b_user U ON U.ID = RB.ENTITY_ID AND U.ACTIVE = 'Y' AND U.LAST_LOGIN > DATE_SUB(NOW(), INTERVAL ".intval($communityLastVisit)." DAY)
					WHERE
						RB.RATING_ID = ".IntVal($arConfigs['RATING_ID'])."
						AND U.ID IS NOT NULL
					";
		$res = $DB->Query($strSql, false, $err_mess.__LINE__);

		return true;
	}
Exemplo n.º 2
0
 function CalcUserRatingForumActivity($arConfigs)
 {
     global $DB;
     $err_mess = CRatings::err_mess() . "<br>Function: CalcUserRatingForumActivity<br>Line: ";
     CRatings::AddComponentResults($arConfigs);
     $strSql = "DELETE FROM b_rating_component_results WHERE RATING_ID = '" . IntVal($arConfigs['RATING_ID']) . "' AND COMPLEX_NAME = '" . $DB->ForSql($arConfigs['COMPLEX_NAME']) . "'";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $sqlAllTopic = '';
     if (isset($arConfigs['CONFIG']['ALL_TOPIC_COEF']) && $arConfigs['CONFIG']['ALL_TOPIC_COEF'] != 0) {
         $sqlAllTopic = "\n\t\t\t\tSELECT\n\t\t\t\t\tUSER_START_ID as ENTITY_ID,\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['ALL_TOPIC_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_forum_topic\n\t\t\t\tWHERE START_DATE  < DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\tGROUP BY USER_START_ID\n\t\t\t\tUNION ALL ";
     }
     $sqlAllMessage = '';
     if (isset($arConfigs['CONFIG']['ALL_POST_COEF']) && $arConfigs['CONFIG']['ALL_POST_COEF'] != 0) {
         $sqlAllMessage = "\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['ALL_POST_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_forum_message\n\t\t\t\tWHERE POST_DATE  < DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\tGROUP BY AUTHOR_ID\n\t\t\t\tUNION ALL ";
     }
     $strSql = "INSERT INTO b_rating_component_results (RATING_ID, MODULE_ID, RATING_TYPE, NAME, COMPLEX_NAME, ENTITY_ID, ENTITY_TYPE_ID, CURRENT_VALUE)\n\t\t\tSELECT\n\t\t\t\t'" . IntVal($arConfigs['RATING_ID']) . "' as RATING_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['MODULE_ID']) . "' as MODULE_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['RATING_TYPE']) . "' as RATING_TYPE,\n\t\t\t\t'" . $DB->ForSql($arConfigs['NAME']) . "' as NAME,\n\t\t\t\t'" . $DB->ForSql($arConfigs['COMPLEX_NAME']) . "' as COMPLEX_NAME,\n\t\t\t\tENTITY_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['ENTITY_ID']) . "'  ENTITY_TYPE_ID,\n\t\t\t\tSUM(CURRENT_VALUE) CURRENT_VALUE\n\t\t\tFROM (\n\t\t\t\t" . $sqlAllMessage . "\n\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tSUM(IF(TO_DAYS(POST_DATE) > TO_DAYS(NOW())-1, 1, 0))*" . floatval($arConfigs['CONFIG']['TODAY_POST_COEF']) . " +\n\t\t\t\t\tSUM(IF(TO_DAYS(POST_DATE) > TO_DAYS(NOW())-7, 1, 0))*" . floatval($arConfigs['CONFIG']['WEEK_POST_COEF']) . "+\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['MONTH_POST_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_forum_message\n\t\t\t\tWHERE POST_DATE  > DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\tGROUP BY AUTHOR_ID\n\n\t\t\t\tUNION ALL\n\t\t\t\t" . $sqlAllTopic . "\n\n\t\t\t\tSELECT\n\t\t\t\t\tUSER_START_ID as ENTITY_ID,\n\t\t\t\t\tSUM(IF(TO_DAYS(START_DATE) > TO_DAYS(NOW())-1, 1, 0))*" . floatval($arConfigs['CONFIG']['TODAY_TOPIC_COEF']) . " +\n\t\t\t\t\tSUM(IF(TO_DAYS(START_DATE) > TO_DAYS(NOW())-7, 1, 0))*" . floatval($arConfigs['CONFIG']['WEEK_TOPIC_COEF']) . " +\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['MONTH_TOPIC_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_forum_topic\n\t\t\t\tWHERE START_DATE  > DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\tGROUP BY USER_START_ID\n\t\t\t) q\n\t\t\tWHERE ENTITY_ID > 0\n\t\t\tGROUP BY ENTITY_ID";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return true;
 }
Exemplo n.º 3
0
 public static function CalcActivity($arConfigs)
 {
     global $DB;
     $err_mess = CRatings::err_mess() . "<br>Function: CRatingsComponentsBlog::CalcActivity<br>Line: ";
     CRatings::AddComponentResults($arConfigs);
     $strSql = "DELETE FROM b_rating_component_results WHERE RATING_ID = '" . IntVal($arConfigs['RATING_ID']) . "' AND COMPLEX_NAME = '" . $DB->ForSql($arConfigs['COMPLEX_NAME']) . "'";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $sqlAllPost = '';
     if (isset($arConfigs['CONFIG']['ALL_POST_COEF']) && $arConfigs['CONFIG']['ALL_POST_COEF'] != 0) {
         $sqlAllPost = "\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['ALL_POST_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_blog_post\n\t\t\t\tWHERE DATE_PUBLISH < DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\t\t\tAND PUBLISH_STATUS = '" . BLOG_PUBLISH_STATUS_PUBLISH . "'\n\t\t\t\tGROUP BY AUTHOR_ID\n\t\t\t\tUNION ALL ";
     }
     $sqlAllComment = '';
     if (isset($arConfigs['CONFIG']['ALL_COMMENT_COEF']) && $arConfigs['CONFIG']['ALL_COMMENT_COEF'] != 0) {
         $sqlAllComment = "\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['ALL_COMMENT_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_blog_comment\n\t\t\t\tWHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\t\tAND PUBLISH_STATUS = '" . BLOG_PUBLISH_STATUS_PUBLISH . "'\n\t\t\t\tGROUP BY AUTHOR_ID\n\t\t\t\tUNION ALL ";
     }
     $strSql = "INSERT INTO b_rating_component_results (RATING_ID, MODULE_ID, RATING_TYPE, NAME, COMPLEX_NAME, ENTITY_ID, ENTITY_TYPE_ID, CURRENT_VALUE)\n\t\t\tSELECT\n\t\t\t\t'" . IntVal($arConfigs['RATING_ID']) . "' as RATING_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['MODULE_ID']) . "' as MODULE_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['RATING_TYPE']) . "' as RATING_TYPE,\n\t\t\t\t'" . $DB->ForSql($arConfigs['NAME']) . "' as NAME,\n\t\t\t\t'" . $DB->ForSql($arConfigs['COMPLEX_NAME']) . "' as COMPLEX_NAME,\n\t\t\t\tENTITY_ID,\n\t\t\t\t'" . $DB->ForSql($arConfigs['ENTITY_ID']) . "'  ENTITY_TYPE_ID,\n\t\t\t\tSUM(CURRENT_VALUE) CURRENT_VALUE\n\t\t\tFROM (\n\t\t\t\t" . $sqlAllPost . "\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tSUM(IF(TO_DAYS(DATE_PUBLISH) > TO_DAYS(NOW())-1, 1, 0))*" . floatval($arConfigs['CONFIG']['TODAY_POST_COEF']) . " +\n\t\t\t\t\tSUM(IF(TO_DAYS(DATE_PUBLISH) > TO_DAYS(NOW())-7, 1, 0))*" . floatval($arConfigs['CONFIG']['WEEK_POST_COEF']) . "+\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['MONTH_POST_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_blog_post\n\t\t\t\tWHERE DATE_PUBLISH  > DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\t\t\tAND PUBLISH_STATUS = '" . BLOG_PUBLISH_STATUS_PUBLISH . "'\n\t\t\t\tGROUP BY AUTHOR_ID\n\n\t\t\t\tUNION ALL\n\t\t\t\t" . $sqlAllComment . "\n\t\t\t\tSELECT\n\t\t\t\t\tAUTHOR_ID as ENTITY_ID,\n\t\t\t\t\tSUM(IF(TO_DAYS(DATE_CREATE) > TO_DAYS(NOW())-1, 1, 0))*" . floatval($arConfigs['CONFIG']['TODAY_COMMENT_COEF']) . " +\n\t\t\t\t\tSUM(IF(TO_DAYS(DATE_CREATE) > TO_DAYS(NOW())-7, 1, 0))*" . floatval($arConfigs['CONFIG']['WEEK_COMMENT_COEF']) . " +\n\t\t\t\t\tCOUNT(*)*" . floatval($arConfigs['CONFIG']['MONTH_COMMENT_COEF']) . " as CURRENT_VALUE\n\t\t\t\tFROM b_blog_comment\n\t\t\t\tWHERE DATE_CREATE  > DATE_SUB(NOW(), INTERVAL 30 DAY)\n\t\t\t\t\tAND PUBLISH_STATUS = '" . BLOG_PUBLISH_STATUS_PUBLISH . "'\n\t\t\t\tGROUP BY AUTHOR_ID\n\t\t\t) q\n\t\t\tWHERE ENTITY_ID > 0\n\t\t\tGROUP BY ENTITY_ID";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return true;
 }