コード例 #1
0
ファイル: ratings.php プロジェクト: mrdeadmouse/u136006
 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;
         }
     }
 }
コード例 #2
0
ファイル: vote.ajax.php プロジェクト: webgksupport/alpina
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);
}
コード例 #3
0
ファイル: ajax.php プロジェクト: ASDAFF/bitrix-5
			}

			foreach ($arResult["arComments"] as $key => $arCommentTmp)
			{
				if ($key === 0)
					$rating_entity_type = $arCommentTmp["EVENT"]["RATING_TYPE_ID"];

				$arCommentID[] = $arCommentTmp["EVENT"]["RATING_ENTITY_ID"];
			}

			$arRatingComments = array();
			if(
				!empty($arCommentID)
				&& strlen($rating_entity_type) > 0
			)
				$arRatingComments = CRatings::GetRatingVoteResult($rating_entity_type, $arCommentID);

			foreach($arResult["arComments"] as $key => $arCommentTmp)
			{
				if (array_key_exists($arCommentTmp["EVENT"]["RATING_ENTITY_ID"], $arRatingComments))
				{
					$arResult["arComments"][$key]["EVENT"]["RATING_USER_VOTE_VALUE"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["USER_VOTE"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["USER_VOTE"] : 0);
					$arResult["arComments"][$key]["EVENT"]["RATING_USER_HAS_VOTED"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["USER_HAS_VOTED"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["USER_HAS_VOTED"] : "N");
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_POSITIVE_VOTES"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_POSITIVE_VOTES"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_POSITIVE_VOTES"] : 0);
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_NEGATIVE_VOTES"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_NEGATIVE_VOTES"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_NEGATIVE_VOTES"] : 0);
					$arResult["arComments"][$key]["EVENT"]["RATING_TOTAL_VALUE"] = (isset($arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_VALUE"]) ? $arRatingComments[$arCommentTmp["EVENT"]["RATING_ENTITY_ID"]]["TOTAL_VALUE"] : 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;
コード例 #4
0
ファイル: component.php プロジェクト: Satariall/izurit
            $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();
コード例 #5
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
                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($arParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
                $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
                $arFields = array("POST_ID" => $arBlogPost["ID"], "COMMENT_ID" => $commentId, "arComment" => $arComment, "arAuthor" => $arAuthor, "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($arParams["PATH_TO_USER"])), "RATING_TYPE" => "like", "SHOW_RATING" => $arParams["SHOW_RATING"]);
                $arParams["RATING_TYPE"] = "like";
                CRatingsComponentsMain::GetShowRating($arParams);
                if ($arParams["SHOW_RATING"] == "Y") {
                    $arFields['arRating'] = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arFields["arComment"]["ID"]));
                }
                CMobileHelper::SendPullComment("blog", $arFields);
            }
        }
    }
}
if (!$strError) {
    $arResult["SUCCESS"] = "Y";
} else {
    $arResult["ERROR"] = $strError;
}
echo \Bitrix\Main\Web\Json::encode($arResult);
define('PUBLIC_AJAX_MODE', true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
die;
コード例 #6
0
ファイル: component.php プロジェクト: Satariall/izurit
     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());
コード例 #7
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"])) {
    ?>
コード例 #8
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
                if ($key === 0) {
                    $rating_entity_type = $arCommentTmp["EVENT"]["RATING_TYPE_ID"];
                }
                if ($key >= $arParams["COMMENTS_IN_EVENT"] && (intval($arResult["LAST_LOG_TS"]) <= 0 || $arResult["COUNTER_TYPE"] == "**" && MakeTimeStamp($arCommentTmp["EVENT"]["LOG_DATE"]) - intval($arResult["TZ_OFFSET"]) <= $arResult["LAST_LOG_TS"])) {
                    //
                } else {
                    if ($arResult["COUNTER_TYPE"] == "**" && intval($arResult["LAST_LOG_TS"]) > 0 && MakeTimeStamp($arCommentTmp["EVENT"]["LOG_DATE"]) - intval($arResult["TZ_OFFSET"]) >= $arResult["LAST_LOG_TS"] && $arCommentTmp["EVENT"]["USER_ID"] != $GLOBALS["USER"]->GetID()) {
                        $arResult["NEW_COMMENTS"]++;
                    }
                    $arCommentTmp["CAN_EDIT"] = $bHasEditCallback && intval($arCommentTmp["EVENT"]["USER_ID"]) > 0 && intval($arCommentTmp["EVENT"]["USER_ID"]) == $GLOBALS["USER"]->GetId() ? "Y" : "N";
                    $arCommentTmp["CAN_DELETE"] = $bHasDeleteCallback && $arCommentTmp["CAN_EDIT"] == "Y" ? "Y" : "N";
                    $arCommentsFullListCut[] = $arCommentTmp;
                }
                $arCommentID[] = $arCommentTmp["EVENT"]["RATING_ENTITY_ID"];
            }
            $arEvent["COMMENTS"] = array_reverse($arCommentsFullListCut);
            $arResult["RATING_COMMENTS"] = array();
            if (!empty($arCommentID) && $arParams["SHOW_RATING"] == "Y" && strlen($rating_entity_type) > 0) {
                $arResult["RATING_COMMENTS"] = CRatings::GetRatingVoteResult($rating_entity_type, $arCommentID);
            }
        } elseif ($arResult["COUNTER_TYPE"] == "**") {
            foreach ($arCommentsFullList as $key => $arCommentTmp) {
                if (intval($arResult["LAST_LOG_TS"]) > 0 && MakeTimeStamp($arCommentTmp["EVENT"]["LOG_DATE"]) - intval($arResult["TZ_OFFSET"]) >= $arResult["LAST_LOG_TS"]) {
                    $arResult["NEW_COMMENTS"]++;
                }
            }
        }
    }
}
$arResult["Event"] = $arEvent;
$this->IncludeComponentTemplate();
コード例 #9
0
ファイル: template.php プロジェクト: mrdeadmouse/u136006
	</a>
