本文整理汇总了PHP中CBlogPost::PreparePath方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlogPost::PreparePath方法的具体用法?PHP CBlogPost::PreparePath怎么用?PHP CBlogPost::PreparePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlogPost
的用法示例。
在下文中一共展示了CBlogPost::PreparePath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
CSearch::Index("blog", "P".$ID,
array(
"TITLE" => "",
"BODY" => ""
)
);
CSearch::DeleteIndex("blog", false, "COMMENT", $arBlog["ID"]."|".$ID);
}
elseif (
$arNewPost["DATE_PUBLISHED"] == "Y"
&& $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH
&& $newPostPerms >= BLOG_PERMS_READ
&& $arBlog["SEARCH_INDEX"] == "Y"
)
{
$tag = "";
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if(strlen($arFields["PATH"]) > 0)
{
$arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]);
}
elseif(strlen($arNewPost["PATH"]) > 0)
{
$arNewPost["PATH"] = (
strlen($arNewPost["CODE"]) > 0
? str_replace("#post_id#", $arNewPost["CODE"], $arNewPost["PATH"])
: str_replace("#post_id#", $ID, $arNewPost["PATH"])
);
$arPostSite = array($arGroup["SITE_ID"] => $arNewPost["PATH"]);
}
else
{
$arPostSite = array(
$arGroup["SITE_ID"] => CBlogPost::PreparePath(
$arBlog["URL"],
$arNewPost["ID"],
$arGroup["SITE_ID"],
false,
$arBlog["OWNER_ID"],
$arBlog["SOCNET_GROUP_ID"]
)
);
}
if (
$arBlog["USE_SOCNET"] == "Y"
&& CModule::IncludeModule("extranet")
)
{
$arPostSiteExt = CExtranet::GetSitesByLogDestinations($arFields["SC_PERM"]);
foreach($arPostSiteExt as $lid)
{
if (!array_key_exists($lid, $arPostSite))
{
$arPostSite[$lid] = str_replace(
array("#user_id#", "#post_id#"),
array($arBlog["OWNER_ID"], $arNewPost["ID"]),
COption::GetOptionString("socialnetwork", "userblogpost_page", false, $lid)
);
}
}
}
if(strlen($arNewPost["CATEGORY_ID"])>0)
{
$arC = explode(",", $arNewPost["CATEGORY_ID"]);
示例2: Update
public static function Update($ID, $arFields, $bSearchIndex = true)
{
global $DB;
$ID = IntVal($ID);
if(strlen($arFields["PATH"]) > 0)
$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);
$arFields1 = array();
foreach ($arFields as $key => $value)
{
if (substr($key, 0, 1) == "=")
{
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CBlogComment::CheckFields("UPDATE", $arFields, $ID))
return false;
elseif(!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_COMMENT", $ID, $arFields))
return false;
foreach(GetModuleEvents("blog", "OnBeforeCommentUpdate", true) as $arEvent)
{
if (ExecuteModuleEventEx($arEvent, Array($ID, &$arFields))===false)
return false;
}
$strUpdate = $DB->PrepareUpdate("b_blog_comment", $arFields);
foreach ($arFields1 as $key => $value)
{
if (strlen($strUpdate) > 0)
$strUpdate .= ", ";
$strUpdate .= $key."=".$value." ";
}
if (strlen($strUpdate) > 0)
{
if(is_set($arFields["PUBLISH_STATUS"]) && strlen($arFields["PUBLISH_STATUS"]) > 0)
{
$arComment = CBlogComment::GetByID($ID);
if($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH)
CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS - 1"));
elseif($arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH)
CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS + 1"));
}
$strSql =
"UPDATE b_blog_comment SET ".
" ".$strUpdate." ".
"WHERE ID = ".$ID." ";
$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);
unset($GLOBALS["BLOG_COMMENT"]["BLOG_COMMENT_CACHE_".$ID]);
$GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_COMMENT", $ID, $arFields);
$arComment = CBlogComment::GetByID($ID);
$arBlog = CBlog::GetByID($arComment["BLOG_ID"]);
if($arBlog["USE_SOCNET"] == "Y")
$arFields["SC_PERM"] = CBlogComment::GetSocNetCommentPerms($arComment["POST_ID"]);
foreach(GetModuleEvents("blog", "OnCommentUpdate", true) as $arEvent)
ExecuteModuleEventEx($arEvent, Array($ID, &$arFields));
if ($bSearchIndex && CModule::IncludeModule("search"))
{
$newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arComment["BLOG_ID"], $arComment["POST_ID"], BLOG_PERMS_POST);
if ($arBlog["SEARCH_INDEX"] != "Y" || $arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH)
{
CSearch::Index("blog", "C".$ID,
array(
"TITLE" => "",
"BODY" => ""
)
);
}
else
{
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if(strlen($arFields["PATH"]) > 0)
{
$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);
$arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]);
}
elseif(strlen($arComment["PATH"]) > 0)
{
$arComment["PATH"] = str_replace("#comment_id#", $ID, $arComment["PATH"]);
$arPostSite = array($arGroup["SITE_ID"] => $arComment["PATH"]);
}
else
{
$arPostSite = array(
$arGroup["SITE_ID"] => CBlogPost::PreparePath(
$arBlog["URL"],
$arComment["POST_ID"],
//.........这里部分代码省略.........
示例3: _IndexPostComments
public static function _IndexPostComments($arParams = Array())
{
if(IntVal($arParams["BLOG_ID"]) <= 0 || IntVal($arParams["POST_ID"]) <= 0 || !CModule::IncludeModule("search"))
return false;
if($arParams["USE_SOCNET"] == "Y")
$arSp = CBlogComment::GetSocNetCommentPerms($arParams["POST_ID"]);
$dbComment = CBlogComment::GetList(Array(), Array("BLOG_ID" => $arParams["BLOG_ID"], "POST_ID" => $arParams["POST_ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH), false, false, Array("ID", "POST_ID", "BLOG_ID", "PUBLISH_STATUS", "PATH", "DATE_CREATE", "POST_TEXT", "TITLE", "AUTHOR_ID"));
while($arComment = $dbComment->Fetch())
{
if(strlen($arComment["PATH"]) > 0)
$arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arComment["PATH"]);
elseif(strlen($arParams["PATH"]) > 0)
$arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arParams["PATH"]);
else
{
$arComment["PATH"] = CBlogPost::PreparePath(
$arParams["BLOG_URL"],
$arComment["POST_ID"],
$arParams["SITE_ID"],
false,
$arParams["OWNER_ID"],
$arParams["SOCNET_GROUP_ID"]
);
}
$arSearchIndex = array(
"SITE_ID" => array($arParams["SITE_ID"] => $arComment["PATH"]),
"LAST_MODIFIED" => $arComment["DATE_CREATE"],
"PARAM1" => "COMMENT",
"PARAM2" => $arComment["BLOG_ID"]."|".$arComment["POST_ID"],
"PERMISSIONS" => array(2),
"TITLE" => $arComment["TITLE"],
"BODY" => blogTextParser::killAllTags($arComment["POST_TEXT"]),
"INDEX_TITLE" => false,
"USER_ID" => (IntVal($arComment["AUTHOR_ID"]) > 0) ? $arComment["AUTHOR_ID"] : false,
"ENTITY_TYPE_ID" => "BLOG_COMMENT",
"ENTITY_ID" => $arComment["ID"],
);
if($arParams["USE_SOCNET"] == "Y")
{
$arSearchIndex["PERMISSIONS"] = $arSp;
if(!in_array("U".$arComment["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"]))
$arSearchIndex["PERMISSIONS"][] = "U".$arComment["AUTHOR_ID"];
if(is_array($arSp))
{
$sgId = array();
foreach($arSp as $perm)
{
if(strpos($perm, "SG") !== false)
{
$sgIdTmp = str_replace("SG", "", substr($perm, 0, strpos($perm, "_")));
if(!in_array($sgIdTmp, $sgId) && IntVal($sgIdTmp) > 0)
$sgId[] = $sgIdTmp;
}
}
if(!empty($sgId))
{
$arSearchIndex["PARAMS"] = array(
"socnet_group" => $sgId,
"entity" => "socnet_group",
);
}
}
}
if(strlen($arComment["TITLE"]) <= 0)
$arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100);
CSearch::Index("blog", "C".$arComment["ID"], $arSearchIndex, True);
}
}
示例4: _IndexPostComments
function _IndexPostComments($arParams = array())
{
if (IntVal($arParams["BLOG_ID"]) <= 0 || IntVal($arParams["POST_ID"]) <= 0 || !CModule::IncludeModule("search")) {
return false;
}
if ($arParams["USE_SOCNET"] == "Y") {
$arSp = CBlogComment::GetSocNetCommentPerms($arParams["POST_ID"]);
}
$dbComment = CBlogComment::GetList(array(), array("BLOG_ID" => $arParams["BLOG_ID"], "POST_ID" => $arParams["POST_ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH), false, false, array("ID", "POST_ID", "BLOG_ID", "PUBLISH_STATUS", "PATH", "DATE_CREATE", "POST_TEXT", "TITLE", "AUTHOR_ID"));
while ($arComment = $dbComment->Fetch()) {
if (strlen($arComment["PATH"]) > 0) {
$arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arComment["PATH"]);
} elseif (strlen($arParams["PATH"]) > 0) {
$arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arParams["PATH"]);
} else {
$arComment["PATH"] = CBlogPost::PreparePath($arParams["BLOG_URL"], $arComment["POST_ID"], $arParams["SITE_ID"], false, $arParams["OWNER_ID"], $arParams["SOCNET_GROUP_ID"]);
}
$arSearchIndex = array("SITE_ID" => array($arParams["SITE_ID"] => $arComment["PATH"]), "LAST_MODIFIED" => $arComment["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $arComment["BLOG_ID"] . "|" . $arComment["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $arComment["TITLE"], "BODY" => blogTextParser::killAllTags($arComment["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($arComment["AUTHOR_ID"]) > 0 ? $arComment["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"]);
if ($arParams["USE_SOCNET"] == "Y") {
$arSearchIndex["PERMISSIONS"] = $arSp;
}
if (strlen($arComment["TITLE"]) <= 0) {
$arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100);
}
CSearch::Index("blog", "C" . $arComment["ID"], $arSearchIndex, True);
}
}
示例5: SendPing
public static function SendPing($postID, $arPingUrls = array())
{
$postID = IntVal($postID);
if (count($arPingUrls) <= 0) {
return False;
}
$arPost = CBlogPost::GetByID($postID);
if ($arPost) {
$arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
$title = urlencode($arPost["TITLE"]);
$excerpt = urlencode(substr($arPost["DETAIL_TEXT"], 0, 255));
$blogName = urlencode($arBlog["NAME"]);
$serverName = "";
$charset = "";
$dbSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => $arGroup["SITE_ID"]));
if ($arSite = $dbSite->Fetch()) {
$serverName = $arSite["SERVER_NAME"];
$charset = $arSite["CHARSET"];
}
if (strlen($serverName) <= 0) {
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
$serverName = SITE_SERVER_NAME;
} else {
$serverName = COption::GetOptionString("main", "server_name", "");
}
}
if (strlen($charset) <= 0) {
if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0) {
$charset = SITE_CHARSET;
} else {
$charset = "windows-1251";
}
}
$url = urlencode("http://" . $serverName . CBlogPost::PreparePath($arBlog["URL"], $postID, $arGroup["SITE_ID"]));
foreach ($arPingUrls as $pingUrl) {
$pingUrl = str_replace("http://", "", $pingUrl);
$pingUrl = str_replace("https://", "", $pingUrl);
$arPingUrl = explode("/", $pingUrl);
$host = trim($arPingUrl[0]);
unset($arPingUrl[0]);
$path = "/" . trim(implode("/", $arPingUrl));
$arHost = explode(":", $host);
$port = count($arHost) > 1 ? $arHost[1] : 80;
$host = $arHost[0];
if (!empty($path) && !empty($host)) {
$query = "title=" . $title . "&url=" . $url . "&excerpt=" . $excerpt . "&blog_name=" . $blogName;
$fp = @fsockopen($host, $port, $errnum, $errstr, 30);
if ($fp) {
fputs($fp, "POST {$path} HTTP/1.1\r\n");
fputs($fp, "Host: {$host}\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded; charset=\"" . $charset . "\"\r\n");
fputs($fp, "User-Agent: bitrixBlog\r\n");
fputs($fp, "Content-length: " . strlen($query) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $query . "\r\n\r\n");
fclose($fp);
}
}
}
}
}
示例6: OnSearchReindex
function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "")
{
global $DB;
$arResult = array();
//CBlogSearch::Trace('OnSearchReindex', 'NS', $NS);
if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) {
$category = substr($NS["ID"], 0, 1);
$id = intval(substr($NS["ID"], 1));
} else {
$category = 'B';
//start with blogs
$id = 0;
//very first id
}
//CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id));
//Reindex blogs
if ($category == 'B') {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t";
//CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
$rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $rs->Fetch()) {
if ($ar["USE_SOCNET"] == "Y") {
$Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => "");
} else {
//CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
$arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
//CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
$Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2));
//CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
}
if ($oCallback) {
$res = call_user_func(array($oCallback, $callback_method), $Result);
if (!$res) {
return $Result["ID"];
}
} else {
$arResult[] = $Result;
}
}
//all blogs indexed so let's start index posts
$category = 'P';
$id = 0;
}
if ($category == 'P') {
$arUser2Blog = array();
if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
$dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID"));
while ($arB = $dbB->Fetch()) {
$arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"];
}
}
$bSonet = false;
if (IsModuleInstalled("socialnetwork")) {
$bSonet = true;
}
$parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/");
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t";
/* AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/
//AND b.SEARCH_INDEX = 'Y'
//CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
$rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $rs->Fetch()) {
//Check permissions
$tag = "";
if ($ar["USE_SOCNET"] != "Y") {
$PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST);
if ($PostPerms < BLOG_PERMS_READ) {
continue;
}
}
//CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
if (strlen($ar["PATH"]) > 0) {
$arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"]));
} else {
$arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
}
if (strlen($ar["CATEGORY_ID"]) > 0) {
$arC = explode(",", $ar["CATEGORY_ID"]);
$tag = "";
$arTag = array();
foreach ($arC as $v) {
$arCategory = CBlogCategory::GetByID($v);
$arTag[] = $arCategory["NAME"];
}
$tag = implode(",", $arTag);
}
//CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
$Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]);
if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) {
$arF = array();
if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) {
$newBlogId = 0;
if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
$newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
} else {
$arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
$bRights = false;
$rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
$arUser = $rsUser->Fetch();
//.........这里部分代码省略.........
示例7: GetRSS
//.........这里部分代码省略.........
//SELECT
$arSelFields = array("ID", "TITLE", "DETAIL_TEXT", "DATE_PUBLISH", "AUTHOR_ID", "BLOG_USER_ALIAS", "BLOG_ID", "DETAIL_TEXT_TYPE", "BLOG_URL", "BLOG_OWNER_ID", "BLOG_SOCNET_GROUP_ID", "BLOG_GROUP_SITE_ID", "CODE", self::UFCategroryCodeField);
//WHERE
$arFilter = array("<=DATE_PUBLISH" => ConvertTimeStamp(false, "FULL", false), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "BLOG_ENABLE_RSS" => "Y", "MICRO" => "N");
if (intval($arSettings["BLOG_CODE"]) === $arSettings["BLOG_CODE"]) {
$arFilter["BLOG_ID"] = $arSettings["BLOG_CODE"];
} else {
$arFilter["BLOG_URL"] = $arSettings["BLOG_CODE"];
}
//Extend standart filter
$arFilter = array_merge($arFilter, $arFilterExt);
CTimeZone::Disable();
$dbPosts = CBlogPost::GetList(array("DATE_PUBLISH" => "DESC"), $arFilter, false, array("nTopCount" => $numPosts), $arSelFields);
CTimeZone::Enable();
while ($arPost = $dbPosts->Fetch()) {
//Can read
if (CBlogPost::GetBlogUserPostPerms($arPost["ID"], $arSettings["CURRENT_USER_ID"]) < BLOG_PERMS_READ) {
continue;
}
$arAuthorUser = $USER->GetByID($arPost["AUTHOR_ID"])->Fetch();
$author = CBlogUser::GetUserName($arPost["BLOG_USER_ALIAS"], $arAuthorUser["NAME"], $arAuthorUser["LAST_NAME"], $arAuthorUser["LOGIN"], $arAuthorUser["SECOND_NAME"]);
$title = str_replace(array("&", "<", ">", "\""), array("&", "<", ">", """), $author . ": " . $arPost["TITLE"]);
//Idea Images
$arImages = array();
$res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "IS_COMMENT" => "N"));
while ($arImage = $res->Fetch()) {
$arImages[$arImage['ID']] = $arImage['FILE_ID'];
}
$arDate = ParseDateTime($arPost["DATE_PUBLISH"], CSite::GetDateFormat("FULL", $arPost["BLOG_GROUP_SITE_ID"]));
$date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
if (!empty($arPathTemplates)) {
$url = htmlspecialcharsbx("http://" . $arSettings["SERVER_NAME"] . CComponentEngine::MakePathFromTemplate($arPathTemplates["BLOG_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplates["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} else {
$url = htmlspecialcharsbx("http://" . $arSettings["SERVER_NAME"] . CBlogPost::PreparePath(htmlspecialcharsbx($arPost["BLOG_URL"]), $arPost["ID"], $arPost["BLOG_GROUP_SITE_ID"]));
}
$category = "";
if (isset($arPost[self::UFCategroryCodeField]) && is_array($arSettings["CATEGORIES"][ToUpper($arPost[self::UFCategroryCodeField])])) {
$category = htmlspecialcharsbx($arSettings["CATEGORIES"][ToUpper($arPost[self::UFCategroryCodeField])]["NAME"]);
}
if (strlen($arPathTemplates["USER"]) > 0) {
$authorURL = htmlspecialcharsbx("http://" . $arSettings["SERVER_NAME"] . CComponentEngine::MakePathFromTemplate($arPathTemplates["USER"], array("user_id" => $arPost["AUTHOR_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} else {
$authorURL = htmlspecialcharsbx("http://" . $arSettings["SERVER_NAME"] . CBlogUser::PreparePath($arPost["AUTHOR_ID"], $arPost["BLOG_GROUP_SITE_ID"]));
}
if ($arPost["DETAIL_TEXT_TYPE"] == "html") {
$IdeaText = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "QUOTE" => "Y", "CODE" => "Y"), true, $arParserParams);
} else {
$IdeaText = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, false, true, $arParserParams);
}
$IdeaText .= "<br /><a href=\"" . $url . "\">" . GetMessage("BLG_GB_RSS_DETAIL") . "</a>";
$IdeaText = "<![CDATA[" . $IdeaText . "]]>";
if ($arSettings["RSS_TYPE"] == "rss.92") {
$arSettings["RSS"] .= "\t<item>\n";
$arSettings["RSS"] .= "\t <title>" . $title . "</title>\n";
$arSettings["RSS"] .= "\t <description>" . $IdeaText . "</description>\n";
$arSettings["RSS"] .= "\t <link>" . $url . "</link>\n";
$arSettings["RSS"] .= "\t</item>\n";
$arSettings["RSS"] .= "\n";
} elseif ($arSettings["RSS_TYPE"] == "rss2.0") {
$arSettings["RSS"] .= "\t<item>\n";
$arSettings["RSS"] .= "\t <title>" . $title . "</title>\n";
$arSettings["RSS"] .= "\t <description>" . $IdeaText . "</description>\n";
$arSettings["RSS"] .= "\t <link>" . $url . "</link>\n";
$arSettings["RSS"] .= "\t <guid>" . $url . "</guid>\n";
$arSettings["RSS"] .= "\t <pubDate>" . $date . "</pubDate>\n";
if (strlen($category) > 0) {
示例8: BuildRSSAll
//.........这里部分代码省略.........
$arFilter["FOR_USER"] = $user_id;
unset($arFilter["MICRO"]);
}
CTimeZone::Disable();
$dbPosts = CBlogPost::GetList(array("DATE_PUBLISH" => "DESC"), $arFilter, false, array("nTopCount" => $numPosts), $arSelFields);
CTimeZone::Enable();
while ($arPost = $dbPosts->Fetch()) {
$perms = CBlogPost::GetBlogUserPostPerms($arPost["ID"], $GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : 0);
if ($perms < BLOG_PERMS_READ) {
continue;
}
$dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
$arUser = $dbUser->Fetch();
$author = CBlogUser::GetUserName($arPost["BLOG_USER_ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"], $arUser["SECOND_NAME"]);
$title = str_replace(array("&", "<", ">", "\""), array("&", "<", ">", """), $author . ": " . $arPost["TITLE"]);
$arImages = array();
$res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "IS_COMMENT" => "N"));
while ($arImage = $res->Fetch()) {
$arImages[$arImage['ID']] = $arImage['FILE_ID'];
}
$arDate = ParseDateTime($arPost["DATE_PUBLISH"], CSite::GetDateFormat("FULL", $arPost["BLOG_GROUP_SITE_ID"]));
$date = date("r", mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
if (strlen($arPost["PATH"]) > 0) {
$url = htmlspecialcharsbx("http://" . $serverName . str_replace("#post_id#", CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), $arPost["PATH"]));
} elseif (!empty($arPathTemplates)) {
if (IntVal($arPost["BLOG_SOCNET_GROUP_ID"]) > 0 && strlen($arPathTemplates["GROUP_BLOG_POST"]) > 0) {
$url = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($arPathTemplates["GROUP_BLOG_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplates["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} else {
$url = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($arPathTemplates["BLOG_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplates["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
}
} elseif (strLen($postTemplate) > 0) {
$url = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($postTemplate, array("blog" => $arPost["BLOG_URL"], "post_id" => $arPost["ID"], "user_id" => $arPost["BLOG_OWNER_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} else {
$url = htmlspecialcharsbx("http://" . $serverName . CBlogPost::PreparePath(htmlspecialcharsbx($arPost["BLOG_URL"]), $arPost["ID"], $arPost["BLOG_GROUP_SITE_ID"]));
}
$category = htmlspecialcharsbx($arPost["CATEGORY_NAME"]);
if (strlen($arPathTemplates["USER"]) > 0) {
$authorURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($arPathTemplates["USER"], array("user_id" => $arPost["AUTHOR_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} elseif (strLen($userTemplate) > 0) {
$authorURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($userTemplate, array("user_id" => $arPost["AUTHOR_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"])));
} else {
$authorURL = htmlspecialcharsbx("http://" . $serverName . CBlogUser::PreparePath($arPost["AUTHOR_ID"], $arPost["BLOG_GROUP_SITE_ID"]));
}
if ($arPost["DETAIL_TEXT_TYPE"] == "html") {
$text = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "QUOTE" => "Y", "CODE" => "Y"), true, $arParserParams);
} else {
$text = $parser->convert_to_rss($arPost["DETAIL_TEXT"], $arImages, false, true, $arParserParams);
}
if ($bUserSocNet != "Y") {
$text .= "<br /><a href=\"" . $url . "\">" . GetMessage("BLG_GB_RSS_DETAIL") . "</a>";
}
$text = "<![CDATA[" . $text . "]]>";
if ($type == "rss.92") {
$rssText .= " <item>\n";
$rssText .= " <title>" . $title . "</title>\n";
$rssText .= " <description>" . $text . "</description>\n";
$rssText .= " <link>" . $url . "</link>\n";
$rssText .= " </item>\n";
$rssText .= "\n";
} elseif ($type == "rss2.0") {
$rssText .= " <item>\n";
$rssText .= " <title>" . $title . "</title>\n";
$rssText .= " <description>" . $text . "</description>\n";
$rssText .= " <link>" . $url . "</link>\n";
$rssText .= " <guid>" . $url . "</guid>\n";
$rssText .= " <pubDate>" . $date . "</pubDate>\n";
示例9: Update
function Update($ID, $arFields)
{
global $DB;
$ID = IntVal($ID);
if (strlen($arFields["PATH"]) > 0) {
$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);
}
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CBlogComment::CheckFields("UPDATE", $arFields, $ID)) {
return false;
} elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_COMMENT", $ID, $arFields)) {
return false;
}
$db_events = GetModuleEvents("blog", "OnBeforeCommentUpdate");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
return false;
}
}
$strUpdate = $DB->PrepareUpdate("b_blog_comment", $arFields);
foreach ($arFields1 as $key => $value) {
if (strlen($strUpdate) > 0) {
$strUpdate .= ", ";
}
$strUpdate .= $key . "=" . $value . " ";
}
if (strlen($strUpdate) > 0) {
if (is_set($arFields["PUBLISH_STATUS"]) && strlen($arFields["PUBLISH_STATUS"]) > 0) {
$arComment = CBlogComment::GetByID($ID);
if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS - 1"));
} elseif ($arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS + 1"));
}
}
$strSql = "UPDATE b_blog_comment SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
unset($GLOBALS["BLOG_COMMENT"]["BLOG_COMMENT_CACHE_" . $ID]);
$GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_COMMENT", $ID, $arFields);
$arComment = CBlogComment::GetByID($ID);
$arBlog = CBlog::GetByID($arComment["BLOG_ID"]);
if ($arBlog["USE_SOCNET"] == "Y") {
$arFields["SC_PERM"] = CBlogComment::GetSocNetCommentPerms($arComment["POST_ID"]);
}
$db_events = GetModuleEvents("blog", "OnCommentUpdate");
while ($arEvent = $db_events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, &$arFields));
}
if (CModule::IncludeModule("search")) {
$newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arComment["BLOG_ID"], $arComment["POST_ID"], BLOG_PERMS_POST);
if ($arBlog["SEARCH_INDEX"] != "Y" || $arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
CSearch::Index("blog", "C" . $ID, array("TITLE" => "", "BODY" => ""));
} else {
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if (strlen($arFields["PATH"]) > 0) {
$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);
$arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]);
} elseif (strlen($arComment["PATH"]) > 0) {
$arComment["PATH"] = str_replace("#comment_id#", $ID, $arComment["PATH"]);
$arPostSite = array($arGroup["SITE_ID"] => $arComment["PATH"]);
} else {
$arPostSite = array($arGroup["SITE_ID"] => CBlogPost::PreparePath($arBlog["URL"], $arComment["POST_ID"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"]));
}
$searchContent = blogTextParser::killAllTags($arComment["POST_TEXT"]);
$searchContent .= "\r\n" . $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("BLOG_COMMENT", $arComment["ID"]);
$authorName = "";
if (IntVal($arComment["AUTHOR_ID"]) > 0) {
$dbUser = CUser::GetByID($arComment["AUTHOR_ID"]);
if ($arUser = $dbUser->Fetch()) {
$arTmpUser = array("NAME" => $arUser["NAME"], "LAST_NAME" => $arUser["LAST_NAME"], "SECOND_NAME" => $arUser["SECOND_NAME"], "LOGIN" => $arUser["LOGIN"]);
$authorName = CUser::FormatName(CSite::GetNameFormat(), $arTmpUser, false, false);
}
} elseif (strlen($arComment["AUTHOR_NAME"]) > 0) {
$authorName = $arComment["AUTHOR_NAME"];
}
if (strlen($authorName) > 0) {
$searchContent .= "\r\n" . $authorName;
}
$arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arComment["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $arComment["BLOG_ID"] . "|" . $arComment["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $arComment["TITLE"], "BODY" => $searchContent, "USER_ID" => IntVal($arComment["AUTHOR_ID"]) > 0 ? $arComment["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"]);
if ($arBlog["USE_SOCNET"] == "Y") {
if (is_array($arFields["SC_PERM"])) {
$arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"];
}
}
if (strlen($arComment["TITLE"]) <= 0) {
//$arPost = CBlogPost::GetByID($arComment["POST_ID"]);
$arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100);
}
CSearch::Index("blog", "C" . $ID, $arSearchIndex, True);
}
}
return $ID;
}
return False;
//.........这里部分代码省略.........