Exemple #1
0
 CModule::IncludeModule("vote");
 $db_res = CVoteChannel::GetList($by = "", $order = "", array("ACTIVE" => "Y"), $is_filtered);
 if ($db_res && ($res = $db_res->Fetch())) {
     do {
         $arVoteChannels[$res["ID"] . ""] = "[ " . $res["ID"] . " ]" . $res["TITLE"];
     } while ($res = $db_res->Fetch());
 }
 $arComponentParameters["PARAMETERS"]["VOTE_CHANNEL_ID"] = array("PARENT" => "VOTE_SETTINGS", "NAME" => GetMessage("F_VOTE_CHANNEL_ID"), "TYPE" => "LIST", "VALUES" => $arVoteChannels, "DEFAULT" => "", "REFRESH" => "Y");
 reset($arVoteChannels);
 if (intVal($arCurrentValues["VOTE_CHANNEL_ID"]) > 0) {
     $voteId = intVal($arCurrentValues["VOTE_CHANNEL_ID"]);
 } else {
     $voteId = key($arVoteChannels);
 }
 if (!empty($voteId)) {
     $arPermissions = CVoteChannel::GetArrayGroupPermission($voteId);
     $arUGroupsEx = array();
     $db_res = CGroup::GetList($by = "c_sort", $order = "asc");
     while ($res = $db_res->Fetch()) {
         if (isset($arPermissions[$res["ID"]]) && intVal($arPermissions[$res["ID"]]) >= 2 || intVal($res["ID"]) == 1) {
             $arUGroupsEx[$res["ID"]] = $res["NAME"] . "[" . $res["ID"] . "]";
         }
     }
     if (!empty($arUGroupsEx)) {
         $arComponentParameters["PARAMETERS"]["VOTE_GROUP_ID"] = array("PARENT" => "VOTE_SETTINGS", "NAME" => GetMessage("F_VOTE_GROUP_ID"), "TYPE" => "LIST", "VALUES" => $arUGroupsEx, "DEFAULT" => "", "MULTIPLE" => "Y");
         $arComponentParameters["PARAMETERS"]["VOTE_TEMPLATE"] = array("PARENT" => "VOTE_SETTINGS", "NAME" => GetMessage("F_VOTE_TEMPLATE"), "TYPE" => "LIST", "VALUES" => array(".default" => GetMessage("F_VOTE_TEMPLATE_DEFAULT"), "light" => GetMessage("F_VOTE_TEMPLATE_LIGHT")), "DEFAULT" => "light", "MULTIPLE" => "N", "ADDITIONAL_VALUES" => "Y");
         $arVoteUnique = array();
         if (IsModuleInstalled('statistic')) {
             $arVoteUnique["1"] = GetMessage("F_VOTE_UNIQUE_SESSION");
         }
         $arVoteUnique["2"] = GetMessage("F_VOTE_UNIQUE_COOKIE_ONLY");
            $message = new CAdminMessage(GetMessage("VOTE_GOT_ERROR"), $e);
        }
    }
}
$db_res = $ID > 0 ? CVoteChannel::GetByID($ID) : false;
if (!($db_res && ($res = $db_res->Fetch()))) {
    $APPLICATION->SetTitle(GetMessage("VOTE_NEW_RECORD"));
    if ($ID > 0 && $message == null) {
        $message = new CAdminMessage(GetMessage("VOTE_CHANNEL_IS_NOT_EXISTS", array("#ID#" => $ID)));
    }
    $ID = 0;
    $res = array("TITLE" => "", "SYMBOLIC_NAME" => "", "ACTIVE" => "Y", "HIDDEN" => "N", "C_SORT" => 100, "VOTE_SINGLE" => "Y", "USE_CAPTCHA" => "N", "SITE" => array_keys($arrSites), "GROUP_ID" => array());
} else {
    $APPLICATION->SetTitle(GetMessage("VOTE_EDIT_RECORD", array("#ID#" => $ID)));
    $res["SITE"] = CVoteChannel::GetSiteArray($ID);
    $res["GROUP_ID"] = CVoteChannel::GetArrayGroupPermission($ID);
}
if (isset($bVarsFromForm) && $bVarsFromForm == true) {
    $res = array_intersect_key($_REQUEST, $res);
}
foreach ($res as $k => $v) {
    $res[$k] = htmlspecialcharsEx($res[$k]);
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
/********************************************************************
				Form
********************************************************************/
$aMenu = array(array("TEXT" => GetMessage("VOTE_LIST"), "TITLE" => GetMessage("VOTE_RECORDS_LIST"), "LINK" => "/bitrix/admin/vote_channel_list.php?lang=" . LANGUAGE_ID, "ICON" => "btn_list"));
if ($ID > 0) {
    $aMenu[] = array("TEXT" => GetMessage("VOTE_VOTES") . ($res["VOTES"] ? " [" . $res["VOTES"] . "]" : ""), "TITLE" => GetMessage("VOTE_VOTES_TITLE"), "LINK" => "/bitrix/admin/vote_list.php?lang=" . LANGUAGE_ID . "&find_channel_id={$ID}&set_filter=Y");
    if ($VOTE_RIGHT == "W") {