Skip to content

Commit

Permalink
Fix re-adding to Chandler-group (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1rwana authored Nov 14, 2023
1 parent 71c5902 commit dcf3631
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Web/Models/Repositories/ChandlerGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ function getPermissionsById(string $UUID): \Traversable
{
foreach($this->perms->where("group", $UUID) as $perm) yield $perm;
}

function isUserAMember(string $GID, string $UID): bool
{
return ($this->context->query("SELECT * FROM `ChandlerACLRelations` WHERE `group` = ? AND `user` = ?", $GID, $UID)) !== NULL;
}
}
6 changes: 4 additions & 2 deletions Web/Presenters/AdminPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ function renderUser(int $id): void
if($user->onlineStatus() != $this->postParam("online")) $user->setOnline(intval($this->postParam("online")));
$user->setVerified(empty($this->postParam("verify") ? 0 : 1));
if($this->postParam("add-to-group")) {
$query = "INSERT INTO `ChandlerACLRelations` (`user`, `group`) VALUES ('" . $user->getChandlerGUID() . "', '" . $this->postParam("add-to-group") . "')";
DatabaseConnection::i()->getConnection()->query($query);
if (!(new ChandlerGroups)->isUserAMember($user->getChandlerGUID(), $this->postParam("add-to-group"))) {
$query = "INSERT INTO `ChandlerACLRelations` (`user`, `group`) VALUES ('" . $user->getChandlerGUID() . "', '" . $this->postParam("add-to-group") . "')";
DatabaseConnection::i()->getConnection()->query($query);
}
}
if($this->postParam("password")) {
$user->getChandlerUser()->updatePassword($this->postParam("password"));
Expand Down

0 comments on commit dcf3631

Please sign in to comment.