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;
 }
 public static function CallBack_AddComment($arFields)
 {
     if (!CModule::IncludeModule('blog')) {
         return false;
     }
     $arResult = array();
     $arLog = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID", "RATING_ENTITY_ID"))->Fetch();
     if ($arLog) {
         $arIdeaPost = CBlogPost::GetById($arLog["SOURCE_ID"]);
         if ($arIdeaPost) {
             $UserIP = CBlogUser::GetUserIP();
             $IdeaCommentId = CBlogComment::Add(array("BLOG_ID" => $arIdeaPost["BLOG_ID"], "POST_ID" => $arIdeaPost["ID"], "AUTHOR_ID" => $arFields["USER_ID"], "POST_TEXT" => $arFields["MESSAGE"], "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "PARENT_ID" => false, "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1]));
             $arResult = array("SOURCE_ID" => $IdeaCommentId);
             if ($arLog["RATING_ENTITY_ID"] > 0) {
                 $arResult["RATING_TYPE_ID"] = "BLOG_COMMENT";
                 $arResult["RATING_ENTITY_ID"] = $IdeaCommentId;
             }
             if (intval($IdeaCommentId) == 0) {
                 global $APPLICATION;
                 if ($ex = $APPLICATION->GetException()) {
                     $arResult["ERROR"] = $ex->GetString();
                 }
             } else {
                 //clear cache on succcess
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/first_page/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/pages/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/comment/" . $arIdeaPost["ID"] . "/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/post/" . $arIdeaPost["ID"] . "/");
             }
         }
     }
     return $arResult;
 }
示例#3
0
 public static function AddBlogPost($arFields)
 {
     if (!is_array($_POST)) {
         $_POST = array();
     }
     $_POST = array_merge($_POST, array("apply" => "Y", "decode" => "N"), $arFields);
     $strPathToPost = COption::GetOptionString("socialnetwork", "userblogpost_page", false, SITE_ID);
     $strPathToSmile = COption::GetOptionString("socialnetwork", "smile_page", false, SITE_ID);
     $BlogGroupID = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, SITE_ID);
     $arBlogComponentParams = array("IS_REST" => "Y", "ID" => "new", "PATH_TO_POST" => $strPathToPost, "PATH_TO_SMILE" => $strPathToSmile, "GROUP_ID" => $BlogGroupID, "USER_ID" => $GLOBALS["USER"]->GetID(), "USE_SOCNET" => "Y", "MICROBLOG" => "Y");
     ob_start();
     $result = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:socialnetwork.blog.post.edit", "", $arBlogComponentParams, false, array("HIDE_ICONS" => "Y"));
     ob_end_clean();
     if (!$result) {
         throw new Exception('Error');
     } else {
         if (isset($arFields["FILES"]) && \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk') && ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($GLOBALS["USER"]->GetID())) && ($folder = $storage->getFolderForUploadedFiles($GLOBALS["USER"]->GetID()))) {
             // upload to storage
             $arResultFile = array();
             foreach ($arFields["FILES"] as $tmp) {
                 $arFile = CRestUtil::saveFile($tmp);
                 if (is_array($arFile)) {
                     $file = $folder->uploadFile($arFile, array('NAME' => $arFile["name"], 'CREATED_BY' => $GLOBALS["USER"]->GetID()), array(), true);
                     if ($file) {
                         $arResultFile[] = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $file->getId();
                     }
                 }
             }
             if (!empty($arResultFile)) {
                 CBlogPost::Update($result, array("HAS_PROPS" => "Y", "UF_BLOG_POST_FILE" => $arResultFile));
             }
         }
         return $result;
     }
 }
示例#4
0
文件: sonet.php 项目: rasuldev/torino
 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;
 }
示例#5
0
 /**
  * Returns true if current user has read access to the blog post.
  * @param array $params Allowed keys: postId, userId.
  * @param int $userId Current user's id.
  * @return bool
  */
 public static function checkUserReadAccess(array $params, $userId)
 {
     if (!Loader::includeModule('blog')) {
         return false;
     }
     $permissions = \CBlogPost::GetSocNetPostPerms($params['postId'], true, $userId);
     return $permissions >= BLOG_PERMS_READ;
 }
示例#6
0
	function Add($arFields)
	{
		global $DB;

		$arFields1 = array();
		foreach ($arFields as $key => $value)
		{
			if (substr($key, 0, 1) == "=")
			{
				$arFields1[substr($key, 1)] = $value;
				unset($arFields[$key]);
			}
		}

		if (!CBlogTrackback::CheckFields("ADD", $arFields))
			return false;

		$arInsert = $DB->PrepareInsert("b_blog_trackback", $arFields);

		foreach ($arFields1 as $key => $value)
		{
			if (strlen($arInsert[0]) > 0)
				$arInsert[0] .= ", ";
			$arInsert[0] .= $key;
			if (strlen($arInsert[1]) > 0)
				$arInsert[1] .= ", ";
			$arInsert[1] .= $value;
		}

		$ID = False;
		if (strlen($arInsert[0]) > 0)
		{
			$strSql =
				"INSERT INTO b_blog_trackback(".$arInsert[0].") ".
				"VALUES(".$arInsert[1].")";
			$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);

			$ID = IntVal($DB->LastID());
		}

		if ($ID)
		{
			$arTrackback = CBlogTrackback::GetByID($ID);
			CBlogPost::Update($arTrackback["POST_ID"], array("=NUM_TRACKBACKS" => "NUM_TRACKBACKS + 1"));
		}

		return $ID;
	}
 function __AutoSetPerms($ID)
 {
     $ID = IntVal($ID);
     $arGroupPerms = CBlogUserGroupPerms::GetByID($ID);
     if (IntVal($arGroupPerms["POST_ID"]) == 0) {
         $dbBlogPosts = CBlogPost::GetList(array(), array("BLOG_ID" => $arGroupPerms["BLOG_ID"]), false, false, array("ID"));
         while ($arBlogPosts = $dbBlogPosts->Fetch()) {
             $dbGroupPerms1 = CBlogUserGroupPerms::GetList(array(), array("BLOG_ID" => $arGroupPerms["BLOG_ID"], "USER_GROUP_ID" => $arGroupPerms["USER_GROUP_ID"], "PERMS_TYPE" => $arGroupPerms["PERMS_TYPE"], "POST_ID" => $arBlogPosts["ID"]), false, false, array("ID", "AUTOSET", "PERMS"));
             if ($arGroupPerms1 = $dbGroupPerms1->Fetch()) {
                 if ($arGroupPerms1["AUTOSET"] == "Y" && $arGroupPerms["PERMS"] != $arGroupPerms1["PERMS"]) {
                     CBlogUserGroupPerms::Update($arGroupPerms1["ID"], array("PERMS" => $arGroupPerms["PERMS"]));
                 }
             } else {
                 CBlogUserGroupPerms::Add(array("BLOG_ID" => $arGroupPerms["BLOG_ID"], "USER_GROUP_ID" => $arGroupPerms["USER_GROUP_ID"], "PERMS_TYPE" => $arGroupPerms["PERMS_TYPE"], "POST_ID" => $arBlogPosts["ID"], "PERMS" => $arGroupPerms["PERMS"], "AUTOSET" => "Y"));
             }
         }
     }
 }
示例#8
0
 protected function prepareData()
 {
     if (strlen(trim($this->arParams["NAME_TEMPLATE"])) <= 0) {
         $this->arParams["NAME_TEMPLATE"] = \CSite::GetNameFormat();
     }
     $dbPost = \CBlogPost::GetList(array(), array("ID" => $this->arParams["postId"]), false, false, array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR", "ENABLE_COMMENTS", "NUM_COMMENTS", "VIEWS", "CODE", "MICRO", "DETAIL_TEXT", "DATE_PUBLISH", "CATEGORY_ID", "HAS_SOCNET_ALL", "HAS_TAGS", "HAS_IMAGES", "HAS_PROPS", "HAS_COMMENT_IMAGES"));
     if ($arPost = $dbPost->Fetch()) {
         if (strlen($arPost['TITLE']) > 30) {
             $arPost['TITLE'] = substr($arPost['TITLE'], 0, 30) . "...";
         }
         $this->arResult['POST'] = $arPost;
         $this->arResult['POST']['PUBLISH_STATUS_DESCRIPTION'] = Loc::getMessage('BLOG_POST_PUBLISH_STATUS_' . $arPost['PUBLISH_STATUS']);
         $this->arResult['POST']['AUTHOR_FORMATTED_NAME'] = \CUser::FormatName($this->arParams['NAME_TEMPLATE'], array('LOGIN' => $this->arResult['POST']['LOGIN'], 'NAME' => $this->arResult['POST']['NAME'], 'LAST_NAME' => $this->arResult['POST']['LAST_NAME']), true, false);
         $this->arResult["POST"]['AUTHOR_PROFILE'] = \CComponentEngine::MakePathFromTemplate($this->arParams["PATH_TO_USER_PROFILE"], array("user_id" => $this->arResult['POST']['AUTHOR']));
         $this->arResult["POST"]['AUTHOR_UNIQID'] = 'u_' . $this->randString();
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $GLOBALS['CACHE_MANAGER']->RegisterTag('blog_post_' . $this->arParams['postId']);
         }
     }
 }
