Merge pull request #5249 from owncloud/activities-api
[OC6] Activities api
This commit is contained in:
commit
408e0022dd
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -132,6 +132,13 @@ interface IServerContainer {
|
|||
*/
|
||||
function getSession();
|
||||
|
||||
/**
|
||||
* Returns the activity manager
|
||||
*
|
||||
* @return \OCP\Activity\IManager
|
||||
*/
|
||||
function getActivityManager();
|
||||
|
||||
/**
|
||||
* Returns the current session
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue