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;
55 if ($by_user_orig !==
"" && $by_user_orig !==
false && $by_user_orig !== null) {
56 if (is_int($by_user)) {
57 $where[] =
"performed_by_guid=$by_user";
58 }
else if (is_array($by_user)) {
59 $where [] =
"performed_by_guid in (" . implode(
",", $by_user) .
")";
63 $where[] =
"event='$event'";
66 $where[] =
"object_class='$class'";
69 $where[] =
"object_type='$type'";
72 $where[] =
"object_subtype='$subtype'";
76 $where[] =
"time_created < " . ((int) $timebefore);
79 $where[] =
"time_created > " . ((int) $timeafter);
82 $where[] =
"object_id = " . ((int) $object_id);
85 $where[] =
"ip_address = '$ip_address'";
90 $select =
"count(*) as count";
92 $query =
"SELECT $select from {$CONFIG->dbprefix}system_log where 1 ";
93 foreach ($where as $w) {
98 $query .=
" order by time_created desc";
99 $query .=
" limit $offset, $limit";
105 return $numrows->count;
124 $entry_id = (int)$entry_id;
126 return get_data_row(
"SELECT * from {$CONFIG->dbprefix}system_log where id=$entry_id");
137 if (is_numeric($entry)) {
144 $class = $entry->object_class;
145 $id = $entry->object_id;
147 if (!class_exists(
$class)) {
153 'ElggAnnotation' =>
'elgg_get_annotation_from_id',
154 'ElggMetadata' =>
'elgg_get_metadata_from_id',
155 'ElggRelationship' =>
'get_relationship',
158 if (isset($getters[
$class]) && is_callable($getters[$class])) {
159 $object = call_user_func($getters[$class],
$id);
160 } elseif (preg_match(
'~^Elgg[A-Z]~', $class)) {
167 }
catch (Exception
$e) {
191 static $cache_size = 0;
202 if (!is_array($log_cache) || $cache_size > 500) {
203 $log_cache = array();
208 $object_id = (int)
$object->getSystemLogID();
209 $object_class = get_class(
$object);
210 $object_type =
$object->getType();
211 $object_subtype =
$object->getSubtype();
216 $ip_address =
'0.0.0.0';
220 if (isset(
$object->access_id)) {
221 $access_id =
$object->access_id;
231 if (isset(
$object->owner_guid)) {
238 if (!isset($log_cache[$time][$object_id][$event])) {
239 $query =
"INSERT DELAYED into {$CONFIG->dbprefix}system_log 240 (object_id, object_class, object_type, object_subtype, event, 241 performed_by_guid, owner_guid, access_id, enabled, time_created, ip_address) 243 ('$object_id','$object_class','$object_type', '$object_subtype', '$event', 244 $performed_by, $owner_guid, $access_id, '$enabled', '$time', '$ip_address')";
248 $log_cache[$time][$object_id][$event] =
true;
270 $query =
"CREATE TABLE {$CONFIG->dbprefix}system_log_$now as 271 SELECT * from {$CONFIG->dbprefix}system_log WHERE time_created<$ts";
279 if (
delete_data(
"DELETE from {$CONFIG->dbprefix}system_log WHERE time_created<$ts") ===
false) {
284 if (!
update_data(
"ALTER TABLE {$CONFIG->dbprefix}system_log_$now engine=archive")) {
318 if (($object_type !=
'systemlog') && ($event !=
'log')) {
get_data_row($query, $callback="")
Retrieve a single row from the database.
get_system_log($by_user="", $event="", $class="", $type="", $subtype="", $limit=10, $offset=0, $count=false, $timebefore=0, $timeafter=0, $object_id=0, $ip_address="")
Retrieve the system log based on a number of parameters.
system_log_default_logger($event, $object_type, $object)
Default system log handler, allows plugins to override, extend or disable logging.
delete_data($query)
Remove a row from the database.
if(isset($vars['id'])) $class
update_data($query)
Update a row in the database.
sanitize_string($string)
Sanitize a string for database use.
insert_data($query)
Insert a row into the database.
system_log_listener($event, $object_type, $object)
System log listener.
datalist_get($name)
Get the value of a datalist element.
$enabled
Sample cli installer script.
sanitise_string($string)
Wrapper function for alternate English spelling (.
archive_log($offset=0)
This function creates an archive copy of the system log.
elgg global
Pointer to the global context.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
get_data($query, $callback="")
Retrieve rows from the database.
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)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
get_log_entry($entry_id)
Return a specific log entry.
if(!$collection_name) $id
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.