Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions lib/Sabre/Album/PublicAlbumPhoto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Photos\Sabre\Album;

use OCP\Files\NotFoundException;
use Sabre\DAV\IFile;

class PublicAlbumPhoto extends AlbumPhoto implements IFile {
/** @return void */
public function delete() {
throw new NotFoundException("Deleting photos from a public album is not allowed.");
}

/** @return void */
public function put($data) {
throw new NotFoundException("Changing a photo from a public album is not allowed.");
}
}
25 changes: 24 additions & 1 deletion lib/Sabre/Album/PublicAlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

namespace OCA\Photos\Sabre\Album;

use OCA\Photos\Album\AlbumFile;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;

class PublicAlbumRoot extends AlbumRoot {
Expand Down Expand Up @@ -52,10 +54,14 @@ protected function getPhotosLocationInfo() {
return [$photosLocation, $userFolder];
}

protected function addFile(int $sourceId, string $ownerUID): bool {
public function createFile($name, $data = null) {
throw new Forbidden('Not allowed to create a file in a public album');
}

protected function addFile(int $sourceId, string $ownerUID): bool {
throw new Forbidden('Not allowed to add a file to a public album');
}

// Do not reveal collaborators for public albums.
public function getCollaborators(): array {
/** @var array{array{'nc:collaborator': array{'id': string, 'label': string, 'type': int}}} */
Expand All @@ -65,4 +71,21 @@ public function getCollaborators(): array {
public function setCollaborators($collaborators): array {
throw new Forbidden('Not allowed to collaborators a public album');
}

/** @return never */
public function getChildren(): array {
return array_map(function (AlbumFile $file) {
return new PublicAlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId));
}, $this->album->getFiles());
}

public function getChild($name): PublicAlbumPhoto {
foreach ($this->album->getFiles() as $file) {
if ($file->getFileId() . "-" . $file->getName() === $name) {
return new PublicAlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId));
}
}

throw new NotFound("$name not found");
}
}
2 changes: 1 addition & 1 deletion lib/Sabre/Album/SharedAlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public function getCollaborators(): array {
}

public function setCollaborators($collaborators): array {
throw new Forbidden('Not allowed to collaborators a public album');
throw new Forbidden('Not allowed to collaborators to a public album');
}
}
2 changes: 1 addition & 1 deletion src/views/Folders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<div v-else class="grid-container">
<VirtualGrid ref="virtualgrid"
:items="contentList"
:scrollElement="appContent"
:scroll-element="appContent"
:get-column-count="() => gridConfig.count"
:get-grid-gap="() => gridConfig.gap" />
</div>
Expand Down
9 changes: 3 additions & 6 deletions src/views/PublicAlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
<Download slot="icon" />
</ActionDownload> -->

<NcActionButton :close-after-click="true"
<!-- <NcActionButton :close-after-click="true"
@click="handleRemoveFilesFromAlbum(selectedFileIds)">
{{ t('photos', 'Remove selection from album') }}
<Close slot="icon" />
</NcActionButton>
</NcActionButton> -->
</template>
</NcActions>
</template>
Expand Down Expand Up @@ -93,11 +93,10 @@ import { createClient, getPatcher } from 'webdav'
import MapMarker from 'vue-material-design-icons/MapMarker'
import Plus from 'vue-material-design-icons/Plus'
import ImagePlus from 'vue-material-design-icons/ImagePlus'
import Close from 'vue-material-design-icons/Close'
// import Download from 'vue-material-design-icons/Download'
// import DownloadMultiple from 'vue-material-design-icons/DownloadMultiple'

import { NcActions, NcActionButton, NcButton, NcEmptyContent, /** NcActionSeparator, */ isMobile } from '@nextcloud/vue'
import { NcActions, NcButton, NcEmptyContent, /** NcActionSeparator, */ isMobile } from '@nextcloud/vue'
import { showError } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import { generateUrl, generateRemoteUrl } from '@nextcloud/router'
Expand Down Expand Up @@ -125,13 +124,11 @@ export default {
components: {
MapMarker,
Plus,
Close,
// Download,
// DownloadMultiple,
ImagePlus,
NcEmptyContent,
NcActions,
NcActionButton,
// NcActionSeparator,
NcButton,
CollectionContent,
Expand Down