Hi everyone,
I've developed a small but very useful enhancement for the Tools > Action Logs menu in the Osclass admin panel. By default, the log table only shows "user" or "admin" in the "Who" column. This modification updates that column to show the user's Real Name (or Username) and turns it into a clickable link that opens the user's listings in a new tab.
Why use this?
Better Visibility: Instantly see who performed the action without checking IDs.
Quick Access: Click the name to see all items belonging to that user in a new tab.
Smart Detection: It intelligently detects if the log belongs to a "user" section (like registration) and shows the correct person.
Performance: Uses static caching so it doesn't slow down your page with extra database queries.
How to apply:
File: /oc-includes/osclass/classes/datatables/LogsDataTable.php
Find line ~132 (or look for the "who" row assignment):
PHP
$row['who'] = ($aRow['s_who'] <> '' ? $aRow['s_who'] : '-');Replace it with this code:
PHP
// --- Enhanced User Info and Smart Link Start ---
$who_type = ($aRow['s_who'] ?: '-');
// Identify the actor or the target user if it's a user-related section
$actor_id = (int)($aRow['fk_i_who_id'] ?? 0);
$target_id = (int)($aRow['fk_i_id'] ?? 0);
$who_id = (($aRow['s_section'] ?? '') === 'user' && $target_id > 0) ? $target_id : $actor_id;
if ($who_type === 'user' && $who_id > 0) {
static $userCache = [];
if (!isset($userCache[$who_id])) {
$user = User::newInstance()->findByPrimaryKey($who_id);
$name = (string)$who_id; // Default fallback to ID
if (is_array($user)) {
if (!empty($user['s_name'])) {
$name = $user['s_name']; // Priority 1: Real Name
} elseif (!empty($user['s_username']) && $user['s_username'] != $who_id) {
$name = $user['s_username']; // Priority 2: Username
}
}
$userCache[$who_id] = $name;
}
$url = osc_admin_base_url(true) . '?page=items&userId=' . $who_id;
// Output: user (Name) with a target="_blank" link
$row['who'] = osc_esc_html($who_type) . ' (<a href="' . osc_esc_html($url) . '" target="_blank">' . osc_esc_html($userCache[$who_id]) . '</a>)';
} else {
$row['who'] = osc_esc_html($who_type);
}
// --- Enhanced User Info and Smart Link End ---Key Improvements:
I hope this helps you manage your logs more efficiently!