git subrepo commit (merge) mailcow/src/mailcow-dockerized
subrepo: subdir: "mailcow/src/mailcow-dockerized"
merged: "02ae5285"
upstream: origin: "https://github.com/mailcow/mailcow-dockerized.git"
branch: "master"
commit: "649a5c01"
git-subrepo: version: "0.4.3"
origin: "???"
commit: "???"
Change-Id: I870ad468fba026cc5abf3c5699ed1e12ff28b32b
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/AbstractPaginator.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/AbstractPaginator.php
new file mode 100644
index 0000000..3dfd3f1
--- /dev/null
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/AbstractPaginator.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace LdapRecord\Query\Pagination;
+
+use LdapRecord\LdapInterface;
+use LdapRecord\Query\Builder;
+
+abstract class AbstractPaginator
+{
+ /**
+ * The query builder instance.
+ *
+ * @var Builder
+ */
+ protected $query;
+
+ /**
+ * The filter to execute.
+ *
+ * @var string
+ */
+ protected $filter;
+
+ /**
+ * The amount of objects to fetch per page.
+ *
+ * @var int
+ */
+ protected $perPage;
+
+ /**
+ * Whether the operation is critical.
+ *
+ * @var bool
+ */
+ protected $isCritical;
+
+ /**
+ * Constructor.
+ *
+ * @param Builder $query
+ */
+ public function __construct(Builder $query, $filter, $perPage, $isCritical)
+ {
+ $this->query = $query;
+ $this->filter = $filter;
+ $this->perPage = $perPage;
+ $this->isCritical = $isCritical;
+ }
+
+ /**
+ * Execute the pagination request.
+ *
+ * @param LdapInterface $ldap
+ *
+ * @return array
+ */
+ public function execute(LdapInterface $ldap)
+ {
+ $pages = [];
+
+ $this->prepareServerControls();
+
+ do {
+ $this->applyServerControls($ldap);
+
+ if (! $resource = $this->query->run($this->filter)) {
+ break;
+ }
+
+ $this->updateServerControls($ldap, $resource);
+
+ $pages[] = $this->query->parse($resource);
+ } while (! empty($this->fetchCookie()));
+
+ $this->resetServerControls($ldap);
+
+ return $pages;
+ }
+
+ /**
+ * Fetch the pagination cookie.
+ *
+ * @return string
+ */
+ abstract protected function fetchCookie();
+
+ /**
+ * Prepare the server controls before executing the pagination request.
+ *
+ * @return void
+ */
+ abstract protected function prepareServerControls();
+
+ /**
+ * Apply the server controls.
+ *
+ * @param LdapInterface $ldap
+ *
+ * @return void
+ */
+ abstract protected function applyServerControls(LdapInterface $ldap);
+
+ /**
+ * Reset the server controls.
+ *
+ * @param LdapInterface $ldap
+ *
+ * @return mixed
+ */
+ abstract protected function resetServerControls(LdapInterface $ldap);
+
+ /**
+ * Update the server controls.
+ *
+ * @param LdapInterface $ldap
+ * @param resource $resource
+ *
+ * @return void
+ */
+ abstract protected function updateServerControls(LdapInterface $ldap, $resource);
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/DeprecatedPaginator.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/DeprecatedPaginator.php
new file mode 100644
index 0000000..b4a7f8d
--- /dev/null
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/DeprecatedPaginator.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace LdapRecord\Query\Pagination;
+
+use LdapRecord\LdapInterface;
+
+/**
+ * @deprecated since v2.5.0
+ */
+class DeprecatedPaginator extends AbstractPaginator
+{
+ /**
+ * The pagination cookie.
+ *
+ * @var string
+ */
+ protected $cookie = '';
+
+ /**
+ * @inheritdoc
+ */
+ protected function fetchCookie()
+ {
+ return $this->cookie;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function prepareServerControls()
+ {
+ $this->cookie = '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function applyServerControls(LdapInterface $ldap)
+ {
+ $ldap->controlPagedResult($this->perPage, $this->isCritical, $this->cookie);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function updateServerControls(LdapInterface $ldap, $resource)
+ {
+ $ldap->controlPagedResultResponse($resource, $this->cookie);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function resetServerControls(LdapInterface $ldap)
+ {
+ $ldap->controlPagedResult();
+ }
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/LazyPaginator.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/LazyPaginator.php
new file mode 100644
index 0000000..2974b8f
--- /dev/null
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/LazyPaginator.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace LdapRecord\Query\Pagination;
+
+use LdapRecord\LdapInterface;
+
+class LazyPaginator extends Paginator
+{
+ /**
+ * Execute the pagination request.
+ *
+ * @param LdapInterface $ldap
+ *
+ * @return Generator
+ */
+ public function execute(LdapInterface $ldap)
+ {
+ $this->prepareServerControls();
+
+ do {
+ $this->applyServerControls($ldap);
+
+ if (! $resource = $this->query->run($this->filter)) {
+ break;
+ }
+
+ $this->updateServerControls($ldap, $resource);
+
+ yield $this->query->parse($resource);
+ } while (! empty($this->fetchCookie()));
+
+ $this->resetServerControls($ldap);
+ }
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/Paginator.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/Paginator.php
new file mode 100644
index 0000000..9ab6e67
--- /dev/null
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/directorytree/ldaprecord/src/Query/Pagination/Paginator.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace LdapRecord\Query\Pagination;
+
+use LdapRecord\LdapInterface;
+
+class Paginator extends AbstractPaginator
+{
+ /**
+ * @inheritdoc
+ */
+ protected function fetchCookie()
+ {
+ return $this->query->controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? null;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function prepareServerControls()
+ {
+ $this->query->addControl(LDAP_CONTROL_PAGEDRESULTS, $this->isCritical, [
+ 'size' => $this->perPage, 'cookie' => '',
+ ]);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function applyServerControls(LdapInterface $ldap)
+ {
+ $ldap->setOption(LDAP_OPT_SERVER_CONTROLS, $this->query->controls);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function updateServerControls(LdapInterface $ldap, $resource)
+ {
+ $errorCode = $dn = $errorMessage = $refs = null;
+
+ $ldap->parseResult(
+ $resource,
+ $errorCode,
+ $dn,
+ $errorMessage,
+ $refs,
+ $this->query->controls
+ );
+
+ $this->resetPageSize();
+ }
+
+ /**
+ * Reset the page control page size.
+ *
+ * @return void
+ */
+ protected function resetPageSize()
+ {
+ $this->query->controls[LDAP_CONTROL_PAGEDRESULTS]['value']['size'] = $this->perPage;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function resetServerControls(LdapInterface $ldap)
+ {
+ $this->query->controls = [];
+ }
+}