mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Merge pull request #3457 from brunoais/ticket/13661
[ticket/13661] Add event to allow editing the queries used to get the logs * brunoais/ticket/13661: [ticket/13661] BUMP version to 3.1.5-dev [ticket/13661] Brackets in their own line [ticket/13661] Re-Fixed $log_type -> $log_time [ticket/13661] Wrong event @since version [ticket/13661] Removed superfluous whitespace [ticket/13661] bugfix: The conditional is the log_time, not log_type [ticket/13661] Fixed the "FROM" in the built query. [ticket/13661] Add event to allow editing the queries used to get the logs [ticket/13661] Transform queries to get logs and log count into built queries
This commit is contained in:
commit
b1d829c232
1 changed files with 70 additions and 15 deletions
|
@ -521,15 +521,77 @@ class log implements \phpbb\log\log_interface
|
||||||
$sql_keywords = $this->generate_sql_keyword($keywords);
|
$sql_keywords = $this->generate_sql_keyword($keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$get_logs_sql_ary = array(
|
||||||
|
'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour',
|
||||||
|
'FROM' => array(
|
||||||
|
$this->log_table => 'l',
|
||||||
|
USERS_TABLE => 'u',
|
||||||
|
),
|
||||||
|
'WHERE' => 'l.log_type = ' . (int) $log_type . "
|
||||||
|
AND l.user_id = u.user_id
|
||||||
|
$sql_keywords
|
||||||
|
$sql_additional",
|
||||||
|
|
||||||
|
'ORDER_BY' => $sort_by,
|
||||||
|
);
|
||||||
|
|
||||||
|
if($log_time)
|
||||||
|
{
|
||||||
|
$get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . '
|
||||||
|
AND ' . $get_logs_sql_ary['WHERE'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify the query to obtain the logs data
|
||||||
|
*
|
||||||
|
* @event core.get_logs_main_query_before
|
||||||
|
* @var array get_logs_sql_ary The array in the format of the query builder with the query
|
||||||
|
* to get the log count and the log list
|
||||||
|
* @var string mode Mode of the entries we display
|
||||||
|
* @var bool count_logs Do we count all matching entries?
|
||||||
|
* @var int limit Limit the number of entries
|
||||||
|
* @var int offset Offset when fetching the entries
|
||||||
|
* @var mixed forum_id Limit entries to the forum_id,
|
||||||
|
* can also be an array of forum_ids
|
||||||
|
* @var int topic_id Limit entries to the topic_id
|
||||||
|
* @var int user_id Limit entries to the user_id
|
||||||
|
* @var int log_time Limit maximum age of log entries
|
||||||
|
* @var string sort_by SQL order option
|
||||||
|
* @var string keywords Will only return entries that have the
|
||||||
|
* keywords in log_operation or log_data
|
||||||
|
* @var string profile_url URL to the users profile
|
||||||
|
* @var int log_type Limit logs to a certain type. If log_type
|
||||||
|
* is false, no entries will be returned.
|
||||||
|
* @var string sql_additional Additional conditions for the entries,
|
||||||
|
* e.g.: 'AND l.forum_id = 1'
|
||||||
|
* @since 3.1.5-RC1
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'get_logs_sql_ary',
|
||||||
|
'mode',
|
||||||
|
'count_logs',
|
||||||
|
'limit',
|
||||||
|
'offset',
|
||||||
|
'forum_id',
|
||||||
|
'topic_id',
|
||||||
|
'user_id',
|
||||||
|
'log_time',
|
||||||
|
'sort_by',
|
||||||
|
'keywords',
|
||||||
|
'profile_url',
|
||||||
|
'log_type',
|
||||||
|
'sql_additional',
|
||||||
|
);
|
||||||
|
extract($this->dispatcher->trigger_event('core.get_logs_main_query_before', compact($vars)));
|
||||||
|
|
||||||
if ($count_logs)
|
if ($count_logs)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT COUNT(l.log_id) AS total_entries
|
$count_logs_sql_ary = $get_logs_sql_ary;
|
||||||
FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u
|
|
||||||
WHERE l.log_type = ' . (int) $log_type . '
|
$count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries';
|
||||||
AND l.user_id = u.user_id
|
unset($count_logs_sql_ary['ORDER_BY']);
|
||||||
AND l.log_time >= ' . (int) $log_time . "
|
|
||||||
$sql_keywords
|
$sql = $this->db->sql_build_query('SELECT', $count_logs_sql_ary);
|
||||||
$sql_additional";
|
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
$this->entry_count = (int) $this->db->sql_fetchfield('total_entries');
|
$this->entry_count = (int) $this->db->sql_fetchfield('total_entries');
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
@ -548,14 +610,7 @@ class log implements \phpbb\log\log_interface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour
|
$sql = $this->db->sql_build_query('SELECT', $get_logs_sql_ary);
|
||||||
FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u
|
|
||||||
WHERE l.log_type = ' . (int) $log_type . '
|
|
||||||
AND u.user_id = l.user_id
|
|
||||||
' . (($log_time) ? 'AND l.log_time >= ' . (int) $log_time : '') . "
|
|
||||||
$sql_keywords
|
|
||||||
$sql_additional
|
|
||||||
ORDER BY $sort_by";
|
|
||||||
$result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset);
|
$result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue