Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contactconnect.php
1<?php
3
7
8
38class ContactConnectTable extends Main\Entity\DataManager
39{
40 const TYPE_PORTAL = 'P'; // bitrix24 portal
41 const TYPE_EXTERNAL = 'E'; // external site (box)
42
48 public static function getTableName()
49 {
50 return 'b_socialservices_contact_connect';
51 }
52
58 public static function getMap()
59 {
60 return array(
61 'ID' => array(
62 'data_type' => 'integer',
63 'primary' => true,
64 'autocomplete' => true,
65 ),
66 'TIMESTAMP_X' => array(
67 'data_type' => 'datetime',
68 ),
69 'CONTACT_ID' => array(
70 'data_type' => 'integer',
71 ),
72 'LINK_ID' => array(
73 'data_type' => 'integer',
74 ),
75 'CONTACT_PROFILE_ID' => array(
76 'data_type' => 'integer',
77 'required' => true,
78 ),
79 'CONTACT_PORTAL' => array(
80 'data_type' => 'string',
81 'required' => true,
82 ),
83 'LAST_AUTHORIZE' => array(
84 'data_type' => 'datetime',
85 ),
86 'CONNECT_TYPE' => array(
87 'data_type' => 'enum',
88 'values' => array(static::TYPE_PORTAL, static::TYPE_EXTERNAL),
89 ),
90 'CONTACT' => array(
91 'data_type' => 'Bitrix\Socialservices\ContactTable',
92 'reference' => array('=this.CONTACT_ID' => 'ref.ID'),
93 ),
94 'LINK' => array(
95 'data_type' => 'Bitrix\Socialservices\UserLinkTable',
96 'reference' => array('=this.LINK_ID' => 'ref.ID'),
97 ),
98 );
99 }
100
101 public static function onBeforeUpdate(Entity\Event $event)
102 {
103 $result = new Entity\EventResult();
104 $data = $event->getParameter("fields");
105
106 if(!isset($data['TIMESTAMP_X']))
107 {
108 $data['TIMESTAMP_X'] = new DateTime();
109 $result->modifyFields($data);
110 }
111 }
112
113 public static function deleteByLink($linkId)
114 {
115 $connection = \Bitrix\Main\Application::getConnection();
116 return $connection->query("
117DELETE
118FROM ".self::getTableName()."
119WHERE LINK_ID='".intval($linkId)."'
120");
121 }
122
123 public static function deleteByContact($contactId)
124 {
125 $connection = \Bitrix\Main\Application::getConnection();
126 return $connection->query("
127DELETE
128FROM ".self::getTableName()."
129WHERE CONTACT_ID='".intval($contactId)."'
130");
131 }
132
133}
static onBeforeUpdate(Entity\Event $event)