Переключение в настройках профиля/группы

This commit is contained in:
n1rwana 2023-07-23 16:09:09 +03:00
parent 13a3e0f169
commit 9aa7edb12d
12 changed files with 39 additions and 4 deletions

View file

@ -389,6 +389,11 @@ class Club extends RowModel
return (object) $res; return (object) $res;
} }
function isAnonCommentsAllowed(): bool
{
return (bool) $this->getRecord()->allow_anon_comments;
}
use Traits\TBackDrops; use Traits\TBackDrops;
use Traits\TSubscribable; use Traits\TSubscribable;
} }

View file

@ -1127,6 +1127,11 @@ class User extends RowModel
return $res; return $res;
} }
function isAnonCommentsAllowed(): bool
{
return (bool) $this->getRecord()->allow_anon_comments;
}
use Traits\TBackDrops; use Traits\TBackDrops;
use Traits\TSubscribable; use Traits\TSubscribable;
} }

View file

@ -51,7 +51,7 @@ final class CommentPresenter extends OpenVKPresenter
if($_FILES["_vid_attachment"] && OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading']) if($_FILES["_vid_attachment"] && OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading'])
$this->flashFail("err", tr("error"), "Video uploads are disabled by the system administrator."); $this->flashFail("err", tr("error"), "Video uploads are disabled by the system administrator.");
$anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"] && $this->postParam("anon") === "on"; $anon = OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"] && $this->postParam("anon") === "on" && $entity->getWallOwner()->isAnonCommentsAllowed();
$flags = 0; $flags = 0;
if($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity)) if($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity))

View file

@ -208,6 +208,7 @@ final class GroupPresenter extends OpenVKPresenter
$club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1); $club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1);
$club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1); $club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1);
$club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed")) ? 0 : 1); $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed")) ? 0 : 1);
$club->setAllow_Anon_Comments(empty($this->postParam("allow_anon_comments")) ? 0 : 1);
$website = $this->postParam("website") ?? ""; $website = $this->postParam("website") ?? "";
if(empty($website)) if(empty($website))

View file

@ -418,6 +418,8 @@ final class UserPresenter extends OpenVKPresenter
if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc"))) if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc")))
$this->flashFail("err", tr("error"), tr("error_shorturl_incorrect")); $this->flashFail("err", tr("error"), tr("error_shorturl_incorrect"));
$user->setAllow_Anon_Comments(empty($this->postParam("allow_anon_comments")) ? 0 : 1);
} else if($_GET['act'] === "privacy") { } else if($_GET['act'] === "privacy") {
$settings = [ $settings = [
"page.read", "page.read",

View file

@ -101,7 +101,14 @@
<input type="radio" name="administrators_list_display" value="2" n:attr="checked => $club->getAdministratorsListDisplay() == 2" /> {_group_dont_display_administrators_list}<br> <input type="radio" name="administrators_list_display" value="2" n:attr="checked => $club->getAdministratorsListDisplay() == 2" /> {_group_dont_display_administrators_list}<br>
</td> </td>
</tr> </tr>
<tr>
<td width="120" valign="top" align="right">
<input n:attr="checked => $club->isAnonCommentsAllowed()" type="checkbox" name="allow_anon_comments">
</td>
<td>
{_allow_anon_comments}
</td>
</tr>
<tr> <tr>
<td> <td>

View file

@ -101,6 +101,15 @@
<input type="text" name="sc" value="{$user->getShortCode()}" style="width: 100%;" /> <input type="text" name="sc" value="{$user->getShortCode()}" style="width: 100%;" />
</td> </td>
</tr> </tr>
<br/>
<tr>
<td width="120" valign="top" align="right">
<input n:attr="checked => $user->isAnonCommentsAllowed()" type="checkbox" name="allow_anon_comments">
</td>
<td>
{_allow_anon_comments}
</td>
</tr>
<tr> <tr>
<td> <td>

View file

@ -3,8 +3,9 @@
<div n:ifset="$thisUser" id="standaloneCommentBox"> <div n:ifset="$thisUser" id="standaloneCommentBox">
{var $commentsURL = "/al_comments/create/$model/" . $parent->getId()} {var $commentsURL = "/al_comments/create/$model/" . $parent->getId()}
{var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club} {var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club}
{var $oObj = $parent->getWallOwner()}
{if !$readOnly} {if !$readOnly}
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true} {include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true, oObj => $oObj}
{/if} {/if}
</div> </div>

View file

@ -17,7 +17,7 @@
<div class="post-has-note"> <div class="post-has-note">
</div> </div>
{var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable']} {var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable'] && $oObj->isAnonCommentsAllowed()}
<div n:if="$postOpts ?? true" class="post-opts"> <div n:if="$postOpts ?? true" class="post-opts">
{if !is_null($thisUser) && !is_null($club ?? NULL) && $owner < 0} {if !is_null($thisUser) && !is_null($club ?? NULL) && $owner < 0}
{if $club->canBeModifiedBy($thisUser)} {if $club->canBeModifiedBy($thisUser)}

View file

@ -0,0 +1,2 @@
ALTER TABLE `profiles` ADD `allow_anon_comments` BOOLEAN NULL DEFAULT NULL AFTER `client_name`;
ALTER TABLE `groups` ADD `allow_anon_comments` BOOLEAN NULL DEFAULT NULL AFTER `backdrop_2`;

View file

@ -214,6 +214,8 @@
"reply" = "Reply"; "reply" = "Reply";
"allow_anon_comments" = "Allow anonymous comments";
/* Friends */ /* Friends */
"friends" = "Friends"; "friends" = "Friends";

View file

@ -191,6 +191,7 @@
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK."; "version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
"graffiti" = "Граффити"; "graffiti" = "Граффити";
"reply" = "Ответить"; "reply" = "Ответить";
"allow_anon_comments" = "Разрешить анонимные комментарии";
/* Friends */ /* Friends */