Log messages without inline HTML

main
Igor Scheller 6 years ago committed by msquare
parent e7f10d846e
commit 4e709d0d23

@ -62,7 +62,7 @@ function user_angeltypes_delete_all_controller()
if ($request->hasPostData('deny_all')) {
UserAngelTypes_delete_all($angeltype['id']);
engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype)));
engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Denied all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
}
@ -102,7 +102,7 @@ function user_angeltypes_confirm_all_controller()
if ($request->hasPostData('confirm_all')) {
UserAngelTypes_confirm_all($angeltype['id'], $user->id);
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype)));
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
}
@ -156,8 +156,8 @@ function user_angeltype_confirm_controller()
engelsystem_log(sprintf(
'%s confirmed for angeltype %s',
User_Nick_render($user_source),
AngelType_name_render($angeltype)
User_Nick_render($user_source, true),
AngelType_name_render($angeltype, true)
));
success(sprintf(
__('%s confirmed for angeltype %s.'),
@ -214,9 +214,8 @@ function user_angeltype_delete_controller()
if ($request->hasPostData('delete')) {
UserAngelType_delete($user_angeltype);
$success_message = sprintf(__('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']);
engelsystem_log($success_message);
success($success_message);
engelsystem_log(sprintf('User %s removed from %s.', User_Nick_render($user_source, true), $angeltype['name']));
success(sprintf(__('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
}
@ -275,15 +274,19 @@ function user_angeltype_update_controller()
if ($request->hasPostData('submit')) {
UserAngelType_update($user_angeltype['id'], $supporter);
$success_message = sprintf(
$supporter
$msg = $supporter
? __('Added supporter rights for %s to %s.')
: __('Removed supporter rights for %s from %s.'),
: __('Removed supporter rights for %s from %s.');
engelsystem_log(sprintf(
$msg,
AngelType_name_render($angeltype, true),
User_Nick_render($user_source, true)
));
success(sprintf(
$msg,
AngelType_name_render($angeltype),
User_Nick_render($user_source)
);
engelsystem_log($success_message);
success($success_message);
));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
}
@ -324,8 +327,8 @@ function user_angeltype_add_controller()
engelsystem_log(sprintf(
'User %s added to %s.',
User_Nick_render($user_source),
AngelType_name_render($angeltype)
User_Nick_render($user_source, true),
AngelType_name_render($angeltype, true)
));
success(sprintf(
__('User %s added to %s.'),
@ -336,8 +339,8 @@ function user_angeltype_add_controller()
UserAngelType_confirm($user_angeltype_id, $user_source->id);
engelsystem_log(sprintf(
'User %s confirmed as %s.',
User_Nick_render($user_source),
AngelType_name_render($angeltype)
User_Nick_render($user_source, true),
AngelType_name_render($angeltype, true)
));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
@ -372,8 +375,8 @@ function user_angeltype_join_controller($angeltype)
$success_message = sprintf(__('You joined %s.'), $angeltype['name']);
engelsystem_log(sprintf(
'User %s joined %s.',
User_Nick_render($user),
AngelType_name_render($angeltype)
User_Nick_render($user, true),
AngelType_name_render($angeltype, true)
));
success($success_message);
@ -381,8 +384,8 @@ function user_angeltype_join_controller($angeltype)
UserAngelType_confirm($user_angeltype_id, $user->id);
engelsystem_log(sprintf(
'User %s confirmed as %s.',
User_Nick_render($user),
AngelType_name_render($angeltype)
User_Nick_render($user, true),
AngelType_name_render($angeltype, true)
));
}

@ -85,7 +85,7 @@ function user_delete_controller()
mail_user_delete($user_source);
success(__('User deleted.'));
engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source)));
engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source, true)));
redirect(users_link());
}
@ -170,7 +170,7 @@ function user_edit_vouchers_controller()
$user_source->state->save();
success(__('Saved the number of vouchers.'));
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
engelsystem_log(User_Nick_render($user_source, true) . ': ' . sprintf('Got %s vouchers',
$user_source->state->got_voucher));
redirect(user_link($user_source->id));

