1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
usertable.php
См. документацию.
1
<?
2
namespace
Bitrix\Socialservices;
3
4
use \Bitrix\Main\Entity;
5
use Bitrix\Main\ORM\Event;
6
use Bitrix\Socialservices\EncryptedToken\FieldValue;
7
8
25
class
UserTable
extends
Entity\DataManager
26
{
27
const
ALLOW
=
'Y'
;
28
const
DISALLOW
=
'N'
;
29
30
const
INITIALIZED
=
'Y'
;
31
const
NOT_INITIALIZED
=
'N'
;
32
33
private
static
$deletedList =
array
();
34
35
public
static
function
getFilePath
()
36
{
37
return
__FILE__;
38
}
39
40
public
static
function
getTableName
()
41
{
42
return
'b_socialservices_user'
;
43
}
44
45
public
static
function
getMap
()
46
{
47
$fieldsMap =
array
(
48
'ID'
=>
array
(
49
'data_type'
=>
'integer'
,
50
'primary'
=>
true
,
51
'autocomplete'
=>
true
,
52
),
53
'LOGIN'
=>
array
(
54
'data_type'
=>
'string'
,
55
'required'
=>
true
,
56
),
57
'NAME'
=>
array
(
58
'data_type'
=>
'string'
,
59
),
60
'LAST_NAME'
=>
array
(
61
'data_type'
=>
'string'
,
62
),
63
'EMAIL'
=>
array
(
64
'data_type'
=>
'string'
,
65
),
66
'PERSONAL_PHOTO'
=>
array
(
67
'data_type'
=>
'string'
,
68
),
69
'EXTERNAL_AUTH_ID'
=>
array
(
70
'data_type'
=>
'string'
,
71
'required'
=>
true
,
72
),
73
'USER_ID'
=>
array
(
74
'data_type'
=>
'integer'
,
75
'required'
=>
true
,
76
),
77
'XML_ID'
=>
array
(
78
'data_type'
=>
'string'
,
79
'required'
=>
true
,
80
),
81
'CAN_DELETE'
=>
array
(
82
'data_type'
=>
'boolean'
,
83
'values'
=>
array
(self::DISALLOW, self::ALLOW)
84
),
85
'PERSONAL_WWW'
=>
array
(
86
'data_type'
=>
'string'
,
87
),
88
'PERMISSIONS'
=>
array
(
89
'data_type'
=>
'string'
,
90
),
91
'OATOKEN'
=>
array
(
92
'data_type'
=>
'\\Bitrix\\Socialservices\\EncryptedToken\\CryptoField'
,
93
'encryption_complete'
=> static::cryptoEnabled(
'OATOKEN'
)
94
),
95
'OATOKEN_EXPIRES'
=>
array
(
96
'data_type'
=>
'integer'
,
97
),
98
'OASECRET'
=>
array
(
99
'data_type'
=>
'\\Bitrix\\Socialservices\\EncryptedToken\\CryptoField'
,
100
'encryption_complete'
=> static::cryptoEnabled(
'OASECRET'
)
101
),
102
'REFRESH_TOKEN'
=>
array
(
103
'data_type'
=>
'\\Bitrix\\Socialservices\\EncryptedToken\\CryptoField'
,
104
'encryption_complete'
=> static::cryptoEnabled(
'REFRESH_TOKEN'
)
105
),
106
'SEND_ACTIVITY'
=>
array
(
107
'data_type'
=>
'boolean'
,
108
'values'
=>
array
(self::DISALLOW, self::ALLOW)
109
),
110
'SITE_ID'
=>
array
(
111
'data_type'
=>
'string'
,
112
),
113
'INITIALIZED'
=>
array
(
114
'data_type'
=>
'boolean'
,
115
'values'
=>
array
(self::NOT_INITIALIZED, self::INITIALIZED)
116
),
117
'USER'
=>
array
(
118
'data_type'
=>
'Bitrix\Main\UserTable'
,
119
'reference'
=>
array
(
'=this.USER_ID'
=>
'ref.ID'
),
120
),
121
);
122
123
return
$fieldsMap;
124
}
125
126
public
static
function
filterFields
(
$fields
, $oldValue =
null
)
127
{
128
$map
= static::getMap();
129
foreach
(
$fields
as
$key
=> $value)
130
{
131
if
(!array_key_exists(
$key
,
$map
))
132
{
133
unset(
$fields
[
$key
]);
134
}
135
elseif
(isset(
$map
[
$key
][
'required'
]) &&
$map
[
$key
][
'required'
] && empty(
$fields
[
$key
]))
136
{
137
unset(
$fields
[
$key
]);
138
}
139
}
140
141
if
(array_key_exists(
'PERSONAL_PHOTO'
,
$fields
) && is_array(
$fields
[
'PERSONAL_PHOTO'
]))
142
{
143
$needUpdatePersonalPhoto =
true
;
144
$fields
[
'PERSONAL_PHOTO'
][
'MODULE_ID'
] =
'socialservices'
;
145
$fields
[
'PERSONAL_PHOTO'
][
'external_id'
] = md5_file(
$fields
[
'PERSONAL_PHOTO'
][
'tmp_name'
]);
146
if
($oldValue[
'PERSONAL_PHOTO'
])
147
{
148
$oldPersonalPhoto = \CFile::GetByID($oldValue[
'PERSONAL_PHOTO'
])->Fetch();
149
if
($oldPersonalPhoto[
'EXTERNAL_ID'
] ==
$fields
[
'PERSONAL_PHOTO'
][
'external_id'
])
150
{
151
$needUpdatePersonalPhoto =
false
;
152
}
153
$fields
[
'PERSONAL_PHOTO'
][
'del'
] =
'Y'
;
154
$fields
[
'PERSONAL_PHOTO'
][
'old_file'
] = $oldValue[
'PERSONAL_PHOTO'
];
155
}
156
if
($needUpdatePersonalPhoto)
157
{
158
$fields
[
'PERSONAL_PHOTO'
] = \CFile::SaveFile(
$fields
[
'PERSONAL_PHOTO'
],
'socialservices'
);
159
}
160
else
161
{
162
unset(
$fields
[
'PERSONAL_PHOTO'
]);
163
}
164
}
165
166
return
$fields
;
167
}
168
169
public
static
function
onBeforeDelete
(
Event
$event
)
170
{
171
$primary =
$event
->getParameter(
"primary"
);
172
$ID
= $primary[
"ID"
];
173
$dbRes
= static::getByPrimary(
$ID
);
174
self::$deletedList[
$ID
] =
$dbRes
->fetch();
175
}
176
177
public
static
function
onAfterDelete
(
Event
$event
)
178
{
179
$primary =
$event
->getParameter(
"primary"
);
180
$ID
= $primary[
"ID"
];
181
$userInfo = self::$deletedList[
$ID
];
182
if
($userInfo)
183
{
184
UserLinkTable::deleteBySocserv
($userInfo[
"USER_ID"
], $userInfo[
"ID"
]);
185
186
if
($userInfo[
"EXTERNAL_AUTH_ID"
] === \
CSocServBitrix24Net::ID
)
187
{
188
$interface = new \CBitrix24NetOAuthInterface();
189
$interface->setToken($userInfo[
"OATOKEN"
]);
190
$interface->setAccessTokenExpires($userInfo[
"OATOKEN_EXPIRES"
]);
191
$interface->setRefreshToken($userInfo[
"REFRESH_TOKEN"
]);
192
193
if
($interface->checkAccessToken() || $interface->getNewAccessToken())
194
{
195
$interface->RevokeAuth();
196
}
197
}
198
199
if
($userInfo[
"PERSONAL_PHOTO"
])
200
{
201
\CFile::Delete($userInfo[
"PERSONAL_PHOTO"
]);
202
}
203
}
204
}
205
}
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\UserTable
Определения
user.php:48
Bitrix\Socialservices\UserLinkTable\deleteBySocserv
static deleteBySocserv($userId, $socservProfileId)
Определения
userlink.php:84
Bitrix\Socialservices\UserTable\filterFields
static filterFields($fields, $oldValue=null)
Определения
usertable.php:126
Bitrix\Socialservices\UserTable\getMap
static getMap()
Определения
usertable.php:45
Bitrix\Socialservices\UserTable\DISALLOW
const DISALLOW
Определения
usertable.php:28
Bitrix\Socialservices\UserTable\getFilePath
static getFilePath()
Определения
usertable.php:35
Bitrix\Socialservices\UserTable\onAfterDelete
static onAfterDelete(Event $event)
Определения
usertable.php:177
Bitrix\Socialservices\UserTable\INITIALIZED
const INITIALIZED
Определения
usertable.php:30
Bitrix\Socialservices\UserTable\ALLOW
const ALLOW
Определения
usertable.php:27
Bitrix\Socialservices\UserTable\NOT_INITIALIZED
const NOT_INITIALIZED
Определения
usertable.php:31
Bitrix\Socialservices\UserTable\onBeforeDelete
static onBeforeDelete(Event $event)
Определения
usertable.php:169
Bitrix\Socialservices\UserTable\getTableName
static getTableName()
Определения
usertable.php:40
CSocServBitrix24Net\ID
const ID
Определения
bitrix24net.php:82
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$ID
if($ajaxMode) $ID
Определения
get_user.php:27
$map
$map
Определения
config.php:5
$event
$event
Определения
prolog_after.php:141
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$dbRes
$dbRes
Определения
yandex_detail.php:168
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
socialservices
lib
usertable.php
Создано системой
1.14.0