Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
applog.php
1<?php
2namespace Bitrix\Rest;
3
5
35class AppLogTable extends Main\Entity\DataManager
36{
37 const ACTION_TYPE_ADD = 'ADD';
38 const ACTION_TYPE_INSTALL = 'INSTALL';
39 const ACTION_TYPE_UPDATE = 'UPDATE';
40 const ACTION_TYPE_UNINSTALL = 'UNINSTALL';
41
42 const USER_ADMIN = 'Y';
43 const USER_NOT_ADMIN = 'N';
44
50 public static function getTableName()
51 {
52 return 'b_rest_app_log';
53 }
54
60 public static function getMap()
61 {
62 return array(
63 'ID' => array(
64 'data_type' => 'integer',
65 'primary' => true,
66 'autocomplete' => true,
67 ),
68 'TIMESTAMP_X' => array(
69 'data_type' => 'datetime',
70 ),
71 'APP_ID' => array(
72 'data_type' => 'integer',
73 'required' => true,
74 ),
75 'ACTION_TYPE' => array(
76 'data_type' => 'string',
77 'required' => true,
78 ),
79 'USER_ID' => array(
80 'data_type' => 'integer',
81 'required' => true,
82 ),
83 'USER_ADMIN' => array(
84 'data_type' => 'boolean',
85 'values' => array(static::USER_NOT_ADMIN, static::USER_ADMIN),
86 ),
87 );
88 }
89
90 public static function log($appId, $action)
91 {
92 global $USER;
93
94 $fields = array(
95 'APP_ID' => $appId,
96 'ACTION_TYPE' => $action,
97 'USER_ID' => $USER->getId(),
98 );
99
100 if($USER->IsAuthorized())
101 {
102 $fields['USER_ADMIN'] = \CRestUtil::isAdmin() ? static::USER_ADMIN : static::USER_NOT_ADMIN;
103 }
104 else
105 {
106 $fields['USER_ADMIN'] = static::USER_NOT_ADMIN;
107 }
108
109 return static::add($fields);
110 }
111}
static log($appId, $action)
Definition applog.php:90