PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | modules/logs/classes/class-log-record.php +143 -121 5.0.3 → 6.2.1 View file →
@@ -6,150 +6,172 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard\Module\Log;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class - Log_Record
12 17 */
13 18 class Log_Record {
14 19
15 - /**
16 - * Record log_id
17 - *
18 - * @var int
19 - */
20 - public $log_id;
20 + /**
21 + * Record log_id
22 + *
23 + * @var int
24 + */
25 + public $log_id;
21 26
22 - /**
23 - * Date record created
24 - *
25 - * @var string
26 - */
27 - public $created;
27 + /**
28 + * Date record created
29 + *
30 + * @var string
31 + */
32 + public $created;
28 33
29 - /**
30 - * Site ID of the site where the record was created
31 - *
32 - * @var int
33 - */
34 - public $site_id;
34 + /**
35 + * Site ID of the site where the record was created
36 + *
37 + * @var int
38 + */
39 + public $site_id;
35 40
36 41
37 - /**
38 - * User ID of the record creator
39 - *
40 - * @var int
41 - */
42 - public $user_id;
42 + /**
43 + * User ID of the record creator
44 + *
45 + * @var int
46 + */
47 + public $user_id;
43 48
44 - /**
45 - * User role of the record creator
46 - *
47 - * @var string
48 - */
49 - public $user_role;
49 + /**
50 + * User role of the record creator
51 + *
52 + * @var string
53 + */
54 + public $user_role;
50 55
51 - /**
52 - * Record user meta data.
53 - *
54 - * @var string
55 - */
56 - public $user_meta;
56 + /**
57 + * Record user meta data.
58 + *
59 + * @var string
60 + */
61 + public $user_meta;
57 62
58 63
59 - /**
60 - * Record log_site_name
61 - *
62 - * @var string
63 - */
64 - public $log_site_name;
64 + /**
65 + * Record log_site_name
66 + *
67 + * @var string
68 + */
69 + public $log_site_name;
65 70
66 - /**
67 - * Record url
68 - *
69 - * @var string
70 - */
71 - public $url;
71 + /**
72 + * Record url
73 + *
74 + * @var string
75 + */
76 + public $url;
72 77
73 - /**
74 - * Record item
75 - *
76 - * @var string
77 - */
78 - public $item;
78 + /**
79 + * Record item
80 + *
81 + * @var string
82 + */
83 + public $item;
79 84
80 - /**
81 - * Record connector
82 - *
83 - * @var string
84 - */
85 - public $connector;
85 + /**
86 + * Record connector
87 + *
88 + * @var string
89 + */
90 + public $connector;
86 91
87 - /**
88 - * Context record was made in.
89 - *
90 - * @var string
91 - */
92 - public $context;
92 + /**
93 + * Context record was made in.
94 + *
95 + * @var string
96 + */
97 + public $context;
93 98
94 - /**
95 - * Record action
96 - *
97 - * @var string
98 - */
99 - public $action;
99 + /**
100 + * Record action
101 + *
102 + * @var string
103 + */
104 + public $action;
100 105
101 - /**
102 - * Duration
103 - *
104 - * @var int
105 - */
106 - public $duration;
106 + /**
107 + * Duration
108 + *
109 + * @var int
110 + */
111 + public $duration;
107 112
108 - /**
109 - * State
110 - *
111 - * @var int
112 - */
113 - public $state;
113 + /**
114 + * State
115 + *
116 + * @var int
117 + */
118 + public $state;
114 119
115 - /**
116 - * Record meta data
117 - *
118 - * @var array
119 - */
120 - public $meta;
120 + /**
121 + * Object id.
122 + *
123 + * @var string
124 + */
125 + public $object_id;
121 126
122 - /**
123 - * Record extra_meta data
124 - *
125 - * @var array
126 - */
127 - public $extra_meta;
127 + /**
128 + * Log type id.
129 + *
130 + * @var string
131 + */
132 + public $log_type_id;
128 133
129 - /**
130 - * Class constructor
131 - *
132 - * @param object $log Record data object.
133 - */
134 - public function __construct( $log ) { //phpcs:ignore -- complex method.
135 - $this->log_id = isset( $log->log_id ) ? $log->log_id : null;
136 - $this->created = isset( $log->created ) ? $log->created : null;
137 - $this->site_id = isset( $log->site_id ) ? $log->site_id : null;
138 - $this->log_site_name = isset( $log->log_site_name ) ? $log->log_site_name : null;
139 - $this->url = isset( $log->url ) ? $log->url : null;
140 - $this->user_id = isset( $log->user_id ) ? $log->user_id : null;
141 - $this->user_meta = isset( $log->meta['user_meta'] ) ? $log->meta['user_meta'] : null;
142 - $this->item = isset( $log->item ) ? $log->item : null;
143 - $this->connector = isset( $log->connector ) ? $log->connector : null;
144 - $this->context = isset( $log->context ) ? $log->context : null;
145 - $this->action = isset( $log->action ) ? $log->action : null;
146 - $this->state = isset( $log->state ) ? $log->state : null;
147 - $this->duration = isset( $log->duration ) ? $log->duration : null;
148 - $this->meta = isset( $log->meta ) ? $log->meta : null;
149 - $this->extra_meta = isset( $log->extra_info ) ? $log->extra_info : null;
134 + /**
135 + * Record meta data
136 + *
137 + * @var array
138 + */
139 + public $meta;
150 140
151 - if ( isset( $this->meta['user_meta'] ) ) {
152 - unset( $this->meta['user_meta'] );
153 - }
154 - }
141 + /**
142 + * Record extra_meta data
143 + *
144 + * @var array
145 + */
146 + public $extra_meta;
147 +
148 + /**
149 + * Class constructor
150 + *
151 + * @param object $log Record data object.
152 + */
153 + public function __construct( $log ) { //phpcs:ignore -- NOSONAR - complex method.
154 + $this->log_id = isset( $log->log_id ) ? $log->log_id : null;
155 + $this->created = isset( $log->created ) ? intval( $log->created / 1000000 ) : null;
156 + $this->site_id = isset( $log->site_id ) ? $log->site_id : null;
157 + $this->log_site_name = isset( $log->log_site_name ) ? $log->log_site_name : null;
158 + $this->url = isset( $log->url ) ? $log->url : null;
159 + $this->user_id = isset( $log->user_id ) ? $log->user_id : null;
160 + $this->item = isset( $log->item ) ? $log->item : null;
161 + $this->connector = isset( $log->connector ) ? $log->connector : null;
162 + $this->context = isset( $log->context ) ? $log->context : null;
163 + $this->log_type_id = isset( $log->log_type_id ) ? $log->log_type_id : null;
164 + $this->action = isset( $log->action ) ? $log->action : null;
165 + $this->state = isset( $log->state ) ? $log->state : null;
166 + $this->duration = isset( $log->duration ) ? $log->duration : null;
167 + $this->object_id = null; // compatible.
168 + $this->extra_meta = isset( $log->extra_info ) ? $log->extra_info : null;
169 + $this->meta = isset( $log->meta ) ? $log->meta : null;
170 +
171 + $user_meta = ! empty( $log->user_meta_json ) ? json_decode( $log->user_meta_json, true ) : array();
172 + if ( empty( $user_meta ) && ! empty( $log->usermeta ) ) {
173 + $user_meta = $log->usermeta;
174 + }
175 + $this->user_meta = $user_meta;
176 + }
155 177 }