diff --git a/VKAPI/Handlers/Video.php b/VKAPI/Handlers/Video.php index a296a17c..3a14f048 100755 --- a/VKAPI/Handlers/Video.php +++ b/VKAPI/Handlers/Video.php @@ -24,7 +24,7 @@ final class Video extends VKAPIRequestHandler $items = []; $video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1])); - if($video) { + if($video && !$video->isDeleted()) { $out_video = $video->getApiStructure($this->getUser())->video; $items[] = $out_video; if($out_video['owner_id']) { diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index f7c6a9b1..4b711827 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -1026,7 +1026,7 @@ final class Wall extends VKAPIRequestHandler } } - if(empty($message) && empty($attachments)) + if(empty($message) && sizeof($final_attachments) < 1) $this->fail(100, "Required parameter 'message' missing."); if(!$comment || $comment->isDeleted()) diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index 5cbc6c42..8dac6089 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -366,7 +366,7 @@
- +
{include "components/cookies.xml"} @@ -428,7 +428,7 @@ window.openvk = { "audio_genres": {\openvk\Web\Models\Entities\Audio::genres}, "at_search": {$atSearch ?? false}, - "max_attachments": {\OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]}, + "max_attachments": {\OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"] ?? 10}, "max_filesize_mb": 5, "current_id": {$thisUser ? $thisUser->getId() : 0}, } diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 23c44e1d..707dd187 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -111,6 +111,7 @@ +
{if is_null($thisUser)} {var $forceNoDeleteLink = true} diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 7d414931..fb258838 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -727,7 +727,7 @@ u(document).on("click", "#editPost", async (e) => { target.removeClass('lagged') - edit_place.find('.edit_menu #__edit_save').on('click', async (e) => { + edit_place.find('.edit_menu #__edit_save').on('click', async (ev) => { const text_node = edit_place.find('.edit_menu textarea') const nsfw_mark = edit_place.find(`.edit_menu input[name='nsfw']`) const as_group = edit_place.find(`.edit_menu input[name='as_group']`) @@ -756,7 +756,7 @@ u(document).on("click", "#editPost", async (e) => { params['copyright'] = copyright.nodes[0].value } - u(e.target).addClass('lagged') + u(ev.target).addClass('lagged') // больше двух запросов ! try { if(type == 'post') { @@ -767,16 +767,18 @@ u(document).on("click", "#editPost", async (e) => { } } catch(e) { fastError(e.message) - u(e.target).removeClass('lagged') + u(ev.target).removeClass('lagged') return } const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}`, { 'method': 'POST' })).text() - u(e.target).removeClass('lagged') + u(ev.target).removeClass('lagged') post.removeClass('editing') post.nodes[0].outerHTML = new_post_html + + bsdnHydrate() }) edit_place.find('.edit_menu #__edit_cancel').on('click', (e) => { @@ -1139,6 +1141,11 @@ u(document).on('click', '#__videoAttachment', async (e) => { u("#gif_loader").remove() const pages_count = Math.ceil(Number(videos.count) / per_page) + + if(pages_count < 1) { + insert_place.append(query == '' ? tr('no_videos') : tr('no_videos_results')) + } + videos.items.forEach(video => { const pretty_id = `${video.owner_id}_${video.id}` const is_attached = (form.find(`.upload-item[data-type='video'][data-id='${video.owner_id}_${video.id}']`)).length > 0 @@ -1294,6 +1301,11 @@ u(document).on('click', '#__notesAttachment', async (e) => { u("#gif_loader").remove() const pages_count = Math.ceil(Number(notes.count) / per_page) + + if(notes.count < 1) { + insert_place.append(tr('no_notes')) + } + notes.notes.forEach(note => { is_attached = (form.find(`.upload-item[data-type='note'][data-id='${note.owner_id}_${note.id}']`)).length > 0 insert_place.append(` @@ -1583,96 +1595,102 @@ async function repost(id, repost_type = 'post') { const repostsCount = u(`#repostsCount${id}`) const previousVal = repostsCount.length > 0 ? Number(repostsCount.html()) : 0; - MessageBox(tr('share'), ` -
- ${tr('auditory')} - -
- + const msg = new CMessageBox({ + title: tr('share'), + unique_name: 'repost_modal', + body: ` +
+ ${tr('auditory')} - +
+ + + - + +
+ + ${tr('your_comment')} + + + + +
- - ${tr('your_comment')} - - - - - -
- `, [tr('send'), tr('cancel')], [ - async () => { - const message = u('#repostMsgInput').nodes[0].value - const type = u(`input[name='repost_type']:checked`).nodes[0].value - let club_id = 0 - try { - club_id = parseInt(u(`select[name='selected_repost_club']`).nodes[0].selectedOptions[0].value) - } catch(e) {} - - const as_group = u(`input[name='asGroup']`).nodes[0].checked - const signed = u(`input[name='signed']`).nodes[0].checked - const attachments = u(`#repost_attachments`).nodes[0].value - - const params = {} - switch(repost_type) { - case 'post': - params.object = `wall${id}` - break - case 'photo': - params.object = `photo${id}` - break - case 'video': - params.object = `video${id}` - break - } - - params.message = message - if(type == 'group' && club_id != 0) { - params.group_id = club_id - } - - if(as_group) { - params.as_group = Number(as_group) - } - - if(signed) { - params.signed = Number(signed) - } - - if(attachments != '') { - params.attachments = attachments - } - - try { - res = await window.OVKAPI.call('wall.repost', params) - - if(u('#reposts' + id).length > 0) { - if(repostsCount.length > 0) { - repostsCount.html(previousVal + 1) - } else { - u('#reposts' + id).nodes[0].insertAdjacentHTML('beforeend', `(1)`) - } + `, + buttons: [tr('send'), tr('cancel')], + callbacks: [ + async () => { + const message = u('#repostMsgInput').nodes[0].value + const type = u(`input[name='repost_type']:checked`).nodes[0].value + let club_id = 0 + try { + club_id = parseInt(u(`select[name='selected_repost_club']`).nodes[0].selectedOptions[0].value) + } catch(e) {} + + const as_group = u(`input[name='asGroup']`).nodes[0].checked + const signed = u(`input[name='signed']`).nodes[0].checked + const attachments = u(`#repost_attachments`).nodes[0].value + + const params = {} + switch(repost_type) { + case 'post': + params.object = `wall${id}` + break + case 'photo': + params.object = `photo${id}` + break + case 'video': + params.object = `video${id}` + break } - - NewNotification(tr('information_-1'), tr('shared_succ'), null, () => {window.location.assign(`/wall${res.pretty_id}`)}); - } catch(e) { - console.error(e) - fastError(e.message) - } - }, - Function.noop - ]); + + params.message = message + if(type == 'group' && club_id != 0) { + params.group_id = club_id + } + + if(as_group) { + params.as_group = Number(as_group) + } + + if(signed) { + params.signed = Number(signed) + } + + if(attachments != '') { + params.attachments = attachments + } + + try { + res = await window.OVKAPI.call('wall.repost', params) + + if(u('#reposts' + id).length > 0) { + if(repostsCount.length > 0) { + repostsCount.html(previousVal + 1) + } else { + u('#reposts' + id).nodes[0].insertAdjacentHTML('beforeend', `(1)`) + } + } + + NewNotification(tr('information_-1'), tr('shared_succ'), null, () => {window.location.assign(`/wall${res.pretty_id}`)}); + } catch(e) { + console.error(e) + fastError(e.message) + } + }, + Function.noop + ] + }); u('.ovk-diag-body').attr('style', 'padding: 14px;') u('.ovk-diag-body').on('change', `input[name='repost_type']`, (e) => { diff --git a/bootstrap.php b/bootstrap.php index 405dc2fb..10025556 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -235,7 +235,7 @@ function ovk_is_ssl(): bool function parseAttachments($attachments, array $allow_types = ['photo', 'video', 'note', 'audio']): array { $exploded_attachments = is_array($attachments) ? $attachments : explode(",", $attachments); - $exploded_attachments = array_slice($exploded_attachments, 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"]); + $exploded_attachments = array_slice($exploded_attachments, 0, OPENVK_ROOT_CONF["openvk"]["preferences"]["wall"]["postSizes"]["maxAttachments"] ?? 10); $imploded_types = implode('|', $allow_types); $output_attachments = []; $repositories = [ diff --git a/install/sqls/000XX-new-video-fields.sql b/install/sqls/00050-new-video-fields.sql similarity index 100% rename from install/sqls/000XX-new-video-fields.sql rename to install/sqls/00050-new-video-fields.sql