当前位置: 首页>>代码示例>>PHP>>正文


PHP CVote::SetVoteUserID方法代码示例

本文整理汇总了PHP中CVote::SetVoteUserID方法的典型用法代码示例。如果您正苦于以下问题:PHP CVote::SetVoteUserID方法的具体用法?PHP CVote::SetVoteUserID怎么用?PHP CVote::SetVoteUserID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVote的用法示例。


在下文中一共展示了CVote::SetVoteUserID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
                     }
//.........这里部分代码省略.........
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:vote.php


注:本文中的CVote::SetVoteUserID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。