Skip to content

Conversation

@schlagma
Copy link
Collaborator

No description provided.

@schlagma schlagma requested a review from lukas-staab July 25, 2025 16:21
@schlagma schlagma changed the title Membership list in profile Membership list in profile and PDF export Jul 27, 2025
@schlagma schlagma changed the title Membership list in profile and PDF export User profile and PDF export of memberships Jul 28, 2025

public function mount($username)
{
if ($username == auth()->user()->username || auth()->user()->can('superadmin', User::class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== statt ==

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Livewire kann man auch $this->authorize() verwenden, dann liefert es aber auch direkt ein Permission denied wenns schief geht. Ich glaube ich fände es schöner eine Policy für PW Changes zu haben und auf die hier zu authorizen. Dann ist wer darf was schön an einem Platz (bei den Policies). Kannst du beim User mit rein nehmen.

{
$username = Auth::user()->username;
$user = User::findOrFailByUsername($username);
if ($username == auth()->user()->username || auth()->user()->can('superadmin', User::class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.o.

public string $fullName;

public function mount()
public $currentUsername;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vorsicht! Public probs können via client api frei verändert werden, auch wenn du da kein Input feld hin machst. Macht das hier Probleme? Evtl das [#Url] oder [#Locked] Prop verwenden stattdessen

}
}

public function getMemberships(string $username, bool $onlyActive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public Methoden können bei livewire auch vom client aus aufgerufen werden. Wenn du das nicht machst (wie hier?) solltest du die private machen

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moderator:innen einer Studischaft haben keinen Zugriff auf den Profil-Bereich. Damit Moderator:innen trotzdem die Möglichkeit haben, die Tätigkeitsübersicht zu exportieren und es möglichst wenig Code-Dopplung gibt, greift auch der Members-Controller auf diese Funktion zu.

$memberships = [];
foreach ($roleMemberships as $row) {
$role = Role::findOrFail('cn=' . $row->role_cn . ',' . $row->committee_dn);
array_push($memberships, [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: If you use array_push() to add one element to the array, it's better to use $array[] = because in that way there is no overhead of calling a function.
https://www.php.net/manual/en/function.array-push.php

Ich finde $memberships[] = [...]; auch leichter verständlich was passiert :)


return response()->streamDownload(function () use ($pdf) {
echo $pdf->stream();
}, 'memberships-' . $this->currentUsername . '.pdf');;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memberships im File Name hier auch übersetzen? @DieMichii was ist ein Guter Dateiname für eine Gremienbescheinigung die wie im Chat aussieht?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.s. man kann auch an die Übersetzung parameter (wie den Namen) übergeben. Das wäre hier vmtl. sinnig.

unset($this->deleteMemberName, $this->deleteMemberUsername);
}

public function exportPdf($username)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sehe ich das Richtig, das es einmal das PDF pro Person und das andere mal das PDF pro Rolle / Realm ist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falls du dich auf den Zugriff aus unterschiedlichen Komponenten auf diese Funktion beziehst, dann ist der einzige Unterschied, dass im Profil kein Realm mitgegeben werden kann, da die Nutzer nicht nur einem einzigen Realm zugeordnet sein können. Beim Export über die Mitglieder-Liste eines Realms kann der aktuelle Realm für den PDF-Export mitgegeben werden, sodass auch die Studischaft im Dokument angezeigt werden kann.

<x-table.cell>{{ $realm_member->cn[0] }}</x-table.cell>
<x-table.cell>
@if (auth()->user()->can('superadmin', \App\Ldap\User::class))
<a wire:navigate href="{{ route('profile', ['username' => $realm_member->uid[0]]) }}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich weiß das es schon so war, aber hier ist es vllt besser das native getFirstAttribute von LdapRecord zu verwenden. Der aktuelle Code würde explodieren falls uid bspw kein Array wäre

<html>
<head>
<meta charset="utf-8" />
<style>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

das war nicht mit Tailwind möglich?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das würde bedeuten, dass wir Tailwind auch in den PDF-Export einbinden müssten. Das ist für die geringen Anforderungen eigentlich nicht unbedingt nötig. Ob die Integration von Tailwind an der Stelle funktioniert, weiß ich nicht genau. Hübscher wird es bei der geringe Komplexität mit normalem CSS aber aus meiner Sicht nicht werden.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOMPDF unterstützt nur CSS 2.1 und ein wenig CSS 3 (siehe https://github.com/dompdf/dompdf).

schlagma and others added 5 commits November 26, 2025 02:53
* Save relation between groups and roles in database and sync group members to LDAP by script

* Script to move the roles of all groups from LDAP to the database
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.

3 participants