mirror of
https://github.com/openvk/openvk
synced 2025-07-07 00:09:48 +03:00
Merge 9aa7edb12d
into 245f8690c6
This commit is contained in:
commit
3ddfb4c28d
12 changed files with 46 additions and 4 deletions
|
@ -401,6 +401,11 @@ class Club extends RowModel
|
|||
return (object) $res;
|
||||
}
|
||||
|
||||
function isAnonCommentsAllowed(): bool
|
||||
{
|
||||
return (bool) $this->getRecord()->allow_anon_comments;
|
||||
}
|
||||
|
||||
use Traits\TBackDrops;
|
||||
use Traits\TSubscribable;
|
||||
}
|
||||
|
|
|
@ -1237,6 +1237,11 @@ class User extends RowModel
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function isAnonCommentsAllowed(): bool
|
||||
{
|
||||
return (bool) $this->getRecord()->allow_anon_comments;
|
||||
}
|
||||
|
||||
use Traits\TBackDrops;
|
||||
use Traits\TSubscribable;
|
||||
|
|
|
@ -57,6 +57,8 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
if($_FILES["_vid_attachment"] && OPENVK_ROOT_CONF['openvk']['preferences']['videos']['disableUploading'])
|
||||
$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" && $entity->getWallOwner()->isAnonCommentsAllowed();
|
||||
|
||||
$flags = 0;
|
||||
if($this->postParam("as_group") === "on" && !is_null($club) && $club->canBeModifiedBy($this->user->identity))
|
||||
$flags |= 0b10000000;
|
||||
|
@ -98,9 +100,10 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
$comment->setModel(get_class($entity));
|
||||
$comment->setTarget($entity->getId());
|
||||
$comment->setContent($this->postParam("text"));
|
||||
$comment->setAnonymous($anon);
|
||||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$comment->save();
|
||||
$comment->save();
|
||||
} catch (\LengthException $ex) {
|
||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий слишком большой.");
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
$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->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") ?? "";
|
||||
if(empty($website))
|
||||
|
|
|
@ -418,6 +418,8 @@ final class UserPresenter extends OpenVKPresenter
|
|||
|
||||
if(!$user->setShortCode(empty($this->postParam("sc")) ? NULL : $this->postParam("sc")))
|
||||
$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") {
|
||||
$settings = [
|
||||
"page.read",
|
||||
|
|
|
@ -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>
|
||||
</td>
|
||||
</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>
|
||||
<td>
|
||||
|
||||
|
|
|
@ -101,6 +101,15 @@
|
|||
<input type="text" name="sc" value="{$user->getShortCode()}" style="width: 100%;" />
|
||||
</td>
|
||||
</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>
|
||||
<td>
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
<div n:ifset="$thisUser" id="standaloneCommentBox">
|
||||
{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 $oObj = $parent->getWallOwner()}
|
||||
{if !$readOnly}
|
||||
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club}
|
||||
{include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, isComment => true, oObj => $oObj}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
<div class="post-has-note">
|
||||
|
||||
</div>
|
||||
{var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable'] && $oObj->isAnonCommentsAllowed()}
|
||||
<div n:if="$postOpts ?? true" class="post-opts">
|
||||
{var $anonEnabled = OPENVK_ROOT_CONF['openvk']['preferences']['wall']['anonymousPosting']['enable']}
|
||||
{if !is_null($thisUser) && !is_null($club ?? NULL) && $owner < 0}
|
||||
{if $club->canBeModifiedBy($thisUser)}
|
||||
<script>
|
||||
|
@ -49,6 +49,10 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<label n:if="$isComment && $anonEnabled" id="octoberAnonOpt">
|
||||
<input type="checkbox" name="anon" /> {_as_anonymous}
|
||||
</label>
|
||||
|
||||
<div n:if="!($postOpts ?? true) && !is_null($thisUser) && !is_null($club ?? NULL) && $club->canBeModifiedBy($thisUser)" class="post-opts">
|
||||
<label>
|
||||
<input type="checkbox" name="as_group" /> {_comment_as_group}
|
||||
|
|
2
install/sqls/00038-anonymous-comments-toggles.sql
Normal file
2
install/sqls/00038-anonymous-comments-toggles.sql
Normal 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`;
|
|
@ -214,6 +214,8 @@
|
|||
|
||||
"reply" = "Reply";
|
||||
|
||||
"allow_anon_comments" = "Allow anonymous comments";
|
||||
|
||||
/* Friends */
|
||||
|
||||
"friends" = "Friends";
|
||||
|
|
|
@ -191,6 +191,7 @@
|
|||
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
|
||||
"graffiti" = "Граффити";
|
||||
"reply" = "Ответить";
|
||||
"allow_anon_comments" = "Разрешить анонимные комментарии";
|
||||
|
||||
/* Friends */
|
||||
|
||||
|
|
Loading…
Reference in a new issue