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@pontapreta.net>2017-03-11 04:40:23 +0300
committerMaxence Lange <maxence@pontapreta.net>2017-03-11 04:40:23 +0300
commitb7c0792545bb5641ea9e0e765e3a9183901b63f9 (patch)
treec2f9314574f7e1a2ea0de6ed0107ce63b32b3ac5 /lib/Api
parent3c4b192c0b670284819b40a483328327a907d714 (diff)
small scrut
Diffstat (limited to 'lib/Api')
-rw-r--r--lib/Api/Sharees.php44
1 files changed, 24 insertions, 20 deletions
diff --git a/lib/Api/Sharees.php b/lib/Api/Sharees.php
index 929d4b65..9689c946 100644
--- a/lib/Api/Sharees.php
+++ b/lib/Api/Sharees.php
@@ -42,6 +42,8 @@ class Sharees {
}
/**
+ * returns circles with
+ *
* @param $search
*
* @return array<string,array>
@@ -52,36 +54,38 @@ class Sharees {
$data = $c->query('CirclesService')
->listCircles(Circle::CIRCLES_ALL, $search, Member::LEVEL_MEMBER);
-
$result = array(
'exact' => ['circles'],
'circles' => []
);
foreach ($data as $entry) {
- if (strtolower($entry->getName()) === strtolower($search)) {
- $result['exact']['circles'][] = [
- 'label' => $entry->getName(),
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_CIRCLE,
- 'circleInfo' => $entry->getInfo(),
- 'shareWith' => $entry->getId()
- ],
- ];
- } else {
- $result['circles'][] = [
- 'label' => $entry->getName(),
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_CIRCLE,
- 'circleInfo' => $entry->getInfo(),
- 'shareWith' => $entry->getId()
- ],
- ];
- }
+ self::addResultEntry(
+ $result, $entry, (strtolower($entry->getName()) === strtolower($search))
+ );
}
return $result;
}
+ private static function addResultEntry(& $result, $entry, $exact = false) {
+
+ $arr = [
+ 'label' => $entry->getName(),
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_CIRCLE,
+ 'circleInfo' => $entry->getInfo(),
+ 'shareWith' => $entry->getId()
+ ],
+ ];
+
+ if ($exact) {
+ $result['exact']['circles'][] = $arr;
+ } else {
+ $result['circles'][] = $arr;
+ }
+
+ }
+
} \ No newline at end of file