summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-12-10 15:59:41 +0100
committerVincent Petry <pvince81@owncloud.com>2014-12-11 12:22:28 +0100
commit745d8706b973ff0494af54f183acc0da361f0e83 (patch)
tree33830b5690368c6c1e66a6bf1125635975a2490e /lib
parent5101bc54faea28d1210eb24f72abd76944c83af6 (diff)
downloadnextcloud-server-745d8706b973ff0494af54f183acc0da361f0e83.tar.gz
nextcloud-server-745d8706b973ff0494af54f183acc0da361f0e83.zip
Add user parameter to tag manager
Diffstat (limited to 'lib')
-rw-r--r--lib/private/server.php3
-rw-r--r--lib/private/tagmanager.php22
-rw-r--r--lib/public/itagmanager.php7
3 files changed, 18 insertions, 14 deletions
diff --git a/lib/private/server.php b/lib/private/server.php
index e0105506970..02cc4e2755a 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -87,8 +87,7 @@ class Server extends SimpleContainer implements IServerContainer {
});
$this->registerService('TagManager', function (Server $c) {
$tagMapper = $c->query('TagMapper');
- $user = \OC_User::getUser();
- return new TagManager($tagMapper, $user);
+ return new TagManager($tagMapper, $c->getUserSession());
});
$this->registerService('RootFolder', function (Server $c) {
// TODO: get user and user manager from container as well
diff --git a/lib/private/tagmanager.php b/lib/private/tagmanager.php
index d5bff04acff..6c7eeab87eb 100644
--- a/lib/private/tagmanager.php
+++ b/lib/private/tagmanager.php
@@ -38,11 +38,11 @@ use OC\Tagging\TagMapper;
class TagManager implements \OCP\ITagManager {
/**
- * User
+ * User session
*
- * @var string
+ * @var \OCP\IUserSession
*/
- private $user;
+ private $userSession;
/**
* TagMapper
@@ -55,12 +55,11 @@ class TagManager implements \OCP\ITagManager {
* Constructor.
*
* @param TagMapper $mapper Instance of the TagMapper abstraction layer.
- * @param string $user The user whose data the object will operate on.
+ * @param \OCP\IUserSession $userSession the user session
*/
- public function __construct(TagMapper $mapper, $user) {
-
+ public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) {
$this->mapper = $mapper;
- $this->user = $user;
+ $this->userSession = $userSession;
}
@@ -71,10 +70,15 @@ class TagManager implements \OCP\ITagManager {
* @param string $type The type identifier e.g. 'contact' or 'event'.
* @param array $defaultTags An array of default tags to be used if none are stored.
* @param boolean $includeShared Whether to include tags for items shared with this user by others.
+ * @param string $userId user for which to retrieve the tags, defaults to the currently
+ * logged in user
* @return \OCP\ITags
*/
- public function load($type, $defaultTags=array(), $includeShared=false) {
- return new Tags($this->mapper, $this->user, $type, $defaultTags, $includeShared);
+ public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) {
+ if (is_null($userId)) {
+ $userId = $this->userSession->getUser()->getUId();
+ }
+ return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
}
}
diff --git a/lib/public/itagmanager.php b/lib/public/itagmanager.php
index 54daa5cc1cb..ac80eebc72d 100644
--- a/lib/public/itagmanager.php
+++ b/lib/public/itagmanager.php
@@ -43,14 +43,15 @@ namespace OCP;
interface ITagManager {
/**
- * Create a new \OCP\ITags instance and load tags from db.
+ * Create a new \OCP\ITags instance and load tags from db for the current user.
*
* @see \OCP\ITags
* @param string $type The type identifier e.g. 'contact' or 'event'.
* @param array $defaultTags An array of default tags to be used if none are stored.
* @param boolean $includeShared Whether to include tags for items shared with this user by others.
+ * @param string $userId user for which to retrieve the tags, defaults to the currently
+ * logged in user
* @return \OCP\ITags
*/
- public function load($type, $defaultTags=array(), $includeShared=false);
-
+ public function load($type, $defaultTags = array(), $includeShared = false, $userId = null);
}