Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/circles.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Api
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2017-10-09 18:47:21 +0300
committerMaxence Lange <maxence@artificial-owl.com>2017-10-09 18:47:21 +0300
commit7e876f441b4dbf02ea02c579566c8ded8552c9b9 (patch)
tree65a1d42a9314323acabb303e8a3121aad9879a63 /lib/Api
parent797d598aed51943b7fe036ee8f624018280d001e (diff)
specify userId on listCircles()
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Api')
-rw-r--r--lib/Api/Sharees.php5
-rw-r--r--lib/Api/v1/Circles.php37
2 files changed, 37 insertions, 5 deletions
diff --git a/lib/Api/Sharees.php b/lib/Api/Sharees.php
index 6e6b4f97..2755f93c 100644
--- a/lib/Api/Sharees.php
+++ b/lib/Api/Sharees.php
@@ -61,9 +61,12 @@ class Sharees {
// public static function search($search, $limit, $offset) {
public static function search($search) {
$c = self::getContainer();
+ $userId = \OC::$server->getUserSession()
+ ->getUser()
+ ->getUID();
$data = $c->query(CirclesService::class)
- ->listCircles(Circle::CIRCLES_ALL, $search, Member::LEVEL_MEMBER);
+ ->listCircles($userId, Circle::CIRCLES_ALL, $search, Member::LEVEL_MEMBER);
$result = array(
'exact' => ['circles'],
'circles' => []
diff --git a/lib/Api/v1/Circles.php b/lib/Api/v1/Circles.php
index d43c068e..60202849 100644
--- a/lib/Api/v1/Circles.php
+++ b/lib/Api/v1/Circles.php
@@ -164,14 +164,21 @@ class Circles {
* @param mixed $type
* @param string $name
* @param int $level
+ * @param string $userId
*
* @return Circle[]
*/
- public static function listCircles($type, $name = '', $level = 0) {
+ public static function listCircles($type, $name = '', $level = 0, $userId = '') {
$c = self::getContainer();
+ if ($userId === '') {
+ $userId = \OC::$server->getUserSession()
+ ->getUser()
+ ->getUID();
+ }
+
return $c->query(CirclesService::class)
- ->listCircles($type, $name, $level);
+ ->listCircles($userId, $type, $name, $level);
}
@@ -180,10 +187,32 @@ class Circles {
*
* Return all the circle the current user is a member.
*
+ * @param string $userId
+ *
* @return Circle[]
*/
- public static function joinedCircles() {
- return self::listCircles(Circle::CIRCLES_ALL, '', Member::LEVEL_MEMBER);
+ public static function joinedCircles($userId = '') {
+ return self::listCircles(Circle::CIRCLES_ALL, '', Member::LEVEL_MEMBER, $userId);
+ }
+
+
+ /**
+ * Circles::joinedCircleIds();
+ *
+ * Return all the circleIds the user is a member, if empty user, using current user.
+ *
+ * @param $userId
+ *
+ * @return array
+ */
+ public static function joinedCircleIds($userId = '') {
+ $circleIds = [];
+ $circles = self::listCircles(Circle::CIRCLES_ALL, '', Member::LEVEL_MEMBER, $userId);
+ foreach ($circles as $circle) {
+ $circleIds[] = $circle->getUniqueId();
+ }
+
+ return $circleIds;
}