public static function Update($ID, $arFields) { global $DB; $ID = IntVal($ID); $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogSitePath::CheckFields("UPDATE", $arFields, $ID)) { return false; } $strUpdate = $DB->PrepareUpdate("b_blog_site_path", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } if (strlen($strUpdate) > 0) { $strSql = "UPDATE b_blog_site_path SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); unset($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_" . $ID]); return $ID; } return False; }
function PreparePath($blogUrl, $postID = 0, $siteID = False, $is404 = True, $userID = 0, $groupID = 0) { $blogUrl = Trim($blogUrl); $postID = IntVal($postID); $groupID = IntVal($groupID); $userID = IntVal($userID); if (!$siteID) { $siteID = SITE_ID; } $dbPath = CBlogSitePath::GetList(array(), array("SITE_ID" => $siteID)); while ($arPath = $dbPath->Fetch()) { if (strlen($arPath["TYPE"]) > 0) { $arPaths[$arPath["TYPE"]] = $arPath["PATH"]; } else { $arPaths["OLD"] = $arPath["PATH"]; } } if ($postID > 0) { if ($groupID > 0) { if (strlen($arPaths["H"]) > 0) { $result = str_replace("#blog#", $blogUrl, $arPaths["H"]); $result = str_replace("#post_id#", $postID, $result); $result = str_replace("#user_id#", $userID, $result); $result = str_replace("#group_id#", $groupID, $result); } elseif (strlen($arPaths["G"]) > 0) { $result = str_replace("#blog#", $blogUrl, $arPaths["G"]); $result = str_replace("#user_id#", $userID, $result); $result = str_replace("#group_id#", $groupID, $result); } } elseif (strlen($arPaths["P"]) > 0) { $result = str_replace("#blog#", $blogUrl, $arPaths["P"]); $result = str_replace("#post_id#", $postID, $result); $result = str_replace("#user_id#", $userID, $result); } elseif (strlen($arPaths["B"]) > 0) { $result = str_replace("#blog#", $blogUrl, $arPaths["B"]); $result = str_replace("#user_id#", $userID, $result); } else { if ($is404) { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/" . htmlspecialcharsbx($blogUrl) . "/" . $postID . ".php"; } else { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/post.php?blog=" . $blogUrl . "&post_id=" . $postID; } } } else { if (strlen($arPaths["B"]) > 0) { $result = str_replace("#blog#", $blogUrl, $arPaths["B"]); $result = str_replace("#user_id#", $userID, $result); } else { if ($is404) { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/" . htmlspecialcharsbx($blogUrl) . "/"; } else { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/post.php?blog=" . $blogUrl; } } } return $result; }
$BLOG_WIDTH = "100%"; } global $USER, $APPLICATION, $strError, $DB; IncludeTemplateLangFile(__FILE__); $is404 = $is404 == 'N' ? false : true; if (CModule::IncludeModule("blog")) { $USER_ID = intval($USER->GetID()); $ID = intval($ID); if (!$ID) { $ID = intval($_POST['ID']); } $BLOG_ID = intval($BLOG_ID); if (!$BLOG_ID) { $BLOG_ID = intval($_POST['BLOG_ID']); } $arr = CBlogSitePath::GetBySiteID(SITE_ID); $sBlogPath = $arr['PATH']; if ($BLOG_ID) { $arBlog = CBlog::GetByID($BLOG_ID); } else { $res = CBlog::GetList(array(), array("URL" => $OWNER)); $arBlog = $res->Fetch(); $BLOG_ID = intval($arBlog['ID']); } if ($arBlog) { if (IntVal($ID) > 0 && ($arPost = CBlogPost::GetByID($ID))) { $APPLICATION->SetTitle(str_replace("#BLOG#", htmlspecialchars($arBlog["NAME"]), "" . GetMessage("BLOG_POST_EDIT") . "")); $perms = CBlogPost::GetBlogUserPostPerms($ID, $USER_ID); } else { $ID = 0; $APPLICATION->SetTitle(str_replace("#BLOG#", htmlspecialchars($arBlog["NAME"]), "" . GetMessage("BLOG_NEW_MESSAGE") . ""));
public static function DeleteBySiteID($siteID) { global $DB; $siteID = Trim($siteID); if (strlen($siteID) <= 0) return False; $dbPath = CBlogSitePath::GetList(Array(), Array("SITE_ID" => $siteID)); while($arPath = $dbPath -> Fetch()) { unset($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH1_CACHE_".$arPath["SITE_ID"]]); unset($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$arPath["ID"]]); return $DB->Query("DELETE FROM b_blog_site_path WHERE ID = ".$arPath["ID"]."", true); } return true; }
function PreparePath($userID = 0, $siteID = False, $is404 = True) { $userID = IntVal($userID); if (!$siteID) { $siteID = SITE_ID; } $dbPath = CBlogSitePath::GetList(array(), array("SITE_ID" => $siteID)); while ($arPath = $dbPath->Fetch()) { if (strlen($arPath["TYPE"]) > 0) { $arPaths[$arPath["TYPE"]] = $arPath["PATH"]; } else { $arPaths["OLD"] = $arPath["PATH"]; } } if (strlen($arPaths["U"]) > 0) { $result = str_replace("#user_id#", $userID, $arPaths["U"]); } else { if ($is404) { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/users/" . $userID . ".php"; } else { $result = htmlspecialcharsbx($arPaths["OLD"]) . "/users.php?&user_id=" . $userID; } } return $result; }
<?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));
</tr> <?php } ?> <tr class="heading"> <td colspan="2"><?php echo GetMessage("BLO_SITE_PATH2"); ?> </td> </tr> <?php $arPaths = array(); $dbPaths = CBlogSitePath::GetList(); while ($arPath = $dbPaths->Fetch()) { $arPaths[$arPath["SITE_ID"]][$arPath["TYPE"]] = $arPath["PATH"]; } $dbSites = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y")); while ($arSite = $dbSites->Fetch()) { ?> <tr> <td valign="top" colspan="2" align="center"><?php echo str_replace("#SITE#", $arSite["LID"], GetMessage("BLO_SITE_PATH_SITE")); ?> :</td> </tr> <tr> <td align="center" colspan="2"> <table cellspacing="2" width="100%">
CBlog::Delete($res_blog["ID"]); } while ($res_blog = $db_blog->Fetch()); } } else { CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/blogs/index.php", array("BLOG_GROUP_ID" => $SocNetGroupID)); return; } } if (WIZARD_FIRST_INSTAL != 'Y') { $arFilters = array(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "blogs/" . WIZARD_SITE_ID . "_blog_#user_id#/", "TYPE" => "B"), array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "blogs/" . WIZARD_SITE_ID . "_blog_#user_id#/#post_id#.php", "TYPE" => "P"), array("SITE_ID" => WIZARD_SITE_ID, "PATH" => WIZARD_SITE_DIR . "blogs/user/#user_id#.php", "TYPE" => "U")); foreach ($arFilters as $arFilter) { $dbSitePath = CBlogSitePath::GetList(array(), $arFilter, false, false, array("ID")); if ($arSitePath = $dbSitePath->Fetch()) { CBlogSitePath::Delete($arSitePath["ID"]); } CBlogSitePath::Add($arFilter); } } COption::SetOptionString('blog', 'avatar_max_size', '30000'); COption::SetOptionString('blog', 'avatar_max_width', '100'); COption::SetOptionString('blog', 'avatar_max_height', '100'); COption::SetOptionString('blog', 'image_max_width', '600'); COption::SetOptionString('blog', 'image_max_height', '600'); COption::SetOptionString('blog', 'allow_alias', 'Y'); COption::SetOptionString('blog', 'block_url_change', 'Y'); COption::SetOptionString('blog', 'GROUP_DEFAULT_RIGHT', 'D'); COption::SetOptionString('blog', 'show_ip', 'N'); COption::SetOptionString('blog', 'enable_trackback', 'N'); COption::SetOptionString('blog', 'allow_html', 'N'); $APPLICATION->SetGroupRight("blog", 1, "W"); COption::SetOptionString("blog", "GROUP_DEFAULT_RIGHT", "D");
COption::SetOptionString('blog', 'allow_html', 'Y'); $APPLICATION->SetGroupRight("blog", 1, "W"); COption::SetOptionString("blog", "GROUP_DEFAULT_RIGHT", "D"); $db_res = CBlogSitePath::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID)); if ($db_res && ($res = $db_res->Fetch())) { if (WIZARD_INSTALL_DEMO_DATA) { $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 == "..") {
</td> </tr> </table> <?php if ($CACHE_TIME > 0) { $cache->EndDataCache(array()); } } if ($arPost["ENABLE_TRACKBACK"] == "Y") { $cache = new CPHPCache(); $cache_id = "blog_trackback_" . serialize($arParams) . "_" . $PostPerm; $cache_path = "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/trackback/" . $arPost["ID"] . "/"; $arurlToBlogs = CBlogSitePath::GetBySiteID(SITE_ID); $urlToBlogs = $arurlToBlogs["PATH"]; if ($CACHE_TIME > 0 && $cache->InitCache($CACHE_TIME, $cache_id, $cache_path)) { $cache->Output(); } else { if ($CACHE_TIME > 0) { $cache->StartDataCache($CACHE_TIME, $cache_id, $cache_path); } $dbTrack = CBlogTrackback::GetList(array("POST_DATE" => "DESC"), array("BLOG_ID" => $arPost["BLOG_ID"], "POST_ID" => $arPost["ID"])); ?> <p class="blogtext"><?php echo GetMessage("B_B_MES_TBA"); ?> <a href="<?php echo $urlToBlogs; ?>
public static function PreparePath($blogUrl, $siteID = False, $is404 = True, $userID = 0, $groupID = 0) { $blogUrl = Trim($blogUrl); if (!$siteID) $siteID = SITE_ID; $dbPath = CBlogSitePath::GetList(array(), array("SITE_ID"=>$siteID)); while($arPath = $dbPath->Fetch()) { if(strlen($arPath["TYPE"])>0) $arPaths[$arPath["TYPE"]] = $arPath["PATH"]; else $arPaths["OLD"] = $arPath["PATH"]; } if($groupID > 0 && strlen($arPaths["G"])>0) { $result = str_replace("#blog#", $blogUrl, $arPaths["G"]); $result = str_replace("#user_id#", $userID, $result); $result = str_replace("#group_id#", $groupID, $result); } elseif(strlen($arPaths["B"])>0) { $result = str_replace("#blog#", $blogUrl, $arPaths["B"]); $result = str_replace("#user_id#", $userID, $result); $result = str_replace("#group_id#", $groupID, $result); } else { if($is404) $result = htmlspecialcharsbx($arPaths["OLD"])."/".htmlspecialcharsbx($blogUrl)."/"; else $result = htmlspecialcharsbx($arPaths["OLD"])."/blog.php?blog=".$blogUrl; } return $result; }
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")); CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/", "TYPE" => "B")); CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/#post_id#.php", "TYPE" => "P")); CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/user/#user_id#.php", "TYPE" => "U")); if (IsModuleInstalled("socialnetwork")) { $rsUser = CUser::GetByID(1); $arUser = $rsUser->Fetch(); $blogID = CBlog::Add(array("NAME" => GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"], "DESCRIPTION" => "", "GROUP_ID" => $SocNetGroupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "USE_SOCNET" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => str_replace(" ", "_", $arUser["LOGIN"]) . "-blog", "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))); CBlog::AddSocnetRead($blogID); $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" => str_replace('[IMG ID=1]', "[IMG ID=2]", 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);