/* if (WIZARD_INSTALL_DEMO_DATA) { $db_blog = CBlog::GetList(array(), array("GROUP_ID" => $res_blog_group["ID"]), false, false, array("ID")); if ($res_blog = $db_blog->Fetch()) { do { CBlog::Delete($res_blog["ID"]); } while ($res_blog = $db_blog->Fetch()); } BXClearCache(True, "/".WIZARD_SITE_ID."/blog/"); BXClearCache(True, "/".WIZARD_SITE_ID."/idea/"); } */ } if (!$SocNetGroupID) { $SocNetGroupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => $IdeaBlogGroupName)); } //Blog $blogID = CBlog::Add(array("NAME" => GetMessage("IDEA_DEMO_BLOG_NAME"), "DESCRIPTION" => "", "GROUP_ID" => $SocNetGroupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => $IdeaBlogUrl, "ACTIVE" => "Y", "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "SOCNET_GROUP_ID" => 1, "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_WRITE), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE), "PATH" => '/services/idea/')); //UF $arUFIdByName = array(); $arStatusList = CIdeaManagment::getInstance()->GetStatusList(); foreach ($arStatusList as $UF) { $arUFIdByName[$UF["XML_ID"]] = $UF["ID"]; } //Categories $categoryID = array(); $categoryID[0][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_1"))); $categoryID[0][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_2"))); $categoryID[1][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_3"))); //Post messages
$dbResult = CForumNew::GetListEx(array(), array("SITE_ID" => $arSite["SITE_ID"], "XML_ID" => "car_forum_demo")); if ($arResult = $dbResult->Fetch()) { $forumID = $arResult["ID"]; } else { $arFields = array("NAME" => GetSocNetMessageLocal("SONET_I_FORUM_NAME", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "XML_ID" => "car_forum_demo", "MODERATION" => "N", "SITES" => array($arSite["SITE_ID"] => StrLen($arSite["DIR"]) > 0 ? $arSite["DIR"] : "/")); $forumID = CForumNew::Add($arFields); } } // ------------------ BLOG ------------------------------- $blogGroupID = 0; if (CModule::IncludeModule("blog")) { $dbResult = CBlogGroup::GetList(array("ID" => "ASC"), array("SITE_ID" => $arSite["SITE_ID"])); if ($arResult = $dbResult->Fetch()) { $blogGroupID = $arResult["ID"]; } else { $blogGroupID = CBlogGroup::Add(array("SITE_ID" => $arSite["SITE_ID"], "NAME" => GetSocNetMessageLocal("SONET_I_BLOG_NAME", $arSite["LANGUAGE_ID"]))); } } // ------------------ PHOTO ------------------------------- $photoIBlockTypeID = "car_gallery_demo"; $photoUserIBlockID = 0; $photoGroupIBlockID = 0; if (CModule::IncludeModule("iblock")) { $dbIBlockType = CIBlockType::GetList(array(), array("=ID" => $photoIBlockTypeID)); if ($arIBlockType = $dbIBlockType->Fetch()) { $photoIBlockTypeID = $arIBlockType["ID"]; } else { $arFieldsLang = array(); foreach ($arLanguages as $arLang) { $arFieldsLang[$arLang["LID"]] = array("NAME" => GetSocNetMessageLocal("SONET_I_PHOTO_IBLOCK_TYPE_NAME", $arLang["LID"])); }
if (substr($key, 0, 9) == "PROPERTY_" && substr($key, -6, 6) == "_VALUE") { $arResult["ELEMENT"]["PROPERTIES"][substr($key, 9, intVal(strLen($key) - 15))] = array("VALUE" => $val); } } if (isset($arParams["BLOG_URL"]) && trim($arParams["BLOG_URL"]) != "") { $arResult["BLOG_URL"] = $arParams["BLOG_URL"]; } else { $arResult["BLOG_URL"] = "catalog_comments"; } $SITE_ID = defined("SITE_ID") && strLen(SITE_ID) > 0 ? SITE_ID : "s1"; $arFields = array("SITE_ID" => $SITE_ID, "NAME" => GetMessage("IBLOCK_CSC_BLOG_GROUP_NAME")); $dbBlogGroup = CBlogGroup::GetList(array(), $arFields, false, false, array("ID")); if ($arBlogGroup = $dbBlogGroup->Fetch()) { $blogGroupID = $arBlogGroup["ID"]; } else { $blogGroupID = CBlogGroup::Add($arFields); } $blogGroupID = intval($blogGroupID); if ($blogGroupID > 0) { $dbBlog = CBlog::GetList(array(), array("URL" => $arResult["BLOG_URL"]), false, false, array("ID")); if ($arBlog = $dbBlog->Fetch()) { $blogId = $arBlog["ID"]; } else { $arFields = array("NAME" => GetMessage("IBLOCK_CSC_BLOG_NAME"), "DESCRIPTION" => GetMessage("IBLOCK_CSC_BLOG_DESCRIPTION"), "GROUP_ID" => $blogGroupID, "ENABLE_COMMENTS" => 'Y', "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => isset($arParams["EMAIL_NOTIFY"]) && $arParams["EMAIL_NOTIFY"] == 'Y' ? 'Y' : 'N', "URL" => $arResult["BLOG_URL"], "ACTIVE" => "Y", "OWNER_ID" => 1, "AUTO_GROUPS" => "N"); $blogId = CBlog::Add($arFields); if (IntVal($blogId) > 0) { CBlog::SetBlogPerms($blogId, array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE), BLOG_PERMS_COMMENT); } else { if ($ex = $APPLICATION->GetException()) { $arResult["ERRORS"][] = $ex->GetString(); } else {
private function InstallBlogGroup() { if ($this->arResult["INSTALLATION"]["BLOG_GROUP_INSTALL"]) { global $APPLICATION; $arFields = array("SITE_ID" => $this->SITE_ID, "NAME" => $this->ModuleBlogGroup); if (!($BlogGroupId = CBlogGroup::Add($arFields))) { if ($ex = $APPLICATION->GetException()) { $this->arResult["ERRORS"][] = $ex->GetString() . ' [' . $this->ModuleBlogGroup . "]"; } else { $this->arResult["ERRORS"][] = GetMessage("IDEA_INSTALL_ERROR_BLOG_GROUP_NOT_INSTALLED"); } } $this->arResult["INSTALLATION"]["BLOG_GROUP_ID"] = $BlogGroupId; } }
if (!$bVarsFromForm && $_REQUEST["blog"] == "Y" && IsModuleInstalled("blog") && $GLOBALS["APPLICATION"]->GetGroupRight("blog") >= "W") { CModule::IncludeModule("blog"); if ($_REQUEST["create_blog_group"] == "Y") { $arFields = array("NAME" => $_REQUEST["blog_group_name"], "SITE_ID" => ""); $arSites = array(); $db_sites = CLang::GetList($lby = "sort", $lorder = "asc"); while ($ar_sites = $db_sites->Fetch()) { if ($ar_sites["DEF"] == "Y") { $arFields["SITE_ID"] = $ar_sites["LID"]; } $arSites[] = $ar_sites; } if (empty($arFields["SITE_ID"])) { $arFields["SITE_ID"] = $arSites[0]["LID"]; } $BLOG_GROUP_ID = CBlogGroup::Add($arFields); if ($BLOG_GROUP_ID <= 0) { $bVarsFromForm = true; if ($ex = $APPLICATION->GetException()) { $strWarning .= $ex->GetString() . ". <br />"; } else { $strWarning .= "Error creating blog group. <br />"; } } else { $arBlogGroupTmp = CBlogGroup::GetByID($BLOG_GROUP_ID); BXClearCache(True, "/" . $arBlogGroupTmp["SITE_ID"] . "/blog/blog_groups/"); $_REQUEST["create_blog_group"] = "N"; $_REQUEST["blog_group_id"] = $BLOG_GROUP_ID; $_REQUEST["blog_group_name"] = ""; } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("blog")) { return; } $dbGroup = CBlogGroup::GetList(array("ID" => "ASC"), array("SITE_ID" => WIZARD_SITE_ID)); if ($arGroup = $dbGroup->Fetch()) { if (WIZARD_B24_TO_CP) { $groupID = $arGroup["ID"]; CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/index.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/index_b24.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/contacts/personal.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/workgroups/index.php", array("BLOG_GROUP_ID" => $groupID)); } return; } CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "contacts/personal/user/#user_id#/blog/", "TYPE" => "B")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "contacts/personal/user/#user_id#/blog/#post_id#/", "TYPE" => "P")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "contacts/personal/user/#user_id#/", "TYPE" => "U")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "workgroups/group/#group_id#/blog/", "TYPE" => "G")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "workgroups/group/#group_id#/blog/#post_id#/", "TYPE" => "H")); $groupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("BLOG_SOCNET_GROUP_EXTRANET_NAME"))); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/index.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/index_b24.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/contacts/personal.php", array("BLOG_GROUP_ID" => $groupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/workgroups/index.php", array("BLOG_GROUP_ID" => $groupID));
else { if ($arParams['BLOG_FROM_AJAX'] === 'N') { $fields = array( 'SITE_ID' => SITE_ID, 'NAME' => GetMessage('IBLOCK_CSC_BLOG_GROUP_NAME') ); $blogGroupIterator = CBlogGroup::GetList(array(), $fields, false, false, array('ID')); if ($blogGroup = $blogGroupIterator->Fetch()) { $blogGroupID = (int)$blogGroup['ID']; } else { $blogGroupID = (int)CBlogGroup::Add($fields); if ($blogGroupID == 0) { if ($ex = $APPLICATION->GetException()) $arResult["ERRORS"][] = $ex->GetString(); else $arResult["ERRORS"][] = GetMessage("IBLOCK_CSC_BLOG_GROUP_CREATE_ERROR"); } } unset($fields); if ($blogGroupID > 0) { if (!$blogExist) { $fields = array( "NAME" => GetMessage("IBLOCK_CSC_BLOG_NAME"),
CBlogSitePath::Update($res["ID"], array("PATH" => $res_tmp[$res["TYPE"]])); } } while ($db_res && ($res = $db_res->Fetch())); } } else { CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "people/user/#user_id#/blog/", "TYPE" => "B")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "people/user/#user_id#/blog/#post_id#/", "TYPE" => "P")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "people/user/#user_id#/", "TYPE" => "U")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "groups/group/#group_id#/blog/", "TYPE" => "G")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "groups/group/#group_id#/blog/#post_id#/", "TYPE" => "H")); } /******************************************************************** Get users list with permission to create blog ********************************************************************/ if (!$SocNetGroupID) { $SocNetGroupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => "[" . WIZARD_SITE_ID . "] " . GetMessage("BLOG_DEMO_GROUP_SOCNET"))); } $arFilter = array(); if ($GLOBALS["APPLICATION"]->GetGroupRight("blog", array(2)) < "N") { $arFilter["!ID"] = 1; $arFilter["GROUPS"] = array(); $db_res = CGroup::GetList($by = "ID", $order = "DESC", array("ACTIVE" => "Y", "!ID" => 2)); if ($db_res && ($res = $db_res->Fetch())) { do { if ($GLOBALS["APPLICATION"]->GetGroupRight("blog", array($res["ID"])) >= "N") { $arFilter["GROUPS"][] = $res["ID"]; } } while ($res = $db_res->Fetch()); } } $db_res = CUser::GetList($by = "ID", $order = "DESC", $arFilter, array("NAV_PARAMS" => array("nPageSize" => 3, "iNumPage" => 1, "bDescPageNumbering" => false)));
$arParams = array("USE_COMMENTS" => "Y", "COMMENTS_TYPE" => "forum", "FORUM_ID" => $FID, "BLOG_URL" => "", "PATH_TO_SMILE" => "/bitrix/images/forum/smile/"); } } elseif (CModule::IncludeModule("blog")) { $iBlogId = ""; $res = CBlog::GetByUrl("gallery"); if ($res && !empty($res) && is_array($res)) { $iBlogId = intVal($res["ID"]); } else { $iBlogGroupId = 0; $arFields = array("NAME" => GetMessage("P_BLOG_GROUP_NAME")); $db_res = CBlogGroup::GetList(array(), $arFields, false, false, array("ID")); if ($db_res && ($res = $db_res->Fetch())) { $iBlogGroupId = intVal($res["ID"]); } else { $arFields["SITE_ID"] = $SITE_ID; $iBlogGroupId = CBlogGroup::Add($arFields); } if ($iBlogGroupId > 0) { $arFields = array("ACTIVE" => "N", "NAME" => GetMessage("P_BLOG_NAME"), "DESCRIPTION" => GetMessage("P_BLOG_DESCRIPTION"), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "URL" => "gallery", "OWNER_ID" => $GLOBALS["USER"]->GetId(), "GROUP_ID" => $iBlogGroupId); $iBlogId = CBlog::Add($arFields); } } if (intVal($iBlogId) > 0) { $arParams = array("USE_COMMENTS" => "Y", "COMMENTS_TYPE" => "blog", "FORUM_ID" => 0, "BLOG_URL" => "gallery", "PATH_TO_SMILE" => "/bitrix/images/blog/smile/"); } } $arParams["IBLOCK_ID"] = $iBlockId; // 4. Copy public files with "on the fly" translation $source = "/public/photogallery/"; $target = "/content/photo/"; $source_base = dirname(__FILE__);
$res_tmp = array("B" => WIZARD_SITE_DIR, "P" => WIZARD_SITE_DIR . "#post_id#/"); do { if (array_key_exists($res["TYPE"], $res_tmp) && $res["PATH"] != $res_tmp[$res["TYPE"]]) { CBlogSitePath::Update($res["ID"], array("PATH" => $res_tmp[$res["TYPE"]])); } } while ($db_res && ($res = $db_res->Fetch())); } } else { CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR, "TYPE" => "B")); CBlogSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "#post_id#/", "TYPE" => "P")); } if ($SocNetGroupID == false) { $SocNetGroupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("BLOG_DEMO_GROUP") . " (" . WIZARD_SITE_ID . ")")); } if ($utilGroupID == false) { $utilGroupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("BLOG_DEMO_GROUP_UTIL") . " (" . WIZARD_SITE_ID . ")")); } /******************************************************************** Creating Posts array and arranging for Users ********************************************************************/ $dir = WIZARD_SERVICE_ABSOLUTE_PATH . "/images/"; $arImages = array(); if (is_dir($dir) && ($dh = opendir($dir))) { while (($file = readdir($dh)) !== false) { if ($file == "." || $file == "..") { continue; } $arImages[$file] = array("name" => $file, "type" => "image/jpeg", "tmp_name" => $dir . $file, "error" => 0, "size" => filesize($dir . $file)); } closedir($dh); }
if (IsModuleInstalled("socialnetwork")) { $SocNetGroupID = CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_SOCNET"))); } $groups = $groupID = CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_1"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_2"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_3"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_4"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_5"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_6"))); $groups .= ","; $groups .= CBlogGroup::Add(array("SITE_ID" => $siteID, "NAME" => GetMessage("BLOG_DEMO_GROUP_7"))); $blogID = CBlog::Add(array("NAME" => GetMessage("BLOG_DEMO_BLOG_NAME"), "DESCRIPTION" => GetMessage("BLOG_DEMO_BLOG_NAME"), "GROUP_ID" => $groupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => "admin-blg", "ACTIVE" => "Y", "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "OWNER_ID" => 1, "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_READ), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE))); $friends = CBlogUserGroup::Add(array("NAME" => GetMessage("BLOG_DEMO_FRIENDS"), "BLOG_ID" => $blogID)); CBlogUserGroupPerms::Add(array("BLOG_ID" => $blogID, "USER_GROUP_ID" => $friends, "PERMS_TYPE" => "P", "PERMS" => "I", "AUTOSET" => "N")); CBlogUserGroupPerms::Add(array("BLOG_ID" => $blogID, "USER_GROUP_ID" => $friends, "PERMS_TYPE" => "C", "PERMS" => "P", "AUTOSET" => "N")); $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_1"))); $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_2"))); $postID = CBlogPost::Add(array("TITLE" => GetMessage("BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => GetMessage("BLOG_DEMO_MESSAGE_BODY_1"), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID), "PERMS_P" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_C" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE))); foreach ($categoryID as $v) { CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $postID, "CATEGORY_ID" => $v)); } $arImage = CFile::MakeFileArray(dirname(__FILE__) . '/images/' . GetMessage("BLOG_DEMO_IMG")); $arImage["MODULE_ID"] = "blog"; $arFields = array("BLOG_ID" => $blogID, "POST_ID" => $postID, "USER_ID" => 1, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => GetMessage("BLOG_DEMO_IMG_TITLE"), "IMAGE_SIZE" => $arImage["size"], "FILE_ID" => $arImage); CBlogImage::Add($arFields); CBlogComment::Add(array("TITLE" => GetMessage("BLOG_DEMO_COMMENT_TITLE"), "POST_TEXT" => GetMessage("BLOG_DEMO_COMMENT_BODY"), "BLOG_ID" => $blogID, "POST_ID" => $postID, "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108"));