public static function GetDropDownList() { global $DB; $err_mess = CVoteChannel::err_mess() . "<br>Function: GetDropDownList<br>Line: "; $strSql = "\n\t\t\tSELECT\n\t\t\t\tID as REFERENCE_ID,\n\t\t\t\tconcat('[',ID,'] ',TITLE) as REFERENCE\n\t\t\tFROM b_vote_channel\n\t\t\tORDER BY C_SORT\n\t\t\t"; $res = $DB->Query($strSql, false, $err_mess . __LINE__); return $res; }
function GetDropDownList() { global $DB; $err_mess = CVoteChannel::err_mess() . "<br>Function: GetDropDownList<br>Line: "; $strSql = "\r\n\t\t\tSELECT\r\n\t\t\t\tID as REFERENCE_ID,\r\n\t\t\t\t'['+convert(varchar(8000),ID)+'] '+TITLE as REFERENCE\r\n\t\t\tFROM b_vote_channel\r\n\t\t\tORDER BY C_SORT\t\t\t\t\r\n\t\t\t"; $res = $DB->Query($strSql, false, $err_mess . __LINE__); return $res; }
public static function GetList(&$by, &$order, $arFilter = array(), &$is_filtered) { $err_mess = CVoteChannel::err_mess() . "<br>Function: GetList<br>Line: "; global $DB; $arSqlSearch = array(); $left_join = ""; if (is_array($arFilter)) { foreach ($arFilter as $key => $val) { if (is_array($val)) { if (count($val) <= 0) { continue; } } else { if (strlen($val) <= 0 || $val === "NOT_REF") { continue; } } $match_value_set = array_key_exists($key . "_EXACT_MATCH", $arFilter); $key = strtoupper($key); switch ($key) { case "ID": $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N"; $arSqlSearch[] = GetFilterQuery("C.ID", $val, $match); break; case "SITE_ID": case "SITE": if (is_array($val)) { $val = implode(" | ", $val); } $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N"; $arSqlSearch[] = GetFilterQuery("CS.SITE_ID", $val, $match); $left_join = "LEFT JOIN b_vote_channel_2_site CS ON (C.ID = CS.CHANNEL_ID)"; break; case "TITLE": $match = $arFilter[$key . "_EXACT_MATCH"] == "Y" && $match_value_set ? "N" : "Y"; $arSqlSearch[] = GetFilterQuery("C.TITLE", $val, $match); break; case "SID": case "SYMBOLIC_NAME": $match = $arFilter[$key . "_EXACT_MATCH"] == "Y" && $match_value_set ? "N" : "Y"; $arSqlSearch[] = GetFilterQuery("C.SYMBOLIC_NAME", $val, $match); break; case "HIDDEN": case "ACTIVE": $arSqlSearch[] = $val == "Y" ? "C." . $key . "='Y'" : "C." . $key . "='N'"; break; case "FIRST_SITE_ID": case "LID": $match = $arFilter[$key . "_EXACT_MATCH"] == "N" && $match_value_set ? "Y" : "N"; $arSqlSearch[] = GetFilterQuery("C.FIRST_SITE_ID", $val, $match); break; } } } if ($by == "s_id") { $strSqlOrder = "ORDER BY C.ID"; } elseif ($by == "s_timestamp") { $strSqlOrder = "ORDER BY C.TIMESTAMP_X"; } elseif ($by == "s_c_sort") { $strSqlOrder = "ORDER BY C.C_SORT"; } elseif ($by == "s_active") { $strSqlOrder = "ORDER BY C.ACTIVE"; } elseif ($by == "s_hidden") { $strSqlOrder = "ORDER BY C.HIDDEN"; } elseif ($by == "s_symbolic_name") { $strSqlOrder = "ORDER BY C.SYMBOLIC_NAME"; } elseif ($by == "s_title") { $strSqlOrder = "ORDER BY C.TITLE "; } elseif ($by == "s_votes") { $strSqlOrder = "ORDER BY VOTES"; } else { $by = "s_id"; $strSqlOrder = "ORDER BY C.ID"; } if ($order != "asc") { $strSqlOrder .= " desc "; $order = "desc"; } $strSqlSearch = GetFilterSqlSearch($arSqlSearch); $strSql = "\n\t\tSELECT CC.*, C.*, C.FIRST_SITE_ID LID, C.SYMBOLIC_NAME SID,\n\t\t\t\t" . $DB->DateToCharFunction("C.TIMESTAMP_X") . " TIMESTAMP_X\n\t\tFROM (\n\t\t\tSELECT C.ID, count(V.ID) VOTES\n\t\t\tFROM b_vote_channel C\n\t\t\t\tLEFT JOIN b_vote V ON (V.CHANNEL_ID = C.ID)\n\t\t\t\t" . $left_join . "\n\t\t\tWHERE " . $strSqlSearch . "\n\t\t\tGROUP BY C.ID) CC\n\t\tINNER JOIN b_vote_channel C ON (C.ID = CC.ID)\n\t\t" . $strSqlOrder; $is_filtered = IsFiltered($strSqlSearch); if (VOTE_CACHE_TIME === false || strpos($_SERVER['REQUEST_URI'], '/bitrix/admin/') !== false) { $res = $DB->Query($strSql, false, $err_mess . __LINE__); return $res; } else { global $CACHE_MANAGER; $md5 = md5($strSql); $arCache = array(); if ($CACHE_MANAGER->Read(VOTE_CACHE_TIME, "b_vote_channel_" . $md5, "b_vote_channel")) { $arCache = $CACHE_MANAGER->Get("b_vote_channel_" . $md5); } else { $res = $DB->Query($strSql, false, $err_mess . __LINE__); while ($ar = $res->Fetch()) { $arCache[] = $ar; } $CACHE_MANAGER->Set("b_vote_channel_" . $md5, $arCache); } $r = new CDBResult(); $r->InitFromArray($arCache); unset($arCache); return $r; } }