class log implements log_interface

This class is used to add entries into the log table.

Properties

protected bool $is_in_admin

If set, administrative user profile links will be returned and messages will not be censored.

protected array $disabled_types

An array with the disabled log types. Logs of such types will not be added when add() is called.

protected int $entry_count

Keeps the total log count of the last call to get_logs()

protected int $last_page_offset

Keeps the offset of the last valid page of the last call to get_logs()

protected string $log_table

The table we use to store our logs.

protected driver $db

Database object

protected user $user

User object

protected auth $auth

Auth object

protected dispatcher_interface $dispatcher

Event dispatcher object

protected string $phpbb_root_path

phpBB root path

protected string $phpbb_admin_path

Admin root path

protected string $php_ext

PHP Extension

Methods

__construct(driver_interface $db, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, string $phpbb_root_path, string $relative_admin_path, string $php_ext, string $log_table)

Constructor

null
set_is_admin(bool $is_in_admin)

Set is_in_admin in order to return administrative user profile links in get_logs()

bool
get_is_admin()

Returns the is_in_admin option

null
set_log_table(string $log_table)

Set table name

bool
is_enabled(string $type = '')

This function returns the state of the log system.

null
disable(mixed $type = '')

Disable log

null
enable(mixed $type = '')

Enable log

int|bool
add(string $mode, int $user_id, string $log_ip, string $log_operation, int|bool $log_time = false, array $additional_data = array())

Adds a log entry to the database

delete(string $mode, array $conditions = array())

Delete entries in the logs

array
get_logs(string $mode, bool $count_logs = true, int $limit = 0, int $offset = 0, mixed $forum_id = 0, int $topic_id = 0, int $user_id = 0, int $log_time = 0, string $sort_by = 'l.log_time DESC', string $keywords = '')

Grab the logs from the database

string
generate_sql_keyword(string $keywords, string $table_alias = 'l.', string $statement_operator = 'AND')

Generates a sql condition for the specified keywords

array
get_topic_auth(array $topic_ids)

Determine whether the user is allowed to read and/or moderate the forum of the topic

array
get_reportee_data(array $reportee_ids)

Get the data for all reportee from the database

int
get_log_count()

Get total log count

int
get_valid_offset()

Get offset of the last valid page

Details

at line 107
__construct(driver_interface $db, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, string $phpbb_root_path, string $relative_admin_path, string $php_ext, string $log_table)

Constructor

Parameters

driver_interface $db

Database object

user $user

User object

auth $auth

Auth object

dispatcher_interface $phpbb_dispatcher

Event dispatcher

string $phpbb_root_path

Root path

string $relative_admin_path

Relative admin root path

string $php_ext

PHP Extension

string $log_table

Name of the table we use to store our logs

at line 134
null set_is_admin(bool $is_in_admin)

Set is_in_admin in order to return administrative user profile links in get_logs()

Parameters

bool $is_in_admin

Are we called from within the acp?

Return Value

null

at line 144
bool get_is_admin()

Returns the is_in_admin option

Return Value

bool

at line 155
null set_log_table(string $log_table)

Set table name

Parameters

string $log_table

Can overwrite the table to use for the logs

Return Value

null

at line 163
bool is_enabled(string $type = '')

This function returns the state of the log system.

Parameters

string $type

The log type we want to check. Empty to get global log status.

Return Value

bool

True if log for the type is enabled

at line 175
null disable(mixed $type = '')

Disable log

This function allows disabling the log system or parts of it, for this page call. When add() is called and the type is disabled, the log will not be added to the database.

Parameters

mixed $type

The log type we want to disable. Empty to disable all logs. Can also be an array of types.

Return Value

null

at line 197
null enable(mixed $type = '')

Enable log

This function allows re-enabling the log system.

Parameters

mixed $type

The log type we want to enable. Empty to enable all logs. Can also be an array of types.

Return Value

null

at line 219
int|bool add(string $mode, int $user_id, string $log_ip, string $log_operation, int|bool $log_time = false, array $additional_data = array())

Adds a log entry to the database

Parameters

string $mode

The mode defines which log_type is used and from which log the entry is retrieved

int $user_id

User ID of the user

string $log_ip

IP address of the user

string $log_operation

Name of the operation

int|bool $log_time

Timestamp when the log entry was added. If false, time() will be used

array $additional_data

More arguments can be added, depending on the log_type

Return Value

int|bool

Returns the log_id, if the entry was added to the database, false otherwise.

at line 325
delete(string $mode, array $conditions = array())

Delete entries in the logs

Parameters

string $mode

The mode defines which log_type is used and from which log the entries are deleted

array $conditions

An array of conditions, 3 different forms are accepted 1) => transformed into 'AND = ' (value should be an integer) 2) => array(, ) transformed into 'AND ' (values can't be an array) 3) => array('IN' => array()) transformed into 'AND IN ' A special field, keywords, can also be defined. In this case only the log entries that have the keywords in log_operation or log_data will be deleted.

at line 418
array get_logs(string $mode, bool $count_logs = true, int $limit = 0, int $offset = 0, mixed $forum_id = 0, int $topic_id = 0, int $user_id = 0, int $log_time = 0, string $sort_by = 'l.log_time DESC', string $keywords = '')

Grab the logs from the database

Parameters

string $mode

The mode defines which log_type is used and ifrom which log the entry is retrieved

bool $count_logs

Shall we count all matching log entries?

int $limit

Limit the number of entries that are returned

int $offset

Offset when fetching the log entries, f.e. when paginating

mixed $forum_id

Restrict the log entries to the given forum_id (can also be an array of forum_ids)

int $topic_id

Restrict the log entries to the given topic_id

int $user_id

Restrict the log entries to the given user_id

int $log_time

Only get log entries newer than the given timestamp

string $sort_by

SQL order option, e.g. 'l.log_time DESC'

string $keywords

Will only return log entries that have the keywords in log_operation or log_data

Return Value

array

The result array with the logs

at line 827
protected string generate_sql_keyword(string $keywords, string $table_alias = 'l.', string $statement_operator = 'AND')

Generates a sql condition for the specified keywords

Parameters

string $keywords

The keywords the user specified to search for

string $table_alias

The alias of the logs' table ('l.' by default)

string $statement_operator

The operator used to prefix the statement ('AND' by default)

Return Value

string

Returns the SQL condition searching for the keywords

at line 896
protected array get_topic_auth(array $topic_ids)

Determine whether the user is allowed to read and/or moderate the forum of the topic

Parameters

array $topic_ids

Array with the topic ids

Return Value

array

Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample: array( 'permission' => array( topic_id => forum_id ), ),

at line 967
protected array get_reportee_data(array $reportee_ids)

Get the data for all reportee from the database

Parameters

array $reportee_ids

Array with the user ids of the reportees

Return Value

array

Returns an array with the reportee data

at line 989
int get_log_count()

Get total log count

Return Value

int

Returns the number of matching logs from the last call to get_logs()

at line 997
int get_valid_offset()

Get offset of the last valid page

Return Value

int

Returns the offset of the last valid page from the last call to get_logs()