Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
dailylimit.php
1<?php
10
12
14use Bitrix\Bitrix24;
15
21{
23 protected static $instance;
24
30 public static function instance()
31 {
32 if (!static::$instance)
33 {
34 static::$instance = new static();
35 }
36
37 return static::$instance;
38 }
39
43 public function __construct()
44 {
45 static $isRatingCalculated = false;
46 if (!$isRatingCalculated)
47 {
48 $isRatingCalculated = true;
50 }
51 }
52
58 public function getCurrent()
59 {
60 return Model\DailyCounterTable::getCurrentFieldValue('SENT_CNT');
61 }
62
68 public function getLimit()
69 {
70 $senderLimit = (int)Config\Option::get("sender", "~mail_counter_limit_daily", 1000);
71
72 $b24MailCounter = new Bitrix24\MailCounter();
73 $b24Limit = $b24MailCounter->getDailyLimit();
74 if (!$b24Limit)
75 {
76 return $senderLimit;
77 }
78
79 return min($senderLimit, $b24Limit);
80
81 }
82
89 public function setLimit($limit)
90 {
91 Config\Option::set("sender", "~mail_counter_limit_daily", intval($limit));
92 }
93
99 public static function increment()
100 {
101 Model\DailyCounterTable::incrementFieldValue('SENT_CNT');
102 }
103
109 public static function incrementError()
110 {
111 Model\DailyCounterTable::incrementFieldValue('ERROR_CNT');
112 }
113}