Use filterNotificationTypes to filter the types and group the methods

This commit is contained in:
Joas Schilling 2015-02-13 11:30:36 +01:00
parent 9ccfbc14f6
commit b768a70616
1 changed files with 37 additions and 43 deletions

View File

@ -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;