本文整理汇总了PHP中CVote::UserGroupPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP CVote::UserGroupPermission方法的具体用法?PHP CVote::UserGroupPermission怎么用?PHP CVote::UserGroupPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVote
的用法示例。
在下文中一共展示了CVote::UserGroupPermission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
//.........这里部分代码省略.........
示例2: VoteVoteEditFromArray
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;
}
//.........这里部分代码省略.........
示例3: ShowVoteResults
function ShowVoteResults($VOTE_ID, $template1="")
{
global $APPLICATION;
$VOTE_ID = GetVoteDataByID($VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "Y");
if (intval($VOTE_ID)>0)
{
/***** for old pre-component templates **********/
global $VOTE_PERMISSION;
$VOTE_PERMISSION = CVote::UserGroupPermission($arChannel["ID"]);
/***** /old *************************************/
$perm = CVoteChannel::GetGroupPermission($arChannel["ID"]);
if (intval($perm)>=1)
{
$template = (strlen($arVote["RESULT_TEMPLATE"])<=0) ? "default.php" : $arVote["RESULT_TEMPLATE"];
require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/vote/include.php");
IncludeModuleLangFile(__FILE__);
$path = COption::GetOptionString("vote", "VOTE_TEMPLATE_PATH_VOTE");
if (strlen($template1)>0) $template = $template1;
if ($APPLICATION->GetShowIncludeAreas())
{
$arIcons = Array();
if (CModule::IncludeModule("fileman"))
{
$arIcons[] =
Array(
"URL" => "/bitrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($path.$template),
"SRC" => "/bitrix/images/vote/panel/edit_template.gif",
"ALT" => GetMessage("VOTE_PUBLIC_ICON_TEMPLATE")
);
$arrUrl = parse_url($_SERVER["REQUEST_URI"]);
$arIcons[] =
Array(
"URL" => "/bitrix/admin/fileman_file_edit.php?lang=".LANGUAGE_ID."&site=".SITE_ID."&full_src=Y&path=". urlencode($arrUrl["path"]),
"SRC" => "/bitrix/images/vote/panel/edit_file.gif",
"ALT" => GetMessage("VOTE_PUBLIC_ICON_HANDLER")
);
}
$arIcons[] =
Array(
"URL" => "/bitrix/admin/vote_edit.php?lang=".LANGUAGE_ID."&ID=".$VOTE_ID,
"SRC" => "/bitrix/images/vote/panel/edit_vote.gif",
"ALT" => GetMessage("VOTE_PUBLIC_ICON_SETTINGS")
);
echo $APPLICATION->IncludeStringBefore($arIcons);
}
$template = Rel2Abs('/', $template);
include($_SERVER["DOCUMENT_ROOT"].$path.$template);
if ($APPLICATION->GetShowIncludeAreas())
{
echo $APPLICATION->IncludeStringAfter();
}
}
}
}