From 280d5325c7ea9cca872b907ffec0eacf35e42f2f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Oct 2016 17:57:44 +0200 Subject: Allow to register activity filters via info.xml Signed-off-by: Joas Schilling --- lib/public/Activity/IExtension.php | 4 +++ lib/public/Activity/IFilter.php | 74 ++++++++++++++++++++++++++++++++++++++ lib/public/Activity/IManager.php | 67 +++++++++++++++++++++++----------- 3 files changed, 124 insertions(+), 21 deletions(-) create mode 100644 lib/public/Activity/IFilter.php (limited to 'lib/public/Activity') diff --git a/lib/public/Activity/IExtension.php b/lib/public/Activity/IExtension.php index aaa4c869561..21d1bd150ac 100644 --- a/lib/public/Activity/IExtension.php +++ b/lib/public/Activity/IExtension.php @@ -129,6 +129,7 @@ interface IExtension { * * @return array|false * @since 8.0.0 + * @deprecated 9.2.0 - Register an IFilter instead */ public function getNavigation(); @@ -138,6 +139,7 @@ interface IExtension { * @param string $filterValue * @return boolean * @since 8.0.0 + * @deprecated 9.2.0 - Register an IFilter instead */ public function isFilterValid($filterValue); @@ -149,6 +151,7 @@ interface IExtension { * @param string $filter * @return array|false * @since 8.0.0 + * @deprecated 9.2.0 - Register an IFilter instead */ public function filterNotificationTypes($types, $filter); @@ -161,6 +164,7 @@ interface IExtension { * @param string $filter * @return array|false * @since 8.0.0 + * @deprecated 9.2.0 - Register an IFilter instead */ public function getQueryForFilter($filter); } diff --git a/lib/public/Activity/IFilter.php b/lib/public/Activity/IFilter.php new file mode 100644 index 00000000000..f3c57c14e97 --- /dev/null +++ b/lib/public/Activity/IFilter.php @@ -0,0 +1,74 @@ + + * @author Morris Jobke + * @author Thomas Müller + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCP\Activity; + +/** + * Interface IFilter + * + * @package OCP\Activity + * @since 9.2.0 + */ +interface IFilter { + + /** + * @return string Lowercase a-z and underscore only identifier + * @since 9.2.0 + */ + public function getIdentifier(); + + /** + * @return string A translated string + * @since 9.2.0 + */ + public function getName(); + + /** + * @return int whether the filter should be rather on the top or bottom of + * the admin section. The filters are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. + * @since 9.2.0 + */ + public function getPriority(); + + /** + * @return string Full URL to an icon, empty string when none is given + * @since 9.2.0 + */ + public function getIcon(); + + /** + * @param string[] $types + * @return string[] An array of allowed apps from which activities should be displayed + * @since 9.2.0 + */ + public function filterTypes(array $types); + + /** + * @return string[] An array of allowed apps from which activities should be displayed + * @since 9.2.0 + */ + public function allowedApps(); +} + diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php index c1476e1a2ae..387a1d85144 100644 --- a/lib/public/Activity/IManager.php +++ b/lib/public/Activity/IManager.php @@ -110,6 +110,27 @@ interface IManager { */ public function registerExtension(\Closure $callable); + /** + * @param string $filter Class must implement OCA\Activity\IFilter + * @return void + * @since 9.2.0 + */ + public function registerFilter($filter); + + /** + * @return IFilter[] + * @since 9.2.0 + */ + public function getFilters(); + + /** + * @param string $id + * @return IFilter + * @throws \InvalidArgumentException when the filter was not found + * @since 9.2.0 + */ + public function getFilterById($id); + /** * Will return additional notification types as specified by other apps * @@ -177,9 +198,31 @@ interface IManager { */ public function getGroupParameter($activity); + + /** + * Set the user we need to use + * + * @param string|null $currentUserId + * @throws \UnexpectedValueException If the user is invalid + * @since 9.0.1 + */ + public function setCurrentUserId($currentUserId); + + /** + * Get the user we need to use + * + * Either the user is logged in, or we try to get it from the token + * + * @return string + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique + * @since 8.1.0 + */ + public function getCurrentUserId(); + /** * @return array * @since 8.0.0 + * @deprecated 9.2.0 - Use getFilters() instead */ public function getNavigation(); @@ -187,6 +230,7 @@ interface IManager { * @param string $filterValue * @return boolean * @since 8.0.0 + * @deprecated 9.2.0 - Use getFilterById() instead */ public function isFilterValid($filterValue); @@ -195,6 +239,7 @@ interface IManager { * @param string $filter * @return array * @since 8.0.0 + * @deprecated 9.2.0 - Use getFilterById()->filterTypes() instead */ public function filterNotificationTypes($types, $filter); @@ -202,27 +247,7 @@ interface IManager { * @param string $filter * @return array * @since 8.0.0 + * @deprecated 9.2.0 - Use getFilterById() instead */ public function getQueryForFilter($filter); - - - /** - * Set the user we need to use - * - * @param string|null $currentUserId - * @throws \UnexpectedValueException If the user is invalid - * @since 9.0.1 - */ - public function setCurrentUserId($currentUserId); - - /** - * Get the user we need to use - * - * Either the user is logged in, or we try to get it from the token - * - * @return string - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique - * @since 8.1.0 - */ - public function getCurrentUserId(); } -- cgit v1.2.3