Esempio n. 1
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if ((is_set($arFields, "POST_ID") || $ACTION == "ADD") && strlen($arFields["POST_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GCT_EMPTY_POST_ID"), "EMPTY_POST_ID");
         return false;
     } elseif (is_set($arFields, "POST_ID")) {
         $arResult = CBlogPost::GetByID($arFields["POST_ID"]);
         if (!$arResult) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["POST_ID"], GetMessage("BLG_GCT_ERROR_NO_POST")), "ERROR_NO_POST");
             return false;
         }
     }
     if ((is_set($arFields, "BLOG_ID") || $ACTION == "ADD") && IntVal($arFields["BLOG_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GCT_EMPTY_BLOG_ID"), "EMPTY_BLOG_ID");
         return false;
     } elseif (is_set($arFields, "BLOG_ID")) {
         $arResult = CBlog::GetByID($arFields["BLOG_ID"]);
         if (!$arResult) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["BLOG_ID"], GetMessage("BLG_GCT_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
             return false;
         }
     }
     if ((is_set($arFields, "CATEGORY_ID") || $ACTION == "ADD") && IntVal($arFields["CATEGORY_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GCT_EMPTY_CATEGORY_ID"), "EMPTY_CATEGORY_ID");
         return false;
     } elseif (is_set($arFields, "CATEGORY_ID")) {
         $arResult = CBlogCategory::GetByID($arFields["CATEGORY_ID"]);
         if (!$arResult) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CATEGORY_ID"], GetMessage("BLG_GCT_ERROR_NO_CATEGORY")), "ERROR_NO_CATEGORY");
             return false;
         }
     }
     return True;
 }
Esempio n. 2
0
 public static function CanUserDeletePost($ID, $userID, $blogOwnerID, $groupOwnerID)
 {
     $ID = IntVal($ID);
     $userID = IntVal($userID);
     $blogOwnerID = IntVal($blogOwnerID);
     $groupOwnerID = IntVal($groupOwnerID);
     $blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog");
     if ($blogModulePermissions >= "W") {
         return True;
     }
     $arPost = CBlogPost::GetByID($ID);
     if (empty($arPost)) {
         return False;
     }
     if ($groupOwnerID > 0) {
         $arBlogUser = CBlogUser::GetByID($userID, BLOG_BY_USER_ID);
         if ($arBlogUser && $arBlogUser["ALLOW_POST"] != "Y") {
             return False;
         }
         $perms = BLOG_PERMS_DENY;
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "view_post")) {
             $perms = BLOG_PERMS_READ;
         }
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "write_post")) {
             $perms = BLOG_PERMS_WRITE;
         }
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "full_post")) {
             $perms = BLOG_PERMS_FULL;
         }
         if ($perms >= BLOG_PERMS_WRITE && $arPost["AUTHOR_ID"] == $userID) {
             return true;
         }
         if ($perms > BLOG_PERMS_WRITE) {
             return true;
         }
     } else {
         $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
         $arBlogUser = CBlogUser::GetByID($userID, BLOG_BY_USER_ID);
         if ($arBlogUser && $arBlogUser["ALLOW_POST"] != "Y") {
             return False;
         }
         $perms = BLOG_PERMS_DENY;
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "view_post")) {
             $perms = BLOG_PERMS_READ;
         }
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "write_post")) {
             $perms = BLOG_PERMS_WRITE;
         }
         if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "full_post")) {
             $perms = BLOG_PERMS_FULL;
         }
         if ($perms >= BLOG_PERMS_WRITE && $arPost["AUTHOR_ID"] == $userID) {
             return true;
         }
         if ($perms > BLOG_PERMS_WRITE) {
             return true;
         }
     }
     return False;
 }
Esempio n. 3
0
 public static function GetPing($blogUrl, $postID, $arParams = array())
 {
     global $DB;
     $blogUrl = Trim($blogUrl);
     $postID = IntVal($postID);
     $bSuccess = True;
     $arPost = CBlogPost::GetByID($postID);
     if (!$arPost) {
         CBlogTrackback::SendPingResponce(1, "Invalid target post");
         $bSuccess = False;
     }
     if ($bSuccess) {
         if ($arPost["ENABLE_TRACKBACK"] != "Y" || COption::GetOptionString("blog", "enable_trackback", "Y") != "Y") {
             CBlogTrackback::SendPingResponce(1, "Trackbacks disabled");
             $bSuccess = False;
         }
     }
     if ($bSuccess) {
         $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
         if (!$arBlog || $arBlog["URL"] != $blogUrl) {
             CBlogTrackback::SendPingResponce(1, "Invalid target blog");
             $bSuccess = False;
         }
     }
     if ($bSuccess) {
         if (!isset($arParams["title"]) || strlen($arParams["title"]) <= 0 || !isset($arParams["url"]) || strlen($arParams["url"]) <= 0) {
             CBlogTrackback::SendPingResponce(1, "Missing required fields");
             $bSuccess = False;
         }
     }
     if ($bSuccess) {
         if (!isset($arParams["excerpt"])) {
             $arParams["excerpt"] = $arParams["title"];
         }
         if (!isset($arParams["blog_name"])) {
             $arParams["blog_name"] = "";
         }
     }
     if ($bSuccess) {
         $serverCharset = "";
         $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
         $dbSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => $arGroup["SITE_ID"]));
         if ($arSite = $dbSite->Fetch()) {
             $serverCharset = $arSite["CHARSET"];
         }
         if (strlen($serverCharset) <= 0) {
             if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0) {
                 $serverCharset = SITE_CHARSET;
             } else {
                 $serverCharset = "windows-1251";
             }
         }
         preg_match("/charset=(\")*(.*?)(\")*(;|\$)/", $_SERVER["CONTENT_TYPE"], $charset);
         $charset = preg_replace("#[^[:space:]a-zA-Z0-9\\-]#is", "", $charset[2]);
         if (strlen($charset) <= 0) {
             $charset = "utf-8";
         }
         if ($charset != $serverCharset) {
             $arParams["title"] = $GLOBALS["APPLICATION"]->ConvertCharset($arParams["title"], $charset, $serverCharset);
             $arParams["url"] = $GLOBALS["APPLICATION"]->ConvertCharset($arParams["url"], $charset, $serverCharset);
             $arParams["excerpt"] = $GLOBALS["APPLICATION"]->ConvertCharset($arParams["excerpt"], $charset, $serverCharset);
             $arParams["blog_name"] = $GLOBALS["APPLICATION"]->ConvertCharset($arParams["blog_name"], $charset, $serverCharset);
         }
         $arFields = array("TITLE" => $arParams["title"], "URL" => $arParams["url"], "PREVIEW_TEXT" => $arParams["excerpt"], "BLOG_NAME" => $arParams["blog_name"], "=POST_DATE" => $DB->CurrentTimeFunction(), "BLOG_ID" => $arPost["BLOG_ID"], "POST_ID" => $arPost["ID"]);
         $dbTrackback = CBlogTrackback::GetList(array(), array("BLOG_ID" => $arPost["BLOG_ID"], "POST_ID" => $arPost["ID"], "URL" => $arParams["url"]));
         if ($arTrackback = $dbTrackback->Fetch()) {
             if (!CBlogTrackback::Update($arTrackback["ID"], $arFields)) {
                 if ($ex = $GLOBALS["APPLICATION"]->GetException()) {
                     $errorMessage = $ex->GetString() . ".<br>";
                 } else {
                     $errorMessage = "Unknown error" . ".<br>";
                 }
                 CBlogTrackback::SendPingResponce(1, $errorMessage);
             }
         } else {
             if (!CBlogTrackback::Add($arFields)) {
                 if ($ex = $GLOBALS["APPLICATION"]->GetException()) {
                     $errorMessage = $ex->GetString() . ".<br>";
                 } else {
                     $errorMessage = "Unknown error" . ".<br>";
                 }
                 CBlogTrackback::SendPingResponce(1, $errorMessage);
             }
         }
         CBlogTrackback::SendPingResponce(0, "Ping accepted");
     }
     return $bSuccess;
 }
Esempio n. 4
0
     }
 } else {
     $dbUser = CUser::GetByID($arBlogUser["USER_ID"]);
     $arUser = $dbUser->GetNext();
     if ($arParams["SET_TITLE"] == "Y") {
         $APPLICATION->SetTitle(str_replace("#NAME#", CBlogUser::GetUserName($arBlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"]), GetMessage("B_B_FR_TITLE_OF")));
     }
 }
 $dbList = CBlogUser::GetUserFriendsList($arParams["ID"], $USER->GetID(), $USER->IsAuthorized(), $arParams["MESSAGE_COUNT"], $arParams["GROUP_ID"]);
 $arResult["FRIENDS_POSTS"] = array();
 $arResult["IDS"] = array();
 $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
 $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]);
 while ($arList = $dbList->Fetch()) {
     $arResult["IDS"][] = $arList["ID"];
     $arPost = CBlogPost::GetByID($arList["ID"]);
     $arPost = CBlogTools::htmlspecialcharsExArray($arPost);
     $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
     $arBlog = CBlogTools::htmlspecialcharsExArray($arBlog);
     $arPost["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"])));
     $arPost["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arPost["AUTHOR_ID"]));
     if ($arPost["AUTHOR_ID"] == $arBlog["OWNER_ID"]) {
         $arPost["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arBlog["URL"]));
     } else {
         if ($arOwnerBlog = CBlog::GetByOwnerID($arPost["AUTHOR_ID"], $arParams["GROUP_ID"])) {
             $arPost["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arOwnerBlog["URL"]));
         }
     }
     $arImages = array();
     $dbImage = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N"));
     while ($arImage = $dbImage->Fetch()) {
Esempio n. 5
0
} else {
    define("LANGUAGE_ID", "en");
}
IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/mobile_app/components/bitrix/socialnetwork.blog.post/mobile/ajax.php");
$strError = false;
if ($post_id <= 0) {
    $strError = GetMessage("BLOG_MOBILE_AJAX_POST_ID_ERROR");
} elseif (!$GLOBALS["USER"]->IsAuthorized()) {
    $strError = GetMessage("BLOG_MOBILE_AJAX_USER_NOT_AUTHORIZED_ERROR");
} elseif (!check_bitrix_sessid()) {
    $strError = GetMessage("BLOG_MOBILE_AJAX_SESSION_ERROR");
} elseif (!CModule::IncludeModule("blog")) {
    $strError = GetMessage("BLOG_MOBILE_AJAX_BLOG_MODULE_ERROR");
} elseif (!CModule::IncludeModule("socialnetwork")) {
    $strError = GetMessage("BLOG_MOBILE_AJAX_SONET_MODULE_ERROR");
} elseif (!($arBlogPost = CBlogPost::GetByID($post_id))) {
    $strError = GetMessage("BLOG_MOBILE_BLOG_POST_ERROR");
} elseif (!($arBlog = CBlog::GetByID($arBlogPost["BLOG_ID"]))) {
    $strError = GetMessage("BLOG_MOBILE_BLOG_ERROR");
}
if (!$strError) {
    if ($action == "delete_post") {
        $PostPerm = CBlogPost::GetSocNetPostPerms($post_id, true, $GLOBALS["USER"]->GetID(), $arBlogPost["AUTHOR_ID"]);
        if ($PostPerm < BLOG_PERMS_FULL) {
            $strError = GetMessage("BLOG_MOBILE_DELETE_PERMISSION_ERROR");
        } else {
            CBlogPost::DeleteLog($post_id);
            if (CBlogPost::Delete($post_id)) {
                BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/");
                BXClearCache(true, "/blog/socnet_post/" . $post_id . "/");
                BXClearCache(true, "/blog/socnet_post/gen/" . $post_id . "/");
Esempio n. 6
0
	public static function BuildRSS($postID, $blogID, $type = "RSS2.0", $numPosts = 10, $arPathTemplate = Array())
	{
		$blogID = IntVal($blogID);
		$postID = IntVal($postID);
		if($blogID <= 0)
			return false;
		if($postID <= 0)
			return false;
		$numPosts = IntVal($numPosts);
		$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
		if ($type != "rss.92" && $type != "atom.03")
			$type = "rss2.0";

		$rssText = False;

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

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

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

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

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

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

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

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

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

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

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

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

						$rssText .= "\n";
					}

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

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

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

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

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

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

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

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

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


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

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

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

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

		return $rssText;
	}
Esempio n. 7
0
    $arParams["SEO_USE"] = "N";
}
$user_id = $USER->GetID();
$arResult["USER_ID"] = $user_id;
$arBlog = CBlog::GetByUrl($arParams["BLOG_URL"], $arParams["GROUP_ID"]);
$arBlog = CBlogTools::htmlspecialcharsExArray($arBlog);
$arResult["Blog"] = $arBlog;
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if (!empty($arBlog) && $arBlog["ACTIVE"] == "Y" && $arGroup["SITE_ID"] == SITE_ID) {
    if ($bIDbyCode) {
        $arParams["ID"] = CBlogPost::GetID($arParams["ID"], $arBlog["ID"]);
    }
    $arPost = CBlogPost::GetByID($arParams["ID"]);
    if (empty($arPost) && !$bIDbyCode) {
        $arParams["ID"] = CBlogPost::GetID($arParams["ID"], $arBlog["ID"]);
        $arPost = CBlogPost::GetByID($arParams["ID"]);
    }
    if (!empty($arPost) && $arPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
        unset($arPost);
    }
    if (!empty($arPost) && $arBlog["ID"] == $arPost["BLOG_ID"]) {
        CBlogPost::CounterInc($arParams["ID"]);
        $arPost = CBlogTools::htmlspecialcharsExArray($arPost);
        $arResult["Post"] = $arPost;
        $arResult["PostPerm"] = CBlogPost::GetBlogUserPostPerms($arParams["ID"], $arResult["USER_ID"]);
        if ($arPost["AUTHOR_ID"] == $arBlog["OWNER_ID"]) {
            $arResult["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arPost["AUTHOR_ID"]));
        } else {
            $arOwnerBlog = CBlog::GetByOwnerID($arPost["AUTHOR_ID"], $arParams["GROUP_ID"]);
            $arResult["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arOwnerBlog["URL"], "user_id" => $arPost["AUTHOR_ID"]));
        }
Esempio n. 8
0
	function AddLiveComment($commentId = 0, $path = "")
	{
		if(IntVal($commentId) <= 0)
			return;
		if(CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus())
		{
			if($arComment = CBlogComment::GetByID($commentId))
			{
				if(strlen($path) <= 0 && strlen($arComment["PATH"]) > 0)
					$path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id"   =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"]));
				if(strlen($path) <= 0)
				{
					$arPost = CBlogPost::GetByID($arComment["POST_ID"]);
					$path = $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id"   =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"]))."?commentId=".$arComment["ID"];
				}

				CPullWatch::AddToStack("UNICOMMENTSBLOG_".$arComment["POST_ID"],
					array(
						'module_id'	=> "unicomments",
						'command'	=> "comment",
						'params'	=> Array(
							"AUTHOR_ID"		=> $arComment["AUTHOR_ID"],
							"ID"			=> $arComment["ID"],
							"POST_ID"		=> $arComment["POST_ID"],
							"TS"			=> time(),
							"ACTION"		=> "REPLY",
							"URL"			=> array(
								"LINK" => $path,
							),
							"ENTITY_XML_ID"	=> "BLOG_".$arComment["POST_ID"],
							"APPROVED"		=> "Y",
							"NEED_REQUEST"	=> "Y",
						),
					)
				);
			}
		}
	}
Esempio n. 9
0
 public static function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $arPost = CBlogPost::GetByID($ID);
     if ($arPost) {
         foreach (GetModuleEvents("blog", "OnBeforePostDelete", true) as $arEvent) {
             if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
                 return false;
             }
         }
         $dbResult = CBlogComment::GetList(array(), array("POST_ID" => $ID), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogComment::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogUserGroupPerms::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogUserGroupPerms::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogTrackback::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogTrackback::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogPostCategory::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogPostCategory::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $strSql = "SELECT F.ID " . "FROM b_blog_post P, b_file F " . "WHERE P.ID = " . $ID . " " . "\tAND P.ATTACH_IMG = F.ID ";
         $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . " LINE:" . __LINE__);
         while ($zr = $z->Fetch()) {
             CFile::Delete($zr["ID"]);
         }
         CBlogPost::DeleteSocNetPostPerms($ID);
         unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_" . $ID]);
         $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
         $result = $DB->Query("DELETE FROM b_blog_post WHERE ID = " . $ID . "", true);
         if (IntVal($arBlog["LAST_POST_ID"]) == $ID) {
             CBlog::SetStat($arPost["BLOG_ID"]);
         }
         if ($result) {
             $res = CBlogImage::GetList(array(), array("POST_ID" => $ID, "IS_COMMENT" => "N"));
             while ($aImg = $res->Fetch()) {
                 CBlogImage::Delete($aImg['ID']);
             }
         }
         if ($result) {
             $GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_POST", $ID);
         }
         foreach (GetModuleEvents("blog", "OnPostDelete", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($ID, &$result));
         }
         if (CModule::IncludeModule("search")) {
             CSearch::Index("blog", "P" . $ID, array("TITLE" => "", "BODY" => ""));
             //CSearch::DeleteIndex("blog", false, "COMMENT", $arPost["BLOG_ID"]."|".$ID);
         }
         return $result;
     } else {
         return false;
     }
     return True;
 }
Esempio n. 10
0
             }
         }
     } else {
         $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_NO_BLOG");
         CHTTP::SetStatus("404 Not Found");
     }
 } elseif (IntVal($_GET["show_id"]) > 0 && $arResult["IDEA_MODERATOR"]) {
     if ($arResult["BLOG"] = CBlog::GetByUrl($arParams["BLOG_URL"], $arParams["GROUP_ID"])) {
         if ($_GET["success"] == "Y") {
             $arResultNFCache["OK_MESSAGE"][] = GetMessage("IDEA_BLOG_BLOG_MES_SHOWED");
         } else {
             if (check_bitrix_sessid()) {
                 $arResult["PostPerm"] = CBlog::GetBlogUserPostPerms($arResult["BLOG"]["ID"], $user_id);
                 $hide_id = IntVal($_GET["show_id"]);
                 if ($arResult["PostPerm"] >= BLOG_PERMS_MODERATE) {
                     if (CBlogPost::GetByID($hide_id)) {
                         if (CBlogPost::Update($hide_id, array("PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH))) {
                             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arParams["BLOG_URL"] . "/first_page/");
                             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arParams["BLOG_URL"] . "/pages/");
                             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arParams["BLOG_URL"] . "/post/" . $hide_id . "/");
                             BXClearCache(True, '/' . SITE_ID . '/idea/statistic_list/');
                             LocalRedirect($APPLICATION->GetCurPageParam("show_id=" . $hide_id . "&success=Y", array("del_id", "sessid", "success", "hide_id", "show_id")));
                         } else {
                             $arResultNFCache["ERROR_MESSAGE"][] = GetMessage("IDEA_BLOG_BLOG_MES_SHOW_ERROR");
                         }
                     }
                 } else {
                     $arResultNFCache["ERROR_MESSAGE"][] = GetMessage("IDEA_BLOG_BLOG_MES_SHOW_NO_RIGHTS");
                 }
             }
         }
Esempio n. 11
0
                     $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_DEL_NO_RIGHTS");
                 }
             } else {
                 $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_DEL_NO_RIGHTS");
             }
         } else {
             $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_SESSID_WRONG");
         }
     }
 } elseif (IntVal($_GET["pub_id"]) > 0) {
     if ($_GET["success"] == "Y") {
         $arResult["OK_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_PUB");
     } else {
         if (check_bitrix_sessid()) {
             $pub_id = IntVal($_GET["pub_id"]);
             if ($arPost = CBlogPost::GetByID($pub_id)) {
                 if ($arPost["AUTHOR_ID"] == $user_id && $arPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
                     if (CBlogPost::Update($pub_id, array("PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "=DATE_PUBLISH" => $DB->GetNowFunction()))) {
                         $arParamsNotify = array("bSoNet" => true, "allowVideo" => $arResult["allowVideo"], "PATH_TO_SMILE" => $arParams["PATH_TO_SMILE"], "PATH_TO_POST" => $arParams["PATH_TO_POST"], "SOCNET_GROUP_ID" => $arParams["SOCNET_GROUP_ID"], "user_id" => $arParams["USER_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"]);
                         CBlogPost::Notify($arPost, false, $arParamsNotify);
                         $socnetRights = CBlogPost::GetSocNetPermsCode($arPost["ID"]);
                         $arFieldsIM = array("TYPE" => "POST", "TITLE" => $arPost["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arPost["ID"], "user_id" => $arParams["USER_ID"])), "ID" => $arPost["ID"], "FROM_USER_ID" => $arParams["USER_ID"], "TO_USER_ID" => array(), "TO_SOCNET_RIGHTS" => $socnetRights, "TO_SOCNET_RIGHTS_OLD" => array());
                         CBlogPost::NotifyIm($arFieldsIM);
                         LocalRedirect($APPLICATION->GetCurPageParam("pub_id=" . $pub_id . "&success=Y", array("del_id", "pub_id", "sessid", "success")));
                     } else {
                         $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_PUB_ERROR");
                     }
                 }
             } else {
                 $arResult["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_PUB_NO_RIGHTS");
             }
Esempio n. 12
0
 function AddComment_Review_CheckIBlock_Blog($arElement)
 {
     if (!CModule::IncludeModule("iblock")) {
         return false;
     }
     if (!CModule::IncludeModule("blog")) {
         return false;
     }
     $needProperty = array();
     $ELEMENT_IBLOCK_ID = intVal($arElement["IBLOCK_ID"]);
     $ELEMENT_NAME = Trim($arElement["~NAME"]);
     $ELEMENT_BLOG_POST_ID = intVal($arElement["PROPERTY_BLOG_POST_ID_VALUE"]);
     $ELEMENT_BLOG_COMMENT_CNT = intVal($arElement["PROPERTY_BLOG_COMMENT_CNT_VALUE"]);
     if ($ELEMENT_BLOG_POST_ID <= 0) {
         $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "BLOG_POST_ID"));
         if (!($db_res && ($res = $db_res->Fetch()))) {
             $needProperty[] = "BLOG_POST_ID";
         }
     }
     if ($ELEMENT_BLOG_COMMENT_CNT <= 0) {
         $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "BLOG_COMMENT_CNT"));
         if (!($db_res && ($res = $db_res->Fetch()))) {
             $needProperty[] = "BLOG_COMMENT_CNT";
         }
     }
     if (!empty($needProperty)) {
         $obProperty = new CIBlockProperty();
         $res = true;
         foreach ($needProperty as $nameProperty) {
             $sName = trim($nameProperty == "BLOG_POST_ID" ? GetMessage("P_BLOG_POST_ID") : GetMessage("P_BLOG_COMMENTS_CNT"));
             $sName = empty($sName) ? $nameProperty : $sName;
             $res = $obProperty->Add(array("IBLOCK_ID" => $ELEMENT_IBLOCK_ID, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => $sName, "CODE" => $nameProperty));
         }
     }
     // Set NULL for post_id if it was deleted
     if ($ELEMENT_BLOG_POST_ID > 0) {
         $arTopic = CBlogPost::GetByID($ELEMENT_BLOG_POST_ID);
         if (!$arTopic || !is_array($arTopic) || count($arTopic) <= 0) {
             CIBlockElement::SetPropertyValues($arElement["ID"], $ELEMENT_IBLOCK_ID, 0, "BLOG_POST_ID");
             $ELEMENT_BLOG_POST_ID = 0;
         }
     }
     return $ELEMENT_BLOG_POST_ID;
 }
Esempio n. 13
0
 function OnGetRatingContentOwner($arParams)
 {
     if ($arParams['ENTITY_TYPE_ID'] == 'BLOG_POST') {
         $arPost = CBlogPost::GetByID(IntVal($arParams['ENTITY_ID']));
         return $arPost['AUTHOR_ID'];
     } elseif ($arParams['ENTITY_TYPE_ID'] == 'BLOG_COMMENT') {
         $arComment = CBlogComment::GetByID(IntVal($arParams['ENTITY_ID']));
         return $arComment['AUTHOR_ID'];
     }
     return false;
 }
Esempio n. 14
0
         $v = CBlogCategory::Add(array("BLOG_ID" => $arCopyBlog["ID"], "NAME" => $arCat["NAME"]));
     } else {
         $v = $arCatBlogCopy[ToLower($arCat["NAME"])];
     }
     CBlogPostCategory::Add(array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID, "CATEGORY_ID" => $v));
     $arCopyCat[] = $v;
 }
 if (!empty($arCopyCat)) {
     $arCopyPostUpdate["CATEGORY_ID"] = implode(",", $arCopyCat);
 }
 if ($_POST["move2blogcopy"] == "Y") {
     $arCopyPostUpdate["NUM_COMMENTS"] = 0;
 }
 if (!empty($arCopyPostUpdate)) {
     $copyID = CBlogPost::Update($copyID, $arCopyPostUpdate);
     $arCopyPost = CBlogPost::GetByID($copyID);
 }
 if ($_POST["move2blogcopy"] != "Y") {
     if (CBlogPost::CanUserDeletePost($arParams["ID"], $user_id)) {
         $dbC = CBlogComment::GetList(array("ID" => "ASC"), array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $arParams["ID"]), false, false, array("PATH", "PUBLISH_STATUS", "POST_TEXT", "TITLE", "DATE_CREATE", "AUTHOR_IP1", "AUTHOR_IP", "AUTHOR_EMAIL", "AUTHOR_NAME", "AUTHOR_ID", "PARENT_ID", "POST_ID", "BLOG_ID", "ID"));
         while ($arC = $dbC->Fetch()) {
             $arCTmp = array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID);
             CBlogComment::Update($arC["ID"], $arCTmp);
         }
         $arFilter = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y");
         $res = CBlogImage::GetList(array("ID" => "ASC"), $arFilter);
         while ($arImg = $res->GetNext()) {
             $arNewImg = array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID);
             CBlogImage::Update($arImg["ID"], $arNewImg);
         }
         if (!CBlogPost::Delete($arParams["ID"])) {
Esempio n. 15
0
         if (CBlogPost::Delete($DEL_ID)) {
             $okMessage = GetMessage("B_B_HIDE_M_DEL");
         } else {
             $errorMessage = GetMessage("B_B_HIDE_M_DEL_ERR");
         }
     } else {
         $errorMessage = GetMessage("B_B_HIDE_M_DEL_RIGHTS");
     }
 } elseif (IntVal($_GET["show_id"]) > 0) {
     if ($_GET["success"] == "Y") {
         $okMessage = GetMessage("BLOG_BLOG_BLOG_MES_SHOWED");
     } else {
         if (check_bitrix_sessid()) {
             $show_id = IntVal($_GET["show_id"]);
             if ($arResult["PostPerm"] >= BLOG_PERMS_MODERATE) {
                 if (CBlogPost::GetByID($show_id)) {
                     if (CBlogPost::Update($show_id, array("PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH))) {
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/first_page/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/pages/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/calendar/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $show_id . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/commented_posts/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/last_comments/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/trackback/" . $show_id . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_out/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_all/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/rss_sonet/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/rss_all/");
Esempio n. 16
0
<?php

if (CModule::IncludeModule("blog")) {
    $arComments = array();
    $dbLogComment = CSocNetLogComments::GetList(array("LOG_DATE" => "ASC"), array("EVENT_ID" => "blog_comment_micro", "SOURCE_ID" => false), false, false, array("ID", "LOG_SOURCE_ID", "USER_ID", "TEXT_MESSAGE", "LOG_DATE"));
    while ($arLogComment = $dbLogComment->Fetch()) {
        $arPost = CBlogPost::GetByID($arLogComment["LOG_SOURCE_ID"]);
        if ($arPost) {
            $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
            $arFieldsComment = array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "POST_TEXT" => $arLogComment["TEXT_MESSAGE"], "DATE_CREATE" => $arLogComment["LOG_DATE"], "AUTHOR_ID" => $arLogComment["USER_ID"], "PARENT_ID" => false);
            $commentId = CBlogComment::Add($arFieldsComment);
            $arComments[$arLogComment["ID"]] = $commentId;
        }
    }
    foreach ($arComments as $log_comment_id => $blog_comment_id) {
        CSocNetLogComments::Update($log_comment_id, array("SOURCE_ID" => $blog_comment_id));
    }
}
Esempio n. 17
0
}
/********************************************************************
				/Default params
********************************************************************/
/********************************************************************
				Actions
********************************************************************/
$postId = $_GET["del_id"] > 0 ? $_GET["del_id"] : ($_GET["hide_id"] > 0 ? $_GET["hide_id"] : $_GET["show_id"]);
if ($arResult["IDEA_MODERATOR"] && $postId > 0) {
    if ($_GET["success"] == "Y") {
        $arResultNFCache["OK_MESSAGE"][] = $_GET["del_id"] > 0 ? GetMessage("BLOG_BLOG_BLOG_MES_DELED") : ($_GET["hide_id"] > 0 ? GetMessage("BLOG_BLOG_BLOG_MES_HIDED") : GetMessage("IDEA_BLOG_BLOG_MES_SHOWED"));
    } else {
        if (!check_bitrix_sessid()) {
            $arResultNFCache["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_SESSID_WRONG");
        } else {
            if (CBlogPost::GetByID($postId)) {
                if ($_GET["del_id"] > 0) {
                    if (!CBlogPost::CanUserDeletePost(IntVal($_GET["del_id"]), $user_id)) {
                        $arResultNFCache["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_DEL_NO_RIGHTS");
                    } else {
                        if (!CBlogPost::Delete($postId)) {
                            $arResultNFCache["ERROR_MESSAGE"][] = GetMessage("BLOG_BLOG_BLOG_MES_DEL_ERROR");
                        } else {
                            CIdeaManagment::getInstance()->Notification(array("TYPE" => "IDEA", "ID" => $postId))->getSonetNotify()->Remove();
                        }
                    }
                } else {
                    if ($arResult["PostPerm"] < BLOG_PERMS_MODERATE) {
                        $arResultNFCache["ERROR_MESSAGE"][] = $_GET["hide_id"] > 0 ? GetMessage("BLOG_BLOG_BLOG_MES_HIDE_NO_RIGHTS") : GetMessage("IDEA_BLOG_BLOG_MES_SHOW_NO_RIGHTS");
                    } elseif (!CBlogPost::Update($postId, array("PUBLISH_STATUS" => $_GET["hide_id"] > 0 ? BLOG_PUBLISH_STATUS_READY : BLOG_PUBLISH_STATUS_PUBLISH))) {
                        $arResultNFCache["ERROR_MESSAGE"][] = $_GET["hide_id"] > 0 ? GetMessage("BLOG_BLOG_BLOG_MES_HIDE_ERROR") : GetMessage("BLOG_BLOG_BLOG_MES_SHOW_ERROR");
Esempio n. 18
0
    /**
     * Use component main.post.list to work with LiveFeed
     * @param int $commentId Comment ID which needs to send.
     * @param array $arParams Array of settings (DATE_TIME_FORMAT, SHOW_RATING, PATH_TO_USER, AVATAR_SIZE, NAME_TEMPLATE, SHOW_LOGIN)
     * @return string
     */
    public static function addLiveComment($commentId = 0, $arParams = array())
    {
        $res = "";
        if ($commentId > 0 && CModule::IncludeModule("pull") && \CPullOptions::GetNginxStatus() && ($comment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($comment["POST_ID"]))) {
            global $DB, $APPLICATION;
            $arParams["DATE_TIME_FORMAT"] = isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : $DB->DateFormatToPHP(CSite::GetDateFormat("FULL"));
            $arParams["SHOW_RATING"] = $arParams["SHOW_RATING"] == "N" ? "N" : "Y";
            $arParams["PATH_TO_USER"] = isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '';
            $arParams["AVATAR_SIZE_COMMENT"] = $arParams["AVATAR_SIZE_COMMENT"] > 0 ? $arParams["AVATAR_SIZE_COMMENT"] : ($arParams["AVATAR_SIZE"] > $arParams["AVATAR_SIZE"] ? $arParams["AVATAR_SIZE"] : 58);
            $arParams["NAME_TEMPLATE"] = isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat();
            $arParams["SHOW_LOGIN"] = $arParams["SHOW_LOGIN"] == "N" ? "N" : "Y";
            $comment["DateFormated"] = FormatDateFromDB($comment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true);
            $timestamp = MakeTimeStamp($comment["DATE_CREATE"]);
            if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                $comment["DateFormated"] = ToLower($comment["DateFormated"]);
            }
            $comment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID);
            $arAuthor = CBlogUser::GetUserInfo($comment["AUTHOR_ID"], $arParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arParams["AVATAR_SIZE_COMMENT"]));
            if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) {
                $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE_COMMENT"], "height" => $arParams["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($comment["UF"][$ufCode])) {
                $p->arUserfields = array($ufCode => array_merge($comment["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);
            $comment["TextFormated"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $p->bMobile = true;
            $comment["TextFormatedMobile"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $comment["TextFormatedJS"] = CUtil::JSEscape(htmlspecialcharsBack($comment["POST_TEXT"]));
            $comment["TITLE"] = CUtil::JSEscape(htmlspecialcharsBack($comment["TITLE"]));
            $eventHandlerID = AddEventHandler("main", "system.field.view.file", array("CSocNetLogTools", "logUFfileShow"));
            $res = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => 'BLOG_COMMENT_BG_', "RATING_TYPE_ID" => $arParams["SHOW_RATING"] == "Y" ? "BLOG_COMMENT" : "", "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "RECORDS" => array($commentId => array("ID" => $comment["ID"], "NEW" => $arParams["FOLLOW"] != "N" && $comment["NEW"] == "Y" ? "Y" : "N", "APPROVED" => $comment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH ? "Y" : "N", "POST_TIMESTAMP" => $timestamp, "POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "AUTHOR" => array("ID" => $arAuthor["ID"], "NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"]), "FILES" => false, "UF" => $comment["UF"], "~POST_MESSAGE_TEXT" => $comment["POST_TEXT"], "WEB" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormated"], "AFTER" => <<<HTML
<script>top.text{$commentId} = text{$commentId} = '{$comment["TextFormatedJS"]}';top.title{$commentId} = title{$commentId} = '{$comment["TITLE"]}';top.arComFiles{$commentId} = [];</script>
HTML
), "MOBILE" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormatedMobile"]))), "NAV_STRING" => "", "NAV_RESULT" => "", "PREORDER" => "N", "RIGHTS" => array("MODERATE" => "N", "EDIT" => "N", "DELETE" => "N"), "VISIBLE_RECORDS_COUNT" => 1, "ERROR_MESSAGE" => "", "OK_MESSAGE" => "", "RESULT" => $commentId, "PUSH&PULL" => array("ACTION" => "REPLY", "ID" => $commentId), "MODE" => "PULL_MESSAGE", "VIEW_URL" => "", "EDIT_URL" => "", "MODERATE_URL" => "", "DELETE_URL" => "", "AUTHOR_URL" => "", "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => "", "LAZYLOAD" => "", "NOTIFY_TAG" => "", "NOTIFY_TEXT" => "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => "", "IMAGE_SIZE" => "", "mfi" => ""), array(), null);
            if ($eventHandlerID !== false && intval($eventHandlerID) > 0) {
                RemoveEventHandler('main', 'system.field.view.file', $eventHandlerID);
            }
        }
        return $res;
    }
Esempio n. 19
0
    function AddLiveComment($commentId = 0, $path = "", $arParams = array())
    {
        if (IntVal($commentId) <= 0) {
            return;
        }
        if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($arComment["POST_ID"]))) {
            if (strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) {
                $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId));
            }
            if (strlen($path) <= 0) {
                $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId)) . "?commentId=" . $commentId;
            }
            $arFormatParams = array("PATH_TO_USER" => isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '', "PATH_TO_POST" => $path, "NAME_TEMPLATE" => isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat(), "SHOW_LOGIN" => isset($arParams["SHOW_LOGIN"]) ? $arParams["SHOW_LOGIN"] : true, "AVATAR_SIZE_COMMENT" => isset($arParams["AVATAR_SIZE_COMMENT"]) ? $arParams["AVATAR_SIZE_COMMENT"] : 58, "PATH_TO_SMILE" => isset($arParams["PATH_TO_SMILE"]) ? $arParams["PATH_TO_SMILE"] : '', "DATE_TIME_FORMAT" => isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : '', "SHOW_RATING" => isset($arParams["SHOW_RATING"]) ? $arParams["SHOW_RATING"] : '', "RATING_TYPE" => "like");
            $arComment["DateFormated"] = FormatDateFromDB($arComment["DATE_CREATE"], $arFormatParams["DATE_TIME_FORMAT"], true);
            if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                $arComment["DateFormated"] = ToLower($arComment["DateFormated"]);
            }
            $arComment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID);
            $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $arFormatParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arFormatParams["AVATAR_SIZE_COMMENT"]));
            if (IsModuleInstalled('extranet') && CModule::IncludeModule('socialnetwork')) {
                CSocNetTools::InitGlobalExtranetArrays();
            }
            $arTmpUser = array("NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "LOGIN" => $arAuthor["~LOGIN"], "NAME_LIST_FORMATTED" => "");
            $arAuthor["NAME_FORMATED"] = CUser::FormatName($arFormatParams["NAME_TEMPLATE"], $arTmpUser, $arFormatParams["SHOW_LOGIN"] != "N");
            if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) {
                $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arFormatParams["AVATAR_SIZE_COMMENT"], "height" => $arFormatParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT);
                $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]);
            }
            $p = new blogTextParser(false, '');
            $ufCode = "UF_BLOG_COMMENT_FILE";
            if (is_array($arComment["UF"][$ufCode])) {
                $p->arUserfields = array($ufCode => array_merge($arComment["UF"][$ufCode], array("TAG" => "DOCUMENT ID")));
            }
            $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y");
            $arParserParams = array("imageWidth" => 800, "imageHeight" => 800);
            $arComment["TextFormated"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $p->bMobile = true;
            $arComment["TextFormatedMobile"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            if ($perm >= BLOG_PERMS_MODERATE) {
                if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                    $arComment["CAN_HIDE"] = "Y";
                } else {
                    $arComment["CAN_SHOW"] = "Y";
                }
            } else {
                $arComment["CAN_SHOW"] = $arComment["CAN_HIDE"] = "N";
            }
            $urlToPost = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFormatParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
            $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
            $arUrl = array("LINK" => $urlToPost, "SHOW" => $urlToPost . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "HIDE" => $urlToPost . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "DELETE" => $urlToPost . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "USER" => htmlspecialcharsback($arFormatParams["PATH_TO_USER"]));
            CRatingsComponentsMain::GetShowRating($arFormatParams);
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRating = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arComment["ID"]));
            }
            $arCommentParams = array("ID" => $commentId, "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "FULL_ID" => array("BLOG_" . $arPost["ID"], $commentId), "ACTION" => "REPLY", "APPROVED" => "Y", "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "NEW" => "Y", "AUTHOR" => array("ID" => $GLOBALS["USER"]->GetID(), "NAME" => $arAuthor["NAME_FORMATED"], "URL" => $arAuthor["url"], "E-MAIL" => $arComment["AuthorEmail"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($GLOBALS["USER"]->GetID(), $GLOBALS["arExtranetUserID"])), "POST_TIMESTAMP" => $arComment["DATE_CREATE_TS"], "POST_TIME" => $arComment["DATE_CREATE_TIME"], "POST_DATE" => $arComment["DateFormated"], "POST_MESSAGE_TEXT" => $arComment["TextFormated"], "POST_MESSAGE_TEXT_MOBILE" => $arComment["TextFormatedMobile"], "URL" => array("LINK" => str_replace(array("##comment_id#", "#comment_id#"), array("", $commentId), $arUrl["LINK"]), "EDIT" => "__blogEditComment('" . $commentId . "', '" . $arPost["ID"] . "');", "MODERATE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arComment["CAN_SHOW"] == "Y" ? $arUrl["SHOW"] : ($arComment["CAN_HIDE"] == "Y" ? $arUrl["HIDE"] : "")), "DELETE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arUrl["DELETE"])), "AFTER" => "", "BEFORE_ACTIONS_MOBILE" => "", "AFTER_MOBILE" => "");
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRatingData = array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $commentId, "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating[$commentId]["USER_VOTE"], "USER_HAS_VOTED" => $arRating[$commentId]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating[$commentId]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating[$commentId]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating[$commentId]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating[$commentId]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arUrl["USER"]);
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS"] = ob_get_clean();
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS_MOBILE"] = ob_get_clean();
            }
            $arUFResult = self::BuildUFFields($arComment["UF"]);
            $arCommentParams["AFTER"] .= $arUFResult["AFTER"];
            $arCommentParams["AFTER_MOBILE"] .= $arUFResult["AFTER_MOBILE"];
            if ($arComment["CAN_EDIT"] == "Y") {
                ob_start();
                ?>
<script>
					top.text<?php 
                echo $commentId;
                ?>
 = text<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo CUtil::JSEscape(htmlspecialcharsBack($arComment["POST_TEXT"]));
                ?>
';
					top.title<?php 
                echo $commentId;
                ?>
 = title<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo isset($arComment["TITLE"]) ? CUtil::JSEscape($arComment["TITLE"]) : '';
                ?>
';
					top.arComFiles<?php 
                echo $commentId;
                ?>
 = [];<?php 
                ?>
</script><?php 
                $arCommentParams["AFTER"] .= ob_get_clean();
            }
            CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arPost["ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arCommentParams));
        }
    }