示例#9
0
 function Add($arFields)
 {
     global $DB;
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CBlogTrackback::CheckFields("ADD", $arFields)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_blog_trackback", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($arInsert[0]) > 0) {
             $arInsert[0] .= ", ";
         }
         $arInsert[0] .= $key;
         if (strlen($arInsert[1]) > 0) {
             $arInsert[1] .= ", ";
         }
         $arInsert[1] .= $value;
     }
     $ID = False;
     if (strlen($arInsert[0]) > 0) {
         $ID = IntVal($DB->NextID("SQ_B_BLOG_TRACKBACK"));
         $strSql = "INSERT INTO b_blog_trackback(ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
         $arBinds = array();
         if (is_set($arFields, "PREVIEW_TEXT")) {
             $arBinds["PREVIEW_TEXT"] = $arFields["PREVIEW_TEXT"];
         }
         $DB->QueryBind($strSql, $arBinds);
     }
     if ($ID) {
         $arTrackback = CBlogTrackback::GetByID($ID);
         CBlogPost::Update($arTrackback["POST_ID"], array("=NUM_TRACKBACKS" => "NUM_TRACKBACKS + 1"));
     }
     return $ID;
 }
 public function Execute()
 {
     global $DB;
     if (!CModule::IncludeModule("socialnetwork") || !CModule::IncludeModule("blog")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $siteId = $this->PostSite ? $this->PostSite : SITE_ID;
     $ownerId = CBPHelper::ExtractUsers($this->OwnerId, $documentId, true);
     $pathToPost = COption::GetOptionString("socialnetwork", "userblogpost_page", false, $siteId);
     $pathToSmile = COption::GetOptionString("socialnetwork", "smile_page", false, $siteId);
     $blogGroupID = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, $siteId);
     $blog = CBlog::GetByOwnerID($ownerId);
     if (!$blog) {
         $blog = $this->createBlog($ownerId, $blogGroupID, $siteId);
     }
     $micro = 'N';
     $title = trim($this->PostTitle);
     if (!$title) {
         $micro = 'Y';
         $title = trim(preg_replace(array("/\n+/is" . BX_UTF_PCRE_MODIFIER, '/\\s+/is' . BX_UTF_PCRE_MODIFIER), " ", blogTextParser::killAllTags($this->PostMessage)));
     }
     try {
         $postFields = array('TITLE' => $title, 'DETAIL_TEXT' => $this->PostMessage, 'DETAIL_TEXT_TYPE' => $this->PostMessageType == 'html' ? 'html' : 'text', '=DATE_PUBLISH' => $DB->CurrentTimeFunction(), 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH, 'CATEGORY_ID' => '', 'PATH' => CComponentEngine::MakePathFromTemplate($pathToPost, array("post_id" => "#post_id#", "user_id" => $ownerId)), 'URL' => $blog['URL'], 'PERMS_POST' => array(), 'PERMS_COMMENT' => array(), 'MICRO' => $micro, 'SOCNET_RIGHTS' => $this->getSocnetRights($this->UsersTo), '=DATE_CREATE' => $DB->CurrentTimeFunction(), 'AUTHOR_ID' => $ownerId, 'BLOG_ID' => $blog['ID'], "HAS_IMAGES" => "N", "HAS_TAGS" => "N", "HAS_PROPS" => "N", "HAS_SOCNET_ALL" => "N");
         if (!empty($postFields["SOCNET_RIGHTS"]) && count($postFields["SOCNET_RIGHTS"]) == 1 && in_array("UA", $postFields["SOCNET_RIGHTS"])) {
             $postFields['HAS_SOCNET_ALL'] = 'Y';
         }
         $newId = CBlogPost::add($postFields);
         $postFields["ID"] = $newId;
         $arParamsNotify = array("bSoNet" => true, "UserID" => $ownerId, "allowVideo" => COption::GetOptionString("blog", "allow_video", "Y"), "PATH_TO_SMILE" => $pathToSmile, "PATH_TO_POST" => $pathToPost, "SOCNET_GROUP_ID" => $blogGroupID, "user_id" => $ownerId, "NAME_TEMPLATE" => CSite::GetNameFormat(false));
         CBlogPost::Notify($postFields, $blog, $arParamsNotify);
         BXClearCache(true, "/" . $siteId . "/blog/last_messages_list/");
         $arFieldsIM = array("TYPE" => "POST", "TITLE" => $postFields["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate($pathToPost, array("post_id" => $newId, "user_id" => $ownerId)), "ID" => $newId, "FROM_USER_ID" => $ownerId, "TO_USER_ID" => array(), "TO_SOCNET_RIGHTS" => $postFields["SOCNET_RIGHTS"], "TO_SOCNET_RIGHTS_OLD" => array());
         CBlogPost::NotifyIm($arFieldsIM);
     } catch (Exception $e) {
         $this->WriteToTrackingService($e->getMessage());
     }
     return CBPActivityExecutionStatus::Closed;
 }
 public function UnBind()
 {
     if (!$this->IsAvailable()) {
         return false;
     }
     //Comment doesn't exists
     $arComment = $this->Get();
     if (!$arComment) {
         return false;
     }
     $arIdea = CBlogPost::GetList(array(), array("ID" => $arComment["POST_ID"]), false, false, array("ID", CIdeaManagment::UFAnswerIdField))->Fetch();
     if ($arIdea) {
         if (!is_array($arIdea[CIdeaManagment::UFAnswerIdField])) {
             $arIdea[CIdeaManagment::UFAnswerIdField] = array();
         }
         $arIdea[CIdeaManagment::UFAnswerIdField] = array_unique($arIdea[CIdeaManagment::UFAnswerIdField]);
         $key = array_search($arComment["ID"], $arIdea[CIdeaManagment::UFAnswerIdField]);
         if (is_numeric($key)) {
             unset($arIdea[CIdeaManagment::UFAnswerIdField][$key], $arIdea["ID"]);
             return CBlogPost::Update($arComment["POST_ID"], $arIdea) > 0;
         }
     }
     return false;
 }
示例#12
0
}
if (!CModule::IncludeModule("blog")) {
    ShowError(GetMessage("BLOG_MODULE_NOT_INSTALL"));
    return;
}
if (!CModule::IncludeModule('idea')) {
    ShowError(GetMessage("IDEA_MODULE_NOT_INSTALL"));
    return;
}
if (strlen($arParams["BLOG_URL"]) == 0) {
    return;
}
$arResult = array();
$obCache = new CPHPCache();
$life_time = 60 * 60 * 24;
//1 day
$cache_id = 'idea_statistic_list_' . $arParams["BLOG_URL"];
$cache_path = '/' . SITE_ID . '/idea/statistic_list/';
if ($obCache->StartDataCache($life_time, $cache_id, $cache_path)) {
    $arResult = CIdeaManagment::getInstance()->Idea()->GetStatusList();
    if ($arCurBlog = CBlog::GetByUrl($arParams["BLOG_URL"])) {
        $dbPosts = CBlogPost::GetList(array(), array("BLOG_ID" => $arCurBlog["ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH), false, false, array("ID", "UF_STATUS"));
        while ($arPost = $dbPosts->Fetch()) {
            $arResult[intval($arPost["UF_STATUS"])]["CNT"]++;
        }
    }
    $obCache->EndDataCache($arResult);
} else {
    $arResult = $obCache->GetVars();
}
$this->IncludeComponentTemplate();
示例#13
0
 function SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm)
 {
     if (substr($operation, 0, 4) == "view") {
         if (CModule::IncludeModule('search')) {
             global $arSonetFeaturesPermsCache;
             unset($arSonetFeaturesPermsCache[$entity_type . "_" . $entity_id]);
             $arGroups = CSocNetSearch::GetSearchGroups($entity_type, $entity_id, $feature, $operation);
             $arParams = CSocNetSearch::GetSearchParams($entity_type, $entity_id, $feature, $operation);
             CSearch::ChangePermission(false, $arGroups, false, false, false, false, $arParams);
         }
     }
     if ($feature == "blog" && in_array($operation, array("view_post", "view_comment")) && CModule::IncludeModule('blog')) {
         if ($operation == "view_post") {
             CBlogPost::ChangeSocNetPermission($entity_type, $entity_id, $operation);
         }
         if ($operation == "view_post") {
             $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
             foreach ($arPost as $id => $perms) {
                 CSearch::ChangePermission("blog", $perms["PERMS"], "P" . $id);
             }
         } else {
             $arTmpCache = array();
             $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
             $dbComment = CBlogComment::GetSocNetPostsPerms($entity_type, $entity_id);
             while ($arComment = $dbComment->Fetch()) {
                 if (!empty($arPost[$arComment["POST_ID"]])) {
                     if (empty($arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
                         $arPost[$arComment["POST_ID"]]["PERMS_CALC"] = array();
                         if (is_array($arPost[$arComment["POST_ID"]]["PERMS_FULL"]) && !empty($arPost[$arComment["POST_ID"]]["PERMS_FULL"])) {
                             foreach ($arPost[$arComment["POST_ID"]]["PERMS_FULL"] as $e => $v) {
                                 if (in_array($v["TYPE"], array("SG", "U"))) {
                                     $type = $v["TYPE"] == "SG" ? "G" : "U";
                                     if (array_key_exists($type . $v["ID"], $arTmpCache)) {
                                         $spt = $arTmpCache[$type . $v["ID"]];
                                     } else {
                                         $spt = CBlogPost::GetSocnetGroups($type, $v["ID"], "view_comment");
                                         $arTmpCache[$type . $v["ID"]] = $spt;
                                     }
                                     foreach ($spt as $vv) {
                                         if (!in_array($vv, $arPost[$arComment["POST_ID"]]["PERMS_CALC"])) {
                                             $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $vv;
                                         }
                                     }
                                 } else {
                                     $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $e;
                                 }
                             }
                         }
                     }
                     CSearch::ChangePermission("blog", $arPost[$arComment["POST_ID"]]["PERMS_CALC"], "C" . $arComment["ID"]);
                 }
             }
         }
     }
 }
示例#14
0
     }
     $arFieldsHave = array();
     if ($arPost["HAS_IMAGES"] == "") {
         $arFieldsHave["HAS_IMAGES"] = $bHasImg ? "Y" : "N";
     }
     if ($arPost["HAS_TAGS"] == "") {
         $arFieldsHave["HAS_TAGS"] = $bHasTag ? "Y" : "N";
     }
     if ($arPost["HAS_PROPS"] == "") {
         $arFieldsHave["HAS_PROPS"] = $bHasProps ? "Y" : "N";
     }
     if ($arPost["HAS_SOCNET_ALL"] == "") {
         $arFieldsHave["HAS_SOCNET_ALL"] = $bHasOnlyAll ? "Y" : "N";
     }
     if (!empty($arFieldsHave)) {
         CBlogPost::Update($arPost["ID"], $arFieldsHave);
     }
     if ($bAll || $arPost["HAS_SOCNET_ALL"] == "Y") {
         $arResult["Post"]["HAVE_ALL_IN_ADR"] = "Y";
     }
     if ($arParams["CACHE_TIME"] > 0) {
         $arCacheData = array("templateCachedData" => $this->GetTemplateCachedData(), "Post" => $arResult["Post"], "images" => $arResult["images"], "Category" => $arResult["Category"], "GRATITUDE" => $arResult["GRATITUDE"], "POST_PROPERTIES" => $arResult["POST_PROPERTIES"], "arUser" => $arResult["arUser"]);
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $GLOBALS["CACHE_MANAGER"]->EndTagCache();
         }
         $cache->EndDataCache($arCacheData);
     }
 }
 $arResult["arUser"]["urlToPostImportant"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_IMPORTANT"], array("user_id" => $arPost["AUTHOR_ID"]));
 $arResult["CanComment"] = $GLOBALS["USER"]->IsAuthorized();
 $arResult["dest_users"] = array();
示例#15
0
        $arParams["POST_ID"] = CBlogPost::GetID($arParams["POST_ID"], $arBlog["ID"]);
        $arPost = CBlogPost::GetByID($arParams["POST_ID"]);
    }
    if (!empty($arBlog) && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y" && !empty($arPost) && $arPost["ENABLE_COMMENTS"] == "Y" && $arPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
        $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
        if ($arGroup["SITE_ID"] == SITE_ID) {
            if ($arParams["RSS1"] == "Y") {
                $arResult[] = array("type" => "rss1", "name" => GetMessage("BRL_C") . "RSS .92", "url" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_RSS"], array("blog" => $arBlog["URL"], "type" => "rss1", "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]))));
            }
            if ($arParams["RSS2"] == "Y") {
                $arResult[] = array("type" => "rss2", "name" => GetMessage("BRL_C") . "RSS 2.0", "url" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_RSS"], array("blog" => $arBlog["URL"], "type" => "rss2", "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]))));
            }
            if ($arParams["ATOM"] == "Y") {
                $arResult[] = array("type" => "atom", "name" => GetMessage("BRL_C") . "Atom .3", "url" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_RSS"], array("blog" => $arBlog["URL"], "type" => "atom", "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]))));
            }
            $APPLICATION->AddHeadString('<link rel="alternate" type="application/rss+xml" title="RSS" href="' . CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_RSS"], array("blog" => $arBlog["URL"], "type" => "rss2", "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]))) . '" />');
        }
    }
} else {
    if ($bSoNet) {
        $blogOwnerID = $arParams["USER_ID"];
        $arFilterblg = array("ACTIVE" => "Y", "GROUP_ID" => $arParams["PARAM_GROUP_ID"], "GROUP_SITE_ID" => SITE_ID, "USE_SOCNET" => "Y");
        if ($bGroupMode) {
            $arFilterblg["SOCNET_GROUP_ID"] = $arParams["SOCNET_GROUP_ID"];
        } else {
            $arFilterblg["OWNER_ID"] = $arParams["USER_ID"];
        }
        $dbBl = CBlog::GetList(array(), $arFilterblg);
        $arBlog = $dbBl->Fetch();
    } else {
        $arBlog = CBlog::GetByUrl($arParams["BLOG_URL"], $arParams["PARAM_GROUP_ID"]);
示例#16
0
	public static function GetSocNetUserPerms($postId = 0, $authorId = 0)
	{
		global $APPLICATION, $USER, $AR_BLOG_PERMS, $BLOG_POST;

		$userId = IntVal($USER->GetID());
		$postId = IntVal($postId);
		$authorId = IntVal($authorId);
		if($postId <= 0)
			return false;

		$perms = BLOG_PERMS_DENY;

		$blogModulePermissions = $APPLICATION->GetGroupRight("blog");
		if($authorId > 0 && $userId == $authorId)
			$perms = BLOG_PERMS_FULL;
		elseif ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin())
		{
			end($AR_BLOG_PERMS);
			$perms = key($AR_BLOG_PERMS);
			reset($AR_BLOG_PERMS);
		}

		if($perms <= BLOG_PERMS_DENY)
		{
			$arPerms = CBlogPost::GetSocNetPerms($postId);
			$arEntities = Array();
			if (isset($BLOG_POST["UAC_CACHE_".$userId]) && !empty($BLOG_POST["UAC_CACHE_".$userId]))
			{
				$arEntities = $BLOG_POST["UAC_CACHE_".$userId];
			}
			else
			{
				$dbA = CAccess::GetUserCodes($userId);
				while($arA = $dbA->Fetch())
				{
					if($arA["PROVIDER_ID"] == "intranet")
					{
						$arEntities["DR"][$arA["ACCESS_CODE"]] = $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] = $gR;
					}
				}
				$BLOG_POST["UAC_CACHE_".$userId] = $arEntities;
			}

			if(!empty($arEntities["DR"]) && !empty($arPerms["DR"]))
			{
				foreach($arPerms["DR"] as $id => $val)
				{
					if(isset($arEntities["DR"]["DR".$id]))
					{
						$perms = BLOG_PERMS_READ;
						break;
					}
				}
			}
			if((!empty($arPerms["U"][$userId]) && in_array("US".$userId, $arPerms["U"][$userId])) || ($authorId >0 && $userId == $authorId)) // if author
				$perms = BLOG_PERMS_FULL;
			else
			{
				if($authorId <= 0)
				{
					foreach($arPerms["U"] as $id => $p)
					{
						if(in_array("US".$id, $p))
						{
							$authorId = $id;
							break;
						}
					}
				}

				if(!empty($arPerms["U"][$userId]) || (!empty($arPerms["U"][$authorId]) && in_array("US".$authorId, $arPerms["U"][$authorId])) || $perms == BLOG_PERMS_READ)
				{
					if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment"))
						$perms = BLOG_PERMS_WRITE;
					elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment"))
						$perms = BLOG_PERMS_PREMODERATE;
					elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment"))
						$perms = BLOG_PERMS_READ;
				}
			}

			if($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_comment", "moderate_comment", "write_comment", "premoderate_comment");
					if($perms < BLOG_PERMS_READ)
						$operation[] = "view_comment";
				}

				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((!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid])) || $val == SONET_ROLES_ALL || ($userId > 0 && $val == SONET_ROLES_AUTHORIZED))
									{
										switch($v)
										{
											case "full_comment":
												$perms = BLOG_PERMS_FULL;
												break;
											case "moderate_comment":
												$perms = BLOG_PERMS_MODERATE;
												break;
											case "write_comment":
												$perms = BLOG_PERMS_WRITE;
												break;
											case "premoderate_comment":
												$perms = BLOG_PERMS_PREMODERATE;
												break;
											case "view_comment":
												$perms = BLOG_PERMS_READ;
												break;
										}
									}
								}
							}
						}
					}
				}
			}
		}

		return $perms;
	}
示例#17
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;
	}
示例#18
0
 public function SetStatus($StatusId)
 {
     if (!$this->IsAvailable()) {
         return false;
     }
     $arStatusList = $this->GetStatusList();
     $arStatusListXML = $this->GetStatusList(true);
     $arPost = CBlogPost::GetList(array(), array("ID" => $this->IdeaId), false, false, array("ID", CIdeaManagment::UFStatusField))->Fetch();
     $bUpdate = false;
     //Get Status ID from XML List
     if (array_key_exists($StatusId, $arStatusListXML)) {
         $StatusId = $arStatusListXML[$StatusId]["ID"];
     }
     //Status Exists and not current
     if (array_key_exists($StatusId, $arStatusList)) {
         $bUpdate = $arPost[CIdeaManagment::UFStatusField] != $StatusId;
     }
     if ($arPost && $bUpdate) {
         return CBlogPost::Update($this->IdeaId, array(CIdeaManagment::UFStatusField => $StatusId));
     }
     return false;
 }
示例#19
0
             } else {
                 $url .= "&";
             }
             $url .= "del_id=" . $arParams["ID"] . "&success=Y";
             LocalRedirect($url);
         } else {
             $arResult["ERROR_MESSAGE"] .= GetMessage("BLOG_BLOG_BLOG_MES_DEL_ERROR") . '<br />';
         }
     } else {
         $arResult["ERROR_MESSAGE"] .= GetMessage("BLOG_BLOG_BLOG_MES_DEL_NO_RIGHTS") . '<br />';
     }
 }
 if ($_GET["hide"] == "Y") {
     if (check_bitrix_sessid()) {
         if ($arResult["PostPerm"] >= BLOG_PERMS_MODERATE) {
             if (CBlogPost::Update($arParams["ID"], array("PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_READY))) {
                 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/" . $arParams["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/" . $arParams["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/");
                 BXClearCache(True, "/" . SITE_ID . "/blog/last_messages_list_extranet/");
示例#20
0
 public static function PostIntoBuzzAsBlog($userTwit, $arSiteId = array(), $userLogin = '')
 {
     global $DB;
     if (!CModule::IncludeModule("blog")) {
         return;
     }
     $arParams = array();
     if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME') && $userLogin != '') {
         if ($arUserTwit = unserialize(base64_decode($userTwit))) {
             $userTwit = $arUserTwit;
         }
         if ($arSiteIdCheck = unserialize(base64_decode($arSiteId))) {
             $arSiteId = $arSiteIdCheck;
         }
         $dbUser = CUser::GetByLogin($userLogin);
         if ($arUser = $dbUser->Fetch()) {
             $arParams["USER_ID"] = $arUser["ID"];
         }
     } else {
         $arParams["USER_ID"] = $userTwit['kp_user_id'];
     }
     if (isset($arSiteId[$userTwit['kp_user_id']])) {
         $siteId = $arSiteId[$userTwit['kp_user_id']];
     }
     if (strlen($siteId) <= 0) {
         $siteId = SITE_ID;
     }
     if (isset($userTwit['text'])) {
         $arParams["GROUP_ID"] = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, $siteId);
         $arParams["PATH_TO_BLOG"] = COption::GetOptionString("socialnetwork", "userblogpost_page", false, $siteId);
         $arParams["PATH_TO_SMILE"] = COption::GetOptionString("socialnetwork", "smile_page", false, $siteId);
         $arParams["NAME_TEMPLATE"] = COption::GetOptionString("main", "TOOLTIP_NAME_TEMPLATE", false, $siteId);
         $arParams["SHOW_LOGIN"] = '******';
         $arParams["PATH_TO_POST"] = $arParams["PATH_TO_BLOG"];
         $arFilterblg = array("ACTIVE" => "Y", "USE_SOCNET" => "Y", "GROUP_ID" => $arParams["GROUP_ID"], "GROUP_SITE_ID" => $siteId, "OWNER_ID" => $arParams["USER_ID"]);
         $groupId = is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]);
         if (isset($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]]) && !empty($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]])) {
             $arBlog = $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]];
         } else {
             $dbBl = CBlog::GetList(array(), $arFilterblg);
             $arBlog = $dbBl->Fetch();
             if (!$arBlog && IsModuleInstalled("intranet")) {
                 $arBlog = CBlog::GetByOwnerID($arParams["USER_ID"]);
             }
             $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]] = $arBlog;
         }
         $arResult["Blog"] = $arBlog;
         if (empty($arBlog)) {
             if (!empty($arParams["GROUP_ID"])) {
                 $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]), "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                 $bRights = false;
                 $rsUser = CUser::GetByID($arParams["USER_ID"]);
                 $arUser = $rsUser->Fetch();
                 if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                 } else {
                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                 }
                 $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . SITE_ID;
                 $arFields["OWNER_ID"] = $arParams["USER_ID"];
                 $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                 if ($urlCheck != $arFields["URL"]) {
                     $arFields["URL"] = "u" . $arParams["USER_ID"] . "-blog-" . SITE_ID;
                 }
                 if (CBlog::GetByUrl($arFields["URL"])) {
                     $uind = 0;
                     do {
                         $uind++;
                         $arFields["URL"] = $arFields["URL"] . $uind;
                     } while (CBlog::GetByUrl($arFields["URL"]));
                 }
                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arFields["OWNER_ID"], "blog", "view_post");
                 if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                     $bRights = true;
                 }
                 $arFields["PATH"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arFields["URL"], "user_id" => $arFields["OWNER_ID"], "group_id" => $arFields["SOCNET_GROUP_ID"]));
                 $blogID = CBlog::Add($arFields);
                 if ($bRights) {
                     CBlog::AddSocnetRead($blogID);
                 }
                 $arBlog = CBlog::GetByID($blogID, $arParams["GROUP_ID"]);
             }
         }
         //	$DATE_PUBLISH = "";
         //	if(strlen($_POST["DATE_PUBLISH_DEF"]) > 0)
         //		$DATE_PUBLISH = $_POST["DATE_PUBLISH_DEF"];
         //	elseif (strlen($_POST["DATE_PUBLISH"])<=0)
         $DATE_PUBLISH = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
         //	else
         //		$DATE_PUBLISH = $_POST["DATE_PUBLISH"];
         $arFields = array("DETAIL_TEXT" => $userTwit['text'], "DETAIL_TEXT_TYPE" => "text", "DATE_PUBLISH" => $DATE_PUBLISH, "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "PATH" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#post_id#", "user_id" => $arBlog["OWNER_ID"])), "URL" => $arBlog["URL"], "SOURCE_TYPE" => "twitter");
         $arFields["PERMS_POST"] = array();
         $arFields["PERMS_COMMENT"] = array();
         $arFields["MICRO"] = "N";
         if (strlen($arFields["TITLE"]) <= 0) {
             $arFields["MICRO"] = "Y";
             $arFields["TITLE"] = trim(blogTextParser::killAllTags($arFields["DETAIL_TEXT"]));
             if (strlen($arFields["TITLE"]) <= 0) {
                 $arFields["TITLE"] = GetMessage("BLOG_EMPTY_TITLE_PLACEHOLDER");
             }
         }
         $arFields["SOCNET_RIGHTS"] = array();
         if (!empty($userTwit['user_perms'])) {
             $bOne = true;
             foreach ($userTwit['user_perms'] as $v => $k) {
                 if (strlen($v) > 0 && is_array($k) && !empty($k)) {
                     foreach ($k as $vv) {
                         if (strlen($vv) > 0) {
                             $arFields["SOCNET_RIGHTS"][] = $vv;
                             if ($v != "SG") {
                                 $bOne = false;
                             }
                         }
                     }
                 }
             }
             if ($bOne && !empty($userTwit['user_perms']["SG"])) {
                 $bOnesg = false;
                 $bFirst = true;
                 $oGrId = 0;
                 foreach ($userTwit['user_perms']["SG"] as $v) {
                     if (strlen($v) > 0) {
                         if ($bFirst) {
                             $bOnesg = true;
                             $bFirst = false;
                             $v = str_replace("SG", "", $v);
                             $oGrId = IntVal($v);
                         } else {
                             $bOnesg = false;
                         }
                     }
                 }
                 if ($bOnesg) {
                     if (!CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "write_post") && !CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "moderate_post") && !CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "full_post")) {
                         $arFields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
                     }
                 }
             }
         }
         $bError = false;
         /*	if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
         			{
         				if(empty($arFields["SOCNET_RIGHTS"]) || in_array("UA", $arFields["SOCNET_RIGHTS"]))
         				{
         					$bError = true;
         					$arResult["ERROR_MESSAGE"] = GetMessage("BLOG_BPE_EXTRANET_ERROR");
         				}
         			}*/
         if (!$bError) {
             preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/ies" . BX_UTF_PCRE_MODIFIER, $userTwit['text'], $arMention);
             $arFields["=DATE_CREATE"] = $DB->GetNowFunction();
             $arFields["AUTHOR_ID"] = $arParams["USER_ID"];
             $arFields["BLOG_ID"] = $arBlog["ID"];
             $newID = CBlogPost::Add($arFields);
             $socnetRightsOld = array("U" => array());
             $bAdd = true;
             $bNeedMail = false;
             if ($newID) {
                 $arFields["ID"] = $newID;
                 $arParamsNotify = array("bSoNet" => true, "UserID" => $arParams["USER_ID"], "allowVideo" => $arResult["allowVideo"], "PATH_TO_SMILE" => $arParams["PATH_TO_SMILE"], "PATH_TO_POST" => $arParams["PATH_TO_POST"], "SOCNET_GROUP_ID" => $arParams["GROUP_ID"], "user_id" => $arParams["USER_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"]);
                 CBlogPost::Notify($arFields, $arBlog, $arParamsNotify);
             }
         }
         if ($newID > 0 && strlen($arResult["ERROR_MESSAGE"]) <= 0 && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
             BXClearCache(true, "/" . SITE_ID . "/blog/last_messages_list/");
             $arFieldsIM = array("TYPE" => "POST", "TITLE" => $arFields["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $newID, "user_id" => $arBlog["OWNER_ID"])), "ID" => $newID, "FROM_USER_ID" => $arParams["USER_ID"], "TO_USER_ID" => array(), "TO_SOCNET_RIGHTS" => $arFields["SOCNET_RIGHTS"], "TO_SOCNET_RIGHTS_OLD" => $socnetRightsOld["U"]);
             if (!empty($arMentionOld)) {
                 $arFieldsIM["MENTION_ID_OLD"] = $arMentionOld[1];
             }
             if (!empty($arMention)) {
                 $arFieldsIM["MENTION_ID"] = $arMention[1];
             }
             CBlogPost::NotifyIm($arFieldsIM);
             $arParams["ID"] = $newID;
             if (!empty($_POST["SPERM"]["SG"])) {
                 foreach ($_POST["SPERM"]["SG"] as $v) {
                     $group_id_tmp = substr($v, 2);
                     if (IntVal($group_id_tmp) > 0) {
                         CSocNetGroup::SetLastActivity(IntVal($group_id_tmp));
                     }
                 }
             }
         }
     }
 }
