diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 31 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Calendar.php | 9 | ||||
-rw-r--r-- | apps/files/src/services/FileInfo.ts | 1 | ||||
-rw-r--r-- | apps/files/src/utils/fileUtils.ts | 44 | ||||
-rw-r--r-- | apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareControllerTest.php | 4 | ||||
-rw-r--r-- | apps/weather_status/lib/Service/WeatherStatusService.php | 15 |
7 files changed, 63 insertions, 45 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 81e999cc356..2ef57ca77bb 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1429,37 +1429,40 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription /** * Moves a calendar object from calendar to calendar. * - * @param int $sourceCalendarId + * @param string $sourcePrincipalUri + * @param int $sourceObjectId + * @param string $targetPrincipalUri * @param int $targetCalendarId - * @param int $objectId - * @param string $oldPrincipalUri - * @param string $newPrincipalUri + * @param string $tragetObjectUri * @param int $calendarType * @return bool * @throws Exception */ - public function moveCalendarObject(int $sourceCalendarId, int $targetCalendarId, int $objectId, string $oldPrincipalUri, string $newPrincipalUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool { + public function moveCalendarObject(string $sourcePrincipalUri, int $sourceObjectId, string $targetPrincipalUri, int $targetCalendarId, string $tragetObjectUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool { $this->cachedObjects = []; - return $this->atomic(function () use ($sourceCalendarId, $targetCalendarId, $objectId, $oldPrincipalUri, $newPrincipalUri, $calendarType) { - $object = $this->getCalendarObjectById($oldPrincipalUri, $objectId); + return $this->atomic(function () use ($sourcePrincipalUri, $sourceObjectId, $targetPrincipalUri, $targetCalendarId, $tragetObjectUri, $calendarType) { + $object = $this->getCalendarObjectById($sourcePrincipalUri, $sourceObjectId); if (empty($object)) { return false; } + $sourceCalendarId = $object['calendarid']; + $sourceObjectUri = $object['uri']; + $query = $this->db->getQueryBuilder(); $query->update('calendarobjects') ->set('calendarid', $query->createNamedParameter($targetCalendarId, IQueryBuilder::PARAM_INT)) - ->where($query->expr()->eq('id', $query->createNamedParameter($objectId, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) - ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) + ->set('uri', $query->createNamedParameter($tragetObjectUri, IQueryBuilder::PARAM_STR)) + ->where($query->expr()->eq('id', $query->createNamedParameter($sourceObjectId, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) ->executeStatement(); - $this->purgeProperties($sourceCalendarId, $objectId); - $this->updateProperties($targetCalendarId, $object['uri'], $object['calendardata'], $calendarType); + $this->purgeProperties($sourceCalendarId, $sourceObjectId); + $this->updateProperties($targetCalendarId, $tragetObjectUri, $object['calendardata'], $calendarType); - $this->addChanges($sourceCalendarId, [$object['uri']], 3, $calendarType); - $this->addChanges($targetCalendarId, [$object['uri']], 1, $calendarType); + $this->addChanges($sourceCalendarId, [$sourceObjectUri], 3, $calendarType); + $this->addChanges($targetCalendarId, [$tragetObjectUri], 1, $calendarType); - $object = $this->getCalendarObjectById($newPrincipalUri, $objectId); + $object = $this->getCalendarObjectById($targetPrincipalUri, $sourceObjectId); // Calendar Object wasn't found - possibly because it was deleted in the meantime by a different client if (empty($object)) { return false; diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index 6fd7d147131..789fe4b55c0 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -391,9 +391,14 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable if (!($sourceNode instanceof CalendarObject)) { return false; } - try { - return $this->caldavBackend->moveCalendarObject($sourceNode->getCalendarId(), (int)$this->calendarInfo['id'], $sourceNode->getId(), $sourceNode->getOwner(), $this->getOwner()); + return $this->caldavBackend->moveCalendarObject( + $sourceNode->getOwner(), + $sourceNode->getId(), + $this->getOwner(), + $this->getResourceId(), + $targetName, + ); } catch (Exception $e) { $this->logger->error('Could not move calendar object: ' . $e->getMessage(), ['exception' => $e]); return false; diff --git a/apps/files/src/services/FileInfo.ts b/apps/files/src/services/FileInfo.ts index 18629845cca..318236f1677 100644 --- a/apps/files/src/services/FileInfo.ts +++ b/apps/files/src/services/FileInfo.ts @@ -24,6 +24,7 @@ export default function(node: Node) { sharePermissions: node.attributes['share-permissions'], shareAttributes: JSON.parse(node.attributes['share-attributes'] || '[]'), type: node.type === 'file' ? 'file' : 'dir', + attributes: node.attributes, }) // TODO remove when no more legacy backbone is used diff --git a/apps/files/src/utils/fileUtils.ts b/apps/files/src/utils/fileUtils.ts index 421b7d02376..f0b974be21d 100644 --- a/apps/files/src/utils/fileUtils.ts +++ b/apps/files/src/utils/fileUtils.ts @@ -3,15 +3,15 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { FileType, type Node } from '@nextcloud/files' -import { translate as t, translatePlural as n } from '@nextcloud/l10n' +import { n } from '@nextcloud/l10n' /** * Extract dir and name from file path * - * @param {string} path the full path - * @return {string[]} [dirPath, fileName] + * @param path - The full path + * @return [dirPath, fileName] */ -export const extractFilePaths = function(path) { +export function extractFilePaths(path: string): [string, string] { const pathSections = path.split('/') const fileName = pathSections[pathSections.length - 1] const dirPath = pathSections.slice(0, pathSections.length - 1).join('/') @@ -20,32 +20,28 @@ export const extractFilePaths = function(path) { /** * Generate a translated summary of an array of nodes - * @param {Node[]} nodes the nodes to summarize - * @param {number} hidden the number of hidden nodes - * @return {string} + * + * @param nodes - The nodes to summarize + * @param hidden - The number of hidden nodes */ -export const getSummaryFor = (nodes: Node[], hidden = 0): string => { +export function getSummaryFor(nodes: Node[], hidden = 0): string { const fileCount = nodes.filter(node => node.type === FileType.File).length const folderCount = nodes.filter(node => node.type === FileType.Folder).length - let summary = '' - - if (fileCount === 0) { - summary = n('files', '{folderCount} folder', '{folderCount} folders', folderCount, { folderCount }) - } else if (folderCount === 0) { - summary = n('files', '{fileCount} file', '{fileCount} files', fileCount, { fileCount }) - } else if (fileCount === 1) { - summary = n('files', '1 file and {folderCount} folder', '1 file and {folderCount} folders', folderCount, { folderCount }) - } else if (folderCount === 1) { - summary = n('files', '{fileCount} file and 1 folder', '{fileCount} files and 1 folder', fileCount, { fileCount }) - } else { - summary = t('files', '{fileCount} files and {folderCount} folders', { fileCount, folderCount }) + const summary: string[] = [] + if (fileCount > 0 || folderCount === 0) { + const fileSummary = n('files', '%n file', '%n files', fileCount) + summary.push(fileSummary) + } + if (folderCount > 0) { + const folderSummary = n('files', '%n folder', '%n folders', folderCount) + summary.push(folderSummary) } - if (hidden > 0) { - // TRANSLATORS: This is a summary of files and folders, where {hiddenFilesAndFolders} is the number of hidden files and folders - summary += ' ' + n('files', '(%n hidden)', ' (%n hidden)', hidden) + // TRANSLATORS: This is the number of hidden files or folders + const hiddenSummary = n('files', '%n hidden', '%n hidden', hidden) + summary.push(hiddenSummary) } - return summary + return summary.join(' ยท ') } diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php index caadd89b46c..686ba32fd49 100644 --- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php +++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php @@ -70,8 +70,10 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider $ownerNameProperty = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); if ($ownerNameProperty->getScope() === IAccountManager::SCOPE_PUBLISHED) { - $ownerName = $owner->getDisplayName(); $ownerId = $owner->getUID(); + $ownerName = $owner->getDisplayName(); + $this->initialState->provideInitialState('owner', $ownerId); + $this->initialState->provideInitialState('ownerDisplayName', $ownerName); } } diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 0ed43da52cd..58cbb4e0b82 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -330,6 +330,8 @@ class ShareControllerTest extends \Test\TestCase { 'filename' => $filename, 'view' => $view, 'fileId' => 111, + 'owner' => 'ownerUID', + 'ownerDisplayName' => 'ownerDisplay', ]; $response = $this->shareController->showShare(); @@ -470,6 +472,8 @@ class ShareControllerTest extends \Test\TestCase { 'filename' => $filename, 'view' => 'public-file-drop', 'disclaimer' => 'My disclaimer text', + 'owner' => 'ownerUID', + 'ownerDisplayName' => 'ownerDisplay', ]; $response = $this->shareController->showShare(); diff --git a/apps/weather_status/lib/Service/WeatherStatusService.php b/apps/weather_status/lib/Service/WeatherStatusService.php index 04500cf66a5..c93010e7f58 100644 --- a/apps/weather_status/lib/Service/WeatherStatusService.php +++ b/apps/weather_status/lib/Service/WeatherStatusService.php @@ -257,12 +257,19 @@ class WeatherStatusService { ]; $url = 'https://nominatim.openstreetmap.org/search'; $results = $this->requestJSON($url, $params); - if ($results['error'] !== null) { - return $results; + + if (isset($results['error'])) { + return ['error' => (string)$results['error']]; } - if (count($results) > 0) { - return $results[0]; + + if (count($results) > 0 && is_array($results[0])) { + return [ + 'display_name' => (string)($results[0]['display_name'] ?? null), + 'lat' => (string)($results[0]['lat'] ?? null), + 'lon' => (string)($results[0]['lon'] ?? null), + ]; } + return ['error' => $this->l10n->t('No result.')]; } |