74 public static function addHistory($userId, $type, array $before =
null, array $after =
null)
78 $server = Context::getCurrent()->getServer();
79 $request = Context::getCurrent()->getRequest();
81 $url = preg_replace(
"/(&?sessid=[0-9a-z]+)/",
"", $request->getDecodedUri());
82 $remoteAddr = $server->get(
"REMOTE_ADDR");
83 $userAgent = $server->get(
"HTTP_USER_AGENT");
84 $updatedBy = (is_object($USER) && ($USER->GetID() > 0)? $USER->GetID() :
null);
86 $changedFields = array();
87 if(is_array($before) && is_array($after))
90 static $hiddenFields = array(
"PASSWORD" => 1,
"CHECKWORD" => 1,
"CONFIRM_CODE" => 1);
91 static $ignoredFields = array(
"TIMESTAMP_X" => 1);
93 foreach($after as $field => $value)
95 if(isset($ignoredFields[$field]))
100 if($before[$field] <> $value)
103 "before" => (isset($hiddenFields[$field])?
"***" : $before[$field]),
104 "after" => (isset($hiddenFields[$field])?
"***" : $value)
107 $changedFields[] = array(
117 if(!empty($changedFields) || $type <> self::TYPE_UPDATE)
119 $result = static::add(array(
120 "USER_ID" => $userId,
121 "EVENT_TYPE" => $type,
122 "REMOTE_ADDR" => $remoteAddr,
123 "USER_AGENT" => $userAgent,
124 "REQUEST_URI" => $url,
125 "UPDATED_BY_ID" => $updatedBy,
129 if(!empty($changedFields) && $result->isSuccess())
131 foreach($changedFields as $value)
133 UserProfileRecordTable::add(array(
134 "HISTORY_ID" => $result->getId(),
135 "FIELD" => $value[
"FIELD"],
136 "DATA" => $value[
"DATA"],