Esempio n. 20
0
 function Update($ID, $arFields)
 {
     global $DB;
     $ID = IntVal($ID);
     if (strlen($arFields["PATH"]) > 0) {
         $arFields["PATH"] = str_replace("#post_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 (!CBlogPost::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     } elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_POST", $ID, $arFields)) {
         return false;
     }
     $db_events = GetModuleEvents("blog", "OnBeforePostUpdate");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
             return false;
         }
     }
     $arOldPost = CBlogPost::GetByID($ID);
     if (is_array($arFields["ATTACH_IMG"])) {
         if (!array_key_exists("MODULE_ID", $arFields["ATTACH_IMG"]) || strlen($arFields["ATTACH_IMG"]["MODULE_ID"]) <= 0) {
             $arFields["ATTACH_IMG"]["MODULE_ID"] = "blog";
         }
         $prefix = "blog";
         if (strlen($arFields["URL"]) > 0) {
             $prefix .= "/" . $arFields["URL"];
         }
         CFile::SaveForDB($arFields, "ATTACH_IMG", $prefix);
     }
     $strUpdate = $DB->PrepareUpdate("b_blog_post", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (strlen($strUpdate) > 0) {
         $oldPostPerms = CBlogUserGroup::GetGroupPerms(1, $arOldPost["BLOG_ID"], $ID, BLOG_PERMS_POST);
         $strSql = "UPDATE b_blog_post SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_" . $ID]);
         $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_POST", $ID, $arFields);
     } else {
         $ID = False;
     }
     if ($ID) {
         $arNewPost = CBlogPost::GetByID($ID);
         if ($arNewPost["PUBLISH_STATUS"] != $arOldPost["PUBLISH_STATUS"] || $arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) {
             CBlog::SetStat($arNewPost["BLOG_ID"]);
         }
         if ($arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) {
             CBlog::SetStat($arOldPost["BLOG_ID"]);
         }
         if (is_set($arFields, "PERMS_POST")) {
             CBlogPost::SetPostPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST);
         }
         if (is_set($arFields, "PERMS_COMMENT")) {
             CBlogPost::SetPostPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT);
         }
         if (array_key_exists("SOCNET_RIGHTS", $arFields)) {
             $arFields["SC_PERM_OLD"] = CBlogPost::GetSocNetPermsCode($ID);
             $arFields["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ID, $arFields["SOCNET_RIGHTS"], $arNewPost);
         }
         $db_events = GetModuleEvents("blog", "OnPostUpdate");
         while ($arEvent = $db_events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, &$arFields));
         }
         if (CModule::IncludeModule("search")) {
             $newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arNewPost["BLOG_ID"], $ID, BLOG_PERMS_POST);
             $arBlog = CBlog::GetByID($arNewPost["BLOG_ID"]);
             if ($arOldPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $oldPostPerms >= BLOG_PERMS_READ && ($arNewPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH || $newPostPerms < BLOG_PERMS_READ) || $arBlog["SEARCH_INDEX"] != "Y") {
                 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) {
                     if (strlen($arNewPost["CODE"]) > 0) {
                         $arNewPost["PATH"] = str_replace("#post_id#", $arNewPost["CODE"], $arNewPost["PATH"]);
                     } else {
                         $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 (strlen($arNewPost["CATEGORY_ID"]) > 0) {
                     $arC = explode(",", $arNewPost["CATEGORY_ID"]);
                     $arTag = array();
                     foreach ($arC as $v) {
                         $arCategory = CBlogCategory::GetByID($v);
                         $arTag[] = $arCategory["NAME"];
                     }
                     $tag = implode(",", $arTag);
                 }
                 $arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arNewPost["DATE_PUBLISH"], "PARAM1" => "POST", "PARAM2" => $arNewPost["BLOG_ID"], "PARAM3" => $arNewPost["ID"], "PERMISSIONS" => array(2), "TITLE" => $arNewPost["TITLE"], "BODY" => blogTextParser::killAllTags($arNewPost["DETAIL_TEXT"]), "TAGS" => $tag, "USER_ID" => $arNewPost["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $arNewPost["ID"]);
                 $bIndexComment = false;
                 if ($arBlog["USE_SOCNET"] == "Y") {
                     if (!empty($arFields["SC_PERM"])) {
                         $arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"];
                         if ($arFields["SC_PERM"] != $arFields["SC_PERM_OLD"]) {
                             $bIndexComment = true;
                         }
                     } else {
                         $arSearchIndex["PERMISSIONS"] = CBlogPost::GetSocnetPermsCode($ID);
                     }
                 }
                 CSearch::Index("blog", "P" . $ID, $arSearchIndex, True);
                 if ($arOldPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || $bIndexComment) {
                     $arParamsComment = array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $ID, "SITE_ID" => $arGroup["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "BLOG_URL" => $arBlog["URL"], "OWNER_ID" => $arBlog["OWNER_ID"], "SOCNET_GROUP_ID" => $arBlog["SOCNET_GROUP_ID"], "USE_SOCNET" => $arBlog["USE_SOCNET"]);
                     CBlogComment::_IndexPostComments($arParamsComment);
                 }
             }
         }
     }
     return $ID;
 }
