本文整理匯總了PHP中CVote::GetByID方法的典型用法代碼示例。如果您正苦於以下問題:PHP CVote::GetByID方法的具體用法?PHP CVote::GetByID怎麽用?PHP CVote::GetByID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CVote
的用法示例。
在下文中一共展示了CVote::GetByID方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: VoteVoteEditFromArray
function VoteVoteEditFromArray($CHANNEL_ID, $VOTE_ID = false, $arFields = array(), $params = array())
{
$CHANNEL_ID = intVal($CHANNEL_ID);
if ($CHANNEL_ID <= 0 || empty($arFields)) {
return false;
} elseif (CVote::UserGroupPermission($CHANNEL_ID) <= 0) {
return false;
}
$aMsg = array();
$params = is_array($params) ? $params : array();
$params["UNIQUE_TYPE"] = is_set($params, "UNIQUE_TYPE") ? intVal($params["UNIQUE_TYPE"]) : 20;
$params["DELAY"] = is_set($params, "DELAY") ? intVal($params["DELAY"]) : 10;
$params["DELAY_TYPE"] = is_set($params, "DELAY_TYPE") && in_array($params['DELAY_TYPE'], array("S", "M", "H", "D")) ? $params["DELAY_TYPE"] : "D";
$arVote = array();
$arQuestions = array();
$arFieldsQuestions = array();
$arFieldsVote = array("CHANNEL_ID" => $CHANNEL_ID, "AUTHOR_ID" => $GLOBALS["USER"]->GetID(), "UNIQUE_TYPE" => $params["UNIQUE_TYPE"], "DELAY" => $params["DELAY"], "DESCRIPTION_TYPE" => $params["DELAY_TYPE"]);
if (!empty($arFields["DATE_START"])) {
$arFieldsVote["DATE_START"] = $arFields["DATE_START"];
}
if (!empty($arFields["DATE_END"])) {
$arFieldsVote["DATE_END"] = $arFields["DATE_END"];
}
if (!empty($arFields["TITLE"])) {
$arFieldsVote["TITLE"] = $arFields["TITLE"];
}
if (isset($arFields["ACTIVE"])) {
$arFieldsVote["ACTIVE"] = $arFields["ACTIVE"];
}
if (isset($arFields["NOTIFY"])) {
$arFieldsVote["NOTIFY"] = $arFields["NOTIFY"];
}
if (isset($arFields["URL"])) {
$arFieldsVote["URL"] = $arFields["URL"];
}
/************** Fatal errors ***************************************/
if (!CVote::CheckFields("UPDATE", $arFieldsVote)) {
$e = $GLOBALS['APPLICATION']->GetException();
$aMsg[] = array("id" => "VOTE_ID", "text" => $e->GetString());
} elseif (intval($VOTE_ID) > 0) {
$db_res = CVote::GetByID($VOTE_ID);
if (!($db_res && ($res = $db_res->Fetch()))) {
$aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_VOTE_NOT_FOUND", array("#ID#", $VOTE_ID)));
} elseif ($res["CHANNEL_ID"] != $CHANNEL_ID) {
$aMsg[] = array("id" => "CHANNEL_ID", "text" => GetMessage("VOTE_CHANNEL_ID_ERR"));
} else {
$arVote = $res;
$db_res = CVoteQuestion::GetList($arVote["ID"], $by = "s_id", $order = "asc", array(), $is_filtered);
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arQuestions[$res["ID"]] = $res + array("ANSWERS" => array());
} while ($res = $db_res->Fetch());
}
$db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arVote["ID"]));
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
} while ($res = $db_res->Fetch());
}
}
}
if (!empty($aMsg)) {
$e = new CAdminException(array_reverse($aMsg));
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
/************** Fatal errors/***************************************/
if (!empty($arFieldsVote["TITLE"]) && !empty($arVote["TITLE"])) {
$q = reset($arQuestions);
if ($arVote["TITLE"] == substr($q["QUESTION"], 0, strlen($arVote["TITLE"]))) {
unset($arFieldsVote["TITLE"]);
}
}
/************** Check Data *****************************************/
// Questions
$arFields["QUESTIONS"] = is_array($arFields["QUESTIONS"]) ? $arFields["QUESTIONS"] : array();
$iQuestions = 0;
foreach ($arFields["QUESTIONS"] as $key => $arQuestion) {
if ($arQuestion["DEL"] != "Y") {
$arQuestion["ID"] = intval($arQuestion["ID"]);
$arQuestion = array("ID" => $arQuestion["ID"] > 0 && is_set($arQuestions, $arQuestion["ID"]) ? $arQuestion["ID"] : false, "QUESTION" => trim($arQuestion["QUESTION"]), "ANSWERS" => is_array($arQuestion["ANSWERS"]) ? $arQuestion["ANSWERS"] : array());
$arAnswers = $arQuestion["ID"] > 0 ? $arQuestions[$arQuestion["ID"]]["ANSWERS"] : array();
foreach ($arQuestion["ANSWERS"] as $keya => $arAnswer) {
$arAnswer["ID"] = intVal($arAnswer["ID"]);
$arAnswer["MESSAGE"] = trim($arAnswer["MESSAGE"]);
if (!empty($arAnswer["MESSAGE"]) && $arAnswer["DEL"] != "Y") {
$arQuestion["ANSWERS"][$keya] = array("MESSAGE" => $arAnswer["MESSAGE"], "FIELD_TYPE" => $arAnswer["FIELD_TYPE"]);
if ($arAnswer["ID"] > 0 && is_set($arAnswers, $arAnswer["ID"])) {
$arQuestion["ANSWERS"][$keya]["ID"] = $arAnswer["ID"];
unset($arAnswers[$arAnswer["ID"]]);
}
}
}
}
if ($arQuestion["DEL"] == "Y" || empty($arQuestion["QUESTION"]) || empty($arQuestion["ANSWERS"])) {
if ($arQuestion["DEL"] != "Y" && !(empty($arQuestion["QUESTION"]) && empty($arQuestion["ANSWERS"]))) {
$aMsg[] = array("id" => "QUESTION_" . $key, "text" => empty($arQuestion["QUESTION"]) ? GetMessage("VOTE_QUESTION_EMPTY", array("#NUMBER#" => $key)) : GetMessage("VOTE_ANSWERS_EMPTY", array("#QUESTION#" => $arQuestion["QUESTION"])));
}
continue;
}
//.........這裏部分代碼省略.........
示例2: UserAlreadyVote
public static function UserAlreadyVote($VOTE_ID, $VOTE_USER_ID, $UNIQUE_TYPE, $KEEP_IP_SEC, $USER_ID = false)
{
global $DB, $USER;
$err_mess = CAllVote::err_mess() . "<br>Function: UserAlreadyVote<br>Line: ";
$VOTE_ID = intval($VOTE_ID);
$UNIQUE_TYPE = intval($UNIQUE_TYPE);
$VOTE_USER_ID = intval($VOTE_USER_ID);
$USER_ID = intval($USER_ID);
if ($VOTE_ID <= 0) {
return false;
}
if ($UNIQUE_TYPE <= 0) {
return false;
}
if ($UNIQUE_TYPE > 4) {
$UNIQUE_TYPE -= 5;
}
//No restrictions
if ($UNIQUE_TYPE <= 0) {
return false;
}
//One session
if ($UNIQUE_TYPE & 1 && IsModuleInstalled('statistic') && is_array($_SESSION["VOTE_ARRAY"]) && in_array($VOTE_ID, $_SESSION["VOTE_ARRAY"])) {
return 1;
}
$arSqlSearch = array();
$arSqlSelect = array("VE.ID");
//Same cookie
if ($UNIQUE_TYPE & 2) {
if ($VOTE_USER_ID > 0 && $UNIQUE_TYPE != 6) {
$arSqlSelect[] = "VE.VOTE_USER_ID";
$arSqlSearch[] = "VE.VOTE_USER_ID='" . $VOTE_USER_ID . "'";
}
}
// Same IP
if ($UNIQUE_TYPE & 4) {
$tmp = CVote::CheckVotingIP($VOTE_ID, $_SERVER["REMOTE_ADDR"], $KEEP_IP_SEC, array("RETURN_SEARCH_ARRAY" => "Y"));
if (is_array($tmp)) {
$arSqlSelect[] = $tmp["select"];
$arSqlSearch[] = $tmp["search"];
} else {
return 4;
}
}
// Same ID
if ($UNIQUE_TYPE & 8) {
if ($USER_ID <= 0 || $USER_ID == $USER->GetID() && !!$_SESSION["VOTE"]["VOTES"][$VOTE_ID]) {
return 8;
} else {
if ($UNIQUE_TYPE & 16) {
$rUser = CUser::GetByID($USER_ID);
if ($rUser && ($arUser = $rUser->Fetch())) {
$userRegister = MakeTimeStamp($arUser['DATE_REGISTER']);
$rVote = CVote::GetByID($VOTE_ID);
if ($rVote && ($arVote = $rVote->Fetch())) {
$voteStart = MakeTimeStamp($arVote['DATE_START']);
if ($userRegister > $voteStart) {
return 16;
}
}
}
}
$arSqlSelect[] = "VU.AUTH_USER_ID";
$arSqlSearch[] = "VU.AUTH_USER_ID=" . $USER_ID;
}
}
if (!empty($arSqlSearch)) {
$strSql = "SELECT " . implode(",", $arSqlSelect) . "\n\t\t\t\tFROM b_vote_event VE\n\t\t\t\tLEFT JOIN b_vote_user VU ON (VE.VOTE_USER_ID = VU.ID)\n\t\t\t\tWHERE VE.VOTE_ID=" . $VOTE_ID . " AND ((" . implode(") OR (", $arSqlSearch) . "))";
$db_res = $DB->Query($strSql, false, $err_mess . __LINE__);
if ($db_res && ($res = $db_res->Fetch())) {
$return = 16;
$event_id = 0;
do {
if ($UNIQUE_TYPE & 2 && $res["VOTE_USER_ID"] == $VOTE_USER_ID) {
$return = min($return, 2);
break;
} elseif ($UNIQUE_TYPE & 4 && $res["IP"] == $_SERVER["REMOTE_ADDR"] && ($KEEP_IP_SEC <= 0 || $KEEP_IP_SEC > $res["KEEP_IP_SEC"])) {
$return = min($return, 4);
} elseif ($UNIQUE_TYPE & 8 && $res["AUTH_USER_ID"] == $USER_ID) {
$return = min($return, 8);
$event_id = $event_id > 0 && $USER_ID == $USER->GetID() ? $event_id : intval($res["ID"]);
}
} while ($res = $db_res->Fetch());
if ($event_id > 0) {
$_SESSION["VOTE"]["VOTES"][$VOTE_ID] = $event_id;
}
return $return != 16 ? $return : true;
}
}
return false;
}
示例3: IncludeModuleLangFile
global $APPLICATION, $DB, $adminChain, $CACHE_MANAGER;
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/prolog.php";
$VOTE_RIGHT = $APPLICATION->GetGroupRight("vote");
if ($VOTE_RIGHT == "D") {
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/include.php";
IncludeModuleLangFile(__FILE__);
define("HELP_FILE", "vote_list.php");
$sTableID = "tbl_vote_question";
$oSort = new CAdminSorting($sTableID, "ID", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$aMenu = array();
$VOTE_ID = intval($_REQUEST["VOTE_ID"]);
$z = CVote::GetByID($VOTE_ID);
if (!($arVote = $z->Fetch())) {
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
echo "<a href='vote_list.php?lang=" . LANGUAGE_ID . "' class='navchain'>" . GetMessage("VOTE_VOTE_LIST") . "</a>";
echo ShowError(GetMessage("VOTE_NOT_FOUND"));
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
$t = CVoteChannel::GetByID($arVote["CHANNEL_ID"]);
$arChannel = $t->Fetch();
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arChannel["TITLE"]), "LINK" => "vote_channel_edit.php?ID={$arChannel['ID']}&lang=" . LANGUAGE_ID));
$adminChain->AddItem(array("TEXT" => strlen($arVote["TITLE"]) > 0 ? htmlspecialcharsbx($arVote["TITLE"]) : TruncateText($arVote["DESCRIPTION_TYPE"] == "html" ? strip_tags($arVote["DESCRIPTION"]) : htmlspecialcharsbx($arVote["DESCRIPTION"]), 200), "LINK" => "vote_edit.php?ID={$arVote['ID']}&lang=" . LANGUAGE_ID));
$arFilterFields = array("find_id", "find_id_exact_match", "find_active", "find_diagram", "find_required", "find_question", "find_question_exact_match");
$lAdmin->InitFilter($arFilterFields);
/********************************************************************
Actions
示例4: ShowError
if (empty($arMessage)) {
ShowError(GetMessage("F_ERROR_MESSAGE_NOT_FOUND"));
return 0;
}
$arResult["TOPIC"] = $arMessage["TOPIC_INFO"];
$arResult["TOPIC_FILTER"] = CForumTopic::GetByID($arMessage["TOPIC_ID"]);
$arResult["MESSAGE"] = $arMessage;
$arResult["MESSAGE"]["FILES"] = array();
$db_res = CForumFiles::GetList(array(), array("MESSAGE_ID" => $arParams["MID"]));
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arResult["MESSAGE"]["FILES"][$res["FILE_ID"]] = $res;
} while ($res = $db_res->Fetch());
}
if ($arParams["SHOW_VOTE"] == "Y" && $arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0) {
$db_vote = CVote::GetByID(intVal($arMessage["PARAM2"]));
if ($db_vote && ($arVote = $db_vote->GetNext())) {
$arResult['DATE_END'] = $arVote['DATE_END'];
}
$db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["VOTE_CHANNEL_ID"], "VOTE_ID" => $arMessage["PARAM2"]));
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arResult["~QUESTIONS"][$res["ID"]] = $res;
$arResult["~QUESTIONS"][$res["ID"]]["ANSWERS"] = array();
} while ($res = $db_res->Fetch());
}
if (!empty($arResult["~QUESTIONS"])) {
$db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arMessage["PARAM2"]));
if ($db_res && ($res = $db_res->Fetch())) {
do {
if (is_set($arResult["~QUESTIONS"], $res["QUESTION_ID"])) {
示例5: LocalRedirect
}
}
if (!empty($save)) {
if (!empty($_REQUEST["return_url"])) {
LocalRedirect($_REQUEST["return_url"]);
}
LocalRedirect("vote_list.php?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arFields["CHANNEL_ID"]);
}
LocalRedirect($APPLICATION->GetCurPage() . "?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arFields["CHANNEL_ID"] . "&ID=" . $ID . "&" . $tabControl->ActiveTabParam() . (!empty($_REQUEST["return_url"]) ? "&return_url=" . urlencode($_REQUEST["return_url"]) : ""));
}
}
/********************************************************************
/ACTIONS
********************************************************************/
if ($ID > 0) {
$db_res = CVote::GetByID($ID);
if ($db_res && ($res = $db_res->Fetch())) {
$arVote = $res;
$arChannel = $arChannels[$arVote["CHANNEL_ID"]];
} else {
$ID = 0;
}
}
if ($ID <= 0) {
$arChannel = current($arChannels);
reset($arChannels);
$arVote = array("CHANNEL_ID" => isset($_REQUEST['CHANNEL_ID']) && intval($_REQUEST['CHANNEL_ID']) > 0 ? intval($_REQUEST['CHANNEL_ID']) : $arChannel["ID"], "C_SORT" => CVote::GetNextSort($arChannel["ID"]), "ACTIVE" => "Y", "DATE_START" => $arChannel["VOTE_SINGLE"] != "N" ? CVote::GetNextStartDate($arChannel["ID"]) : "", "UNIQUE_TYPE" => 12, "DELAY" => 10, "DELAY_TYPE" => "M", "DESCRIPTION_TYPE" => "html", "IMAGE_ID" => 0, "EVENT1" => "vote", "EVENT2" => strtolower($arChannel["SYMBOLIC_NAME"]), "TEMPLATE" => "default.php");
}
if ($bVarsFromForm) {
if (!empty($arVote["IMAGE_ID"])) {
unset($arFields["IMAGE_ID"]);
示例6: intVal
$VOTE_ID = intVal($arQuestion["VOTE_ID"]);
$db_res = CVoteAnswer::GetList($ID);
if ($db_res && ($res = $db_res->Fetch())) {
do {
$arAnswers[$ii] = $res;
$ii++;
} while ($res = $db_res->Fetch());
}
}
}
if ($ID <= 0) {
$arQuestion = array("ACTIVE" => "Y", "VOTE_ID" => $VOTE_ID, "C_SORT" => CVoteQuestion::GetNextSort($VOTE_ID), "QUESTION" => "", "QUESTION_TYPE" => "html", "IMAGE_ID" => "", "DIAGRAM" => "Y", "REQUIRED" => "N", "DIAGRAM_TYPE" => VOTE_DEFAULT_DIAGRAM_TYPE, "TEMPLATE" => "default.php", "TEMPLATE_NEW" => "default.php");
}
$VOTE_ID = intVal($VOTE_ID);
$arVote = array();
$db_res = CVote::GetByID($VOTE_ID);
if (!($db_res && ($arVote = $db_res->Fetch()))) {
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
echo "<a href='vote_list.php?lang=" . LANGUAGE_ID . "' class='navchain'>" . GetMessage("VOTE_VOTE_LIST") . "</a>";
echo ShowError(GetMessage("VOTE_NOT_FOUND"));
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
$arVote["TITLE"] = strlen($arVote["TITLE"]) > 0 ? $arVote["TITLE"] : TruncateText($arVote["DESCRIPTION_TYPE"] == "html" ? strip_tags($arVote["DESCRIPTION"]) : $arVote["DESCRIPTION"], 200);
$db_res = CVoteChannel::GetByID($arVote["CHANNEL_ID"]);
$arChannel = $db_res->Fetch();
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arChannel["TITLE"]), "LINK" => "vote_channel_edit.php?ID={$arChannel['ID']}&lang=" . LANGUAGE_ID));
$adminChain->AddItem(array("TEXT" => htmlspecialcharsbx($arVote["TITLE"]), "LINK" => "vote_edit.php?ID={$arVote['ID']}&lang=" . LANGUAGE_ID));
$sDocTitle = $ID > 0 ? str_replace("#ID#", $ID, GetMessage("VOTE_EDIT_RECORD")) : GetMessage("VOTE_NEW_RECORD");
$APPLICATION->SetTitle($sDocTitle);
/********************************************************************
示例7: IsUserVoted
function IsUserVoted($PUBLIC_VOTE_ID)
{
global $USER, $APPLICATION;
$PUBLIC_VOTE_ID = intval($PUBLIC_VOTE_ID);
if ($PUBLIC_VOTE_ID <= 0)
return false;
$res = CVote::GetByID($PUBLIC_VOTE_ID);
if($res && ($arVote = $res->GetNext(true, false)))
{
$VOTE_USER_ID = intval($APPLICATION->get_cookie("VOTE_USER_ID"));
$res = CVote::UserAlreadyVote($arVote["ID"], $VOTE_USER_ID, $arVote["UNIQUE_TYPE"], $arVote["KEEP_IP_SEC"], $USER->GetID());
return ($res != false);
}
return false;
}
示例8: IsUserVoted
function IsUserVoted($PUBLIC_VOTE_ID)
{
$PUBLIC_VOTE_ID = intval($PUBLIC_VOTE_ID);
if ($PUBLIC_VOTE_ID <= 0) {
return false;
}
$res = CVote::GetByID($PUBLIC_VOTE_ID);
if ($res && ($arVote = $res->GetNext(true, false))) {
$VOTE_USER_ID = intval($GLOBALS["APPLICATION"]->get_cookie("VOTE_USER_ID"));
$res = CVote::UserAlreadyVote($arVote["ID"], $VOTE_USER_ID, $arVote["UNIQUE_TYPE"], $arVote["KEEP_IP_SEC"], $GLOBALS["USER"]->GetID());
return $res != false;
}
return false;
}