</div>
<?php 
}
global $by, $order;
/********************************************************************
				Input params
********************************************************************/
/*************** Ratings *********************************************/
if ($arParams["SHOW_RATING"] == 'Y') {
    $arFileId = array();
    foreach ($arResult["GRID_DATA"] as $data) {
        $arFileId[] = $data['data']['ID'];
    }
    if (!empty($arFileId)) {
        $arResult['RATING'] = CRatings::GetRatingVoteResult('IBLOCK_ELEMENT', $arFileId);
    }
    if ($arParams["RATING_TYPE"] == "") {
        $sRatingVoteType = COption::GetOptionString("main", "rating_vote_type", "standart");
        if ($sRatingVoteType == "like_graphic") {
            $arParams["RATING_TYPE"] = "like";
        } else {
            if ($sRatingVoteType == "standart") {
                $arParams["RATING_TYPE"] = "standart_text";
            }
        }
    } else {
        if ($arParams["RATING_TYPE"] == "like_graphic") {
            $arParams["RATING_TYPE"] = "like";
        } else {
            if ($arParams["RATING_TYPE"] == "standart") {
コード例 #10
0
ファイル: include.php プロジェクト: mrdeadmouse/u136006
 function __SLMGetLogRecord($logID, $arParams, $current_page_date)
 {
     $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("EVENT", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT"])) {
             $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
         }
         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", "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()) {
             $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["EVENT_ID"]);
             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")) {
                     $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"]) && is_array($arSiteWorkgroupsPage) && array_key_exists(SITE_ID, $arSiteWorkgroupsPage)) {
                     $arEvent["URL"] = str_replace("#GROUPS_PATH#", $arSiteWorkgroupsPage[SITE_ID], $arEvent["URL"]);
                 }
             }
             $arEventTmp = CSocNetLogTools::FindLogEventByID($arEvent["EVENT_ID"]);
             if ($arEventTmp && is_array($arEventTmp) && array_key_exists("CLASS_FORMAT", $arEventTmp) && array_key_exists("METHOD_FORMAT", $arEventTmp)) {
                 $arParams["MOBILE"] = "Y";
                 $arParams["NEW_TEMPLATE"] = "Y";
                 $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"])) {
                         $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", "TITLE_24", "TITLE_24_2", "IS_IMPORTANT", "MESSAGE", "DATETIME_FORMATTED", "LOG_DATE_FORMAT", "DESCRIPTION", "DESCRIPTION_STYLE", "AVATAR_STYLE", "HAS_COMMENTS");
                         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", "SOURCE_ID", "MODULE_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");
                         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"];
                 }
             }
             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";
             }
             $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");
         }
         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 (!array_key_exists("COMMENTS_PARAMS", $arEvent["FIELDS_FORMATTED"])) {
         $entities_xml_id = array("tasks" => array("TASK", "TK", "FORUM|COMMENT"), "forum" => array("FORUM", "FM", "FORUM|COMMENT"), "photo_photo" => array("PHOTO", "PH", "FORUM|COMMENT"), "sonet" => array("SOCNET", "SC", ""), "lists_new_element" => array("WF", "WF", ""));
         if (array_key_exists($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"], $entities_xml_id) && intval($arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"]) > 0) {
             $arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => $entities_xml_id[$arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]][1], "ENTITY_XML_ID" => $entities_xml_id[$arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]][0] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"], "NOTIFY_TAGS" => $entities_xml_id[$arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]][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" => "");
         }
     }
     $timestamp = MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (isset($arParams["FIELDS_FORMATTED"]["EVENT"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT"]["LOG_DATE_FORMAT"] : $arParams["EVENT"]["LOG_DATE"]));
     $timeFormated = FormatDate(GetMessage("SONET_SLM_FORMAT_TIME"), $timestamp);
     if (strlen($arParams["DATE_TIME_FORMAT"]) <= 0) {
         $dateTimeFormated = __SMLFormatDate($timestamp);
     } else {
         $dateTimeFormated = FormatDate($arParams["DATE_TIME_FORMAT"] == "FULL" ? $GLOBALS["DB"]->DateFormatToPHP(str_replace(":SS", "", FORMAT_DATETIME)) : $arParams["DATE_TIME_FORMAT"], $timestamp);
     }
     if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
         $dateTimeFormated = ToLower($dateTimeFormated);
     }
     // 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["FIELDS_FORMATTED"]["LOG_TIME_FORMAT"] = $timeFormated;
     if (strlen($arParams["DATE_TIME_FORMAT"]) <= 0) {
         if (array_key_exists("EVENT_FORMATTED", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && array_key_exists("LOG_DATE_FORMAT", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"])) {
             $bToday = ConvertTimeStamp(MakeTimeStamp($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]), "SHORT") == ConvertTimeStamp();
             if ($bToday) {
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $timeFormated;
             } else {
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated;
             }
         } else {
             $bToday = $arEvent["FIELDS_FORMATTED"]["LOG_DATE_DAY"] == ConvertTimeStamp();
             if ($bToday) {
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $timeFormated;
             } else {
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated;
             }
         }
     } else {
         $arFormat = array("tommorow" => "tommorow, " . GetMessage("SONET_SLM_FORMAT_TIME"), "today" => "today, " . GetMessage("SONET_SLM_FORMAT_TIME"), "yesterday" => "yesterday, " . GetMessage("SONET_SLM_FORMAT_TIME"), "" => date("Y", $timestamp) == date("Y") ? GetMessage("SONET_SLM_FORMAT_DATE") : GetMessage("SONET_SLM_FORMAT_DATE_YEAR"));
         $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = FormatDate($arFormat, $timestamp);
     }
     if (is_array($arEvent["FIELDS_FORMATTED"]["EVENT"])) {
         if ($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 {
                 $feature = CSocNetLogTools::FindFeatureByEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]);
                 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"]) ? "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" && is_object($GLOBALS["USER"]) && (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;
         $bExtranetUser = CModule::IncludeModule("extranet") && !CExtranet::IsIntranetUser();
         $arGroupID = CSocNetLogTools::GetAvailableGroups($bExtranetUser ? "Y" : "N");
         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) || $arDestination["TYPE"] == "DR" && $bExtranetUser)) {
                     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"]) + $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"] - $arParams["DESTINATION_LIMIT_SHOW"];
                 $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] = array_slice($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"], 0, $arParams["DESTINATION_LIMIT_SHOW"]);
             }
         }
     }
     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"]);
     }
     if (array_key_exists("FAVORITES_USER_ID", $arEvent) && intval($arEvent["FAVORITES_USER_ID"]) > 0) {
         $arEvent["FIELDS_FORMATTED"]["FAVORITES"] = "Y";
     } else {
         $arEvent["FIELDS_FORMATTED"]["FAVORITES"] = "N";
     }
     return $arEvent["FIELDS_FORMATTED"];
 }
コード例 #11
0
ファイル: vote.php プロジェクト: rasuldev/torino
<?php

