summaryrefslogtreecommitdiffstats
path: root/apps/sharebymail
diff options
context:
space:
mode:
authorNextcloud bot <bot@nextcloud.com>2018-12-25 01:12:03 +0000
committerNextcloud bot <bot@nextcloud.com>2018-12-25 01:12:03 +0000
commita1e425027873d1df4c6291920cf5ff4030f8eb27 (patch)
treecf45d4fed66200d337a3d5e2f209c949eae34506 /apps/sharebymail
parent224dbe15fdbf73bf16636c9eea0ca1760b493d12 (diff)
downloadnextcloud-server-a1e425027873d1df4c6291920cf5ff4030f8eb27.tar.gz
nextcloud-server-a1e425027873d1df4c6291920cf5ff4030f8eb27.zip
[tx-robot] updated from transifex
Diffstat (limited to 'apps/sharebymail')
-rw-r--r--apps/sharebymail/l10n/cs.js4
-rw-r--r--apps/sharebymail/l10n/cs.json4
2 files changed, 8 insertions, 0 deletions
diff --git a/apps/sharebymail/l10n/cs.js b/apps/sharebymail/l10n/cs.js
index 41d3ae9c848..c7a72c2e366 100644
--- a/apps/sharebymail/l10n/cs.js
+++ b/apps/sharebymail/l10n/cs.js
@@ -5,6 +5,8 @@ OC.L10N.register(
"Shared with {email}" : "Sdíleno s {email}",
"Shared with %1$s by %2$s" : "%2$s sdílí s %1$s",
"Shared with {email} by {actor}" : "{actor} sdílí s {email}",
+ "Unshared from {email}" : "Sdílení zrušeno od {email}",
+ "Unshared from {email} by {actor}" : "{actor} zrušil(a) sdílení od {email}",
"Password for mail share sent to %1$s" : "Heslo e-mailového sdílení odesláno na %1$s",
"Password for mail share sent to {email}" : "Heslo e-mailového sdílení odesláno na {email}",
"Password for mail share sent to you" : "Heslo e-mailového sdílení vám bylo zasláno",
@@ -12,6 +14,8 @@ OC.L10N.register(
"You shared {file} with {email} by mail" : "E-mailem jste s {email} sdíleli {file}",
"%3$s shared %1$s with %2$s by mail" : "%3$s s %2$s sdílel e-mailem %1$s",
"{actor} shared {file} with {email} by mail" : "{actor} sdílel(a) {file} e-mailem s {email}",
+ "You unshared %1$s from %2$s by mail" : "Přestali jste sdílet %1$s od %2$s po e-mailu",
+ "You unshared {file} from {email} by mail" : "Zrušili jste sdílení {file} z {email} e-mailem",
"Password to access %1$s was sent to %2s" : "Heslo pro přístupu k %1$s bylo zasláno na %2s",
"Password to access {file} was sent to {email}" : "Heslo pro přístup k {file} bylo zasláno na {email}",
"Password to access %1$s was sent to you" : "Heslo pro přístup k %1$s vám bylo zasláno",
diff --git a/apps/sharebymail/l10n/cs.json b/apps/sharebymail/l10n/cs.json
index c1794e8044b..98208b52b8c 100644
--- a/apps/sharebymail/l10n/cs.json
+++ b/apps/sharebymail/l10n/cs.json
@@ -3,6 +3,8 @@
"Shared with {email}" : "Sdíleno s {email}",
"Shared with %1$s by %2$s" : "%2$s sdílí s %1$s",
"Shared with {email} by {actor}" : "{actor} sdílí s {email}",
+ "Unshared from {email}" : "Sdílení zrušeno od {email}",
+ "Unshared from {email} by {actor}" : "{actor} zrušil(a) sdílení od {email}",
"Password for mail share sent to %1$s" : "Heslo e-mailového sdílení odesláno na %1$s",
"Password for mail share sent to {email}" : "Heslo e-mailového sdílení odesláno na {email}",
"Password for mail share sent to you" : "Heslo e-mailového sdílení vám bylo zasláno",
@@ -10,6 +12,8 @@
"You shared {file} with {email} by mail" : "E-mailem jste s {email} sdíleli {file}",
"%3$s shared %1$s with %2$s by mail" : "%3$s s %2$s sdílel e-mailem %1$s",
"{actor} shared {file} with {email} by mail" : "{actor} sdílel(a) {file} e-mailem s {email}",
+ "You unshared %1$s from %2$s by mail" : "Přestali jste sdílet %1$s od %2$s po e-mailu",
+ "You unshared {file} from {email} by mail" : "Zrušili jste sdílení {file} z {email} e-mailem",
"Password to access %1$s was sent to %2s" : "Heslo pro přístupu k %1$s bylo zasláno na %2s",
"Password to access {file} was sent to {email}" : "Heslo pro přístup k {file} bylo zasláno na {email}",
"Password to access %1$s was sent to you" : "Heslo pro přístup k %1$s vám bylo zasláno",
{ color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php

declare(strict_types=1);

/**
 * @copyright Copyright (c) 2021 Julien Veyssier <eneiluj@posteo.net>
 *
 * @author Julien Veyssier <eneiluj@posteo.net>
 * @author Kate Döen <kate.doeen@nextcloud.com>
 * @author Richard Steinmetz <richard@steinmetz.cloud>
 *
 * @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\Dashboard\Controller;

use OCA\Dashboard\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IAPIWidgetV2;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\IManager;
use OCP\Dashboard\IOptionWidget;
use OCP\Dashboard\IReloadableWidget;
use OCP\Dashboard\IWidget;
use OCP\Dashboard\Model\WidgetButton;
use OCP\Dashboard\Model\WidgetItem;

use OCP\Dashboard\Model\WidgetOptions;
use OCP\IConfig;
use OCP\IRequest;

/**
 * @psalm-import-type DashboardWidget from ResponseDefinitions
 * @psalm-import-type DashboardWidgetItem from ResponseDefinitions
 * @psalm-import-type DashboardWidgetItems from ResponseDefinitions
 */
class DashboardApiController extends OCSController {

	/** @var IManager */
	private $dashboardManager;
	/** @var IConfig */
	private $config;
	/** @var string|null */
	private $userId;

	public function __construct(
		string $appName,
		IRequest $request,
		IManager $dashboardManager,
		IConfig $config,
		?string $userId
	) {
		parent::__construct($appName, $request);

		$this->dashboardManager = $dashboardManager;
		$this->config = $config;
		$this->userId = $userId;
	}

	/**
	 * @param string[] $widgetIds Limit widgets to given ids
	 * @return IWidget[]
	 */
	private function getShownWidgets(array $widgetIds): array {
		if (empty($widgetIds)) {
			$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
			$widgetIds = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault));
		}

		return array_filter(
			$this->dashboardManager->getWidgets(),
			static function (IWidget $widget) use ($widgetIds) {
				return in_array($widget->getId(), $widgetIds);
			},
		);
	}

	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 *
	 * Get the items for the widgets
	 *
	 * @param array<string, string> $sinceIds Array indexed by widget Ids, contains date/id from which we want the new items
	 * @param int $limit Limit number of result items per widget
	 * @param string[] $widgets Limit results to specific widgets
	 * @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItem[]>, array{}>
	 *
	 * 200: Widget items returned
	 */
	public function getWidgetItems(array $sinceIds = [], int $limit = 7, array $widgets = []): DataResponse {
		$items = [];
		$widgets = $this->getShownWidgets($widgets);
		foreach ($widgets as $widget) {
			if ($widget instanceof IAPIWidget) {
				$items[$widget->getId()] = array_map(static function (WidgetItem $item) {
					return $item->jsonSerialize();
				}, $widget->getItems($this->userId, $sinceIds[$widget->getId()] ?? null, $limit));
			}
		}

		return new DataResponse($items);
	}

	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 *
	 * Get the items for the widgets
	 *
	 * @param array<string, string> $sinceIds Array indexed by widget Ids, contains date/id from which we want the new items
	 * @param int $limit Limit number of result items per widget
	 * @param string[] $widgets Limit results to specific widgets
	 * @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItems>, array{}>
	 *
	 * 200: Widget items returned
	 */
	public function getWidgetItemsV2(array $sinceIds = [], int $limit = 7, array $widgets = []): DataResponse {
		$items = [];
		$widgets = $this->getShownWidgets($widgets);
		foreach ($widgets as $widget) {
			if ($widget instanceof IAPIWidgetV2) {
				$items[$widget->getId()] = $widget
					->getItemsV2($this->userId, $sinceIds[$widget->getId()] ?? null, $limit)
					->jsonSerialize();
			}
		}

		return new DataResponse($items);
	}

	/**
	 * Get the widgets
	 *
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 *
	 * @return DataResponse<Http::STATUS_OK, array<string, DashboardWidget>, array{}>
	 *
	 * 200: Widgets returned
	 */
	public function getWidgets(): DataResponse {
		$widgets = $this->dashboardManager->getWidgets();

		$items = array_map(function (IWidget $widget) {
			$options = ($widget instanceof IOptionWidget) ? $widget->getWidgetOptions() : WidgetOptions::getDefault();
			$data = [
				'id' => $widget->getId(),
				'title' => $widget->getTitle(),
				'order' => $widget->getOrder(),
				'icon_class' => $widget->getIconClass(),
				'icon_url' => ($widget instanceof IIconWidget) ? $widget->getIconUrl() : '',
				'widget_url' => $widget->getUrl(),
				'item_icons_round' => $options->withRoundItemIcons(),
				'item_api_versions' => [],
				'reload_interval' => 0,
			];
			if ($widget instanceof IButtonWidget) {
				$data += [
					'buttons' => array_map(function (WidgetButton $button) {
						return [
							'type' => $button->getType(),
							'text' => $button->getText(),
							'link' => $button->getLink(),
						];
					}, $widget->getWidgetButtons($this->userId)),
				];
			}
			if ($widget instanceof IReloadableWidget) {
				$data['reload_interval'] = $widget->getReloadInterval();
			}
			if ($widget instanceof IAPIWidget) {
				$data['item_api_versions'][] = 1;
			}
			if ($widget instanceof IAPIWidgetV2) {
				$data['item_api_versions'][] = 2;
			}
			return $data;
		}, $widgets);

		return new DataResponse($items);
	}
}