public static function Reset($ID) { global $DB; $err_mess = CVote::err_mess() . "<br>Function: Reset<br>Line: "; $ID = intval($ID); if ($ID <= 0) { return false; } // zeroize questions CVoteQuestion::Reset(false, $ID); // zeroize events $DB->Query("DELETE FROM b_vote_event WHERE VOTE_ID='{$ID}'", false, $err_mess . __LINE__); // zeroize vote counter unset($GLOBALS["VOTE_CACHE_VOTING"][$ID]); $DB->Update("b_vote", array("COUNTER" => "0"), "WHERE ID=" . $ID, $err_mess . __LINE__); /***************** Event OnVoteReset *******************************/ foreach (GetModuleEvents("vote", "onVoteReset", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID)); } /***************** /Event ******************************************/ return true; }
public static function Copy($ID, $newVoteID) { $ID = intVal($ID); if ($ID <= 0) { return false; } $newVoteID = intVal($newVoteID); if ($newVoteID <= 0) { return false; } $res = CVoteQuestion::GetByID($ID); if (!($arQuestion = $res->Fetch())) { return false; } $arQuestion['VOTE_ID'] = $newVoteID; unset($arQuestion['ID']); $newQuestionID = CVoteQuestion::Add($arQuestion); if ($newQuestionID === false) { return false; } $state = true; $rAnswers = CVoteAnswer::GetList($ID); while ($arAnswer = $rAnswers->Fetch()) { $arAnswer['QUESTION_ID'] = $newQuestionID; unset($arAnswer['ID']); $state = $state && CVoteAnswer::Add($arAnswer) !== false; } if (!$state) { return $state; } CVoteQuestion::Reset($newQuestionID); return $newQuestionID; }
function Delete($ID) { global $DB; $err_mess = CVoteQuestion::err_mess() . "<br>Function: Delete<br>Line: "; $ID = intval($ID); // обнуляем вопрос CVoteQuestion::Reset($ID); // удаляем вопрос $res = $DB->Query("DELETE FROM b_vote_question WHERE ID='{$ID}'", false, $err_mess . __LINE__); return $res; }
function Copy($ID, $newVoteID) { $err_mess = CAllVoteQuestion::err_mess() . "<br>Function: Copy<br>Line: "; $ID = intVal($ID); if ($ID <= 0) { return false; } $newVoteID = intVal($newVoteID); if ($newVoteID <= 0) { return false; } $res = CVoteQuestion::GetByID($ID); if (!($arQuestion = $res->Fetch())) { return false; } $arQuestion['VOTE_ID'] = $newVoteID; unset($arQuestion['ID']); $newQuestionID = CVoteQuestion::Add($arQuestion); if ($newQuestionID === false) { return false; } $state = true; $rAnswers = CVoteAnswer::GetList($ID); while ($arAnswer = $rAnswers->GetNext()) { $arAnswer['QUESTION_ID'] = $newQuestionID; unset($arAnswer['ID']); unset($arAnswer['~ID']); $state = $state && CVoteAnswer::Add($arAnswer) !== false; } if (!$state) { return $state; } CVoteQuestion::Reset($newQuestionID); return $newQuestionID; }