PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
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 +147 -102 4.6.0.1 → 6.2.2 View file →
@@ -6,127 +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 - /**
59 - * Record item
60 - *
61 - * @var string
62 - */
63 - public $item;
64 63
65 - /**
66 - * Record connector
67 - *
68 - * @var string
69 - */
70 - public $connector;
64 + /**
65 + * Record log_site_name
66 + *
67 + * @var string
68 + */
69 + public $log_site_name;
71 70
72 - /**
73 - * Context record was made in.
74 - *
75 - * @var string
76 - */
77 - public $context;
71 + /**
72 + * Record url
73 + *
74 + * @var string
75 + */
76 + public $url;
78 77
79 - /**
80 - * Record action
81 - *
82 - * @var string
83 - */
84 - public $action;
78 + /**
79 + * Record item
80 + *
81 + * @var string
82 + */
83 + public $item;
85 84
86 - /**
87 - * Duration
88 - *
89 - * @var int
90 - */
91 - public $duration;
85 + /**
86 + * Record connector
87 + *
88 + * @var string
89 + */
90 + public $connector;
92 91
93 - /**
94 - * State
95 - *
96 - * @var int
97 - */
98 - public $state;
92 + /**
93 + * Context record was made in.
94 + *
95 + * @var string
96 + */
97 + public $context;
99 98
100 - /**
101 - * Record meta data
102 - *
103 - * @var array
104 - */
105 - public $meta;
99 + /**
100 + * Record action
101 + *
102 + * @var string
103 + */
104 + public $action;
106 105
107 - /**
108 - * Class constructor
109 - *
110 - * @param object $item Record data object.
111 - */
112 - public function __construct( $item ) { //phpcs:ignore -- complex method.
113 - $this->log_id = isset( $item->log_id ) ? $item->log_id : null;
114 - $this->created = isset( $item->created ) ? $item->created : null;
115 - $this->site_id = isset( $item->site_id ) ? $item->site_id : null;
116 - $this->name = isset( $item->name ) ? $item->name : null;
117 - $this->url = isset( $item->url ) ? $item->url : null;
118 - $this->user_id = isset( $item->user_id ) ? $item->user_id : null;
119 - $this->user_meta = isset( $item->meta['user_meta'] ) ? $item->meta['user_meta'] : null;
120 - $this->item = isset( $item->item ) ? $item->item : null;
121 - $this->connector = isset( $item->connector ) ? $item->connector : null;
122 - $this->context = isset( $item->context ) ? $item->context : null;
123 - $this->action = isset( $item->action ) ? $item->action : null;
124 - $this->state = isset( $item->state ) ? $item->state : null;
125 - $this->duration = isset( $item->duration ) ? $item->duration : null;
126 - $this->meta = isset( $item->meta ) ? $item->meta : null;
106 + /**
107 + * Duration
108 + *
109 + * @var int
110 + */
111 + public $duration;
127 112
128 - if ( isset( $this->meta['user_meta'] ) ) {
129 - unset( $this->meta['user_meta'] );
130 - }
131 - }
113 + /**
114 + * State
115 + *
116 + * @var int
117 + */
118 + public $state;
119 +
120 + /**
121 + * Object id.
122 + *
123 + * @var string
124 + */
125 + public $object_id;
126 +
127 + /**
128 + * Log type id.
129 + *
130 + * @var string
131 + */
132 + public $log_type_id;
133 +
134 + /**
135 + * Record meta data
136 + *
137 + * @var array
138 + */
139 + public $meta;
140 +
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 + }
132 177 }