@ -48,7 +48,7 @@ function AngelType_delete($angeltype)
WHERE `id`=?
LIMIT 1
', [$angeltype['id']]);
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype, true));
}
/**

@ -94,7 +94,7 @@ function ShiftEntry_create($shift_entry)
]
);
engelsystem_log(
'User ' . User_Nick_render($user)
'User ' . User_Nick_render($user, true)
. ' signed up for shift ' . $shift['name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
@ -156,7 +156,7 @@ function ShiftEntry_delete($shiftEntry)
$angeltype = AngelType($shiftEntry['TID']);
engelsystem_log(
'Shift signout: ' . User_Nick_render($signout_user) . ' from shift ' . $shifttype['name']
'Shift signout: ' . User_Nick_render($signout_user, true) . ' from shift ' . $shifttype['name']
. ' at ' . $room['Name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])

@ -47,7 +47,7 @@ function UserWorkLog_delete($userWorkLog)
engelsystem_log(sprintf(
'Delete work log for %s, %s hours, %s',
User_Nick_render($user_source),
User_Nick_render($user_source, true),
$userWorkLog['work_hours'],
$userWorkLog['comment']
));
@ -78,7 +78,7 @@ function UserWorkLog_update($userWorkLog)
engelsystem_log(sprintf(
'Updated work log for %s, %s hours, %s',
User_Nick_render($user_source),
User_Nick_render($user_source, true),
$userWorkLog['work_hours'],
$userWorkLog['comment'])
);
@ -115,7 +115,7 @@ function UserWorkLog_create($userWorkLog)
time()
]);
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s', User_Nick_render($user_source),
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s', User_Nick_render($user_source, true),
$userWorkLog['work_hours'], $userWorkLog['comment']));
return $result;

@ -5,6 +5,7 @@ use Engelsystem\Database\DB;
use Engelsystem\Models\User\PasswordReset;
use Engelsystem\Models\User\User;
use Engelsystem\ValidationResult;
use Illuminate\Database\Query\JoinClause;
/**
* User model
@ -222,7 +223,7 @@ function User_reset_api_key($user, $log = true)
$user->save();
if ($log) {
engelsystem_log(sprintf('API key resetted (%s).', User_Nick_render($user)));
engelsystem_log(sprintf('API key resetted (%s).', User_Nick_render($user, true)));
}
}
@ -239,7 +240,7 @@ function User_generate_password_recovery_token($user)
$reset->token = md5($user->name . time() . rand());
$reset->save();
engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
engelsystem_log('Password recovery for ' . User_Nick_render($user, true) . ' started.');
return $reset->token;
}

@ -86,7 +86,7 @@ function admin_active()
foreach ($users as $usr) {
$usr->state->active = true;
$usr->state->save();
$user_nicks[] = User_Nick_render($usr);
$user_nicks[] = User_Nick_render($usr, true);
}
State::whereForceActive(true)->update(['active' => true]);
@ -108,7 +108,7 @@ function admin_active()
if ($user_source) {
$user_source->state->active = true;
$user_source->state->save();
engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
engelsystem_log('User ' . User_Nick_render($user_source, true) . ' is active now.');
$msg = success(__('Angel has been marked as active.'), true);
} else {
$msg = error(__('Angel not found.'), true);
@ -119,7 +119,7 @@ function admin_active()
if ($user_source) {
$user_source->state->active = false;
$user_source->state->save();
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
engelsystem_log('User ' . User_Nick_render($user_source, true) . ' is NOT active now.');
$msg = success(__('Angel has been marked as not active.'), true);
} else {
$msg = error(__('Angel not found.'), true);
@ -130,7 +130,7 @@ function admin_active()
if ($user_source) {
$user_source->state->got_shirt = true;
$user_source->state->save();
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
engelsystem_log('User ' . User_Nick_render($user_source, true) . ' has tshirt now.');
$msg = success(__('Angel has got a t-shirt.'), true);
} else {
$msg = error('Angel not found.', true);
@ -141,7 +141,7 @@ function admin_active()
if ($user_source) {
$user_source->state->got_shirt = false;
$user_source->state->save();
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
engelsystem_log('User ' . User_Nick_render($user_source, true) . ' has NO tshirt.');
$msg = success(__('Angel has got no t-shirt.'), true);
} else {
$msg = error(__('Angel not found.'), true);

@ -37,7 +37,7 @@ function admin_arrive()
$user_source->state->arrival_date = null;
$user_source->state->save();
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source, true));
success(__('Reset done. Angel has not arrived.'));
redirect(user_link($user_source->id));
} else {
@ -55,7 +55,7 @@ function admin_arrive()
$user_source->state->arrival_date = new Carbon\Carbon();
$user_source->state->save();
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source, true));
success(__('Angel has been marked as arrived.'));
redirect(user_link($user_source->id));
} else {

@ -130,9 +130,9 @@ function admin_questions()
);
engelsystem_log(
'Question '
. htmlspecialchars($question['Question'])
. $question['Question']
. ' answered: '
. htmlspecialchars($answer)
. $answer
);
redirect(page_link_to('admin_questions'));
} else {
@ -159,7 +159,7 @@ function admin_questions()
);
if (!empty($question)) {
DB::delete('DELETE FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id]);
engelsystem_log('Question deleted: ' . htmlspecialchars($question['Question']));
engelsystem_log('Question deleted: ' . $question['Question']);
redirect(page_link_to('admin_questions'));
} else {
return error('No question found.', true);

@ -240,7 +240,7 @@ function admin_user()
}
$user_source = User::find($user_id);
engelsystem_log(
'Set groups of ' . User_Nick_render($user_source) . ' to: '
'Set groups of ' . User_Nick_render($user_source, true) . ' to: '
. join(', ', $user_groups_info)
);
$html .= success('Benutzergruppen gespeichert.', true);
@ -293,7 +293,7 @@ function admin_user()
) {
set_password($user_id, $request->postData('new_pw'));
$user_source = User::find($user_id);
engelsystem_log('Set new password for ' . User_Nick_render($user_source));
engelsystem_log('Set new password for ' . User_Nick_render($user_source, true));
$html .= success('Passwort neu gesetzt.', true);
} else {
$html .= error(

@ -89,7 +89,8 @@ function guest_register()
if (!$nickValidation->isValid()) {
$valid = false;
$msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'), $nick), true);
$msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'),
$nick), true);
}
if (User::whereName($nick)->count() > 0) {
$valid = false;
@ -246,7 +247,7 @@ function guest_register()
}
engelsystem_log(
'User ' . User_Nick_render($user)
'User ' . User_Nick_render($user, true)
. ' signed up as: ' . join(', ', $user_angel_types_info)
);
success(__('Angel registration successful!'));
@ -287,7 +288,8 @@ function guest_register()
div('row', [
div('col-sm-4', [
form_text('nick', __('Nick') . ' ' . entry_required(), $nick),
form_info('', __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'))
form_info('',
__('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'))
]),
div('col-sm-8', [
form_email('mail', __('E-Mail') . ' ' . entry_required(), $mail),

@ -99,7 +99,7 @@ function user_myshifts()
]);
engelsystem_log(
'Updated ' . User_Nick_render($user_source) . '\'s shift ' . $shift['name']
'Updated ' . User_Nick_render($user_source, true) . '\'s shift ' . $shift['name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
. ' with comment ' . $comment

@ -156,7 +156,7 @@ function user_news_comments()
]
);
engelsystem_log('Created news_comment: ' . htmlspecialchars($text));
engelsystem_log('Created news_comment: ' . $text);
$html .= success(__('Entry saved.'), true);
}

@ -18,7 +18,7 @@ function engelsystem_log($message, $level = LogLevel::INFO)
$user = auth()->user();
if ($user) {
$nick = User_Nick_render($user);
$nick = User_Nick_render($user, true);
}
$logger->log($level, '{nick}: {message}', ['nick' => $nick, 'message' => $message]);

@ -12,10 +12,15 @@ use Engelsystem\ShiftsFilterRenderer;
* Renders the angeltypes name as link.
*
* @param array $angeltype
* @param bool $plain
* @return string
*/
function AngelType_name_render($angeltype)
function AngelType_name_render($angeltype, $plain = false)
{
if ($plain) {
return sprintf('%s (%u)', $angeltype['name'], $angeltype['id']);
}
return '<a href="' . angeltype_link($angeltype['id']) . '">'
. ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name']
. '</a>';

@ -36,7 +36,10 @@ function User_settings_view(
form_info('', __('Here you can change your user details.')),
form_info(entry_required() . ' = ' . __('Entry required!')),
form_text('nick', __('Nick'), $user_source->name, true),
form_info('', __('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.')),
form_info(
'',
__('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.')
),
form_text('lastname', __('Last name'), $personalData->last_name),
form_text('prename', __('First name'), $personalData->first_name),
$enable_planned_arrival ? form_date(
@ -856,14 +859,19 @@ function User_groups_render($user_groups)
* Render a user nickname.
*
* @param array|User $user
* @param bool $plain
* @return string
*/
function User_Nick_render($user)
function User_Nick_render($user, $plain = false)
{
if (is_array($user)) {
$user = (new User())->forceFill($user);
}
if ($plain) {
return sprintf('%s (%u)', $user->name, $user->id);
}
return render_profile_link(
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($user->name) . '</a>',
$user->id,

Loading…
Cancel
Save