define("NO_KEEP_STATISTIC", "Y");
define("NO_AGENT_STATISTIC", "Y");
define("PUBLIC_AJAX_MODE", true);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$entityTypeId = $_REQUEST['ENTITY_TYPE_ID'];
$entityId = intval($_REQUEST['ENTITY_ID']);
$voteAction = $_REQUEST['VOTE_ACTION'] == 'plus' ? 'plus' : 'minus';
$userId = $USER->GetId();
$arRatingResult = CRatings::GetRatingVoteResult($entityTypeId, $entityId, $USER->GetId());
if (empty($arRatingResult)) {
    $arRatingResult['USER_HAS_VOTED'] = $USER->IsAuthorized() ? "N" : "Y";
    $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.php");
include_once $path;
$resultValue = $arRatingResult['TOTAL_VALUE'];
$resultStatus = $resultValue < 0 ? 'minus' : 'plus';
$resultTitle = sprintf($MESS["RATING_COMPONENT_DESC"], $arRatingResult['TOTAL_VOTES'], $arRatingResult['TOTAL_POSITIVE_VOTES'], $arRatingResult['TOTAL_NEGATIVE_VOTES']);
echo '{"result" : "true", "resultValue" : "' . $resultValue . '", "resultStatus" : "' . $resultStatus . '", "resultTitle" : "' . $resultTitle . '"}';
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
コード例 #12
0
ファイル: class.php プロジェクト: webgksupport/alpina
 protected function prepareParams(array &$arParams, array &$arResult)
 {
     // Action params
     /*@param string $arParams["mfi"] contains hash of something to add new uploaded file into session array */
     $arParams["mfi"] = trim($arParams["mfi"]);
     // List params
     /*@param string $arParams["ENTITY_XML_ID"] main param that means ID */
     $arParams["ENTITY_XML_ID"] = trim($arParams["ENTITY_XML_ID"]);
     /*@param array $arParams["RECORDS"] contains data to view */
     $arParams["RECORDS"] = is_array($arParams["RECORDS"]) ? $arParams["RECORDS"] : array();
     $arParams["NAV_STRING"] = !!$arParams["NAV_STRING"] && is_string($arParams["NAV_STRING"]) ? $arParams["NAV_STRING"] : "";
     //$arParams["NAV_RESULT"] = (!!$arParams["NAV_STRING"] && is_object($arParams["NAV_RESULT"]) ? $arParams["NAV_RESULT"] : false);
     $arParams["PREORDER"] = $arParams["PREORDER"] == "Y" ? "Y" : "N";
     $arParams["RIGHTS"] = is_array($arParams["RIGHTS"]) ? $arParams["RIGHTS"] : array();
     foreach (array("MODERATE", "EDIT", "DELETE") as $act) {
         $arParams["RIGHTS"][$act] = in_array(strtoupper($arParams["RIGHTS"][$act]), array("Y", "ALL", "OWN", "OWNLAST")) ? $arParams["RIGHTS"][$act] : "N";
     }
     $arParams["LAST_RECORD"] = array();
     // Answer params
     /*@param int $arParams["RESULT"] contains id of new record for cutting out and sending back*/
     $arParams["RESULT"] = intval($arParams["RESULT"] ?: $this->request->getPost("MID"));
     /*@param array $arParams["PUSH&PULL"] contains record id to pushing other clients */
     $arParams["PUSH&PULL"] = isset($arParams["~PUSH&PULL"]) ? $arParams["~PUSH&PULL"] : $arParams["PUSH&PULL"];
     $arParams["MODE"] = is_array($arParams["PUSH&PULL"]) && $arParams["PUSH&PULL"]["ID"] > 0 && $arParams["MODE"] == "PULL_MESSAGE" ? "PULL_MESSAGE" : "PLAIN";
     /*@param string $arParams["NOTIFY_TAG"] params for bottom notifier */
     $arParams["NOTIFY_TAG"] = trim($arParams["NOTIFY_TAG"]);
     $arParams["NOTIFY_TEXT"] = trim($arParams["NOTIFY_TEXT"]);
     $arParams["ERROR_MESSAGE"] = trim($arParams["ERROR_MESSAGE"]);
     $arParams["OK_MESSAGE"] = trim($arParams["OK_MESSAGE"]);
     // Template params
     $arParams["VISIBLE_RECORDS_COUNT"] = !!$arParams["NAV_RESULT"] ? intval($arParams["VISIBLE_RECORDS_COUNT"]) : 0;
     $arParams["TEMPLATE_ID"] = !!$arParams["TEMPLATE_ID"] ? $arParams["TEMPLATE_ID"] : 'COMMENT_' . $arParams["ENTITY_XML_ID"] . '_';
     $arParams["AVATAR_SIZE"] = $arParams["AVATAR_SIZE"] > 0 ? $arParams["AVATAR_SIZE"] : 39;
     //$arParams["IMAGE_SIZE"] = ($arParams["IMAGE_SIZE"] > 0 ? $arParams["IMAGE_SIZE"] : 30);
     $arParams['SHOW_MINIMIZED'] = $arParams['SHOW_MINIMIZED'] == "Y" ? "Y" : "N";
     $arParams["NAME_TEMPLATE"] = !!$_REQUEST["NAME_TEMPLATE"] ? $_REQUEST["NAME_TEMPLATE"] : \CSite::GetNameFormat();
     $arParams["SHOW_LOGIN"] = $_REQUEST["SHOW_LOGIN"] == "Y" ? "Y" : "N";
     $arParams["DATE_TIME_FORMAT"] = trim($arParams["DATE_TIME_FORMAT"]);
     $arParams["SHOW_POST_FORM"] = $arParams["SHOW_POST_FORM"] == "Y" ? "Y" : "N";
     $arParams["BIND_VIEWER"] = $arParams["BIND_VIEWER"] == "Y" ? "Y" : "N";
     $arParams["SIGN"] = $this->sign->sign($arParams["ENTITY_XML_ID"], "main.post.list");
     $arParams["VIEW_URL"] = trim($arParams["VIEW_URL"]);
     $arParams["EDIT_URL"] = trim($arParams["EDIT_URL"]);
     $arParams["MODERATE_URL"] = trim($arParams["MODERATE_URL"]);
     $arParams["DELETE_URL"] = trim($arParams["DELETE_URL"]);
     $arParams["AUTHOR_URL"] = trim($arParams["PATH_TO_USER"] ?: $arParams["AUTHOR_URL"]);
     if ($arParams["VISIBLE_RECORDS_COUNT"] > 0) {
         if ($arParams["NAV_RESULT"]->bShowAll) {
             $arParams["VISIBLE_RECORDS_COUNT"] = 0;
         } else {
             if (array_key_exists($arParams['RESULT'], $arParams["RECORDS"])) {
                 $arParams["VISIBLE_RECORDS_COUNT"] = count($arParams["RECORDS"]);
             } else {
                 if (0 < $arParams["NAV_RESULT"]->NavRecordCount && $arParams["NAV_RESULT"]->NavRecordCount <= $arParams["VISIBLE_RECORDS_COUNT"]) {
                     $arParams["VISIBLE_RECORDS_COUNT"] = $arParams["NAV_RESULT"]->NavRecordCount;
                 } else {
                     if (isset($_REQUEST["PAGEN_" . $arParams["NAV_RESULT"]->NavNum]) || isset($_REQUEST["FILTER"]) && $arParams["ENTITY_XML_ID"] == $_REQUEST["ENTITY_XML_ID"]) {
                         $arParams["VISIBLE_RECORDS_COUNT"] = 0;
                     }
                 }
             }
         }
         if (!!$arParams["NAV_STRING"]) {
             $path = "PAGEN_" . $arParams["NAV_RESULT"]->NavNum . "=";
             if ($arParams["VISIBLE_RECORDS_COUNT"] > 0) {
                 $path .= $arParams["NAV_RESULT"]->NavPageNomer;
             } else {
                 if ($arParams["NAV_RESULT"]->bDescPageNumbering) {
                     $path .= $arParams["NAV_RESULT"]->NavPageNomer - 1;
                 } else {
                     $path .= $arParams["NAV_RESULT"]->NavPageNomer + 1;
                 }
             }
             $arParams["NAV_STRING"] .= (strpos($arParams["NAV_STRING"], "?") === false ? "?" : "&") . $path;
         }
     }
     if (!empty($arParams["RECORDS"])) {
         if ($arParams["VISIBLE_RECORDS_COUNT"] > 0) {
             $list = array();
             $res = 0;
             for ($ii = 0; $ii < $arParams["VISIBLE_RECORDS_COUNT"]; $ii++) {
                 $res = array_shift($arParams["RECORDS"]);
                 $list[$res["ID"]] = $res;
             }
             $arParams["RECORDS"] = $list;
         }
         $arParams["LAST_RECORD"] = end($arParams["RECORDS"]);
         reset($arParams["RECORDS"]);
         if ($arParams["PREORDER"] === "N") {
             $arParams["RECORDS"] = array_reverse($arParams["RECORDS"], true);
         }
         if (!empty($arParams["RATING_TYPE_ID"])) {
             $arParams["RATING_RESULTS"] = CRatings::GetRatingVoteResult($arParams["RATING_TYPE_ID"], array_keys($arParams["RECORDS"]));
         }
         $arParams["~RECORDS"] = $arParams["RECORDS"];
         foreach ($arParams["~RECORDS"] as $key => &$res) {
             $arParams["RECORDS"][$key] = $this->buildComment($res);
         }
     }
     $arResult["AUTHOR"] = array("ID" => $this->getUser()->getId(), "NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], array("NAME" => $this->getUser()->getFirstName(), "LAST_NAME" => $this->getUser()->getLastName(), "SECOND_NAME" => $this->getUser()->getSecondName(), "LOGIN" => $this->getUser()->getLogin(), "NAME_LIST_FORMATTED" => ""), $arParams["SHOW_LOGIN"] != "N", false), "AVATAR" => \CFile::ResizeImageGet($_SESSION["SESS_AUTH"]["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT));
 }
