Fixup "Groups: Transfer community permissions to another user (#348)"

Didn't notice these problems during the code review :3
This commit is contained in:
Maxim Leshchenko 2021-12-16 21:23:28 +02:00
parent 1d5a599734
commit 846510ef93
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
2 changed files with 20 additions and 8 deletions

View file

@ -291,7 +291,18 @@ final class GroupPresenter extends OpenVKPresenter
$this->flashFail("err", tr("error"), tr("forbidden")); $this->flashFail("err", tr("error"), tr("forbidden"));
$club->setOwner($newOwnerId); $club->setOwner($newOwnerId);
$club->addManager($this->user->id);
$club->addManager($this->user->identity);
$oldOwnerManager = $club->getManager($this->user->identity);
$oldOwnerManager->setHidden($club->isOwnerHidden());
$oldOwnerManager->setComment($club->getOwnerComment());
$oldOwnerManager->save();
$newOwnerManager = $club->getManager($newOwner);
$club->setOwner_Hidden($newOwnerManager->isHidden());
$club->setOwner_Comment($newOwnerManager->getComment());
$club->removeManager($newOwner);
$club->save(); $club->save();
$this->flashFail("succ", tr("information_-1"), tr("group_owner_setted", $newOwner->getCanonicalName(), $club->getName())); $this->flashFail("succ", tr("information_-1"), tr("group_owner_setted", $newOwner->getCanonicalName(), $club->getName()));

View file

@ -123,21 +123,22 @@
</tbody> </tbody>
</table> </table>
<script> <script n:if="$club->getOwner()->getId() != $user->getId() && $manager && $thisUser->getId() == $club->getOwner()->getId()">
console.log("gayshit")
function changeOwner(club, newOwner) { function changeOwner(club, newOwner) {
let action = "/groups/" + club + "/setNewOwner/" + newOwner; const action = "/groups/" + club + "/setNewOwner/" + newOwner;
MessageBox(tr("group_changeowner_modal_title"), ` MessageBox({_group_changeowner_modal_title}, `
tr("group_changeowner_modal_text", {$user->getFullName()}) {tr("group_changeowner_modal_text", htmlentities($user->getFullName()))|noescape}
<br/><br/> <br/><br/>
<form id="transfer-owner-permissions-form" method="post"> <form id="transfer-owner-permissions-form" method="post">
<label for="password">tr("password")</label> <label for="password">{_password|noescape}</label>
<input type="password" id="password" name="password" required /> <input type="password" id="password" name="password" required />
<input type="hidden" name="hash" value={$csrfToken} /> <input type="hidden" name="hash" value={$csrfToken} />
</form> </form>
`, [tr("transfer"), tr("cancel")], [ `, [{_transfer}, {_cancel}], [
() => { () => {
$('#transfer-owner-permissions-form').attr('action', action); $("#transfer-owner-permissions-form").attr("action", action);
document.querySelector("#transfer-owner-permissions-form").submit(); document.querySelector("#transfer-owner-permissions-form").submit();
}, Function.noop }, Function.noop
]); ]);