示例#21
0
 function NotifyIm($arParams)
 {
     if (!CModule::IncludeModule("im")) {
         return;
     }
     $arUsers = array();
     if (!empty($arParams["TO_USER_ID"])) {
         foreach ($arParams["TO_USER_ID"] as $val) {
             $val = IntVal($val);
             if ($val > 0 && $val != $arParams["FROM_USER_ID"]) {
                 $arUsers[] = $val;
             }
         }
     }
     if (!empty($arParams["TO_SOCNET_RIGHTS"])) {
         foreach ($arParams["TO_SOCNET_RIGHTS"] as $v) {
             if (substr($v, 0, 1) == "U") {
                 $u = IntVal(substr($v, 1));
                 if ($u > 0 && !in_array($u, $arUsers) && empty($arParams["TO_SOCNET_RIGHTS_OLD"][$u]) && $u != $arParams["FROM_USER_ID"]) {
                     $arUsers[] = $u;
                 }
             }
         }
     }
     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "blog");
     if (CModule::IncludeModule("socialnetwork")) {
         $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("blog_post", "blog_post_micro"), "SOURCE_ID" => $arParams["ID"]), false, false, array("ID"));
         if ($arLog = $rsLog->Fetch()) {
             $arMessageFields["LOG_ID"] = $arLog["ID"];
         }
     }
     $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]);
     $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
     $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
     $dbSite = CSite::GetByID(SITE_ID);
     $arSite = $dbSite->Fetch();
     $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
     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", "");
         }
     }
     $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $serverName;
     if ($arParams["TYPE"] == "POST") {
         $arMessageFields["NOTIFY_EVENT"] = "post";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|POST|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
     } elseif ($arParams["TYPE"] == "COMMENT") {
         $arMessageFields["NOTIFY_EVENT"] = "comment";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
     }
     foreach ($arUsers as $v) {
         if (!empty($arParams["EXCLUDE_USERS"]) && IntVal($arParams["EXCLUDE_USERS"][$v]) > 0) {
             continue;
         }
         $arMessageFieldsTmp = $arMessageFields;
         if ($arParams["TYPE"] == "COMMENT") {
             if ($arParams["AUTHOR_ID"] == $v) {
                 $arMessageFieldsTmp["NOTIFY_MESSAGE"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR"];
                 $arMessageFieldsTmp["NOTIFY_MESSAGE_OUT"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"];
             }
         }
         $arMessageFieldsTmp["TO_USER_ID"] = $v;
         $ID = CIMNotify::Add($arMessageFieldsTmp);
     }
     if (!empty($arParams["MENTION_ID"])) {
         if (!is_array($arParams["MENTION_ID_OLD"])) {
             $arParams["MENTION_ID_OLD"] = array();
         }
         foreach ($arParams["MENTION_ID"] as $val) {
             $val = IntVal($val);
             if (IntVal($val) > 0 && !in_array($val, $arUsers) && !in_array($val, $arParams["MENTION_ID_OLD"]) && $val != $arParams["FROM_USER_ID"]) {
                 if (CBlogPost::GetSocNetPostPerms($arParams["ID"], false, $val) >= BLOG_PERMS_READ) {
                     $arMessageFields["TO_USER_ID"] = $val;
                     $arMessageFields["NOTIFY_EVENT"] = "mention";
                     if ($arParams["TYPE"] == "POST") {
                         $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"];
                         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $arParams["URL"] . ")";
                     } elseif ($arParams["TYPE"] == "COMMENT") {
                         $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"];
                         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $arParams["URL"] . ")";
                     }
                     $ID = CIMNotify::Add($arMessageFields);
                     if (intval($ID) > 0 && intval($arMessageFields["LOG_ID"]) > 0) {
                         $db_events = GetModuleEvents("blog", "OnBlogPostMentionNotifyIm");
                         while ($arEvent = $db_events->Fetch()) {
                             ExecuteModuleEventEx($arEvent, array($ID, $arMessageFields));
                         }
                     }
                 }
             }
         }
     }
 }
示例#22
0
    $cache->Output();
} else {
    if ($arParams["CACHE_TIME"] > 0) {
        $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
    }
    $arFilter = array("<=DATE_PUBLISH" => ConvertTimeStamp(time() + $tzOffset, "FULL", false), ">=DATE_PUBLISH" => ConvertTimeStamp(AddToTimeStamp(array("DD" => "-" . $arParams["PERIOD_DAYS"])) + $tzOffset, "FULL", false), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "BLOG_ACTIVE" => "Y", "BLOG_GROUP_SITE_ID" => SITE_ID, ">PERMS" => BLOG_PERMS_DENY);
    if (!empty($arParams["GROUP_ID"])) {
        $arFilter["BLOG_GROUP_ID"] = $arParams["GROUP_ID"];
    }
    $arSelectedFields = array("ID", "BLOG_ID", "PERMS", "NUM_COMMENTS", "VIEWS");
    if (CModule::IncludeModule("socialnetwork") && $arParams["USE_SOCNET"] == "Y") {
        unset($arFilter[">PERMS"]);
        $arSelectedFields[] = "SOCNET_BLOG_READ";
        $arFilter["BLOG_USE_SOCNET"] = "Y";
    }
    $dbItem = CBlogPost::GetList(array("VIEWS" => "DESC", "NUM_COMMENTS" => "DESC"), $arFilter, false, false, $arSelectedFields);
    while ($arItem = $dbItem->Fetch()) {
        $arBlogs[$arItem["BLOG_ID"]]["VIEWS"] += $arItem["VIEWS"];
        $arBlogs[$arItem["BLOG_ID"]]["NUM_COMMENTS"] += $arItem["NUM_COMMENTS"];
    }
    if (!empty($arBlogs)) {
        uasort($arBlogs, create_function('$a, $b', 'if($a["VIEWS"] == $b["VIEWS"]) { if($a["NUM_COMMENTS"] < $b["NUM_COMMENTS"]) return 1; elseif($a["NUM_COMMENTS"] > $b["NUM_COMMENTS"]) return -1; else return 0;} return ($a["VIEWS"] < $b["VIEWS"])? 1 : -1;'));
        $i = 0;
        foreach ($arBlogs as $blogID => $info) {
            if ($i >= $arParams["BLOG_COUNT"] && IntVal($arParams["BLOG_COUNT"]) > 0) {
                continue;
            }
            $arBlog = CBlog::GetByID($blogID);
            $arBlog = CBlogTools::htmlspecialcharsExArray($arBlog);
            $arBlog["BlogUser"] = CBlogUser::GetByID($arBlog["OWNER_ID"], BLOG_BY_USER_ID);
            $arBlog["BlogUser"] = CBlogTools::htmlspecialcharsExArray($arBlog["BlogUser"]);
示例#23
0
     $arBlog = $arOwnBlog;
 }
 if (!empty($arBlog)) {
     if (IntVal($user_id) > 0) {
         $perm = CBlog::GetBlogUserPostPerms($arBlog["ID"], $user_id);
         if ($perm >= BLOG_PERMS_WRITE) {
             $arResult["urlToDraft"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_DRAFT"], array("blog" => $arBlog["URL"]));
             $arResult["urlToNewPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_EDIT"], array("blog" => $arBlog["URL"], "post_id" => "new"));
             if ($perm >= BLOG_PERMS_MODERATE) {
                 $arResult["urlToModeration"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_MODERATION"], array("blog" => $arBlog["URL"]));
                 $dbPost = CBlogPost::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_READY), array("COUNT" => "ID"), false, array("ID", "BLOG_ID"));
                 if ($arPost = $dbPost->Fetch()) {
                     $arResult["CntToModerate"] = $arPost["ID"];
                 }
             }
             $dbPost = CBlogPost::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_DRAFT, "AUTHOR_ID" => $user_id), array("COUNT" => "ID"), false, array("ID", "BLOG_ID"));
             if ($arPost = $dbPost->Fetch()) {
                 $arResult["CntToDraft"] = $arPost["ID"];
             }
             $arResult["SecondLine"] = "Y";
         } elseif ($perm >= BLOG_PERMS_PREMODERATE) {
             $arResult["urlToNewPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST_EDIT"], array("blog" => $arBlog["URL"], "post_id" => "new"));
             $arResult["SecondLine"] = "Y";
         }
         if (CBlog::CanUserManageBlog($arBlog["ID"], $user_id)) {
             $arResult["urlToUserSettings"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_SETTINGS"], array("blog" => $arBlog["URL"]));
             $arResult["urlToGroupEdit"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP_EDIT"], array("blog" => $arBlog["URL"]));
             $arResult["urlToCategoryEdit"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_CATEGORY_EDIT"], array("blog" => $arBlog["URL"]));
             $arResult["urlToBlogEdit"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG_EDIT"], array("blog" => $arBlog["URL"]));
             $arResult["ThirdLine"] = "Y";
         }
示例#24
0
 public static function NotifyIm($arParams)
 {
     if (!CModule::IncludeModule("im")) {
         return;
     }
     $arUsers = array();
     $arUserIDSent = array();
     if (!empty($arParams["TO_USER_ID"])) {
         foreach ($arParams["TO_USER_ID"] as $val) {
             $val = IntVal($val);
             if ($val > 0 && $val != $arParams["FROM_USER_ID"]) {
                 $arUsers[] = $val;
             }
         }
     }
     if (!empty($arParams["TO_SOCNET_RIGHTS"])) {
         foreach ($arParams["TO_SOCNET_RIGHTS"] as $v) {
             if (substr($v, 0, 1) == "U") {
                 $u = IntVal(substr($v, 1));
                 if ($u > 0 && !in_array($u, $arUsers) && (!array_key_exists("U", $arParams["TO_SOCNET_RIGHTS_OLD"]) || empty($arParams["TO_SOCNET_RIGHTS_OLD"]["U"][$u])) && $u != $arParams["FROM_USER_ID"]) {
                     $arUsers[] = $u;
                 }
             }
         }
     }
     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "blog");
     $aditGM = "";
     if (IntVal($arParams["FROM_USER_ID"]) > 0) {
         $dbUser = CUser::GetByID($arParams["FROM_USER_ID"]);
         if ($arUser = $dbUser->Fetch()) {
             if ($arUser["PERSONAL_GENDER"] == "F") {
                 $aditGM = "_FEMALE";
             }
         }
     }
     if (CModule::IncludeModule("socialnetwork")) {
         $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("blog_post", "blog_post_important", "blog_post_micro"), "SOURCE_ID" => $arParams["ID"]), false, false, array("ID"));
         if ($arLog = $rsLog->Fetch()) {
             $arMessageFields["LOG_ID"] = $arLog["ID"];
         }
     }
     $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]);
     $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
     $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
     $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
     if (IsModuleInstalled("extranet")) {
         $user_path = COption::GetOptionString("socialnetwork", "user_page", false, SITE_ID);
         if (strpos($arParams["URL"], $user_path) === 0) {
             $arParams["URL"] = str_replace($user_path, "#USER_PATH#", $arParams["URL"]);
         }
     }
     if ($arParams["TYPE"] == "POST") {
         $arMessageFields["NOTIFY_EVENT"] = "post";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|POST|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "";
     } elseif ($arParams["TYPE"] == "COMMENT") {
         $arMessageFields["NOTIFY_EVENT"] = "comment";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "\n\n" . $arParams["BODY"];
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "\n\n" . $arParams["BODY"];
     } elseif ($arParams["TYPE"] == "SHARE") {
         $arMessageFields["NOTIFY_EVENT"] = "share";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|SHARE|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "";
     } elseif ($arParams["TYPE"] == "SHARE2USERS") {
         $arMessageFields["NOTIFY_EVENT"] = "share2users";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|SHARE2USERS|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "";
     }
     foreach ($arUsers as $v) {
         if (!empty($arParams["EXCLUDE_USERS"]) && IntVal($arParams["EXCLUDE_USERS"][$v]) > 0) {
             continue;
         }
         if (IsModuleInstalled("extranet")) {
             $arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arParams["URL"]), $v);
             $url = $arTmp["URLS"]["URL"];
             if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) {
                 $serverName = "";
             } else {
                 $serverName = $arTmp["SERVER_NAME"];
             }
             if ($arParams["TYPE"] == "POST") {
                 $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $url . ")";
             } elseif ($arParams["TYPE"] == "COMMENT") {
                 $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "\n\n" . $arParams["BODY"];
                 $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "\n\n" . $arParams["BODY"];
             } elseif ($arParams["TYPE"] == "SHARE") {
                 $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_8" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "";
             } elseif ($arParams["TYPE"] == "SHARE2USERS") {
                 $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                 $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_9" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "";
             }
         }
         $arMessageFieldsTmp = $arMessageFields;
         if ($arParams["TYPE"] == "COMMENT") {
             if ($arParams["AUTHOR_ID"] == $v) {
                 $arMessageFieldsTmp["NOTIFY_MESSAGE"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR"];
                 $arMessageFieldsTmp["NOTIFY_MESSAGE_OUT"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"];
             }
         }
         $arMessageFieldsTmp["TO_USER_ID"] = $v;
         $ID = CIMNotify::Add($arMessageFieldsTmp);
         $arUserIDSent[] = $v;
     }
     if (!empty($arParams["MENTION_ID"])) {
         if (!is_array($arParams["MENTION_ID_OLD"])) {
             $arParams["MENTION_ID_OLD"] = array();
         }
         foreach ($arParams["MENTION_ID"] as $val) {
             $val = IntVal($val);
             if (IntVal($val) > 0 && !in_array($val, $arUsers) && !in_array($val, $arParams["MENTION_ID_OLD"]) && $val != $arParams["FROM_USER_ID"]) {
                 if (CBlogPost::GetSocNetPostPerms($arParams["ID"], false, $val) >= BLOG_PERMS_READ) {
                     $arMessageFields["TO_USER_ID"] = $val;
                     $arMessageFields["NOTIFY_EVENT"] = "mention";
                     if (IsModuleInstalled("extranet")) {
                         $arTmp = CSocNetLogTools::ProcessPath(array("URL" => $arParams["URL"]), $val);
                         $url = $arTmp["URLS"]["URL"];
                         if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) {
                             $serverName = "";
                         } else {
                             $serverName = $arTmp["SERVER_NAME"];
                         }
                         if ($arParams["TYPE"] == "POST") {
                             $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"];
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "";
                         } elseif ($arParams["TYPE"] == "COMMENT") {
                             $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"];
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $url . "";
                         }
                     } else {
                         if ($arParams["TYPE"] == "POST") {
                             $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"];
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "";
                         } elseif ($arParams["TYPE"] == "COMMENT") {
                             $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"];
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7" . $aditGM, array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " " . $serverName . $arParams["URL"] . "";
                         }
                     }
                     $ID = CIMNotify::Add($arMessageFields);
                     $arUserIDSent[] = $val;
                     if (intval($ID) > 0 && intval($arMessageFields["LOG_ID"]) > 0) {
                         foreach (GetModuleEvents("blog", "OnBlogPostMentionNotifyIm", true) as $arEvent) {
                             ExecuteModuleEventEx($arEvent, array($ID, $arMessageFields));
                         }
                     }
                 }
             }
         }
     }
     if ($arParams["TYPE"] == "POST" && !empty($arParams["TO_SOCNET_RIGHTS"])) {
         $arGroupsId = array();
         foreach ($arParams["TO_SOCNET_RIGHTS"] as $perm_tmp) {
             if (preg_match('/^SG(\\d+)_' . SONET_ROLES_USER . '$/', $perm_tmp, $matches) || preg_match('/^SG(\\d+)$/', $perm_tmp, $matches)) {
                 $group_id_tmp = $matches[1];
                 if ($group_id_tmp > 0 && (!array_key_exists("SG", $arParams["TO_SOCNET_RIGHTS_OLD"]) || empty($arParams["TO_SOCNET_RIGHTS_OLD"]["SG"][$group_id_tmp]))) {
                     $arGroupsId[] = $group_id_tmp;
                 }
             }
         }
         if (!empty($arGroupsId)) {
             $title_tmp = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]);
             $title = TruncateText($title_tmp, 100);
             $title_out = TruncateText($title_tmp, 255);
             $arNotifyParams = array("LOG_ID" => $arMessageFields["LOG_ID"], "GROUP_ID" => $arGroupsId, "NOTIFY_MESSAGE" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "URL" => $arParams["URL"], "MESSAGE" => GetMessage("SONET_IM_NEW_POST", array("#title#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">" . $title . "</a>")), "MESSAGE_OUT" => GetMessage("SONET_IM_NEW_POST", array("#title#" => $title_out)) . " #URL#", "EXCLUDE_USERS" => array_merge(array($arParams["FROM_USER_ID"]), array($arUserIDSent)));
             CSocNetSubscription::NotifyGroup($arNotifyParams);
         }
     }
 }
