本文整理汇总了PHP中CBlogPost类的典型用法代码示例。如果您正苦于以下问题:PHP CBlogPost类的具体用法?PHP CBlogPost怎么用?PHP CBlogPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBlogPost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckFields
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;
}
示例2: CallBack_AddComment
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: AddBlogPost
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: CanUserDeletePost
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: checkUserReadAccess
/**
* 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: Add
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;
}
示例7: __AutoSetPerms
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: prepareData
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: Execute
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;
}
示例10: UnBind
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;
}
示例11: ShowError
}
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();
示例12: SetFeaturePermissions
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"]);
}
}
}
}
}
示例13: array
}
$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();
示例14: array
$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"]);
示例15: GetSocNetUserPerms
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;
}
//.........这里部分代码省略.........