Compare commits

..

No commits in common. "59513bf2e21ec994467859ab57bda4186ba1d2dd" and "f1eddb4c9aeb7dc32b2bed84eff3634023c9fff9" have entirely different histories.

5 changed files with 40 additions and 72 deletions

View file

@ -278,23 +278,19 @@ final class Photos extends VKAPIRequestHandler
$album = (new Albums())->getAlbumByOwnerAndId($owner_id, $album_id);
if (!$album || $album->isDeleted() || $album->isCreatedBySystem()) {
if (!$album || $album->isDeleted() || $album->isCreatedBySystem())
$this->fail(114, "Invalid album id");
}
if (!$album->canBeModifiedBy($this->getUser())) {
if (!$album->canBeModifiedBy($this->getUser()))
$this->fail(15, "Access denied");
}
if (!is_null($title) && !empty($title) && !ctype_space($title)) {
if (!is_null($title) && !empty($title) && !ctype_space($content))
$album->setName($title);
}
if (!is_null($description)) {
if (!is_null($description))
$album->setDescription($description);
}
try {
$album->save();
} catch (\Throwable $e) {
} catch(\Throwable $e) {
return 1;
}
@ -316,12 +312,10 @@ final class Photos extends VKAPIRequestHandler
if (empty($album_ids)) {
$owner = get_entity_by_id($owner_id);
if (!$owner || !$owner->canBeViewedBy($this->getUser())) {
if (!$owner || !$owner->canBeViewedBy($this->getUser()))
$this->fail(15, "Access denied");
}
if ($owner_id > 0 && !$owner->getPrivacyPermission('photos.read', $this->getUser())) {
if ($owner_id > 0 && !$owner->getPrivacyPermission('photos.read', $this->getUser()))
$this->fail(15, "Access denied");
}
$albums_list = null;
if ($owner_id > 0) {
@ -335,19 +329,17 @@ final class Photos extends VKAPIRequestHandler
} else {
$album_ids = explode(',', $album_ids);
foreach ($album_ids as $album_id) {
$album = (new Albums())->getAlbumByOwnerAndId((int) $owner_id, (int) $album_id);
if (!$album || $album->isDeleted() || !$album->canBeViewedBy($this->getUser())) {
$album = (new Albums())->getAlbumByOwnerAndId((int)$owner_id, (int)$album_id);
if (!$album || $album->isDeleted() || !$album->canBeViewedBy($this->getUser()))
continue;
}
$albums_list[] = $album;
}
}
foreach ($albums_list as $album) {
if (!$need_system && $album->isCreatedBySystem()) { # TODO use queries
if (!$need_system && $album->isCreatedBySystem()) # TODO use queries
continue;
}
$res["items"][] = $album->toVkApiStruct($this->getUser(), $need_covers, $photo_sizes);
}
@ -363,7 +355,7 @@ final class Photos extends VKAPIRequestHandler
$user_id = $this->getUser()->getId();
}
if (!is_null($user_id)) {
if (!is_null($user_id)){
$__user = (new UsersRepo())->get($user_id);
if (!$__user || $__user->isDeleted() || !$__user->getPrivacyPermission('photos.read', $this->getUser())) {
$this->fail(15, "Access denied");
@ -396,9 +388,8 @@ final class Photos extends VKAPIRequestHandler
foreach ($photos_splitted_list as $photo_id) {
$photo_s_id = explode("_", $photo_id);
$photo = (new PhotosRepo())->getByOwnerAndVID((int) $photo_s_id[0], (int) $photo_s_id[1]);
if (!$photo || $photo->isDeleted() || !$photo->canBeViewedBy($this->getUser())) {
if(!$photo || $photo->isDeleted() || !$photo->canBeViewedBy($this->getUser()))
continue;
}
$res[] = $photo->toVkApiStruct($photo_sizes, $extended);
}
@ -444,9 +435,8 @@ final class Photos extends VKAPIRequestHandler
$id = explode("_", $photo);
$photo_entity = (new PhotosRepo())->getByOwnerAndVID((int) $id[0], (int) $id[1]);
if (!$photo_entity || $photo_entity->isDeleted() || !$photo_entity->canBeViewedBy($this->getUser())) {
if (!$photo_entity || $photo_entity->isDeleted() || !$photo_entity->canBeViewedBy($this->getUser()))
continue;
}
$res["items"][] = $photo_entity->toVkApiStruct($photo_sizes, $extended);
}
@ -495,15 +485,14 @@ final class Photos extends VKAPIRequestHandler
$this->requireUser();
$this->willExecuteWriteAction();
if (!$owner_id) {
if(!$owner_id) {
$owner_id = $this->getUser()->getId();
}
if (is_null($photos)) {
if (is_null($photo_id)) {
if(is_null($photo_id))
return 0;
}
$photo = (new PhotosRepo())->getByOwnerAndVID($owner_id, $photo_id);
if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser())) {
return 1;
@ -515,13 +504,12 @@ final class Photos extends VKAPIRequestHandler
if (sizeof($photos_list) > 10) {
$this->fail(-78, "Photos count must not exceed limit");
}
foreach ($photos_list as $photo_id) {
$id = explode("_", $photo_id);
$photo = (new PhotosRepo())->getByOwnerAndVID((int) $id[0], (int) $id[1]);
if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser())) {
if (!$photo || $photo->isDeleted() || !$photo->canBeModifiedBy($this->getUser()))
continue;
}
$photo->delete();
}

View file

@ -595,17 +595,6 @@
</tbody>
</table>
</form>
<table cellspacing="7" cellpadding="0" width="60%" border="0" align="center" id="_js_settings">
<tbody>
<tr>
<td width="120" valign="top" align="right"></td>
<td>
<a href="javascript:openJsSettings()">{_ui_settings_window}</a>
</td>
</tr>
</tbody>
</table>
<h4>{_ui_settings_sidebar}</h4>
<form action="/settings?act=lMenu" method="POST" enctype="multipart/form-data">

View file

@ -84,6 +84,8 @@ u(document).on('click', '#__feed_settings_link', (e) => {
const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') ?? 10)
const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') ?? 1)
const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') ?? 0)
const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1)
const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') ?? 0)
const COUNT = [1, 5, 10, 20, 30, 40, 50]
u('#_feed_settings_container #__content').html(`
<table cellspacing="7" cellpadding="0" border="0" align="center">
@ -114,6 +116,26 @@ u(document).on('click', '#__feed_settings_link', (e) => {
<label for='showIgnored'>${tr('show_ignored_sources')}</label>
</td>
</tr>
<tr>
<td width="120" valign="top">
<span class="nobold">
<input type='checkbox' data-act='localstorage_item' data-inverse="1" name='ux.disable_ajax_routing' id="ux.disable_ajax_routing" ${CURRENT_DISABLE_AJAX == 0 ? 'checked' : ''}>
</span>
</td>
<td>
<label for='ux.disable_ajax_routing'>${tr('ajax_routing')}</label>
</td>
</tr>
<tr>
<td width="120" valign="top">
<span class="nobold">
<input type='checkbox' data-act='localstorage_item' name='ux.auto_scroll' id="ux.auto_scroll" ${CURRENT_AUTO_SCROLL == 1 ? 'checked' : ''}>
</span>
</td>
<td>
<label for='ux.auto_scroll'>${tr('auto_scroll')}</label>
</td>
</tr>
<tr>
<td width="120" valign="top">
</td>
@ -277,32 +299,3 @@ u(document).on('change', `input[data-act='localstorage_item']`, (e) => {
localStorage.setItem(e.target.name, Number(e.target.checked))
})
function openJsSettings() {
const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1)
const CURRENT_DISABLE_AJAX = Number(localStorage.getItem('ux.disable_ajax_routing') ?? 0)
u("#_js_settings td").remove()
u("#_js_settings").append(`
<tr>
<td width="120" valign="top">
<span class="nobold">
<input type='checkbox' data-act='localstorage_item' data-inverse="1" name='ux.disable_ajax_routing' id="ux.disable_ajax_routing" ${CURRENT_DISABLE_AJAX == 0 ? 'checked' : ''}>
</span>
</td>
<td>
<label for='ux.disable_ajax_routing'>${tr('ajax_routing')}</label>
</td>
</tr>
<tr>
<td width="120" valign="top">
<span class="nobold">
<input type='checkbox' data-act='localstorage_item' name='ux.auto_scroll' id="ux.auto_scroll" ${CURRENT_AUTO_SCROLL == 1 ? 'checked' : ''}>
</span>
</td>
<td>
<label for='ux.auto_scroll'>${tr('auto_scroll')}</label>
</td>
</tr>
`)
}

View file

@ -703,7 +703,6 @@
"round_avatars" = "Round";
"apply_style_for_this_device" = "Apply style only for this device";
"ui_settings_window" = "Advanced settings";
"search_for_groups" = "Search for groups";
"search_for_users" = "Search for users";

View file

@ -676,7 +676,6 @@
"cut" = "Квадратные";
"round_avatars" = "Круглые";
"apply_style_for_this_device" = "Применить стиль только для этого устройства";
"ui_settings_window" = "Дополнительные настройки";
"search_for_groups" = "Поиск групп";
"search_for_users" = "Поиск людей";
"search_for_posts" = "Поиск записей";