Fix re-adding to Chandler-group (#938)

This commit is contained in:
n1rwana 2023-11-14 22:57:49 +03:00 committed by GitHub
parent 71c59023cf
commit dcf3631d89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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; 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

@ -110,9 +110,11 @@ final class AdminPresenter extends OpenVKPresenter
if($user->onlineStatus() != $this->postParam("online")) $user->setOnline(intval($this->postParam("online"))); if($user->onlineStatus() != $this->postParam("online")) $user->setOnline(intval($this->postParam("online")));
$user->setVerified(empty($this->postParam("verify") ? 0 : 1)); $user->setVerified(empty($this->postParam("verify") ? 0 : 1));
if($this->postParam("add-to-group")) { if($this->postParam("add-to-group")) {
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") . "')"; $query = "INSERT INTO `ChandlerACLRelations` (`user`, `group`) VALUES ('" . $user->getChandlerGUID() . "', '" . $this->postParam("add-to-group") . "')";
DatabaseConnection::i()->getConnection()->query($query); DatabaseConnection::i()->getConnection()->query($query);
} }
}
if($this->postParam("password")) { if($this->postParam("password")) {
$user->getChandlerUser()->updatePassword($this->postParam("password")); $user->getChandlerUser()->updatePassword($this->postParam("password"));
} }