summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/private/activitymanager.php69
-rw-r--r--lib/private/server.php12
-rw-r--r--lib/public/activity/iconsumer.php42
-rw-r--r--lib/public/activity/imanager.php54
-rw-r--r--lib/public/iservercontainer.php7
-rw-r--r--lib/public/share.php5
6 files changed, 189 insertions, 0 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php
new file mode 100755
index 00000000000..7e7e2257874
--- /dev/null
+++ b/lib/private/activitymanager.php
@@ -0,0 +1,69 @@
+<?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;
+use OCP\Activity\IManager;
+
+class ActivityManager implements IManager {
+
+ private $consumers = array();
+
+ /**
+ * @param $app
+ * @param $subject
+ * @param $subjectParams
+ * @param $message
+ * @param $messageParams
+ * @param $file
+ * @param $link
+ * @param $affectedUser
+ * @param $type
+ * @param $priority
+ * @return mixed
+ */
+ function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) {
+ foreach($this->consumers as $consumer) {
+ $c = $consumer();
+ if ($c instanceof IConsumer) {
+ try {
+ $c->receive(
+ $app,
+ $subject,
+ $subjectParams,
+ $message,
+ $messageParams,
+ $file,
+ $link,
+ $affectedUser,
+ $type,
+ $priority);
+ } catch (\Exception $ex) {
+ // TODO: log the excepetion
+ }
+ }
+
+ }
+ }
+
+ /**
+ * 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/private/server.php b/lib/private/server.php
index 73a0cbd6ce6..7f86919f845 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -129,6 +129,9 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('UserCache', function($c) {
return new UserCache();
});
+ $this->registerService('ActivityManager', function($c) {
+ return new ActivityManager();
+ });
}
/**
@@ -290,4 +293,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');
+ }
}
diff --git a/lib/public/activity/iconsumer.php b/lib/public/activity/iconsumer.php
new file mode 100644
index 00000000000..ca9bd5096b3
--- /dev/null
+++ b/lib/public/activity/iconsumer.php
@@ -0,0 +1,42 @@
+<?php
+ /**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\Activity;
+
+interface IConsumer {
+ /**
+ * @param $app
+ * @param $subject
+ * @param $subjectParams
+ * @param $message
+ * @param $messageParams
+ * @param $file
+ * @param $link
+ * @param $affectedUser
+ * @param $type
+ * @param $priority
+ * @return mixed
+ */
+ function receive($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority );
+}
+
diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php
new file mode 100644
index 00000000000..99ac2a1958e
--- /dev/null
+++ b/lib/public/activity/imanager.php
@@ -0,0 +1,54 @@
+<?php
+ /**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\Activity;
+
+interface IManager {
+
+ /**
+ * @param $app
+ * @param $subject
+ * @param $subjectParams
+ * @param $message
+ * @param $messageParams
+ * @param $file
+ * @param $link
+ * @param $affectedUser
+ * @param $type
+ * @param $priority
+ * @return mixed
+ */
+ function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority);
+
+ /**
+ * 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);
+
+}
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index 3afb2b6599d..cc9436a75c8 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -133,6 +133,13 @@ interface IServerContainer {
function getSession();
/**
+ * Returns the activity manager
+ *
+ * @return \OCP\Activity\IManager
+ */
+ function getActivityManager();
+
+ /**
* Returns the current session
*
* @return \OCP\IDBConnection
diff --git a/lib/public/share.php b/lib/public/share.php
index 66605dafee5..b2873d22f43 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -1472,6 +1472,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;