summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/activitymanager.php48
-rw-r--r--lib/public/activity/imanager.php8
-rw-r--r--lib/public/share.php5
-rw-r--r--lib/server.php12
4 files changed, 73 insertions, 0 deletions
diff --git a/lib/activitymanager.php b/lib/activitymanager.php
new file mode 100755
index 00000000000..c1338d873fa
--- /dev/null
+++ b/lib/activitymanager.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller thomas.mueller@tmit.eu
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+namespace OC;
+
+
+use OCP\Activity\IConsumer;
+
+class ActivityManager implements \OCP\Activity\IManager {
+
+ private $consumers = array();
+
+ /**
+ * @param $app
+ * @param $subject
+ * @param $message
+ * @param $file
+ * @param $link
+ * @return mixed
+ */
+ function publishActivity($app, $subject, $message, $file, $link) {
+ foreach($this->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 da7e9d4b662..9cba2db7e7f 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 6c5783f1179..ff11aad1a12 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 cabb15324ec..b14b2e17d03 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');
+ }
}