public static function Copy($ID) { global $DB; $err_mess = CVote::err_mess() . "<br>Function: Copy<br>Line: "; $ID = intval($ID); if ($ID <= 0) { return false; } $rCurrentVote = CVote::GetByID($ID); if (!($arCurrentVote = $rCurrentVote->Fetch())) { return false; } unset($arCurrentVote["ID"]); $arCurrentVote['ACTIVE'] = "N"; $newImageId = false; if (intval($arCurrentVote['IMAGE_ID'] > 0)) { $imageId = $arCurrentVote['IMAGE_ID']; $newImageId = CFile::CopyFile($imageId); $arCurrentVote["IMAGE_ID"] = NULL; } $newID = CVote::Add($arCurrentVote); if ($newID === false) { return false; } $DB->Update("b_vote", array("COUNTER" => "0"), "WHERE ID=" . $newID, $err_mess . __LINE__); if ($newImageId) { $DB->Update("b_vote", array("IMAGE_ID" => $newImageId), "WHERE ID=" . $newID, $err_mess . __LINE__); } $state = true; $rQuestions = CVoteQuestion::GetList($ID, $by, $order, array(), $is_filtered); while ($arQuestion = $rQuestions->Fetch()) { $state = $state && CVoteQuestion::Copy($arQuestion['ID'], $newID) !== false; } if ($state == true) { return $newID; } else { return $state; } }
$imageId = $arCurrentVote['IMAGE_ID']; $newImageId = CFile::CopyFile($imageId); $arCurrentVote["IMAGE_ID"] = NULL; } $newID = $ID; if ($newID === false) { return false; } $DB->Update("b_vote", array("COUNTER" => "0"), "WHERE ID=" . $newID, $err_mess . __LINE__); if ($newImageId) { $DB->Update("b_vote", array("IMAGE_ID" => $newImageId), "WHERE ID=" . $newID, $err_mess . __LINE__); } $state = true; $rQuestions = CVoteQuestion::GetList($oldID, $by, $order, array(), $is_filtered); while ($arQuestion = $rQuestions->Fetch()) { $state = $state && CVoteQuestion::Copy($arQuestion['ID'], $newID) !== false; } } if (!empty($save)) { if (!empty($_REQUEST["return_url"])) { LocalRedirect($_REQUEST["return_url"]); } LocalRedirect("vote_list.php?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arFields["CHANNEL_ID"]); } LocalRedirect($APPLICATION->GetCurPage() . "?lang=" . LANGUAGE_ID . "&CHANNEL_ID=" . $arFields["CHANNEL_ID"] . "&ID=" . $ID . "&" . $tabControl->ActiveTabParam() . (!empty($_REQUEST["return_url"]) ? "&return_url=" . urlencode($_REQUEST["return_url"]) : "")); } } /******************************************************************** /ACTIONS ********************************************************************/ if ($ID > 0) {