Skip to content
Snippets Groups Projects
Commit 7fedee30 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

use correct variable, fixes #2504

Closes #2504

Merge request studip/studip!1693
parent 58b66b21
No related branches found
No related tags found
No related merge requests found
...@@ -48,38 +48,52 @@ class StudipLog ...@@ -48,38 +48,52 @@ class StudipLog
* @param mixed $dbg_info Debug information to add to the event * @param mixed $dbg_info Debug information to add to the event
* @param mixed $user_id Provide null for the current user id * @param mixed $user_id Provide null for the current user id
**/ **/
public static function log($action_name, $affected = null, public static function log(
$coaffected = null, $info = null, $dbg_info = null, $user_id = null) $action_name,
{ $affected = null,
$coaffected = null,
$info = null,
$dbg_info = null,
$user_id = null
) {
if (!Config::get()->LOG_ENABLE) { if (!Config::get()->LOG_ENABLE) {
return; return false;
}
// automagically set current user as agent
if (!$user_id) {
$user_id = $GLOBALS['user']->id;
} }
$log_action = LogAction::findOneByName($action_name); $log_action = LogAction::findOneByName($action_name);
if (!$log_action) { if (!$log_action) {
// Action doesn't exist -> LOG_ERROR // Action doesn't exist -> LOG_ERROR
$debug = sprintf('StudipLog::log(%s,%s,%s,%s,%s) for user %s', $debug = sprintf(
$log_action->name, $affected, $coaffected, $info, 'StudipLog::log(%s,%s,%s,%s,%s) for user %s',
$dbg_info, $user_id); $action_name,
$affected,
$coaffected,
$info,
$dbg_info,
$user_id
);
self::log('LOG_ERROR', null, null, null, $debug); self::log('LOG_ERROR', null, null, null, $debug);
return false; return false;
} }
if ($log_action->isActive()) {
// automagically set current user as agent if (!$log_action->isActive()) {
if (!$user_id) { return false;
$user_id = $GLOBALS['auth']->auth['uid'];
}
$log_event = new LogEvent();
$log_event->user_id = $user_id;
$log_event->action_id = $log_action->getId();
$log_event->affected_range_id = $affected;
$log_event->coaffected_range_id = $coaffected;
$log_event->info = $info;
$log_event->dbg_info = $dbg_info;
$log_event->store();
return true;
} }
return false;
$log_event = new LogEvent();
$log_event->user_id = $user_id;
$log_event->action_id = $log_action->getId();
$log_event->affected_range_id = $affected;
$log_event->coaffected_range_id = $coaffected;
$log_event->info = $info;
$log_event->dbg_info = $dbg_info;
$log_event->store();
return true;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment