- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/lib/invitation/register.php
- Класс: BitrixIntranetInvitationRegister
- Вызов: Register::checkItems
static function checkItems($items, &$errors)
{
$emailItems = [];
$phoneItems = [];
$errorEmailItems = [];
$errorPhoneItems = [];
$phoneCnt = 0;
$emailCnt = 0;
$dailyPhoneLimit = (
Loader::includeModule('bitrix24')
&& CBitrix24::getLicenseType() === 'project'
? 10
: 0 // unlimited
);
$date = new DateTime();
$date->add('-1 days');
$pastPhoneInvitationNumber = 0;
if ($dailyPhoneLimit > 0)
{
$pastPhoneInvitationNumber = InvitationTable::getList([
'select' => [ 'ID' ],
'filter' => [
'=INVITATION_TYPE' => BitrixIntranetInvitation::TYPE_PHONE,
'>DATE_CREATE' => $date,
],
'count_total' => true,
])->getCount();
}
$dailyPhoneLimitExceeded = false;
foreach ($items as $item)
{
if (isset($item["PHONE"]))
{
$item["PHONE"] = trim($item["PHONE"]);
if (self::checkPhone($item))
{
if (
$dailyPhoneLimit <= 0
|| ($pastPhoneInvitationNumber + $phoneCnt) < $dailyPhoneLimit
)
{
$phoneItems[] = $item;
$phoneCnt++;
}
else
{
$dailyPhoneLimitExceeded = true;
// $errorPhoneItems[] = $item["PHONE"];
}
}
else
{
$errorPhoneItems[] = $item["PHONE"];
}
}
elseif (isset($item["EMAIL"]))
{
$item["EMAIL"] = trim($item["EMAIL"]);
if (check_email($item["EMAIL"]))
{
$emailItems[] = $item;
$emailCnt++;
}
else
{
$errorEmailItems[] = $item["EMAIL"];
}
}
}
if ($dailyPhoneLimitExceeded)
{
$errors[] = Loc::getMessage("INTRANET_INVITATION_DAILY_PHONE_LIMIT_EXCEEDED");
}
if ($phoneCnt >= 5)
{
$errors[] = Loc::getMessage("INTRANET_INVITATION_PHONE_LIMIT_EXCEEDED");
}
if ($emailCnt > self::getMaxEmailCount())
{
$errors[] = Loc::getMessage("INTRANET_INVITATION_EMAIL_LIMIT_EXCEEDED");
}
if (!empty($errorEmailItems))
{
$errors[] = Loc::getMessage("INTRANET_INVITATION_EMAIL_ERROR")." ".implode(", ", $errorEmailItems);
}
if (!empty($errorPhoneItems))
{
$errors[] = Loc::getMessage("INTRANET_INVITATION_PHONE_ERROR")." ".implode(", ", $errorPhoneItems);
}
return [
"PHONE_ITEMS" => $phoneItems,
"EMAIL_ITEMS" => $emailItems
];
}