aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-03-04 18:11:42 -0600
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-03-04 18:11:42 -0600
commitcb4bd3f8812b469afb489bdc60473a234837e50c (patch)
tree4ebb850682e83f928498d71ea0e555c5f3679374 /phpBB/includes/functions.php
parent1148f3fca51efb60e536f2fe0d51880610f0812b (diff)
parent7423d48757bec0a81c8d439e911ed32d5af3a775 (diff)
downloadforums-cb4bd3f8812b469afb489bdc60473a234837e50c.tar
forums-cb4bd3f8812b469afb489bdc60473a234837e50c.tar.gz
forums-cb4bd3f8812b469afb489bdc60473a234837e50c.tar.bz2
forums-cb4bd3f8812b469afb489bdc60473a234837e50c.tar.xz
forums-cb4bd3f8812b469afb489bdc60473a234837e50c.zip
Merge remote-tracking branch 'remotes/nickv/ticket/10714' into develop
# By Joas Schilling # Via Joas Schilling * remotes/nickv/ticket/10714: (56 commits) [ticket/10714] Get log from container in install, update and download/file [ticket/10714] Use $phpbb_adm_relative_path instead of hardcoded adm/ [ticket/10714] Logs are disabled for this page call only [ticket/10714] Update add_log docs block with @param and @deprecated [ticket/10714] Remove fallback code from previous commits and move global [ticket/10714] Fix missing parameter and global phpbb_log in unit tests [ticket/10714] Add getter for is_in_admin and use it [ticket/10714] Fix more comments [ticket/10714] Cast values to integer before using them in the query [ticket/10714] Fix several doc blocks and comments [ticket/10714] Fix missing 8th argument in unit tests [ticket/10714] Use new core.adm_relative_path to create the object. [ticket/10714] Fix several comments and variable names [ticket/10714] Fix database driver class name [ticket/10714] Forgot most important, use container to create $phpbb_log [ticket/10714] Remove type hinting to allow the usage of mocks in tests [ticket/10714] Fix dependency injections in unit tests with mocks [ticket/10714] Use dependencies instead of globals [ticket/10714] Compare log_type to false, rather then null [ticket/10714] Add global variables for the unit tests ...
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php72
1 files changed, 26 insertions, 46 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 6a1f144967..c0fd3918dc 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3582,69 +3582,49 @@ function parse_cfg_file($filename, $lines = false)
}
/**
-* Add log event
+* Add log entry
+*
+* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved
+* @param int $forum_id Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise
+* @param int $topic_id Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise
+* @param int $reportee_id Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise
+* @param string $log_operation Name of the operation
+* @param array $additional_data More arguments can be added, depending on the log_type
+*
+* @return int|bool Returns the log_id, if the entry was added to the database, false otherwise.
+*
+* @deprecated Use $phpbb_log->add() instead
*/
function add_log()
{
- global $db, $user;
-
- // In phpBB 3.1.x i want to have logging in a class to be able to control it
- // For now, we need a quite hakish approach to circumvent logging for some actions
- // @todo implement cleanly
- if (!empty($GLOBALS['skip_add_log']))
- {
- return false;
- }
+ global $phpbb_log, $user;
$args = func_get_args();
+ $mode = array_shift($args);
- $mode = array_shift($args);
- $reportee_id = ($mode == 'user') ? intval(array_shift($args)) : '';
- $forum_id = ($mode == 'mod') ? intval(array_shift($args)) : '';
- $topic_id = ($mode == 'mod') ? intval(array_shift($args)) : '';
- $action = array_shift($args);
- $data = (!sizeof($args)) ? '' : serialize($args);
-
- $sql_ary = array(
- 'user_id' => (empty($user->data)) ? ANONYMOUS : $user->data['user_id'],
- 'log_ip' => $user->ip,
- 'log_time' => time(),
- 'log_operation' => $action,
- 'log_data' => $data,
- );
-
+ // This looks kind of dirty, but add_log has some additional data before the log_operation
+ $additional_data = array();
switch ($mode)
{
case 'admin':
- $sql_ary['log_type'] = LOG_ADMIN;
+ case 'critical':
break;
-
case 'mod':
- $sql_ary += array(
- 'log_type' => LOG_MOD,
- 'forum_id' => $forum_id,
- 'topic_id' => $topic_id
- );
+ $additional_data['forum_id'] = array_shift($args);
+ $additional_data['topic_id'] = array_shift($args);
break;
-
case 'user':
- $sql_ary += array(
- 'log_type' => LOG_USERS,
- 'reportee_id' => $reportee_id
- );
- break;
-
- case 'critical':
- $sql_ary['log_type'] = LOG_CRITICAL;
+ $additional_data['reportee_id'] = array_shift($args);
break;
-
- default:
- return false;
}
- $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+ $log_operation = array_shift($args);
+ $additional_data = array_merge($additional_data, $args);
+
+ $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id'];
+ $user_ip = (empty($user->ip)) ? '' : $user->ip;
- return $db->sql_nextid();
+ return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data);
}
/**