Esempio n. 21
0
    }
    $BLOG_ID = intval($BLOG_ID);
    if (!$BLOG_ID) {
        $BLOG_ID = intval($_POST['BLOG_ID']);
    }
    $arr = CBlogSitePath::GetBySiteID(SITE_ID);
    $sBlogPath = $arr['PATH'];
    if ($BLOG_ID) {
        $arBlog = CBlog::GetByID($BLOG_ID);
    } else {
        $res = CBlog::GetList(array(), array("URL" => $OWNER));
        $arBlog = $res->Fetch();
        $BLOG_ID = intval($arBlog['ID']);
    }
    if ($arBlog) {
        if (IntVal($ID) > 0 && ($arPost = CBlogPost::GetByID($ID))) {
            $APPLICATION->SetTitle(str_replace("#BLOG#", htmlspecialchars($arBlog["NAME"]), "" . GetMessage("BLOG_POST_EDIT") . ""));
            $perms = CBlogPost::GetBlogUserPostPerms($ID, $USER_ID);
        } else {
            $ID = 0;
            $APPLICATION->SetTitle(str_replace("#BLOG#", htmlspecialchars($arBlog["NAME"]), "" . GetMessage("BLOG_NEW_MESSAGE") . ""));
            $perms = CBlog::GetBlogUserPostPerms($BLOG_ID, $USER_ID);
        }
        if ($perms >= BLOG_PERMS_WRITE && (intval($arPost['ID']) == 0 || $arPost['BLOG_ID'] == $BLOG_ID)) {
            ###### Form ####
            $image_form = '
				<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
				<html>
				<head>
				<title>' . GetMessage("BLOG_P_IMAGE_UPLOAD") . '</title>
				</head>
Esempio n. 22
0
 /**
  * Checking blog comment for spam
  * @param &array Comment fields to check
  * @return null|boolean NULL when success or FALSE when spam detected
  */
 function OnBeforeCommentAddHandler(&$arFields)
 {
     global $APPLICATION, $USER;
     $ct_status = COption::GetOptionString('cleantalk.antispam', 'status', '0');
     $ct_comment_blog = COption::GetOptionString('cleantalk.antispam', 'form_comment_blog', '0');
     if ($ct_status == 1 && $ct_comment_blog == 1) {
         if ($USER->IsAdmin()) {
             return;
         }
         // Skip authorized user with more than 5 approved comments
         if ($USER->IsAuthorized()) {
             $approved_comments = CBlogComment::GetList(array('ID' => 'ASC'), array('AUTHOR_ID' => $arFields['AUTHOR_ID'], 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH), array());
             if (intval($approved_comments) > 5) {
                 return;
             }
         }
         $aComment = array();
         $aComment['type'] = 'comment';
         $aComment['sender_email'] = isset($arFields['AUTHOR_EMAIL']) ? $arFields['AUTHOR_EMAIL'] : '';
         $aComment['sender_nickname'] = isset($arFields['AUTHOR_NAME']) ? $arFields['AUTHOR_NAME'] : '';
         $aComment['message_title'] = '';
         $aComment['message_body'] = isset($arFields['POST_TEXT']) ? $arFields['POST_TEXT'] : '';
         $aComment['example_title'] = '';
         $aComment['example_body'] = '';
         $aComment['example_comments'] = '';
         if (COption::GetOptionString('cleantalk.antispam', 'form_send_example', '0') == 1) {
             $arPost = CBlogPost::GetByID($arFields['POST_ID']);
             if (is_array($arPost)) {
                 $aComment['example_title'] = $arPost['TITLE'];
                 $aComment['example_body'] = $arPost['DETAIL_TEXT'];
                 // Find last 10 approved comments
                 $db_res = CBlogComment::GetList(array('DATE_CREATE' => 'DESC'), array('POST_ID' => $arFields['POST_ID'], 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH), false, array('nTopCount' => 10), array('POST_TEXT'));
                 while ($ar_res = $db_res->Fetch()) {
                     $aComment['example_comments'] .= $ar_res['TITLE'] . "\n\n" . $ar_res['POST_TEXT'] . "\n\n";
                 }
             }
         }
         $aResult = self::CheckAllBefore($aComment, TRUE);
         if (isset($aResult) && is_array($aResult)) {
             if ($aResult['errno'] == 0) {
                 if ($aResult['allow'] == 1) {
                     // Not spammer - just return;
                     return;
                 } else {
                     if ($aResult['stop_queue'] == 1) {
                         // Spammer and stop_queue - return false and throw
                         if (preg_match('//u', $aResult['ct_result_comment'])) {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str);
                         } else {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/i', '', $err_str);
                         }
                         $APPLICATION->ThrowException($err_str);
                         return FALSE;
                     } else {
                         // Spammer and NOT stop_queue - to manual approvement
                         // BLOG_PUBLISH_STATUS_READY
                         // It doesn't work
                         // values below results in endless 'Loading' AJAX message :(
                         //$arFields['PUBLISH_STATUS'] = BLOG_PUBLISH_STATUS_READY;
                         //$arFields['PUBLISH_STATUS'] = BLOG_PUBLISH_STATUS_DRAFT;
                         //return;
                         // It doesn't work too
                         // Status setting in OnCommentAddHandler still results in endless 'Loading' AJAX message :(
                         //$GLOBALS['ct_after_CommentAdd_status'] = BLOG_PUBLISH_STATUS_READY;
                         //return;
                         if (preg_match('//u', $aResult['ct_result_comment'])) {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str);
                         } else {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/i', '', $err_str);
                         }
                         $APPLICATION->ThrowException($err_str);
                         return FALSE;
                     }
                 }
             }
         }
     }
 }
