1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
userprofilehistory.php
См. документацию.
1<?php
2
9
10namespace Bitrix\Main;
11
12use Bitrix\Main\ORM\Data;
13
33{
34 use Data\Internal\DeleteByFilterTrait;
35
36 const TYPE_ADD = 1;
37 const TYPE_UPDATE = 2;
38 const TYPE_DELETE = 3;
39
40 public static function getTableName()
41 {
42 return 'b_user_profile_history';
43 }
44
45 public static function getMap()
46 {
47 return array(
48 new Entity\IntegerField("ID", array(
49 'primary' => true,
50 'autocomplete' => true,
51 )),
52 new Entity\IntegerField("USER_ID", array(
53 'required' => true,
54 )),
55 new Entity\IntegerField("EVENT_TYPE"),
56 new Entity\DatetimeField("DATE_INSERT", array(
57 'default_value' => function(){return new Type\DateTime();}
58 )),
59 new Entity\StringField("REMOTE_ADDR"),
60 new Entity\TextField('USER_AGENT'),
61 new Entity\TextField('REQUEST_URI'),
62 new Entity\IntegerField("UPDATED_BY_ID"),
63 );
64 }
65
73 public static function addHistory($userId, $type, array $before = null, array $after = null)
74 {
75 global $USER;
76
77 $server = Context::getCurrent()->getServer();
78 $request = Context::getCurrent()->getRequest();
79
80 $url = preg_replace("/(&?sessid=[0-9a-z]+)/", "", $request->getDecodedUri());
81 $remoteAddr = $server->get("REMOTE_ADDR");
82 $userAgent = $server->get("HTTP_USER_AGENT");
83 $updatedBy = (is_object($USER) && ($USER->GetID() > 0)? $USER->GetID() : null);
84
85 $changedFields = array();
86 if(is_array($before) && is_array($after))
87 {
88 //we shouldn't display some values
89 static $hiddenFields = array("PASSWORD" => 1, "CHECKWORD" => 1, "CONFIRM_CODE" => 1);
90 static $ignoredFields = array("TIMESTAMP_X" => 1);
91
92 foreach($after as $field => $value)
93 {
94 if(isset($ignoredFields[$field]))
95 {
96 continue;
97 }
98
99 if($before[$field] <> $value)
100 {
101 $data = array(
102 "before" => (isset($hiddenFields[$field])? "***" : $before[$field]),
103 "after" => (isset($hiddenFields[$field])? "***" : $value)
104 );
105
106 $changedFields[] = array(
107 "FIELD" => $field,
108 "DATA" => $data,
109 );
110 }
111 }
112 }
113
114 $result = null;
115
116 if(!empty($changedFields) || $type <> self::TYPE_UPDATE)
117 {
118 $result = static::add(array(
119 "USER_ID" => $userId,
120 "EVENT_TYPE" => $type,
121 "REMOTE_ADDR" => $remoteAddr,
122 "USER_AGENT" => $userAgent,
123 "REQUEST_URI" => $url,
124 "UPDATED_BY_ID" => $updatedBy,
125 ));
126 }
127
128 if(!empty($changedFields) && $result->isSuccess())
129 {
130 foreach($changedFields as $value)
131 {
132 UserProfileRecordTable::add(array(
133 "HISTORY_ID" => $result->getId(),
134 "FIELD" => $value["FIELD"],
135 "DATA" => $value["DATA"],
136 ));
137 }
138 }
139
140 return $result;
141 }
142
143 public static function deleteByUser($userId)
144 {
145 static::deleteByFilter(["=USER_ID" => $userId]);
146 }
147
148 protected static function onBeforeDeleteByFilter(string $where)
149 {
151 }
152}
$type
Определения options.php:106
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static deleteByUser($userId)
Определения userprofilehistory.php:143
static addHistory($userId, $type, array $before=null, array $after=null)
Определения userprofilehistory.php:73
static onBeforeDeleteByFilter(string $where)
Определения userprofilehistory.php:148
static deleteByHistoryFilter($where)
Определения userprofilerecord.php:58
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
Определения ufield.php:9
$url
Определения iframe.php:7