Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contactlist.php
1<?php
8namespace Bitrix\Sender;
9
14
15Loc::loadMessages(__FILE__);
16
34{
40 public static function getTableName()
41 {
42 return 'b_sender_contact_list';
43 }
44
50 public static function getMap()
51 {
52 return array(
53 'CONTACT_ID' => array(
54 'data_type' => 'integer',
55 'primary' => true,
56 ),
57 'LIST_ID' => array(
58 'data_type' => 'integer',
59 'primary' => true,
60 ),
61 'LIST' => array(
62 'data_type' => 'Bitrix\Sender\ListTable',
63 'reference' => array('=this.LIST_ID' => 'ref.ID'),
64 ),
65 'CONTACT' => array(
66 'data_type' => 'Bitrix\Sender\ContactTable',
67 'reference' => array('=this.CONTACT_ID' => 'ref.ID'),
68 ),
69 );
70 }
71
79 public static function addIfNotExist($contactId, $listId)
80 {
81 $result = false;
82 $arPrimary = array('CONTACT_ID' => $contactId, 'LIST_ID' => $listId);
83 if( !($arList = static::getRowById($arPrimary) ))
84 {
85 $resultAdd = static::add($arPrimary);
86 if ($resultAdd->isSuccess())
87 {
88 $result = true;
89 }
90 }
91 else
92 {
93 $result = true;
94 }
95
96 return $result;
97 }
105 public static function deleteList(array $filter)
106 {
107 $entity = static::getEntity();
108 $connection = $entity->getConnection();
109
110 \CTimeZone::disable();
111 $sql = sprintf(
112 'DELETE FROM %s WHERE %s',
113 $connection->getSqlHelper()->quote($entity->getDbTableName()),
114 Query::buildFilterSql($entity, $filter)
115 );
116 $res = $connection->query($sql);
117 \CTimeZone::enable();
118
119 return $res;
120 }
121}
static loadMessages($file)
Definition loc.php:64
static deleteList(array $filter)
static addIfNotExist($contactId, $listId)