本文整理汇总了PHP中CForumUser::GetFormattedNameFieldsForSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumUser::GetFormattedNameFieldsForSelect方法的具体用法?PHP CForumUser::GetFormattedNameFieldsForSelect怎么用?PHP CForumUser::GetFormattedNameFieldsForSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumUser
的用法示例。
在下文中一共展示了CForumUser::GetFormattedNameFieldsForSelect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetListEx
public static function GetListEx($arOrder = array("ID" => "ASC"), $arFilter = array(), $arAddParams = array())
{
global $DB;
$arSqlSearch = array();
$arSqlFrom = array();
$arSqlOrder = array();
$strSqlSearch = "";
$strSqlFrom = "";
$strSqlOrder = "";
$arFilter = is_array($arFilter) ? $arFilter : array();
foreach ($arFilter as $key => $val) {
$key_res = CForumNew::GetFilterOperation($key);
$key = strtoupper($key_res["FIELD"]);
$strNegative = $key_res["NEGATIVE"];
$strOperation = $key_res["OPERATION"];
switch ($key) {
case "TOPIC_ID":
case "FORUM_ID":
if (intVal($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL OR FSTAT." . $key . "<=0)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . intVal($val) . ")";
}
break;
case "SITE_ID":
$bOrNull = false;
if (is_array($val)) {
$res = array();
foreach ($val as $v) {
$v = trim($v);
if ($v == "NULL") {
$bOrNull = true;
} elseif (!empty($v)) {
$res[] = "'" . $DB->ForSql($v) . "'";
}
}
$val = !empty($res) ? implode(", ", $res) : "";
$strOperation = !empty($res) ? "IN" : $strOperation;
} else {
$val = "'" . $DB->ForSql($val) . "'";
}
if (strlen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL OR LENGTH(FSTAT." . $key . ")<=0)";
} elseif ($strOperation == "IN") {
$arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " IN (" . $val . ")" . ($bOrNull ? " OR (FSTAT." . $key . " IS NULL OR LENGTH(FSTAT." . $key . ")<=0)" : "") . ")";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . $val . ")";
}
break;
case "LAST_VISIT":
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT." . $key . " IS NULL)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FSTAT." . $key . " IS NULL OR NOT " : "") . "(FSTAT." . $key . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")";
}
break;
case "PERIOD":
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FSTAT.LAST_VISIT IS NULL)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FSTAT.LAST_VISIT IS NULL OR NOT " : "") . "(FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - " . intVal($val) . ") " . $strOperation . " FSTAT.LAST_VISIT)";
}
break;
case "HIDE_FROM_ONLINE":
$arSqlFrom["FU"] = "LEFT JOIN b_forum_user FU ON (FSTAT.USER_ID=FU.USER_ID)";
if (strLen($val) <= 0) {
$arSqlSearch[] = ($strNegative == "Y" ? "NOT" : "") . "(FU." . $key . " IS NULL OR LENGTH(FU." . $key . ")<=0)";
} else {
$arSqlSearch[] = ($strNegative == "Y" ? " FU." . $key . " IS NULL OR NOT " : "") . "(((FU." . $key . " " . $strOperation . " '" . $DB->ForSql($val) . "' ) AND (FSTAT.USER_ID > 0)) OR (FSTAT.USER_ID <= 0))";
}
break;
break;
case "ACTIVE":
$arSqlFrom["U"] = "LEFT JOIN b_user U ON (FSTAT.USER_ID=U.ID)";
$arSqlSearch[] = ($strNegative == "Y" ? " U." . $key . " IS NULL OR NOT " : "") . "(FSTAT.USER_ID = 0 OR U.ACTIVE = 'Y')";
break;
}
}
if (!empty($arSqlSearch)) {
$strSqlSearch = " AND " . implode(" AND ", $arSqlSearch) . " ";
}
if (!empty($arSqlFrom)) {
$strSqlFrom = implode("\n", $arSqlFrom);
}
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order);
$order = $order != "ASC" ? $order = "DESC" : "ASC";
if ($by == "USER_ID") {
$arSqlOrder[] = " FSTAT.USER_ID " . $order . " ";
}
}
DelDuplicateSort($arSqlOrder);
if (count($arSqlOrder) > 0) {
$strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
}
$strSql = "SELECT FSTAT.USER_ID, FSTAT.IP_ADDRESS, FSTAT.PHPSESSID, \n" . "\t" . $DB->DateToCharFunction("FSTAT.LAST_VISIT", "FULL") . " AS LAST_VISIT, \n" . "\tFSTAT.FORUM_ID, FSTAT.TOPIC_ID \n" . "FROM b_forum_stat FSTAT " . $strSqlFrom . "\n" . "WHERE 1=1 " . $strSqlSearch . "\n" . $strSqlOrder;
if (is_set($arFilter, "COUNT_GUEST")) {
$strSql = "SELECT FST.*, FU.*, FSTAT.IP_ADDRESS, FSTAT.PHPSESSID, \n" . "\t" . $DB->DateToCharFunction("FSTAT.LAST_VISIT", "FULL") . " AS LAST_VISIT, \n" . "\tFSTAT.FORUM_ID, FSTAT.TOPIC_ID, \n" . "\tU.LOGIN, U.NAME, U.SECOND_NAME, U.LAST_NAME, \n" . "\t" . (!empty($arAddParams["sNameTemplate"]) ? CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U.", "sForumUserTablePrefix" => "FU.", "sFieldName" => "SHOW_NAME")), false) : "FSTAT.SHOW_NAME") . "\n " . " FROM ( " . " SELECT FSTAT.USER_ID, MAX(FSTAT.ID) FST_ID, COUNT(FSTAT.PHPSESSID) COUNT_USER " . " FROM b_forum_stat FSTAT " . $strSqlFrom . " WHERE 1=1 " . $strSqlSearch . " GROUP BY FSTAT.USER_ID" . ") FST " . "LEFT JOIN b_forum_stat FSTAT ON (FST.FST_ID = FSTAT.ID) " . "LEFT JOIN b_forum_user FU ON (FST.USER_ID = FU.USER_ID) " . "LEFT JOIN b_user U ON (FST.USER_ID = U.ID) " . $strSqlOrder;
}
//.........这里部分代码省略.........
示例2: GetListEx
//.........这里部分代码省略.........
$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($ar_res = $db_res->Fetch())
{
$iLAST_MESSAGE_ID = intVal($ar_res["LAST_MESSAGE_ID"]);
}
}
}
// / This code exists because of http://bugs.mysql.com/bug.php?id=64002
if ($bCount === 4)
return array("CNT" => $iCnt, "LAST_MESSAGE_ID" => $iLAST_MESSAGE_ID);
if ($bCount)
return $iCnt;
}
if ($UseGroup)
{
$strSql =
"SELECT F_M.*, FM.FORUM_ID, FM.TOPIC_ID, FM.USE_SMILES, FM.NEW_TOPIC, \n".
" FM.APPROVED, FM.SOURCE_ID, \n".
" ".$DB->DateToCharFunction("FM.POST_DATE", "FULL")." as POST_DATE, \n".
" FM.POST_MESSAGE, FM.POST_MESSAGE_HTML, FM.POST_MESSAGE_FILTER, \n".
" FM.ATTACH_IMG, FM.XML_ID, FM.PARAM1, FM.PARAM2, \n".
" FM.AUTHOR_ID, FM.AUTHOR_NAME, FM.AUTHOR_EMAIL, \n".
" FM.AUTHOR_IP, FM.AUTHOR_REAL_IP, FM.GUEST_ID, \n".
" FM.EDITOR_ID, FM.EDITOR_NAME, FM.EDITOR_EMAIL, FM.EDIT_REASON, \n".
" ".$DB->DateToCharFunction("FM.EDIT_DATE", "FULL")." as EDIT_DATE, \n".
" FM.HTML, FM.MAIL_HEADER, \n".
" FU.SHOW_NAME, FU.DESCRIPTION, FU.NUM_POSTS, FU.POINTS as NUM_POINTS, FU.SIGNATURE, FU.AVATAR, \n".
" ".$DB->DateToCharFunction("FU.DATE_REG", "SHORT")." as DATE_REG, \n".
" U.LOGIN, U.NAME, U.SECOND_NAME, U.LAST_NAME, U.PERSONAL_PHOTO, FU.RANK_ID, U.PERSONAL_WWW, U.PERSONAL_GENDER, \n".
" U.EMAIL, U.PERSONAL_ICQ, U.PERSONAL_CITY, U.PERSONAL_COUNTRY".
(!empty($arAddParams["sNameTemplate"]) ?
",\n\t".CForumUser::GetFormattedNameFieldsForSelect(array_merge(
$arAddParams, array(
"sUserTablePrefix" => "U.",
"sForumUserTablePrefix" => "FU.",
"sFieldName" => "AUTHOR_NAME_FRMT")), false) : "")." \n".
"FROM ( \n".
" SELECT FM.ID".$strSqlSelect." \n".
" FROM b_forum_message FM \n".
" LEFT JOIN b_forum_user FU ON FM.AUTHOR_ID = FU.USER_ID \n".
" LEFT JOIN b_user U ON FM.AUTHOR_ID = U.ID \n".
" ".$strSqlFrom." \n".
" WHERE (1=1 ".$strSqlSearch.") \n".
" GROUP BY FM.ID".$strSqlGroup." \n".
" ) F_M \n".
" INNER JOIN b_forum_message FM ON (F_M.ID = FM.ID) \n".
" LEFT JOIN b_forum_user FU ON (FM.AUTHOR_ID = FU.USER_ID) \n".
" LEFT JOIN b_user U ON (FM.AUTHOR_ID = U.ID) \n".
$strSqlOrder;
}
else
{
$strSql =
"SELECT FM.ID, FM.FORUM_ID, FM.TOPIC_ID, FM.USE_SMILES, FM.NEW_TOPIC, \n".
" FM.APPROVED, FM.SOURCE_ID, \n".
" ".$DB->DateToCharFunction("FM.POST_DATE", "FULL")." as POST_DATE, \n".
" FM.POST_MESSAGE, FM.POST_MESSAGE_HTML, FM.POST_MESSAGE_FILTER, \n".
" FM.ATTACH_IMG, FM.XML_ID, FM.PARAM1, FM.PARAM2, \n".
" FM.AUTHOR_ID, FM.AUTHOR_NAME, FM.AUTHOR_EMAIL, \n".
" FM.AUTHOR_IP, FM.AUTHOR_REAL_IP, FM.GUEST_ID, \n".
" FM.EDITOR_ID, FM.EDITOR_NAME, FM.EDITOR_EMAIL, FM.EDIT_REASON, \n".
" ".$DB->DateToCharFunction("FM.EDIT_DATE", "FULL")." as EDIT_DATE, \n".
" FM.HTML, FM.MAIL_HEADER, \n".
" FU.SHOW_NAME, FU.DESCRIPTION, FU.NUM_POSTS, FU.POINTS as NUM_POINTS, FU.SIGNATURE, FU.AVATAR, \n".
示例3: GetByUSER_IDEx
public static function GetByUSER_IDEx($USER_ID, $arAddParams = array())
{
global $DB;
$arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
$USER_ID = intVal($USER_ID);
$strSql = "SELECT F_USER.*, FU.ID, FU.USER_ID, FU.SHOW_NAME, FU.DESCRIPTION, FU.IP_ADDRESS,\n " . "\tFU.REAL_IP_ADDRESS, FU.AVATAR, FU.NUM_POSTS, FU.POINTS as NUM_POINTS,\n " . "\tFU.INTERESTS, FU.HIDE_FROM_ONLINE, FU.SUBSC_GROUP_MESSAGE, FU.SUBSC_GET_MY_MESSAGE,\n " . "\tFU.LAST_POST, FU.ALLOW_POST, FU.SIGNATURE, FU.RANK_ID, FU.POINTS,\n " . "\t" . $DB->DateToCharFunction("FU.DATE_REG", "SHORT") . " as DATE_REG,\n " . "\t" . $DB->DateToCharFunction("FU.LAST_VISIT", "FULL") . " as LAST_VISIT,\n " . "\tU.EMAIL, U.NAME, U.SECOND_NAME, U.LAST_NAME, U.LOGIN, U.PERSONAL_BIRTHDATE,\n " . "\tU.PERSONAL_ICQ, U.PERSONAL_WWW, U.PERSONAL_PROFESSION,\n " . "\tU.PERSONAL_CITY, U.PERSONAL_COUNTRY, U.PERSONAL_PHOTO, U.PERSONAL_GENDER,\n " . "\t" . $DB->DateToCharFunction("U.PERSONAL_BIRTHDAY", "SHORT") . " as PERSONAL_BIRTHDAY " . (array_key_exists("SHOW_ABC", $arAddParams) || in_array("SHOW_ABC", $arAddParams) ? ", \n\t" . CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U.", "sForumUserTablePrefix" => "FU.", "sFieldName" => "SHOW_ABC"), false)) : "") . "\n" . " FROM b_forum_user FU \n" . " INNER JOIN b_user U ON (FU.USER_ID = U.ID) \n" . " LEFT JOIN ( \n" . "\t SELECT FM.AUTHOR_ID, MAX(FM.ID) AS LAST_MESSAGE_ID, COUNT(FM.ID) AS CNT \n" . "\t FROM b_forum_message FM \n" . "\t WHERE (FM.AUTHOR_ID = " . $USER_ID . " AND FM.APPROVED = 'Y') \n" . "\t GROUP BY FM.AUTHOR_ID \n" . "\t) F_USER ON (F_USER.AUTHOR_ID = FU.USER_ID) \n" . " WHERE (FU.USER_ID = " . $USER_ID . ")";
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($db_res && ($res = $db_res->Fetch())) {
return $res;
}
return False;
}
示例4: GetListEx
//.........这里部分代码省略.........
$arSqlFrom["FP"] = "LEFT JOIN b_forum_perms FP ON (FP.FORUM_ID=FT.FORUM_ID)";
$arSqlSearch[] = "FP.GROUP_ID IN (" . $DB->ForSql($USER->GetGroups()) . ") AND (FP.PERMISSION IN ('Q','U','Y'))";
$UseGroup = true;
break;
}
}
if (count($arSqlSearch) > 0) {
$strSqlSearch = " AND (" . implode(") AND (", $arSqlSearch) . ")";
}
if (count($arSqlSelect) > 0) {
$res = array();
foreach ($arSqlSelect as $key => $val) {
if (substr($key, 0, 1) == "!") {
$key = substr($key, 1);
}
if ($key != $val) {
$res[] = $val . " AS " . $key;
} else {
$res[] = $val;
}
}
$strSqlSelect = ", " . implode(", ", $res);
}
if (count($arSqlFrom) > 0) {
$strSqlFrom = implode("\n", $arSqlFrom);
}
if ($UseGroup) {
foreach ($arSqlSelect as $key => $val) {
if (substr($key, 0, 1) != "!") {
$arSqlGroup[$key] = $val;
}
}
if (!empty($arSqlGroup)) {
$strSqlGroup = ", " . implode(", ", $arSqlGroup);
}
}
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order);
if ($order != "ASC") {
$order = "DESC";
}
if (in_array($by, array("ID", "FORUM_ID", "TOPIC_ID", "TITLE", "TAGS", "DESCRIPTION", "ICON_ID", "STATE", "APPROVED", "SORT", "VIEWS", "USER_START_ID", "USER_START_NAME", "START_DATE", "POSTS", "LAST_POSTER_ID", "LAST_POSTER_NAME", "LAST_POST_DATE", "LAST_MESSAGE_ID", "POSTS_UNAPPROVED", "ABS_LAST_POSTER_ID", "ABS_LAST_POSTER_NAME", "ABS_LAST_POST_DATE", "ABS_LAST_MESSAGE_ID", "SOCNET_GROUP_ID", "OWNER_ID", "HTML", "XML_ID"))) {
$arSqlOrder[] = "FT." . $by . " " . $order;
} elseif ($by == "FORUM_NAME") {
$arSqlOrder[] = "F.NAME " . $order;
} else {
$arSqlOrder[] = "FT.SORT " . $order;
$by = "SORT";
}
}
$arSqlOrder = array_unique($arSqlOrder);
DelDuplicateSort($arSqlOrder);
if (count($arSqlOrder) > 0) {
$strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
}
if ($bCount || is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0) {
$strSql = "SELECT COUNT(FT.ID) as CNT FROM b_forum_topic FT ";
$arCountSqlFrom = $arSqlFrom;
if (isset($arSqlFrom['FUT']) && strpos($strSqlSearch, "FUT.") === false) {
unset($arCountSqlFrom['FUT']);
}
$strSqlCountFrom = implode("\n", $arCountSqlFrom);
$strSql .= $strSqlCountFrom . " WHERE 1 = 1 " . $strSqlSearch;
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$iCnt = 0;
if ($ar_res = $db_res->Fetch()) {
$iCnt = intVal($ar_res["CNT"]);
}
if ($bCount) {
return $iCnt;
}
}
$arSQL = array("select" => "", "join" => "");
if (!empty($arAddParams["sNameTemplate"])) {
$arSQL = array_merge_recursive(CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_START.", "sForumUserTablePrefix" => "FU_START.", "sFieldName" => "USER_START_NAME_FRMT", "sUserIDFieldName" => "FT.USER_START_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_LAST.", "sForumUserTablePrefix" => "FU_LAST.", "sFieldName" => "LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.LAST_POSTER_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_ABS_LAST.", "sForumUserTablePrefix" => "FU_ABS_LAST.", "sFieldName" => "ABS_LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.ABS_LAST_POSTER_ID"))));
$arSQL["select"] = ",\n\t" . implode(",\n\t", $arSQL["select"]);
$arSQL["join"] = "\n" . implode("\n", $arSQL["join"]);
}
if ($UseGroup) {
$strSql = " SELECT F_T.*, FT.FORUM_ID, FT.TOPIC_ID, FT.TITLE, FT.TAGS, FT.DESCRIPTION, FT.ICON_ID, \n" . "\tFT.STATE, FT.APPROVED, FT.SORT, FT.VIEWS, FT.USER_START_ID, FT.USER_START_NAME, \n" . "\t" . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . " as TITLE_SEO, \n" . "\t" . $DB->DateToCharFunction("FT.START_DATE", "FULL") . " as START_DATE, \n" . "\tFT.POSTS, FT.LAST_POSTER_ID, FT.LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE, \n" . "\tFT.LAST_POST_DATE AS LAST_POST_DATE_ORIGINAL, FT.LAST_MESSAGE_ID, \n" . "\tFT.POSTS_UNAPPROVED, FT.ABS_LAST_POSTER_ID, FT.ABS_LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE, \n" . "\tFT.ABS_LAST_POST_DATE AS ABS_LAST_POST_DATE_ORIGINAL, FT.ABS_LAST_MESSAGE_ID, \n" . "\tFT.SOCNET_GROUP_ID, FT.OWNER_ID, FT.HTML, FT.XML_ID, \n" . "\tF.NAME as FORUM_NAME, \n" . "\tFS.IMAGE, '' as IMAGE_DESCR " . $arSQL["select"] . " \n" . " FROM \n" . "\t( \n" . "\t\tSELECT FT.ID" . $strSqlSelect . " \n" . "\t\tFROM b_forum_topic FT \n" . "\t\t\tLEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . "\t\t\t" . $strSqlFrom . " \n" . "\t\tWHERE 1 = 1 " . $strSqlSearch . " \n" . "\t\tGROUP BY FT.ID" . $strSqlGroup . " \n" . "\t) F_T \n" . " INNER JOIN b_forum_topic FT ON (F_T.ID = FT.ID) \n" . " LEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . " LEFT JOIN b_forum_smile FS ON (FT.ICON_ID = FS.ID) " . $arSQL["join"] . " \n" . $strSqlOrder;
} else {
$strSql = " SELECT FT.ID, FT.FORUM_ID, FT.TOPIC_ID, FT.TITLE, FT.TAGS, FT.DESCRIPTION, FT.ICON_ID, \n" . "\tFT.STATE, FT.APPROVED, FT.SORT, FT.VIEWS, FT.USER_START_ID, FT.USER_START_NAME, \n" . "\t" . CForumNew::Concat("-", array("FT.ID", "FT.TITLE_SEO")) . " as TITLE_SEO, \n" . "\t" . $DB->DateToCharFunction("FT.START_DATE", "FULL") . " as START_DATE, \n" . "\tFT.POSTS, FT.LAST_POSTER_ID, FT.LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE, \n" . "\tFT.LAST_POST_DATE AS LAST_POST_DATE_ORIGINAL, FT.LAST_MESSAGE_ID, \n" . "\tFT.POSTS_UNAPPROVED, FT.ABS_LAST_POSTER_ID, FT.ABS_LAST_POSTER_NAME, \n" . "\t" . $DB->DateToCharFunction("FT.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE, \n" . "\tFT.ABS_LAST_POST_DATE AS ABS_LAST_POST_DATE_ORIGINAL, FT.ABS_LAST_MESSAGE_ID, \n" . "\tFT.SOCNET_GROUP_ID, FT.OWNER_ID, FT.HTML, FT.XML_ID, \n" . "\tF.NAME as FORUM_NAME, \n" . "\tFS.IMAGE, '' as IMAGE_DESCR" . $strSqlSelect . $arSQL["select"] . " \n" . " FROM b_forum_topic FT \n" . "\tLEFT JOIN b_forum F ON (FT.FORUM_ID = F.ID) \n" . "\tLEFT JOIN b_forum_smile FS ON (FT.ICON_ID = FS.ID) \n" . "\t" . $strSqlFrom . $arSQL["join"] . " \n" . " WHERE 1 = 1 " . $strSqlSearch . " \n" . $strSqlOrder;
}
$iNum = intVal($iNum);
if ($iNum > 0 || intVal($arAddParams["nTopCount"]) > 0) {
$iNum = $iNum > 0 ? $iNum : intVal($arAddParams["nTopCount"]);
$strSql .= "\nLIMIT 0," . $iNum;
}
if (!$iNum && is_set($arAddParams, "bDescPageNumbering") && intVal($arAddParams["nTopCount"]) <= 0) {
$db_res = new CDBResult();
$db_res->NavQuery($strSql, $iCnt, $arAddParams);
} else {
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
if (is_set($arAddParams, 'NoFilter') && $arAddParams['NoFilter'] == true) {
return $db_res;
}
return new _CTopicDBResult($db_res, $arAddParams);
}
示例5: GetByIDEx
function GetByIDEx($ID, $SITE_ID = false, $arAddParams = array())
{
global $DB, $CACHE_MANAGER;
$ID = intVal($ID);
$SITE_ID = $SITE_ID == false || empty($SITE_ID) ? false : $SITE_ID;
$key = $SITE_ID == false ? "EX" : "EX_PATH_" . strToUpper($SITE_ID);
$cache_id = "b_forum_" . $ID . strToLower($key);
if ($ID <= 0) {
return false;
} elseif (!is_array($GLOBALS["FORUM_CACHE"]["FORUM"][$ID])) {
$GLOBALS["FORUM_CACHE"]["FORUM"][$ID] = array();
}
if (!array_key_exists($key, $GLOBALS["FORUM_CACHE"]["FORUM"][$ID])) {
if (CACHED_b_forum !== false && $CACHE_MANAGER->Read(CACHED_b_forum, $cache_id, "b_forum")) {
$GLOBALS["FORUM_CACHE"]["FORUM"][$ID][$key] = $CACHE_MANAGER->Get($cache_id);
} else {
$arSQL = array("select" => "", "join" => "");
if (!empty($arAddParams["sNameTemplate"])) {
$arSQL = array_merge_recursive(CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_LAST.", "sForumUserTablePrefix" => "FU_LAST.", "sFieldName" => "LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "F.LAST_POSTER_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_ABS_LAST.", "sForumUserTablePrefix" => "FU_ABS_LAST.", "sFieldName" => "ABS_LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "F.ABS_LAST_POSTER_ID"))));
$arSQL["select"] = ",\n\t" . implode(",\n\t", $arSQL["select"]);
$arSQL["join"] = "\n" . implode("\n", $arSQL["join"]);
}
$strSql = "SELECT F.ID, F.NAME, F.DESCRIPTION, F.ACTIVE, F.MODERATION, F.INDEXATION, F.DEDUPLICATION,\n\t\t\t\t\t\tF.ALLOW_MOVE_TOPIC, '' as LID, F.TOPICS, F.POSTS, F.LAST_POSTER_ID, F.LAST_POSTER_NAME,\n\t\t\t\t\t\t" . $DB->DateToCharFunction("F.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE,\n\t\t\t\t\t\tF.LAST_MESSAGE_ID, FM.TOPIC_ID as TID, F.LAST_MESSAGE_ID as MID,\n\t\t\t\t\t\tF.POSTS_UNAPPROVED, F.ABS_LAST_POSTER_ID, F.ABS_LAST_POSTER_NAME,\n\t\t\t\t\t\t" . $DB->DateToCharFunction("F.ABS_LAST_POST_DATE", "FULL") . " as ABS_LAST_POST_DATE,\n\t\t\t\t\t\tF.ABS_LAST_MESSAGE_ID, FT.TITLE, F.SORT, '' as DIR, F.ORDER_BY, F.ORDER_DIRECTION,\n\t\t\t\t\t\tF.ALLOW_HTML, F.ALLOW_ANCHOR, F.ALLOW_BIU, F.ALLOW_TABLE, F.ALLOW_ALIGN, F.ALLOW_SIGNATURE,\n\t\t\t\t\t\tF.ALLOW_IMG, F.ALLOW_VIDEO, F.ALLOW_LIST, F.ALLOW_QUOTE, F.ALLOW_CODE, F.ALLOW_TOPIC_TITLED,\n\t\t\t\t\t\tF.ALLOW_FONT, F.ALLOW_SMILES, F.ALLOW_UPLOAD, F.EVENT1, F.EVENT2,\n\t\t\t\t\t\tF.EVENT3, F.ALLOW_NL2BR, " . (!$SITE_ID ? "''" : "FS.PATH2FORUM_MESSAGE") . " as PATH2FORUM_MESSAGE, F.ALLOW_UPLOAD_EXT,\n\t\t\t\t\t\tF.FORUM_GROUP_ID, F.ASK_GUEST_EMAIL, F.USE_CAPTCHA, F.HTML, FT.HTML AS TOPIC_HTML, F.XML_ID" . $arSQL["select"] . "\n\t\t\t\t\tFROM b_forum F\n\t\t\t\t\t\tLEFT JOIN b_forum_group FG ON (F.FORUM_GROUP_ID = FG.ID) " . (!$SITE_ID ? "" : "\n\t\t\t\t\t\tLEFT JOIN b_forum2site FS ON (F.ID = FS.FORUM_ID AND FS.SITE_ID = '" . $DB->ForSql($SITE_ID) . "') ") . $arSQL["join"] . "\n\t\t\t\t\t\tLEFT JOIN b_forum_message FM ON (F.LAST_MESSAGE_ID = FM.ID)\n\t\t\t\t\t\tLEFT JOIN b_forum_topic FT ON (FM.TOPIC_ID = FT.ID)\n\t\t\t\t\tWHERE (F.ID=" . $ID . ")";
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$db_res = new _CForumDBResult($db_res, $arAddParams);
$GLOBALS["FORUM_CACHE"]["FORUM"][$ID][$key] = $db_res->Fetch();
if (CACHED_b_forum !== false) {
$CACHE_MANAGER->Set($cache_id, $GLOBALS["FORUM_CACHE"]["FORUM"][$ID][$key]);
}
}
}
return $GLOBALS["FORUM_CACHE"]["FORUM"][$ID][$key];
}
示例6: GetByIDEx
function GetByIDEx($ID, $arAddParams = array())
{
global $DB;
$ID = intVal($ID);
if ($ID <= 0) {
return false;
}
$arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
$arAddParams["GET_FORUM_INFO"] = $arAddParams["GET_FORUM_INFO"] == "Y" ? "Y" : "N";
$arSQL = array("select" => array(), "join" => array());
if (!empty($arAddParams["sNameTemplate"])) {
$arSQL = array_merge_recursive(CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_START.", "sForumUserTablePrefix" => "FU_START.", "sFieldName" => "USER_START_NAME_FRMT", "sUserIDFieldName" => "FT.USER_START_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_LAST.", "sForumUserTablePrefix" => "FU_LAST.", "sFieldName" => "LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.LAST_POSTER_ID"))), CForumUser::GetFormattedNameFieldsForSelect(array_merge($arAddParams, array("sUserTablePrefix" => "U_ABS_LAST.", "sForumUserTablePrefix" => "FU_ABS_LAST.", "sFieldName" => "ABS_LAST_POSTER_NAME_FRMT", "sUserIDFieldName" => "FT.ABS_LAST_POSTER_ID"))));
}
if ($arAddParams["GET_FORUM_INFO"] == "Y") {
$arSQL["select"][] = CForumNew::GetSelectFields(array("sPrefix" => "F_", "sReturnResult" => "string"));
$arSQL["join"][] = "INNER JOIN b_forum F ON (FT.FORUM_ID = F.ID)";
}
$arSQL["select"] = !empty($arSQL["select"]) ? ",\n\t" . implode(",\n\t", $arSQL["select"]) : "";
$arSQL["join"] = !empty($arSQL["join"]) ? "\n\t" . implode("\n", $arSQL["join"]) : "";
$strSql = "SELECT FT.*,\n" . "\t" . $DB->DateToCharFunction("FT.START_DATE", "FULL") . " as START_DATE, \n" . "\t" . $DB->DateToCharFunction("FT.LAST_POST_DATE", "FULL") . " as LAST_POST_DATE, \n" . "\tFS.IMAGE, '' as IMAGE_DESCR" . $arSQL["select"] . "\n" . "FROM b_forum_topic FT \n" . "\tLEFT JOIN b_forum_smile FS ON (FT.ICON_ID = FS.ID)" . $arSQL["join"] . "\n" . "WHERE FT.ID = " . $ID;
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$db_res = new _CTopicDBResult($db_res);
}
if ($res = $db_res->Fetch()) {
if (is_array($res)) {
// Cache topic data for hits
if ($arAddParams["GET_FORUM_INFO"] == "Y") {
$res["TOPIC_INFO"] = array();
$res["FORUM_INFO"] = array();
foreach ($res as $key => $val) {
if (substr($key, 0, 2) == "F_") {
$res["FORUM_INFO"][substr($key, 2)] = $val;
} else {
$res["TOPIC_INFO"][$key] = $val;
}
}
if (!empty($res["TOPIC_INFO"])) {
$GLOBALS["FORUM_CACHE"]["TOPIC"][intVal($res["TOPIC_INFO"]["ID"])] = $res["TOPIC_INFO"];
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
$db_res_filter = new CDBResult();
$db_res_filter->InitFromArray(array($res["TOPIC_INFO"]));
$db_res_filter = new _CTopicDBResult($db_res_filter);
if ($res_filter = $db_res_filter->Fetch()) {
$GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][intVal($res["TOPIC_INFO"]["ID"])] = $res_filter;
}
}
}
if (!empty($res["FORUM_INFO"])) {
$GLOBALS["FORUM_CACHE"]["FORUM"][intVal($res["FORUM_INFO"]["ID"])] = $res["FORUM_INFO"];
}
}
}
return $res;
}
return false;
}