示例#25
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (strlen($arResult["VARIABLES"]["post_id"]) > 0) {
    CModule::IncludeModule("blog");
    $postID = trim($arResult["VARIABLES"]["post_id"]);
    if (!is_numeric($postID) || strlen(IntVal($postID)) != strlen($postID)) {
        $postID = preg_replace("/[^a-zA-Z0-9_-]/is", "", Trim($postID));
        $arFilter = array("CODE" => $postID);
    } else {
        $arFilter = array("ID" => IntVal($postID));
    }
    if (strlen($arResult["PATH_TO_USER_BLOG_POST"]) <= 0) {
        $arResult["PATH_TO_USER_BLOG_POST"] = "/company/personal/user/#user_id#/blog/#post_id#/";
    }
    $dbPost = CBlogPost::GetList(array(), $arFilter, false, false, array("ID", "AUTHOR_ID"));
    if ($arPost = $dbPost->Fetch()) {
        LocalRedirect(CComponentEngine::MakePathFromTemplate($arResult["PATH_TO_USER_BLOG_POST"], array("post_id" => $arPost["ID"], "user_id" => $arPost["AUTHOR_ID"])));
        die;
    }
}
示例#26
0
 //END -> Notifications
 //start custom, use UF binding ::@Idea
 if ($arResult["IDEA_MODERATOR"] && $_REQUEST["BIND_OFFICIAL_ANSWER"] == "Y") {
     // Bind offical answer
     CIdeaManagment::getInstance()->IdeaComment($commentID)->Bind();
 }
 if ($arResult["IDEA_MODERATOR"] && $_REQUEST["BIND_IDEA_STATUS"] != "") {
     CIdeaManagment::getInstance()->Idea($arPost["ID"])->SetStatus($_REQUEST["BIND_IDEA_STATUS"]);
     BXClearCache(True, '/' . SITE_ID . '/idea/statistic_list/');
 }
 /*end*/
 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/comment/" . $arOldComment["POST_ID"] . "/");
 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/post/" . $arOldComment["POST_ID"] . "/");
 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/first_page/");
 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/pages/");
 $commentUrl = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"]));
 if (strpos($commentUrl, "?") !== false) {
     $commentUrl .= "&";
 } else {
     $commentUrl .= "?";
 }
 if ($_REQUEST["redirect_type"] == 'list') {
     //bx redirect for idea list
     LocalRedirect($APPLICATION->GetCurPageParam());
 } elseif (strlen($arFields["PUBLISH_STATUS"]) > 0 && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
     $commentAddedUrl = $commentUrl . $arParams["COMMENT_ID_VAR"] . "=" . $commentID . "&hidden_add_comment_id=" . $commentID;
     LocalRedirect($commentAddedUrl);
 } else {
     $commentUrl .= $arParams["COMMENT_ID_VAR"] . "=" . $commentID . "#" . $commentID;
     LocalRedirect($commentUrl);
 }
