Пример #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;
	}
Пример #2
0
 function subordinateCheck($arConfigs)
 {
     global $DB, $USER_FIELD_MANAGER;
     $err_mess = "File: " . __FILE__ . "<br>Function: subordinateCheck<br>Line: ";
     $ratingId = CRatings::GetAuthorityRating();
     if ($ratingId == 0) {
         return true;
     }
     $maxVotes = $arConfigs['CONDITION_CONFIG']['SUBORDINATE']['MAX_VOTES'];
     $type = $arConfigs['CONDITION_CONFIG']['SUBORDINATE']['TYPE'];
     $iblockId = COption::GetOptionInt('intranet', 'iblock_structure', 0);
     global $DB;
     $table = 'b_utm_user';
     $columns = array('FIELD_ID', 'VALUE_INT', 'VALUE_ID');
     if (!$DB->IndexExists($table, $columns)) {
         $DB->Query("create index " . substr("ix_" . mt_rand(0, 1000000) . "_" . $table . "_" . implode("_", $columns), 0, 30) . " on " . $table . "(" . implode(", ", $columns) . ")", true);
     }
     $table = 'b_uts_iblock_' . $iblockId . '_section';
     $columns = array('UF_HEAD');
     if (!$DB->IndexExists($table, $columns)) {
         $DB->Query("create index " . substr("ix_" . mt_rand(0, 1000000) . "_" . $table . "_" . implode("_", $columns), 0, 30) . " on " . $table . "(" . implode(", ", $columns) . ")", true);
     }
     $fieldId = 0;
     $arUserFields = $USER_FIELD_MANAGER->GetUserFields("USER");
     if (isset($arUserFields["UF_DEPARTMENT"]["ID"])) {
         $fieldId = intval($arUserFields["UF_DEPARTMENT"]["ID"]);
     }
     if ($iblockId > 0 && $fieldId > 0) {
         // truncate table first
         $DB->Query("TRUNCATE TABLE b_rating_subordinate", false, $err_mess . __LINE__);
         $squery = "\n\t\t\t\tINSERT INTO b_rating_subordinate (RATING_ID, ENTITY_ID, VOTES)\n\t\t\t\tSELECT '" . intval($ratingId) . "' RATING_ID, U2U.USER_ID ENTITY_ID, (case when U2U.ID > 0 then SUM(" . $DB->IsNull("RU.BONUS", "RUS.BONUS") . ") else RUS.BONUS end) VOTES\n\t\t\t\tFROM\n\t\t\t\t(\n\t\t\t\t\tSELECT DISTINCT U.ID USER_ID, UP.VALUE_ID SUBORDINATE_ID, UD.ID\n\t\t\t\t\tFROM\n\t\t\t\t\tb_user U\n\t\t\t\t\tLEFT JOIN b_utm_user UD ON UD.VALUE_ID = U.ID AND UD.FIELD_ID = " . $fieldId . "\n\t\t\t\t\tLEFT JOIN b_uts_iblock_" . $iblockId . "_section BSSV on BSSV.UF_HEAD = U.ID\n\t\t\t\t\tLEFT JOIN b_iblock_section BS ON BS.ID = BSSV.VALUE_ID\n\t\t\t\t\tLEFT JOIN b_iblock_section BsubS on BsubS.IBLOCK_ID = BS.IBLOCK_ID AND BsubS.LEFT_MARGIN >= BS.LEFT_MARGIN AND BsubS.RIGHT_MARGIN <= BS.RIGHT_MARGIN\n\t\t\t\t\tLEFT JOIN b_uts_iblock_" . $iblockId . "_section NACH_PODOTD on NACH_PODOTD.VALUE_ID = BsubS.ID\n\t\t\t\t\tLEFT JOIN b_utm_user UP on (UP.VALUE_INT = BsubS.ID) OR (UP.VALUE_ID = NACH_PODOTD.UF_HEAD) AND UP.FIELD_ID = " . $fieldId . "\n\t\t\t\t\tLEFT JOIN b_user U2 on U2.ID = UP.VALUE_ID\n\t\t\t\t\tWHERE (U2.ACTIVE = 'Y' OR U2.ID IS NULL) AND U.ACTIVE = 'Y'\n\t\t\t\t) U2U\n\t\t\t\tLEFT JOIN b_rating_user RU on RU.RATING_ID = " . intval($ratingId) . " and RU.ENTITY_ID = U2U.SUBORDINATE_ID\n\t\t\t\tLEFT JOIN b_rating_user RUS on RUS.RATING_ID = " . intval($ratingId) . " and RUS.ENTITY_ID = U2U.USER_ID\n\t\t\t\tGROUP BY U2U.USER_ID, U2U.ID, RU.BONUS, RUS.BONUS";
         $DB->Query($squery, false, $err_mess . __LINE__);
     }
     return true;
 }
Пример #3
0
 function OnPrepareComments()
 {
     $arResult =& $this->component->arResult;
     $arParams =& $this->component->arParams;
     $arMessages =& $arResult['MESSAGES'];
     $arMessageIDs = array_keys($arMessages);
     $arRatings = CRatings::GetRatingVoteResult('FORUM_POST', $arMessageIDs);
     if ($arRatings) {
         foreach ($arRatings as $postID => $arRating) {
             $this->arRatings[$postID] = $arRating;
         }
     }
 }
Пример #4
0
 function voteCheck($arConfigs)
 {
     global $DB;
     $err_mess = "File: " . __FILE__ . "<br>Function: voteCheck<br>Line: ";
     $ratingId = CRatings::GetAuthorityRating();
     if ($ratingId == 0) {
         return true;
     }
     // 1. UPDATE OLD VOTE (< 90 day)
     $strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_vote\n\t\t\tSET\n\t\t\t\tACTIVE = 'N',\n\t\t\t\tUSER_ID = 0\n\t\t\tWHERE \n\t\t\t\tENTITY_TYPE_ID = 'USER' and CREATED < DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 2. INSERT NEW VOTE FOR AUTHORITY
     $sRatingUser = "";
     $sRatingWeightType = COption::GetOptionString("main", "rating_weight_type", "auto");
     if ($sRatingWeightType == 'auto') {
         $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);
             $sValue = "({$communitySize}*(RR.VOTE_WEIGHT/" . round($voteWeight, 4) . ")/" . round($communityAuthority) . ") as VALUE";
             $ratingId = CRatings::GetAuthorityRating();
             $sRatingUser = "******" . intval($ratingId) . " AND RR.ENTITY_ID = RV.USER_ID";
         } else {
             $sValue = "1 as VALUE";
         }
     } else {
         $ratingId = CRatings::GetAuthorityRating();
         $sRatingUser = "******" . intval($ratingId) . " AND RR.ENTITY_ID = RV.USER_ID";
         $sValue = "RR.VOTE_WEIGHT as VALUE";
     }
     $strSql = "\n\t\t\tINSERT INTO b_rating_vote (RATING_VOTING_ID, VALUE, ACTIVE, CREATED, USER_ID, USER_IP, ENTITY_TYPE_ID, ENTITY_ID, OWNER_ID)\n\t\t\tSELECT \n\t\t\t\t0 as RATING_VOTING_ID,\n\t\t\t   {$sValue},\n\t\t\t\t'N' as ACTIVE,\n\t\t   \t" . $DB->GetNowFunction() . " as CREATED,\n\t\t\t\tRV.USER_ID, \n\t\t\t\t'auto' as USER_IP, \n\t\t\t\t'USER' as ENTITY_TYPE_ID,\n\t\t\t\tRV.OWNER_ID as ENTITY_ID, \n\t\t\t\tRV.OWNER_ID\n\t\t\tFROM  \n\t\t\t\tb_rating_vote RV \n\t\t\t\t{$sRatingUser}\n\t\t\t\tLEFT JOIN b_rating_vote RV2 ON RV2.USER_ID = RV.USER_ID AND RV2.ENTITY_TYPE_ID = 'USER' AND RV2.ENTITY_ID = RV.OWNER_ID\n\t\t\tWHERE \n\t\t\t\tRV.CREATED > DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t\tand RV.VALUE > 0 and RV2.VALUE IS NULL and RV.OWNER_ID > 0\n\t\t\tGROUP BY RV.USER_ID, RV.OWNER_ID\n\t\t\tHAVING \n\t\t\t\tSUM(case\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'FORUM_TOPIC' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_FORUM_TOPIC']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'FORUM_POST' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_FORUM_POST']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'BLOG_POST' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_BLOG_POST']) . "\n\t\t\t\t\twhen RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' then " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_BLOG_COMMENT']) . "\n\t\t\t\telse 0 end) >= " . floatval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_RESULT']) . "\n\t\t";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 3.INSERT NEW VOTING GROUP (FROM STEP 2)
     $strSql = "\n\t\t\tINSERT INTO b_rating_voting (ENTITY_TYPE_ID, ENTITY_ID, ACTIVE, CREATED, LAST_CALCULATED, TOTAL_VALUE, TOTAL_VOTES, TOTAL_POSITIVE_VOTES, TOTAL_NEGATIVE_VOTES, OWNER_ID)\n\t\t\tSELECT \n\t\t\t\tRV.ENTITY_TYPE_ID, \n\t\t\t\tRV.ENTITY_ID,\n\t\t\t\t'Y' as ACTIVE,\n\t\t\t\t" . $DB->GetNowFunction() . " as CREATED,\n\t\t\t\t" . $DB->GetNowFunction() . " as LAST_CALCULATED,  \n\t\t\t\tSUM(VALUE) as TOTAL_VALUE,\n\t\t\t\tSUM(1) as TOTAL_VOTES,\n\t\t\t\tSUM(case when RV.VALUE > '0' then 1 else 0 end) as TOTAL_POSITIVE_VOTES, \t\n\t\t\t\tSUM(case when RV.VALUE > '0' then 0 else 1 end) as TOTAL_NEGATIVE_VOTES, \t\t\n\t\t\t\tRV.ENTITY_ID as OWNER_ID\n\t\t\tFROM  \n\t\t\t\tb_rating_vote RV \n\t\t\t\tLEFT JOIN b_rating_voting RVG ON RVG.ENTITY_TYPE_ID = RV.ENTITY_TYPE_ID AND RVG.ENTITY_ID = RV.ENTITY_ID\n\t\t\tWHERE \n\t\t\t\tRATING_VOTING_ID = 0\n\t\t\tand RV.CREATED > DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)\n\t\t\tand RVG.ID IS NULL and RV.OWNER_ID > 0\n\t\t\tGROUP BY RV.ENTITY_TYPE_ID, RV.ENTITY_ID\n\t\t";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 4 UPDATE FIELD RATING_VOTE_ID (FROM STEP 3)
     $strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_vote RV,\n\t\t\t\tb_rating_voting RVG\n\t\t\tSET\n\t\t\t\tRV.RATING_VOTING_ID = RVG.ID,\n\t\t\t\tRV.ACTIVE = 'Y'\n\t\t\tWHERE \n\t\t\t\tRV.ENTITY_TYPE_ID = RVG.ENTITY_TYPE_ID\n\t\t\tand RV.ENTITY_ID = RVG.ENTITY_ID\n\t\t\tand RV.RATING_VOTING_ID = 0";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 5 INSERT TEMP TABLE VOTE RESULTS
     $DB->Query("TRUNCATE b_rating_voting_prepare", false, $err_mess . __LINE__);
     $strSql = "\n\t\t\tINSERT INTO b_rating_voting_prepare (RATING_VOTING_ID, TOTAL_VALUE, TOTAL_VOTES, TOTAL_POSITIVE_VOTES, TOTAL_NEGATIVE_VOTES)\n\t\t\tSELECT \t\t\t\t\n\t\t\t\tRV.RATING_VOTING_ID,\n\t\t\t\tSUM(RV.VALUE) as TOTAL_VALUE,\n\t\t\t\tSUM(1) as TOTAL_VOTES,\n\t\t\t\tSUM(case when RV.VALUE > '0' then 1 else 0 end) as TOTAL_POSITIVE_VOTES, \t\n\t\t\t\tSUM(case when RV.VALUE > '0' then 0 else 1 end) as TOTAL_NEGATIVE_VOTES \t\t\n\t\t\tFROM  \n\t\t\t\tb_rating_vote RV \n\t\t\tWHERE \n\t\t\t\tRV.RATING_VOTING_ID IN (SELECT DISTINCT RV0.RATING_VOTING_ID FROM b_rating_vote RV0 WHERE RV0.ACTIVE='N')\n\t\t\tand RV.USER_ID > 0\n\t\t\tGROUP BY RV.RATING_VOTING_ID";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 6 UPDATE VOTE_RESULTS FROM TEMP TABLE
     $strSql = "\n\t\t\tUPDATE\n\t\t\t\tb_rating_voting RVG,\n\t\t\t\tb_rating_voting_prepare RVG0\n\t\t\tSET\n\t\t\t\tRVG.TOTAL_VALUE = RVG0.TOTAL_VALUE,\n\t\t\t\tRVG.TOTAL_VOTES = RVG0.TOTAL_VOTES,\n\t\t\t\tRVG.TOTAL_POSITIVE_VOTES = RVG0.TOTAL_POSITIVE_VOTES,\n\t\t\t\tRVG.TOTAL_NEGATIVE_VOTES = RVG0.TOTAL_NEGATIVE_VOTES\n\t\t\tWHERE \n\t\t\t\tRVG.ID = RVG0.RATING_VOTING_ID";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     // 7 DELETE OLD POST
     $strSql = "DELETE FROM b_rating_vote WHERE ENTITY_TYPE_ID = 'USER' and CREATED < DATE_SUB(NOW(), INTERVAL " . intval($arConfigs['CONDITION_CONFIG']['VOTE']['VOTE_LIMIT']) . " DAY)";
     $DB->Query($strSql, false, $err_mess . __LINE__);
     return true;
 }
Пример #5
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;
 }
Пример #6
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;
 }
Пример #7
0
 function ratingCheckInterval($arConfigs)
 {
     global $DB;
     $err_mess = "File: " . __FILE__ . "<br>Function: ratingCheckInterval<br>Line: ";
     $ruleId = IntVal($arConfigs['ID']);
     if (isset($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL'])) {
         $ratingValueFrom = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_VALUE_FROM']);
         $ratingValueTo = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_VALUE_TO']);
         $ratingId = IntVal($arConfigs['CONDITION_CONFIG']['RATING_INTERVAL']['RATING_ID']);
     } else {
         $ratingVoteWeight = COption::GetOptionString("main", "rating_vote_weight", 1);
         $ratingValueFrom = IntVal($arConfigs['CONDITION_CONFIG']['AUTHORITY_INTERVAL']['RATING_VALUE_FROM']) * $ratingVoteWeight;
         $ratingValueTo = IntVal($arConfigs['CONDITION_CONFIG']['AUTHORITY_INTERVAL']['RATING_VALUE_TO']) * $ratingVoteWeight;
         $ratingId = CRatings::GetAuthorityRating();
     }
     $strSql = "INSERT INTO b_rating_rule_vetting (RULE_ID, ENTITY_TYPE_ID, ENTITY_ID)\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t'{$ruleId}' as RULE_ID,\n\t\t\t\t\t\trr.ENTITY_TYPE_ID as ENTITY_TYPE_ID,\n\t\t\t\t\t\trr.ENTITY_ID as ENTITY_ID\n\t\t\t\t\tFROM b_rating_results rr\n\t\t\t\t\tWHERE rr.RATING_ID = {$ratingId}\n\t\t\t\t\t  AND rr.CURRENT_VALUE BETWEEN {$ratingValueFrom} AND {$ratingValueTo}";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     return true;
 }
Пример #8
0
function GetVoteResult($entityTypeId, $entityId)
{
    global $USER;
    $entityId = intval($entityId);
    $userId = intval($USER->GetId());
    $arRatingResult = CRatings::GetRatingVoteResult($entityTypeId, $entityId, $userId);
    if (empty($arRatingResult)) {
        $arRatingResult['USER_HAS_VOTED'] = $USER->IsAuthorized() ? "N" : "Y";
        $arRatingResult['USER_VOTE'] = 0;
        $arRatingResult['TOTAL_VALUE'] = 0;
        $arRatingResult['TOTAL_VOTES'] = 0;
        $arRatingResult['TOTAL_POSITIVE_VOTES'] = 0;
        $arRatingResult['TOTAL_NEGATIVE_VOTES'] = 0;
    }
    $path = str_replace(array("\\", "//"), "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/vote.ajax.php");
    include_once $path;
    $resultStatus = $arRatingResult['TOTAL_VALUE'] < 0 ? 'minus' : 'plus';
    $resultTitle = sprintf($MESS["RATING_COMPONENT_DESC"], $arRatingResult['TOTAL_VOTES'], $arRatingResult['TOTAL_POSITIVE_VOTES'], $arRatingResult['TOTAL_NEGATIVE_VOTES']);
    return array('resultValue' => $arRatingResult['TOTAL_VALUE'], 'resultVotes' => $arRatingResult['TOTAL_VOTES'], 'resultPositiveVotes' => $arRatingResult['TOTAL_POSITIVE_VOTES'], 'resultNegativeVotes' => $arRatingResult['TOTAL_NEGATIVE_VOTES'], 'resultStatus' => $resultStatus, 'resultTitle' => $resultTitle);
}
Пример #9
0
        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'] = '******';
    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);
    COption::SetOptionString("socialnetwork", "tooltip_show_rating", "Y", "", WIZARD_SITE_ID);
    COption::SetOptionString("main", "rating_normalization", 10);
    COption::SetOptionString("forum", "SHOW_VOTES", "N");
    COption::SetOptionString("main", "rating_vote_type", 'like');
}
Пример #10
0
	public static function BuildRSS($postID, $blogID, $type = "RSS2.0", $numPosts = 10, $arPathTemplate = Array())
	{
		$blogID = IntVal($blogID);
		$postID = IntVal($postID);
		if($blogID <= 0)
			return false;
		if($postID <= 0)
			return false;
		$numPosts = IntVal($numPosts);
		$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
		if ($type != "rss.92" && $type != "atom.03")
			$type = "rss2.0";

		$rssText = False;

		$arBlog = CBlog::GetByID($blogID);
		if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y")
		{
			$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
			if($arGroup["SITE_ID"] == SITE_ID)
			{
				$arPost = CBlogPost::GetByID($postID);
				if(!empty($arPost) && $arPost["BLOG_ID"] == $arBlog["ID"] && $arPost["ENABLE_COMMENTS"] == "Y")
				{
					$now = date("r");
					$nowISO = date("Y-m-d\TH:i:s").substr(date("O"), 0, 3).":".substr(date("O"), -2, 2);

					$serverName = "";
					$charset = "";
					$language = "";
					$dbSite = CSite::GetList(($b = "sort"), ($o = "asc"), array("LID" => SITE_ID));
					if ($arSite = $dbSite->Fetch())
					{
						$serverName = $arSite["SERVER_NAME"];
						$charset = $arSite["CHARSET"];
						$language = $arSite["LANGUAGE_ID"];
					}

					if (strlen($serverName) <= 0)
					{
						if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
							$serverName = SITE_SERVER_NAME;
						else
							$serverName = COption::GetOptionString("main", "server_name", "");
					}

					if (strlen($charset) <= 0)
					{
						if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0)
							$charset = SITE_CHARSET;
						else
							$charset = "windows-1251";
					}

					if(strlen($arPathTemplate["PATH_TO_BLOG"])>0)
						$blogURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
					else
						$blogURL = htmlspecialcharsbx("http://".$serverName.CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"]));

					if(strlen($arPathTemplate["PATH_TO_POST"])>0)
						$url = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplate["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
					else
						$url = htmlspecialcharsbx("http://".$serverName.CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], $arGroup["SITE_ID"]));

					$dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
					$arUser = $dbUser->Fetch();

					if($arPathTemplate["USE_SOCNET"] == "Y")
					{
						$blogName = GetMessage("BLG_GCM_RSS_TITLE_SOCNET", Array("#AUTHOR_NAME#" => htmlspecialcharsEx($arUser["NAME"]." ".$arUser["LAST_NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
					}
					else
					{
						$blogName = GetMessage("BLG_GCM_RSS_TITLE", Array("#BLOG_NAME#" => htmlspecialcharsEx($arBlog["NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
					}

					$rssText = "";
					if ($type == "rss.92")
					{
						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<rss version=\".92\">\n";
						$rssText .= " <channel>\n";
						$rssText .= "	<title>".$blogName."</title>\n";
						$rssText .= "	<description>".$blogName."</description>\n";
						$rssText .= "	<link>".$url."</link>\n";
						$rssText .= "	<language>".$language."</language>\n";
						$rssText .= "	<docs>http://backend.userland.com/rss092</docs>\n";
						$rssText .= "\n";
					}
					elseif ($type == "rss2.0")
					{
						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<rss version=\"2.0\">\n";
						$rssText .= " <channel>\n";
						$rssText .= "	<title>".$blogName."</title>\n";
						$rssText .= "	<description>".$blogName."</description>\n";
						//$rssText .= "	<guid>".$url."</guid>\n";
						$rssText .= "	<link>".$url."</link>\n";
						$rssText .= "	<language>".$language."</language>\n";
						$rssText .= "	<docs>http://backend.userland.com/rss2</docs>\n";
						$rssText .= "	<pubDate>".$now."</pubDate>\n";
						$rssText .= "\n";
					}
					elseif ($type == "atom.03")
					{
						$atomID = "tag:".htmlspecialcharsbx($serverName).",".date("Y-m-d").":".$postID;

						$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
						$rssText .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\" xml:lang=\"".$language."\">\n";
						$rssText .= "  <title>".$blogName."</title>\n";
						$rssText .= "  <tagline>".$url."</tagline>\n";
						$rssText .= "  <id>".$atomID."</id>\n";
						$rssText .= "  <link rel=\"alternate\" type=\"text/html\" href=\"".$url."\" />\n";
						$rssText .= "  <modified>".$nowISO."</modified>\n";

						$BlogUser = CBlogUser::GetByID($arPost["AUTHOR_ID"], BLOG_BY_USER_ID);
						$authorP = htmlspecialcharsex(CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"], $arUser["SECOND_NAME"]));
						if(strLen($arPathTemplate["PATH_TO_USER"])>0)
							$authorURLP = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_USER"], array("user_id"=>$arPost["AUTHOR_ID"])));
						else
							$authorURLP = "http://".$serverName.CBlogUser::PreparePath($arPost["AUTHOR_ID"], $arGroup["SITE_ID"]);

						$rssText .= "  <author>\n";
						$rssText .= "  		<name>".$authorP."</name>\n";
						$rssText .= "  		<uri>".$authorURLP."</uri>\n";
						$rssText .= "  </author>\n";

						$rssText .= "\n";
					}

					$user_id = $GLOBALS["USER"]->GetID();
					if($arPathTemplate["USE_SOCNET"] == "Y")
					{
						$postPerm = CBlogPost::GetSocNetPostPerms($postID);
						if($postPerm > BLOG_PERMS_DENY)
							$postPerm = CBlogComment::GetSocNetUserPerms($postID, $arPost["AUTHOR_ID"]);
					}
					else
						$postPerm = CBlogPost::GetBlogUserCommentPerms($postID, IntVal($user_id));

					if($postPerm >= BLOG_PERMS_READ)
					{
						$parser = new blogTextParser();
						$arParserParams = Array(
							"imageWidth" => $arPathTemplate["IMAGE_MAX_WIDTH"],
							"imageHeight" => $arPathTemplate["IMAGE_MAX_HEIGHT"],
						);

						CTimeZone::Disable();
						$dbComments = CBlogComment::GetList(
							array("DATE_CREATE" => "DESC"),
							array(
								//"BLOG_ID" => $blogID,
								"POST_ID" => $postID,
								"PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH,
							),
							false,
							array("nTopCount" => $numPosts),
							array("ID", "TITLE", "DATE_CREATE", "POST_TEXT", "AUTHOR_EMAIL", "AUTHOR_ID", "AUTHOR_NAME", "USER_LOGIN", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_NAME", "BLOG_USER_ALIAS")
						);
						CTimeZone::Enable();
						$arImages = Array();
						$dbImages = CBlogImage::GetList(Array(), Array("BLOG_ID" => $blogID, "POST_ID" => $postID, "IS_COMMENT" => "Y", "!COMMENT_ID" => false));
						while($arI = $dbImages->Fetch())
							$arImages[$arI["ID"]] = $arI["FILE_ID"];

						while ($arComments = $dbComments->Fetch())
						{
							$arDate = ParseDateTime($arComments["DATE_CREATE"], CSite::GetDateFormat("FULL", $arGroup["SITE_ID"]));
							$date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));

							if(strpos($url, "?") !== false)
								$url1 = $url."&amp;";
							else
								$url1 = $url."?";
							$url1 .= "commentId=".$arComments["ID"]."#".$arComments["ID"];

							$authorURL = "";
							if(IntVal($arComments["AUTHOR_ID"]) > 0)
							{
								$author = CBlogUser::GetUserName($arComments["BLOG_USER_ALIAS"], $arComments["USER_NAME"], $arComments["USER_LAST_NAME"], $arComments["USER_LOGIN"], $arComments["USER_SECOND_NAME"]);
								if(strLen($arPathTemplate["PATH_TO_USER"])>0)
									$authorURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_USER"], array("user_id"=>$arComments["AUTHOR_ID"])));
								else
									$authorURL = htmlspecialcharsbx("http://".$serverName.CBlogUser::PreparePath($arComments["AUTHOR_ID"], $arGroup["SITE_ID"]));
							}
							else
								$author = $arComments["AUTHOR_NAME"];
							$arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N");
							if($arPathTemplate["NO_URL_IN_COMMENTS"] == "L" || (IntVal($arComments["AUTHOR_ID"]) <= 0  && $arPathTemplate["NO_URL_IN_COMMENTS"] == "A"))
								$arAllow["CUT_ANCHOR"] = "Y";

							if($arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComments["AUTHOR_ID"]) > 0)
							{
								$authorityRatingId = CRatings::GetAuthorityRating();
								$arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComments["AUTHOR_ID"]);
								if($arRatingResult["CURRENT_VALUE"] < $arPathTemplate["NO_URL_IN_COMMENTS_AUTHORITY"])
									$arAllow["CUT_ANCHOR"] = "Y";
							}

							$text = $parser->convert_to_rss($arComments["POST_TEXT"], $arImages, $arAllow, false, $arParserParams);

							$title = GetMessage("BLG_GCM_COMMENT_TITLE", Array("#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"]), "#COMMENT_AUTHOR#" => htmlspecialcharsEx($author)));
							/*$title = str_replace(
								array("&", "<", ">", "\""),
								array("&amp;", "&lt;", "&gt;", "&quot;"),
								$title);
							*/
							//$text1 = HTMLToTxt($text, "", Array("\&nbsp;"), 60);
							$text = "<![CDATA[".$text."]]>";


							if ($type == "rss.92")
							{
								$rssText .= "    <item>\n";
								$rssText .= "      <title>".$title."</title>\n";
								$rssText .= "      <description>".$text."</description>\n";
								$rssText .= "      <link>".$url1."</link>\n";
								$rssText .= "    </item>\n";
								$rssText .= "\n";
							}
							elseif ($type == "rss2.0")
							{
								$rssText .= "    <item>\n";
								$rssText .= "      <title>".$title."</title>\n";
								$rssText .= "      <description>".$text."</description>\n";
								$rssText .= "      <link>".$url1."</link>\n";
								$rssText .= "      <guid>".$url1."</guid>\n";
								$rssText .= "      <pubDate>".$date."</pubDate>\n";
								$rssText .= "    </item>\n";
								$rssText .= "\n";
							}
							elseif ($type == "atom.03")
							{
								$atomID = "tag:".htmlspecialcharsbx($serverName).":".$arBlog["URL"]."/".$arPost["ID"];

								$timeISO = mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]);
								$dateISO = date("Y-m-d\TH:i:s", $timeISO).substr(date("O", $timeISO), 0, 3).":".substr(date("O", $timeISO), -2, 2);

								$rssText .= "<entry>\n";
								$rssText .= "  <title type=\"text/html\">".$title."</title>\n";
								$rssText .= "  <link rel=\"alternate\" type=\"text/html\" href=\"".$url1."\"/>\n";
								$rssText .= "  <issued>".$dateISO."</issued>\n";
								$rssText .= "  <modified>".$nowISO."</modified>\n";
								$rssText .= "  <id>".$atomID."</id>\n";
								$rssText .= "  <content type=\"text/html\" mode=\"escaped\" xml:lang=\"".$language."\" xml:base=\"".$blogURL."\">\n";
								$rssText .= $text."\n";
								$rssText .= "  </content>\n";
								$rssText .= "  <author>\n";
								$rssText .= "    <name>".htmlspecialcharsex($author)."</name>\n";
								if(strlen($authorURL) > 0)
									$rssText .= "    <uri>".$authorURL."</uri>\n";
								$rssText .= "  </author>\n";
								$rssText .= "</entry>\n";
								$rssText .= "\n";
							}
						}
					}

					if ($type == "rss.92")
						$rssText .= "  </channel>\n</rss>";
					elseif ($type == "rss2.0")
						$rssText .= "  </channel>\n</rss>";
					elseif ($type == "atom.03")
						$rssText .= "\n\n</feed>";
				}
			}
		}

		return $rssText;
	}
Пример #11
0
                            }
                        }
                    }
                    if (IntVal($v["AUTHOR_ID"]) > 0) {
                        if ($v["AUTHOR_ID"] == $user_id || $blogModulePermissions >= "W" && $arResult["IDEA_MODERATOR"]) {
                            $arResult["Comments"][$v["ID"]]["CAN_EDIT"] = "Y";
                        }
                    } else {
                        if ($blogModulePermissions >= "W") {
                            $arResult["Comments"][$v["ID"]]["CAN_EDIT"] = "Y";
                        }
                    }
                }
            }
            if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) {
                $arResult['RATING'] = CRatings::GetRatingVoteResult('BLOG_COMMENT', $arResult["IDS"]);
            }
        }
        if ($USER->IsAuthorized()) {
            if (IntVal($commentUrlID) > 0 && empty($arResult["Comments"][$commentUrlID])) {
                $arComment = CBlogComment::GetByID($commentUrlID);
                if ($arComment["AUTHOR_ID"] == $user_id && $arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_READY) {
                    $arResult["MESSAGE"] = GetMessage("B_B_PC_HIDDEN_POSTED");
                }
            }
        }
        $this->IncludeComponentTemplate();
    }
}
if (!is_array($arResult["CommentsResult"][0])) {
    return 0;
Пример #12
0
	else
	{
		$GLOBALS["NavNum"]++;
		if ($arAllow["VIDEO"] == "Y")
		{
			foreach ($arMessages as $key => $res):
				$arAllow["SMILES"] = ($res["USE_SMILES"] == "Y" ? $arResult["FORUM"]["ALLOW_SMILES"] : "N");
				$arMessages[$key]["POST_MESSAGE_TEXT"] = $parser->convert($res["~POST_MESSAGE_TEXT"], $arAllow);
			endforeach;
		}
	}
	/************** Rating ****************************************/
	if ($arParams["SHOW_RATING"] == "Y")
	{
		$arMessageIDs = array_keys($arMessages);
		$arRatings = CRatings::GetRatingVoteResult('FORUM_POST', $arMessageIDs);
		if ($arRatings)
		foreach($arRatings as $messageID => $arRating)
			$arMessages[$messageID]['RATING'] = $arRating;
	}
	$arResult["MESSAGES"] = $arMessages;
	// Link to forum
	$arResult["read"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"],
		array("FID" => $arParams["FORUM_ID"], "TID" => $arResult["FORUM_TOPIC_ID"], "TITLE_SEO" => $arResult["FORUM_TOPIC_ID"], "MID" => "s",
			"PARAM1" => "IB", "PARAM2" => $arParams["ELEMENT_ID"]));
}
/************** 5. Show post form **********************************/
$arResult["SHOW_POST_FORM"] = (($arResult["USER"]["PERMISSION"] >= "M" || ($arResult["USER"]["PERMISSION"] >= "I" && !empty($arResult["MESSAGES"]))) ? "Y" : "N");

if ($arResult["SHOW_POST_FORM"] == "Y")
{
Пример #13
0
$arResult['USER_VOTE'] = floatval($arParams['USER_VOTE']);
$arResult['ALLOW_VOTE'] = $arAllowVote;
$arResult['PATH_TO_USER_PROFILE'] = $arParams['PATH_TO_USER_PROFILE'];

$isLikeTemplate = in_array($sRatingTemplate, array("like", "like_graphic", "mobile_like"));
if ($isLikeTemplate)
	$arResult['TOTAL_VOTES'] = IntVal($arParams['TOTAL_POSITIVE_VOTES']);

if (!array_key_exists('TOTAL_VALUE', $arParams) ||
	!array_key_exists('TOTAL_VOTES', $arParams) ||
	!array_key_exists('TOTAL_POSITIVE_VOTES', $arParams) ||
	!array_key_exists('TOTAL_NEGATIVE_VOTES', $arParams) ||
	!array_key_exists('USER_HAS_VOTED', $arParams) ||
	!array_key_exists('USER_VOTE', $arParams))
{
	$arComponentVoteResult  = CRatings::GetRatingVoteResult($arResult['ENTITY_TYPE_ID'], $arResult['ENTITY_ID']);
	if (!empty($arComponentVoteResult))
	{
		$arResult['TOTAL_VALUE'] = $arComponentVoteResult['TOTAL_VALUE'];
		$arResult['TOTAL_VOTES'] = $arComponentVoteResult['TOTAL_VOTES'];
		$arResult['TOTAL_POSITIVE_VOTES'] = $arComponentVoteResult['TOTAL_POSITIVE_VOTES'];
		$arResult['TOTAL_NEGATIVE_VOTES'] = $arComponentVoteResult['TOTAL_NEGATIVE_VOTES'];
		$arResult['USER_VOTE'] = $arComponentVoteResult['USER_VOTE'];
		$arResult['USER_HAS_VOTED'] = $arComponentVoteResult['USER_HAS_VOTED'];

		if (in_array($sRatingTemplate, array("like", "like_graphic", "mobile_like")))
			$arResult['TOTAL_VOTES'] = $arComponentVoteResult['TOTAL_POSITIVE_VOTES'];
	}
}

$arResult['VOTE_BUTTON'] = $arResult['USER_HAS_VOTED'] == 'Y'? ($arResult['USER_VOTE'] > 0? 'PLUS': 'MINUS'): 'NONE';
Пример #14
0
    try {
        $arPermissionsParams = array('COURSE_ID' => $arParams['COURSE_ID'], 'LESSON_ID' => $arParams['CHAPTER_ID']);
        $isAccessible = CLearnAccessMacroses::CanUserViewLessonAsPublic($arPermissionsParams);
    } catch (Exception $e) {
        $isAccessible = false;
        // access denied
    }
    if (!$isAccessible) {
        ShowError(GetMessage('LEARNING_COURSE_DENIED'));
        return;
        exit;
    }
}
$ratingTransistor = '';
if ($arParams['CHAPTER_ID'] > 0) {
    $arRatingData = CRatings::GetRatingVoteResult('LEARN_LESSON', $arParams['CHAPTER_ID']);
    $ratingTransistor = serialize($arRatingData);
}
$lastDirtyCacheTS = COption::GetOptionString('learning', CLearnCacheOfLessonTreeComponent::OPTION_TS, time());
// was: if($this->StartResultCache(false, $USER->GetGroups()))
$additionalCacheID = CLearnAccess::GetAccessSymbolsHashForSiteUser() . '|' . $ratingTransistor . '|' . $lastDirtyCacheTS;
if ($this->StartResultCache(false, $additionalCacheID)) {
    //Module
    if (!CModule::IncludeModule("learning")) {
        $this->AbortResultCache();
        ShowError(GetMessage("LEARNING_MODULE_NOT_FOUND"));
        return;
    }
    //Course
    $rsCourse = CCourse::GetList(array(), array("ID" => $arParams["COURSE_ID"], "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "SITE_ID" => LANG, "CHECK_PERMISSIONS" => 'N'));
    if (!($arCourse = $rsCourse->GetNext())) {
Пример #15
0
}
if (!isset($arParams["CACHE_TIME"])) {
    $arParams["CACHE_TIME"] = 36000000;
}
//SELECT
$arSelect = array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_TEXT_TYPE", "PREVIEW_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_TEXT", "CREATED_BY");
//WHERE
$arFilter = array('IBLOCK_ID' => $arParams["IBLOCK_ID"], 'ACTIVE' => 'Y', 'IBLOCK_ACTIVE' => 'Y', 'SECTION_ID' => $arParams["SECTION_ID"], 'ID' => $arParams["ELEMENT_ID"]);
//ORDER BY
$arOrder = array('SORT' => 'ASC', 'ID' => 'DESC');
$arAddCacheParams = array("MODE" => $_REQUEST['bitrix_show_mode'] ? $_REQUEST['bitrix_show_mode'] : 'view', "SESS_MODE" => $_SESSION['SESS_PUBLIC_SHOW_MODE'] ? $_SESSION['SESS_PUBLIC_SHOW_MODE'] : 'view');
//**work body**//
if ($this->StartResultCache(false, array($arParams["CACHE_GROUPS"] === "N" ? false : $USER->GetGroups(), $arFilter, $arAddCacheParams))) {
    $arItem = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect);
    if ($arResItem = $arItem->Fetch()) {
        $arResult['ITEM'] = $arResItem;
    }
    if (!isset($arResult['ITEM'])) {
        $this->AbortResultCache();
        @define("ERROR_404", "Y");
        return;
    }
    $this->EndResultCache();
}
// activation rating
CRatingsComponentsMain::GetShowRating($arParams);
if ($arParams['SHOW_RATING'] == 'Y' && $arResult['ITEM'] > 0) {
    $arResult['RATING'] = CRatings::GetRatingVoteResult('IBLOCK_ELEMENT', $arResult['ITEM']);
}
//include template
$this->IncludeComponentTemplate();
Пример #16
0
 function __SLEGetLogRecord($logID, $arParams, $arCurrentUserSubscribe, $current_page_date)
 {
     static $isExtranetInstalled, $isExtranetSite, $isExtranetUser, $arUserIdVisible, $arAvailableExtranetUserID, $isExtranetAdmin, $bCurrentUserIsAdmin, $arSocNetFeaturesSettings;
     if (!$isExtranetInstalled) {
         $isExtranetInstalled = CModule::IncludeModule("extranet") ? "Y" : "N";
         $isExtranetSite = $isExtranetInstalled == "Y" && CExtranet::IsExtranetSite() ? "Y" : "N";
         $isExtranetUser = $isExtranetInstalled == "Y" && !CExtranet::IsIntranetUser() ? "Y" : "N";
         $isExtranetAdmin = $isExtranetInstalled == "Y" && CExtranet::IsExtranetAdmin() ? "Y" : "N";
         $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin();
         $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
         if ($isExtranetUser == "Y") {
             $arUserIdVisible = CExtranet::GetMyGroupsUsersSimple(SITE_ID);
         } elseif ($isExtranetInstalled == "Y" && $isExtranetUser != "Y") {
             if ($isExtranetAdmin == "Y" && $bCurrentUserIsAdmin) {
                 $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsers(SITE_ID);
             } else {
                 $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsersSimple(CExtranet::GetExtranetSiteID());
             }
         }
     }
     $cache_time = 31536000;
     $arEvent = array();
     $cache = new CPHPCache();
     $arCacheID = array();
     $arKeys = array("AVATAR_SIZE", "DESTINATION_LIMIT", "CHECK_PERMISSIONS_DEST", "NAME_TEMPLATE", "NAME_TEMPLATE_WO_NOBR", "SHOW_LOGIN", "DATE_TIME_FORMAT", "PATH_TO_USER", "PATH_TO_GROUP", "PATH_TO_CONPANY_DEPARTMENT");
     foreach ($arKeys as $param_key) {
         if (array_key_exists($param_key, $arParams)) {
             $arCacheID[$param_key] = $arParams[$param_key];
         } else {
             $arCacheID[$param_key] = false;
         }
     }
     $cache_id = "log_post_" . $logID . "_" . md5(serialize($arCacheID)) . "_" . SITE_TEMPLATE_ID . "_" . SITE_ID . "_" . LANGUAGE_ID . "_" . FORMAT_DATETIME . "_" . CTimeZone::GetOffset();
     $cache_path = "/sonet/log/" . intval(intval($logID) / 1000) . "/" . $logID . "/entry/";
     if (is_object($cache) && $cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $arCacheVars = $cache->GetVars();
         $arEvent["FIELDS_FORMATTED"] = $arCacheVars["FIELDS_FORMATTED"];
         if (array_key_exists("CACHED_CSS_PATH", $arEvent["FIELDS_FORMATTED"])) {
             if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) && strlen($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) > 0) {
                 $GLOBALS['APPLICATION']->SetAdditionalCSS($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]);
             } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"])) {
                 foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"] as $css_path) {
                     $GLOBALS['APPLICATION']->SetAdditionalCSS($css_path);
                 }
             }
         }
         if (array_key_exists("CACHED_JS_PATH", $arEvent["FIELDS_FORMATTED"])) {
             if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]) && $arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] !== '') {
                 $GLOBALS['APPLICATION']->AddHeadScript($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]);
             } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"])) {
                 foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] as $js_path) {
                     $GLOBALS['APPLICATION']->AddHeadScript($js_path);
                 }
             }
         }
     } else {
         if (is_object($cache)) {
             $cache->StartDataCache($cache_time, $cache_id, $cache_path);
         }
         $arFilter = array("ID" => $logID);
         $arListParams = array("CHECK_RIGHTS" => "N", "USE_FOLLOW" => "N", "USE_SUBSCRIBE" => "N");
         $arSelect = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "SOURCE_TYPE");
         $dbEvent = CSocNetLog::GetList(array(), $arFilter, false, false, $arSelect, $arListParams);
         if ($arEvent = $dbEvent->GetNext()) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arEvent["USER_ID"]));
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag("SONET_LOG_" . intval($arEvent["ID"]));
                 if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
                     $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group_" . $arEvent["ENTITY_ID"]);
                 }
             }
             $arEvent["EVENT_ID_FULLSET"] = CSocNetLogTools::FindFullSetEventIDByEventID($arEvent["EVENT_ID"]);
             if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
                 static $arSiteWorkgroupsPage;
                 if (!$arSiteWorkgroupsPage && (IsModuleInstalled("extranet") || is_set($arEvent["URL"]) && strpos($arEvent["URL"], "#GROUPS_PATH#") !== false)) {
                     $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
                     while ($arSite = $rsSite->Fetch()) {
                         $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]);
                     }
                 }
                 if (is_set($arEvent["URL"]) && isset($arSiteWorkgroupsPage[SITE_ID])) {
                     $arEvent["URL"] = str_replace("#GROUPS_PATH#", $arSiteWorkgroupsPage[SITE_ID], $arEvent["URL"]);
                 }
             }
             $arEventTmp = CSocNetLogTools::FindLogEventByID($arEvent["EVENT_ID"]);
             if ($arEventTmp && isset($arEventTmp["CLASS_FORMAT"]) && isset($arEventTmp["METHOD_FORMAT"])) {
                 $arEvent["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("SONET_LOG", $arEvent["ID"], LANGUAGE_ID);
                 $arEvent["FIELDS_FORMATTED"] = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arEvent, $arParams);
                 if (is_array($arEvent["FIELDS_FORMATTED"])) {
                     if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"])) {
                         if (in_array($arEvent["EVENT_ID"], array('calendar'))) {
                             $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]);
                         } else {
                             $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = CSocNetTextParser::closetags(htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]));
                         }
                     }
                     if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"])) {
                         $arFields2Cache = array("URL", "STYLE", "DESTINATION", "DESTINATION_MORE", "TITLE_24", "TITLE_24_2", "TITLE_24_2_STYLE", "IS_IMPORTANT", "MESSAGE", "FOOTER_MESSAGE", "MESSAGE_TITLE_24", "DATETIME_FORMATTED", "LOG_DATE_FORMAT", "MENU", "COMMENT_URL");
                         foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"] as $field => $value) {
                             if (!in_array($field, $arFields2Cache)) {
                                 unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"][$field]);
                             }
                         }
                     }
                     if (isset($arEvent["FIELDS_FORMATTED"]["EVENT"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT"])) {
                         $arFields2Cache = array("ID", "URL", "USER_ID", "ENTITY_TYPE", "ENTITY_ID", "EVENT_ID", "EVENT_ID_FULLSET", "TITLE", "MESSAGE", "SOURCE_ID", "PARAMS", "RATING_TYPE_ID", "RATING_ENTITY_ID");
                         foreach ($arEvent["FIELDS_FORMATTED"]["EVENT"] as $field => $value) {
                             if (!in_array($field, $arFields2Cache)) {
                                 unset($arEvent["FIELDS_FORMATTED"]["EVENT"][$field]);
                             }
                         }
                     }
                     if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"])) {
                         $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL", "IS_EXTRANET");
                         foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"] as $field => $value) {
                             if (!in_array($field, $arFields2Cache)) {
                                 unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"][$field]);
                             }
                         }
                         if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"])) {
                             $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL");
                             foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"] as $field => $value) {
                                 if (!in_array($field, $arFields2Cache)) {
                                     unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"][$field]);
                                 }
                             }
                         }
                     }
                     if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"])) {
                         $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL");
                         foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"] as $field => $value) {
                             if (!in_array($field, $arFields2Cache)) {
                                 unset($arEvent["FIELDS_FORMATTED"]["ENTITY"][$field]);
                             }
                         }
                         if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"])) {
                             $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL");
                             foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"] as $field => $value) {
                                 if (!in_array($field, $arFields2Cache)) {
                                     unset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"][$field]);
                                 }
                             }
                         }
                     }
                     $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["UF"] = $arEvent["UF"];
                 } else {
                     $bEmpty = true;
                 }
             }
             if (!$bEmpty) {
                 $dateFormated = FormatDate($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATE), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"])));
                 $timeFormated = FormatDateFromDB(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]), stripos($arParams["DATE_TIME_FORMAT"], 'a') || ($arParams["DATE_TIME_FORMAT"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'H:MI TT' : 'H:MI T' : 'HH:MI');
                 $dateTimeFormated = FormatDate(!empty($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] == "FULL" ? $GLOBALS["DB"]->DateFormatToPHP(str_replace(":SS", "", FORMAT_DATETIME)) : $arParams["DATE_TIME_FORMAT"] : $GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"])));
                 if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                     $dateTimeFormated = ToLower($dateTimeFormated);
                     $dateFormated = ToLower($dateFormated);
                     $timeFormated = ToLower($timeFormated);
                 }
                 // strip current year
                 if (!empty($arParams['DATE_TIME_FORMAT']) && ($arParams['DATE_TIME_FORMAT'] == 'j F Y G:i' || $arParams['DATE_TIME_FORMAT'] == 'j F Y g:i a')) {
                     $dateTimeFormated = ltrim($dateTimeFormated, '0');
                     $curYear = date('Y');
                     $dateTimeFormated = str_replace(array('-' . $curYear, '/' . $curYear, ' ' . $curYear, '.' . $curYear), '', $dateTimeFormated);
                 }
                 $arEvent["MESSAGE_FORMAT"] = htmlspecialcharsback($arEvent["MESSAGE"]);
                 if (StrLen($arEvent["CALLBACK_FUNC"]) > 0) {
                     if (StrLen($arEvent["MODULE_ID"]) > 0) {
                         CModule::IncludeModule($arEvent["MODULE_ID"]);
                     }
                     $arEvent["MESSAGE_FORMAT"] = call_user_func($arEvent["CALLBACK_FUNC"], $arEvent);
                 }
                 $arEvent["FIELDS_FORMATTED"]["LOG_TIME_FORMAT"] = $timeFormated;
                 $arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_TS"] = MakeTimeStamp($arEvent["LOG_UPDATE"]);
                 $arEvent["FIELDS_FORMATTED"]["LOG_DATE_TS"] = MakeTimeStamp($arEvent["LOG_DATE"]);
                 $arEvent["FIELDS_FORMATTED"]["LOG_DATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_DATE"]), "SHORT");
                 $arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_UPDATE"]), "SHORT");
                 $arEvent["FIELDS_FORMATTED"]["COMMENTS_COUNT"] = $arEvent["COMMENTS_COUNT"];
                 $arEvent["FIELDS_FORMATTED"]["TMP_ID"] = $arEvent["TMP_ID"];
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated;
                 $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["EVENT_ID"]);
                 if (!array_key_exists("HAS_COMMENTS", $arEvent["FIELDS_FORMATTED"]) || $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] != "N") {
                     $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] = $arCommentEvent && (!array_key_exists("ENABLE_COMMENTS", $arEvent) || $arEvent["ENABLE_COMMENTS"] != "N") ? "Y" : "N";
                 }
             }
         }
         if (is_object($cache)) {
             $arCacheData = array("FIELDS_FORMATTED" => $arEvent["FIELDS_FORMATTED"]);
             $cache->EndDataCache($arCacheData);
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->EndTagCache();
             }
         }
     }
     if ($bEmpty) {
         return false;
     }
     $feature = CSocNetLogTools::FindFeatureByEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
     if ($feature && (!array_key_exists($feature, $arSocNetFeaturesSettings) || array_key_exists("allowed", $arSocNetFeaturesSettings[$feature]) && is_array($arSocNetFeaturesSettings[$feature]["allowed"]) && !in_array($arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arSocNetFeaturesSettings[$feature]["allowed"]))) {
         return false;
     }
     if (!array_key_exists("COMMENTS_PARAMS", $arEvent["FIELDS_FORMATTED"])) {
         $arForumMetaData = CSocNetLogTools::GetForumCommentMetaData($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
         if ($arForumMetaData && $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"] > 0) {
             $arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => $arForumMetaData[1], "ENTITY_XML_ID" => $arForumMetaData[0] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"], "NOTIFY_TAGS" => $arForumMetaData[2]);
         } else {
             $arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => substr(strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], 0, 2), "ENTITY_XML_ID" => strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], "NOTIFY_TAGS" => "");
         }
     }
     foreach (GetModuleEvents("socialnetwork", "OnSonetLogEntryMenuCreate", true) as $arModuleEvent) {
         if (!array_key_exists("FIELDS_FORMATTED", $arEvent)) {
             $arEvent["FIELDS_FORMATTED"] = array();
         }
         if (!array_key_exists("MENU", $arEvent["FIELDS_FORMATTED"])) {
             $arEvent["FIELDS_FORMATTED"]["MENU"] = array();
         }
         $arMenuItems = ExecuteModuleEventEx($arModuleEvent, array($arEvent));
         if (!empty($arMenuItems)) {
             $arEvent["FIELDS_FORMATTED"]["MENU"] = array_merge($arEvent["FIELDS_FORMATTED"]["MENU"], $arMenuItems);
         }
     }
     if (is_array($arCurrentUserSubscribe)) {
         $arEvent["FIELDS_FORMATTED"]["TRANSPORT"] = __SLEGetTransport($arEvent, $arCurrentUserSubscribe);
     }
     $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
     if (!$GLOBALS["USER"]->IsAuthorized()) {
         $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = "N";
     } elseif ($arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && $arCommentEvent["OPERATION_ADD"] == "log_rights") {
         $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = CSocNetLogRights::CheckForUser($arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], $GLOBALS["USER"]->GetID()) ? "Y" : "N";
     } else {
         $array_key = $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"];
         if (array_key_exists($array_key, $GLOBALS["CurUserCanAddComments"])) {
             $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N";
         } else {
             if ($feature && $arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) {
                 $GLOBALS["CurUserCanAddComments"][$array_key] = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"], $feature == "microblog" ? "blog" : $feature, $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin) ? "Y" : "N";
             } else {
                 $GLOBALS["CurUserCanAddComments"][$array_key] = "Y";
             }
             $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N";
         }
     }
     $arEvent["FIELDS_FORMATTED"]["FAVORITES"] = $arParams["EVENT"]["FAVORITES"];
     if ($arParams["USE_FOLLOW"] == "Y") {
         $arEvent["FIELDS_FORMATTED"]["EVENT"]["FOLLOW"] = $arParams["EVENT"]["FOLLOW"];
         $arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW_X1"] = $arParams["EVENT"]["DATE_FOLLOW_X1"];
         $arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW"] = $arParams["EVENT"]["DATE_FOLLOW"];
     }
     if ($arParams["CHECK_PERMISSIONS_DEST"] == "N" && !$bCurrentUserIsAdmin && is_object($GLOBALS["USER"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) || array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"]))) {
         $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"] = 0;
         $arGroupID = CSocNetLogTools::GetAvailableGroups();
         if (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"])) {
             foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] as $key => $arDestination) {
                 if (array_key_exists("TYPE", $arDestination) && array_key_exists("ID", $arDestination) && ($arDestination["TYPE"] == "SG" && !in_array(intval($arDestination["ID"]), $arGroupID) || in_array($arDestination["TYPE"], array("CRMCOMPANY", "CRMLEAD", "CRMCONTACT", "CRMDEAL")) && CModule::IncludeModule("crm") && !CCrmAuthorizationHelper::CheckReadPermission(CCrmLiveFeedEntity::ResolveEntityTypeID($arDestination["TYPE"]), $arDestination["ID"]) || in_array($arDestination["TYPE"], array("DR", "D")) && $isExtranetUser == "Y" || $arDestination["TYPE"] == "U" && isset($arUserIdVisible) && is_array($arUserIdVisible) && !in_array(intval($arDestination["ID"]), $arUserIdVisible) || $arDestination["TYPE"] == "U" && isset($arDestination["IS_EXTRANET"]) && $arDestination["IS_EXTRANET"] == "Y" && isset($arAvailableExtranetUserID) && is_array($arAvailableExtranetUserID) && !in_array(intval($arDestination["ID"]), $arAvailableExtranetUserID))) {
                     unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"][$key]);
                     $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++;
                 }
             }
             if (intval($arParams["DESTINATION_LIMIT_SHOW"]) > 0 && count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) > $arParams["DESTINATION_LIMIT_SHOW"]) {
                 $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_MORE"] = count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) - $arParams["DESTINATION_LIMIT_SHOW"];
                 $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] = array_slice($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"], 0, $arParams["DESTINATION_LIMIT_SHOW"]);
             }
         } elseif (array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"])) {
             foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"] as $key => $right_tmp) {
                 if (preg_match('/^SG(\\d+)$/', $right_tmp, $matches) && !in_array(intval($matches[1]), $arGroupID)) {
                     unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"][$key]);
                     $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++;
                 }
             }
         }
     }
     if ($arParams["SHOW_RATING"] == "Y" && strlen($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"]) > 0 && intval($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]) > 0) {
         $arEvent["FIELDS_FORMATTED"]["RATING"] = CRatings::GetRatingVoteResult($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]);
     }
     return $arEvent["FIELDS_FORMATTED"];
 }
