mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Add NSFW CW back
Co-authored-by: Celestine <34442450+rem-pai@users.noreply.github.com>
This commit is contained in:
parent
9132eb8d98
commit
fc9df5624b
8 changed files with 61 additions and 13 deletions
|
@ -59,7 +59,7 @@ class Post extends Postable
|
||||||
|
|
||||||
function isExplicit(): bool
|
function isExplicit(): bool
|
||||||
{
|
{
|
||||||
return ($this->getRecord()->flags & 0b00100000) > 0;
|
return (bool) $this->getRecord()->nsfw;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDeleted(): bool
|
function isDeleted(): bool
|
||||||
|
|
|
@ -26,6 +26,10 @@ class User extends RowModel
|
||||||
const PRIVACY_ONLY_REGISTERED = 2;
|
const PRIVACY_ONLY_REGISTERED = 2;
|
||||||
const PRIVACY_EVERYONE = 3;
|
const PRIVACY_EVERYONE = 3;
|
||||||
|
|
||||||
|
const NSFW_INTOLERANT = 0;
|
||||||
|
const NSFW_TOLERANT = 1;
|
||||||
|
const NSFW_FULL_TOLERANT = 2;
|
||||||
|
|
||||||
protected function _abstractRelationGenerator(string $filename, int $page = 1): \Traversable
|
protected function _abstractRelationGenerator(string $filename, int $page = 1): \Traversable
|
||||||
{
|
{
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
@ -99,7 +103,7 @@ class User extends RowModel
|
||||||
|
|
||||||
function getAvatarUrl(): string
|
function getAvatarUrl(): string
|
||||||
{
|
{
|
||||||
$url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . '/';
|
$url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'];
|
||||||
$url = explode('?', $url);
|
$url = explode('?', $url);
|
||||||
$serverUrl = $url[0];
|
$serverUrl = $url[0];
|
||||||
|
|
||||||
|
@ -424,6 +428,11 @@ class User extends RowModel
|
||||||
{
|
{
|
||||||
return $this->_abstractRelationCount("get-subscriptions-user");
|
return $this->_abstractRelationCount("get-subscriptions-user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUnreadMessagesCount(): int
|
||||||
|
{
|
||||||
|
return sizeof(DatabaseConnection::i()->getContext()->table("messages")->where(["recipient_id" => $this->getId(), "unread" => 1]));
|
||||||
|
}
|
||||||
|
|
||||||
function getClubs(int $page = 1): \Traversable
|
function getClubs(int $page = 1): \Traversable
|
||||||
{
|
{
|
||||||
|
@ -501,6 +510,11 @@ class User extends RowModel
|
||||||
return bin2hex($rand) . bin2hex(sodium_crypto_stream_xor((string) $this->getId(), $rand, $key));
|
return bin2hex($rand) . bin2hex(sodium_crypto_stream_xor((string) $this->getId(), $rand, $key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNsfwTolerance(): int
|
||||||
|
{
|
||||||
|
return $this->getRecord()->nsfw_tolerance;
|
||||||
|
}
|
||||||
|
|
||||||
function isFemale(): bool
|
function isFemale(): bool
|
||||||
{
|
{
|
||||||
return (bool) $this->getRecord()->sex;
|
return (bool) $this->getRecord()->sex;
|
||||||
|
@ -563,6 +577,11 @@ class User extends RowModel
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setNsfwTolerance(int $tolerance): void
|
||||||
|
{
|
||||||
|
$this->stateChanges("nsfw_tolerance", $tolerance);
|
||||||
|
}
|
||||||
|
|
||||||
function setPrivacySetting(string $id, int $status): void
|
function setPrivacySetting(string $id, int $status): void
|
||||||
{
|
{
|
||||||
$this->stateChanges("privacy", bmask($this->changes["privacy"] ?? $this->getRecord()->privacy, [
|
$this->stateChanges("privacy", bmask($this->changes["privacy"] ?? $this->getRecord()->privacy, [
|
||||||
|
|
|
@ -113,12 +113,12 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$user->setSex($this->postParam("gender"));
|
$user->setSex($this->postParam("gender"));
|
||||||
|
|
||||||
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
||||||
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["zadarma"]["enable"])
|
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"])
|
||||||
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
||||||
|
|
||||||
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
||||||
|
|
||||||
if(!Sms::send($this->postParam("phone"), "OPENVK | Your verification code is: $code"))
|
if(!Sms::send($this->postParam("phone"), "OPENVK - Your verification code is: $code"))
|
||||||
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
||||||
}
|
}
|
||||||
} elseif($_GET['act'] === "contacts") {
|
} elseif($_GET['act'] === "contacts") {
|
||||||
|
@ -266,6 +266,9 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
|
|
||||||
if (in_array($this->postParam("microblog"), [0, 1]))
|
if (in_array($this->postParam("microblog"), [0, 1]))
|
||||||
$user->setMicroblog((int) $this->postParam("microblog"));
|
$user->setMicroblog((int) $this->postParam("microblog"));
|
||||||
|
|
||||||
|
if(in_array($this->postParam("nsfw"), [0, 1, 2]))
|
||||||
|
$user->setNsfwTolerance((int) $this->postParam("nsfw"));
|
||||||
}elseif($_GET['act'] === "lMenu") {
|
}elseif($_GET['act'] === "lMenu") {
|
||||||
$settings = [
|
$settings = [
|
||||||
"menu_bildoj" => "photos",
|
"menu_bildoj" => "photos",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
namespace openvk\Web\Presenters;
|
namespace openvk\Web\Presenters;
|
||||||
use openvk\Web\Models\Entities\{Post, Photo, Club};
|
use openvk\Web\Models\Entities\{Post, Photo, Club, User};
|
||||||
use openvk\Web\Models\Entities\Notifications\{LikeNotification, RepostNotification, WallPostNotification};
|
use openvk\Web\Models\Entities\Notifications\{LikeNotification, RepostNotification, WallPostNotification};
|
||||||
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums};
|
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums};
|
||||||
use Chandler\Database\DatabaseConnection;
|
use Chandler\Database\DatabaseConnection;
|
||||||
|
@ -117,6 +117,9 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
->where("deleted", 0)
|
->where("deleted", 0)
|
||||||
->order("created DESC");
|
->order("created DESC");
|
||||||
|
|
||||||
|
if($this->user->identity->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||||
|
$posts = $posts->where("nsfw", false);
|
||||||
|
|
||||||
$this->template->_template = "Wall/Feed.xml";
|
$this->template->_template = "Wall/Feed.xml";
|
||||||
$this->template->globalFeed = true;
|
$this->template->globalFeed = true;
|
||||||
$this->template->paginatorConf = (object) [
|
$this->template->paginatorConf = (object) [
|
||||||
|
@ -175,8 +178,6 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$flags |= 0b10000000;
|
$flags |= 0b10000000;
|
||||||
if($this->postParam("force_sign") === "on")
|
if($this->postParam("force_sign") === "on")
|
||||||
$flags |= 0b01000000;
|
$flags |= 0b01000000;
|
||||||
if($this->postParam("nsfw") === "on")
|
|
||||||
$flags |= 0b00100000;
|
|
||||||
|
|
||||||
|
|
||||||
if($_FILES["_pic_attachment"]["error"] === UPLOAD_ERR_OK) {
|
if($_FILES["_pic_attachment"]["error"] === UPLOAD_ERR_OK) {
|
||||||
|
@ -201,6 +202,7 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$post->setCreated(time());
|
$post->setCreated(time());
|
||||||
$post->setContent($this->postParam("text"));
|
$post->setContent($this->postParam("text"));
|
||||||
$post->setFlags($flags);
|
$post->setFlags($flags);
|
||||||
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
$post->save();
|
$post->save();
|
||||||
$post->attach($photo);
|
$post->attach($photo);
|
||||||
} elseif($this->postParam("text")) {
|
} elseif($this->postParam("text")) {
|
||||||
|
@ -211,6 +213,7 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$post->setCreated(time());
|
$post->setCreated(time());
|
||||||
$post->setContent($this->postParam("text"));
|
$post->setContent($this->postParam("text"));
|
||||||
$post->setFlags($flags);
|
$post->setFlags($flags);
|
||||||
|
$post->setNsfw($this->postParam("nsfw") === "on");
|
||||||
$post->save();
|
$post->save();
|
||||||
} catch(\LogicException $ex) {
|
} catch(\LogicException $ex) {
|
||||||
$this->flashFail("err", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
$this->flashFail("err", "Не удалось опубликовать пост", "Пост пустой или слишком большой.");
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
{script "js/openvk.cls.js"}
|
{script "js/openvk.cls.js"}
|
||||||
|
|
||||||
{ifset $thisUser}
|
{ifset $thisUser}
|
||||||
|
{if $thisUser->getNsfwTolerance() < 2}
|
||||||
|
{css "css/nsfw-posts.css"}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{if !is_null($thisUser->getTheme())}
|
{if !is_null($thisUser->getTheme())}
|
||||||
{var theme = $thisUser->getTheme()}
|
{var theme = $thisUser->getTheme()}
|
||||||
{if $theme->inheritDefault()}
|
{if $theme->inheritDefault()}
|
||||||
|
@ -48,6 +52,8 @@
|
||||||
{else}
|
{else}
|
||||||
{css "css/style.css"}
|
{css "css/style.css"}
|
||||||
{css "css/dialog.css"}
|
{css "css/dialog.css"}
|
||||||
|
{css "css/nsfw-posts.css"}
|
||||||
|
|
||||||
{if $isXmas}
|
{if $isXmas}
|
||||||
{css "css/xmas.css"}
|
{css "css/xmas.css"}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -131,7 +137,14 @@
|
||||||
{/if}</a>
|
{/if}</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('photos')" href="/albums{$thisUser->getId()}" class="link">{_"my_photos"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('photos')" href="/albums{$thisUser->getId()}" class="link">{_"my_photos"}</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('videos')" href="/videos{$thisUser->getId()}" class="link">{_"my_videos"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('videos')" href="/videos{$thisUser->getId()}" class="link">{_"my_videos"}</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('messages')" href="/im" class="link">{_"my_messages"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('messages')" href="/im" class="link">{_"my_messages"}
|
||||||
|
{if $thisUser->getUnreadMessagesCount() > 0}
|
||||||
|
<object type="internal/link">
|
||||||
|
(<b>{$thisUser->getUnreadMessagesCount()}</b>)
|
||||||
|
</object>
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('notes')" href="/notes{$thisUser->getId()}" class="link">{_"my_notes"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('notes')" href="/notes{$thisUser->getId()}" class="link">{_"my_notes"}</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('groups')" href="/groups{$thisUser->getId()}" class="link">{_"my_groups"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('groups')" href="/groups{$thisUser->getId()}" class="link">{_"my_groups"}</a>
|
||||||
<a n:if="$thisUser->getLeftMenuItemStatus('news')" href="/feed" class="link">{_"my_feed"}</a>
|
<a n:if="$thisUser->getLeftMenuItemStatus('news')" href="/feed" class="link">{_"my_feed"}</a>
|
||||||
|
|
|
@ -314,6 +314,18 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="120" valign="top">
|
||||||
|
<span class="nobold">NSFW-контент</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name="nsfw">
|
||||||
|
<option value="0" {if $user->getNsfwTolerance() === 0}selected{/if}>Не показывать в глобальной ленте</option>
|
||||||
|
<option value="1" {if $user->getNsfwTolerance() === 1}selected{/if}>Только замазывать</option>
|
||||||
|
<option value="2" {if $user->getNsfwTolerance() === 2}selected{/if}>Показывать</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="120" valign="top">
|
<td width="120" valign="top">
|
||||||
<span class="nobold">Вид постов</span>
|
<span class="nobold">Вид постов</span>
|
||||||
|
|
|
@ -35,11 +35,9 @@
|
||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{*
|
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="nsfw" /> Содержит NSFW-контент
|
<input type="checkbox" name="nsfw" /> Содержит NSFW-контент
|
||||||
</label>
|
</label>
|
||||||
*}
|
|
||||||
</div>
|
</div>
|
||||||
<input type="file" name="_pic_attachment" accept="image/*" style="display:none;" />
|
<input type="file" name="_pic_attachment" accept="image/*" style="display:none;" />
|
||||||
<input type="hidden" name="type" value="1" />
|
<input type="hidden" name="type" value="1" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.post-nsfw .post-content img.media {
|
.post-nsfw .post-content img.media {
|
||||||
filter: saturate(0.8) blur(5px);
|
filter: saturate(0.8) blur(15px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-nsfw .post-content .attachment {
|
.post-nsfw .post-content .attachment {
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-nsfw .post-content .attachment:hover img.media {
|
.post-nsfw .post-content .attachment:active img.media {
|
||||||
filter: none;
|
filter: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@
|
||||||
content: attr(data-localized-nsfw-text);
|
content: attr(data-localized-nsfw-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-nsfw .post-content .attachment:hover::after {
|
.post-nsfw .post-content .attachment:active::after {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue