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
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2022-11-09 23:10:16 +0300
committerMaxence Lange <maxence@artificial-owl.com>2022-11-10 13:17:23 +0300
commit6b892f4edd9a39117289b211d1c944c39e8795d5 (patch)
tree6d0d3c4739df966e69562c477f013de47269b9b0
parenteb16c2d983bb12c910b9987c111662229a121701 (diff)
fix getChecksum()stable22
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/Model/Probes/CircleProbe.php71
-rw-r--r--lib/Tools/Traits/TDeserialize.php35
2 files changed, 105 insertions, 1 deletions
diff --git a/lib/Model/Probes/CircleProbe.php b/lib/Model/Probes/CircleProbe.php
index 084ebfbe..11006792 100644
--- a/lib/Model/Probes/CircleProbe.php
+++ b/lib/Model/Probes/CircleProbe.php
@@ -49,6 +49,8 @@ class CircleProbe extends MemberProbe {
/** @var bool */
private $includeNonVisible = false;
+ /** @var bool */
+ private $visitSingleCircles = false;
/**
@@ -59,6 +61,8 @@ class CircleProbe extends MemberProbe {
/**
+ * Configure whether personal circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -74,6 +78,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether single circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -89,6 +95,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether system circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -104,6 +112,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether hidden circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -119,6 +129,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether backend circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -134,6 +146,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether non-visible circles are included in the probe
+ *
* @param bool $include
*
* @return $this
@@ -145,6 +159,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Return whether non-visible circles are included in the probe
+ *
* @return bool
*/
public function nonVisibleCirclesIncluded(): bool {
@@ -153,6 +169,31 @@ class CircleProbe extends MemberProbe {
/**
+ * Configure whether single circles are visited in the probe
+ *
+ * @param bool $visit
+ *
+ * @return $this
+ */
+ public function visitSingleCircles(bool $visit = true): self {
+ $this->visitSingleCircles = $visit;
+
+ return $this;
+ }
+
+ /**
+ * Return whether single circles are visited in the probe
+ *
+ * @return bool
+ */
+ public function visitingSingleCircles(): bool {
+ return $this->visitSingleCircles;
+ }
+
+
+ /**
+ * Return the include value
+ *
* @return int
*/
public function included(): int {
@@ -160,6 +201,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Return whether a config is included in the probe (bitwise comparison)
+ *
* @param int $config
*
* @return bool
@@ -170,6 +213,8 @@ class CircleProbe extends MemberProbe {
/**
+ * Configure whether personal circles are filtered in the probe
+ *
* @param bool $filter
*
* @return $this
@@ -185,6 +230,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether single circles are filtered in the probe
+ *
* @param bool $filter
*
* @return $this
@@ -200,6 +247,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether system circles are filtered in the probe
+ *
* @param bool $filter
*
* @return $this
@@ -215,6 +264,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether hidden circles are filtered in the probe
+ *
* @param bool $filter
*
* @return $this
@@ -230,6 +281,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Configure whether backend circles are filtered in the probe
+ *
* @param bool $filter
*
* @return $this
@@ -246,6 +299,8 @@ class CircleProbe extends MemberProbe {
/**
+ * Add a config to the probe filter
+ *
* @param int $config
* @param bool $filter
*
@@ -263,6 +318,8 @@ class CircleProbe extends MemberProbe {
/**
+ * Return the filtered value
+ *
* @return int
*/
public function filtered(): int {
@@ -270,6 +327,8 @@ class CircleProbe extends MemberProbe {
}
/**
+ * Return whether a config is filtered in the probe (bitwise comparison)
+ *
* @param int $config
*
* @return bool
@@ -280,6 +339,8 @@ class CircleProbe extends MemberProbe {
/**
+ * Return an array with includes as options
+ *
* @return array
*/
public function getAsOptions(): array {
@@ -292,6 +353,7 @@ class CircleProbe extends MemberProbe {
'includeSystemCircles' => $this->isIncluded(Circle::CFG_SYSTEM),
'includePersonalCircles' => $this->isIncluded(Circle::CFG_PERSONAL),
'includeNonVisibleCircles' => $this->nonVisibleCirclesIncluded(),
+ 'visitingSingleCircles' => $this->visitingSingleCircles(),
'filtered' => $this->included(),
'filterHiddenCircles' => $this->isIncluded(Circle::CFG_HIDDEN),
'filterSingleCircles' => $this->isIncluded(Circle::CFG_SINGLE),
@@ -305,6 +367,15 @@ class CircleProbe extends MemberProbe {
/**
+ * @return string
+ */
+ public function getChecksum(): string {
+ return md5(json_encode($this->getAsOptions()));
+ }
+
+ /**
+ * Return a JSON object with includes as options
+ *
* @return array
*/
public function JsonSerialize(): array {
diff --git a/lib/Tools/Traits/TDeserialize.php b/lib/Tools/Traits/TDeserialize.php
index e5889945..733b6957 100644
--- a/lib/Tools/Traits/TDeserialize.php
+++ b/lib/Tools/Traits/TDeserialize.php
@@ -80,12 +80,45 @@ trait TDeserialize {
/**
* @param array $data
* @param string $class
+ * @param bool $associative
+ *
+ * @return IDeserializable[]
+ */
+ public function deserializeArray(array $data, string $class, bool $associative = false): array {
+ $arr = [];
+ foreach ($data as $key => $entry) {
+ if (!is_array($entry)) {
+ continue;
+ }
+
+ try {
+ if ($associative) {
+ $arr[$key] = $this->deserialize($entry, $class);
+ } else {
+ $arr[] = $this->deserialize($entry, $class);
+ }
+ } catch (InvalidItemException $e) {
+ }
+ }
+
+ return $arr;
+ }
+
+
+ /**
+ * @param string $json
+ * @param string $class
*
* @return IDeserializable[]
* @throws InvalidItemException
*/
- public function deserializeArray(array $data, string $class): array {
+ public function deserializeList(string $json, string $class): array {
$arr = [];
+ $data = json_decode($json, true);
+ if (!is_array($data)) {
+ return $arr;
+ }
+
foreach ($data as $entry) {
$arr[] = $this->deserialize($entry, $class);
}