Esempio n. 23
0
 $arResult["ELEMENT"]["~DETAIL_PAGE_URL"] = CComponentEngine::MakePathFromTemplate($arParams["~DETAIL_URL"], array("USER_ALIAS" => $arGallery["CODE"], "SECTION_ID" => $arResult["ELEMENT"]["IBLOCK_SECTION_ID"], "ELEMENT_ID" => $arResult["ELEMENT"]["ID"]));
 $arResult["ELEMENT"]["DETAIL_PAGE_URL"] = htmlspecialcharsbx($arResult["ELEMENT"]["~DETAIL_PAGE_URL"]);
 $obProperty = false;
 $iCommentID = 0;
 /************** BLOG *****************************************************/
 $obProperty = new CIBlockProperty();
 if (is_set($arResult["ELEMENT"]["PROPERTIES"], "BLOG_POST_ID")) {
     $iCommentID = intVal($arResult["ELEMENT"]["PROPERTIES"]["BLOG_POST_ID"]["VALUE"]);
 } else {
     $res = $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_BLOG_POST_ID")) <= 0 ? "BLOG_POST_ID" : GetMessage("P_BLOG_POST_ID"), "CODE" => "BLOG_POST_ID"));
 }
 if (!is_set($arResult["ELEMENT"], "PROPERTY_BLOG_COMMENTS_CNT_VALUE")) {
     $res = $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => strLen(GetMessage("P_BLOG_COMMENTS_CNT")) <= 0 ? "P_BLOG_COMMENTS_CNT" : GetMessage("P_BLOG_COMMENTS_CNT"), "CODE" => "BLOG_COMMENTS_CNT"));
 }
 if ($iCommentID > 0) {
     $arPost = CBlogPost::GetByID($iCommentID);
     if (!$arPost) {
         $iCommentID = 0;
     } elseif (intVal($arPost["NUM_COMMENTS"]) > 0 && $arPost["NUM_COMMENTS"] != $arResult["ELEMENT"]["PROPERTIES"]["BLOG_COMMENTS_CNT"]["VALUE"]) {
         CIBlockElement::SetPropertyValues($arParams["ELEMENT_ID"], $arParams["IBLOCK_ID"], intVal($arPost["NUM_COMMENTS"]), "BLOG_COMMENTS_CNT");
     }
 }
 if (!$iCommentID && isset($_REQUEST["parentId"])) {
     $arCategory = array();
     $arBlog = CBlog::GetByUrl($arParams["BLOG_URL"]);
     if (!empty($arResult["ELEMENT"]["TAGS"])) {
         $arCategoryVal = explode(",", $arResult["ELEMENT"]["TAGS"]);
         foreach ($arCategoryVal as $k => $v) {
             if ($id = CBlogCategory::Add(array("BLOG_ID" => $arBlog["ID"], "NAME" => $v))) {
                 $arCategory[] = $id;
             }
Esempio n. 24
0
 $arGalleriesIds = array(0);
 $arUsers = array();
 switch ($_REQUEST["ACTION"]) {
     case "drop":
         if (!CIBlockElement::Delete($itemID)) {
             $sError = GetMessage("P_DELETE_ERROR");
             if ($ex = $APPLICATION->GetException()) {
                 $sError = $ex->GetString();
             }
             $arError[] = array("id" => "drop error", "text" => PhotoShowError(array("code" => "NOT_DELETED", "title" => $sError, "DATA" => $arRes)));
             continue;
         }
         $iFileSize += intVal($arRes["REAL_PICTURE"]["FILE_SIZE"]);
         if ($arRes["BLOG_POST_ID"] > 0) {
             CModule::IncludeModule("blog");
             $arPost = CBlogPost::GetByID($arRes["BLOG_POST_ID"]);
             $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
             CBlogPost::Delete($arRes["BLOG_POST_ID"]);
             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"]);
         }
         if ($arRes["FORUM_TOPIC_ID"] > 0) {
             CModule::IncludeModule("forum");
             ForumDeleteTopic($arRes["FORUM_TOPIC_ID"]);
         }
         $events = GetModuleEvents("photogallery", "OnAfterPhotoDrop");
         $arEventFields = array("ID" => $arRes["ID"], "SECTION_ID" => $arRes["IBLOCK_SECTION_ID"]);
         $sectionsIds[] = $arRes["IBLOCK_SECTION_ID"];
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($arEventFields, $arParams));
         }
         break;
Esempio n. 25
0
	function Update($ID, $arFields, $bSearchIndex = true)
	{
		global $DB;

		$ID = IntVal($ID);
		if(strlen($arFields["PATH"]) > 0)
			$arFields["PATH"] = str_replace("#post_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 (!CBlogPost::CheckFields("UPDATE", $arFields, $ID))
			return false;
		elseif(!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_POST", $ID, $arFields))
			return false;

		foreach(GetModuleEvents("blog", "OnBeforePostUpdate", true) as $arEvent)
		{
			if (ExecuteModuleEventEx($arEvent, Array($ID, &$arFields))===false)
				return false;
		}

		$arOldPost = CBlogPost::GetByID($ID);

		if(is_array($arFields["ATTACH_IMG"]))
		{
			if (
				!array_key_exists("MODULE_ID", $arFields["ATTACH_IMG"])
				|| strlen($arFields["ATTACH_IMG"]["MODULE_ID"]) <= 0
			)
				$arFields["ATTACH_IMG"]["MODULE_ID"] = "blog";

			$prefix = "blog";
			if(strlen($arFields["URL"]) > 0)
				$prefix .= "/".$arFields["URL"];
			CFile::SaveForDB($arFields, "ATTACH_IMG", $prefix);
		}

		$strUpdate = $DB->PrepareUpdate("b_blog_post", $arFields);

		foreach ($arFields1 as $key => $value)
		{
			if (strlen($strUpdate) > 0)
				$strUpdate .= ", ";
			$strUpdate .= $key."=".$value." ";
		}

		if (strlen($strUpdate) > 0)
		{
			$oldPostPerms = CBlogUserGroup::GetGroupPerms(1, $arOldPost["BLOG_ID"], $ID, BLOG_PERMS_POST);

			$strSql =
				"UPDATE b_blog_post SET ".
				"	".$strUpdate." ".
				"WHERE ID = ".$ID." ";
			$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);

			unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_".$ID]);

			foreach(GetModuleEvents("blog", "OnBeforePostUserFieldUpdate", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, Array("BLOG_POST", $ID, $arFields));

			$GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_POST", $ID, $arFields);
		}
		else
		{
			$ID = False;
		}

		if ($ID)
		{
			$arNewPost = CBlogPost::GetByID($ID);
			if($arNewPost["PUBLISH_STATUS"] != $arOldPost["PUBLISH_STATUS"]  || $arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"])
				CBlog::SetStat($arNewPost["BLOG_ID"]);

			if ($arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"])
				CBlog::SetStat($arOldPost["BLOG_ID"]);

			if (is_set($arFields, "PERMS_POST"))
				CBlogPost::SetPostPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST);
			if (is_set($arFields, "PERMS_COMMENT"))
				CBlogPost::SetPostPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT);

			if(array_key_exists("SOCNET_RIGHTS", $arFields))
			{
				$arFields["SC_PERM_OLD"] = CBlogPost::GetSocNetPermsCode($ID);
				$arFields["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ID, $arFields["SOCNET_RIGHTS"], $arNewPost);
			}

			foreach(GetModuleEvents("blog", "OnPostUpdate", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, Array($ID, &$arFields));

			if ($bSearchIndex && CModule::IncludeModule("search"))
			{
				$newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arNewPost["BLOG_ID"], $ID, BLOG_PERMS_POST);
				$arBlog = CBlog::GetByID($arNewPost["BLOG_ID"]);

				if (
					$arOldPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH &&
					$oldPostPerms >= BLOG_PERMS_READ
					&& (
						$arNewPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH ||
						$newPostPerms < BLOG_PERMS_READ
						)
					|| $arBlog["SEARCH_INDEX"] != "Y"
					)
				{
					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"]);
						$arTag = Array();
						foreach($arC as $v)
						{
							$arCategory = CBlogCategory::GetByID($v);
							$arTag[] = $arCategory["NAME"];
						}
						$tag =  implode(",", $arTag);
					}

					$searchContent = blogTextParser::killAllTags($arNewPost["DETAIL_TEXT"]);
					$searchContent .= "\r\n" . $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("BLOG_POST", $arNewPost["ID"]);

					$authorName = "";
					if(IntVal($arNewPost["AUTHOR_ID"]) > 0)
					{
						$dbUser = CUser::GetByID($arNewPost["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);
							if(strlen($authorName) > 0)
								$searchContent .= "\r\n".$authorName;
						}
					}

					$arSearchIndex = array(
						"SITE_ID" => $arPostSite,
						"LAST_MODIFIED" => $arNewPost["DATE_PUBLISH"],
						"PARAM1" => "POST",
						"PARAM2" => $arNewPost["BLOG_ID"],
						"PARAM3" => $arNewPost["ID"],
						"PERMISSIONS" => array(2),
						"TITLE" => $arNewPost["TITLE"],
						"BODY" => $searchContent,
						"TAGS" => $tag,
						"USER_ID" => $arNewPost["AUTHOR_ID"],
						"ENTITY_TYPE_ID" => "BLOG_POST",
						"ENTITY_ID" => $arNewPost["ID"],
					);

					$bIndexComment = false;
					if($arBlog["USE_SOCNET"] == "Y")
					{
						if(!empty($arFields["SC_PERM"]))
						{
							$arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"];
							if($arFields["SC_PERM"] != $arFields["SC_PERM_OLD"])
								$bIndexComment = true;
						}
						else
							$arSearchIndex["PERMISSIONS"] = CBlogPost::GetSocnetPermsCode($ID);

						if(!in_array("U".$arNewPost["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"]))
							$arSearchIndex["PERMISSIONS"][] = "U".$arNewPost["AUTHOR_ID"];

						if(is_array($arSearchIndex["PERMISSIONS"]))
						{
							$sgId = array();
							foreach($arSearchIndex["PERMISSIONS"] 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",
								);
							}
						}

						// get mentions and grats
						$arMentionedUserID = CBlogPost::GetMentionedUserID($arNewPost);
						if (!empty($arMentionedUserID))
						{
							if (!isset($arSearchIndex["PARAMS"]))
							{
								$arSearchIndex["PARAMS"] = array();
							}
							$arSearchIndex["PARAMS"]["mentioned_user_id"] = $arMentionedUserID;
						}
					}

					CSearch::Index("blog", "P".$ID, $arSearchIndex, True);

					if(($arOldPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) || $bIndexComment) //index comments
					{
						$arParamsComment = Array(
							"BLOG_ID" => $arBlog["ID"],
							"POST_ID" => $ID,
							"SITE_ID" => $arGroup["SITE_ID"],
							"PATH" => $arPostSite[$arGroup["SITE_ID"]]."?commentId=#comment_id###comment_id#",
							"BLOG_URL" => $arBlog["URL"],
							"OWNER_ID" => $arBlog["OWNER_ID"],
							"SOCNET_GROUP_ID" => $arBlog["SOCNET_GROUP_ID"],
							"USE_SOCNET" => $arBlog["USE_SOCNET"],
						);

						CBlogComment::_IndexPostComments($arParamsComment);
					}
				}
			}
		}

		BXClearCache(true, '/blog/socnet_post/gen/'.$ID);

		return $ID;
	}
 function SetGroupPerms($ID, $blogID, $postID = 0, $permission = BLOG_PERMS_DENY, $permsType = BLOG_PERMS_POST)
 {
     global $DB;
     $ID = IntVal($ID);
     $blogID = IntVal($blogID);
     $postID = IntVal($postID);
     $arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]);
     if (!in_array($permission, $arAvailPerms)) {
         $permission = $arAvailPerms[0];
     }
     $permsType = $permsType == BLOG_PERMS_COMMENT ? BLOG_PERMS_COMMENT : BLOG_PERMS_POST;
     $bSuccess = True;
     $arUserGroup = CBlogUserGroup::GetByID($ID);
     if (!$arUserGroup) {
         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("BLG_GUG_ERROR_NO_USER_GROUP")), "ERROR_NO_USER_GROUP");
         $bSuccess = False;
     }
     if ($bSuccess) {
         $arBlog = CBlog::GetByID($blogID);
         if (!$arBlog) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $blogID, GetMessage("BLG_GUG_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
             $bSuccess = False;
         }
     }
     if ($bSuccess) {
         if ($postID > 0) {
             $arPost = CBlogPost::GetByID($postID);
             if (!$arPost) {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $postID, GetMessage("BLG_GUG_ERROR_NO_POST")), "ERROR_NO_POST");
                 $bSuccess = False;
             }
         }
     }
     if ($bSuccess) {
         $oldGroupPerms = CBlogUserGroup::GetGroupPerms(1, $blogID, 0, BLOG_PERMS_POST);
         $DB->StartTransaction();
         $currentPerms = CBlogUserGroup::GetGroupPerms($ID, $blogID, $postID, $permsType);
         if ($currentPerms) {
             if ($currentPerms != $permission) {
                 if ($postID > 0) {
                     $DB->Query("UPDATE b_blog_user_group_perms SET " . "\tPERMS = '" . $DB->ForSql($permission) . "' " . "WHERE BLOG_ID = " . $blogID . " " . "\tAND POST_ID = " . $postID . " " . "\tAND USER_GROUP_ID = " . $ID . "" . "\tAND PERMS_TYPE = '" . $DB->ForSql($permsType) . "'");
                 } else {
                     $DB->Query("UPDATE b_blog_user_group_perms SET " . "\tPERMS = '" . $DB->ForSql($permission) . "' " . "WHERE BLOG_ID = " . $blogID . " " . "\tAND USER_GROUP_ID = " . $ID . " " . "\tAND PERMS_TYPE = '" . $DB->ForSql($permsType) . "'" . "\tAND POST_ID IS NULL ");
                 }
             }
         } else {
             if ($postID > 0) {
                 $DB->Query("INSERT INTO b_blog_user_group_perms (BLOG_ID, USER_GROUP_ID, PERMS_TYPE, POST_ID, PERMS) " . "VALUES (" . $blogID . ", " . $ID . ", '" . $DB->ForSql($permsType) . "', " . $postID . ", '" . $DB->ForSql($permission) . "') ");
             } else {
                 $DB->Query("INSERT INTO b_blog_user_group_perms (BLOG_ID, USER_GROUP_ID, PERMS_TYPE, POST_ID, PERMS) " . "VALUES (" . $blogID . ", " . $ID . ", '" . $DB->ForSql($permsType) . "', null, '" . $DB->ForSql($permission) . "') ");
             }
         }
         $DB->Commit();
         unset($GLOBALS["BLOG_USER_GROUP"]["BLOG_GROUP_PERMS_CACHE_" . $blogID . "_" . $postID . "_" . $permsType . "_" . $ID]);
         unset($GLOBALS["BLOG_USER_GROUP"]["BLOG_USER_PERMS_CACHE_" . $blogID . "_" . $postID . "_" . $permsType]);
     }
     if ($bSuccess) {
         if (CModule::IncludeModule("search")) {
             $newGroupPerms = CBlogUserGroup::GetGroupPerms(1, $blogID, 0, BLOG_PERMS_POST);
             if ($oldGroupPerms >= BLOG_PERMS_READ && $newGroupPerms < BLOG_PERMS_READ) {
                 CSearch::DeleteIndex("blog", false, $blogID);
             } elseif ($oldGroupPerms < BLOG_PERMS_READ && $newGroupPerms >= BLOG_PERMS_READ) {
             }
         }
     }
     return $bSuccess;
 }
