function CheckFields($arUserField, $value) { if (!($arUserField && is_array($arUserField["USER_TYPE"]) && $arUserField["USER_TYPE"]["CLASS_NAME"] == __CLASS__)) return true; $arData = (isset($GLOBALS[$arUserField["FIELD_NAME"]."_DATA"]) ? $GLOBALS[$arUserField["FIELD_NAME"]."_DATA"] : false); $aMsg = array(); if (!empty($arData) && CModule::IncludeModule("vote")) { $arVote = array( "ID" => $value, "CHANNEL_ID" => $arUserField["SETTINGS"]["CHANNEL_ID"], "TITLE" => $arData["TITLE"], "URL" => $arData["URL"], "NOTIFY" => $arUserField["SETTINGS"]["NOTIFY"], "DATE_END" => GetTime((isset($arData["DATE_END"]) ? MakeTimeStamp($arData["DATE_END"]) : 1924984799), "FULL"), "QUESTIONS" => array()); $arVoteQuestions = array(); $arQuestions = is_array($arData["QUESTIONS"]) ? $arData["QUESTIONS"] : array(); if (!$arVote["ID"]) { $arVote["DATE_START"] = GetTime(CVote::GetNowTime(), "FULL"); } else { $db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arVote["CHANNEL_ID"], "VOTE_ID" => $arVote["ID"])); if ($db_res && $res = $db_res->Fetch()) { do { $arVoteQuestions[$res["ID"]] = $res + array("ANSWERS" => array()); } while ($res = $db_res->Fetch()); } if (!empty($arVoteQuestions)) { $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arVote["CHANNEL_ID"], "VOTE_ID" => $arVote["ID"])); if ($db_res && $res = $db_res->Fetch()) { do { if (is_set($arVoteQuestions, $res["QUESTION_ID"])) $arVoteQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res; } while ($res = $db_res->Fetch()); } } } foreach ($arQuestions as $key => $arQuestion) { $res = array( "ID" => (array_key_exists($arQuestion["ID"], $arVoteQuestions) ? $arQuestion["ID"] : false), "QUESTION" => trim($arQuestion["QUESTION"]), "MULTI" => ($arQuestion["MULTI"] == "Y" ? "Y" : "N"), "ANSWERS" => array()); $arQuestion["ANSWERS"] = (is_array($arQuestion["ANSWERS"]) ? $arQuestion["ANSWERS"] : array()); $arVoteAnswers = ($res["ID"] > 0 ? $arVoteQuestions[$res["ID"]]["ANSWERS"] : array()); foreach ($arQuestion["ANSWERS"] as $arAnswer) { $resa = array( "ID" => (array_key_exists($arAnswer["ID"], $arVoteAnswers) ? $arAnswer["ID"] : false), "MESSAGE" => trim($arAnswer["MESSAGE"]), "FIELD_TYPE" => ($res["MULTI"] == "Y" ? 1 : 0)); if (empty($resa["MESSAGE"])){ continue; } if (!!$resa["ID"]) { unset($arVoteAnswers[$resa["ID"]]); } $res["ANSWERS"][] = $resa; } foreach ($arVoteAnswers as $arAnswer) { $res["ANSWERS"][] = array_merge($arAnswer, array("DEL" => "Y")); } if (empty($res["ANSWERS"]) && empty($res["QUESTION"]) && !$res["ID"]) { continue; } if (!!$res["ID"]) { unset($arVoteQuestions[$res["ID"]]); } $arVote["QUESTIONS"][] = $res; } $arVoteParams = array(); if (!empty($arVote["QUESTIONS"])) { $arVoteParams = array( "UNIQUE_TYPE" => $arUserField["SETTINGS"]['UNIQUE'], "DELAY" => intval($arUserField["SETTINGS"]['UNIQUE_IP_DELAY']["DELAY"]), "DELAY_TYPE" => $arUserField["SETTINGS"]['UNIQUE_IP_DELAY']["DELAY_TYPE"]); } if (!VoteVoteEditFromArray($arUserField["SETTINGS"]["CHANNEL_ID"], $arVote["ID"], $arVote, ($res = ($arVoteParams + array("bOnlyCheck" => "Y"))))) { $aMsg[] = array( "id" => $arUserField["FIELD_NAME"], "text" => (($e = $GLOBALS['APPLICATION']->GetException()) && $e ? preg_replace("/\<br(.*?)\>/", " ", $e->GetString()) : GetMessage("VT_UNKNOWN_ERROR_ADD_VOTE")) ); } else { $GLOBALS[__CLASS__.$arUserField["ENTITY_VALUE_ID"]] = array("VOTE" => $arVote, "PARAMS" => $arVoteParams); } } return $aMsg; }
$arResult["CONTROL_UID"] = md5(randString(15)); $arResult["VOTES"] = array(); if ($arParams["bVarsFromForm"]) { $arResult["VOTES"] = is_array($_POST[$arParams["~INPUT_NAME"]]) ? $_POST[$arParams["~INPUT_NAME"] . "_DATA"] : array($_POST[$arParams["~INPUT_NAME"] . "_DATA"]); } else { if (!empty($arParams["INPUT_VALUE"])) { $db_res = CVote::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@ID" => $arParams["INPUT_VALUE"])); while ($res = $db_res->Fetch()) { $arResult["VOTES"][$res["ID"]] = $res + array("QUESTIONS" => array()); } if (!empty($arResult["VOTES"])) { $db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@VOTE_ID" => array_keys($arResult["VOTES"]))); while ($res = $db_res->Fetch()) { $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["ID"]] = $res + array("ANSWERS" => array()); } $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["CHANNEL_ID"], "ACTIVE" => "Y", "@VOTE_ID" => array_keys($arResult["VOTES"]))); while ($res = $db_res->Fetch()) { if ($res["FIELD_TYPE"] == 1) { $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["QUESTION_ID"]]["MULTI"] = "Y"; } $arResult["VOTES"][$res["VOTE_ID"]]["QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res; } } } } if (!empty($arResult["VOTES"])) { function htmlspecialcharsmix(&$mixed) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { if (is_string($value)) {
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; } if ($arQuestion["ID"] > 0) { unset($arQuestions[$arQuestion["ID"]]); foreach ($arAnswers as $arAnswer) { $arQuestion["ANSWERS"][] = $arAnswer + array("DEL" => "Y"); } } $iQuestions++; $arFieldsQuestions[$key] = $arQuestion; } foreach ($arQuestions as $arQuestion) { $arFieldsQuestions[] = $arQuestion + array("DEL" => "Y"); } if (!empty($aMsg)) { $e = new CAdminException(array_reverse($aMsg)); $GLOBALS["APPLICATION"]->ThrowException($e); return false; } elseif (empty($arFieldsQuestions) && $VOTE_ID <= 0) { return true; } elseif ($params["bOnlyCheck"] == "Y") { return true; } /************** Check Data/*****************************************/ /************** Main actions with return ***************************/ if (empty($arFieldsVote["TITLE"])) { $q = reset($arFieldsQuestions); $arFieldsVote["TITLE"] = null; do { if ($q["DEL"] != "Y") { $arFieldsVote["TITLE"] = $q["QUESTION"]; break; } } while ($q = next($arFieldsQuestions)); reset($arFieldsQuestions); } if (empty($arVote)) { $arFieldsVote["UNIQUE_TYPE"] = $params["UNIQUE_TYPE"]; $arFieldsVote["DELAY"] = $params["DELAY"]; $arFieldsVote["DELAY_TYPE"] = $params["DELAY_TYPE"]; $arVote["ID"] = intval(CVote::Add($arFieldsVote)); } else { CVote::Update($VOTE_ID, $arFieldsVote); } if ($iQuestions > 0 && $arVote["ID"] > 0) { $iQuestions = 0; foreach ($arFieldsQuestions as $arQuestion) { if ($arQuestion["DEL"] == "Y") { CVoteQuestion::Delete($arQuestion["ID"]); continue; } elseif ($arQuestion["ID"] > 0) { $arQuestion["C_SORT"] = ($iQuestions + 1) * 10; CVoteQuestion::Update($arQuestion["ID"], $arQuestion); } else { $arQuestion["C_SORT"] = ($iQuestions + 1) * 10; $arQuestion["VOTE_ID"] = $arVote["ID"]; $arQuestion["ID"] = intVal(CVoteQuestion::Add($arQuestion)); if ($arQuestion["ID"] <= 0) { continue; } } $iQuestions++; $iAnswers = 0; foreach ($arQuestion["ANSWERS"] as $arAnswer) { if ($arAnswer["DEL"] == "Y") { CVoteAnswer::Delete($arAnswer["ID"]); continue; } if ($arAnswer["ID"] > 0) { $arAnswer["C_SORT"] = $iAnswers * 10; CVoteAnswer::Update($arAnswer["ID"], $arAnswer); } else { $arAnswer["QUESTION_ID"] = $arQuestion["ID"]; $arAnswer["C_SORT"] = ($iAnswers + 1) * 10; $arAnswer["ID"] = intVal(CVoteAnswer::Add($arAnswer)); if ($arAnswer["ID"] <= 0) { continue; } } $iAnswers++; } if ($iAnswers <= 0) { CVoteQuestion::Delete($arQuestion["ID"]); $iQuestions--; } } } if (intVal($arVote["ID"]) <= 0) { return false; } elseif ($iQuestions <= 0) { CVote::Delete($arVote["ID"]); return 0; } return $arVote["ID"]; /************** Actions/********************************************/ /* $arFields = array( "ID" => 345, "TITLE" => "test", "...", "QUESTIONS" => array( array( "ID" => 348, "QUESTION" => "test", "ANSWERS" => array( array( "ID" => 340, "MESSAGE" => "test"), array( "ID" => 0, "MESSAGE" => "test"), array( "ID" => 350, "DEL" => "Y", "MESSAGE" => "test") ) ), array( "ID" => 351, "DEL" => "Y", "QUESTION" => "test", "ANSWERS" => array( array( "ID" => 0, "MESSAGE" => "test"), array( "ID" => 478, "DEL" => "Y", "MESSAGE" => "test") ) ), array( "ID" => 0, "QUESTION" => "test", "ANSWERS" => array( array( "ID" => 0, "MESSAGE" => "test"), ) ), ) ); */ }
} elseif ($arParams["MODE"] != "GROUP" && $res["FORUM_ID"] != $arParams["FID"]) { $arError[] = array("id" => "mid_is_lost", "text" => GetMessage("F_MID_IS_LOST_IN_FORUM")); } elseif ($arParams["MODE"] == "GROUP" && $res["TOPIC_INFO"]["SOCNET_GROUP_ID"] == $arParams["SOCNET_GROUP_ID"] || $arParams["MODE"] != "GROUP" && $res["TOPIC_INFO"]["OWNER_ID"] == $arParams["USER_ID"]) { $arResult["MESSAGE"] = $res; $arParams["TID"] = $res["TOPIC_INFO"]["ID"]; $arResult["TOPIC"] = $res["TOPIC_INFO"]; $arResult["TOPIC_FILTER"] = CForumTopic::GetByID($arParams["TID"]); if ($arParams["SHOW_VOTE"] == "Y" && $arResult["MESSAGE"]["PARAM1"] == "VT" && intVal($arResult["MESSAGE"]["PARAM2"]) > 0) { $db_res = CVoteQuestion::GetListEx(array("ID" => "ASC"), array("CHANNEL_ID" => $arParams["VOTE_CHANNEL_ID"], "VOTE_ID" => $arResult["MESSAGE"]["PARAM2"])); if ($db_res && ($res = $db_res->Fetch())) { do { $arResult["~QUESTIONS"][$res["ID"]] = $res + array("ANSWERS" => array()); } while ($res = $db_res->Fetch()); } if (!empty($arResult["~QUESTIONS"])) { $db_res = CVoteAnswer::GetListEx(array("ID" => "ASC"), array("VOTE_ID" => $arResult["MESSAGE"]["PARAM2"])); if ($db_res && ($res = $db_res->Fetch())) { do { if (is_set($arResult["~QUESTIONS"], $res["QUESTION_ID"])) { $arResult["~QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res; } } while ($res = $db_res->Fetch()); } } $arResult["QUESTIONS"] = $arResult["~QUESTIONS"]; } } else { $arError[] = array("id" => "mid_is_lost", "text" => GetMessage("F_MID_IS_LOST")); } } /************** Permission *****************************************/
} 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"])) { $arResult["~QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res; if (intVal($res["FIELD_TYPE"]) == 1) { $arResult["~QUESTIONS"][$res["QUESTION_ID"]]["MULTI"] = "Y"; } } } while ($res = $db_res->Fetch()); } } $arResult["QUESTIONS"] = $arResult["~QUESTIONS"]; } } if ($arParams["bVarsFromForm"] == "Y") {
function GetVoteDataByID($VOTE_ID, &$arChannel, &$arVote, &$arQuestions, &$arAnswers, &$arDropDown, &$arMultiSelect, &$arGroupAnswers, $arAddParams = "N") { $VOTE_ID = intval($VOTE_ID); $arChannel = array(); $arVote = array(); $arQuestions = array(); $arAnswers = array(); $arDropDown = array(); $arMultiSelect = array(); $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID] = (is_array($GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]) ? $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID] : array()); if (empty($GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID])) { $db_res = CVote::GetByIDEx($VOTE_ID); if (!($db_res && $arVote = $db_res->GetNext())) { return false; } foreach ($arVote as $key => $res) { if (strpos($key, "CHANNEL_") === 0) { $arChannel[substr($key, 8)] = $res; } elseif (strpos($key, "~CHANNEL_") === 0) { $arChannel["~".substr($key, 9)] = $res; } } $by = "s_c_sort"; $order = "asc"; $db_res = CVoteQuestion::GetList($VOTE_ID, $by, $order, array("ACTIVE" => "Y"), $is_filtered); while ($res = $db_res->GetNext()) { $arQuestions[$res["ID"]] = $res + array("ANSWERS" => array()); } if (!empty($arQuestions)) { $db_res = CVoteAnswer::GetListEx( array("C_SORT" => "ASC"), array("VOTE_ID" => $VOTE_ID, "ACTIVE" => "Y", "@QUESTION_ID" => array_keys($arQuestions))); while ($res = $db_res->GetNext()) { $arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res; $arAnswers[$res["QUESTION_ID"]][] = $res; switch ($res["FIELD_TYPE"]) // dropdown and multiselect and text inputs { case 2: $arDropDown[$res["QUESTION_ID"]] = (is_array($arDropDown[$res["QUESTION_ID"]]) ? $arDropDown[$res["QUESTION_ID"]] : array("reference" => array(), "reference_id" => array(), "~reference" => array())); $arDropDown[$res["QUESTION_ID"]]["reference"][] = $res["MESSAGE"]; $arDropDown[$res["QUESTION_ID"]]["~reference"][] = $res["~MESSAGE"]; $arDropDown[$res["QUESTION_ID"]]["reference_id"][] = $res["ID"]; break; case 3: $arMultiSelect[$res["QUESTION_ID"]] = (is_array($arMultiSelect[$res["QUESTION_ID"]]) ? $arMultiSelect[$res["QUESTION_ID"]] : array("reference" => array(), "reference_id" => array(), "~reference" => array())); $arMultiSelect[$res["QUESTION_ID"]]["reference"][] = $res["MESSAGE"]; $arMultiSelect[$res["QUESTION_ID"]]["~reference"][] = $res["~MESSAGE"]; $arMultiSelect[$res["QUESTION_ID"]]["reference_id"][] = $res["ID"]; break; } } $event_id = intval($arAddParams["bRestoreVotedData"] == "Y" && !!$_SESSION["VOTE"]["VOTES"][$VOTE_ID] ? $_SESSION["VOTE"]["VOTES"][$VOTE_ID] : 0); $db_res = CVoteEvent::GetUserAnswerStat($VOTE_ID, array("bGetMemoStat" => "N", "bGetEventResults" => $event_id)); if ($db_res && ($res = $db_res->Fetch())) { do { if (isset($arQuestions[$res["QUESTION_ID"]]) && is_array($arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]) && is_array($res)) { $arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]] += $res; if ($event_id > 0 && !empty($res["RESTORED_ANSWER_ID"])) { switch ($arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]["FIELD_TYPE"]): case 0: // radio case 2: // dropdown list $fieldName = ($arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]["FIELD_TYPE"] == 0 ? "vote_radio_" : "vote_dropdown_").$res["QUESTION_ID"]; $_REQUEST[$fieldName] = $res["RESTORED_ANSWER_ID"]; break; case 1: // checkbox case 3: // multiselect list $fieldName = ($arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]["FIELD_TYPE"] == 1 ? "vote_checkbox_" : "vote_multiselect_").$res["QUESTION_ID"]; $_REQUEST[$fieldName] = (is_array($_REQUEST[$fieldName]) ? $_REQUEST[$fieldName] : array()); $_REQUEST[$fieldName][] = $res["ANSWER_ID"]; break; case 4: // field case 5: // text // do not restored break; endswitch; } } } while ($res = $db_res->Fetch()); } } reset($arChannel); reset($arVote); reset($arQuestions); reset($arDropDown); reset($arMultiSelect); reset($arAnswers); $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID] = array( "V" => $arVote, "C" => $arChannel, "QA" => array( "Q" => $arQuestions, "A" => $arAnswers, "M" => $arMultiSelect, "D" => $arDropDown, "G" => array(), "GA" => "N" ) ); } if ($arAddParams["bGetMemoStat"] == "Y" && $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["GA"] == "N") { $db_res = CVoteEvent::GetUserAnswerStat($VOTE_ID, array("bGetMemoStat" => "Y")); while($res = $db_res->GetNext(true, false)) { $arGroupAnswers[$res['ANSWER_ID']][] = $res; } $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["G"] = $arGroupAnswers; $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["GA"] = "Y"; } $arVote = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["V"]; $arChannel = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["C"]; $arQuestions = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["Q"]; $arAnswers = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["A"]; $arMultiSelect = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["M"]; $arDropDown = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["D"]; $arGroupAnswers = $GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]["QA"]["G"]; return $arVote["ID"]; }