31 $offset = 0,
$count =
false, $timebefore = 0, $timeafter = 0, $object_id = 0,
36 $by_user_orig = $by_user;
37 if (is_array($by_user) &&
sizeof($by_user) > 0) {
38 foreach ($by_user as
$key => $val) {
39 $by_user[
$key] = (int) $val;
42 $by_user = (int)$by_user;
58 if ($by_user_orig !==
"" && $by_user_orig !==
false && $by_user_orig !== null) {
59 if (is_int($by_user)) {
60 $where[] =
"performed_by_guid=$by_user";
61 }
else if (is_array($by_user)) {
62 $where [] =
"performed_by_guid in (" . implode(
",", $by_user) .
")";
66 $where[] =
"event='$event'";
69 $where[] =
"object_class='$class'";
72 $where[] =
"object_type='$type'";
75 $where[] =
"object_subtype='$subtype'";
79 $where[] =
"time_created < " . ((int) $timebefore);
82 $where[] =
"time_created > " . ((int) $timeafter);
85 $where[] =
"object_id = " . ((int) $object_id);
88 $where[] =
"ip_address = '$ip_address'";
95 $query =
"SELECT $select from {$CONFIG->dbprefix}system_log where 1 ";
96 foreach ($where as $w) {
101 $query .=
" order by time_created desc";
102 $query .=
" limit $offset, $limit";
108 return $numrows->count;
127 $entry_id = (int)$entry_id;
129 return get_data_row(
"SELECT * from {$CONFIG->dbprefix}system_log where id=$entry_id");
140 if (is_numeric($entry)) {
147 $class = $entry->object_class;
148 $id = $entry->object_id;
150 if (!class_exists(
$class)) {
156 'ElggAnnotation' =>
'elgg_get_annotation_from_id',
157 'ElggMetadata' =>
'elgg_get_metadata_from_id',
158 'ElggRelationship' =>
'get_relationship',
161 if (isset($getters[
$class]) && is_callable($getters[$class])) {
162 $object = call_user_func($getters[$class],
$id);
163 } elseif (preg_match(
'~^Elgg[A-Z]~', $class)) {
194 static $cache_size = 0;
205 if (!is_array($log_cache) || $cache_size > 500) {
206 $log_cache = array();
211 $object_id = (int)
$object->getSystemLogID();
212 $object_class = get_class(
$object);
213 $object_type =
$object->getType();
214 $object_subtype =
$object->getSubtype();
219 $ip_address =
'0.0.0.0';
223 if (isset(
$object->access_id)) {
224 $access_id =
$object->access_id;
234 if (isset(
$object->owner_guid)) {
241 if (!isset($log_cache[$time][$object_id][$event])) {
242 $query =
"INSERT into {$CONFIG->dbprefix}system_log 243 (object_id, object_class, object_type, object_subtype, event, 244 performed_by_guid, owner_guid, access_id, enabled, time_created, ip_address) 246 ('$object_id','$object_class','$object_type', '$object_subtype', '$event', 247 $performed_by, $owner_guid, $access_id, '$enabled', '$time', '$ip_address')";
251 $log_cache[$time][$object_id][$event] =
true;
273 $query =
"CREATE TABLE {$CONFIG->dbprefix}system_log_$now as 274 SELECT * from {$CONFIG->dbprefix}system_log WHERE time_created<$ts";
282 if (
delete_data(
"DELETE from {$CONFIG->dbprefix}system_log WHERE time_created<$ts") ===
false) {
287 if (!
update_data(
"ALTER TABLE {$CONFIG->dbprefix}system_log_$now engine=archive")) {
321 if (($object_type !=
'systemlog') && ($event !=
'log')) {
330 $events->registerHandler(
'all',
'all',
'system_log_listener', 400);
333 $events->registerHandler(
'log',
'systemlog',
'system_log_default_logger', 999);
$object
These two snippets demonstrates triggering an event and how to register for that event.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
delete_data($query, array $params=[])
Remove a row from the database.
system_log_default_logger($event, $object_type, $object)
Default system log handler, allows plugins to override, extend or disable logging.
sanitize_string($string)
Sanitizes a string for use in a query.
system_log_listener($event, $object_type, $object)
System log listener.
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
datalist_get($name)
Get the value of a datalist element.
execute_delayed_write_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that writes to the database.
sanitise_string($string)
Alias of sanitize_string.
archive_log($offset=0)
This function creates an archive copy of the system log.
get_system_log($by_user="", $event="", $class="", $type="", $subtype="", $limit=null, $offset=0, $count=false, $timebefore=0, $timeafter=0, $object_id=0, $ip_address="")
Retrieve the system log based on a number of parameters.
elgg global
Pointer to the global context.
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
system_log($object, $event)
Log a system event related to a specific object.
get_object_from_log_entry($entry)
Return the object referred to by a given log entry.
elgg_trigger_event($event, $object_type, $object=null)
get_log_entry($entry_id)
Return a specific log entry.
if(!$collection_name) $id
$enabled
CI CLI installer script.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
get_entity($guid)
Loads and returns an entity object from a guid.