2##############################################
3# Bitrix Site Manager Forum #
4# Copyright (c) 2002-2009 Bitrix #
6# mailto:admin@bitrixsoft.com #
7##############################################
38 "text" =>
GetMessage(
"VOTE_EMPTY_CHANNEL_ID"));
41 if (! ($rChannel && $arChannel = $rChannel->Fetch()))
45 "text" =>
GetMessage(
"VOTE_WRONG_CHANNEL_ID"));
62 "text" =>
GetMessage(
"VOTE_WRONG_DATE_START"));
70 if ($date_start !=
false):
71 $date_end = $date_start + 2592000;
74 $date_end = 1924984799;
105 if (intval($vid) > 0):
107 "id" =>
"DATE_START",
108 "text" => str_replace(
"#ID#", $vid,
GetMessage(
"VOTE_WRONG_INTERVAL")));
122 $arFields[
"IMAGE_ID"][
"MODULE_ID"] =
"vote";
123 if (!empty($arVote)):
124 $arFields[
"IMAGE_ID"][
"old_file"] = $arVote[
"IMAGE_ID"];
148 $typeMultiplier =
array(
192 public static function Add(
$arFields, $strUploadDir =
false)
198 $errCollection =
$result->getErrorCollection();
199 for ($errCollection->rewind(); $errCollection->valid(); $errCollection->next())
202 $error = $errCollection->current();
203 $aMsg[] = [
"id" =>
$error->getCode(),
"text" =>
$error->getMessage()];
208 $APPLICATION->ThrowException((
new CAdminException(array_reverse($aMsg))));
222 public static function Update(
$ID,
$arFields, $strUploadDir =
false)
228 $errCollection =
$result->getErrorCollection();
229 for ($errCollection->rewind(); $errCollection->valid(); $errCollection->next())
232 $error = $errCollection->current();
233 $aMsg[] = [
"id" =>
$error->getCode(),
"text" =>
$error->getMessage()];
238 $APPLICATION->ThrowException((
new CAdminException(array_reverse($aMsg))));
255 foreach (
GetModuleEvents(
"vote",
"onBeforeVoteDelete",
true) as $arEvent)
260 @set_time_limit(1000);
261 $DB->StartTransaction();
267 $strSql =
"SELECT IMAGE_ID FROM b_vote WHERE ID = ".$ID.
" AND IMAGE_ID > 0";
268 $z =
$DB->Query($strSql);
269 while (
$zr =
$z->Fetch()) CFile::Delete(
$zr[
"IMAGE_ID"]);
272 $DB->Query(
"DELETE FROM b_vote_event WHERE VOTE_ID='$ID'");
274 $res =
$DB->Query(
"DELETE FROM b_vote WHERE ID='$ID'");
277 foreach (
GetModuleEvents(
"vote",
"onAfterVoteDelete",
true) as $arEvent)
287 if (isset($_SESSION[
'VOTE'][
'VOTES'][
$ID]))
289 unset($_SESSION[
"VOTE"][
"VOTES"][
$ID]);
303 if (!$arCurrentVote = $rCurrentVote->Fetch())
305 unset($arCurrentVote[
"ID"]);
306 $arCurrentVote[
'ACTIVE'] =
"N";
309 if (intval($arCurrentVote[
'IMAGE_ID'] > 0))
311 $imageId = $arCurrentVote[
'IMAGE_ID'];
312 $newImageId = CFile::CopyFile($imageId);
313 $arCurrentVote[
"IMAGE_ID"] = NULL;
315 $newID = CVote::Add($arCurrentVote);
316 if ($newID ===
false)
318 $DB->Update(
"b_vote",
array(
"COUNTER"=>
"0"),
"WHERE ID=".$newID);
321 $DB->Update(
"b_vote",
array(
"IMAGE_ID"=>$newImageId),
"WHERE ID=".$newID);
326 while ($arQuestion = $rQuestions->Fetch())
379 if (!!VOTE_CACHE_TIME)
389 public static function UserAlreadyVote($voteId, $VOTE_USER_ID, $UNIQUE_TYPE, $delay, $USER_ID =
false)
393 $voteId = intval($voteId);
394 $UNIQUE_TYPE = intval($UNIQUE_TYPE);
395 $VOTE_USER_ID = intval($VOTE_USER_ID);
396 $USER_ID = intval($USER_ID);
398 if ($voteId <= 0 || $UNIQUE_TYPE <= 0)
402 if (($UNIQUE_TYPE & 1) &&
IsModuleInstalled(
'statistic') && isset($_SESSION[
"VOTE"][
"VOTES"][$voteId]))
407 $arSqlSearch =
array();
408 $arSqlSelect =
array(
"VE.ID");
411 if ($UNIQUE_TYPE & 2 && ($VOTE_USER_ID > 0))
413 $arSqlSelect[] =
"VE.VOTE_USER_ID";
414 $arSqlSearch[] =
"VE.VOTE_USER_ID='".$VOTE_USER_ID.
"'";
418 if ($UNIQUE_TYPE & 4)
421 $arSqlSelect[] =
$tmp[
"select"];
422 $arSqlSearch[] =
$tmp[
"search"];
426 if ($UNIQUE_TYPE & 8)
428 if ($USER_ID <= 0 || $USER_ID == $USER->GetID() && isset($_SESSION[
"VOTE"][
"VOTES"][$voteId]))
434 $arSqlSelect[] =
"VU.AUTH_USER_ID";
435 $arSqlSearch[] =
"VU.AUTH_USER_ID=".$USER_ID;
438 if (($UNIQUE_TYPE & 16) &&
439 ($arUser = \CUser::GetByID($USER_ID)->fetch()) &&
445 ($userRegister > $voteStart)
452 if (!empty($arSqlSearch))
454 $db_res =
$DB->Query(
"SELECT ".implode(
",", $arSqlSelect).
"
456 LEFT JOIN b_vote_user VU ON (VE.VOTE_USER_ID = VU.ID)
457 WHERE VE.VOTE_ID=".$voteId.
" AND ((".implode(
") OR (", $arSqlSearch).
"))");
460 if ($USER_ID > 0 && $USER_ID ==
$USER->GetID())
461 $_SESSION[
"VOTE"][
"VOTES"][$voteId] =
$res[
"ID"];
463 if (isset(
$res[
"VOTE_USER_ID"]) &&
$res[
"VOTE_USER_ID"] == $VOTE_USER_ID)
469 && ($delay <= 0 || !isset(
$res[
"KEEP_IP_SEC"]) || $delay >
$res[
"KEEP_IP_SEC"]))
474 if (isset(
$res[
"AUTH_USER_ID"]) &&
$res[
"AUTH_USER_ID"] == $USER_ID)
480 $return = empty($return) ? 0 : min($return);
481 return ($return > 0 ? $return :
false);
492 return \Bitrix\Vote\User::getCurrent()->setVotedUserId();
499 $VOTE_USER_ID = intval($VOTE_USER_ID);
501 "DATE_LAST" =>
$DB->GetNowFunction(),
502 "COUNTER" =>
"COUNTER+1"
504 return $DB->Update(
"b_vote_user",
$arFields,
"WHERE ID='".$VOTE_USER_ID.
"'");
507 public static function keepVoting()
511 $r = \Bitrix\Main\Context::getCurrent()->getRequest();
512 $request = array_merge($r->getQueryList()->toArray(), $r->getPostList()->toArray());
514 $PUBLIC_VOTE_ID = intval(
$request[
"PUBLIC_VOTE_ID"]);
515 $errorCollection = new \Bitrix\Main\ErrorCollection();
520 throw new \Bitrix\Main\ArgumentException(
GetMessage(
"VOTE_NOT_FOUND"),
"bad_params");
522 $vote = new \Bitrix\Vote\Vote($PUBLIC_VOTE_ID);
525 throw new \Bitrix\Main\AccessDeniedException();
527 $channel = $vote->getChannel();
528 if ($channel[
"USE_CAPTCHA"] ==
"Y" && !
$USER->IsAuthorized())
530 $cpt =
new CCaptcha();
531 if ((!empty(
$request[
"captcha_code"]) && !$cpt->CheckCodeCrypt(
$request[
"captcha_word"],
$request[
"captcha_code"])) ||
532 empty(
$request[
"captcha_code"]) && !$cpt->CheckCode(
$request[
"captcha_word"], 0))
535 throw new \Bitrix\Main\ArgumentException(
GetMessage(
"VOTE_BAD_CAPTCHA"),
"captcha");
539 $errorCollection->add($vote->getErrors());
541 $GLOBALS[
"VOTING_ID"] = $vote->getId();
543 catch (\Exception $e)
545 $errorCollection->add(
array(
new \Bitrix\Main\
Error($e->getMessage(), $e->getCode())));
548 if ($errorCollection->isEmpty())
556 for ($errorCollection->rewind(); $errorCollection->valid(); $errorCollection->next())
557 $m[] = $errorCollection->current()->getMessage();
559 $APPLICATION->ThrowException(implode(
"", $m),
"CVote::KeepVoting");
568 $CHANNEL_ID = intval($CHANNEL_ID);
569 $strSql =
"SELECT max(C_SORT) MAX_SORT FROM b_vote WHERE CHANNEL_ID='$CHANNEL_ID'";
570 $z =
$DB->Query($strSql);
572 return intval(
$zr[
"MAX_SORT"])+100;
579 $CURRENT_VOTE_ID = intval($CURRENT_VOTE_ID);
580 $CURRENT_VOTE_ID = ($CURRENT_VOTE_ID > 0 ? $CURRENT_VOTE_ID :
false);
581 $CHANNEL_ID = intval($CHANNEL_ID);
582 $CHANNEL_ID = ($CHANNEL_ID > 0 ? $CHANNEL_ID :
false);
583 $DATE_START = ($DATE_START ==
false ?
false : (trim($DATE_START) ==
'' ?
false : trim($DATE_START)));
584 $DATE_END = ($DATE_END ==
false ?
false : (trim($DATE_END) ==
'' ?
false : trim($DATE_END)));
586 if($CURRENT_VOTE_ID ==
false && $CHANNEL_ID ==
false)
594 if(
$res[
"VOTE_SINGLE"] !=
"Y")
598 $st = ($DATE_START ==
false ?
"VV.DATE_START" :
$DB->CharToDateFunction($DATE_START,
"FULL"));
599 $en = ($DATE_END ==
false ?
"VV.DATE_END" :
$DB->CharToDateFunction($DATE_END,
"FULL"));
600 if($CURRENT_VOTE_ID <= 0)
602 if($DATE_START ==
false)
603 $st =
$DB->CurrentTimeFunction();
604 if($DATE_END ==
false)
605 $en =
$DB->CharToDateFunction(ConvertTimeStamp(1924984799,
"FULL"),
"FULL");
611 ".($CURRENT_VOTE_ID > 0 ?
612 "LEFT JOIN b_vote VV ON (VV.ID = ".$CURRENT_VOTE_ID.
") " :
"").
"
613 INNER JOIN b_vote_channel VC ON (V.CHANNEL_ID = VC.ID AND VC.VOTE_SINGLE = 'Y')
615 V.CHANNEL_ID=".($CHANNEL_ID ==
false ?
"VV.CHANNEL_ID" : $CHANNEL_ID).
" AND
617 ".($CURRENT_VOTE_ID > 0 ?
618 "V.ID<>'".$CURRENT_VOTE_ID.
"' AND " :
"").
"
620 (".$st.
" between V.DATE_START and V.DATE_END) OR
621 (".$en.
" between V.DATE_START and V.DATE_END) OR
622 (V.DATE_START between ".$st.
" and ".$en.
") OR
623 (V.DATE_END between ".$st.
" and ".$en.
")
627 return intval(
$res[
"ID"]);
637 parent::__construct(
$res);
641 if(
$res = parent::Fetch())
643 if (
$res[
"LAMP"] ==
"yellow" && !empty(
$res[
"CHANNEL_ID"]))
645 $res[
"LAMP"] = (
$res[
"ID"] == CVote::GetActiveVoteId(
$res[
"CHANNEL_ID"]) ?
"green" :
"red");
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
__construct($res, $params=array())
static deleteByFilter(array $filter)
static resetStatistic($voteId)
static GetFilterOperation($key)
static GetGroupPermission($channel_id, $arGroups=false, $params=array())
static GetList($by='s_id', $order='desc', $arFilter=[])
static UpdateVoteUserID($VOTE_USER_ID)
static GetFilterOperation($key)
static UserGroupPermission($CHANNEL_ID)
static UserAlreadyVote($voteId, $VOTE_USER_ID, $UNIQUE_TYPE, $delay, $USER_ID=false)
static CheckFields($ACTION, &$arFields, $ID=0)
static WrongDateInterval($CURRENT_VOTE_ID, $DATE_START, $DATE_END, $CHANNEL_ID)
static GetNextSort($CHANNEL_ID)
static GetList($VOTE_ID, $by='s_c_sort', $order='asc', $arFilter=[])
static Copy($ID, $newVoteID)
static Delete($ID, $VOTE_ID=false)
static GetListEx($arOrder=array(), $arFilter=array())
static CheckVotingIP($VOTE_ID, $REMOTE_ADDR, $KEEP_IP_SEC, $params=array())
static GetList($by='s_id', $order='desc', $arFilter=[])
if(!is_array($prop["VALUES"])) $tmp
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
check_bitrix_sessid($varname='sessid')
ExecuteModuleEventEx($arEvent, $arParams=[])
IsModuleInstalled($module_id)
GetTime($timestamp, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
MakeTimeStamp($datetime, $format=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
$GLOBALS['_____370096793']