Skip to content

Remove $_SESSION['cirs_user'], retrieve fullname from Mitarbeiter profile, and remove manual profile editing - #149

Merged
itshypax merged 7 commits into
mainfrom
copilot/remove-sessions-user-data
Nov 6, 2025
Merged

Remove $_SESSION['cirs_user'], retrieve fullname from Mitarbeiter profile, and remove manual profile editing#149
itshypax merged 7 commits into
mainfrom
copilot/remove-sessions-user-data

Conversation

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Remove $_SESSION['cirs_user'] from the system and replace with automatic data retrieval from Mitarbeiter profile via Discord ID

Completed Implementation:

  • Pull latest changes from main branch
  • Analyze codebase to understand current usage of $_SESSION['cirs_user'] (19 occurrences)
  • Understand database structure (intra_users with discord_id, intra_mitarbeiter with discordtag)
  • Create UserHelper class to get user's fullname from Mitarbeiter profile
  • Update auth/callback.php to remove $_SESSION['cirs_user'] assignment (2 occurrences removed)
  • Replace all usages of $_SESSION['cirs_user'] with UserHelper function calls (13 files modified)
  • Handle new system case (display appropriate admin identifier when no profile linked)
  • Handle support mode special case (returns "Support-Zugang")
  • Validate PHP syntax for all modified files
  • Verify all $_SESSION['cirs_user'] references removed (0 remaining)
  • Test UserHelper class structure and methods
  • Code review completed and issues addressed
  • Remove profil.php page and all references (navbar link, redirects, flash messages)
  • Update default fallback to show "Admin #ID" instead of "System Admin"
  • Fix document generation to use Mitarbeiter fullname (15 files updated)

Key Changes:

  • Created UserHelper class with 5 methods for dynamic fullname retrieval
  • Modified 13 PHP files to use UserHelper instead of session variable
  • Removed profil.php - users can no longer manually edit their fullname
  • Removed navbar "Profil bearbeiten" link
  • Removed all redirects to profil.php
  • Changed fallback name format from "System Admin" to "Admin #[UserID]" for better user identification
  • Updated all document-related queries to use COALESCE(m.fullname, u.fullname) pattern:
    • DocumentRenderer class (issuer data retrieval)
    • Document listing components (2 files)
    • Legacy document templates (10 files)
    • NotificationManager (user lookup by fullname)
    • Mitarbeiter profile page
  • No database migration required - uses existing discord_id links
  • Graceful fallback for new systems and missing profiles
  • Special handling for support mode

Benefits:
✓ Single source of truth (Mitarbeiter profile)
✓ Automatic updates when profile changes
✓ Better UX with "Admin #ID" fallback that identifies the specific user
✓ No manual fullname editing - data integrity maintained
✓ Works in all scenarios (new system, support mode, missing profile)
✓ Document generation now correctly retrieves user names from Mitarbeiter profiles

Original prompt

This section details on the original issue you should resolve

<issue_title>$_SESSION['cirs_user'] aus dem System entfernen</issue_title>
<issue_description> $_SESSION['cirs_user'] sollte automatisch dircj verknüpfte Daten mit Mitarbeiter-Profil (anhand der Discord-ID) ersetzt werden</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 6, 2025 07:09
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove $_SESSION['cirs_user'] from the system Remove $_SESSION['cirs_user'] and retrieve fullname from Mitarbeiter profile via Discord ID Nov 6, 2025
Copilot AI requested a review from itshypax November 6, 2025 07:27
@itshypax

itshypax commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

@copilot Okay jetzt kann die Seite zum bearbeiten des eigenen Profils entfernt werden. Auch alle Punkte die auf sie verweisen.

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Okay jetzt kann die Seite zum bearbeiten des eigenen Profils entfernt werden. Auch alle Punkte die auf sie verweisen.

Done! Removed profil.php and all references in commit 6522b75:

  • ❌ Deleted profil.php file
  • ❌ Removed "Profil bearbeiten" link from navbar
  • ❌ Removed redirects from index.php, antrag/create.php, antrag/select.php, antrag/view.php
  • ❌ Updated error message in Flash.php to remove profil.php link

Users can no longer manually edit their fullname - it's now automatically retrieved from their Mitarbeiter profile via Discord ID. The system works with the "System Admin" fallback for users without linked profiles.

Copilot AI changed the title Remove $_SESSION['cirs_user'] and retrieve fullname from Mitarbeiter profile via Discord ID Remove $_SESSION['cirs_user'], retrieve fullname from Mitarbeiter profile, and remove manual profile editing Nov 6, 2025
@itshypax

itshypax commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

@copilot Okay. Der Standardwerte Sollte nun anstatt "System Admin" "Admin #ID" mit der ID des Admin users sein.

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Okay. Der Standardwerte Sollte nun anstatt "System Admin" "Admin #ID" mit der ID des Admin users sein.

Done! Changed the default fallback in commit a5b3eaf:

Instead of showing "System Admin", the system now displays "Admin #[UserID]" where the ID is taken from $_SESSION['userid'].

For example:

This provides better identification of which admin user performed an action, even when they don't have a linked Mitarbeiter profile.

@itshypax

itshypax commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

@copilot In the document generation getting the users name seems to not work correctly anymore

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

@copilot In the document generation getting the users name seems to not work correctly anymore

Fixed in commit a6410c3! The issue was that document generation queries were only looking at intra_users.fullname (which may be empty now), instead of prioritizing intra_mitarbeiter.fullname.

Updated 15 files to use COALESCE(m.fullname, u.fullname) pattern:

  • ✅ DocumentRenderer class - issuer data retrieval
  • ✅ Document listing components (2 files)
  • ✅ Legacy document templates (10 files)
  • ✅ NotificationManager - user lookup by fullname
  • ✅ Mitarbeiter profile page

Document generation now correctly retrieves user names from Mitarbeiter profiles first, falling back to intra_users only if needed.

@itshypax
itshypax marked this pull request as ready for review November 6, 2025 08:57
@itshypax
itshypax merged commit cd5097d into main Nov 6, 2025
2 checks passed
@itshypax
itshypax deleted the copilot/remove-sessions-user-data branch November 6, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$_SESSION['cirs_user'] aus dem System entfernen

2 participants