コード例 #13
0
ファイル: include.php プロジェクト: k-kalashnikov/geekcon_new
 function __SLEGetLogRecord($logID, $arParams, $arCurrentUserSubscribe, $current_page_date)
 {
     $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 . "_" . CTimeZone::GetOffset();
     $cache_path = "/sonet/log/";
     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);
                 }
             }
         }
     } 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_CARD_" . intval($arEvent["USER_ID"] / 100));
                 $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")) {
                     $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
                     while ($arSite = $rsSite->Fetch()) {
                         $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroup_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]);
                     }
                 }
                 if (is_set($arEvent["URL"]) && is_array($arSiteWorkgroupsPage) && array_key_exists(SITE_ID, $arSiteWorkgroupsPage)) {
                     $arEvent["URL"] = str_replace("#GROUPS_PATH#", $arSiteWorkgroupsPage[SITE_ID], $arEvent["URL"]);
                 }
             }
             $arEventTmp = CSocNetLogTools::FindLogEventByID($arEvent["EVENT_ID"]);
             if ($arEventTmp && is_array($arEventTmp) && array_key_exists("CLASS_FORMAT", $arEventTmp) && array_key_exists("METHOD_FORMAT", $arEventTmp)) {
                 $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"])) {
                         $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", "IS_IMPORTANT", "MESSAGE", "MESSAGE_TITLE_24", "DATETIME_FORMATTED");
                         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", "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");
                         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]);
                                 }
                             }
                         }
                     }
                 }
             }
             if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
                 $path2Entity = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arEvent["ENTITY_ID"]));
             } else {
                 $path2Entity = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arEvent["ENTITY_ID"]));
             }
             $dateFormated = FormatDate($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATE), MakeTimeStamp(is_array($arEvent["FIELDS_FORMATTED"]) && array_key_exists("EVENT_FORMATTED", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && array_key_exists("LOG_DATE_FORMAT", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"])));
             $timeFormated = FormatDateFromDB(is_array($arEvent["FIELDS_FORMATTED"]) && array_key_exists("EVENT_FORMATTED", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && array_key_exists("LOG_DATE_FORMAT", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) ? $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 ? '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(is_array($arEvent["FIELDS_FORMATTED"]) && array_key_exists("EVENT_FORMATTED", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && array_key_exists("LOG_DATE_FORMAT", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) ? $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);
             }
             // 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"];
             if (array_key_exists("EVENT_FORMATTED", $arEvent["FIELDS_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && array_key_exists("LOG_DATE_FORMAT", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"])) {
                 if (ConvertTimeStamp(MakeTimeStamp($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]), "SHORT") == ConvertTimeStamp()) {
                     $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $timeFormated;
                 } else {
                     $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated;
                 }
             } elseif ($arEvent["FIELDS_FORMATTED"]["LOG_DATE_DAY"] == ConvertTimeStamp()) {
                 $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $timeFormated;
             } else {
                 $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();
             }
         }
     }
     $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin();
     if (is_array($arCurrentUserSubscribe)) {
         $arEvent["FIELDS_FORMATTED"]["TRANSPORT"] = __SLEGetTransport($arEvent, $arCurrentUserSubscribe);
     }
     $array_key = $arEvent["ENTITY_TYPE"] . "_" . $arEvent["ENTITY_ID"] . "_" . $arEvent["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 {
         $feature = CSocNetLogTools::FindFeatureByEventID($arEvent["EVENT_ID"]);
         if ($feature && $arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) {
             $GLOBALS["CurUserCanAddComments"][$array_key] = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arEvent["ENTITY_TYPE"], $arEvent["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 = array();
         if (!empty($GLOBALS["SONET_GROUPS_ID_AVAILABLE"])) {
             $arGroupID = $GLOBALS["SONET_GROUPS_ID_AVAILABLE"];
         } else {
             // get tagged cached available groups and intersect
             $cache = new CPHPCache();
             $cache_id = $GLOBALS["USER"]->GetID();
             $cache_path = "/sonet/groups_available/";
             if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
                 $arCacheVars = $cache->GetVars();
                 $arGroupID = $arCacheVars["arGroupID"];
             } else {
                 $cache->StartDataCache($cache_time, $cache_id, $cache_path);
                 if (defined("BX_COMP_MANAGED_CACHE")) {
                     $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                     $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_user2group_U" . $GLOBALS["USER"]->GetID());
                     $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group");
                 }
                 $rsGroup = CSocNetGroup::GetList(array(), array("CHECK_PERMISSIONS" => $GLOBALS["USER"]->GetID()), false, false, array("ID"));
                 while ($arGroup = $rsGroup->Fetch()) {
                     $arGroupID[] = $arGroup["ID"];
                 }
                 $arCacheData = array("arGroupID" => $arGroupID);
                 $cache->EndDataCache($arCacheData);
                 if (defined("BX_COMP_MANAGED_CACHE")) {
                     $GLOBALS["CACHE_MANAGER"]->EndTagCache();
                 }
             }
             $GLOBALS["SONET_GROUPS_ID_AVAILABLE"] = $arGroupID;
         }
         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)) {
                     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"];
 }
コード例 #14
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
    }
    // avatars
    if ($arResult['TASK']["CREATED_BY_PHOTO"] > 0) {
        $imageFile = CFile::GetFileArray($arResult['TASK']["CREATED_BY_PHOTO"]);
        if ($imageFile !== false) {
            $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 58, "height" => 58), BX_RESIZE_IMAGE_EXACT, false);
            $arResult['TASK']["CREATED_BY_PHOTO"] = $arFileTmp["src"];
        } else {
            $arResult['TASK']["CREATED_BY_PHOTO"] = false;
        }
    }
    if ($arResult['TASK']["RESPONSIBLE_PHOTO"] > 0) {
        $imageFile = CFile::GetFileArray($arResult['TASK']["RESPONSIBLE_PHOTO"]);
        if ($imageFile !== false) {
            $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 58, "height" => 58), BX_RESIZE_IMAGE_EXACT, false);
            $arResult['TASK']["RESPONSIBLE_PHOTO"] = $arFileTmp["src"];
        } else {
            $arResult['TASK']["RESPONSIBLE_PHOTO"] = false;
        }
    }
    // for buttons only
    if (isset($arParams['TASK_ID']) && in_array('buttons', $arResult['BLOCKS'])) {
        // ratings
        if (intval($arResult['TASK']['ID'])) {
            $arResult["RATING"] = CRatings::GetRatingVoteResult("TASK", $arResult['TASK']['ID']);
        }
    }
} catch (Exception $e) {
    return false;
}
$this->IncludeComponentTemplate();
コード例 #15
0
ファイル: component.php プロジェクト: akniyev/arteva.ru
	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")
{
コード例 #16
0
ファイル: template_message.php プロジェクト: Satariall/izurit
function __forum_default_template_show_message($arMessages, $message, $arResult, $arParams, $component = false)
{
    $message = is_array($message) ? $message : array();
    $arMessages = is_array($arMessages) ? $arMessages : array($arMessages);
    $arResult = is_array($arResult) ? $arResult : array($arResult);
    if ($arParams["SHOW_RATING"] == 'Y') {
        $arAuthorId = array();
        $arPostId = array();
        $arTopicId = array();
        foreach ($arMessages as $res) {
            $arAuthorId[] = $res['AUTHOR_ID'];
            if ($res['NEW_TOPIC'] == "Y") {
                $arTopicId[] = $res['TOPIC_ID'];
            } else {
                $arPostId[] = $res['ID'];
            }
        }
        if (!empty($arAuthorId)) {
            $arRatingResult = CRatings::GetRatingResult($arParams["RATING_ID"], $arAuthorId);
        }
        if (!empty($arPostId)) {
            $arRatingVote['FORUM_POST'] = CRatings::GetRatingVoteResult('FORUM_POST', $arPostId);
        }
        if (!empty($arTopicId)) {
            $arRatingVote['FORUM_TOPIC'] = CRatings::GetRatingVoteResult('FORUM_TOPIC', $arTopicId);
        }
    }
    $iCount = count($arMessages);
    // messages count
    $iNumber = 0;
    // message number in list
    foreach ($arMessages as $res) {
        $iNumber++;
        if ($arParams["SHOW_VOTE"] == "Y" && $res["PARAM1"] == "VT" && intVal($res["PARAM2"]) > 0 && IsModuleInstalled("vote")) {
            ?>
		<div class="forum-info-box forum-post-vote">
			<div class="forum-info-box-inner">
				<a name="message<?php 
            echo $res["ID"];
            ?>
"></a><?php 
            $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:voting.current", $arParams["VOTE_TEMPLATE"], array("VOTE_ID" => $res["PARAM2"], "VOTE_CHANNEL_ID" => $arParams["VOTE_CHANNEL_ID"], "PERMISSION" => $arResult["VOTE_PERMISSION"], "VOTE_RESULT_TEMPLATE" => POST_FORM_ACTION_URI, "CACHE_TIME" => $arParams["CACHE_TIME"], "NEED_SORT" => "N", "SHOW_RESULTS" => "Y"), $component && $component->__component && $component->__component->__parent ? $component->__component->__parent : null, array("HIDE_ICONS" => "Y"));
            ?>
			</div>
		</div>
		<?php 
        }
        ?>
<!--MSG_<?php 
        echo $res["ID"];
        ?>
--><?php 
        ?>
<table cellspacing="0" border="0" class="forum-post-table <?php 
        echo $iNumber == 1 ? "forum-post-first " : "";
        echo $iNumber == $iCount ? "forum-post-last " : "";
        echo $iNumber % 2 == 1 ? "forum-post-odd " : "forum-post-even ";
        echo $res["APPROVED"] == "Y" ? "" : " forum-post-hidden ";
        echo in_array($res["ID"], $message) ? " forum-post-selected " : "";
        ?>
" <?php 
        ?>
id="message_block_<?php 
        echo $res["ID"];
        ?>
" bx-author-name="<?php 
        echo htmlspecialcharsbx($res["~AUTHOR_NAME"]);
        ?>
" bx-author-id="<?php 
        echo $res["AUTHOR_ID"];
        ?>
">
				<tbody>
				<tr>
				<td class="forum-cell-user">
					<div class="forum-user-info">
						<?php 
        if ($res["AUTHOR_ID"] > 0) {
            ?>
							<div class="forum-user-name"><a href="<?php 
            echo $res["URL"]["AUTHOR"];
            ?>
"><span><?php 
            echo $res["AUTHOR_NAME"];
            ?>
</span></a></div>
							<?php 
            if (is_array($res["AVATAR"]) && !empty($res["AVATAR"]["HTML"])) {
                ?>
								<div class="forum-user-avatar"><?php 
                ?>
<a href="<?php 
                echo $res["URL"]["AUTHOR"];
                ?>
" title="<?php 
                echo GetMessage("F_AUTHOR_PROFILE");
                ?>
"><?php 
                echo $res["AVATAR"]["HTML"];
                ?>
</a></div>
								<?php 
            } else {
                ?>
								<div class="forum-user-register-avatar"><?php 
                ?>
<a href="<?php 
                echo $res["URL"]["AUTHOR"];
                ?>
" title="<?php 
                echo GetMessage("F_AUTHOR_PROFILE");
                ?>
"><span><!-- ie --></span></a></div>
								<?php 
            }
        } else {
            ?>
							<div class="forum-user-name"><span><?php 
            echo $res["AUTHOR_NAME"];
            ?>
</span></div>
							<div class="forum-user-guest-avatar"><!-- ie --></div>
							<?php 
        }
        if (!empty($res["AUTHOR_STATUS"])) {
            ?>
							<div class="forum-user-status <?php 
            echo !empty($res["AUTHOR_STATUS_CODE"]) ? "forum-user-" . $res["AUTHOR_STATUS_CODE"] . "-status" : "";
            ?>
"><?php 
            ?>
<span><?php 
            echo $res["AUTHOR_STATUS"];
            ?>
</span></div>
							<?php 
        }
        ?>
						<div class="forum-user-additional">
							<?php 
        if (intVal($res["NUM_POSTS"]) > 0) {
            ?>
								<span><?php 
            echo GetMessage("F_NUM_MESS");
            ?>
 <span><?php 
            echo $res["NUM_POSTS"];
            ?>
</span></span>
								<?php 
        }
        if (COption::GetOptionString("forum", "SHOW_VOTES", "Y") == "Y" && $res["AUTHOR_ID"] > 0 && ($res["NUM_POINTS"] > 0 || $res["VOTES"]["ACTION"] == "VOTE" || $res["VOTES"]["ACTION"] == "UNVOTE")) {
            ?>
								<span><?php 
            echo GetMessage("F_POINTS");
            ?>
 <span><?php 
            echo $res["NUM_POINTS"];
            ?>
</span><?php 
            if ($res["VOTING"] == "VOTE" || $res["VOTING"] == "UNVOTE") {
                ?>
&nbsp;(<span class="forum-vote-user"><?php 
                ?>
<a onclick="return fasessid(this);" href="<?php 
                echo $res["URL"]["AUTHOR_VOTE"];
                ?>
" title="<?php 
                echo $res["VOTING"] == "VOTE" ? GetMessage("F_NO_VOTE_DO") : GetMessage("F_NO_VOTE_UNDO");
                ?>
"><?php 
                echo $res["VOTING"] == "VOTE" ? "+" : "-";
                ?>
</a></span>)<?php 
            }
            ?>
</span>
								<?php 
        }
        if ($arParams["SHOW_RATING"] == 'Y' && $res["AUTHOR_ID"] > 0) {
            ?>
								<span>
				<?php 
            $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.result", "", array("RATING_ID" => $arParams["RATING_ID"], "ENTITY_ID" => $arRatingResult[$res['AUTHOR_ID']]['ENTITY_ID'], "CURRENT_VALUE" => $arRatingResult[$res['AUTHOR_ID']]['CURRENT_VALUE'], "PREVIOUS_VALUE" => $arRatingResult[$res['AUTHOR_ID']]['PREVIOUS_VALUE']), null, array("HIDE_ICONS" => "Y"));
            ?>
				</span>
								<?php 
        }
        if (!empty($res["~DATE_REG"])) {
            ?>
								<span><?php 
            echo GetMessage("F_DATE_REGISTER");
            ?>
 <span><?php 
            echo $res["DATE_REG"];
            ?>
</span></span>
								<?php 
        }
        ?>
						</div>
						<?php 
        if (!empty($res["DESCRIPTION"])) {
            ?>
							<div class="forum-user-description"><span><?php 
            echo $res["DESCRIPTION"];
            ?>
</span></div>
							<?php 
        }
        ?>
					</div>
				</td>
				<td class="forum-cell-post">
					<span style='position:absolute;'><a id="message<?php 
        echo $res["ID"];
        ?>
">&nbsp;</a></span><?php 
        /* IE9 */
        ?>
					<div class="forum-post-date">
						<div class="forum-post-number"><noindex><a href="<?php 
        echo $res["URL"]["MESSAGE"];
        ?>
#message<?php 
        echo $res["ID"];
        ?>
" <?php 
        ?>
onclick="prompt(oText['ml'], (location.protocol + '//' + location.host + this.getAttribute('href'))); return false;" title="<?php 
        echo GetMessage("F_ANCHOR");
        ?>
" rel="nofollow">#<?php 
        echo $res["NUMBER"];
        ?>
</a></noindex><?php 
        if ($arResult["USER"]["PERMISSION"] >= "Q" && $res["SHOW_CONTROL"] != "N") {
            ?>
&nbsp;<input type="checkbox" name="message_id[]" value="<?php 
            echo $res["ID"];
            ?>
" id="message_id_<?php 
            echo $res["ID"];
            ?>
_" <?php 
            if (in_array($res["ID"], $message)) {
                ?>
 checked="checked" <?php 
            }
            if (isset($arParams['iIndex'])) {
                ?>
 onclick="SelectPost(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, <?php 
                echo $arParams['iIndex'];
                ?>
, this.value)" /><?php 
            } else {
                ?>
 onclick="SelectPost(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode)" /><?php 
            }
        }
        ?>
</div>
						<?php 
        if ($arParams["SHOW_RATING"] == 'Y') {
            ?>
						<div class="forum-post-rating" style="float: right;padding-right: 10px; padding-top: 2px;">
							<?php 
            $voteEntityType = $res['NEW_TOPIC'] == "Y" ? "FORUM_TOPIC" : "FORUM_POST";
            $voteEntityId = $res['NEW_TOPIC'] == "Y" ? $res['TOPIC_ID'] : $res['ID'];
            $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arParams["RATING_TYPE"], array("ENTITY_TYPE_ID" => $voteEntityType, "ENTITY_ID" => $voteEntityId, "OWNER_ID" => $res['AUTHOR_ID'], "USER_VOTE" => $arRatingVote[$voteEntityType][$voteEntityId]['USER_VOTE'], "USER_HAS_VOTED" => $arRatingVote[$voteEntityType][$voteEntityId]['USER_HAS_VOTED'], "TOTAL_VOTES" => $arRatingVote[$voteEntityType][$voteEntityId]['TOTAL_VOTES'], "TOTAL_POSITIVE_VOTES" => $arRatingVote[$voteEntityType][$voteEntityId]['TOTAL_POSITIVE_VOTES'], "TOTAL_NEGATIVE_VOTES" => $arRatingVote[$voteEntityType][$voteEntityId]['TOTAL_NEGATIVE_VOTES'], "TOTAL_VALUE" => $arRatingVote[$voteEntityType][$voteEntityId]['TOTAL_VALUE'], "PATH_TO_USER_PROFILE" => $arParams["~URL_TEMPLATES_PROFILE_VIEW"]), $arParams["component"], array("HIDE_ICONS" => "Y"));
            ?>
						</div>
						<?php 
        }
        ?>
						<span><?php 
        echo $res["POST_DATE"];
        ?>
</span>
					</div>
					<div class="forum-post-entry">
						<div class="forum-post-text" id="message_text_<?php 
        echo $res["ID"];
        ?>
"><?php 
        echo $res["POST_MESSAGE_TEXT"];
        ?>
</div>
						<?php 
        if (!empty($res["FILES"])) {
            $arFilesHTML = array("thumb" => array(), "files" => array());
            foreach ($res["FILES"] as $arFile) {
                if (!in_array($arFile["FILE_ID"], $res["FILES_PARSED"])) {
                    $arFileTemplate = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:forum.interface", "show_file", array("FILE" => $arFile, "SHOW_MODE" => $arParams["ATTACH_MODE"], "WIDTH" => $arParams["ATTACH_SIZE"], "HEIGHT" => $arParams["ATTACH_SIZE"], "CONVERT" => "N", "FAMILY" => "FORUM", "SINGLE" => "Y", "RETURN" => "ARRAY", "SHOW_LINK" => "Y"), null, array("HIDE_ICONS" => "Y"));
                    if (!empty($arFileTemplate["DATA"])) {
                        $arFilesHTML["thumb"][] = $arFileTemplate["RETURN_DATA"];
                    } else {
                        $arFilesHTML["files"][] = $arFileTemplate["RETURN_DATA"];
                    }
                }
            }
            if (!empty($arFilesHTML["thumb"]) || !empty($arFilesHTML["files"])) {
                ?>
								<div class="forum-post-attachments">
									<label><?php 
                echo GetMessage("F_ATTACH_FILES");
                ?>
</label>
									<?php 
                if (!empty($arFilesHTML["thumb"])) {
                    ?>
<div class="forum-post-attachment forum-post-attachment-thumb"><fieldset><?php 
                    echo implode("", $arFilesHTML["thumb"]);
                    ?>
</fieldset></div><?php 
                }
                if (!empty($arFilesHTML["files"])) {
                    ?>
<div class="forum-post-attachment forum-post-attachment-files"><ul><li><?php 
                    echo implode("</li><li>", $arFilesHTML["files"]);
                    ?>
</li></ul></div><?php 
                }
                ?>
								</div>
								<?php 
            }
        }
        if (is_array($res["PROPS"])) {
            foreach ($res["PROPS"] as $arPostField) {
                if (!empty($arPostField["VALUE"])) {
                    if (!empty($arPostField["EDIT_FORM_LABEL"])) {
                        $arPostField["EDIT_FORM_LABEL"] = "<span>" . $arPostField["EDIT_FORM_LABEL"] . ": </span>";
                    }
                    ?>
<div class="forum-post-userfield"><?php 
                    echo $arPostField["EDIT_FORM_LABEL"];
                    $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:system.field.view", $arPostField["USER_TYPE"]["USER_TYPE_ID"], array("arUserField" => $arPostField), null, array("HIDE_ICONS" => "Y"));
                    ?>
</div><?php 
                }
            }
        }
        if (!empty($res["EDITOR_NAME"])) {
            ?>
<div class="forum-post-lastedit">
								<span class="forum-post-lastedit"><?php 
            echo GetMessage("F_EDIT_HEAD");
            ?>
									<span class="forum-post-lastedit-user"><?php 
            if (!empty($res["URL"]["EDITOR"])) {
                ?>
<a href="<?php 
                echo $res["URL"]["EDITOR"];
                ?>
"><?php 
                echo $res["EDITOR_NAME"];
                ?>
</a><?php 
            } else {
                echo $res["EDITOR_NAME"];
            }
            ?>
</span> - <span class="forum-post-lastedit-date"><?php 
            echo $res["EDIT_DATE"];
            ?>
</span>
									<?php 
            if (!empty($res["EDIT_REASON"])) {
                ?>
										<span class="forum-post-lastedit-reason">(<span><?php 
                echo $res["EDIT_REASON"];
                ?>
</span>)</span>
										<?php 
            }
            ?>
							</span></div><?php 
        }
        if (strLen($res["SIGNATURE"]) > 0) {
            ?>
							<div class="forum-user-signature">
								<div class="forum-signature-line"></div>
								<span><?php 
            echo $res["SIGNATURE"];
            ?>
</span>
							</div>
							<?php 
        }
        ?>
					</div>
					<?php 
        if ($arParams["PERMISSION_ORIGINAL"] >= "Q") {
            ?>
						<div class="forum-post-entry forum-user-additional forum-user-moderate-info">
							<?php 
            if ($res["SOURCE_ID"] == "EMAIL") {
                ?>
								<span><?php 
                echo GetMessage("F_SOURCE_ID");
                ?>
: <?php 
                if (!empty($res["MAIL_HEADER"])) {
                    if ($res["PANELS"]["MAIL"] == "Y" && !empty($res["XML_ID"])) {
                        $res["MAIL_HEADER"] .= "<br /><a href=\"/bitrix/admin/mail_message_view.php?MSG_ID=" . $res["XML_ID"] . "\">" . GetMessage("F_ORIGINAL_MESSAGE") . "</a>";
                    }
                    ?>
<a href="#" onclick="this.nextSibling.style.display=(this.nextSibling.style.display=='none'?'':'none'); return false;" title="<?php 
                    echo GetMessage("F_EMAIL_ADD_INFO");
                    ?>
">e-mail</a><?php 
                    ?>
<div>
										<div class="forum-note-box forum-note-success">
											<div class="forum-note-box-text">
												<?php 
                    echo preg_replace("/\r\n/", "<br />", $res["MAIL_HEADER"]);
                    ?>
											</div>
										</div>
									</div><?php 
                } else {
                    ?>
<span>e-mail</span> <?php 
                }
                ?>
</span>
								<?php 
            }
            if ($res["IP_IS_DIFFER"] == "Y") {
                ?>
								<span>IP<?php 
                echo GetMessage("F_REAL_IP");
                ?>
: <span><?php 
                echo $res["AUTHOR_IP"];
                ?>
 / <?php 
                echo $res["AUTHOR_REAL_IP"];
                ?>
</span></span>
								<?php 
            } else {
                ?>
								<span>IP: <span><?php 
                echo $res["AUTHOR_IP"];
                ?>
</span></span>
								<?php 
            }
            if ($res["PANELS"]["STATISTIC"] == "Y") {
                ?>
								<span><?php 
                echo GetMessage("F_USER_ID");
                ?>
: <span><a href="/bitrix/admin/guest_list.php?lang=<?php 
                echo LANG_ADMIN_LID;
                ?>
&amp;find_id=<?php 
                echo $res["GUEST_ID"];
                ?>
&amp;set_filter=Y"><?php 
                echo $res["GUEST_ID"];
                ?>
</a></span></span>
								<?php 
            }
            if ($res["PANELS"]["MAIN"] == "Y") {
                ?>
								<span><?php 
                echo GetMessage("F_USER_ID_USER");
                ?>
: <span><?php 
                ?>
<a href="/bitrix/admin/user_edit.php?lang=<?php 
                echo LANG_ADMIN_LID;
                ?>
&amp;ID=<?php 
                echo $res["AUTHOR_ID"];
                ?>
"><?php 
                echo $res["AUTHOR_ID"];
                ?>
</a></span></span>
								<?php 
            }
            ?>
						</div>
						<?php 
        } elseif ($res["SOURCE_ID"] == "EMAIL") {
            ?>
						<div class="forum-post-entry forum-user-additional forum-user-moderate-info">
							<span><?php 
            echo GetMessage("F_SOURCE_ID");
            ?>
: <span>e-mail</span></span>
						</div>
						<?php 
        }
        ?>
				</td>
				</tr>
				<tr>
					<td class="forum-cell-contact">
						<div class="forum-contact-links">
							<?php 
        if ($arParams["SHOW_MAIL"] == "Y" && strlen($res["EMAIL"]) > 0) {
            ?>
								<span class="forum-contact-email"><a href="<?php 
            echo $res["URL"]["AUTHOR_EMAIL"];
            ?>
" title="<?php 
            echo GetMessage("F_EMAIL_TITLE");
            ?>
">E-mail</a></span>
								<?php 
        } else {
            ?>
								&nbsp;
								<?php 
        }
        ?>
						</div>
					</td>
					<td class="forum-cell-actions">
						<div class="forum-action-links">
							<?php 
        if ($res["NUMBER"] == 1) {
            if ($res["PANELS"]["MODERATE"] == "Y") {
                if ($arResult["TOPIC"]["APPROVED"] != "Y") {
                    ?>
										<span class="forum-action-show"><a onclick="return fasessid(this);" href="<?php 
                    echo $GLOBALS["APPLICATION"]->GetCurPageParam("ACTION=SHOW_TOPIC", array("ACTION", "sessid"));
                    ?>
"><?php 
                    echo GetMessage("F_SHOW_TOPIC");
                    ?>
</a></span>
										<?php 
                } elseif (false) {
                    ?>
										<span class="forum-action-hide"><a onclick="return fasessid(this);" href="<?php 
                    echo $GLOBALS["APPLICATION"]->GetCurPageParam("ACTION=HIDE_TOPIC", array("ACTION", "sessid"));
                    ?>
"><?php 
                    echo GetMessage("F_HIDE_TOPIC");
                    ?>
</a></span>
										<?php 
                }
            }
            if ($res["PANELS"]["DELETE"] == "Y") {
                ?>
									&nbsp;&nbsp;<span class="forum-action-delete"><a onclick="if(confirm(oText['cdt'])){return fasessid(this);}return false;" href="<?php 
                echo $GLOBALS["APPLICATION"]->GetCurPageParam("ACTION=DEL_TOPIC", array("ACTION", "sessid"));
                ?>
"><?php 
                echo GetMessage("F_DELETE_TOPIC");
                ?>
</a></span>
									<?php 
                if ($res["SOURCE_ID"] == "EMAIL") {
                    ?>
										&nbsp;&nbsp;<span class="forum-action-spam"><a onclick="if(confirm(oText['cdt'])){return fasessid(this);}return false;" href="<?php 
                    echo $GLOBALS["APPLICATION"]->GetCurPageParam("ACTION=SPAM_TOPIC", array("ACTION", "sessid"));
                    ?>
"><?php 
                    echo GetMessage("F_SPAM");
                    ?>
</a></span>
										<?php 
                }
            }
            if ($res["PANELS"]["EDIT"] == "Y" && $arResult["USER"]["PERMISSION"] >= "U") {
                ?>
									&nbsp;&nbsp;<span class="forum-action-edit"><a href="<?php 
                echo $res["URL"]["MESSAGE_EDIT"];
                ?>
"><?php 
                echo GetMessage("F_EDIT_TOPIC");
                ?>
</a></span>
									<?php 
            } elseif ($res["PANELS"]["EDIT"] == "Y") {
                ?>
									&nbsp;&nbsp;<span class="forum-action-edit"><a href="<?php 
                echo $res["URL"]["MESSAGE_EDIT"];
                ?>
"><?php 
                echo GetMessage("F_EDIT");
                ?>
</a></span>
									<?php 
            }
        } else {
            if ($res["PANELS"]["MODERATE"] == "Y") {
                if ($res["APPROVED"] == "Y") {
                    ?>
										<span class="forum-action-hide"><a <?php 
                    if ($arParams['AJAX_POST'] == 'Y') {
                        ?>
onclick="return forumActionComment(this, 'MODERATE');"<?php 
                    } else {
                        ?>
onclick="return fasessid(this);"<?php 
                    }
                    ?>
 href="<?php 
                    echo $res["URL"]["MESSAGE_SHOW"];
                    ?>
"><?php 
                    echo GetMessage("F_HIDE");
                    ?>
</a></span>&nbsp;&nbsp;
										<?php 
                } else {
                    ?>
										<span class="forum-action-show"><a <?php 
                    if ($arParams['AJAX_POST'] == 'Y') {
                        ?>
onclick="return forumActionComment(this, 'MODERATE');"<?php 
                    } else {
                        ?>
onclick="return fasessid(this);"<?php 
                    }
                    ?>
 href="<?php 
                    echo $res["URL"]["MESSAGE_SHOW"];
                    ?>
"><?php 
                    echo GetMessage("F_SHOW");
                    ?>
</a></span>&nbsp;&nbsp;
										<?php 
                }
            }
            if ($res["PANELS"]["DELETE"] == "Y") {
                ?>
									<span class="forum-action-delete"><noindex><a rel="nofollow" <?php 
                if ($arParams['AJAX_POST'] == 'Y') {
                    ?>
onclick="return forumActionComment(this, 'DEL');"<?php 
                } else {
                    ?>
onclick="if(confirm(oText['cdm'])){return fasessid(this);}return false;"<?php 
                }
                ?>
 href="<?php 
                echo $res["URL"]["MESSAGE_DELETE"];
                ?>
" <?php 
                ?>
><?php 
                echo GetMessage("F_DELETE");
                ?>
</a></noindex></span>&nbsp;&nbsp;
									<?php 
                if ($res["SOURCE_ID"] == "EMAIL") {
                    ?>
										<span class="forum-action-spam"><a href="<?php 
                    echo $res["URL"]["MESSAGE_SPAM"];
                    ?>
" <?php 
                    ?>
onclick="if (confirm(oText['cdm'])){return fasessid(this);}return false;"><?php 
                    echo GetMessage("F_SPAM");
                    ?>
</a></span>&nbsp;&nbsp;
										<?php 
                }
            }
            if ($res["PANELS"]["EDIT"] == "Y") {
                ?>
									<span class="forum-action-edit"><a href="<?php 
                echo $res["URL"]["MESSAGE_EDIT"];
                ?>
"><?php 
                echo GetMessage("F_EDIT");
                ?>
</a></span>&nbsp;&nbsp;
									<?php 
            }
        }
        if ($arResult["USER"]["RIGHTS"]["ADD_MESSAGE"] == "Y") {
            if ($res["NUMBER"] == 1) {
                ?>
&nbsp;&nbsp;<?php 
            }
            if ($arResult["FORUM"]["ALLOW_QUOTE"] == "Y") {
                ?>
									<span class="forum-action-quote"><a title="<?php 
                echo GetMessage("F_QUOTE_HINT");
                ?>
" href="#postform" <?php 
                ?>
 onmousedown="if (window['quoteMessageEx']){quoteMessageEx(<?php 
                echo $res["ID"];
                ?>
);}"><?php 
                echo GetMessage("F_QUOTE");
                ?>
</a></span>
									<?php 
                if ($arParams["SHOW_NAME_LINK"] == "Y") {
                    ?>
										&nbsp;&nbsp;<span class="forum-action-reply"><a href="#postform" title="<?php 
                    echo GetMessage("F_INSERT_NAME");
                    ?>
" <?php 
                    ?>
 onmousedown="reply2author(<?php 
                    echo $res["ID"];
                    ?>
)"><?php 
                    echo GetMessage("F_NAME");
                    ?>
</a></span>
										<?php 
                }
            } elseif ($arParams["SHOW_NAME_LINK"] != "Y") {
                ?>
									<span class="forum-action-reply"><a href="#postform" <?php 
                ?>
 onmousedown="reply2author(<?php 
                echo $res["ID"];
                ?>
)"><?php 
                echo GetMessage("F_REPLY");
                ?>
