3#############################################
4# Bitrix Site Manager Forum #
5# Copyright (c) 2002-2009 Bitrix #
7# mailto:admin@bitrixsoft.com #
8#############################################
30 'id' =>
'QUESTION_ID',
31 'text' =>
GetMessage(
'VOTE_FORGOT_QUESTION_ID')
39 if (!
$USER ||
$USER->CanDoOperation(
'edit_php') !==
true)
45 $aMsg[] = [
'id' =>
'MESSAGE',
'text' =>
GetMessage(
'VOTE_FORGOT_MESSAGE')];
55 if (array_key_exists(
'IMAGE_ID',
$arFields))
69 'text' =>
'Answer: '.
$str);
73 $arFields[
'IMAGE_ID'][
'MODULE_ID'] =
'vote';
110 foreach (
GetModuleEvents(
"vote",
"onBeforeVoteAnswerAdd",
true) as $arEvent)
118 array_key_exists(
"IMAGE_ID",
$arFields) &&
122 $arFields[
"IMAGE_ID"][
"MODULE_ID"] =
"vote";
123 CFile::SaveForDB(
$arFields,
"IMAGE_ID",
"vote");
126 if (
$DB->type ==
"ORACLE")
139 $arInsert =
$DB->PrepareInsert(
"b_vote_answer",
$arFields);
141 $DB->QueryBind(
"INSERT INTO b_vote_answer (".$arInsert[0].
", TIMESTAMP_X) VALUES(".$arInsert[1].
", ".
$DB->GetNowFunction().
")",
array(
"MESSAGE" =>
$arFields[
"MESSAGE"]),
false);
145 foreach (
GetModuleEvents(
"vote",
"onAfterVoteAnswerAdd",
true) as $arEvent)
160 foreach (
GetModuleEvents(
"vote",
"onBeforeVoteAnswerUpdate",
true) as $arEvent)
168 array_key_exists(
"IMAGE_ID",
$arFields) &&
172 $arFields[
"IMAGE_ID"][
"MODULE_ID"] =
"vote";
173 CFile::SaveForDB(
$arFields,
"IMAGE_ID",
"vote");
181 $strUpdate =
$DB->PrepareUpdate(
"b_vote_answer",
$arFields);
183 $arBinds[
"MESSAGE"] =
$arFields[
"MESSAGE"];
185 if (!empty($strUpdate)):
186 $strSql =
"UPDATE b_vote_answer SET ".$strUpdate.
" WHERE ID=".
$ID;
187 $DB->QueryBind($strSql, $arBinds);
191 foreach (
GetModuleEvents(
"vote",
"onAfterVoteAnswerUpdate",
true) as $arEvent)
197 public static function Delete(
$ID, $QUESTION_ID =
false, $VOTE_ID =
false)
201 foreach (
GetModuleEvents(
"vote",
"onBeforeVoteAnswerDelete",
true) as $arEvent)
208 $ID = (intval(
$ID) > 0 ? intval(
$ID) :
false);
209 $QUESTION_ID = (intval($QUESTION_ID) > 0 ? intval($QUESTION_ID) :
false);
210 $VOTE_ID = (intval($VOTE_ID) > 0 ? intval($VOTE_ID) :
false);
212 $strSqlEventAnswer =
"DELETE FROM b_vote_event_answer WHERE ANSWER_ID=".$ID;
213 $strSqlAnswer =
"DELETE FROM b_vote_answer WHERE ID=".$ID;
214 elseif ($QUESTION_ID !=
false):
215 $strSqlEventAnswer =
"DELETE FROM b_vote_event_answer WHERE ANSWER_ID IN (
216 SELECT VA.ID FROM b_vote_answer VA WHERE VA.QUESTION_ID = ".$QUESTION_ID.
")";
217 $strSqlAnswer =
"DELETE FROM b_vote_answer WHERE QUESTION_ID = ".$QUESTION_ID;
218 elseif ($VOTE_ID !=
false):
219 $strSqlEventAnswer =
"DELETE FROM b_vote_event_answer WHERE ANSWER_ID IN (
221 FROM b_vote_answer VA, b_vote_question VQ
222 WHERE VA.QUESTION_ID = VQ.ID AND VQ.VOTE_ID = ".$VOTE_ID.
")";
223 $strSqlAnswer =
"DELETE FROM b_vote_answer WHERE QUESTION_ID IN (
224 SELECT VQ.ID FROM b_vote_question VQ WHERE VQ.VOTE_ID = ".$VOTE_ID.
")";
229 $DB->Query($strSqlEventAnswer);
230 $DB->Query($strSqlAnswer);
232 foreach (
GetModuleEvents(
"vote",
"onAfterVoteAnswerDelete",
true) as $arEvent)
241 $QUESTION_ID = intval($QUESTION_ID);
242 $arSqlSearch = Array();
246 if(empty(
$val) ||
$val ===
"NOT_REF")
262 $arSqlSearch[] = (
$val==
"Y") ?
"A.ACTIVE='Y'" :
"A.ACTIVE='N'";
268 $by = (($by ==
"s_id" || $by ==
"s_counter") ? $by :
"s_c_sort");
269 if ($by ==
"s_id") $strSqlOrder =
" ORDER BY A.ID";
270 elseif ($by ==
"s_counter") $strSqlOrder =
" ORDER BY A.COUNTER";
271 else $strSqlOrder =
" ORDER BY A.C_SORT";
272 $strSqlOrder .=
" ".$order;
274 $strSqlFrom =
"FROM b_vote_answer A WHERE ".$strSqlSearch.
" and A.QUESTION_ID=".$QUESTION_ID.
"";
275 $strSql =
"SELECT A.* ".$strSqlFrom.$strSqlOrder;
277 $arAddParams[
"nTopCount"] = ($arAddParams[
"nTopCount"] ?? 0);
278 if ($arAddParams[
"nTopCount"] > 0)
280 $arAddParams[
"nTopCount"] = intval($arAddParams[
"nTopCount"]);
281 if (
$DB->type==
"MSSQL")
282 $strSql =
"SELECT TOP ".$arAddParams[
"nTopCount"].
" A.* ".$strSqlFrom.$strSqlOrder;
283 else if (
$DB->type==
"ORACLE")
284 $strSql =
"SELECT * FROM(".$strSql.
") WHERE ROWNUM<=".$arAddParams[
"nTopCount"];
286 $strSql =
"SELECT A.* ".$strSqlFrom.$strSqlOrder.
" LIMIT 0,".$arAddParams[
"nTopCount"];
288 else if (
is_set($arAddParams,
"bDescPageNumbering"))
290 $db_res =
$DB->Query(
"SELECT COUNT(A.ID) as CNT ".$strSqlFrom);
293 $db_res->NavQuery($strSql, $iCnt, $arAddParams);
296 return $DB->Query($strSql);
303 $arSqlSearch = Array();
305 $arSqlOrder = Array();
312 if (
$val ===
"NOT_REF")
315 $strNegative = $key_res[
"NEGATIVE"];
316 $strOperation = $key_res[
"OPERATION"];
317 $key = mb_strtoupper($key_res[
"FIELD"]);
323 $str = ($strNegative==
"Y"?
"NOT":
"").
"(VA.".
$key.
" IS NULL OR VA.".
$key.
"<=0)";
326 $str = ($strNegative==
"Y"?
" VA.".$key.
" IS NULL OR NOT ":
"").
"(VA.".
$key.
" ".$strOperation.
" ".intval(
$val).
")";
327 if ($strOperation ==
"IN")
329 $val = array_unique(array_map(
"intval", (is_array(
$val) ?
$val : explode(
",",
$val))), SORT_NUMERIC);
332 $str = ($strNegative==
"Y"?
" NOT ":
"").
"(VA.".
$key.
" IN (".implode(
",",
$val).
"))";
336 $arSqlSearch[] =
$str;
339 $str = ($strNegative==
"Y"?
"NOT":
"").
"(VQ.".
$key.
" IS NULL OR VQ.".
$key.
"<=0)";
342 $str = ($strNegative==
"Y"?
" VQ.".$key.
" IS NULL OR NOT ":
"").
"(VQ.".
$key.
" ".$strOperation.
" ".intval(
$val).
")";
343 if ($strOperation ==
"IN")
345 $val = array_unique(array_map(
"intval", (is_array(
$val) ?
$val : explode(
",",
$val))), SORT_NUMERIC);
348 $str = ($strNegative==
"Y"?
" NOT ":
"").
"(VQ.".
$key.
" IN (".implode(
",",
$val).
"))";
352 $arSqlSearch[] =
$str;
355 $str = ($strNegative==
"Y"?
"NOT":
"").
"(V.".
$key.
" IS NULL OR V.".
$key.
"<=0)";
358 $str = ($strNegative==
"Y"?
" V.".$key.
" IS NULL OR NOT ":
"").
"(V.".
$key.
" ".$strOperation.
" ".intval(
$val).
")";
359 if ($strOperation ==
"IN")
361 $val = array_unique(array_map(
"intval", (is_array(
$val) ?
$val : explode(
",",
$val))), SORT_NUMERIC);
364 $str = ($strNegative==
"Y"?
" NOT ":
"").
"(V.".
$key.
" IN (".implode(
",",
$val).
"))";
368 $arSqlSearch[] =
$str;
372 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(VA.".
$key.
" IS NULL OR ".(
$DB->type ==
"MSSQL" ?
"LEN" :
"LENGTH").
"(VA.".
$key.
")<=0)";
374 $arSqlSearch[] = ($strNegative==
"Y"?
" VA.".$key.
" IS NULL OR NOT ":
"").
"(VA.".
$key.
" ".$strOperation.
" '".
$DB->ForSql(
$val).
"')";
378 if (
count($arSqlSearch) > 0)
379 $strSqlSearch =
" AND (".implode(
") AND (", $arSqlSearch).
") ";
381 foreach ($arOrder as $by =>
$order)
383 $by = mb_strtoupper($by);
385 $by = (in_array($by,
array(
"ACTIVE",
"QUESTION_ID",
"C_SORT",
"COUNTER")) ? $by :
"ID");
387 if ($by ==
"ACTIVE") $arSqlOrder[] =
" VA.ACTIVE ".$order.
" ";
388 elseif ($by ==
"QUESTION_ID") $arSqlOrder[] =
" VA.QUESTION_ID ".$order.
" ";
389 elseif ($by ==
"C_SORT") $arSqlOrder[] =
" VA.C_SORT ".$order.
" ";
390 elseif ($by ==
"COUNTER") $arSqlOrder[] =
" VA.COUNTER ".$order.
" ";
391 else $arSqlOrder[] =
" VA.ID ".$order.
" ";
394 if (
count($arSqlOrder) > 0)
395 $strSqlOrder =
" ORDER BY ".implode(
", ", $arSqlOrder);
398 SELECT V.CHANNEL_ID, VQ.VOTE_ID, VA.*
399 FROM b_vote_answer VA
400 INNER JOIN b_vote_question VQ ON (VA.QUESTION_ID = VQ.ID)
401 INNER JOIN b_vote V ON (VQ.VOTE_ID = V.ID)
402 WHERE 1=1 ".$strSqlSearch.
" ".$strSqlOrder;
404 return $DB->Query($strSql);
410 $ANSWER_ID = intval($ANSWER_ID);
412 "SELECT A.MESSAGE, count(A.ID) as COUNTER ".
414 b_vote_event_answer A,
415 b_vote_event_question Q,
418 A.ANSWER_ID = '$ANSWER_ID'
419 and Q.ID = A.EVENT_QUESTION_ID
420 and E.ID = Q.EVENT_ID
423 ORDER BY COUNTER desc";
const REACTION_MAX_LENGTH
static cleanText(?string $text)
static GetList($QUESTION_ID, $by="s_c_sort", $order="asc", $arFilter=array(), $arAddParams=array())
static GetListEx($arOrder=array("ID"=> "ASC"), $arFilter=array())
static CheckFields($ACTION, &$arFields, $ID=0)
static GetGroupAnswers($ANSWER_ID)
static Delete($ID, $QUESTION_ID=false, $VOTE_ID=false)
static Update($ID, $arFields)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
ExecuteModuleEventEx($arEvent, $arParams=[])
DelDuplicateSort(&$arSort)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
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."%"
VoteGetFilterOperation($key)