本文整理汇总了PHP中CVote::UserAlreadyVote方法的典型用法代码示例。如果您正苦于以下问题:PHP CVote::UserAlreadyVote方法的具体用法?PHP CVote::UserAlreadyVote怎么用?PHP CVote::UserAlreadyVote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVote
的用法示例。
在下文中一共展示了CVote::UserAlreadyVote方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strToUpper
$arParams["~" . strToUpper($URL) . "_TEMPLATE"] = $arParams[strToUpper($URL) . "_TEMPLATE"];
$arParams[strToUpper($URL) . "_TEMPLATE"] = htmlspecialcharsbx($arParams["~" . strToUpper($URL) . "_TEMPLATE"]);
}
/********************************************************************
/Input params
********************************************************************/
/********************************************************************
Data
********************************************************************/
$arResult["VOTES"] = array();
$arResult["NAV_STRING"] = "";
$db_res = GetVoteList($arParams["CHANNEL_SID"], array("bDescPageNumbering" => false, "nPageSize" => 10, "bShowAll" => false));
if ($db_res) {
$arResult["NAV_STRING"] = $db_res->GetPageNavString(GetMessage("VOTE_PAGES"));
while ($res = $db_res->Fetch()) {
$res["USER_ALREADY_VOTE"] = CVote::UserAlreadyVote($res["ID"], $_SESSION["VOTE_USER_ID"], $res["UNIQUE_TYPE"], $res["KEEP_IP_SEC"], $GLOBALS["USER"]->GetID()) ? "Y" : "N";
$res["URL"] = array("~VOTE_RESULT" => CComponentEngine::MakePathFromTemplate($arParams["~VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "~VOTE_FORM" => CComponentEngine::MakePathFromTemplate($arParams["~VOTE_FORM_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "VOTE_RESULT" => CComponentEngine::MakePathFromTemplate($arParams["VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $res["ID"])), "VOTE_FORM" => CComponentEngine::MakePathFromTemplate($arParams["VOTE_FORM_TEMPLATE"], array("VOTE_ID" => $res["ID"])));
$res["IMAGE"] = CFile::GetFileArray($res["IMAGE_ID"]);
// For custom
foreach ($res["URL"] as $key => $val) {
$res[$key . "_URL"] = $val;
}
$res["TITLE"] = htmlspecialcharsEx($res["TITLE"]);
if ($res['DESCRIPTION_TYPE'] == 'text') {
$res['DESCRIPTION'] = htmlspecialcharsbx($res['DESCRIPTION']);
}
$arResult["VOTES"][$res["ID"]] = $res;
}
}
/********************************************************************
/Data
示例2: KeepVoting
public static function KeepVoting()
{
global $DB, $VOTING_LAMP, $USER_ALREADY_VOTE, $USER_GROUP_PERMISSION, $USER;
$err_mess = CAllVote::err_mess() . "<br>Function: KeepVoting<br>Line: ";
$VOTING_LAMP = "green";
$USER_ALREADY_VOTE = "N";
$PUBLIC_VOTE_ID = intval($_REQUEST["PUBLIC_VOTE_ID"]);
$aMsg = array();
$VOTE_ID = 0;
$arVote = array();
$arQuestions = array();
if (!(!empty($_REQUEST["vote"]) && $PUBLIC_VOTE_ID > 0 && check_bitrix_sessid())) {
$aMsg[] = array("id" => "bad_params", "text" => GetMessage("VOTE_NOT_FOUND"));
} elseif (($VOTE_ID = intVal(GetVoteDataByID($PUBLIC_VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "N"))) && ($VOTE_ID <= 0 || $arVote["LAMP"] != "green")) {
$VOTING_LAMP = "red";
if ($VOTE_ID <= 0) {
$aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_NOT_FOUND"));
} else {
$aMsg[] = array("id" => "LAMP", "text" => GetMessage("VOTE_RED_LAMP"));
}
} elseif ($arChannel["USE_CAPTCHA"] == "Y" && !$USER->IsAuthorized()) {
include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/captcha.php";
$cpt = new CCaptcha();
if (!empty($_REQUEST["captcha_word"])) {
$captchaPass = COption::GetOptionString("main", "captcha_password", "");
if (!$cpt->CheckCodeCrypt($_REQUEST["captcha_word"], $_REQUEST["captcha_code"], $captchaPass)) {
$GLOBALS["BAD_CAPTCHA"] = "Y";
$aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("VOTE_BAD_CAPTCHA"));
}
} else {
if (!$cpt->CheckCode($_REQUEST["captcha_word"], 0)) {
$GLOBALS["NO_CAPTCHA"] = "Y";
$aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("VOTE_BAD_CAPTCHA"));
}
}
}
if (empty($aMsg)) {
// get user id
$_SESSION["VOTE_USER_ID"] = CVote::SetVoteUserID();
$GLOBALS["VOTING_ID"] = $VOTE_ID;
// check: can user vote
$UNIQUE_TYPE = $arVote["UNIQUE_TYPE"];
$KEEP_IP_SEC = $arVote["KEEP_IP_SEC"];
$CHANNEL_ID = $arVote["CHANNEL_ID"];
$StatusVote = CVote::UserAlreadyVote($VOTE_ID, $_SESSION["VOTE_USER_ID"], $UNIQUE_TYPE, $KEEP_IP_SEC, $USER->GetID());
$USER_ALREADY_VOTE = $StatusVote != false ? "Y" : "N";
$USER_GROUP_PERMISSION = CVote::UserGroupPermission($CHANNEL_ID);
// if user can vote that
if (($USER_ALREADY_VOTE == "N" || $StatusVote == 8 && $_REQUEST["REVOTE_ID"] == $VOTE_ID) && $USER_GROUP_PERMISSION >= 2) {
$arSqlAnswers = array();
// check answers
foreach ($arQuestions as $qID => $arQuestion) {
$arSqlAnswers[$arQuestion["ID"]] = array();
$bIndicators = array();
foreach ($arQuestion["ANSWERS"] as $arAnswer) {
switch ($arAnswer["FIELD_TYPE"]) {
case 0:
// radio
// radio
case 2:
// dropdown list
$fieldName = ($arAnswer["FIELD_TYPE"] == 0 ? "vote_radio_" : "vote_dropdown_") . $qID;
$aID = intval($GLOBALS[$fieldName]);
if (!isset($bIndicators[$fieldName]) && array_key_exists($aID, $arQuestion["ANSWERS"])) {
if (!empty($arAnswer['MESSAGE'])) {
$arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID);
}
$bIndicators[$fieldName] = "Y";
}
break;
case 1:
// checkbox
// checkbox
case 3:
// multiselect list
$fieldName = ($arAnswer["FIELD_TYPE"] == 1 ? "vote_checkbox_" : "vote_multiselect_") . $qID;
$res = $GLOBALS[$fieldName];
if (!isset($bIndicators[$fieldName]) && is_array($res) && !empty($res)) {
reset($res);
foreach ($res as $aID) {
if (array_key_exists($aID, $arQuestion["ANSWERS"])) {
$arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID);
}
}
$bIndicators[$fieldName] = "Y";
}
break;
case 4:
// field
// field
case 5:
// text
$aID = $arAnswer["ID"];
$fieldName = ($arAnswer["FIELD_TYPE"] == 4 ? "vote_field_" : "vote_memo_") . $aID;
$MESSAGE = trim($GLOBALS[$fieldName]);
if ($MESSAGE != "") {
$arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID, "MESSAGE" => "'" . $DB->ForSql(trim($MESSAGE), 2000) . "'");
}
break;
}
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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;
}
示例5: elseif
$arParams["PERMISSION"] = $arParams["PERMISSION"] === false ? CVoteChannel::GetGroupPermission($arResult["VOTE"]["CHANNEL_ID"]) : $arParams["PERMISSION"];
if ($arParams["PERMISSION"] <= 0) {
return false;
} elseif ($GLOBALS["VOTING_OK"] == "Y" && $GLOBALS["VOTING_ID"] == $arParams["VOTE_ID"] && !empty($arParams["VOTE_RESULT_TEMPLATE"])) {
$var = array("VOTE_ID", "VOTING_OK", "VOTE_SUCCESSFULL", "view_result", "view_form");
$url = CComponentEngine::MakePathFromTemplate($arParams["VOTE_RESULT_TEMPLATE"], array("VOTE_ID" => $arVote["ID"]));
if (strpos($url, "?") === false) {
$url .= "?";
} elseif (($token = substr($url, strpos($url, "?") + 1)) && !empty($token) && preg_match_all("/(?<=^|\\&)\\w+(?=\$|\\=)/is", $token, $matches)) {
$var = array_merge($var, $matches);
}
$strNavQueryString = DeleteParam($var);
LocalRedirect($url . "&VOTE_SUCCESSFULL=Y&VOTE_ID=" . intval($_REQUEST["VOTE_ID"]) . ($strNavQueryString != "" ? "&" : "") . $strNavQueryString);
}
$voteUserID = $_SESSION["VOTE_USER_ID"] ? $_SESSION["VOTE_USER_ID"] : intval($GLOBALS["APPLICATION"]->get_cookie("VOTE_USER_ID"));
$arParams["VOTED"] = CVote::UserAlreadyVote($arResult["VOTE_ID"], $voteUserID, $arResult["VOTE"]["UNIQUE_TYPE"], $arResult["VOTE"]["KEEP_IP_SEC"], $GLOBALS["USER"]->GetID());
$isUserCanVote = $arParams["VOTED"] == false;
$arParams["CAN_VOTE"] = $arResult["CAN_VOTE"] = $isUserCanVote && $arParams["PERMISSION"] > 1 ? "Y" : "N";
$arParams["CAN_REVOTE"] = $arParams["VOTED"] == 8 && $arParams["PERMISSION"] > 1 ? "Y" : "N";
$bShowResult = $arResult["VOTE"]["LAMP"] != "green" || $arParams["CAN_VOTE"] != "Y" && $arParams["CAN_REVOTE"] != "Y";
if (!$bShowResult) {
$bShowResult = $_REQUEST["view_result"] == "Y" || $GLOBALS["VOTING_OK"] == "Y" && $GLOBALS["VOTING_ID"] == $arResult["VOTE_ID"] || $GLOBALS["USER_ALREADY_VOTE"] == "Y" && $arParams["CAN_REVOTE"] != "Y" || $_REQUEST["VOTE_SUCCESSFULL"] == "Y" && $_REQUEST["VOTE_ID"] == $arResult["VOTE_ID"];
if ($_REQUEST["view_form"] == "Y") {
$bShowResult = false;
} else {
if (!$bShowResult) {
$bShowResult = $arParams["CAN_REVOTE"] == "Y";
if ($bShowResult && $GLOBALS["VOTING_ID"] == $arResult["VOTE"]["ID"] && $GLOBALS["VOTING_OK"] != "Y") {
$bShowResult = false;
}
}