示例#27
0
 } else {
     if ($arParams["USE_SOCNET"] == "Y" && IntVal($arParams["SOCNET_GROUP_ID"]) > 0) {
         $arTmp["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arPost["AUTHOR_ID"]));
     } else {
         $arOwnerBlog = CBlog::GetByOwnerID($arTmp["AUTHOR_ID"], $arParams["GROUP_ID"]);
         if (!empty($arOwnerBlog)) {
             $arTmp["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arOwnerBlog["URL"], "user_id" => $arOwnerBlog["OWNER_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"]));
         } else {
             $arTmp["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arPost["BLOG_URL"], "user_id" => $arPost["AUTHOR_ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"]));
         }
     }
 }
 if (IntVal($arPost["BLOG_SOCNET_GROUP_ID"]) > 0) {
     $arTmp["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP_BLOG_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"]));
 } else {
     $arTmp["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"]));
 }
 $arTmp["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arPost["AUTHOR_ID"]));
 $arTmp["AuthorName"] = CBlogUser::GetUserName($arPost["BLOG_USER_ALIAS"], $arPost["AUTHOR_NAME"], $arPost["AUTHOR_LAST_NAME"], $arPost["AUTHOR_LOGIN"]);
 if ($itemCnt == 0) {
     $arTmp["FIRST"] = "Y";
 }
 $text = preg_replace("#\\[img\\](.+?)\\[/img\\]#is", "", $arPost["~DETAIL_TEXT"]);
 $text = preg_replace("#\\[url(.+?)\\](.*?)\\[/url\\]#is", "\\2", $text);
 $text = preg_replace("#\\[video(.+?)\\](.+?)\\[/video\\]#is", "", $text);
 $text = preg_replace("#^(.+?)<cut[\\s]*(/>|>).*?\$#is", "\\1", $text);
 $text = preg_replace("#^(.+?)\\[cut[\\s]*(/\\]|\\]).*?\$#is", "\\1", $text);
 $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|/*)(.*?)(\\]|>)#is", "", $text);
 $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
 $text1 = $text;
 $title = $p->convert($text1, true, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N"));
示例#28
0
 }
 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;
             }
         }
     }
     $arResult["ELEMENT"]["DETAIL_PICTURE"] = CFile::GetFileArray($arResult["ELEMENT"]["DETAIL_PICTURE"]);
     $arResult["ELEMENT"]["REAL_PICTURE"] = CFile::GetFileArray($arResult["ELEMENT"]["PROPERTIES"]["REAL_PICTURE"]["VALUE"]);
     $arFields = array("TITLE" => $arResult["ELEMENT"]["NAME"], "DETAIL_TEXT" => "[IMG]http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["DETAIL_PICTURE"]["SRC"] . "[/IMG]\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["~DETAIL_PAGE_URL"] . "]" . $arResult["ELEMENT"]["NAME"] . "[/URL]\n" . (!empty($arResult["ELEMENT"]["TAGS"]) ? $arResult["ELEMENT"]["TAGS"] . "\n" : "") . $arResult["ELEMENT"]["~DETAIL_TEXT"] . "\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["REAL_PICTURE"]["SRC"] . "]" . GetMessage("P_ORIGINAL") . "[/URL]", "CATEGORY_ID" => implode(",", $arCategory), "PUBLISH_STATUS" => "P", "PERMS_POST" => array(), "PERMS_COMMENT" => array(), "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "AUTHOR_ID" => !empty($arResult["ELEMENT"]["CREATED_BY"]) ? $arResult["ELEMENT"]["CREATED_BY"] : 1, "BLOG_ID" => $arBlog["ID"], "ENABLE_TRACKBACK" => "N");
     $newID = CBlogPost::Add($arFields);
     if ($newID > 0) {
         foreach ($arCategory as $key) {
             CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "CATEGORY_ID" => $key));
         }
         BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"]);
         BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/");
         BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
         $iCommentID = $newID;
         CIBlockElement::SetPropertyValues($arResult["ELEMENT"]["ID"], $arParams["IBLOCK_ID"], $iCommentID, "BLOG_POST_ID");
     }
 }
 $arResult["COMMENT_ID"] = $iCommentID;
 if ($arParams["CACHE_TIME"] > 0) {
     $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
     $cache->EndDataCache(array("COMMENT_ID" => $arResult["COMMENT_ID"], "ELEMENT" => $arResult["ELEMENT"]));
示例#29
0
    function DeletePost($params)
    {
        global $USER;
        $postId = IntVal(CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]));
        $user = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]);
        $password = CBlogMetaWeblog::DecodeParams($params[3]["#"]["value"][0]["#"]);
        if (CBlogMetaWeblog::Authorize($user, $password)) {
            $result = '';
            $userId = $USER->GetID();
            if (IntVal($postId) > 0) {
                $dbPost = CBlogPost::GetList(array(), array("AUTHOR_ID" => $userId, "ID" => $postId), false, array("nTopCount" => 1), array("ID", "BLOG_ID", "AUTHOR_ID"));
                if ($arPost = $dbPost->Fetch()) {
                    CBlogPost::Delete($postId);
                    $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
                    if (intval($arBlog["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork") && method_exists("CSocNetGroup", "GetSite")) {
                        $arSites = array();
                        $rsGroupSite = CSocNetGroup::GetSite($arBlog["SOCNET_GROUP_ID"]);
                        while ($arGroupSite = $rsGroupSite->Fetch()) {
                            $arSites[] = $arGroupSite["LID"];
                        }
                    } else {
                        $arSites = array(SITE_ID);
                    }
                    foreach ($arSites as $site_id_tmp) {
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/first_page/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/pages/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/calendar/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/post/" . $postId . "/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/last_messages/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/commented_posts/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/popular_posts/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/last_comments/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/groups/" . $arResult["BLOG"]["GROUP_ID"] . "/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/trackback/" . $postId . "/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_out/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_all/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_sonet/");
                        BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_all/");
                    }
                }
            }
            return '<params>
						<param>
							<value>
								<boolean>1</boolean>
							</value>
						</param>
					</params>';
        } else {
            return '<fault>
				<value>
					<struct>
						<member>
							<name>faultCode</name>
							<value><int>3</int></value>
							</member>
						<member>
							<name>faultString</name>
							<value><string>' . $arAuthResult["MESSAGE"] . '</string></value>
							</member>
						</struct>
					</value>
				</fault>';
        }
    }
示例#30
0
	public static function Update($ID, $arFields, $bSearchIndex = true)
	{
		global $DB;

		$ID = IntVal($ID);
		
		if(strlen($arFields["PATH"]) > 0)
			$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);

		$arFields1 = array();
		foreach ($arFields as $key => $value)
		{
			if (substr($key, 0, 1) == "=")
			{
				$arFields1[substr($key, 1)] = $value;
				unset($arFields[$key]);
			}
		}

		if (!CBlogComment::CheckFields("UPDATE", $arFields, $ID))
			return false;
		elseif(!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_COMMENT", $ID, $arFields))
			return false;

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

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

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

		if (strlen($strUpdate) > 0)
		{
			if(is_set($arFields["PUBLISH_STATUS"]) && strlen($arFields["PUBLISH_STATUS"]) > 0)
			{
				$arComment = CBlogComment::GetByID($ID);
				if($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH)
					CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS - 1"));
				elseif($arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH)
					CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS + 1"));
			}
			
			$strSql =
				"UPDATE b_blog_comment SET ".
				"	".$strUpdate." ".
				"WHERE ID = ".$ID." ";
			$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);
			unset($GLOBALS["BLOG_COMMENT"]["BLOG_COMMENT_CACHE_".$ID]);
			
			$GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_COMMENT", $ID, $arFields);

			$arComment = CBlogComment::GetByID($ID);			
			$arBlog = CBlog::GetByID($arComment["BLOG_ID"]);
			if($arBlog["USE_SOCNET"] == "Y")
				$arFields["SC_PERM"] = CBlogComment::GetSocNetCommentPerms($arComment["POST_ID"]);

			foreach(GetModuleEvents("blog", "OnCommentUpdate", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, Array($ID, &$arFields));
			
			if ($bSearchIndex && CModule::IncludeModule("search"))
			{
				$newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arComment["BLOG_ID"], $arComment["POST_ID"], BLOG_PERMS_POST);
				
				if ($arBlog["SEARCH_INDEX"] != "Y" || $arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH)
				{
					CSearch::Index("blog", "C".$ID,
						array(
							"TITLE" => "",
							"BODY" => ""
						)
					);
				}
				else
				{
					$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);

					if(strlen($arFields["PATH"]) > 0)
					{
						$arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]);
						$arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]);
					}
					elseif(strlen($arComment["PATH"]) > 0)
					{
						$arComment["PATH"] = str_replace("#comment_id#", $ID, $arComment["PATH"]);
						$arPostSite = array($arGroup["SITE_ID"] => $arComment["PATH"]);
					}
					else
					{
						$arPostSite = array(
							$arGroup["SITE_ID"] => CBlogPost::PreparePath(
									$arBlog["URL"],
									$arComment["POST_ID"],
									$arGroup["SITE_ID"],
									false,
									$arBlog["OWNER_ID"],
									$arBlog["SOCNET_GROUP_ID"]
								)
						);
					}

					$searchContent = blogTextParser::killAllTags($arComment["POST_TEXT"]);
					$searchContent .= "\r\n" . $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("BLOG_COMMENT", $arComment["ID"]);

					$arSearchIndex = array(
						"SITE_ID" => $arPostSite,
						"LAST_MODIFIED" => $arComment["DATE_CREATE"],
						"PARAM1" => "COMMENT",
						"PARAM2" => $arComment["BLOG_ID"]."|".$arComment["POST_ID"],
						"PERMISSIONS" => array(2),
						"TITLE" => $arComment["TITLE"],
						"BODY" => $searchContent,
						"USER_ID" => (IntVal($arComment["AUTHOR_ID"]) > 0) ? $arComment["AUTHOR_ID"] : false,
						"ENTITY_TYPE_ID" => "BLOG_COMMENT",
						"ENTITY_ID" => $arComment["ID"],
					);

					if($arBlog["USE_SOCNET"] == "Y")
					{
						if(is_array($arFields["SC_PERM"]))
						{
							$arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"];
							$sgId = array();
							foreach($arFields["SC_PERM"] as $perm)
							{
								if(strpos($perm, "SG") !== false)
								{
									$sgIdTmp = str_replace("SG", "", substr($perm, 0, strpos($perm, "_")));
									if(!in_array($sgIdTmp, $sgId) && IntVal($sgIdTmp) > 0)
										$sgId[] = $sgIdTmp;
								}
							}

							if(!empty($sgId))
							{
								$arSearchIndex["PARAMS"] = array(
									"socnet_group" => $sgId,
									"entity" => "socnet_group",
								);
							}
							if(!in_array("U".$arComment["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"]))
								$arSearchIndex["PERMISSIONS"][] = "U".$arComment["AUTHOR_ID"];
						}
					}

					if(strlen($arComment["TITLE"]) <= 0)
					{
						//$arPost = CBlogPost::GetByID($arComment["POST_ID"]);
						$arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100);
					}

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

			return $ID;
		}

		return False;
	}