mirror of
https://github.com/openvk/openvk
synced 2025-07-07 08:19:49 +03:00
+
This commit is contained in:
parent
17937432bc
commit
1d52381654
4 changed files with 32 additions and 4 deletions
|
@ -3,7 +3,7 @@ namespace openvk\Web\Presenters;
|
|||
use openvk\Web\Models\Entities\{Club, Photo};
|
||||
use openvk\Web\Models\Entities\Notifications\ClubModeratorNotification;
|
||||
use openvk\Web\Models\Repositories\{Clubs, Users, Albums, Managers};
|
||||
|
||||
use Chandler\Security\Authenticator;
|
||||
final class GroupPresenter extends OpenVKPresenter
|
||||
{
|
||||
private $clubs;
|
||||
|
@ -275,12 +275,19 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] !== "POST")
|
||||
$this->redirect("/groups".$this->user->id);
|
||||
|
||||
if(!Authenticator::verifyHash($this->postParam("password"), $this->user->identity->getChandlerUser()->getRaw()->passwordHash))
|
||||
$this->flashFail("err", tr("error"), tr("incorrect_password"));
|
||||
|
||||
$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->addManager($this->user->id);
|
||||
$club->save();
|
||||
|
||||
$this->flashFail("succ", tr("information_-1"), tr("group_owner_setted", $newOwner->getCanonicalName(), $club->getName()));
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
</a>
|
||||
{if $club->getOwner()->getId() != $user->getId() && $manager && $thisUser->getId() == $club->getOwner()->getId()}
|
||||
|
|
||||
<a href="/groups/{$club->getId()}/setNewOwner/{$user->getId()}">
|
||||
<a href="javascript:changeOwner({$club->getId()}, {$user->getId()})">
|
||||
{_promote_to_owner}
|
||||
</a>
|
||||
{/if}
|
||||
|
@ -122,4 +122,25 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function changeOwner(club, newOwner) {
|
||||
let action = "/groups/" + club + "/setNewOwner/" + newOwner;
|
||||
|
||||
MessageBox("Передача прав владельца", `
|
||||
Внимание! Вы передаёте права владельца пользователю {$user->getFullName()}. После передачи Вы получите роль администратора в сообществе.
|
||||
<br/><br/>
|
||||
<form id="transfer-owner-permissions-form" method="post">
|
||||
<label for="password">Пароль</label>
|
||||
<input type="password" id="password" name="password" required />
|
||||
<input type="hidden" name="hash" value={$csrfToken} />
|
||||
</form>
|
||||
`, ["Передать", "Отмена"], [
|
||||
() => {
|
||||
$('#transfer-owner-permissions-form').attr('action', action);
|
||||
document.querySelector("#transfer-owner-permissions-form").submit();
|
||||
}, Function.noop
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
|
|
@ -241,7 +241,7 @@
|
|||
"group_display_all_administrators" = "Display all administrators";
|
||||
"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.";
|
||||
"group_owner_setted" = "The new owner ($1) has been successfully assigned to the community $2. You have been granted administrator rights in the community. If you want to return the owner role, contact <a href='/support?act=new'>site technical support</a>.";
|
||||
|
||||
"participants_zero" = "No participants";
|
||||
"participants_one" = "$1 participant";
|
||||
|
|
|
@ -251,7 +251,7 @@
|
|||
"group_display_all_administrators" = "Отображать всех администраторов";
|
||||
"group_dont_display_administrators_list" = "Ничего не отображать";
|
||||
|
||||
"group_owner_setted" = "Новый владелец ($1) успешно назначен в сообщество $2. Если Вы хотите вернуть сообщество, обратитесь в техническую поддержку сайта.";
|
||||
"group_owner_setted" = "Новый владелец ($1) успешно назначен в сообщество $2. Вам выданы права администратора в сообществе. Если Вы хотите вернуть роль владельца, обратитесь в <a href='/support?act=new'>техническую поддержку сайта</a>.";
|
||||
|
||||
"participants_zero" = "Ни одного участника";
|
||||
"participants_one" = "Один участник";
|
||||
|
|
Loading…
Reference in a new issue