本文整理汇总了PHP中Poll::vote方法的典型用法代码示例。如果您正苦于以下问题:PHP Poll::vote方法的具体用法?PHP Poll::vote怎么用?PHP Poll::vote使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poll
的用法示例。
在下文中一共展示了Poll::vote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
$pollObj = new Poll($mysqli);
$member = new Member($mysqli);
$arrReturn = array("result" => "fail");
$pollOptionSelector = "poll_" . $_POST['pollID'];
if ($pollObj->select($_POST['pollID'])) {
$pollInfo = $pollObj->get_info_filtered();
$pollObj->objAccess->arrAccessFor = array("keyName" => "poll_id", "keyValue" => $pollInfo['poll_id']);
$blnVote = false;
$member->select($_SESSION['btUsername']);
$memberID = "";
if ($pollInfo['accesstype'] == "members" && $member->authorizeLogin($_SESSION['btPassword'])) {
$memberID = $member->get_info("member_id");
$blnVote = true;
} elseif ($pollInfo['accesstype'] == "memberslimited" && $member->authorizeLogin($_SESSION['btPassword']) && $pollObj->hasAccess($member)) {
$memberID = $member->get_info("member_id");
$blnVote = true;
} elseif ($pollInfo['accesstype'] == "public") {
$memberID = $member->authorizeLogin($_SESSION['btPassword']) ? $member->get_info("member_id") : "";
$blnVote = true;
}
if ($blnVote) {
foreach (json_decode($_POST['pollOptionID'], true) as $pollOptionID) {
$pollObj->objPollOption->select($pollOptionID);
$pollOptionInfo = $pollObj->objPollOption->get_info_filtered();
$arrReturn = $pollObj->vote($memberID, $pollOptionInfo);
}
} else {
$arrReturn['errors'] = "You do not have permission to vote on this poll.";
}
}
echo json_encode($arrReturn);