Esempio n. 27
0
 function GetSocNetPostPerms($postId = 0, $bNeedFull = false, $userId = false)
 {
     if (!$userId) {
         $userId = IntVal($GLOBALS["USER"]->GetID());
         $bByUserId = false;
     } else {
         $userId = IntVal($userId);
         $bByUserId = true;
     }
     $postId = IntVal($postId);
     if ($postId <= 0) {
         return false;
     }
     $perms = BLOG_PERMS_DENY;
     $arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]);
     if (!$bByUserId) {
         $blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog");
         if ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) {
             $perms = $arAvailPerms[count($arAvailPerms) - 1];
         }
     } else {
         if (CSocNetUser::IsUserModuleAdmin($userId)) {
             $perms = $arAvailPerms[count($arAvailPerms) - 1];
         }
     }
     $arPost = CBlogPost::GetByID($postId);
     if ($arPost["AUTHOR_ID"] == $userId) {
         $perms = BLOG_PERMS_FULL;
     }
     if ($perms <= BLOG_PERMS_DENY) {
         $arPerms = CBlogPost::GetSocNetPerms($postId);
         $arEntities = array();
         if (isset($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId]) && !empty($GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId])) {
             $arEntities = $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId];
         } else {
             $dbA = CAccess::GetUserCodes($userId);
             while ($arA = $dbA->Fetch()) {
                 if ($arA["PROVIDER_ID"] == "intranet") {
                     $arEntities["DR"][] = $arA["ACCESS_CODE"];
                 } elseif ($arA["PROVIDER_ID"] == "socnetgroup") {
                     $g = substr($arA["ACCESS_CODE"], 2);
                     $gId = IntVal($g);
                     $gR = substr($g, strpos($g, "_") + 1);
                     $arEntities["SG"][$gId][] = $gR;
                 }
             }
             $GLOBALS["BLOG_POST"]["UAC_CACHE_" . $userId] = $arEntities;
         }
         foreach ($arPerms as $t => $val) {
             foreach ($val as $id => $p) {
                 if ($userId > 0 && $t == "U" && $userId == $id) {
                     $perms = BLOG_PERMS_READ;
                     if (in_array("US" . $userId, $p)) {
                         // if author
                         $perms = BLOG_PERMS_FULL;
                     }
                     break;
                 }
                 if (in_array("G2", $p)) {
                     $perms = BLOG_PERMS_READ;
                     break;
                 }
                 if ($userId > 0 && in_array("AU", $p)) {
                     $perms = BLOG_PERMS_READ;
                     break;
                 }
                 if ($t == "SG") {
                     if (!empty($arEntities["SG"][$id])) {
                         foreach ($arEntities["SG"][$id] as $gr) {
                             if (in_array("SG" . $id . "_" . $gr, $p)) {
                                 $perms = BLOG_PERMS_READ;
                                 break;
                             }
                         }
                     }
                 }
                 if ($t == "DR") {
                     if (in_array("DR" . $id, $arEntities["DR"])) {
                         $perms = BLOG_PERMS_READ;
                         break;
                     }
                 }
             }
             if ($perms > BLOG_PERMS_DENY) {
                 break;
             }
         }
         if ($bNeedFull && $perms <= BLOG_PERMS_FULL) {
             $arGroupsId = array();
             if (!empty($arPerms["SG"])) {
                 foreach ($arPerms["SG"] as $gid => $val) {
                     if (!empty($arEntities["SG"][$gid])) {
                         $arGroupsId[] = $gid;
                     }
                 }
             }
             $operation = array("full_post", "moderate_post", "write_post", "premoderate_post");
             if (!empty($arGroupsId)) {
                 foreach ($operation as $v) {
                     if ($perms <= BLOG_PERMS_READ) {
                         $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v);
                         if (!empty($f)) {
                             foreach ($f as $gid => $val) {
                                 if (in_array($val, $arEntities["SG"][$gid])) {
                                     switch ($v) {
                                         case "full_post":
                                             $perms = BLOG_PERMS_FULL;
                                             break;
                                         case "moderate_post":
                                             $perms = BLOG_PERMS_MODERATE;
                                             break;
                                         case "write_post":
                                             $perms = BLOG_PERMS_WRITE;
                                             break;
                                         case "premoderate_post":
                                             $perms = BLOG_PERMS_PREMODERATE;
                                             break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $perms;
 }
Esempio n. 28
0
 public static function getBlogPostUsersImprtnt($arFields)
 {
     if (!is_array($arFields)) {
         throw new Exception('Incorrect input data');
     }
     $arParams["postId"] = intval($arFields['POST_ID']);
     if ($arParams["postId"] <= 0) {
         throw new Exception('Wrong post ID');
     }
     $arParams["nTopCount"] = 500;
     $arParams["paramName"] = 'BLOG_POST_IMPRTNT';
     $arParams["paramValue"] = 'Y';
     $arResult = array();
     $cache = new CPHPCache();
     $cache_id = "blog_post_param_" . serialize(array($arParams["postId"], $arParams["nTopCount"], $arParams["paramName"], $arParams["paramValue"]));
     $cache_path = $GLOBALS["CACHE_MANAGER"]->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog")) . "/" . $arParams["postId"];
     $cache_time = defined("BX_COMP_MANAGED_CACHE") ? 3600 * 24 * 365 : 600;
     if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $arResult = $cache->GetVars();
     } else {
         $cache->StartDataCache($cache_time, $cache_id, $cache_path);
         if (CModule::IncludeModule("blog")) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag($arParams["paramName"] . $arParams["postId"]);
             }
             if ($arBlogPost = CBlogPost::GetByID($arParams["postId"])) {
                 $postPerms = CBlogPost::GetSocNetPostPerms($arParams["postId"], true, $GLOBALS["USER"]->GetID(), $arBlogPost["AUTHOR_ID"]);
                 if ($postPerms >= BLOG_PERMS_READ) {
                     $db_res = CBlogUserOptions::GetList(array(), array('POST_ID' => $arParams["postId"], 'NAME' => $arParams["paramName"], 'VALUE' => $arParams["paramValue"], 'USER_ACTIVE' => 'Y'), array("nTopCount" => $arParams["nTopCount"], "SELECT" => array("USER_ID")));
                     if ($db_res) {
                         while ($res = $db_res->Fetch()) {
                             $arResult[] = $res["USER_ID"];
                         }
                     }
                 }
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->EndTagCache();
             }
             $cache->EndDataCache($arResult);
         }
     }
     return $arResult;
 }
Esempio n. 29
0
                 LocalRedirect($APPLICATION->GetCurPageParam("del_id=" . $DEL_ID . "&success=Y", array("del_id", "sessid", "success", "show_id")));
             } else {
                 $errorMessage = GetMessage("B_B_HIDE_M_DEL_ERR");
             }
         } else {
             $errorMessage = GetMessage("B_B_HIDE_M_DEL_RIGHTS");
         }
     }
 } elseif (IntVal($_GET["show_id"]) > 0) {
     if ($_GET["success"] == "Y") {
         $okMessage = GetMessage("BLOG_BLOG_BLOG_MES_SHOWED");
     } else {
         if (check_bitrix_sessid()) {
             $show_id = IntVal($_GET["show_id"]);
             if ($arResult["PostPerm"] >= BLOG_PERMS_MODERATE) {
                 if ($arPost = CBlogPost::GetByID($show_id)) {
                     if (CBlogPost::Update($show_id, array("PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH))) {
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/first_page/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/pages/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/calendar/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $show_id . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/commented_posts/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/last_comments/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/trackback/" . $show_id . "/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_out/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_all/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/rss_sonet/");
                         BXClearCache(True, "/" . SITE_ID . "/blog/rss_all/");
Esempio n. 30
0
		"ID"=>IntVal($arFolders[1]),
		"TBLenght" => 0,
		"CACHE_TIME"=>0,
	)
); 
*/
if (CModule::IncludeModule("blog")) {
    $CACHE_TIME = intval($CACHE_TIME);
    $ID = IntVal($ID);
    $BLOG_URL = preg_replace("/[^a-zA-Z0-9_-]/is", "", Trim($BLOG_URL));
    $TBLenght = IntVal($TBLenght) > 0 ? IntVal($TBLenght) : false;
    $editPage = strlen($EDIT_PAGE) > 0 ? $EDIT_PAGE : "post_edit.php";
    $is404 = $is404 == 'N' ? false : true;
    $USER_ID = $USER->GetID();
    $PostPerm = CBlogPost::GetBlogUserPostPerms($ID, $USER_ID);
    $arPost = CBlogPost::GetByID($ID);
    $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
    $dbBlog = CBlog::GetList(array(), array("URL" => $BLOG_URL), false, array("nTopCount" => 1));
    if (($arBlogUrl = $dbBlog->Fetch()) || strlen($BLOG_URL) <= 0) {
        $APPLICATION->SetTitle($arPost["TITLE"]);
        $APPLICATION->AddChainItem($arBlogUrl["NAME"], CBlog::PreparePath($arBlogUrl["URL"]));
        //Заявка на чтение блога
        if ($_GET["become_friend"] == "Y" && $PostPerm < BLOG_PERMS_READ) {
            if ($USER->IsAuthorized()) {
                $dbCandidate = CBlogCandidate::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $USER_ID));
                if ($arCandidate = $dbCandidate->Fetch()) {
                    echo '<font class="text">' . GetMessage("B_B_MES_REQUEST_ALREADY") . '</font>';
                } else {
                    if (CBlogCandidate::Add(array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $USER_ID))) {
                        echo '<font class="text">' . GetMessage("B_B_MES_REQUEST_ADDED") . '</font>';
                    } else {