diff --git a/lib/activitymanager.php b/lib/activitymanager.php new file mode 100755 index 0000000000..c1338d873f --- /dev/null +++ b/lib/activitymanager.php @@ -0,0 +1,48 @@ +consumers as $consumer) { + $c = $consumer(); + if ($c instanceof IConsumer) { + $c->receive($app, $subject, $message, $file, $link); + } + + } + } + + /** + * In order to improve lazy loading a closure can be registered which will be called in case + * activity consumers are actually requested + * + * $callable has to return an instance of OCA\Activity\IConsumer + * + * @param string $key + * @param \Closure $callable + */ + function registerConsumer(\Closure $callable) { + array_push($this->consumers, $callable); + } +} diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php index da7e9d4b66..9cba2db7e7 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -25,6 +25,14 @@ namespace OCP\Activity; interface IManager { + /** + * @param $app + * @param $subject + * @param $message + * @param $file + * @param $link + * @return mixed + */ function publishActivity($app, $subject, $message, $file, $link); /** diff --git a/lib/public/share.php b/lib/public/share.php index 6c5783f117..ff11aad1a1 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1400,6 +1400,11 @@ class Share { 'id' => $parent, 'token' => $token )); + + // hook up activity manager + $subject = 'Something has been shared'; + \OC::$server->getActivityManager()->publishActivity('files_sharing', $subject, '', '', ''); + if ($parentFolder === true) { // Return parent folders to preserve file target paths for potential children return $parentFolders; diff --git a/lib/server.php b/lib/server.php index cabb15324e..b14b2e17d0 100644 --- a/lib/server.php +++ b/lib/server.php @@ -114,6 +114,9 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('UserCache', function($c) { return new UserCache(); }); + $this->registerService('ActivityManager', function($c) { + return new ActivityManager(); + }); } /** @@ -252,4 +255,13 @@ class Server extends SimpleContainer implements IServerContainer { function getDatabaseConnection() { return \OC_DB::getConnection(); } + + /** + * Returns the activity manager + * + * @return \OCP\Activity\IManager + */ + function getActivityManager() { + return $this->query('ActivityManager'); + } }