示例#1
0
}
$arParams["CONTROL_ID"] = preg_match("/^[a-zA-Z0-9_]+\$/", $arParams["CONTROL_ID"]) ? $arParams["CONTROL_ID"] : randString();
$arParams["bVarsFromForm"] = $arParams["bVarsFromForm"] ? true : false;
/********************************************************************
				/Input params
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$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;
            }
示例#2
0
 public static function GetByIDEx($ID)
 {
     $ID = intval($ID);
     if ($ID <= 0) {
         return false;
     }
     if (!isset($GLOBALS["VOTE_CACHE"]["VOTE"][$ID])) {
         global $CACHE_MANAGER;
         if (!!VOTE_CACHE_TIME && $CACHE_MANAGER->Read(VOTE_CACHE_TIME, $ID, "b_vote")) {
             $GLOBALS["VOTE_CACHE"]["VOTE"][$ID] = $CACHE_MANAGER->Get($ID);
         } else {
             $db_res = CVote::GetListEx(array("ID" => "ASC"), array("ID" => $ID));
             if ($db_res && ($res = $db_res->Fetch())) {
                 $GLOBALS["VOTE_CACHE"]["VOTE"][$ID] = $res;
                 if (!!VOTE_CACHE_TIME) {
                     $CACHE_MANAGER->Set($ID, $res);
                 }
             }
         }
     }
     $db_res = new CDBResult();
     $db_res->InitFromArray(array($GLOBALS["VOTE_CACHE"]["VOTE"][$ID]));
     return $db_res;
 }