1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17:
18: class UBEvent {
19: 20: 21: 22: 23: 24: 25: 26:
27: static function get_latest($offset = 0, $limit = 10) {
28: return get_system_log(null,
29: null,
30: null,
31: null,
32: null,
33: $limit,
34: $offset,
35: null,
36: null,
37: null,
38: null,
39: null
40: );
41: }
42:
43: 44: 45: 46: 47: 48: 49: 50: 51:
52: static function get_by_user($user_array, $offset = 0, $limit = 10) {
53: if (empty($user_array)) {
54: return array();
55: }
56: global $CONFIG;
57: $query = "SELECT * FROM {$CONFIG->dbprefix}system_log where ";
58: $query .= "performed_by_guid in (" . implode(",", $user_array) . ")";
59: $query .= " OR ";
60: $query .= "owner_guid in (" . implode(",", $user_array) . ")";
61: foreach ($user_array as $user_id) {
62: $relationship_array = array_merge(get_entity_relationships($user_id, false),
63: get_entity_relationships($user_id, true));
64: if ($relationship_array) {
65: foreach ($relationship_array as $relationship) {
66: $relationship_ids[] = $relationship->id;
67: }
68: if (isset($relationship_ids) and !empty($relationship_ids)) {
69: $query .= " OR ";
70: $query .= "object_id";
71: $query .= " IN (";
72: $query .= implode(",", $relationship_ids) . ")";
73: }
74: }
75: }
76: $query .= " ORDER BY ";
77: $query .= "time_created desc";
78: $query .= " LIMIT $offset, $limit";
79: return get_data($query);
80: }
81:
82: 83: 84: 85: 86: 87: 88: 89: 90:
91: static function get_by_object($object_array, $offset = 0, $limit = 10) {
92: if (empty($object_array)) {
93: return array();
94: }
95: global $CONFIG;
96: $query = "SELECT * FROM {$CONFIG->dbprefix}system_log where ";
97: $query .= "object_id IN (" . implode(",", $object_array) . ")";
98: $query .= " AND object_type != \"relationship\" AND object_type != \"metadata\"";
99: $query .= " UNION";
100: $query .= " SELECT * FROM {$CONFIG->dbprefix}system_log";
101: $relationship_array = array();
102: foreach ($object_array as $object_id) {
103: $relationship_array = array_merge($relationship_array,
104: get_entity_relationships($object_id, false),
105: get_entity_relationships($object_id, true));
106: }
107: if (!empty($relationship_array)) {
108: foreach ($relationship_array as $relationship) {
109: $relationship_ids[] = $relationship->id;
110: }
111: if (isset($relationship_ids) and !empty($relationship_ids)) {
112: $query .= " where object_id IN (";
113: $query .= implode(",", $relationship_ids) . ") ";
114: $query .= " AND object_type = \"relationship\"";
115: }
116: }
117: $query .= " ORDER BY ";
118: $query .= "time_created desc";
119: $query .= " LIMIT $offset, $limit";
120: return get_data($query);
121: }
122: }