From b768a70616eade852fb1eec43dc3fa5095bf4bf7 Mon Sep 17 00:00:00 2001
From: Joas Schilling <nickvergessen@gmx.de>
Date: Fri, 13 Feb 2015 11:30:36 +0100
Subject: [PATCH] Use filterNotificationTypes to filter the types and group the
 methods

---
 apps/files_sharing/lib/activity.php | 80 +++++++++++++----------------
 1 file changed, 37 insertions(+), 43 deletions(-)

diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index be1bf4b670f..0cd874d69f0 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -83,22 +83,6 @@ class Activity implements IExtension {
 		);
 	}
 
-	/**
-	 * The extension can filter the types based on the filter if required.
-	 * In case no filter is to be applied false is to be returned unchanged.
-	 *
-	 * @param array $types
-	 * @param string $filter
-	 * @return array|false
-	 */
-	public function filterNotificationTypes($types, $filter) {
-		switch ($filter) {
-			case self::FILTER_SHARES:
-				return array_intersect([self::TYPE_SHARED], $types);
-		}
-		return false;
-	}
-
 	/**
 	 * For a given method additional types to be displayed in the settings can be returned.
 	 * In case no additional types are to be added false is to be returned.
@@ -119,6 +103,25 @@ class Activity implements IExtension {
 		return $defaultTypes;
 	}
 
+	/**
+	 * A string naming the css class for the icon to be used can be returned.
+	 * If no icon is known for the given type false is to be returned.
+	 *
+	 * @param string $type
+	 * @return string|false
+	 */
+	public function getTypeIcon($type) {
+		switch ($type) {
+			case self::TYPE_SHARED:
+			case self::TYPE_REMOTE_SHARE:
+				return 'icon-share';
+			case self::TYPE_PUBLIC_LINKS:
+				return 'icon-download';
+		}
+
+		return false;
+	}
+
 	/**
 	 * The extension can translate a given message to the requested languages.
 	 * If no translation is available false is to be returned.
@@ -214,25 +217,6 @@ class Activity implements IExtension {
 		return false;
 	}
 
-	/**
-	 * A string naming the css class for the icon to be used can be returned.
-	 * If no icon is known for the given type false is to be returned.
-	 *
-	 * @param string $type
-	 * @return string|false
-	 */
-	public function getTypeIcon($type) {
-		switch ($type) {
-			case self::TYPE_SHARED:
-			case self::TYPE_REMOTE_SHARE:
-				return 'icon-share';
-			case self::TYPE_PUBLIC_LINKS:
-				return 'icon-download';
-		}
-
-		return false;
-	}
-
 	/**
 	 * The extension can define the parameter grouping by returning the index as integer.
 	 * In case no grouping is required false is to be returned.
@@ -275,6 +259,22 @@ class Activity implements IExtension {
 		return $filterValue === self::FILTER_SHARES;
 	}
 
+	/**
+	 * The extension can filter the types based on the filter if required.
+	 * In case no filter is to be applied false is to be returned unchanged.
+	 *
+	 * @param array $types
+	 * @param string $filter
+	 * @return array|false
+	 */
+	public function filterNotificationTypes($types, $filter) {
+		switch ($filter) {
+			case self::FILTER_SHARES:
+				return array_intersect([self::TYPE_SHARED, self::TYPE_REMOTE_SHARE], $types);
+		}
+		return false;
+	}
+
 	/**
 	 * For a given filter the extension can specify the sql query conditions including parameters for that query.
 	 * In case the extension does not know the filter false is to be returned.
@@ -287,14 +287,8 @@ class Activity implements IExtension {
 	public function getQueryForFilter($filter) {
 		if ($filter === self::FILTER_SHARES) {
 			return [
-				'('
-					. '`app` = ? and `type` = ? or '
-					. '`app` = ? and `type` = ?'
-				. ')',
-				[
-					'files_sharing', self::TYPE_REMOTE_SHARE,
-					'files', self::TYPE_SHARED,
-				],
+				'(`app` = ? or `app` = ?)',
+				['files_sharing', 'files'],
 			];
 		}
 		return false;
-- 
GitLab