Фикс повторного добавления в Chandler-группу

This commit is contained in:
n1rwana 2023-07-31 22:41:57 +03:00
parent a2384cc231
commit 2914b249bc
2 changed files with 9 additions and 2 deletions

View file

@ -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;
}
}

View file

@ -83,8 +83,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"));