本文整理汇总了PHP中CBlog类的典型用法代码示例。如果您正苦于以下问题:PHP CBlog类的具体用法?PHP CBlog怎么用?PHP CBlog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBlog类的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: GetList
public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
if (!CModule::IncludeModule('blog')) {
return false;
}
global $DB;
if (count($arSelectFields) == 0) {
$arSelectFields = array("ID", "USER_ID", "USER_EMAIL");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "IES.ID", "TYPE" => "string"), "USER_ID" => array("FIELD" => "IES.USER_ID", "TYPE" => "int"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (IES.USER_ID = U.ID)"));
$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
//Make Query
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_idea_email_subscribe IES " . " " . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
示例3: OnGroupDelete
public static function OnGroupDelete($ID)
{
$ID = IntVal($ID);
if ($ID <= 0) {
return false;
}
$arBlog = CBlog::GetBySocNetGroupID($ID);
if (!empty($arBlog)) {
CBlog::Delete($arBlog["ID"]);
}
}
示例4: Delete
function Delete($ID)
{
global $DB;
$ID = IntVal($ID);
$dbResult = CBlog::GetList(array(), array("GROUP_ID" => $ID), false, false, array("ID"));
if ($dbResult->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("BLG_GG_ERROR_NOT_EMPTY")), "ERROR_NOT_EMPTY");
return False;
}
unset($GLOBALS["BLOG_GROUP"]["BLOG_GROUP_CACHE_" . $ID]);
return $DB->Query("DELETE FROM b_blog_group WHERE ID = " . $ID . "", true);
}
示例5: GetList
public static function GetList($arOrder = array("ID" => "ASC"), $arFilter = array(), $arAddParams = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "BPP.ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "BPP.POST_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "BPP.USER_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "BPP.NAME", "TYPE" => "string"), "VALUE" => array("FIELD" => "BPP.VALUE", "TYPE" => "string"), "RANK" => $arOrder["OWNER_ID"] > 0 ? array("FIELD" => "RV0.RANK", "TYPE" => "int", "FROM" => "\n\tLEFT JOIN (\n\t\t" . "SELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID \n\t\t" . "FROM b_rating_user RV2 \n\t\t" . "GROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)\n\t" . "LEFT JOIN (\n\t\t" . "SELECT RV1.OWNER_ID, SUM(case when RV1.ID is not null then 1 else 0 end) as RANK \n\t\t" . "FROM b_rating_vote RV1 \n\t\t" . "WHERE RV1.USER_ID = " . $arOrder["OWNER_ID"] . "\n\t\t" . "GROUP BY RV1.OWNER_ID) RV0 ON (RV0.OWNER_ID = BPP.USER_ID)") : array("FIELD" => "RV.RANK", "TYPE" => "string", "FROM" => "\n\tLEFT JOIN (" . "\n\t\tSELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID, 0 as RANK " . "\n\t\tFROM b_rating_user RV2" . "\n\t\tGROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)"), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"));
$arSelect = array_diff(array_keys($arFields), array("RANK"));
$arSelect = is_array($arAddParams["SELECT"]) && !empty($arAddParams["SELECT"]) ? array_intersect($arAddParams["SELECT"], $arSelect) : $arSelect;
$arSql = CBlog::PrepareSql($arFields, array(), $arFilter, false, $arSelect);
$arSql["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSql["SELECT"]);
$iCnt = 0;
if ($arAddParams["bCount"] || array_key_exists("bDescPageNumbering", $arAddParams)) {
$strSql = "SELECT COUNT(BPP.ID) AS CNT \n" . "FROM b_blog_post_param BPP " . $arSql["FROM"] . "\n" . (empty($arSql["GROUPBY"]) ? "" : "GROUP BY " . $arSql["GROUPBY"] . "\n") . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]);
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arAddParams["bCount"]) {
return $db_res;
}
$iCnt = $db_res && ($res = $db_res->Fetch()) ? intval($res["CNT"]) : 0;
}
// ORDER BY -->
$arSqlOrder = array();
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order) != "ASC" ? "DESC" : "ASK";
if (array_key_exists($by, $arFields) && !array_key_exists($by, $arSqlOrder)) {
if (strtoupper($DB->type) == "ORACLE") {
$order .= $order == "ASC" ? " NULLS FIRST" : " NULLS LAST";
}
if (isset($arFields[$by]["FROM"]) && !empty($arFields[$by]["FROM"]) && strpos($arSql["FROM"], $arFields[$by]["FROM"]) === false) {
$arSql["FROM"] .= " " . $arFields[$by]["FROM"];
}
if ($by == "RANK") {
$arSql["SELECT"] .= ", " . $arFields["RANK"]["FIELD"];
$arSqlOrder[$by] = IsModuleInstalled("intranet") ? "RV.VOTE_WEIGHT " . $order . ", RANK " . $order : "RANK " . $order . ", RV.VOTE_WEIGHT " . $order;
} else {
$arSqlOrder[$by] = (array_key_exists("ORDER", $arFields[$by]) ? $arFields[$by]["ORDER"] : $arFields[$by]["FIELD"]) . " " . $order;
}
}
}
DelDuplicateSort($arSqlOrder);
$arSql["ORDERBY"] = implode(", ", $arSqlOrder);
// <-- ORDER BY
$strSql = "SELECT " . $arSql["SELECT"] . "\n" . "FROM b_blog_post_param BPP" . $arSql["FROM"] . "\n" . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]) . (empty($arSql["ORDERBY"]) ? "" : "\nORDER BY " . $arSql["ORDERBY"]);
if (is_set($arAddParams, "bDescPageNumbering")) {
$db_res = new CDBResult();
$db_res->NavQuery($strSql, $iCnt, $arAddParams);
} else {
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $db_res;
}
示例6: CheckFields
function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "BLOG_ID") || $ACTION == "ADD") && IntVal($arFields["BLOG_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_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_GUGP_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
return false;
}
}
if ((is_set($arFields, "USER_GROUP_ID") || $ACTION == "ADD") && IntVal($arFields["USER_GROUP_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_USER_GROUP_ID"), "EMPTY_USER_GROUP_ID");
return false;
} elseif (is_set($arFields, "USER_GROUP_ID")) {
$arResult = CBlogUserGroup::GetByID($arFields["USER_GROUP_ID"]);
if (!$arResult) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_GROUP_ID"], GetMessage("BLG_GUGP_ERROR_NO_USER_GROUP")), "ERROR_NO_USER_GROUP");
return false;
}
}
if ((is_set($arFields, "PERMS_TYPE") || $ACTION == "ADD") && $arFields["PERMS_TYPE"] != BLOG_PERMS_POST && $arFields["PERMS_TYPE"] != BLOG_PERMS_COMMENT) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_PERMS_TYPE"), "EMPTY_PERMS_TYPE");
return false;
}
if ((is_set($arFields, "PERMS") || $ACTION == "ADD") && strlen($arFields["PERMS"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_PERMS"), "EMPTY_PERMS");
return false;
} elseif (is_set($arFields, "PERMS")) {
$arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]);
if (!in_array($arFields["PERMS"], $arAvailPerms)) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERMS"], GetMessage("BLG_GUGP_ERROR_NO_PERMS")), "ERROR_NO_PERMS");
return false;
}
}
if ((is_set($arFields, "AUTOSET") || $ACTION == "ADD") && $arFields["AUTOSET"] != "Y" && $arFields["AUTOSET"] != "N") {
$arFields["AUTOSET"] = "N";
}
return True;
}
示例7: CheckFields
public static function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GCT_EMPTY_NAME"), "EMPTY_NAME");
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, "NAME")) {
if (intval($arFields["BLOG_ID"]) > 0) {
$blogID = $arFields["BLOG_ID"];
} elseif (IntVal($ID) > 0) {
$arCat = CBlogCategory::GetByID($ID);
$blogID = $arCat["BLOG_ID"];
} else {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GCT_EMPTY_BLOG_ID"), "EMPTY_BLOG_ID");
return false;
}
if (strlen($arFields["NAME"]) > 255) {
$arFields["NAME"] = substr($arFields["NAME"], 0, 255);
}
$dbCategory = CBlogCategory::GetList(array(), array("BLOG_ID" => $blogID, "NAME" => $arFields["NAME"]));
while ($arCategory = $dbCategory->Fetch()) {
if ($ID != $arCategory["ID"]) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_ALREADY_EXIST"), "ALREADY_EXIST");
return false;
}
}
}
return True;
}
示例8: CheckFields
public static function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "BLOG_ID") || $ACTION == "ADD") && IntVal($arFields["BLOG_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GC_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_GB_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
return false;
}
}
if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GB_EMPTY_USER_ID"), "EMPTY_USER_ID");
return false;
} elseif (is_set($arFields, "USER_ID")) {
$dbResult = CUser::GetByID($arFields["USER_ID"]);
if (!$dbResult->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GB_ERROR_NO_USER_ID"), "ERROR_NO_USER_ID");
return false;
}
}
return True;
}
示例9: array
$SORT = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]);
$arFilter = array("SITE_ID" => SITE_ID);
if (!empty($arParams["GROUP_ID"])) {
$arFilter["ID"] = $arParams["GROUP_ID"];
}
$arSelectFields = false;
// if($arParams["GROUPS_COUNT"]>0)
// $COUNT = Array("nTopCount" => $arParams["GROUPS_COUNT"]*2);
// else
$COUNT = false;
$arResult["GROUPS"] = array();
$arResult["GROUPS_TABLE"] = array();
$dbGroups = CBlogGroup::GetList($SORT, $arFilter, false, $COUNT, $arSelectFields);
$itemCnt = 0;
while ($arGroups = $dbGroups->Fetch()) {
$dbBlog = CBlog::GetList(array(), array("GROUP_ID" => $arGroups["ID"]), false, false, array("ID", "GROUP_ID"));
if ($arBlog = $dbBlog->Fetch()) {
$url = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arGroups["ID"]));
$arResult["GROUPS"][] = array("ID" => $arGroups["ID"], "NAME" => htmlspecialcharsex($arGroups["NAME"]), "URL" => $url);
$itemCnt++;
if ($itemCnt >= $arParams["GROUPS_COUNT"] && $arParams["GROUPS_COUNT"] > 0) {
break;
}
}
}
$cnt = count($arResult["GROUPS"]);
$row1 = ceil($cnt / $arParams["COLS_COUNT"]);
$all = $cnt - $row1;
for ($i = 1; $i < $arParams["COLS_COUNT"]; $i++) {
if ($arParams["COLS_COUNT"] - $i > 1) {
${"row" . ($i + 1)} = ceil($all / ($arParams["COLS_COUNT"] - $i));
示例10: array
$rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
while ($arSite = $rsSite->Fetch()) {
$arIdeaBlogGroupID[] = COption::GetOptionInt("idea", "blog_group_id", false, $arSite["LID"]);
}
}
if (empty($arIdeaBlogGroupID)) {
$arBlog = CBlog::GetByOwnerID($arParams["USER_ID"]);
} else {
$arBlogGroupID = array();
$rsBlogGroup = CBlogGroup::GetList(array(), array(), false, false, array("ID"));
while ($arBlogGroup = $rsBlogGroup->Fetch()) {
if (!in_array($arBlogGroup["ID"], $arIdeaBlogGroupID)) {
$arBlogGroupID[] = $arBlogGroup["ID"];
}
}
$arBlog = CBlog::GetByOwnerID($arParams["USER_ID"], $arBlogGroupID);
}
}
$obCache->EndDataCache($arBlog);
}
$arResult["Blog"] = $arBlog;
if ($GLOBALS["USER"]->IsAuthorized()) {
CSocNetTools::InitGlobalExtranetArrays();
if (isset($GLOBALS["arExtranetGroupID"])) {
$arResult["arExtranetGroupID"] = $GLOBALS["arExtranetGroupID"];
}
}
}
$arParams["ID"] = trim($arParams["ID"]);
if (preg_match("/^[1-9][0-9]*\$/", $arParams["ID"])) {
$arParams["ID"] = IntVal($arParams["ID"]);
示例11: GetList
public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "TITLE", "URL", "PREVIEW_TEXT", "BLOG_NAME", "POST_DATE", "BLOG_ID", "POST_ID");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "C.ID", "TYPE" => "int"), "TITLE" => array("FIELD" => "C.TITLE", "TYPE" => "string"), "URL" => array("FIELD" => "C.URL", "TYPE" => "string"), "PREVIEW_TEXT" => array("FIELD" => "C.PREVIEW_TEXT", "TYPE" => "string"), "BLOG_NAME" => array("FIELD" => "C.BLOG_NAME", "TYPE" => "string"), "POST_DATE" => array("FIELD" => "C.POST_DATE", "TYPE" => "datetime"), "BLOG_ID" => array("FIELD" => "C.BLOG_ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "C.POST_ID", "TYPE" => "int"));
// <-- FIELDS
$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog_trackback C " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例12: 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();
示例13: GetList
//.........这里部分代码省略.........
"AUTHOR_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"AUTHOR_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"AUTHOR_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"AUTHOR_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"AUTHOR_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"AUTHOR" => array("FIELD" => "U.LOGIN, U.NAME, U.LAST_NAME, U.EMAIL, U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
"CATEGORY_NAME" => array("FIELD" => "PCN.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_category PCN ON (P.CATEGORY_ID = PCN.ID)"),
"CATEGORY_ID_F" => array("FIELD" => "PC.CATEGORY_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_post_category PC ON (PC.POST_ID = P.ID)"),
"BLOG_USER_ALIAS" => array("FIELD" => "BU.ALIAS", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_user BU ON (P.AUTHOR_ID = BU.USER_ID)"),
"BLOG_USER_AVATAR" => array("FIELD" => "BU.AVATAR", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_user BU ON (P.AUTHOR_ID = BU.USER_ID)"),
"BLOG_URL" => array("FIELD" => "B.URL", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_OWNER_ID" => array("FIELD" => "B.OWNER_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_ACTIVE" => array("FIELD" => "B.ACTIVE", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_GROUP_ID" => array("FIELD" => "B.GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_ENABLE_RSS" => array("FIELD" => "B.ENABLE_RSS", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_USE_SOCNET" => array("FIELD" => "B.USE_SOCNET", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_NAME" => array("FIELD" => "B.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"BLOG_GROUP_SITE_ID" => array("FIELD" => "BG.SITE_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_group BG ON (B.GROUP_ID = BG.ID)"),
"SOCNET_BLOG_READ" => array("FIELD" => "BSR.BLOG_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_socnet BSR ON (P.BLOG_ID = BSR.BLOG_ID)"),
"BLOG_SOCNET_GROUP_ID" => array("FIELD" => "B.SOCNET_GROUP_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (P.BLOG_ID = B.ID)"),
"SOCNET_GROUP_ID" => array("FIELD" => "SR1.ENTITY_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_socnet_rights SR1 ON (P.ID = SR1.POST_ID AND SR1.ENTITY_TYPE = 'SG')"),
"SOCNET_SITE_ID" => array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro', 'blog_post_important') AND BSL.SOURCE_ID = P.ID) ".
"LEFT JOIN b_sonet_log_site SLS ON BSL.ID = SLS.LOG_ID"),
"COMMENT_ID" => array("FIELD" => "PC.ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_comment PC ON (P.ID = PC.POST_ID)"),
);
foreach ($arFilter as $key => $val)
{
$key_res = CBlog::GetFilterOperation($key);
$k = $key_res["FIELD"];
if (strpos($k, "POST_PARAM_") === 0)
{
$user_id = 0; $ii++; $pref = "BPP".$ii;
if (is_array($val))
{
$user_id = (isset($val["USER_ID"]) ? intval($val["USER_ID"]) : 0);
$arFilter[$key] = $val["VALUE"];
}
$arSelectFields[] = $k;
$arFields[$k] = array("FIELD" => $pref.".VALUE", "TYPE" => "string",
"FROM" => "LEFT JOIN b_blog_post_param ".$pref." ON (P.ID = ".$pref.".POST_ID AND ".$pref.".USER_ID".
($user_id <= 0 ? " IS NULL" : "=".$user_id)." AND ".$pref.".NAME='".$GLOBALS["DB"]->ForSql(substr($k, 11), 50)."')");
}
}
if(isset($arFilter["GROUP_CHECK_PERMS"]))
{
if(is_array($arFilter["GROUP_CHECK_PERMS"]))
{
foreach($arFilter["GROUP_CHECK_PERMS"] as $val)
{
if(IntVal($val)>0)
{
$arFields["POST_PERM_".$val] = Array(
"FIELD" => "BUGP".$val.".PERMS",
"TYPE" => "string",
"FROM" => "LEFT JOIN b_blog_user_group_perms BUGP".$val."
ON (P.BLOG_ID = BUGP".$val.".BLOG_ID
AND P.ID = BUGP".$val.".POST_ID
AND BUGP".$val.".USER_GROUP_ID = ".$val."
AND BUGP".$val.".PERMS_TYPE = '".BLOG_PERMS_POST."')"
);
示例14: BuildRSS
public static function BuildRSS($postID, $blogID, $type = "RSS2.0", $numPosts = 10, $arPathTemplate = Array())
{
$blogID = IntVal($blogID);
$postID = IntVal($postID);
if($blogID <= 0)
return false;
if($postID <= 0)
return false;
$numPosts = IntVal($numPosts);
$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
if ($type != "rss.92" && $type != "atom.03")
$type = "rss2.0";
$rssText = False;
$arBlog = CBlog::GetByID($blogID);
if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y")
{
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if($arGroup["SITE_ID"] == SITE_ID)
{
$arPost = CBlogPost::GetByID($postID);
if(!empty($arPost) && $arPost["BLOG_ID"] == $arBlog["ID"] && $arPost["ENABLE_COMMENTS"] == "Y")
{
$now = date("r");
$nowISO = date("Y-m-d\TH:i:s").substr(date("O"), 0, 3).":".substr(date("O"), -2, 2);
$serverName = "";
$charset = "";
$language = "";
$dbSite = CSite::GetList(($b = "sort"), ($o = "asc"), array("LID" => SITE_ID));
if ($arSite = $dbSite->Fetch())
{
$serverName = $arSite["SERVER_NAME"];
$charset = $arSite["CHARSET"];
$language = $arSite["LANGUAGE_ID"];
}
if (strlen($serverName) <= 0)
{
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
$serverName = SITE_SERVER_NAME;
else
$serverName = COption::GetOptionString("main", "server_name", "");
}
if (strlen($charset) <= 0)
{
if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0)
$charset = SITE_CHARSET;
else
$charset = "windows-1251";
}
if(strlen($arPathTemplate["PATH_TO_BLOG"])>0)
$blogURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
else
$blogURL = htmlspecialcharsbx("http://".$serverName.CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"]));
if(strlen($arPathTemplate["PATH_TO_POST"])>0)
$url = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplate["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
else
$url = htmlspecialcharsbx("http://".$serverName.CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], $arGroup["SITE_ID"]));
$dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
$arUser = $dbUser->Fetch();
if($arPathTemplate["USE_SOCNET"] == "Y")
{
$blogName = GetMessage("BLG_GCM_RSS_TITLE_SOCNET", Array("#AUTHOR_NAME#" => htmlspecialcharsEx($arUser["NAME"]." ".$arUser["LAST_NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
}
else
{
$blogName = GetMessage("BLG_GCM_RSS_TITLE", Array("#BLOG_NAME#" => htmlspecialcharsEx($arBlog["NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
}
$rssText = "";
if ($type == "rss.92")
{
$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
$rssText .= "<rss version=\".92\">\n";
$rssText .= " <channel>\n";
$rssText .= " <title>".$blogName."</title>\n";
$rssText .= " <description>".$blogName."</description>\n";
$rssText .= " <link>".$url."</link>\n";
$rssText .= " <language>".$language."</language>\n";
$rssText .= " <docs>http://backend.userland.com/rss092</docs>\n";
$rssText .= "\n";
}
elseif ($type == "rss2.0")
{
$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
$rssText .= "<rss version=\"2.0\">\n";
$rssText .= " <channel>\n";
$rssText .= " <title>".$blogName."</title>\n";
$rssText .= " <description>".$blogName."</description>\n";
//$rssText .= " <guid>".$url."</guid>\n";
$rssText .= " <link>".$url."</link>\n";
$rssText .= " <language>".$language."</language>\n";
$rssText .= " <docs>http://backend.userland.com/rss2</docs>\n";
//.........这里部分代码省略.........
示例15: GetList
//.........这里部分代码省略.........
"FIELD" => "BUGP.PERMS",
"TYPE" => "string",
"FROM" => "LEFT JOIN b_blog_user_group_perms BUGP
ON (C.BLOG_ID = BUGP.BLOG_ID
AND C.POST_ID = BUGP.POST_ID
AND BUGP.USER_GROUP_ID = ".$arFilter["GROUP_CHECK_PERMS"]."
AND BUGP.PERMS_TYPE = '".BLOG_PERMS_COMMENT."')"
);
$arSelectFields[] = "POST_PERM_".$arFilter["GROUP_CHECK_PERMS"];
}
}
unset($arFilter["GROUP_CHECK_PERMS"]);
}
// rating variable
if (
in_array("RATING_TOTAL_VOTES", $arSelectFields) ||
in_array("RATING_TOTAL_POSITIVE_VOTES", $arSelectFields) ||
in_array("RATING_TOTAL_NEGATIVE_VOTES", $arSelectFields) ||
array_key_exists("RATING_TOTAL_VALUE", $arOrder) ||
array_key_exists("RATING_TOTAL_VOTES", $arOrder)
)
{
$arFields["RATING_TOTAL_VALUE"] = array("FIELD" => $DB->IsNull('RV.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
$arFields["RATING_TOTAL_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
$arFields["RATING_TOTAL_POSITIVE_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
$arFields["RATING_TOTAL_NEGATIVE_VOTES"] = array("FIELD" => $DB->IsNull('RV.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RV ON ( RV.ENTITY_TYPE_ID = 'BLOG_COMMENT' AND RV.ENTITY_ID = C.ID )");
}
$bNeedDistinct = false;
$blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog");
if ($blogModulePermissions < "W")
{
$arUserGroups = CBlogUser::GetUserGroups(($GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : 0), 0, "Y", BLOG_BY_USER_ID);
$strUserGroups = "0";
foreach($arUserGroups as $v)
$strUserGroups .= ",".IntVal($v);
$arFields["PERMS"] = array("FIELD" => "UGP.PERMS", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms UGP ON (C.POST_ID = UGP.POST_ID AND C.BLOG_ID = UGP.BLOG_ID AND UGP.USER_GROUP_ID IN (".$strUserGroups.") AND UGP.PERMS_TYPE = '".BLOG_PERMS_COMMENT."')");
$bNeedDistinct = true;
}
else
{
$arFields["PERMS"] = array("FIELD" => "'W'", "TYPE" => "string");
}
$arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
if(array_key_exists("FOR_USER", $arFilter))
{
if(IntVal($arFilter["FOR_USER"]) > 0) //authorized user
{
$arSqls["FROM"] .=
" INNER JOIN b_blog_socnet_rights SR ON (C.POST_ID = SR.POST_ID) " .
" LEFT JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = ".IntVal($arFilter["FOR_USER"]).") ";
if(strlen($arSqls["WHERE"]) > 0)
$arSqls["WHERE"] .= " AND ";
$arSqls["WHERE"] .= " (UA.USER_ID is not NULL OR SR.ENTITY = 'AU') ";
}
else
{
$arSqls["FROM"] .=
" INNER JOIN b_blog_socnet_rights SR ON (C.POST_ID = SR.POST_ID) ".
" INNER JOIN b_user_access UA ON (UA.ACCESS_CODE = SR.ENTITY AND UA.USER_ID = 0)";
}
$bNeedDistinct = true;
}