Skip to content

Commit

Permalink
feat: Pass user id as string
Browse files Browse the repository at this point in the history
  • Loading branch information
KminekMatej committed Sep 7, 2024
1 parent 291e868 commit d955044
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions app/module/core/component/templates/blocks/team.latte
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{plink :Team:Player: $me->getWebName()}">{$me->getDisplayName()} <span class="badge badge-danger" n:if="$me->getWarnings()">{$me->getWarnings()}</span></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-primary" href="{plink :Team:Default:inits}" n:if="$counts['INIT'] > 0 && $user->isAllowed($user->getId(), 'SYS:SEE_INITS')">{_team.INIT,2} <span class="badge badge-primary" n:if="$counts['INIT'] > 0">{$counts['INIT']}</span></a>
<a class="dropdown-item text-primary" href="{plink :Team:Default:inits}" n:if="$counts['INIT'] > 0 && $user->isAllowed((string) $user->getId(), 'SYS:SEE_INITS')">{_team.INIT,2} <span class="badge badge-primary" n:if="$counts['INIT'] > 0">{$counts['INIT']}</span></a>
<a class="dropdown-item" href="{plink :Team:Default:players}">{_team.PLAYER,2} ({$counts['PLAYER']}) <span class="badge badge-success" n:if="$counts['NEW:PLAYER'] > 0">{_common.new}</span></a>
<a class="dropdown-item" href="{plink :Team:Default:members}">{_team.MEMBER,2} ({$counts['MEMBER']})</a>
<a class="dropdown-item" href="{plink :Team:Default:sicks}">{_team.SICK,2} ({$counts['SICK']})</a>
<a class="dropdown-item" href="{plink :Team:Default:}">{_common.everyone} ({$counts['ALL']})</a>
<a class="dropdown-item" href="{plink :Team:Player:new}" n:if="$user->isAllowed($user->getId(), 'SYS:USR_CREATE')"><i class="fa fa-plus-circle text-success" aria-hidden="true"></i> {_common.new}</a>
<a class="dropdown-item" href="{plink :Team:Player:new}" n:if="$user->isAllowed((string) $user->getId(), 'SYS:USR_CREATE')"><i class="fa fa-plus-circle text-success" aria-hidden="true"></i> {_common.new}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{plink :Team:Default:jerseys}"><i class="fas fa-tshirt" aria-hidden="true"></i> {_team.jerseyList}</a>
<a n:if="$user->isAllowed($user->getId(), 'SYS:USR_CREATE')" class="dropdown-item" href="{plink :Team:Default:invitation}"><i class="fa-solid fa-envelope-open-text"></i> {_team.invitation, 2}</a>
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:USR_CREATE')" class="dropdown-item" href="{plink :Team:Default:invitation}"><i class="fa-solid fa-envelope-open-text"></i> {_team.invitation, 2}</a>
</div>
</li>
16 changes: 8 additions & 8 deletions app/module/core/presenter/front/SecuredPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,35 +146,35 @@ public function getAccessibleSettings()
private function setAccessibleSettings()
{
$separate = false;
if ($this->getUser()->isAllowed($this->user->getId(), "SYS:DSSETUP")) {
if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:DSSETUP")) {
$this->accessibleSettings[] = new SettingMenu("discussions", $this->translator->translate("discussion.discussion", 2), $this->link(":Setting:Discussion:"), "fa-comments", true);
$separate = true;
}
if (
$this->getUser()->isAllowed($this->user->getId(), "SYS:EVE_UPDATE") ||
$this->getUser()->isAllowed($this->user->getId(), "SYS:EVE_CREATE") ||
$this->getUser()->isAllowed($this->user->getId(), "SYS:EVE_DELETE")
$this->getUser()->isAllowed((string) $this->user->getId(), "SYS:EVE_UPDATE") ||
$this->getUser()->isAllowed((string) $this->user->getId(), "SYS:EVE_CREATE") ||
$this->getUser()->isAllowed((string) $this->user->getId(), "SYS:EVE_DELETE")
) {
$this->accessibleSettings[] = new SettingMenu("events", $this->translator->translate("event.event", 2), $this->link(":Setting:Event:"), "fa-calendar", true);
$separate = true;
}

if ($this->getUser()->isAllowed($this->user->getId(), "SYS:TEAM_UPDATE")) {
if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:TEAM_UPDATE")) {
$this->accessibleSettings[] = new SettingMenu("team", $this->translator->translate("team.team", 1), $this->link(":Setting:Team:"), "fa-users", true);
$separate = true;
}

if ($this->getUser()->isAllowed($this->user->getId(), "SYS:ASK.VOTE_UPDATE")) {
if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:ASK.VOTE_UPDATE")) {
$this->accessibleSettings[] = new SettingMenu("polls", $this->translator->translate("poll.poll", 2), $this->link(":Setting:Poll:"), "fa-chart-pie", true);
$separate = true;
}

/*if ($this->getUser()->isAllowed($this->user->getId(), "SYS:REP_SETUP")) {
/*if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:REP_SETUP")) {
$this->accessibleSettings[] = new SettingMenu("reports", $this->translator->translate("report.report", 2), $this->link(":Setting:Report:"), "fa-chart-area", false);
$separate = true;
}*/

if ($this->getUser()->isAllowed($this->user->getId(), "SYS:IS_ADMIN")) {
if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:IS_ADMIN")) {
$this->accessibleSettings[] = new SettingMenu("permissions", $this->translator->translate("permission.permission", 2), $this->link(":Setting:Permission:"), "fa-gavel", true);
$separate = true;
}
Expand Down
2 changes: 1 addition & 1 deletion app/module/debt/presenter/front/DebtBasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function beforeRender(): void
protected function getPayeeList(): array
{
$payeeList = [$this->userManager->getById($this->user->getId())];
if ($this->getUser()->isAllowed($this->user->getId(), "SYS:DEBTS_TEAM")) {
if ($this->getUser()->isAllowed((string) $this->user->getId(), "SYS:DEBTS_TEAM")) {
$payeeList[] = $this->userManager->mockTeamUser();
}
return $payeeList;
Expand Down
2 changes: 1 addition & 1 deletion app/module/event/presenter/templates/Detail/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="col"><h4 class="card-title">{$event->getCaption()}</h4></div>
<div class="col col-md-auto text-right">
<a class="btn btn-sm btn-outline-dark ajax" n:href="loadHistory! $event->getWebName()" n:snippet="historyBtn" onclick="btnRotate($(this), true)" title="{_event.displayHistory}"><i class="fas fa-history"></i></a>
<a n:if="$user->isAllowed($user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-sm btn-light btn-light-bordered" title="{_common.edit}" href="{plink :Setting:Event: $event->getWebName()}"><i class="fa fa-edit" aria-hidden="true"></i></a>
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-sm btn-light btn-light-bordered" title="{_common.edit}" href="{plink :Setting:Event: $event->getWebName()}"><i class="fa fa-edit" aria-hidden="true"></i></a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function beforeRender()
*/
protected function allowPermission(string $permissionName, string $type = "SYS"): void
{
if (!$this->getUser()->isAllowed($this->user->getId(), "$type:$permissionName")) {
if (!$this->getUser()->isAllowed((string) $this->user->getId(), "$type:$permissionName")) {
$this->flashMessage($this->translator->translate("common.alerts.notPermitted"));
$this->redirect(":Setting:Default:");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
<td class="text-center"><label class="custom-control custom-checkbox"><input name="publicRead" type="checkbox" data-value="{$d->getPublicRead() ? 1 : 0}" n:attr="checked => $d->getPublicRead()" class="form-control form-control-sm custom-control-input" /><span class="custom-control-label"></span></label></td>
<td class="text-center"><label class="custom-control custom-checkbox"><input name="editablePosts" type="checkbox" data-value="{$d->getEditablePosts() ? 1 : 0}" n:attr="checked => $d->getEditablePosts()" class="form-control form-control-sm custom-control-input" /><span class="custom-control-label"></span></label></td>
<td><input name="order" data-value="{$d->getOrder()}" type="number" value="{$d->getOrder()}" class="form-control form-control-sm" style="max-width: 60px;"/></td>
<td class="btn-group" role="group" n:if="$user->isAllowed($user->getId(), 'SYS:DSSETUP')">
<td class="btn-group" role="group" n:if="$user->isAllowed((string) $user->getId(), 'SYS:DSSETUP')">
<button class="btn btn-sm btn-primary binder-save-btn" href="{link discussionEdit!}" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
<button class="btn btn-sm btn-danger binder-delete-btn" href="{link discussionDelete!}" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></button>
</td>
</tr>
</table>
</div>
<div class="card-footer text-right" n:if="$user->isAllowed($user->getId(), 'SYS:DSSETUP')">
<div class="card-footer text-right" n:if="$user->isAllowed((string) $user->getId(), 'SYS:DSSETUP')">
<a class="btn btn-lg btn-success" href="{plink :Setting:Discussion:New}" onclick="btnRotate($(this), true)" title="{_discussion.newDiscussionTitle}" style="margin-right: 10px">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</label></td></tr>
</table>
</div>
<div class="card-footer text-right" n:if="$user->isAllowed($user->getId(), 'SYS:DSSETUP')">
<div class="card-footer text-right" n:if="$user->isAllowed((string) $user->getId(), 'SYS:DSSETUP')">
<button n:if="!$isNew" href="{link discussionDelete!}" class="btn btn-danger mx-2 binder-delete-btn" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></button>
<button n:if="!$isNew" href="{link discussionEdit!}" class="btn btn-lg btn-primary binder-save-btn" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
<button n:if="$isNew" href="{link discussionCreate!}" class="btn btn-lg btn-primary binder-save-btn" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
Expand Down
6 changes: 3 additions & 3 deletions app/module/setting/presenter/templates/Event/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
{input resultRightName, class=> 'form-control form-control-sm'}
</td>
<td class="btn-group" role="group">
<button n:name="save" n:if="$user->isAllowed($user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-sm btn-primary" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
<a n:if="$user->isAllowed($user->getId(), 'SYS:EVE_DELETE')" href="{link eventDelete! $event->getId()}" class="btn btn-sm btn-danger ajax" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></a>
<button n:name="save" n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-sm btn-primary" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_DELETE')" href="{link eventDelete! $event->getId()}" class="btn btn-sm btn-danger ajax" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></a>
</td>
</tr>
{/form}
Expand All @@ -92,7 +92,7 @@
</table>
</div>
<div class="card-footer text-right">
<a n:if="$user->isAllowed($user->getId(), 'SYS:EVE_CREATE')" class="btn btn-lg btn-success" href="{plink :Setting:Event:New}" onclick="btnRotate($(this), true)" title="{_common.save}" style="margin-right: 10px">
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_CREATE')" class="btn btn-lg btn-success" href="{plink :Setting:Event:New}" onclick="btnRotate($(this), true)" title="{_common.save}" style="margin-right: 10px">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/module/setting/presenter/templates/Event/event.latte
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
</table>
</div>
<div class="card-footer text-right">
<a n:if="$user->isAllowed($user->getId(), 'SYS:EVE_DELETE')" href="{link eventDelete! $eventId}" class="btn btn-danger mx-2" title="{_common.delete}" type="button"><i class="far fa-trash-can" aria-hidden="true"></i></a>
<button n:name="save" n:if="$user->isAllowed($user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-lg btn-primary" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_DELETE')" href="{link eventDelete! $eventId}" class="btn btn-danger mx-2" title="{_common.delete}" type="button"><i class="far fa-trash-can" aria-hidden="true"></i></a>
<button n:name="save" n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_UPDATE')" class="btn btn-lg btn-primary" title="{_common.save}"><i class="fa fa-save" aria-hidden="true"></i></button>
</div>
</div>
{/form}
Expand Down
4 changes: 2 additions & 2 deletions app/module/setting/presenter/templates/Event/new.latte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{input resultRightName, class=> 'form-control form-control-sm'}
</td>
<td class="btn-group" role="group">
<button n:if="$user->isAllowed($user->getId(), 'SYS:EVE_CREATE')" class="btn btn-sm btn-outline-danger" title="{_common.delete}" onclick="removeRow(this)"><i class="far fa-trash-can" aria-hidden="true"></i></button>
<button n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_CREATE')" class="btn btn-sm btn-outline-danger" title="{_common.delete}" onclick="removeRow(this)"><i class="far fa-trash-can" aria-hidden="true"></i></button>
</td>
</tr>
</table>
Expand Down Expand Up @@ -111,7 +111,7 @@
</div>
</div>
<div class="card-footer text-right">
<button n:if="$user->isAllowed($user->getId(), 'SYS:EVE_CREATE')" n:name="save" class="btn btn-lg btn-primary">
<button n:if="$user->isAllowed((string) $user->getId(), 'SYS:EVE_CREATE')" n:name="save" class="btn btn-lg btn-primary">
<i class="fa fa-save" aria-hidden="true"></i>
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/module/setting/presenter/templates/Poll/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="card-body">
{include $componentsDir . '/tymy-table.latte'}
<div class="card-footer text-right">
<a n:if="$user->isAllowed($user->getId(), 'SYS:ASK.VOTE_UPDATE')" class="btn btn-lg btn-success" href="{plink :Setting:Poll:new}" onclick="btnRotate($(this), true)" title="{_poll.createPoll}" style="margin-right: 10px">
<a n:if="$user->isAllowed((string) $user->getId(), 'SYS:ASK.VOTE_UPDATE')" class="btn btn-lg btn-success" href="{plink :Setting:Poll:new}" onclick="btnRotate($(this), true)" title="{_poll.createPoll}" style="margin-right: 10px">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/module/setting/presenter/templates/Poll/new.latte
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</div>
<div class="card-footer text-right">
<a href="{plink :Setting:default:}" type="button" class="btn btn-danger mx-2" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></a>
<button n:if="$user->isAllowed($user->getId(), 'SYS:ASK.VOTE_UPDATE')" n:name="save" class="btn btn-lg btn-primary"><i class="fa fa-save" aria-hidden="true"></i></button>
<button n:if="$user->isAllowed((string) $user->getId(), 'SYS:ASK.VOTE_UPDATE')" n:name="save" class="btn btn-lg btn-primary"><i class="fa fa-save" aria-hidden="true"></i></button>
</div>
{/form}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/module/setting/presenter/templates/Poll/poll.latte
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
</div>
<div class="card-footer text-right">
<a href="{link pollDelete!}" type="button" class="btn btn-danger mx-2" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></a>
<button n:if="$user->isAllowed($user->getId(), 'SYS:ASK.VOTE_UPDATE')" n:name="save" class="btn btn-lg btn-primary"><i class="fa fa-save" aria-hidden="true"></i></button>
<button n:if="$user->isAllowed((string) $user->getId(), 'SYS:ASK.VOTE_UPDATE')" n:name="save" class="btn btn-lg btn-primary"><i class="fa fa-save" aria-hidden="true"></i></button>
</div>
{/form}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
{input "{$etid}_postStatusSet", class => 'form-control form-control-sm'}
</td>

<td n:if="$user->isAllowed($user->getId(), 'SYS:TEAM_UPDATE')" class="py-1">
<td n:if="$user->isAllowed((string) $user->getId(), 'SYS:TEAM_UPDATE')" class="py-1">
<a class="btn btn-sm btn-danger" href="{plink :Setting:Team:deleteType $etid}" title="{_common.delete}"><i class="far fa-trash-can" aria-hidden="true"></i></a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer text-right" n:if="$user->isAllowed($user->getId(), 'SYS:TEAM_UPDATE')">
<div class="card-footer text-right" n:if="$user->isAllowed((string) $user->getId(), 'SYS:TEAM_UPDATE')">
<a class="btn btn-lg mr-4 btn-outline-success" href="{plink :Setting:Team:newType}" onclick="btnRotate($(this), true)" title="{_common.new}" type="">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
Expand Down
Loading

0 comments on commit d955044

Please sign in to comment.