1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
auxiliary.php
См. документацию.
1<?php
2
4
6
7/***********************************************************************/
8/*********** CSaleAuxiliary ******************************************/
9/***********************************************************************/
11{
12 public static function PrepareItemMD54Where($val, $key, $operation, $negative, $field, &$arField, &$arFilter)
13 {
14 $val1 = md5($val);
15 return "(".($negative=="Y"?" A.ITEM_MD5 IS NULL OR NOT ":"")."(A.ITEM_MD5 ".$operation." '".$GLOBALS["DB"]->ForSql($val1)."' )".")";
16 }
17
18 //********** CHECK **************//
19 public static function CheckAccess($userID, $itemMD5, $periodLength, $periodType)
20 {
21 global $DB;
22
23 $userID = intval($userID);
24 if ($userID <= 0)
25 return false;
26
27 $itemMD5 = Trim($itemMD5);
28 if ($itemMD5 == '')
29 return false;
30
31 $periodLength = intval($periodLength);
32 if ($periodLength <= 0)
33 return False;
34
35 $periodType = Trim($periodType);
36 $periodType = mb_strtoupper($periodType);
37 if ($periodType == '')
38 return False;
39
40 $checkVal = 0;
41 if ($periodType == "I")
42 $checkVal = mktime(date("H"), date("i") - $periodLength, date("s"), date("m"), date("d"), date("Y"));
43 elseif ($periodType == "H")
44 $checkVal = mktime(date("H") - $periodLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
45 elseif ($periodType == "D")
46 $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $periodLength, date("Y"));
47 elseif ($periodType == "W")
48 $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 7 * $periodLength, date("Y"));
49 elseif ($periodType == "M")
50 $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - $periodLength, date("d"), date("Y"));
51 elseif ($periodType == "Q")
52 $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - 3 * $periodLength, date("d"), date("Y"));
53 elseif ($periodType == "S")
54 $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - 6 * $periodLength, date("d"), date("Y"));
55 elseif ($periodType == "Y")
56 $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") - $periodLength);
57
58 if ($checkVal <= 0)
59 return False;
60
61 $dbAuxiliary = CSaleAuxiliary::GetList(
62 array(),
63 array(
64 "USER_ID" => $userID,
65 "ITEM_MD5" => $itemMD5,
66 ">=DATE_INSERT" => Date($GLOBALS["DB"]->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), $checkVal)
67 ),
68 false,
69 false,
70 array("*")
71 );
72 if ($arAuxiliary = $dbAuxiliary->Fetch())
73 return $arAuxiliary;
74
75 return false;
76 }
77
78 //********** ADD, UPDATE, DELETE **************//
79 public static function CheckFields($ACTION, &$arFields, $ID = 0)
80 {
81 if ((is_set($arFields, "USER_ID") || $ACTION=="ADD") && intval($arFields["USER_ID"]) <= 0)
82 {
83 $GLOBALS["APPLICATION"]->ThrowException("Empty user field", "EMPTY_USER_ID");
84 return false;
85 }
86 if ((is_set($arFields, "ITEM") || $ACTION=="ADD") && $arFields["ITEM"] == '')
87 {
88 $GLOBALS["APPLICATION"]->ThrowException("Empty item field", "EMPTY_ITEM");
89 return false;
90 }
91 if ((is_set($arFields, "ITEM_MD5") || $ACTION=="ADD") && $arFields["ITEM_MD5"] == '')
92 {
93 $GLOBALS["APPLICATION"]->ThrowException("Empty item md5 field", "EMPTY_ITEM_MD5");
94 return false;
95 }
96 if ((is_set($arFields, "DATE_INSERT") || $ACTION=="ADD") && $arFields["DATE_INSERT"] == '')
97 {
98 $GLOBALS["APPLICATION"]->ThrowException("Empty date insert field", "EMPTY_DATE_INSERT");
99 return false;
100 }
101
102 if (is_set($arFields, "ITEM_MD5"))
103 $arFields["ITEM_MD5"] = md5($arFields["ITEM_MD5"]);
104
105 if (is_set($arFields, "USER_ID"))
106 {
107 $dbUser = CUser::GetByID($arFields["USER_ID"]);
108 if (!$dbUser->Fetch())
109 {
110 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SGMA_NO_USER")), "ERROR_NO_USER_ID");
111 return false;
112 }
113 }
114
115 $connection = Application::getConnection();
116 $helper = $connection->getSqlHelper();
117 unset($arFields['TIMESTAMP_X']);
118 $arFields['~TIMESTAMP_X'] = $helper->getCurrentDateTimeFunction();
119
120 return true;
121 }
122
123 public static function Delete($ID)
124 {
125 global $DB;
126
127 $ID = intval($ID);
128 if ($ID <= 0)
129 return False;
130
131 return $DB->Query("DELETE FROM b_sale_auxiliary WHERE ID = ".$ID." ", true);
132 }
133
134 public static function DeleteByUserID($userID)
135 {
136 global $DB;
137
138 $userID = intval($userID);
139 if ($userID <= 0)
140 return False;
141
142 return $DB->Query("DELETE FROM b_sale_auxiliary WHERE USER_ID = ".$userID." ", true);
143 }
144
145 //********** EVENTS **************//
146 public static function OnUserDelete($userID)
147 {
148 $userID = intval($userID);
149
150 $bSuccess = True;
151
152 if (!CSaleAuxiliary::DeleteByUserID($userID))
153 $bSuccess = False;
154
155 return $bSuccess;
156 }
157
158 //********** AGENTS **************//
159 public static function DeleteOldAgent($periodLength, $periodType)
160 {
161 CSaleAuxiliary::DeleteByTime($periodLength, $periodType);
162
163 global $pPERIOD;
164 $pPERIOD = 12*60*60;
165 return 'CSaleAuxiliary::DeleteOldAgent('.$periodLength.', "'.$periodType.'");';
166 }
167}
$connection
Определения actionsdefinitions.php:38
Определения auxiliary.php:11
static PrepareItemMD54Where($val, $key, $operation, $negative, $field, &$arField, &$arFilter)
Определения auxiliary.php:12
static DeleteOldAgent($periodLength, $periodType)
Определения auxiliary.php:159
static Delete($ID)
Определения auxiliary.php:123
static DeleteByUserID($userID)
Определения auxiliary.php:134
static CheckFields($ACTION, &$arFields, $ID=0)
Определения auxiliary.php:79
static OnUserDelete($userID)
Определения auxiliary.php:146
static CheckAccess($userID, $itemMD5, $periodLength, $periodType)
Определения auxiliary.php:19
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения auxiliary.php:59
static DeleteByTime($periodLength, $periodType)
Определения auxiliary.php:157
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if($ajaxMode) $ID
Определения get_user.php:27
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$val
Определения options.php:1793
const SITE_ID
Определения sonet_set_content_view.php:12
$GLOBALS['_____370096793']
Определения update_client.php:1
$arFilter
Определения user_search.php:106