294 $entity = static::getEntity();
295 $connection = $entity->getConnection();
297 \CTimeZone::disable();
299 'DELETE FROM %s WHERE %s',
300 $connection->getSqlHelper()->quote($entity->getDbTableName()),
301 Query::buildFilterSql($entity, $filter)
303 $res = $connection->query($sql);
304 \CTimeZone::enable();
337 if(array_key_exists(
'LIST_CODE', $ar) && array_key_exists(
'LIST_NAME', $ar))
340 unset($ar[
'LIST_CODE'], $ar[
'LIST_NAME']);
343 $ar[
'EMAIL'] = mb_strtolower($ar[
'EMAIL']);
344 $contactDb = ContactTable::getList(array(
345 'select' => array(
'ID'),
347 '=CODE' => $ar[
'EMAIL'],
348 '=TYPE_ID' => Recipient\Type::EMAIL
351 if($contact = $contactDb->fetch())
353 $id = $contact[
'ID'];
357 $ar[
'TYPE_ID'] = Recipient\Type::EMAIL;
358 $ar[
'CODE'] = $ar[
'EMAIL'];
361 $resultAdd = static::add($ar);
362 if($resultAdd->isSuccess())
363 $id = $resultAdd->getId();
401 $startTime = getmicrotime();
402 $withoutNav = empty($pageNumber);
404 $onlyOneLoop =
false;
414 if($dataDb->resourceCDBResult)
416 $dataDb = $dataDb->resourceCDBResult;
418 elseif($dataDb->resource)
420 $dataDb = new \CDBResult($dataDb->resource);
424 $dataDb = new \CDBResult();
425 $dataDb->initFromArray(array());
428 if(!is_subclass_of($dataDb,
'CDBResultMysql'))
434 while($timeout==0 || getmicrotime()-$startTime < $timeout)
438 $dataDb->navStart($rowsInPage,
false, $pageNumber);
439 $countAll = $dataDb->selectedRowsCount();
443 while ($row = $dataDb->fetch())
461 $contactDb = ContactTable::getList(array(
462 'select' => array(
'ID'),
463 'filter' => array(
'EMAIL' => $row[
'EMAIL'])
465 if($contactRow = $contactDb->fetch())
467 $id = $contactRow[
'ID'];
472 $resultAdd = static::add(array(
473 'NAME' => $row[
'NAME'],
474 'EMAIL' => $row[
'EMAIL'],
475 'USER_ID' => $row[
'USER_ID']
477 if ($resultAdd->isSuccess())
479 $id = $resultAdd->getId();
499 if ($dataDb->NavPageCount <= $pageNumber)
507 $result = $pageNumber;
518 $countProgress = $countAll;
522 $countProgress = ($pageNumber-1) * $dataDb->NavPageSize;
523 if (!$result || $countProgress > $countAll) $countProgress = $countAll;
528 'COUNT_ALL' => $countAll,
529 'COUNT_PROGRESS' => $countProgress,
530 'COUNT_PROCESSED' => $countProcessed,
531 'COUNT_NEW' => $countAdded,
532 'COUNT_ERROR' => $countError,
549 public static function upload(array $list,
bool $isBlacklist =
false, ?
int $listId =
null)
553 foreach ($list as $item)
555 if (is_string($item))
557 $item = [
'CODE' => $item];
560 if (empty($item[
'CODE']))
564 $code = trim((
string)$item[
'CODE']);
566 $updateItem = $updateItemFactory->make($code, $item[
'NAME'] ??
null);
569 $updateCollection->append($updateItem);
574 if ($updateCollection->count() === 0)
583 return $updateCollection->count();
586 $row = ListTable::getRowById($listId);
595 return ContactListTable::getCount(array(
'=LIST_ID' => $listId));