diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-08-11 11:24:27 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-08-11 11:24:27 +0200 |
commit | acd54fbeda9dae0fa43291a9c190226ccd306503 (patch) | |
tree | 468a3b1c9ee56b0c8249fbbc855036fc1dceb529 /apps/files/lib | |
parent | 669d705792b9acdb5687ece5d8d358b71609e360 (diff) | |
parent | a1037f1679a53954a1385481dc30d37a8413b179 (diff) | |
download | nextcloud-server-acd54fbeda9dae0fa43291a9c190226ccd306503.tar.gz nextcloud-server-acd54fbeda9dae0fa43291a9c190226ccd306503.zip |
Merge pull request #16528 from owncloud/activity-302-improve-settings
Activity 302 improve settings
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/activity.php | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/apps/files/lib/activity.php b/apps/files/lib/activity.php index fff49ea4ea5..44b051248b5 100644 --- a/apps/files/lib/activity.php +++ b/apps/files/lib/activity.php @@ -30,6 +30,7 @@ use OCP\IL10N; use OCP\IURLGenerator; class Activity implements IExtension { + const APP_FILES = 'files'; const FILTER_FILES = 'files'; const FILTER_FAVORITES = 'files_favorites'; @@ -78,7 +79,7 @@ class Activity implements IExtension { * @return IL10N */ protected function getL10N($languageCode = null) { - return $this->languageFactory->get('files', $languageCode); + return $this->languageFactory->get(self::APP_FILES, $languageCode); } /** @@ -86,14 +87,21 @@ class Activity implements IExtension { * If no additional types are to be added false is to be returned * * @param string $languageCode - * @return array|false + * @return array|false Array "stringID of the type" => "translated string description for the setting" + * or Array "stringID of the type" => [ + * 'desc' => "translated string description for the setting" + * 'methods' => [self::METHOD_*], + * ] */ public function getNotificationTypes($languageCode) { $l = $this->getL10N($languageCode); return [ self::TYPE_SHARE_CREATED => (string) $l->t('A new file or folder has been <strong>created</strong>'), self::TYPE_SHARE_CHANGED => (string) $l->t('A file or folder has been <strong>changed</strong>'), - self::TYPE_FAVORITES => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'), + self::TYPE_FAVORITES => [ + 'desc' => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'), + 'methods' => [self::METHOD_STREAM], + ], self::TYPE_SHARE_DELETED => (string) $l->t('A file or folder has been <strong>deleted</strong>'), self::TYPE_SHARE_RESTORED => (string) $l->t('A file or folder has been <strong>restored</strong>'), ]; @@ -107,7 +115,7 @@ class Activity implements IExtension { * @return array|false */ public function getDefaultTypes($method) { - if ($method === 'stream') { + if ($method === self::METHOD_STREAM) { $settings = array(); $settings[] = self::TYPE_SHARE_CREATED; $settings[] = self::TYPE_SHARE_CHANGED; @@ -132,7 +140,7 @@ class Activity implements IExtension { * @return string|false */ public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) { - if ($app !== 'files') { + if ($app !== self::APP_FILES) { return false; } @@ -173,7 +181,7 @@ class Activity implements IExtension { * @return array|false */ function getSpecialParameterList($app, $text) { - if ($app === 'files') { + if ($app === self::APP_FILES) { switch ($text) { case 'created_self': case 'created_by': @@ -223,7 +231,7 @@ class Activity implements IExtension { * @return integer|false */ public function getGroupParameter($activity) { - if ($activity['app'] === 'files') { + if ($activity['app'] === self::APP_FILES) { switch ($activity['subject']) { case 'created_self': case 'created_by': @@ -309,7 +317,7 @@ class Activity implements IExtension { $user = $this->activityManager->getCurrentUserId(); // Display actions from all files if ($filter === self::FILTER_FILES) { - return ['`app` = ?', ['files']]; + return ['`app` = ?', [self::APP_FILES]]; } if (!$user) { @@ -323,7 +331,7 @@ class Activity implements IExtension { $favorites = $this->helper->getFavoriteFilePaths($user); } catch (\RuntimeException $e) { // Too many favorites, can not put them into one query anymore... - return ['`app` = ?', ['files']]; + return ['`app` = ?', [self::APP_FILES]]; } /* @@ -331,7 +339,7 @@ class Activity implements IExtension { * or `file` is a favorite or in a favorite folder */ $parameters = $fileQueryList = []; - $parameters[] = 'files'; + $parameters[] = self::APP_FILES; $fileQueryList[] = '(`type` <> ? AND `type` <> ?)'; $parameters[] = self::TYPE_SHARE_CREATED; @@ -346,7 +354,7 @@ class Activity implements IExtension { $parameters[] = $favorite . '/%'; } - $parameters[] = 'files'; + $parameters[] = self::APP_FILES; return [ ' CASE WHEN `app` = ? THEN (' . implode(' OR ', $fileQueryList) . ') ELSE `app` <> ? END ', @@ -363,6 +371,6 @@ class Activity implements IExtension { * @return bool */ protected function userSettingFavoritesOnly($user) { - return (bool) $this->config->getUserValue($user, 'activity', 'notify_stream_' . self::TYPE_FAVORITES, false); + return (bool) $this->config->getUserValue($user, 'activity', 'notify_' . self::METHOD_STREAM . '_' . self::TYPE_FAVORITES, false); } } |