Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
recipientcontroller.php
1<?php
3
4use Bitrix\Crm\Timeline;
5
9
14class RecipientController extends Timeline\EntityController
15{
17 protected static $instance = null;
18
24 public static function getInstance()
25 {
26 if(self::$instance === null)
27 {
28 self::$instance = new static();
29 }
30 return self::$instance;
31 }
32
38 public function getEntityTypeID()
39 {
40 return \CCrmOwnerType::Wait;
41 }
42
49 public function onCreate($id, array $params)
50 {
51
52 }
53
60 public function onModify($id, array $params)
61 {
62
63 }
64
71 public function onDelete($ownerID, array $params)
72 {
73
74 }
75
83 public function prepareHistoryDataModel(array $data, array $options = null)
84 {
85 $settings = (object) ((isset($data['SETTINGS']) && is_array($data['SETTINGS'])) ? $data['SETTINGS'] : array());
86 $data = parent::prepareHistoryDataModel($data, $options);
87
88 try
89 {
90
91 if ($settings->isAds)
92 {
93 $entity = new Entity\Ad($settings->letterId);
94 $settings->path = '/marketing/ads/edit/' . $settings->letterId . '/';
95 $settings->messageName = $entity->getMessage()->getName();
96 }
97 else
98 {
99 $entity = new Entity\Letter($settings->letterId);
100 $settings->path = '/marketing/letter/edit/' . $settings->letterId . '/';
101 $settings->messageName = $entity->getMessage()->getName();
102 }
103 $settings->letterTitle = $entity->get('TITLE');
104
105 if ($settings->recipient)
106 {
107 $row = PostingRecipientTable::getRow([
108 'select' => ['IS_READ', 'IS_CLICK', 'IS_UNSUB', 'STATUS'],
109 'filter' => ['=ID' => $settings->recipient['id']]
110 ]);
111 $settings->isRead = $row ? $row['IS_READ'] == 'Y' : false;
112 $settings->isClick = $row ? $row['IS_CLICK'] == 'Y' : false;
113 $settings->isUnsub = $row ? $row['IS_UNSUB'] == 'Y' : false;
114 $settings->isError = $row ? $row['STATUS'] === PostingRecipientTable::SEND_RESULT_ERROR : false;
115 }
116
117
118 $data['SETTINGS'] = (array) $settings;
119 }
120 catch (ArgumentException $e)
121 {
122 return $data;
123 }
124
125 return $data;
126 }
127}