1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
limiter.php
См. документацию.
1<?php
8
9namespace Bitrix\Sender\Integration\Bitrix24\Limitation;
10
11use Bitrix\Main\Config\Option;
12use Bitrix\Main\Localization\Loc;
13use Bitrix\Bitrix24\MailCounter as B24MailCounter;
14
15use Bitrix\Main\Mail\Sender;
16use Bitrix\Main\Mail\SenderSendCounter;
17use Bitrix\Sender\Integration\Bitrix24\Service;
18use Bitrix\Sender\Transport;
19
20Loc::loadMessages(__FILE__);
21
27{
29 protected static $limiters;
30
36 public static function getList()
37 {
38 if (!Service::isCloud())
39 {
40 return array();
41 }
42
43 if (empty(self::$limiters))
44 {
45 self::$limiters = array(
46 self::getMonthly(),
47 self::getDaily(),
48 );
49 }
50
51 return self::$limiters;
52 }
53
59 public static function getMonthlyLimitPercentage()
60 {
61 $value = (int) Option::get('sender', '~mail_month_limit_percent', 90);
62 $value = $value < 10 ? 10 : $value;
63 $value = $value > 100 ? 100 : $value;
64
65 return $value;
66 }
67
74 public static function setMonthlyLimitPercentage($value)
75 {
76 $value = (int) $value;
77 $value = $value < 10 ? 10 : $value;
78 $value = $value > 100 ? 100 : $value;
79
80 Option::set('sender', '~mail_month_limit_percent', $value);
81 }
82
88 public static function getMonthly()
89 {
90 $counter = new B24MailCounter();
92 ->withName('mail_per_month')
93 ->withLimit($counter->getLimit())
94 ->withUnit("1 " . Transport\iLimiter::MONTHS)
95 ->withCurrent(
96 function () use ($counter)
97 {
98 return $counter->getMonthly();
99 }
100 )
101 ->setParameter(
102 'globalHelpUri',
103 'javascript:top.BX.Helper.show("redirect=detail&code=6904325")'
104 )
105 ->setParameter('percentage', self::getMonthlyLimitPercentage());
106
108 {
109 $limiter->setParameter('setupUri', 'javascript: top.BX.Sender.B24License.showMailLimitPopup();');
110 }
111
112 return $limiter;
113 }
114
120 public static function getEmailMonthly($email)
121 {
124 ->withName('mail_per_email_per_day')
125 ->withLimit(Sender::getEmailLimit($email))
126 ->withUnit("1 " . Transport\iLimiter::DAYS)
127 ->withCurrent(
128 function () use ($counter, $email)
129 {
130 return Sender::getEmailLimit($email) === null ? -1 : $counter->get($email);
131 }
132 )
133 ->setHidden(true)
134 ->setParameter(
135 'globalHelpUri',
136 'javascript:top.BX.Helper.show("redirect=detail&code=6904325")'
137 );
138
140 {
141 $limiter->setParameter('setupUri', 'javascript: top.BX.Sender.B24License.showMailLimitPopup();');
142 }
143
144 return $limiter;
145 }
146
152 protected static function getDaily()
153 {
154 $counter = new DailyLimit();
156 ->withName('mail_per_day')
157 ->withLimit($counter->getLimit())
158 ->withUnit("1 " . Transport\iLimiter::DAYS)
159 ->withCurrent(
160 function () use ($counter)
161 {
162 return $counter->getCurrent();
163 }
164 )
165 ->setParameter('setupUri', 'javascript:top.BX.Helper.show("redirect=detail&code=6846227")')
166 ->setParameter('setupCaption', Loc::getMessage('SENDER_INTEGRATION_BITRIX24_LIMITER_DAILY_DETAILS'));
167 }
168
169
170 public static function getPortalVerification(): Transport\iLimiter
171 {
172 $verify = new PortalVerifyLimit();
174 ->withName('portal_verify')
175 ->withLimit($verify->getLimit())
176 // ->withUnit("1 " . Transport\iLimiter::DAYS)
177 ->setHidden(true)
178 ->withCurrent(
179 function () use ($verify)
180 {
181 return $verify->getCurrent();
182 }
183 )
184 ->setParameter('setupUri', 'javascript:top.BX.Helper.show("redirect=detail&code=14406430")')
185 ->setParameter('setupCaption', Loc::getMessage('SENDER_INTEGRATION_BITRIX24_LIMITER_DAILY_DETAILS'));
186 }
187}
static setMonthlyLimitPercentage($value)
Определения limiter.php:74
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$email
Определения payment.php:49
$counter
Определения options.php:5