diff --git a/Web/Models/Entities/Post.php b/Web/Models/Entities/Post.php index dacced18..30c6eac3 100644 --- a/Web/Models/Entities/Post.php +++ b/Web/Models/Entities/Post.php @@ -301,7 +301,7 @@ class Post extends Postable { $liked = parent::toggleLike($user); - if($this->getOwner(false)->getId() !== $user->getId() && !($this->getOwner() instanceof Club) && !$this instanceof Comment) + if(!$user->isPrivateLikes() && $this->getOwner(false)->getId() !== $user->getId() && !($this->getOwner() instanceof Club) && !$this instanceof Comment) (new LikeNotification($this->getOwner(false), $this, $user))->emit(); foreach($this->getChildren() as $attachment) @@ -383,34 +383,70 @@ class Post extends Postable { $domain = ovk_scheme(true).$_SERVER["HTTP_HOST"]; $description = $this->getText(false); + $title = str_replace("\n", "", ovk_proc_strtr($description, 79)); $description_html = $description; $url = $domain."/wall".$this->getPrettyId(); + if($this->isUpdateAvatarMessage()) + $title = tr('upd_in_general'); + if($this->isDeactivationMessage()) + $title = tr('post_deact_in_general'); + $author = $this->getOwner(); - $author_name = htmlspecialchars($author->getCanonicalName(), ENT_DISALLOWED | ENT_XHTML); + $target_wall = $this->getWallOwner(); + $author_name = escape_html($author->getCanonicalName()); if($this->isExplicit()) - $description_html .= "
".tr('contains_nsfw').".
"; + $title = 'NSFW: ' . $title; foreach($this->getChildren() as $child) { if($child instanceof Photo) { $child_page = $domain.$child->getPageURL(); - $child_url = $child->getURLBySizeId('large'); - $description_html .= "
"; + $child_url = $child->getURL(); + $description_html .= "

"; } elseif($child instanceof Video) { $child_page = $domain.'/video'.$child->getPrettyId(); - $description_html .= "
Video"; + + if($child->getType() != 1) { + $description_html .= "". + "
". + "
". + "".escape_html($child->getName())."
"; + } else { + $description_html .= "". + "
". + "getVideoDriver()->getURL()."\">".escape_html($child->getName())."
"; + } } elseif($child instanceof Audio) { - $description_html .= "
Audio"; + if(!$child->isWithdrawn()) { + $description_html .= "
" + ."".escape_html($child->getName()).":" + ."
" + ."" + ."
"; + } + } elseif($child instanceof Poll) { + $description_html .= "
".tr('poll').": ".escape_html($child->getTitle()); + } elseif($child instanceof Note) { + $description_html .= "
".tr('note').": ".escape_html($child->getName()); } } $description_html .= "
".tr('author').": " . $author_name . ""; - if($this->hasSource()) { - $description_html .= "
".tr('source').": ".htmlspecialchars($this->getSource(), ENT_DISALLOWED | ENT_XHTML); + + if($target_wall->getRealId() != $author->getRealId()) + $description_html .= "
".tr('on_wall').": " . escape_html($target_wall->getCanonicalName()) . ""; + + if($this->isSigned()) { + $signer = $this->getOwner(false); + $description_html .= "
".tr('sign_short').": " . escape_html($signer->getCanonicalName()) . ""; } + if($this->hasSource()) + $description_html .= "
".tr('source').": ".escape_html($this->getSource()); + $item = new \Bhaktaraz\RSSGenerator\Item(); - $item->title(str_replace("\n", "", ovk_proc_strtr($description, 79))) + $item->title($title) ->url($url) ->guid($url) ->creator($author_name) diff --git a/Web/Models/Entities/Postable.php b/Web/Models/Entities/Postable.php index 55e1adf7..fc6cb8ca 100644 --- a/Web/Models/Entities/Postable.php +++ b/Web/Models/Entities/Postable.php @@ -97,8 +97,14 @@ abstract class Postable extends Attachable "target" => $this->getRecord()->id, ])->page($page, $perPage); - foreach($sel as $like) - yield (new Users)->get($like->origin); + foreach($sel as $like) { + $user = (new Users)->get($like->origin); + if($user->isPrivateLikes() && OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["enable"]) { + $user = (new Users)->get((int) OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["anonymousPosting"]["account"]); + } + + yield $user; + } } function isAnonymous(): bool diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 1e17dd82..a0574f3d 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -498,6 +498,7 @@ class User extends RowModel "wall.write", "messages.write", "audios.read", + "likes.read", ], ])->get($id); } @@ -1062,6 +1063,7 @@ class User extends RowModel "wall.write", "messages.write", "audios.read", + "likes.read", ], ])->set($id, $status)->toInteger()); } @@ -1338,6 +1340,11 @@ class User extends RowModel return $this->getId(); } + function isPrivateLikes(): bool + { + return $this->getPrivacySetting("likes.read") == User::PRIVACY_NO_ONE; + } + function toVkApiStruct(?User $user = NULL, string $fields = ''): object { $res = (object) []; diff --git a/Web/Models/Repositories/Posts.php b/Web/Models/Repositories/Posts.php index da1f9c8d..f5fef282 100644 --- a/Web/Models/Repositories/Posts.php +++ b/Web/Models/Repositories/Posts.php @@ -53,9 +53,9 @@ class Posts $offset--; } } - } /*else if(!is_null($offset)) { + } else if(!is_null($offset) && $pinPost) { $offset--; - }*/ + } $sel = $this->posts->where([ "wall" => $user, diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index b64823fb..4c6bb0dd 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -503,6 +503,7 @@ final class UserPresenter extends OpenVKPresenter "wall.write", "messages.write", "audios.read", + "likes.read", ]; foreach($settings as $setting) { $input = $this->postParam(str_replace(".", "_", $setting)); diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index d34993e8..244c52c4 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -395,6 +395,17 @@ + + + {_privacy_setting_see_likes} + + + + + {_profile_type} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index c9a5cf7f..bbb92e39 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -3784,12 +3784,16 @@ hr { overflow-x: hidden; } +.like_tooltip_wrapper { + box-shadow: 0px 2px 6px -5px rgba(0, 0, 0, 0.8); +} + .like_tooltip_wrapper .like_tooltip_head { background: linear-gradient(180deg, #595959, #515151); box-shadow: 0px 1px 0px 0px rgba(255, 255, 255, 0.18) inset; border: solid 1px #575757; padding: 4px 10px; - width: 200px; + width: 180px; display: flex; justify-content: space-between; align-items: center; diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 5a6e40f3..1a93898e 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -886,7 +886,7 @@ async function __uploadToTextarea(file, textareaNode) { if(filetype == 'photo') { const temp_url = URL.createObjectURL(file) const rand = random_int(0, 1000) - textareaNode.find('.post-horizontal').append(``) + textareaNode.find('.post-horizontal').append(``) const res = await fetch(`/photos/upload`, { method: 'POST', diff --git a/bootstrap.php b/bootstrap.php index f4d8958e..e964af81 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -366,6 +366,11 @@ function check_copyright_link(string $link = ''): bool return true; } +function escape_html(string $unsafe): string +{ + return htmlspecialchars($unsafe, ENT_DISALLOWED | ENT_XHTML); +} + return (function() { _ovk_check_environment(); require __DIR__ . "/vendor/autoload.php"; diff --git a/locales/en.strings b/locales/en.strings index 527323da..5789074f 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -698,6 +698,7 @@ "privacy_setting_write_wall" = "Who can publish posts on my wall"; "privacy_setting_write_messages" = "Who can write messages to me"; "privacy_setting_view_audio" = "Who can see my audios"; +"privacy_setting_see_likes" = "Who can see my likes"; "privacy_value_anybody" = "Anybody"; "privacy_value_anybody_dative" = "Anybody"; "privacy_value_users" = "OpenVK users"; @@ -2236,3 +2237,10 @@ "roll_back" = "rollback"; "roll_backed" = "rollbacked"; + +/* RSS */ + +"post_deact_in_general" = "Page deletion"; +"upd_in_general" = "Avatar update"; +"on_wall" = "On wall"; +"sign_short" = "Sign"; diff --git a/locales/ru.strings b/locales/ru.strings index 4385b6cd..c06e7cde 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -671,6 +671,7 @@ "privacy_setting_write_wall" = "Кто может писать у меня на стене"; "privacy_setting_write_messages" = "Кто может писать мне сообщения"; "privacy_setting_view_audio" = "Кому видно мои аудиозаписи"; +"privacy_setting_see_likes" = "Кому видны мои лайки"; "privacy_value_anybody" = "Все желающие"; "privacy_value_anybody_dative" = "Всем желающим"; "privacy_value_users" = "Пользователям OpenVK"; @@ -2127,3 +2128,9 @@ "roll_back" = "откатить"; "roll_backed" = "откачено"; +/* RSS */ + +"post_deact_in_general" = "Удаление страницы"; +"upd_in_general" = "Обновление фотографии страницы"; +"on_wall" = "На стене"; +"sign_short" = "Подпись"; diff --git a/themepacks/midnight/res/xmas.css b/themepacks/midnight/res/xmas.css index 5033703b..7ead875c 100644 --- a/themepacks/midnight/res/xmas.css +++ b/themepacks/midnight/res/xmas.css @@ -1,7 +1,7 @@ .page_header { - background-image: url('/themepack/midnight/0.0.3.1/resource/xheader.png') !important; + background-image: url('/themepack/midnight/0.0.3.3/resource/xheader.png') !important; } .page_custom_header { - background-image: url('/themepack/midnight/0.0.3.1/resource/xheader_custom.png') !important; + background-image: url('/themepack/midnight/0.0.3.3/resource/xheader_custom.png') !important; } diff --git a/themepacks/midnight/stylesheet.css b/themepacks/midnight/stylesheet.css index 1c3b3079..6c9861fc 100644 --- a/themepacks/midnight/stylesheet.css +++ b/themepacks/midnight/stylesheet.css @@ -135,10 +135,18 @@ th, .ovk-photo-view, .page_wrap_content_main .def_row_content, .topGrayBlock, -.bigPlayer { +.bigPlayer, +input[type="number"], +.like_tooltip_wrapper .like_tooltip_body, +.like_tooltip_wrapper .like_tooltip_head { border-color: #2c2640 !important; } +.like_tooltip_wrapper .like_tooltip_head { + background: linear-gradient(180deg, #383052, #231e33) !important; + box-shadow: unset !important; +} + .post-upload, .post-has-poll, .post-has-note { @@ -187,10 +195,8 @@ hr { .ovk-diag-action, .minilink .counter, .topGrayBlock, -.showMore, -.showMoreAudiosPlaylist, -#showMorePhotos, -#showMoreVideos { +#show_more, +.information { background-color: #2c2640 !important; } @@ -232,7 +238,8 @@ a, .paginator a:hover, .post-share-button:hover, .post-like-button:hover, -#search_box_button:active { +#search_box_button:active, +.mb_tab:hover { background-color: #272138 !important; } @@ -288,7 +295,8 @@ td.e, tr.e, .playlistListView:hover, .playlistListView .playlistCover, -.photosInsert > div { +.photosInsert > div, +.attachment_selector #attachment_insert #attachment_insert_count { background-color: #231e33 !important; } @@ -307,7 +315,8 @@ tr.v, .expand_button, #userContent blockquote, .tippy-box[data-theme~="vk"], -.searchOptions { +.searchOptions, +.like_tooltip_wrapper .like_tooltip_body { background-color: #1e1a2b !important; } @@ -317,11 +326,11 @@ tr.v, } .content_title_expanded { - background-image: url("/themepack/midnight/0.0.3.1/resource/flex_arrow_open.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/flex_arrow_open.png") !important; } .content_title_unexpanded { - background-image: url("/themepack/midnight/0.0.3.1/resource/flex_arrow_shut.gif") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/flex_arrow_shut.gif") !important; } .ovk-video>.preview, @@ -348,17 +357,17 @@ tr.h { .page_yellowheader { color: #c6d2e8; - background-image: url("/themepack/midnight/0.0.3.1/resource/header_purple.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/header_purple.png") !important; background-color: #231f34; border-color: #231f34; } .page_header { - background-image: url("/themepack/midnight/0.0.3.1/resource/header.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/header.png") !important; } .page_custom_header { - background-image: url("/themepack/midnight/0.0.3.1/resource/header_custom.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/header_custom.png") !important; } .page_yellowheader span, @@ -390,17 +399,18 @@ input[type~="phone"], input[type="search"], input[type~="search"], input[type~="date"], +input[type="number"], select, .crp-entry--message.unread { background-color: #181826 !important; } input[type="checkbox"] { - background-image: url("/themepack/midnight/0.0.3.1/resource/checkbox.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/checkbox.png") !important; } input[type="radio"] { - background-image: url("/themepack/midnight/0.0.3.1/resource/radio.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/radio.png") !important; } .header_navigation .link, .header_navigation .header_divider_stick { @@ -408,20 +418,20 @@ input[type="radio"] { } .heart { - background-image: url("/themepack/midnight/0.0.3.1/resource/like.gif") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/like.gif") !important; } .pinned-mark, .post-author .pin { - background-image: url("/themepack/midnight/0.0.3.1/resource/pin.png") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/pin.png") !important; } .repost-icon { - background-image: url("/themepack/midnight/0.0.3.1/resource/published.gif") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/published.gif") !important; } .post-author .delete { - background-image: url("/themepack/midnight/0.0.3.1/resource/input_clear.gif") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/input_clear.gif") !important; } .user-alert { @@ -454,7 +464,7 @@ input[type="radio"] { } #backdropEditor { - background-image: url("/themepack/midnight/0.0.3.1/resource/backdrop-editor.gif") !important; + background-image: url("/themepack/midnight/0.0.3.3/resource/backdrop-editor.gif") !important; border-color: #473e66 !important; } diff --git a/themepacks/midnight/theme.yml b/themepacks/midnight/theme.yml index 1f5b81d1..541012c7 100644 --- a/themepacks/midnight/theme.yml +++ b/themepacks/midnight/theme.yml @@ -1,5 +1,5 @@ id: midnight -version: "0.0.3.1" +version: "0.0.3.3" openvk_version: 0 enabled: 1 metadata: