3##############################################
4# Bitrix Site Manager Forum #
5# Copyright (c) 2002-2007 Bitrix #
7# mailto:admin@bitrixsoft.com #
8##############################################
20 if (in_array(1, $arUserGroups))
return True;
26 if (in_array(1, $arUserGroups))
return True;
32 if (in_array(1, $arUserGroups))
return True;
46 while ($arLang = $db_lang->Fetch())
51 if (is_array(
$res) &&
$res[
"LID"] == $arLang[
"LID"])
64 "id"=>
'POINTS[NAME][LID]['.$arLang[
"LID"].
']',
65 "text" => str_replace(
"#LANG#", $arLang[
"NAME"].
" [".$arLang[
"LID"].
"]",
GetMessage(
"FORUM_PE_ERROR_NONAME")));
76 "id"=>
'POINTS[MIN_POINTS]',
77 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_POINTS_EMPTY"));
82 "id"=>
'POINTS[MIN_POINTS]',
83 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_POINTS_BAD"));
94 "id"=>
'POINTS[MIN_POINTS]',
95 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_POINTS_EXIST"));
105 $GLOBALS[
"APPLICATION"]->ThrowException($e);
122 $strUpdate =
$DB->PrepareUpdate(
"b_forum_points",
$arFields);
123 $strSql =
"UPDATE b_forum_points SET ".$strUpdate.
" WHERE ID = ".
$ID;
128 $DB->Query(
"DELETE FROM b_forum_points_lang WHERE POINTS_ID = ".
$ID.
"");
132 $arInsert =
$DB->PrepareInsert(
"b_forum_points_lang",
$arFields[
"LANG"][
$i]);
133 $strSql =
"INSERT INTO b_forum_points_lang(POINTS_ID, ".$arInsert[0].
") VALUES(".
$ID.
", ".$arInsert[1].
")";
145 $DB->Query(
"DELETE FROM b_forum_points_lang WHERE POINTS_ID = ".
$ID, True);
146 $DB->Query(
"DELETE FROM b_forum_points WHERE ID = ".
$ID, True);
154 $arSqlSearch = Array();
156 $arSqlOrder = Array();
163 $key = mb_strtoupper($key_res[
"FIELD"]);
164 $strNegative = $key_res[
"NEGATIVE"];
165 $strOperation = $key_res[
"OPERATION"];
172 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.".
$key.
" IS NULL OR FR.".
$key.
"<=0)";
174 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.".$key.
" IS NULL OR NOT ":
"").
"(FR.".
$key.
" ".$strOperation.
" ".intval(
$val).
" )";
178 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.CODE IS NULL)";
180 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.CODE IS NULL OR NOT ":
"").
"(FR.CODE ".$strOperation.
" '".
$DB->ForSql(
$val).
"' )";
184 if (!empty($arSqlSearch))
185 $strSqlSearch =
"WHERE (".implode(
") AND (", $arSqlSearch).
")";
187 foreach ($arOrder as $by=>
$order)
189 $by = mb_strtoupper($by);
193 if ($by ==
"ID") $arSqlOrder[] =
" FR.ID ".$order.
" ";
194 elseif ($by ==
"CODE") $arSqlOrder[] =
" FR.CODE ".$order.
" ";
195 elseif ($by ==
"VOTES") $arSqlOrder[] =
" FR.VOTES ".$order.
" ";
198 $arSqlOrder[] =
" FR.MIN_POINTS ".$order.
" ";
203 if (!empty($arSqlOrder))
204 $strSqlOrder =
" ORDER BY ".implode(
", ", $arSqlOrder);
207 "SELECT FR.ID, FR.MIN_POINTS, FR.CODE, FR.VOTES ".
208 "FROM b_forum_points FR ".
213 return $DB->Query($strSql);
219 $arSqlSearch = Array();
221 $arSqlOrder = Array();
228 $key = mb_strtoupper($key_res[
"FIELD"]);
229 $strNegative = $key_res[
"NEGATIVE"];
230 $strOperation = $key_res[
"OPERATION"];
237 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.".
$key.
" IS NULL OR FR.".
$key.
"<=0)";
239 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.".$key.
" IS NULL OR NOT ":
"").
"(FR.".
$key.
" ".$strOperation.
" ".intval(
$val).
" )";
243 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.CODE IS NULL)";
245 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.CODE IS NULL OR NOT ":
"").
"(FR.CODE ".$strOperation.
" '".
$DB->ForSql(
$val).
"' )";
249 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FRL.LID IS NULL OR ".(
$DB->type ==
"MSSQL" ?
"LEN" :
"LENGTH").
"(FRL.LID)<=0)";
251 $arSqlSearch[] = ($strNegative==
"Y"?
" FRL.LID IS NULL OR NOT ":
"").
"(FRL.LID ".$strOperation.
" '".
$DB->ForSql(
$val).
"' )";
255 if (!empty($arSqlSearch))
256 $strSqlSearch =
" WHERE (".implode(
") AND (", $arSqlSearch).
") ";
258 foreach ($arOrder as $by=>
$order)
260 $by = mb_strtoupper($by);
264 if ($by ==
"ID") $arSqlOrder[] =
" FR.ID ".$order.
" ";
265 elseif ($by ==
"LID") $arSqlOrder[] =
" FRL.LID ".$order.
" ";
266 elseif ($by ==
"NAME") $arSqlOrder[] =
" FRL.NAME ".$order.
" ";
267 elseif ($by ==
"CODE") $arSqlOrder[] =
" FR.CODE ".$order.
" ";
268 elseif ($by ==
"VOTES") $arSqlOrder[] =
" FR.VOTES ".$order.
" ";
271 $arSqlOrder[] =
" FR.MIN_POINTS ".$order.
" ";
276 if (!empty($arSqlOrder))
277 $strSqlOrder =
" ORDER BY ".implode(
", ", $arSqlOrder);
280 "SELECT FR.ID, FR.MIN_POINTS, FR.CODE, FR.VOTES, FRL.LID, FRL.NAME ".
281 "FROM b_forum_points FR ".
282 " LEFT JOIN b_forum_points_lang FRL ON FR.ID = FRL.POINTS_ID ".
287 return $DB->Query($strSql);
296 "SELECT FR.ID, FR.MIN_POINTS, FR.CODE, FR.VOTES ".
297 "FROM b_forum_points FR ".
298 "WHERE FR.ID = ".$ID.
"";
314 "SELECT FR.ID, FR.MIN_POINTS, FR.CODE, FR.VOTES, FRL.LID, FRL.NAME ".
315 "FROM b_forum_points FR ".
316 " LEFT JOIN b_forum_points_lang FRL ON (FR.ID = FRL.POINTS_ID AND FRL.LID = '".$DB->ForSql($strLang).
"') ".
317 "WHERE FR.ID = ".$ID.
"";
331 $POINTS_ID = intval($POINTS_ID);
333 "SELECT FRL.POINTS_ID, FRL.LID, FRL.NAME ".
334 "FROM b_forum_points_lang FRL ".
335 "WHERE FRL.POINTS_ID = ".$POINTS_ID.
" ".
336 " AND FRL.LID = '".$DB->ForSql($strLang).
"' ";
356 if (in_array(1, $arUserGroups))
return True;
362 if (in_array(1, $arUserGroups))
return True;
368 if (in_array(1, $arUserGroups))
return True;
381 "id"=>
'POINTS2POST[MIN_NUM_POSTS]',
382 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_NUM_POSTS_EMPTY"));
387 "id"=>
'POINTS2POST[MIN_NUM_POSTS]',
388 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_NUM_POSTS_BAD"));
399 "id"=>
'POINTS2POST[MIN_NUM_POSTS]',
400 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_NUM_POSTS_EXIST"));
409 if (mb_strlen(round(
$arFields[
"POINTS_PER_POST"], 0)) > 14 || mb_strlen(mb_strstr(
$arFields[
"POINTS_PER_POST"],
".")) > 5 ||
410 preg_match(
"/[^0-9.]/",
$arFields[
"POINTS_PER_POST"]))
412 "id" =>
'POINTS2POST[POINTS_PER_POST]',
413 "text" =>
GetMessage(
"FORUM_PE_ERROR_MIN_POINTS_BAD"));
419 $GLOBALS[
"APPLICATION"]->ThrowException($e);
433 if (
$ID<=0)
return False;
437 $strUpdate =
$DB->PrepareUpdate(
"b_forum_points2post",
$arFields);
438 $strSql =
"UPDATE b_forum_points2post SET ".$strUpdate.
" WHERE ID = ".
$ID;
450 $DB->Query(
"DELETE FROM b_forum_points2post WHERE ID = ".
$ID, True);
459 $arSqlSearch =
array();
460 $arSqlOrder = Array();
468 $key = mb_strtoupper($key_res[
"FIELD"]);
469 $strNegative = $key_res[
"NEGATIVE"];
470 $strOperation = $key_res[
"OPERATION"];
475 case "MIN_NUM_POSTS":
477 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.".
$key.
" IS NULL OR FR.".
$key.
"<=0)";
479 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.".$key.
" IS NULL OR NOT ":
"").
"(FR.".
$key.
" ".$strOperation.
" ".intval(
$val).
" )";
483 if (
count($arSqlSearch) > 0)
484 $strSqlSearch =
"WHERE (".implode(
") AND (", $arSqlSearch).
") ";
486 foreach ($arOrder as $by=>
$order)
488 $by = mb_strtoupper($by);
491 if ($by ==
"ID") $arSqlOrder[] =
" FR.ID ".$order.
" ";
492 elseif ($by ==
"MIN_NUM_POSTS") $arSqlOrder[] =
" FR.MIN_NUM_POSTS ".$order.
" ";
495 $arSqlOrder[] =
" FR.POINTS_PER_POST ".$order.
" ";
496 $by =
"POINTS_PER_POST";
501 if (
count($arSqlOrder) > 0)
502 $strSqlOrder =
" ORDER BY ".implode(
", ", $arSqlOrder);
505 "SELECT FR.ID, FR.MIN_NUM_POSTS, FR.POINTS_PER_POST
506 FROM b_forum_points2post FR
520 "SELECT FR.ID, FR.MIN_NUM_POSTS, FR.POINTS_PER_POST ".
521 "FROM b_forum_points2post FR ".
522 "WHERE FR.ID = ".$ID.
"";
571 $FROM_USER_ID = intval($FROM_USER_ID);
572 if ($FROM_USER_ID<=0)
return False;
574 $TO_USER_ID = intval($TO_USER_ID);
575 if ($TO_USER_ID<=0)
return False;
580 $strUpdate =
$DB->PrepareUpdate(
"b_forum_user_points",
$arFields);
582 $strDatePostValue =
"";
585 $strDatePostValue .=
", DATE_UPDATE = ".$DB->GetNowFunction().
" ";
588 $strSql =
"UPDATE b_forum_user_points SET ".$strUpdate.$strDatePostValue.
" WHERE FROM_USER_ID = ".$FROM_USER_ID.
" AND TO_USER_ID = ".$TO_USER_ID;
592 $arUserFields =
array();
602 $arUserFields[
"USER_ID"] = $TO_USER_ID;
609 public static function Delete($FROM_USER_ID, $TO_USER_ID)
613 $FROM_USER_ID = intval($FROM_USER_ID);
614 if ($FROM_USER_ID<=0)
return False;
616 $TO_USER_ID = intval($TO_USER_ID);
617 if ($TO_USER_ID<=0)
return False;
619 $DB->Query(
"DELETE FROM b_forum_user_points WHERE FROM_USER_ID = ".$FROM_USER_ID.
" AND TO_USER_ID = ".$TO_USER_ID);
622 $arUserFields =
array();
632 $arUserFields[
"USER_ID"] = $TO_USER_ID;
642 $arSqlSearch = Array();
644 $arSqlOrder = Array();
651 $key = mb_strtoupper($key_res[
"FIELD"]);
652 $strNegative = $key_res[
"NEGATIVE"];
653 $strOperation = $key_res[
"OPERATION"];
660 $arSqlSearch[] = ($strNegative==
"Y"?
"NOT":
"").
"(FR.".
$key.
" IS NULL OR FR.".
$key.
"<=0)";
662 $arSqlSearch[] = ($strNegative==
"Y"?
" FR.".$key.
" IS NULL OR NOT ":
"").
"(FR.".
$key.
" ".$strOperation.
" ".intval(
$val).
" )";
666 if (!empty($arSqlSearch))
667 $strSqlSearch =
" WHERE (".implode(
") AND (", $arSqlSearch).
") ";
669 foreach ($arOrder as $by=>
$order)
671 $by = mb_strtoupper($by);
675 if ($by ==
"FROM_USER_ID") $arSqlOrder[] =
" FR.FROM_USER_ID ".$order.
" ";
676 elseif ($by ==
"POINTS") $arSqlOrder[] =
" FR.POINTS ".$order.
" ";
677 elseif ($by ==
"DATE_UPDATE") $arSqlOrder[] =
" FR.DATE_UPDATE ".$order.
" ";
680 $arSqlOrder[] =
" FR.TO_USER_ID ".$order.
" ";
685 if (!empty($arSqlOrder))
686 $strSqlOrder =
" ORDER BY ".implode(
", ", $arSqlOrder);
689 "SELECT FR.FROM_USER_ID, FR.TO_USER_ID, FR.POINTS, FR.DATE_UPDATE ".
690 "FROM b_forum_user_points FR ".
697 public static function GetByID($FROM_USER_ID, $TO_USER_ID)
701 $FROM_USER_ID = intval($FROM_USER_ID);
702 if ($FROM_USER_ID<=0)
705 $TO_USER_ID = intval($TO_USER_ID);
710 "SELECT FR.FROM_USER_ID, FR.TO_USER_ID, FR.POINTS, FR.DATE_UPDATE
711 FROM b_forum_user_points FR
712 WHERE FR.FROM_USER_ID = ".$FROM_USER_ID.
"
713 AND FR.TO_USER_ID = ".$TO_USER_ID.
"";
724 $TO_USER_ID = intval($TO_USER_ID);
725 if ($TO_USER_ID<=0)
return 0;
728 "SELECT SUM(FR.POINTS) as SM ".
729 "FROM b_forum_user_points FR ".
730 "WHERE FR.TO_USER_ID = ".$TO_USER_ID.
"";
735 return intval(
$res[
"SM"]);
static GetFilterOperation($key)
static CanUserDeletePoints2Post($ID, $arUserGroups)
static GetList($arOrder=array("MIN_NUM_POSTS"=>"ASC"), $arFilter=array())
static CanUserAddPoints2Post($arUserGroups)
static CheckFields($ACTION, &$arFields, $ID=0)
static CanUserUpdatePoints2Post($ID, $arUserGroups)
static Update($ID, $arFields)
static CanUserDeletePoints($ID, $arUserGroups)
static CheckFields($ACTION, &$arFields, $ID=0)
static GetLangByID($POINTS_ID, $strLang)
static GetListEx($arOrder=array("MIN_POINTS"=>"ASC"), $arFilter=array())
static CanUserUpdatePoints($ID, $arUserGroups)
static GetByIDEx($ID, $strLang)
static GetList($arOrder=array("MIN_POINTS"=>"ASC"), $arFilter=array())
static Update($ID, $arFields)
static CanUserAddPoints($arUserGroups)
static CountUserPoints($USER_ID=0, $iCnt=false)
static GetByUSER_ID($USER_ID)
static Add($fields, $strUploadDir=false)
static Update($ID, $arFields, $strUploadDir=false, $UpdateByUserId=false)
static CountSumPoints($TO_USER_ID)
static CanUserUpdateUserPoints($iUserID)
static Update($FROM_USER_ID, $TO_USER_ID, $arFields)
static CheckFields($ACTION, &$arFields)
static CanUserDeleteUserPoints($iUserID)
static GetList($arOrder=array("TO_USER_ID"=>"ASC"), $arFilter=array())
static GetByID($FROM_USER_ID, $TO_USER_ID)
static CanUserAddUserPoints($iUserID)
static Delete($FROM_USER_ID, $TO_USER_ID)
static GetList($by="sort", $order="asc", $arFilter=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
DelDuplicateSort(&$arSort)
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."%"
$GLOBALS['_____370096793']