diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php new file mode 100755 index 0000000000000000000000000000000000000000..7e7e22578746cede8edc834dede5007e19bbaa0b --- /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 e55f59f6a1c18b93dc74e9f1b5d8559f548f0a36..d450907534beff0451fd7cf169ce3cfb4cf3d88b 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -127,6 +127,9 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('UserCache', function($c) { return new UserCache(); }); + $this->registerService('ActivityManager', function($c) { + return new ActivityManager(); + }); } /** @@ -289,4 +292,12 @@ class Server extends SimpleContainer implements IServerContainer { 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 0000000000000000000000000000000000000000..ca9bd5096b38552c9dec89419ca6424a11cc3a2a --- /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 0000000000000000000000000000000000000000..99ac2a1958edbb6ba2efd301e2084396d7014b95 --- /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 3afb2b6599d37a101116af13b387a4f59ed0081f..cc9436a75c8237d974ba8579d0903831233ef082 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -132,6 +132,13 @@ interface IServerContainer { */ function getSession(); + /** + * Returns the activity manager + * + * @return \OCP\Activity\IManager + */ + function getActivityManager(); + /** * Returns the current session * diff --git a/lib/public/share.php b/lib/public/share.php index 59150e1964fbba857625bbac7f4594508879961b..dce3c2211b14963b6129ecab9e5e73ee0af051db 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1475,6 +1475,7 @@ class Share { 'id' => $parent, 'token' => $token )); + if ($parentFolder === true) { // Return parent folders to preserve file target paths for potential children return $parentFolders;