</a></span>
									<?php 
            }
        } else {
            ?>
								&nbsp;
								<?php 
        }
        ?>
						</div>
					</td>
				</tr>
				</tbody>
		<?php 
        if ($iNumber < $iCount || $arParams["FIRST_MESSAGE_ID"] == $res["ID"]) {
            ?>
			</table><!--MSG_END_<?php 
            echo $res["ID"];
            ?>
-->
		<?php 
        }
    }
}
コード例 #17
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;
コード例 #18
0
ファイル: component.php プロジェクト: ASDAFF/open_bx
$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';
コード例 #19
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();
コード例 #20
0
ファイル: template.php プロジェクト: ASDAFF/bitrix-5
	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
ファイル: component.php プロジェクト: webgksupport/alpina
    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())) {
コード例 #22
0
ファイル: blog_comment.php プロジェクト: rasuldev/torino
    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));
        }
    }
コード例 #23
0
ファイル: include.php プロジェクト: webgksupport/alpina
 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"];
 }
コード例 #24
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
            $arImage = array();
            $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID']));
            while ($arImage = $res->Fetch()) {
                $arImages[$arImage['ID']] = $arImage['FILE_ID'];
            }
            if (preg_match("/(\\[CUT\\])/i", $arTmp['DETAIL_TEXT']) || preg_match("/(<CUT>)/i", $arTmp['DETAIL_TEXT'])) {
                $arTmp["CUT"] = "Y";
            }
            if ($arTmp["DETAIL_TEXT_TYPE"] == "html") {
                $arTmp["TEXT_FORMATED"] = $p->convert($arTmp["~DETAIL_TEXT"], true, $arImages, array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y"));
            } else {
                $arTmp["TEXT_FORMATED"] = $p->convert($arTmp["~DETAIL_TEXT"], true, $arImages);
            }
            $arTmp["IMAGES"] = $arImages;
            $arTmp["DATE_PUBLISH_FORMATED"] = date($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arTmp["DATE_PUBLISH"], CSite::GetDateFormat("FULL")));
            $dbCategory = CBlogPostCategory::GetList(array("NAME" => "ASC"), array("POST_ID" => $arTmp["ID"], "BLOG_ID" => $arPost["BLOG_ID"]));
            while ($arCategory = $dbCategory->GetNext()) {
                $arCategory["urlToCategory"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG_CATEGORY"], array("category_name" => urlencode($arCategory["NAME"])));
                $arTmp["CATEGORY"][] = $arCategory;
            }
            $arResult["POSTS"][] = $arTmp;
        }
        if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) {
            $arResult["RATING"] = CRatings::GetRatingVoteResult("BLOG_POST", $arResult["IDS"]);
        }
        if ($arParams["CACHE_TIME"] > 0) {
            $cache->EndDataCache(array("templateCachedData" => $this->GetTemplateCachedData(), "arResult" => $arResult));
        }
    }
}
$this->IncludeComponentTemplate();