diff --git a/VKAPI/Handlers/Audio.php b/VKAPI/Handlers/Audio.php index 3ffb0be4..413a2a3a 100644 --- a/VKAPI/Handlers/Audio.php +++ b/VKAPI/Handlers/Audio.php @@ -184,6 +184,9 @@ final class Audio extends VKAPIRequestHandler if(!$user) $this->fail(0404, "User not found"); + if(!$user->getPrivacyPermission("audios.read", $this->getUser())) + $this->fail(15, "Access denied"); + if($uploaded_only) { return DatabaseConnection::i()->getContext()->table("audios") ->where([ @@ -264,6 +267,14 @@ final class Audio extends VKAPIRequestHandler if($owner_id <= 0) $this->fail(8, "uploaded_only can only be used with owner_id > 0"); + $user = (new \openvk\Web\Models\Repositories\Users)->get($owner_id); + + if(!$user) + $this->fail(0602, "Invalid user"); + + if(!$user->getPrivacyPermission("audios.read", $this->getUser())) + $this->fail(15, "Access denied: this user chose to hide his audios"); + if(!is_null($shuffleSeed)) { $audio_ids = []; $query = $dbCtx->table("audios")->select("virtual_id")->where([ @@ -351,6 +362,7 @@ final class Audio extends VKAPIRequestHandler function beacon(int $aid, ?int $gid = NULL): int { $this->requireUser(); + $this->willExecuteWriteAction(); $audio = (new Audios)->get($aid); if(!$audio) @@ -428,6 +440,7 @@ final class Audio extends VKAPIRequestHandler function edit(int $owner_id, int $audio_id, ?string $artist = NULL, ?string $title = NULL, ?string $text = NULL, ?int $genre_id = NULL, ?string $genre_str = NULL, int $no_search = 0): int { $this->requireUser(); + $this->willExecuteWriteAction(); $audio = (new Audios)->getByOwnerAndVID($owner_id, $audio_id); if(!$audio) @@ -470,6 +483,7 @@ final class Audio extends VKAPIRequestHandler function add(int $audio_id, int $owner_id, ?int $group_id = NULL, ?int $album_id = NULL): string { $this->requireUser(); + $this->willExecuteWriteAction(); if(!is_null($album_id)) $this->fail(10, "album_id not implemented"); @@ -504,6 +518,7 @@ final class Audio extends VKAPIRequestHandler function delete(int $audio_id, int $owner_id, ?int $group_id = NULL): int { $this->requireUser(); + $this->willExecuteWriteAction(); $from = $this->getUser(); if(!is_null($group_id)) { @@ -592,6 +607,7 @@ final class Audio extends VKAPIRequestHandler function addAlbum(string $title, ?string $description = NULL, int $group_id = 0): int { $this->requireUser(); + $this->willExecuteWriteAction(); $group = NULL; if($group_id != 0) { @@ -624,6 +640,7 @@ final class Audio extends VKAPIRequestHandler function editAlbum(int $album_id, ?string $title = NULL, ?string $description = NULL): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($album_id); if(!$album) @@ -646,6 +663,7 @@ final class Audio extends VKAPIRequestHandler function deleteAlbum(int $album_id): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($album_id); if(!$album) @@ -661,6 +679,7 @@ final class Audio extends VKAPIRequestHandler function moveToAlbum(int $album_id, string $audio_ids): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($album_id); if(!$album) @@ -700,6 +719,7 @@ final class Audio extends VKAPIRequestHandler function removeFromAlbum(int $album_id, string $audio_ids): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($album_id); if(!$album) @@ -739,6 +759,7 @@ final class Audio extends VKAPIRequestHandler function bookmarkAlbum(int $id): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($id); if(!$album) @@ -753,6 +774,7 @@ final class Audio extends VKAPIRequestHandler function unBookmarkAlbum(int $id): int { $this->requireUser(); + $this->willExecuteWriteAction(); $album = (new Audios)->getPlaylist($id); if(!$album) diff --git a/Web/Presenters/templates/Audio/player.xml b/Web/Presenters/templates/Audio/player.xml index 361d4d86..7d4ee152 100644 --- a/Web/Presenters/templates/Audio/player.xml +++ b/Web/Presenters/templates/Audio/player.xml @@ -12,7 +12,7 @@
-
+
{ovk_proc_strtr($audio->getPerformer(), 50)} diff --git a/Web/static/css/audios.css b/Web/static/css/audios.css index d639ebad..e998f856 100644 --- a/Web/static/css/audios.css +++ b/Web/static/css/audios.css @@ -1,3 +1,14 @@ +.noOverflow { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.overflowedName { + position: absolute; + z-index: 99; +} + .musicIcon { background-image: url('/assets/packages/static/openvk/img/audios_controls.png'); background-repeat: no-repeat; diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js index 81129a2d..b7f387a7 100644 --- a/Web/static/js/al_music.js +++ b/Web/static/js/al_music.js @@ -346,7 +346,7 @@ class bigPlayer { }) u(document).on("keyup", (e) => { - if([87, 65, 83, 68, 82].includes(e.keyCode)) { + if([87, 65, 83, 68, 82, 77].includes(e.keyCode)) { if(document.querySelector(".ovk-diag-cont") != null) return @@ -365,6 +365,9 @@ class bigPlayer { case 82: document.querySelector(".bigPlayer .additionalButtons .repeatButton").click() break + case 77: + document.querySelector(".bigPlayer .additionalButtons .deviceButton").click() + break } }) @@ -661,7 +664,21 @@ document.addEventListener("DOMContentLoaded", function() { if(bigplayer != null) bigPlayerObserver.observe(bigplayer); -}}) + } + + $(`.audioEntry .mediaInfo`).on("mouseover mouseleave", (e) => { + const info = e.currentTarget.closest(".mediaInfo") + const overfl = info.querySelector(".info") + + if(e.originalEvent.type == "mouseleave" || e.originalEvent.type == "mouseout") { + overfl.classList.add("noOverflow") + overfl.classList.remove("overflowedName") + } else { + overfl.classList.remove("noOverflow") + overfl.classList.add("overflowedName") + } + }) +}) $(document).on("click", ".audioEmbed > *", (e) => { const player = e.currentTarget.closest(".audioEmbed") @@ -827,7 +844,7 @@ $(document).on("click", ".musicIcon.edit-icon", (e) => { let genre = player.dataset.genre let lyrics = e.currentTarget.dataset.lyrics - MessageBox(tr("edit"), ` + MessageBox(tr("edit_audio"), `
${tr("performer")} @@ -854,7 +871,7 @@ $(document).on("click", ".musicIcon.edit-icon", (e) => {
${tr("fully_delete_audio")}
- `, [tr("ok"), tr("cancel")], [ + `, [tr("save"), tr("cancel")], [ function() { let t_name = $(".ovk-diag-body input[name=name]").val(); let t_perf = $(".ovk-diag-body input[name=performer]").val(); @@ -894,7 +911,7 @@ $(document).on("click", ".musicIcon.edit-icon", (e) => { player.querySelector(".title").classList.add("withLyrics") } else { player.insertAdjacentHTML("beforeend", ` -
+
${response.new_info.lyrics}
`) @@ -1037,7 +1054,7 @@ $(document).on("click", ".musicIcon.add-icon-group", async (ev) => { let body = ` ${tr("what_club_add")}
- +
@@ -1117,23 +1134,25 @@ $(document).on("click", ".musicIcon.add-icon", (e) => { $(document).on("click", "#_deletePlaylist", (e) => { let id = e.currentTarget.dataset.id - $.ajax({ - type: "POST", - url: `/playlist${id}/action?act=delete`, - data: { - hash: u("meta[name=csrf]").attr("value"), - }, - beforeSend: () => { - e.currentTarget.classList.add("lagged") - }, - success: (response) => { - if(response.success) { - window.location.assign("/playlists" + response.id) - } else { - fastError(response.flash.message) + MessageBox(tr("warning"), tr("sure_delete_playlist"), [tr("yes"), tr("no")], [() => { + $.ajax({ + type: "POST", + url: `/playlist${id}/action?act=delete`, + data: { + hash: u("meta[name=csrf]").attr("value"), + }, + beforeSend: () => { + e.currentTarget.classList.add("lagged") + }, + success: (response) => { + if(response.success) { + window.location.assign("/playlists" + response.id) + } else { + fastError(response.flash.message) + } } - } - }) + }) + }, Function.noop]) }) $(document).on("click", "#_audioAttachment", (e) => { diff --git a/locales/en.strings b/locales/en.strings index 6aa0459d..6921651f 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -831,6 +831,8 @@ "audio_successfully_uploaded" = "Audio has been successfully uploaded and is currently being processed."; "broadcast_audio" = "Broadcast audio to status"; +"sure_delete_playlist" = "Do you sure want to delete this playlist?"; +"edit_audio" = "Edit audio"; /* Notifications */ @@ -1938,6 +1940,7 @@ /* Mobile */ "mobile_friends" = "Friends"; "mobile_photos" = "Photos"; +"mobile_audios" = "Audios"; "mobile_videos" = "Videos"; "mobile_messages" = "Messages"; "mobile_notes" = "Notes"; @@ -1951,6 +1954,9 @@ "mobile_user_info_hide" = "Hide"; "mobile_user_info_show_details" = "Show details"; +"my" = "My"; +"enter_a_name_or_artist" = "Enter a name or artist..."; + /* Moderation */ "section" = "Section"; diff --git a/locales/ru.strings b/locales/ru.strings index df9ea9c0..cfb46b75 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -786,6 +786,8 @@ "audio_successfully_uploaded" = "Аудио успешно загружено и на данный момент обрабатывается."; "broadcast_audio" = "Транслировать аудио в статус"; +"sure_delete_playlist" = "Вы действительно хотите удалить этот плейлист?"; +"edit_audio" = "Редактировать аудиозапись"; /* Notifications */ @@ -1827,6 +1829,7 @@ /* Mobile */ "mobile_friends" = "Друзья"; "mobile_photos" = "Фотографии"; +"mobile_audios" = "Аудиозаписи"; "mobile_videos" = "Видеозаписи"; "mobile_messages" = "Сообщения"; "mobile_notes" = "Заметки"; @@ -1840,6 +1843,9 @@ "mobile_user_info_hide" = "Скрыть"; "mobile_user_info_show_details" = "Показать подробнее"; +"my" = "Мои"; +"enter_a_name_or_artist" = "Введите название или автора..."; + /* Moderation */ "section" = "Раздел";