Пример #17
0
    function AddLiveComment($commentId = 0, $path = "", $arParams = array())
    {
        if (IntVal($commentId) <= 0) {
            return;
        }
        if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($arComment["POST_ID"]))) {
            if (strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) {
                $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId));
            }
            if (strlen($path) <= 0) {
                $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId)) . "?commentId=" . $commentId;
            }
            $arFormatParams = array("PATH_TO_USER" => isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '', "PATH_TO_POST" => $path, "NAME_TEMPLATE" => isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat(), "SHOW_LOGIN" => isset($arParams["SHOW_LOGIN"]) ? $arParams["SHOW_LOGIN"] : true, "AVATAR_SIZE_COMMENT" => isset($arParams["AVATAR_SIZE_COMMENT"]) ? $arParams["AVATAR_SIZE_COMMENT"] : 58, "PATH_TO_SMILE" => isset($arParams["PATH_TO_SMILE"]) ? $arParams["PATH_TO_SMILE"] : '', "DATE_TIME_FORMAT" => isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : '', "SHOW_RATING" => isset($arParams["SHOW_RATING"]) ? $arParams["SHOW_RATING"] : '', "RATING_TYPE" => "like");
            $arComment["DateFormated"] = FormatDateFromDB($arComment["DATE_CREATE"], $arFormatParams["DATE_TIME_FORMAT"], true);
            if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                $arComment["DateFormated"] = ToLower($arComment["DateFormated"]);
            }
            $arComment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID);
            $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $arFormatParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arFormatParams["AVATAR_SIZE_COMMENT"]));
            if (IsModuleInstalled('extranet') && CModule::IncludeModule('socialnetwork')) {
                CSocNetTools::InitGlobalExtranetArrays();
            }
            $arTmpUser = array("NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "LOGIN" => $arAuthor["~LOGIN"], "NAME_LIST_FORMATTED" => "");
            $arAuthor["NAME_FORMATED"] = CUser::FormatName($arFormatParams["NAME_TEMPLATE"], $arTmpUser, $arFormatParams["SHOW_LOGIN"] != "N");
            if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) {
                $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arFormatParams["AVATAR_SIZE_COMMENT"], "height" => $arFormatParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT);
                $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]);
            }
            $p = new blogTextParser(false, '');
            $ufCode = "UF_BLOG_COMMENT_FILE";
            if (is_array($arComment["UF"][$ufCode])) {
                $p->arUserfields = array($ufCode => array_merge($arComment["UF"][$ufCode], array("TAG" => "DOCUMENT ID")));
            }
            $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y");
            $arParserParams = array("imageWidth" => 800, "imageHeight" => 800);
            $arComment["TextFormated"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $p->bMobile = true;
            $arComment["TextFormatedMobile"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            if ($perm >= BLOG_PERMS_MODERATE) {
                if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                    $arComment["CAN_HIDE"] = "Y";
                } else {
                    $arComment["CAN_SHOW"] = "Y";
                }
            } else {
                $arComment["CAN_SHOW"] = $arComment["CAN_HIDE"] = "N";
            }
            $urlToPost = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFormatParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
            $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
            $arUrl = array("LINK" => $urlToPost, "SHOW" => $urlToPost . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "HIDE" => $urlToPost . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "DELETE" => $urlToPost . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "USER" => htmlspecialcharsback($arFormatParams["PATH_TO_USER"]));
            CRatingsComponentsMain::GetShowRating($arFormatParams);
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRating = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arComment["ID"]));
            }
            $arCommentParams = array("ID" => $commentId, "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "FULL_ID" => array("BLOG_" . $arPost["ID"], $commentId), "ACTION" => "REPLY", "APPROVED" => "Y", "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "NEW" => "Y", "AUTHOR" => array("ID" => $GLOBALS["USER"]->GetID(), "NAME" => $arAuthor["NAME_FORMATED"], "URL" => $arAuthor["url"], "E-MAIL" => $arComment["AuthorEmail"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($GLOBALS["USER"]->GetID(), $GLOBALS["arExtranetUserID"])), "POST_TIMESTAMP" => $arComment["DATE_CREATE_TS"], "POST_TIME" => $arComment["DATE_CREATE_TIME"], "POST_DATE" => $arComment["DateFormated"], "POST_MESSAGE_TEXT" => $arComment["TextFormated"], "POST_MESSAGE_TEXT_MOBILE" => $arComment["TextFormatedMobile"], "URL" => array("LINK" => str_replace(array("##comment_id#", "#comment_id#"), array("", $commentId), $arUrl["LINK"]), "EDIT" => "__blogEditComment('" . $commentId . "', '" . $arPost["ID"] . "');", "MODERATE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arComment["CAN_SHOW"] == "Y" ? $arUrl["SHOW"] : ($arComment["CAN_HIDE"] == "Y" ? $arUrl["HIDE"] : "")), "DELETE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arUrl["DELETE"])), "AFTER" => "", "BEFORE_ACTIONS_MOBILE" => "", "AFTER_MOBILE" => "");
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRatingData = array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $commentId, "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating[$commentId]["USER_VOTE"], "USER_HAS_VOTED" => $arRating[$commentId]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating[$commentId]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating[$commentId]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating[$commentId]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating[$commentId]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arUrl["USER"]);
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS"] = ob_get_clean();
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS_MOBILE"] = ob_get_clean();
            }
            $arUFResult = self::BuildUFFields($arComment["UF"]);
            $arCommentParams["AFTER"] .= $arUFResult["AFTER"];
            $arCommentParams["AFTER_MOBILE"] .= $arUFResult["AFTER_MOBILE"];
            if ($arComment["CAN_EDIT"] == "Y") {
                ob_start();
                ?>
<script>
					top.text<?php 
                echo $commentId;
                ?>
 = text<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo CUtil::JSEscape(htmlspecialcharsBack($arComment["POST_TEXT"]));
                ?>
';
					top.title<?php 
                echo $commentId;
                ?>
 = title<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo isset($arComment["TITLE"]) ? CUtil::JSEscape($arComment["TITLE"]) : '';
                ?>
';
					top.arComFiles<?php 
                echo $commentId;
                ?>
 = [];<?php 
                ?>
</script><?php 
                $arCommentParams["AFTER"] .= ob_get_clean();
            }
            CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arPost["ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arCommentParams));
        }
    }
Пример #18
0
$bCreateRule = true;
$rsData = $DB->Query("SELECT ID, ACTIVE FROM b_rating_rule WHERE CONDITION_MODULE = 'intranet'");
while ($arRule = $rsData->Fetch()) {
    if ($arRule["ACTIVE"] == "N") {
        $DB->Query("DELETE FROM b_rating_rule WHERE ID = " . $arRule["ID"], true);
    } else {
        COption::SetOptionString("intranet", "ratingSubordinateId", $arRule['ID']);
        CRatingRule::Apply($arRule['ID']);
        $bCreateRule = false;
    }
}
// после авторитета
if ($bCreateRule) {
    $dbRes = CLanguage::GetList($by = 'sort', $order = 'asc');
    while ($arRes = $dbRes->Fetch()) {
        if (file_exists(dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php')) {
            require dirname(__FILE__) . '/' . $arRes['LID'] . '/rating.php';
        }
    }
    $arFields = array("ACTIVE" => "Y", "NAME" => $MESS['INTR_INSTALL_RATING_RULE'], "ENTITY_TYPE_ID" => "USER", "CONDITION_NAME" => "SUBORDINATE", "CONDITION_MODULE" => "intranet", "CONDITION_CLASS" => "CRatingRulesIntranet", "CONDITION_METHOD" => "subordinateCheck", "CONDITION_CONFIG" => array("SUBORDINATE" => array()), "ACTION_NAME" => "empty", "ACTION_CONFIG" => array(), "ACTIVATE" => "N", "ACTIVATE_CLASS" => "empty", "ACTIVATE_METHOD" => "empty", "DEACTIVATE" => "N", "DEACTIVATE_CLASS" => "empty ", "DEACTIVATE_METHOD" => "empty", "~CREATED" => $DB->GetNowFunction(), "~LAST_MODIFIED" => $DB->GetNowFunction());
    $arFields["CONDITION_CONFIG"] = serialize($arFields["CONDITION_CONFIG"]);
    $arFields["ACTION_CONFIG"] = serialize($arFields["ACTION_CONFIG"]);
    $ID = $DB->Add("b_rating_rule", $arFields, array("ACTION_CONFIG", "CONDITION_CONFIG"));
    COption::SetOptionString("intranet", "ratingSubordinateId", $ID);
    CRatingRule::Apply($ID);
}
// recount ratings
$rsData = CRatings::GetList(array('ID' => 'ASC'), array());
while ($arRes = $rsData->Fetch()) {
    CRatings::Calculate($arRes['ID'], true);
}
Пример #19
0
    } elseif ($arResult['PROGRESS_POSITION'] < 0) {
        $arResult['PROGRESS_POSITION'] = $arResult['CURRENT_POSITION'] - $arResult['PREVIOUS_POSITION'];
        $arResult['PROGRESS_POSITION_DIRECT'] = 'down';
    } else {
        $arResult['PROGRESS_POSITION_DIRECT'] = 'unchanged';
    }
} else {
    $arResult['RESULT_TYPE'] = 'VALUE';
    if (isset($arParams['CURRENT_VALUE'])) {
        $arResult["CURRENT_VALUE"] = floatval($arParams["CURRENT_VALUE"]);
    }
    if (isset($arParams['PREVIOUS_VALUE'])) {
        $arResult["PREVIOUS_VALUE"] = floatval($arParams["PREVIOUS_VALUE"]);
    }
    if (!isset($arParams['CURRENT_VALUE']) || !isset($arParams['PREVIOUS_VALUE'])) {
        $arComponentRatingResult = CRatings::GetRatingResult($arParams["RATING_ID"], $arParams['ENTITY_ID']);
        $arResult['CURRENT_VALUE'] = array_key_exists('CURRENT_VALUE', $arComponentRatingResult) ? $arComponentRatingResult['CURRENT_VALUE'] : 0;
        $arResult['PREVIOUS_VALUE'] = array_key_exists('PREVIOUS_VALUE', $arComponentRatingResult) ? $arComponentRatingResult['PREVIOUS_VALUE'] : 0;
    }
    if (isset($arParams['PROGRESS_VALUE'])) {
        $arResult['PROGRESS_VALUE'] = $arParams['PROGRESS_VALUE'];
    } else {
        $arResult['PROGRESS_VALUE'] = $arResult['CURRENT_VALUE'] - $arResult['PREVIOUS_VALUE'];
        $arResult['PROGRESS_VALUE'] = round($arResult['PROGRESS_VALUE'], 2);
        $arResult['PROGRESS_VALUE'] = $arResult['PROGRESS_VALUE'] > 0 ? "+" . $arResult['PROGRESS_VALUE'] : $arResult['PROGRESS_VALUE'];
    }
    if (isset($arParams['ROUND_CURRENT_VALUE'])) {
        $arResult['ROUND_CURRENT_VALUE'] = $arParams['ROUND_CURRENT_VALUE'];
    } else {
        $arResult['ROUND_CURRENT_VALUE'] = round($arResult['CURRENT_VALUE']) == 0 ? 0 : round($arResult['CURRENT_VALUE']);
    }
Пример #20
0
	elseif ($_REQUEST["value"] != "hide" && in_array($_REQUEST["option"], $arUserOptions["hide"])):
		$key = intVal(array_search($_REQUEST["option"], $arUserOptions["hide"]));
		unset($arUserOptions["hide"][$key]);
		$bUpdate = true;
	endif;
	if ($bUpdate):
		CUserOptions::SetOption("forum", "profile", serialize($arUserOptions), false, $arParams["UID"]);
	endif;
	$arResult["USER"]["SHOW_PANELS"][$_REQUEST["option"]] = ($_REQUEST["value"] == "hide" ? "N" : "Y");
endif;

if ($arParams["SHOW_RATING"] == 'Y')
{
	$authorId = intval($arParams["UID"]);
	$arRatingResult = CRatings::GetRatingResult($arParams["RATING_ID"], $authorId);
	$arRatingVote	= CRatings::GetRatingVoteResult('USER', $authorId);
}

$bShowedInfo = false;
?><script type="text/javascript">
function forumAddSessid(el)
{
	if (!!el || !!el.href) { el.href += (el.href.indexOf("?") > 0 ? "&" : "?") + 'sessid=' + BX.bitrix_sessid(); }
	return true;
}
</script>
<?
/*******************************************************************/
if (!empty($arResult["ERROR_MESSAGE"])): 
?>
<div class="forum-note-box forum-note-error">
Пример #21
0
$tabControl->BeginCustomField("ACTIVE", GetMessage('RATING_EDIT_FRM_ACTIVE'), false);
?>
	<tr>
		<td><?php 
echo GetMessage("RATING_EDIT_FRM_ACTIVE");
?>
</td>
		<td><?php 
echo InputType("checkbox", "ACTIVE", "Y", $str_ACTIVE);
?>
</td>
	</tr>
<?php 
$tabControl->EndCustomField("ACTIVE");
$tabControl->AddSection("CAT_RATING_COMPONENT", GetMessage("RATING_EDIT_CAT_RATING_COMPONENT"));
$arRatingConfigs = CRatings::GetRatingConfigs($str_ENTITY_ID);
$tabControl->BeginCustomField("CAT_WHAT_CNT_FORM", '', true);
?>
	<tr>
		<td width="100%" colspan="2">
<?php 
$aTabs2 = array();
foreach ($arRatingConfigs as $arConfigModule => $arConfigModuleValue) {
    $aTabs2[] = array("DIV" => "panel_" . $arConfigModule, "TAB" => $arConfigModuleValue['MODULE_NAME'], "TITLE" => $arConfigModuleValue['MODULE_NAME']);
}
$tabControl2 = new CAdminViewTabControl("tabControl2", $aTabs2);
$tabControl2->Begin();
foreach ($arRatingConfigs as $arConfigModule => $arConfigModuleValue) {
    $tabControl2->BeginNextTab();
    foreach ($arConfigModuleValue as $arConfigType => $arConfigTypeValue) {
        if (is_array($arConfigTypeValue)) {
Пример #22
0
 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()) {
Пример #23
0
     if ($arResult["PostPerm"] >= BLOG_PERMS_FULL) {
         $arResult["urlToDelete"] = $arResult["urlToEdit"];
         if (strpos($arResult["urlToDelete"], "?") === false) {
             $arResult["urlToDelete"] .= "?";
         } else {
             $arResult["urlToDelete"] .= "&";
         }
         $arResult["urlToDelete"] .= "delete_blog_post_id=#del_post_id#&ajax_blog_post_delete=Y" . "&" . bitrix_sessid_get();
         $arResult["canDelete"] = "Y";
     }
 }
 if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["Post"])) {
     if (array_key_exists("RATING_ENTITY_ID", $arParams) && intval($arParams["RATING_ENTITY_ID"]) > 0 && array_key_exists("RATING_TOTAL_VALUE", $arParams) && is_numeric($arParams["RATING_TOTAL_VALUE"]) && array_key_exists("RATING_TOTAL_VOTES", $arParams) && intval($arParams["RATING_TOTAL_VOTES"]) >= 0 && array_key_exists("RATING_TOTAL_POSITIVE_VOTES", $arParams) && intval($arParams["RATING_TOTAL_POSITIVE_VOTES"]) >= 0 && array_key_exists("RATING_TOTAL_NEGATIVE_VOTES", $arParams) && intval($arParams["RATING_TOTAL_NEGATIVE_VOTES"]) >= 0 && array_key_exists("RATING_USER_VOTE_VALUE", $arParams) && is_numeric($arParams["RATING_USER_VOTE_VALUE"])) {
         $arResult['RATING'][$arResult["Post"]["ID"]] = array("USER_VOTE" => $arParams["RATING_USER_VOTE_VALUE"], "USER_HAS_VOTED" => $arParams["RATING_USER_VOTE_VALUE"] == 0 ? "N" : "Y", "TOTAL_VOTES" => $arParams["RATING_TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arParams["RATING_TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arParams["RATING_TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arParams["RATING_TOTAL_VALUE"]);
     } else {
         $arResult['RATING'][$arResult["Post"]["ID"]] = CRatings::GetRatingVoteResult('BLOG_POST', $arResult["Post"]["ID"]);
     }
 }
 if ($arParams["IS_UNREAD"]) {
     $arResult["Post"]["new"] = "Y";
 }
 if ($arParams["IS_HIDDEN"]) {
     $arResult["Post"]["hidden"] = "Y";
 }
 $arResult["Post"]["IS_IMPORTANT"] = false;
 if (is_array($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_IMPRTNT"]) && intval($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_IMPRTNT"]["VALUE"]) > 0) {
     $arResult["Post"]["IS_IMPORTANT"] = true;
     unset($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_IMPRTNT"]);
     $arResult["Post"]["IMPORTANT"] = array();
     if ($GLOBALS["USER"]->IsAuthorized()) {
         $arResult["Post"]["IMPORTANT"] = array("COUNT" => 0, "IS_READ" => false, "USER" => array());
Пример #24
0
 $arResult = array();
 $dbComment = CBlogComment::GetList($SORT, $arFilter, false, $COUNT, $arSelectedFields);
 $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
 $itemCnt = 0;
 while ($arComment = $dbComment->GetNext()) {
     $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "N", "USER" => "N");
     $text = preg_replace("#\\[img\\](.+?)\\[/img\\]#ie", "", $arComment["~POST_TEXT"]);
     $text = preg_replace("#\\[user\\](.+?)\\[/user\\]#ie", "", $text);
     $text = preg_replace("#\\[code\\](.+?)\\[/code\\]#is", "", $text);
     $text = preg_replace("#\\[quote\\](.+?)\\[/quote\\]#is", "", $text);
     if ($arResult["NO_URL_IN_COMMENTS"] == "L" || IntVal($arComment["AUTHOR_ID"]) <= 0 && $arParams["NO_URL_IN_COMMENTS"] == "A") {
         $arAllow["CUT_ANCHOR"] = "Y";
         $arAllow["ANCHOR"] = "Y";
     } elseif ($arParams["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComment["AUTHOR_ID"]) > 0) {
         $authorityRatingId = CRatings::GetAuthorityRating();
         $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComment["AUTHOR_ID"]);
         if ($arRatingResult["CURRENT_VALUE"] < $arParams["NO_URL_IN_COMMENTS_AUTHORITY"]) {
             $arAllow["ANCHOR"] = "Y";
             $arAllow["CUT_ANCHOR"] = "Y";
         }
     } else {
         $text = preg_replace("#\\[url(.*?)\\](.*?)\\[/url\\]#is", "\\2", $text);
     }
     $text = $p->convert($text, false, false, $arAllow);
     $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|video|table|tr|td|align|user|/*)(.*?)(\\]|>)#is", "", $text);
     $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
     $arComment["TEXT_FORMATED"] = $text;
     if (IntVal($arComment["AUTHOR_ID"]) > 0) {
         $arComment["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arComment["AUTHOR_ID"]));
         $arComment["BlogUser"] = CBlogUser::GetByID($arComment["AUTHOR_ID"], BLOG_BY_USER_ID);
         $arComment["BlogUser"] = CBlogTools::htmlspecialcharsExArray($arComment["BlogUser"]);
Пример #25
0
            $arTopicId[] = $res['TOPIC_ID'];
        } else {
            $arPostId[] = $res['ID'];
        }
    }
    if (!empty($arAuthorId)) {
        foreach ($arParams["RATING_ID"] as $key => $ratingId) {
            $arParams["RATING_ID"][$key] = intval($ratingId);
            $arRatingResult[$arParams["RATING_ID"][$key]] = CRatings::GetRatingResult($arParams["RATING_ID"][$key], array_unique($arAuthorId));
        }
    }
    if (!empty($arPostId)) {
        $arRatingVote['FORUM_POST'] = CRatings::GetRatingVoteResult('FORUM_POST', $arPostId);
    }
    if (!empty($arTopicId)) {
        $arRatingVote['FORUM_TOPIC'] = CRatings::GetRatingVoteResult('FORUM_TOPIC', $arTopicId);
    }
}
/*************** Default data **************************************/
if (!empty($arResult["ERROR_MESSAGE"])) {
    ?>
<div class="forum-note-box forum-note-error">
	<div class="forum-note-box-text"><?php 
    echo ShowError($arResult["ERROR_MESSAGE"], "forum-note-error");
    ?>
</div>
</div>
<?php 
}
if (!empty($arResult["OK_MESSAGE"])) {
    ?>
Пример #26
0
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_VOTES"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_VOTES"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_VOTES"] : 0);
				}
				else
				{
					$arResult["arComments"][$key]["EVENT"]["RATING_USER_VOTE_VALUE"] = 0;
					$arResult["arComments"][$key]["EVENT"]["RATING_USER_HAS_VOTED"] = "N";
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_POSITIVE_VOTES"] = 0;
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_NEGATIVE_VOTES"] = 0;
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_VALUE"] = 0;
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_VOTES"] = 0;
				}
				
				if (strlen($rating_entity_type) > 0)
					$arResult["arComments"][$key]["EVENT_FORMATTED"]["ALLOW_VOTE"] = CRatings::CheckAllowVote(
						array(
							"ENTITY_TYPE_ID" => $rating_entity_type,
							"OWNER_ID" => $arResult["arComments"][$key]["EVENT"]["USER_ID"]
						)
					);
			}
		}
	}
	elseif ($action == "change_favorites" && $GLOBALS["USER"]->IsAuthorized())
	{
		$log_id = intval($_REQUEST["log_id"]);
		if ($arLog = CSocNetLog::GetByID($log_id))
		{
			if ($strRes = CSocNetLogFavorites::Change($GLOBALS["USER"]->GetID(), $log_id))
			{
				if ($strRes == "Y")
					CSocNetLogFollow::Set($GLOBALS["USER"]->GetID(), "L".$log_id, "Y");
				$arResult["bResult"] = $strRes;
Пример #27
0
            $text = preg_replace("#\\[url(.+?)\\](.*?)\\[/url\\]#is", "\\2", $text);
            $text = preg_replace("#\\[video(.+?)\\](.+?)\\[/video\\]#is", "", $text);
            $text = preg_replace("#^(.+?)<cut[\\s]*(/>|>).*?\$#is", "\\1", $text);
            $text = preg_replace("#^(.+?)\\[cut[\\s]*(/\\]|\\]).*?\$#is", "\\1", $text);
            $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|/*)(.*?)(\\]|>)#is", "", $text);
            $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
            $text1 = $text;
            $title = $p->convert($text1, true, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N"));
            $text = $p->convert($text, true, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "N"));
            $text = CBlogTools::DeleteDoubleBR($text);
            $arTmp["TEXT_FORMATED"] = $text;
            $arTmp["DATE_PUBLISH_FORMATED"] = FormatDate($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arTmp["DATE_PUBLISH"], CSite::GetDateFormat("FULL")));
            if ($arTmp["MICRO"] == "Y") {
                $arTmp["TITLE"] = TruncateText(str_replace(array("<br />", "<br>", "'", "&quot;", "&lt;", "&gt;"), "", $title), 60);
                $arTmp["~TITLE"] = htmlspecialcharsback($arTmp["TITLE"]);
            }
            $itemCnt++;
            $arResult[] = $arTmp;
            $ids[] = $arTmp["ID"];
        }
        $arResult["IDS"] = $ids;
    }
    if ($arParams["CACHE_TIME"] > 0) {
        $cache->EndDataCache(array("templateCachedData" => $this->GetTemplateCachedData(), "arResult" => $arResult));
    }
}
if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) {
    $arResult[0]['RATING'] = CRatings::GetRatingVoteResult('BLOG_POST', $arResult["IDS"]);
}
unset($arResult["IDS"]);
$this->IncludeComponentTemplate();
Пример #28
0
 public static function GetUserRank($USER_ID, $strLang = false)
 {
     $USER_ID = intval($USER_ID);
     $arUser = false;
     if ($USER_ID <= 0) {
         return false;
     }
     if (COption::GetOptionString("forum", "SHOW_VOTES", "Y") == "Y") {
         $arUser = CForumUser::GetByUSER_ID($USER_ID);
     } else {
         $authorityRatingId = CRatings::GetAuthorityRating();
         $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $USER_ID);
         if (isset($arRatingResult['CURRENT_VALUE'])) {
             $arUser = array('POINTS' => round(floatval($arRatingResult['CURRENT_VALUE']) / COption::GetOptionString("main", "rating_vote_weight", 1)));
         }
     }
     if ($arUser) {
         if ($strLang === false || strLen($strLang) != 2) {
             $db_res = CForumPoints::GetList(array("MIN_POINTS" => "DESC"), array("<=MIN_POINTS" => $arUser["POINTS"]));
         } else {
             $db_res = CForumPoints::GetListEx(array("MIN_POINTS" => "DESC"), array("<=MIN_POINTS" => $arUser["POINTS"], "LID" => $strLang));
         }
         if ($db_res && ($ar_res = $db_res->Fetch())) {
             return $ar_res;
         }
     }
     return false;
 }
Пример #29
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("forum")) {
    return;
}
$arForum = array();
$db_res = CForumNew::GetList(array(), array());
if ($db_res && ($res = $db_res->GetNext())) {
    do {
        $arForum[intVal($res["ID"])] = $res["NAME"];
    } while ($res = $db_res->GetNext());
}
$arComponentParameters = array("GROUPS" => array("URL_TEMPLATES" => array("NAME" => GetMessage("F_URL_TEMPLATES"))), "PARAMETERS" => array("FID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_FID"), "TYPE" => "LIST", "VALUES" => $arForum, "DEFAULT" => '0'), "TID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_TID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["TID"]}'), "MID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_DEFAULT_MID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["MID"]}'), "SOCNET_GROUP_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_SOCNET_GROUP_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["SOCNET_GROUP_ID"]}'), "USER_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("F_USER_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["USER_ID"]}'), "URL_TEMPLATES_TOPIC_LIST" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_LIST_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic_list.php"), "URL_TEMPLATES_TOPIC" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_READ_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic.php?TID=#TID#"), "URL_TEMPLATES_TOPIC_EDIT" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_TOPIC_NEW_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "topic_edit.php?TID=#TID#&MID=#MID#"), "URL_TEMPLATES_MESSAGE" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_MESSAGE_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "message.php?TID=#TID#&MID=#MID#"), "URL_TEMPLATES_PROFILE_VIEW" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("F_PROFILE_VIEW_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "profile_view.php?UID=#UID#"), "PAGEN" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGEN"), "TYPE" => "STRING", "DEFAULT" => intVal($GLOBALS["NavNum"] + 1)), "PAGE_NAVIGATION_TEMPLATE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => ""), "PAGE_NAVIGATION_WINDOW" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_WINDOW"), "TYPE" => "STRING", "DEFAULT" => "11"), "PAGE_NAVIGATION_SHOW_ALL" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_PAGE_NAVIGATION_SHOW_ALL"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "PATH_TO_SMILE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_DEFAULT_PATH_TO_SMILE"), "TYPE" => "STRING", "DEFAULT" => "/bitrix/images/forum/smile/"), "WORD_LENGTH" => CForumParameters::GetWordLength(), "IMAGE_SIZE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_IMAGE_SIZE"), "TYPE" => "STRING", "DEFAULT" => 500), "MESSAGES_PER_PAGE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_MESSAGES_PER_PAGE"), "TYPE" => "STRING", "DEFAULT" => COption::GetOptionString("forum", "MESSAGES_PER_PAGE", "10")), "DATE_FORMAT" => CForumParameters::GetDateFormat(GetMessage("F_DATE_FORMAT"), "ADDITIONAL_SETTINGS"), "DATE_TIME_FORMAT" => CForumParameters::GetDateTimeFormat(GetMessage("F_DATE_TIME_FORMAT"), "ADDITIONAL_SETTINGS"), "AJAX_TYPE" => CForumParameters::GetAjaxType(), "SET_TITLE" => array(), "CACHE_TIME" => array()));
$arComponentParameters["PARAMETERS"]["SHOW_RATING"] = array("NAME" => GetMessage("SHOW_RATING"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("SHOW_RATING_CONFIG"), "Y" => GetMessage("MAIN_YES"), "N" => GetMessage("MAIN_NO")), "MULTIPLE" => "N", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS", "REFRESH" => "Y");
if ($arCurrentValues["SHOW_RATING"] != "N") {
    $arRatingsList = array();
    $db_res = CRatings::GetList($aSort = array("ID" => "ASC"), array("ACTIVE" => "Y", "ENTITY_ID" => "USER"));
    while ($res = $db_res->Fetch()) {
        $arRatingsList[$res["ID"]] = "[ " . $res["ID"] . " ] " . $res["NAME"];
    }
    $arComponentParameters["PARAMETERS"]["RATING_ID"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("F_RATING_ID"), "TYPE" => "LIST", "VALUES" => $arRatingsList, "DEFAULT" => "", "REFRESH" => "N");
    $arComponentParameters["PARAMETERS"]["RATING_TYPE"] = array("NAME" => GetMessage("RATING_TYPE"), "TYPE" => "LIST", "VALUES" => array("" => GetMessage("RATING_TYPE_CONFIG"), "like" => GetMessage("RATING_TYPE_LIKE_TEXT"), "like_graphic" => GetMessage("RATING_TYPE_LIKE_GRAPHIC"), "standart_text" => GetMessage("RATING_TYPE_STANDART_TEXT"), "standart" => GetMessage("RATING_TYPE_STANDART_GRAPHIC")), "MULTIPLE" => "N", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS");
}
Пример #30
0
 public static function __UpdateComponents($ID, $arFields)
 {
     global $DB;
     $ID = intval($ID);
     $err_mess = CRatings::err_mess() . "<br>Function: __UpdateComponents<br>Line: ";
     $DB->Query("DELETE FROM b_rating_component WHERE RATING_ID={$ID}", false, $err_mess . __LINE__);
     CRatings::__AddComponents($ID, $arFields);
     return true;
 }