Skip to content

Commit

Permalink
Unsubscribe from events not possible if max member count reached #1482
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Sep 20, 2023
1 parent 287e4c0 commit 07b7e9d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions adm_program/system/classes/TableDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function clear()
* Check if it's possible for the current user to participate in this event.
* Therefore, we check if the user is allowed to participate and if the deadline of the event isn't exceeded.
* There should be no participants limit or the limit is not reached or the current user is already member
* of the event.
* of the event. If the user is already a member of the event, then this method will return true, if the
* deadline is not reached.
* @return bool Return true if it's possible for the current user to participate in the event.
*/
public function possibleToParticipate(): bool
Expand All @@ -105,11 +106,12 @@ public function possibleToParticipate(): bool
$this->mParticipants = new Participants($this->db, $this->getValue('dat_rol_id'));
}

if ($this->allowedToParticipate() || $this->mParticipants->isMemberOfEvent($gCurrentUserId)) {
if ((int) $this->getValue('dat_max_members') === 0
|| ($this->mParticipants->getCount() < (int) $this->getValue('dat_max_members'))) {
return true;
}
if ($this->mParticipants->isMemberOfEvent($gCurrentUserId)) {
return true;
} elseif ($this->allowedToParticipate()
&& ((int) $this->getValue('dat_max_members') === 0
|| $this->mParticipants->getCount() < (int) $this->getValue('dat_max_members'))) {
return true;
}
}

Expand Down

0 comments on commit 07b7e9d

Please sign in to comment.