Groups: Transfer community permissions to another user

Groups: Transfer community permissions to another user

(Issue #302 )
This commit is contained in:
n1rwana 2021-12-15 17:32:28 +03:00
parent bc832ece64
commit 17937432bc
5 changed files with 30 additions and 0 deletions

View file

@ -269,4 +269,20 @@ final class GroupPresenter extends OpenVKPresenter
$this->notFound(); $this->notFound();
} }
} }
function renderChangeOwner(int $id, int $newOwnerID): void
{
$this->assertUserLoggedIn();
$this->willExecuteWriteAction();
$club = $this->clubs->get($id);
$newOwner = (new Users)->get($newOwnerID);
if($this->user->id !== $club->getOwner()->getId())
$this->flashFail("err", tr("error"), tr("forbidden"));
$club->setOwner($newOwnerID);
$club->save();
$this->flashFail("succ", tr("information_-1"), tr("group_owner_setted", $newOwner->getCanonicalName(), $club->getName()));
}
} }

View file

@ -91,6 +91,12 @@
{_promote_to_admin} {_promote_to_admin}
{/if} {/if}
</a> </a>
{if $club->getOwner()->getId() != $user->getId() && $manager && $thisUser->getId() == $club->getOwner()->getId()}
|
<a href="/groups/{$club->getId()}/setNewOwner/{$user->getId()}">
{_promote_to_owner}
</a>
{/if}
{if $manager} {if $manager}
| |
<a href="javascript:setClubAdminComment('{$club->getId()}', '{$manager->getUserId()}', '{rawurlencode($csrfToken)}')"> <a href="javascript:setClubAdminComment('{$club->getId()}', '{$manager->getUserId()}', '{rawurlencode($csrfToken)}')">

View file

@ -73,6 +73,8 @@ routes:
handler: "Group->attend" handler: "Group->attend"
- url: "/al_comments.pl/create/{text}/{num}" - url: "/al_comments.pl/create/{text}/{num}"
handler: "Comment->makeComment" handler: "Comment->makeComment"
- url: "/groups/{num}/setNewOwner/{num}"
handler: "Group->changeOwner"
- url: "/comment{num}/like" - url: "/comment{num}/like"
handler: "Comment->like" handler: "Comment->like"
- url: "/comment{num}/delete" - url: "/comment{num}/delete"

View file

@ -229,6 +229,7 @@
"role" = "Role"; "role" = "Role";
"administrator" = "Administrator"; "administrator" = "Administrator";
"promote_to_admin" = "Promote to admin"; "promote_to_admin" = "Promote to admin";
"promote_to_owner" = "Promote to owner";
"devote" = "Devote"; "devote" = "Devote";
"set_comment" = "Set comment"; "set_comment" = "Set comment";
"hidden_yes" = "Hidden: Yes"; "hidden_yes" = "Hidden: Yes";
@ -240,6 +241,8 @@
"group_display_all_administrators" = "Display all administrators"; "group_display_all_administrators" = "Display all administrators";
"group_dont_display_administrators_list" = "Display nothing"; "group_dont_display_administrators_list" = "Display nothing";
"group_owner_setted" = "New owner ($1) has been successfully assigned to community $2. If you want to return the community, please contact the technical support of the site.";
"participants_zero" = "No participants"; "participants_zero" = "No participants";
"participants_one" = "$1 participant"; "participants_one" = "$1 participant";
"participants_other" = "$1 participant"; "participants_other" = "$1 participant";

View file

@ -239,6 +239,7 @@
"role" = "Роль"; "role" = "Роль";
"administrator" = "Администратор"; "administrator" = "Администратор";
"promote_to_admin" = "Повысить до администратора"; "promote_to_admin" = "Повысить до администратора";
"promote_to_owner" = "Назначить владельцем";
"devote" = "Разжаловать"; "devote" = "Разжаловать";
"set_comment" = "Изменить комментарий"; "set_comment" = "Изменить комментарий";
"hidden_yes" = "Скрыт: Да"; "hidden_yes" = "Скрыт: Да";
@ -250,6 +251,8 @@
"group_display_all_administrators" = "Отображать всех администраторов"; "group_display_all_administrators" = "Отображать всех администраторов";
"group_dont_display_administrators_list" = "Ничего не отображать"; "group_dont_display_administrators_list" = "Ничего не отображать";
"group_owner_setted" = "Новый владелец ($1) успешно назначен в сообщество $2. Если Вы хотите вернуть сообщество, обратитесь в техническую поддержку сайта.";
"participants_zero" = "Ни одного участника"; "participants_zero" = "Ни одного участника";
"participants_one" = "Один участник"; "participants_one" = "Один участник";
"participants_few" = "$1 участника"; "participants_few" = "$1 участника";