PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
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 5.2.2 5.3 All 153 releases
mainwp / modules / logs / classes / class-log-record.php

class-log-record.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies trunk, at modules/logs/classes/class-log-record.php

178 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Manages the state of a single record
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard\Module\Log;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class - Log_Record
17 */
18 class Log_Record {
19
20 /**
21 * Record log_id
22 *
23 * @var int
24 */
25 public $log_id;
26
27 /**
28 * Date record created
29 *
30 * @var string
31 */
32 public $created;
33
34 /**
35 * Site ID of the site where the record was created
36 *
37 * @var int
38 */
39 public $site_id;
40
41
42 /**
43 * User ID of the record creator
44 *
45 * @var int
46 */
47 public $user_id;
48
49 /**
50 * User role of the record creator
51 *
52 * @var string
53 */
54 public $user_role;
55
56 /**
57 * Record user meta data.
58 *
59 * @var string
60 */
61 public $user_meta;
62
63
64 /**
65 * Record log_site_name
66 *
67 * @var string
68 */
69 public $log_site_name;
70
71 /**
72 * Record url
73 *
74 * @var string
75 */
76 public $url;
77
78 /**
79 * Record item
80 *
81 * @var string
82 */
83 public $item;
84
85 /**
86 * Record connector
87 *
88 * @var string
89 */
90 public $connector;
91
92 /**
93 * Context record was made in.
94 *
95 * @var string
96 */
97 public $context;
98
99 /**
100 * Record action
101 *
102 * @var string
103 */
104 public $action;
105
106 /**
107 * Duration
108 *
109 * @var int
110 */
111 public $duration;
112
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 }
177 }
178