GetVoteDataByID
GetVoteDataByID( int VOTE_ID, array &arChannel, array &arVote, array &arQuestions, array &arAnswers, array &arDropDown, array &arMultiSelect, array &arGroupAnswers, string getGroupAnswers )
The function returns information describing the poll by its ID.
Parameters
Parameter | Description |
---|---|
VOTE_ID | Vote (poll) ID. |
arChannel | Array describing the channel of the poll. The array has the following keys.
|
arVote | Array describing the specified poll. The array has the following keys.
|
arQuestions | Array of arrays each describing a single question. The arrays has the following keys.
|
arAnswers | Arrays of answers. Each key of the array is a question ID. Each value is a
list of arrays each describing a single answer. Each array has the following keys.
|
arDropDown | Array describing all controls of the type "2" (drop-down list).
Keys are the question ID's. Values are arrays with the following keys:
|
arMultiSelect | Array describing all controls of the type "3" (multiselect list).
Keys are the question ID's. Values are arrays with the following keys:
|
arGroupAnswers | Array describing variants of answer of all controls of the type
"4" (text) and "5" (textarea). Keys are the question
ID's. Values are arrays with the following keys:
|
getGroupAnswers | Specifies whether the array arGroupAnswers is to be returned. If set to "Y", the function GetVoteDataByID returns this array. If "N", this array is not returned. |
Return Values
The function GetVoteDataByID returns the string with the poll ID. If the passed poll ID is correct, the ID value is non-zero.
Example
The following example displays a form with the required poll according to the user permissions.
<? function ShowVote($VOTE_ID, $template1="") { global $MESS, $VOTING_LAMP, $VOTING_OK, $USER_ALREADY_VOTE; global $USER_GROUP_PERMISSION, $VOTE_USER_ID, $VOTE_PERMISSION; $VOTE_ID = GetVoteDataByID($VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "N"); if (intval($VOTE_ID)>0) { $perm = CVoteChannel::GetGroupPermission($arChannel["ID"]); if (intval($perm) >= 2) { $template = (strlen($arVote["TEMPLATE"])<=0) ? "default.php" : $arVote["TEMPLATE"]; $VOTE_PERMISSION = CVote::UserGroupPermission($arChannel["ID"]); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/vote/include.php"); @include_once( GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/lang/", "/".$template)); $path = COption::GetOptionString("vote", "VOTE_TEMPLATE_PATH", "/bitrix/php_interface/include/vote/show/"); if (strlen($template1)>0) $template = $template1; @include($_SERVER["DOCUMENT_ROOT"].$path.$template); } } } ?>
The following example obtains the poll information.
<? $VOTE_ID = GetVoteDataByID($PUBLIC_VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "N", $template, $res_template); $VOTE_ID = intval($VOTE_ID); // if the poll ID is valid... if ($VOTE_ID>0 && $arVote["LAMP"]=="green") { ... } ?>
© «Bitrix24», 2001-2024