public static function GetByID($ID) { $ID = intval($ID); return CVote::GetList($by = "s_id", $order = "desc", array("ID" => $ID), $is_filtered = false); }
$lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(GetMessage("VOTE_SAVE_ERROR"), $ID); } } break; } } } /******************************************************************** /ACTIONS ********************************************************************/ /******************************************************************** Data ********************************************************************/ $rsData = CVote::GetList($by, $order, $arFilter, $is_filtered); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("VOTE_PAGES"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "s_id", "default" => true), array("id" => "LAMP", "content" => GetMessage("VOTE_LAMP"), "sort" => "s_lamp", "default" => true), array("id" => "DATE_START", "content" => GetMessage("VOTE_DATE_START"), "sort" => "s_date_start", "default" => true), array("id" => "DATE_END", "content" => GetMessage("VOTE_DATE_END"), "sort" => "s_date_end", "default" => true), array("id" => "CHANNEL_ID", "content" => GetMessage("VOTE_CHANNEL"), "sort" => "s_channel", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("VOTE_ACTIVE"), "sort" => "s_active", "default" => true), array("id" => "C_SORT", "content" => GetMessage("VOTE_C_SORT"), "sort" => "s_c_sort", "default" => true), array("id" => "TITLE", "content" => GetMessage("VOTE_TITLE"), "sort" => "s_title", "default" => true), array("id" => "QUESTIONS", "content" => GetMessage("VOTE_QUESTIONS"), "default" => true), array("id" => "COUNTER", "content" => GetMessage("VOTE_COUNTER"), "sort" => "s_counter", "default" => true))); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRes); $row->AddViewField("ID", "<a href='vote_edit.php?lang=" . LANGUAGE_ID . "&ID={$f_ID}' title='" . GetMessage("VOTE_EDIT_TITLE") . "'>{$f_ID}</a>"); if ($f_LAMP == "yellow") { $arRes["LAMP"] = $f_LAMP = $f_ID == CVote::GetActiveVoteId($arRes["CHANNEL_ID"]) ? "green" : "red"; } $lamp = $f_LAMP; if ($f_LAMP == "green") { $lamp = "<div class=\"lamp-green\" title=\"" . GetMessage("VOTE_LAMP_ACTIVE") . "\"></div>"; } elseif ($f_LAMP == "red") { $lamp = "<div class=\"lamp-red\" title=\"" . ($f_ACTIVE != 'Y' ? GetMessage("VOTE_NOT_ACTIVE") : GetMessage("VOTE_ACTIVE_RED_LAMP")) . "\"></div>";
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("vote")) { return; } $arrChannels = array(); $arrVotes = array(); $rs = CVoteChannel::GetList($v1, $v2, array(), $v3); while ($arChannel = $rs->Fetch()) { $arrChannels[$arChannel["SID"]] = "[" . $arChannel["SID"] . "] " . $arChannel["TITLE"]; $rsVotes = CVote::GetList($v1, $v2, array("CHANNEL_ID" => $arChannel["ID"]), $v3); while ($arVote = $rsVotes->Fetch()) { $arrVotes[$arVote["ID"]] = "[" . $arVote["ID"] . "] (" . $arChannel["SID"] . ") " . TruncateText($arVote["TITLE"], 40); } } $arComponentParameters = array("PARAMETERS" => array("VOTE_ID" => array("NAME" => GetMessage("VOTE_POLL_ID"), "TYPE" => "LIST", "PARENT" => "BASE", "VALUES" => $arrVotes, "DEFAULT" => '={$_REQUEST["VOTE_ID"]}', "MULTIPLE" => "N", "ADDITIONAL_VALUES" => "Y"), "VOTE_RESULT_TEMPLATE" => array("NAME" => GetMessage("VOTE_RESULT_PAGE"), "TYPE" => "STRING", "PARENT" => "URL_TEMPLATES", "COLS" => 45, "DEFAULT" => "vote_result.php?VOTE_ID=#VOTE_ID#"), "CACHE_TIME" => array("DEFAULT" => 3600)));
$arFields["LANG"][] = array("LID" => $lang, "NAME" => $name, "DESCRIPTION" => $description); } $arGroup[$key] = CForumGroup::Add($arFields); } } $arFieldsParams = array("SHOW_VOTE" => "N", "VOTE_CHANNEL_ID" => 0, "VOTE_GROUP_ID" => 0, "VOTE_ID" => 0, "FORUMS_ID" => ""); if (CModule::IncludeModule("vote")) { $db_res = CVoteChannel::GetList($by, $order, array('SYMBOLIC_NAME' => 'FORUM', 'SYMBOLIC_NAME_EXACT_MATCH' => 'Y'), $is_filtered); if ($db_res && ($res = $db_res->Fetch())) { $arFieldsParams = array("SHOW_VOTE" => "Y", "VOTE_CHANNEL_ID" => $res["ID"], "VOTE_GROUP_ID" => 0); //Registered users group $dbResult = CGroup::GetList($by, $order, array("STRING_ID" => "REGISTERED_USERS")); if ($dbResult && ($res = $dbResult->Fetch())) { $arFieldsParams["VOTE_GROUP_ID"] = $res["ID"]; } $db_res = CVote::GetList($by, $order, array("CHANNEL_ID" => $arFieldsParams["VOTE_CHANNEL_ID"]), $is_filtered); if ($db_res && ($res = $db_res->Fetch())) { $arFieldsParams["VOTE_ID"] = intVal($res["ID"]); } } } // Forums $arForums = array(); $arReplaceForums = array(); $db_res = CForumNew::GetList(array(), array("SITE_ID" => $SITE_ID)); if ($db_res && ($res = $db_res->Fetch())) { do { $arForums[$res["ID"]] = $res["NAME"]; } while ($res = $db_res->Fetch()); } // Forum № 1
function GetByID($ID) { $err_mess = CAllVote::err_mess() . "<br>Function: GetByID<br>Line: "; $ID = intval($ID); //if($ID<=0) //return false; $res = CVote::GetList($by = "s_id", $order = "desc", array("ID" => $ID), $is_filtered = false); return $res; }
function GetAnyAccessibleVote($site_id=SITE_ID, $channel_id=null) { $arParams = array("ACTIVE"=>"Y","SITE"=>$site_id); if ($channel_id !== null) { $arParams['SID'] = $channel_id; $arParams['SID_EXACT_MATCH'] = 'Y'; } $z = CVoteChannel::GetList($by="s_c_sort", $order="asc", $arParams, $is_filtered); $arResult = array(); while ($zr = $z->Fetch()) { $perm = CVoteChannel::GetGroupPermission($zr["ID"]); if (intval($perm)>=2) { $v = CVote::GetList($by, $order, array("CHANNEL_ID"=>$zr["ID"], "LAMP"=>"green"), $is_filtered); while ($vr = $v->Fetch()) { if (!(IsUserVoted($vr['ID']))) $arResult[] = $vr['ID']; } } } if (sizeof($arResult) > 0) return array_rand(array_flip($arResult)); return false; }
} /******************************************************************** /Input params ********************************************************************/ $obCache = new CPHPCache(); $cache_path = str_replace(array(":", "//"), "/", "/" . SITE_ID . "/" . $componentName . "/" . $arParams["CHANNEL_SID"] . "/"); $cache_id = "vote_current_" . serialize($arParams) . (($tzOffset = CTimeZone::GetOffset()) != 0 ? "_" . $tzOffset : ""); if (!$obCache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) { $arVote = array(); $db_res = false; if (!!$arParams["VOTE_ID"]) { $db_res = CVote::GetByIDEx($arParams["VOTE_ID"]); } else { $obChannel = CVoteChannel::GetList($by, $order, array("SID" => $arParams["CHANNEL_SID"], "SID_EXACT_MATCH" => "Y", "SITE" => SITE_ID, "ACTIVE" => "Y", "HIDDEN" => "N"), $is_filtered); if ($obChannel && ($arChannel = $obChannel->Fetch())) { $db_res = CVote::GetList($by, $order, array("CHANNEL_ID" => $arChannel["ID"], "LAMP" => "green"), $is_filtered); } } $arVote = $db_res ? $db_res->Fetch() : array(); if (empty($arVote) || $arVote["CHANNEL_ACTIVE"] != "Y" || $arVote["ACTIVE"] != "Y") { return false; } $arResult = array("VOTE" => $arVote, "VOTE_ID" => $arVote["ID"], "VOTE_RESULT_TEMPLATE" => $APPLICATION->GetCurPageParam("", array("VOTE_SUCCESSFULL", "VOTE_ID", "view_form")), "ADDITIONAL_CACHE_ID" => "current_vote"); $obCache->StartDataCache(); CVoteCacheManager::SetTag($cache_path, array("C" => $arVote["CHANNEL_ID"], "V" => $arVote["ID"])); $obCache->EndDataCache(array("arResult" => $arResult)); } else { $arVars = $obCache->GetVars(); $arResult = $arVars["arResult"]; $this->SetTemplateCachedData($arVars["templateCachedData"]); }
{ $channels[] = Array( "text" => $__arChannel["TITLE"], "url" => "vote_list.php?lang=".LANGUAGE_ID."&find_channel_id=".$__arChannel["ID"]."&set_filter=Y", "more_url" => Array(), "title" => GetMessage("VOTE_GROUP_LST").$__arChannel["TITLE"] ); } */ CModule::IncludeModule('vote'); $menuResults = array(); if (method_exists($this, "IsSectionActive") && $this->IsSectionActive("menu_vote_channels") || defined('BX_ADMIN_FORM_MENU_OPEN') && BX_ADMIN_FORM_MENU_OPEN == 1) { $by = "s_c_sort"; $order = "asc"; $rChannels = CVoteChannel::GetList($by, $order, $arFilter, $is_filtered); while ($arChannel = $rChannels->Fetch()) { if (intval($arChannel["VOTES"]) > 0) { $menuChannel = array("text" => htmlspecialcharsEx($arChannel["TITLE"]), "url" => "vote_user_votes_table.php?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arChannel['ID'], "module_id" => "vote", "page_icon" => "vote_page_icon", "items_id" => "vote_channel_" . $arChannel["ID"], "items" => array()); $obVote = CVote::GetList($by, $order, array("CHANNEL_ID" => $arChannel["ID"]), $is_filtered); while ($arVote = $obVote->GetNext()) { $menuVote = array("items_id" => "vote_channel_" . $arChannel["ID"], "text" => $arVote["TITLE"], "title" => GetMessage("VOTE_MENU_POLL_DESCRIPTION") . '\'' . htmlspecialcharsEx($arVote["TITLE"]) . '\'', "module_id" => "vote", "url" => "vote_user_votes_table.php?lang=" . LANGUAGE_ID . "&VOTE_ID=" . $arVote['ID']); $menuChannel["items"][] = $menuVote; } $menuResults[] = $menuChannel; } } } $aMenu = array("parent_menu" => "global_menu_services", "section" => "vote", "sort" => 100, "module_id" => "vote", "text" => GetMessage("VOTE_MENU_MAIN"), "title" => GetMessage("VOTE_MENU_MAIN_TITLE"), "icon" => "vote_menu_icon", "page_icon" => "vote_page_icon", "items_id" => "menu_vote", "items" => array(array("text" => GetMessage("VOTE_MENU_CHANNEL"), "url" => "vote_channel_list.php?lang=" . LANGUAGE_ID, "title" => GetMessage("VOTE_MENU_CHANNEL_ALT"), "more_url" => array("vote_channel_edit.php")), array("text" => GetMessage("VOTE_MENU_VOTE"), "url" => "vote_list.php?lang=" . LANGUAGE_ID, "more_url" => array("vote_edit.php", "vote_question_list.php", "vote_question_edit.php", "vote_results.php", "vote_preview.php"), "title" => GetMessage("VOTE_MENU_VOTE_ALT")), array("text" => GetMessage("VOTE_MENU_USER"), "url" => "vote_user_list.php?lang=" . LANGUAGE_ID, "more_url" => array(), "title" => GetMessage("VOTE_MENU_USER_ALT")), array("text" => GetMessage("VOTE_MENU_RESULT"), "items_id" => "menu_vote_channels", "module_id" => "vote", "url" => "vote_user_votes.php?lang=" . LANGUAGE_ID, "dynamic" => true, "more_url" => array("vote_user_results.php", "vote_user_results_table.php"), "title" => GetMessage("VOTE_MENU_RESULT_ALT"), "items" => $menuResults))); return $aMenu; } return false;