Skip to content

Commit

Permalink
🐛🚸 Fix permissions and improve message block (#530)
Browse files Browse the repository at this point in the history
* Fix permissions and improve message block

closes #502

* Add translation

* ui

* emoji -> font awesome
  • Loading branch information
MrKrisKrisu authored Oct 2, 2021
1 parent 5d57795 commit a4eb7f0
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 40 deletions.
3 changes: 3 additions & 0 deletions app/Models/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public function getSocialTextAttribute(): string {
* @return bool
*/
public function getStatusInvisibleToMeAttribute(): bool {
if($this->user->userInvisibleToMe) {
return true;
}
if (Auth::check() && Auth::id() == $this->user_id || $this->visibility == StatusVisibility::PUBLIC) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"controller.transport.no-name-given": "Du musst einen Stationsnamen angeben!",
"controller.transport.not-in-stopovers": "Die Start-ID ist nicht in den Zwischenstops.",
"controller.transport.overlapping-checkin": "Du hast bereits einen Check-In in Verbindung :linename: <a href=\":url\">#:id</a>",
"controller.transport.also-in-connection": "Auch in dieser Verbindung sind:",
"controller.transport.also-in-connection": "Auch in dieser Verbindung ist:|Auch in dieser Verbindung sind:",
"controller.transport.social-post": "Ich bin gerade in :lineName nach :Destination! #NowTräwelling |Ich bin gerade in Linie :lineName nach :Destination! #NowTräwelling ",
"controller.transport.social-post-with-event": "Ich bin gerade in :lineName nach :destination für #:hashtag! #NowTräwelling | Ich bin gerade in Linie :lineName nach #destination für #:hashtag! #NowTräwelling ",
"controller.transport.social-post-for": " für #:hashtag",
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/de_by.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"controller.user.follow-destroyed": "Du folgsch dera Person nimme.",
"controller.status.like-not-found": "Dean Like gaits id.",
"controller.user.follow-delete-not-permitted": "Dia Aktion isch id erlaubt.",
"controller.transport.also-in-connection": "Ja sag amoi, au in der Verbindung sand:",
"controller.transport.also-in-connection": "Ja sag amoi, au in der Verbindung is:|Ja sag amoi, au in der Verbindung sand:",
"controller.status.like-already": "Dean Like gaits schu.",
"user.mute-tooltip": "B'nutzr schdummschalda",
"status.visibility.0": "Öffatlich",
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/de_he.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"controller.transport.no-name-given": "Du muschd en Stazionsname angewwe!",
"controller.transport.not-in-stopovers": "Die Start-ID is nedd inde Zwischestops.",
"controller.transport.overlapping-checkin": "Du hoaschd schunn en Scheck-In in Verbindung :linename: <a href=\":url\">#:id</a>",
"controller.transport.also-in-connection": "Aa in der Verbindung sinn:",
"controller.transport.also-in-connection": "Aa in der Verbindung is:|Aa in der Verbindung sinn:",
"controller.transport.social-post": "Isch bin groad in :lineName noach :Destination! #NowTräwelling |Isch bin groad in Linie :lineName noach :Destination! #NowTräwelling ",
"controller.transport.social-post-with-event": "Isch bin groad in :lineName noach :destination für #:hashtag! #NowTräwelling | Isch bin groad in Linie :lineName noach #destination für #:hashtag! #NowTräwelling ",
"controller.transport.social-post-for": " für #:hashtag",
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/de_pfl.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"controller.transport.no-name-given": "Du musch e Stationsname angewwe!",
"controller.transport.not-in-stopovers": "Die Start-ID is ned in de Zwischestops.",
"controller.transport.overlapping-checkin": "Du hasch bereits e Check-In in Verbinnung :linename: <a href=\":url\">#:id</a>",
"controller.transport.also-in-connection": "In dere Verbinnung sinn aach:",
"controller.transport.also-in-connection": "In dere Verbinnung is aach:|In dere Verbinnung sinn aach:",
"controller.transport.social-post": "Ich bin grad in :lineName nooch :Destination! #NowTräwelling |Ich bin grad in de Linje :lineName nooch :Destination! #NowTräwelling ",
"controller.transport.social-post-with-event": "Ich bin grad in :lineName nooch :destination fer #:hashtag! #NowTräwelling | Ich bin grad in de Linje :lineName nooch :destination fer #:hashtag! #NowTräwelling ",
"controller.transport.social-post-for": " fer #:hashtag",
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"controller.transport.no-name-given": "You need to provide a station name!",
"controller.transport.not-in-stopovers": "Start-ID is not in stopovers.",
"controller.transport.overlapping-checkin": "You have an overlapping checkin with connection :linename: <a href=\":url\">#:id</a>",
"controller.transport.also-in-connection": "Also in this connection are:",
"controller.transport.also-in-connection": "Also in this connection is:|Also in this connection are:",
"controller.transport.social-post": "I'm in :lineName towards :Destination! #NowTräwelling |I'm in line :lineName towards :Destination! #NowTräwelling ",
"controller.transport.social-post-with-event": "I'm in :lineName towards #:hashtag via :Destination! #NowTräwelling | I'm in Line :lineName towards #:hashtag via :Destination! #NowTräwelling ",
"controller.transport.social-post-for": " for #:hashtag",
Expand Down
37 changes: 2 additions & 35 deletions resources/views/includes/message-block.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,8 @@
</div>
@endif

@if(Session::has('checkin-success'))
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
<h4 class="alert-heading">{{ __('controller.transport.checkin-heading') }}</h4>
<p>{{ trans_choice('controller.transport.checkin-ok', preg_match('/\s/', Session::get('checkin-success')['lineName']), ['lineName' => Session::get('checkin-success')['lineName']]) }}</p>
@if(Session::get('checkin-success')['alsoOnThisConnection']->count() >= 1)
<p>{{ __('controller.transport.also-in-connection') }}</p>
<ul>
@foreach(Session::get('checkin-success')['alsoOnThisConnection'] as $otherStatus)
<li>
<a href="{{ route('account.show', ['username' => $otherStatus->user->username]) }}">{{ '@' . $otherStatus->user->username }}</a>
</li>
@endforeach
</ul>
@endif
@if(Session::get('checkin-success')['event'])
<p>
{!! __('events.on-your-way', [
"name" => Session::get('checkin-success')['event']['name'],
"url" => route('statuses.byEvent', ['eventSlug' => Session::get('checkin-success')['event']['slug']])
]) !!}
</p>
@endif
<hr>
<p class="mb-0">
<i class="fa fa-stopwatch d-inline"></i>&nbsp;<b>{!! durationToSpan(secondsToDuration(Session::get('checkin-success')['duration'] * 60)) !!}</b>
<i class="fa fa-route d-inline"></i>&nbsp;<b>{{ number(Session::get('checkin-success')['distance']) }}
<small>km</small></b>
<i class="fa fa-dice-d20 d-inline"></i>&nbsp;<b>{{ Session::get('checkin-success')['points'] }}
<small>{{__('profile.points-abbr')}}</small></b>
</p>
</div>
@endif
@include('includes.messages.checkin-success')

<div id="alert_placeholder"></div>
</div>
</div>
Expand Down
59 changes: 59 additions & 0 deletions resources/views/includes/messages/checkin-success.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@if(session()->has('checkin-success'))
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
<h4 class="alert-heading">{{ __('controller.transport.checkin-heading') }}</h4>
<p>{{ trans_choice('controller.transport.checkin-ok', preg_match('/\s/', session()->get('checkin-success')['lineName']), ['lineName' => session()->get('checkin-success')['lineName']]) }}</p>
@if(session()->get('checkin-success')['alsoOnThisConnection']->count() >= 1)
<span>{{ trans_choice('controller.transport.also-in-connection', session()->get('checkin-success')['alsoOnThisConnection']->count()) }}</span>
<table style="margin-left: auto;margin-right: auto;">
<tbody>
@foreach(session()->get('checkin-success')['alsoOnThisConnection'] as $otherStatus)
@if($otherStatus->statusInvisibleToMe)
<tr>
<td colspan="5">
<i class="fas fa-user-secret" aria-hidden="true"></i>
{{__('user.private-profile')}}
</td>
</tr>
@else
<tr>
<td>
<i class="fas fa-user" aria-hidden="true"></i>
<a href="{{ route('account.show', ['username' => $otherStatus->user->username]) }}">
{{ '@' . $otherStatus->user->username }}
</a>
</td>
<td>-</td>
<td>{{ $otherStatus->trainCheckin->Origin->name }}</td>
<td>➜</td>
<td>{{ $otherStatus->trainCheckin->Destination->name }}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
@endif
@if(session()->get('checkin-success')['event'])
<p>
{!! __('events.on-your-way', [
"name" => session()->get('checkin-success')['event']['name'],
"url" => route('statuses.byEvent', ['eventSlug' => session()->get('checkin-success')['event']['slug']])
]) !!}
</p>
@endif
<hr>
<p class="mb-0">
<i class="fa fa-stopwatch d-inline"></i>&nbsp;
<b>{!! durationToSpan(secondsToDuration(session()->get('checkin-success')['duration'] * 60)) !!}</b>
<i class="fa fa-route d-inline"></i>&nbsp;
<b>
{{ number(session()->get('checkin-success')['distance']) }}
<small>km</small>
</b>
<i class="fa fa-dice-d20 d-inline"></i>&nbsp;
<b>{{ session()->get('checkin-success')['points'] }}<small>{{__('profile.points-abbr')}}</small></b>
</p>
</div>
@endif

0 comments on commit a4eb7f0

Please sign in to comment.