diff --git a/Web/Models/Repositories/ChandlerGroups.php b/Web/Models/Repositories/ChandlerGroups.php index 45af2a62..30b706e2 100644 --- a/Web/Models/Repositories/ChandlerGroups.php +++ b/Web/Models/Repositories/ChandlerGroups.php @@ -45,4 +45,9 @@ class ChandlerGroups { 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; + } } diff --git a/Web/Presenters/AdminPresenter.php b/Web/Presenters/AdminPresenter.php index 658d2f4b..3d864e56 100644 --- a/Web/Presenters/AdminPresenter.php +++ b/Web/Presenters/AdminPresenter.php @@ -110,8 +110,10 @@ final class AdminPresenter extends OpenVKPresenter 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"));