1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
limitation.php
См. документацию.
1<?php
2namespace Bitrix\MessageService\Sender;
3
4use Bitrix\Main\Config\Option;
5use Bitrix\MessageService\Internal\Entity\MessageTable;
6
8{
9 private static $options;
10 private static $optionName = 'sender.limitation.daily';
11 private static $defaultLimit = 0;
12
13 public static function getDailyLimits()
14 {
15 $limits = array();
16 $counts = MessageTable::getAllDailyCount();
17
18 foreach (SmsManager::getSenders() as $sender)
19 {
20 $sid = $sender->getId();
21 foreach ($sender->getFromList() as $from)
22 {
23 $key = $sid.':'.$from['id'];
24 $limits[$key] = array(
25 'senderId' => $sid,
26 'fromId' => $from['id'],
27 'limit' => static::getDailyLimit($sid, $from['id']),
28 'current' => isset($counts[$key]) ? $counts[$key] : 0
29 );
30 }
31 }
32
33 return $limits;
34 }
35
36 public static function hasDailyLimits(): bool
37 {
38 foreach (SmsManager::getSenders() as $sender)
39 {
40 foreach ($sender->getFromList() as $from)
41 {
42 $limit = static::getDailyLimit($sender->getId(), $from['id']);
43 if (isset($limit) && $limit > 0)
44 {
45 return true;
46 }
47 }
48 }
49
50 return false;
51 }
52
53 public static function getDailyLimit($senderId, $fromId)
54 {
55 $key = $senderId . ':' . $fromId;
56 return static::getOption($key, static::$defaultLimit);
57 }
58
59 public static function setDailyLimit($senderId, $fromId, $limit)
60 {
61 $key = $senderId . ':' . $fromId;
62 static::setOption($key, (int)$limit);
63 MessageTable::returnDeferredToQueue($senderId, $fromId);
64 return true;
65 }
66
67 public static function checkDailyLimit($senderId, $fromId)
68 {
69 $limit = static::getDailyLimit($senderId, $fromId);
70 if ($limit > 0)
71 {
72 $current = MessageTable::getDailyCount($senderId, $fromId);
73
74 return ($current < $limit);
75 }
76 return true;
77 }
78
79 public static function getRetryTime()
80 {
81 $time = static::getOption('retryTime', [
82 'h' => 9,
83 'i' => 0,
84 'auto' => true,
85 'tz' => ''
86 ]);
87
88 return $time;
89 }
90
91 public static function setRetryTime(array $params)
92 {
93 $result = [
94 'h' => (int)$params['h'],
95 'i' => (int)$params['i'],
96 'auto' => (bool)$params['auto'],
97 'tz' => (string)$params['tz'],
98 ];
99
100 static::setOption('retryTime', $result);
101 return true;
102 }
103
109 private static function setOptions(array $options)
110 {
111 static::$options = $options;
112 Option::set('messageservice', static::$optionName, serialize($options));
113 return true;
114 }
115
121 private static function getOptions()
122 {
123 if (static::$options === null)
124 {
125 $optionsString = Option::get('messageservice', static::$optionName);
126 if (\CheckSerializedData($optionsString))
127 {
128 static::$options = unserialize($optionsString, ['allowed_classes' => false]);
129 }
130
131 if (!is_array(static::$options))
132 {
133 static::$options = array();
134 }
135 }
136 return static::$options;
137 }
138
147 private static function setOption($optionName, $optionValue)
148 {
149 $options = static::getOptions();
150 if (!isset($options[$optionName]) || $options[$optionName] !== $optionValue)
151 {
152 $options[$optionName] = $optionValue;
153 static::setOptions($options);
154 }
155 return true;
156 }
157
165 private static function getOption($optionName, $defaultValue = null)
166 {
167 $options = static::getOptions();
168 return isset($options[$optionName]) ? $options[$optionName] : $defaultValue;
169 }
170
175 public static function clearOptions()
176 {
177 static::$options = array();
178 Option::delete('messageservice', array('name' => static::$optionName));
179 return true;
180 }
181
182}
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
static getDailyLimit($senderId, $fromId)
Определения limitation.php:53
static setDailyLimit($senderId, $fromId, $limit)
Определения limitation.php:59
static checkDailyLimit($senderId, $fromId)
Определения limitation.php:67
static setRetryTime(array $params)
Определения limitation.php:91
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
CheckSerializedData($str, $max_depth=200)
Определения tools.php:4949
$time
Определения payment.php:61
if(empty($signedUserToken)) $key
Определения quickway.php:257
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$optionValue
Определения options.php:3512