From e28aafa71695c3f709f55740a631815fc707d111 Mon Sep 17 00:00:00 2001 From: Peter Lieverdink Date: Wed, 25 May 2022 16:35:45 +1000 Subject: [PATCH 1/2] [OPS-8323] Use drush command to generate a list of URLs that we want to query ELK for. --- .../src/Commands/IascContentCommands.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php b/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php index 2485d2340..52add6ee8 100644 --- a/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php +++ b/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php @@ -81,4 +81,34 @@ public function archiveBanner() { $this->logger->info("Finished: Archive banner activated for $counter groups."); } + /** + * List all files that are not available for anon download. + * + * @command iasc_content:private-files + * @usage iasc_content:private-files + * Add archive banners to closed groups. + * @validate-module-enabled iasc_content + */ + public function listPrivates() { + + $account = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); + if ($account->id != 0) { + die("Must be anonymous."); + } + + // List of all files. + $query = \Drupal::database()->select('file_managed', 'f'); + $query->distinct(); + $query->fields('f', ['uri']); + $list = $query->execute()->fetchCol(); + + // Use the download hook to check if the anon user can access this file. If not, it's protected! + foreach ($list as $uri) { + $access = iasc_content_file_download($uri); + if ($access === -1) + $url = \Drupal::service('file_url_generator')->generateAbsoluteString($uri); + echo "$url\n"; + } + } + } From 23add04f6caafff1d213fca6268a258254f15abe Mon Sep 17 00:00:00 2001 From: Peter Lieverdink Date: Wed, 25 May 2022 17:41:11 +1000 Subject: [PATCH 2/2] [OPS-8323] Maybe pass some tests eh. --- .../custom/iasc_content/src/Commands/IascContentCommands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php b/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php index 52add6ee8..009a27107 100644 --- a/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php +++ b/html/modules/custom/iasc_content/src/Commands/IascContentCommands.php @@ -81,7 +81,7 @@ public function archiveBanner() { $this->logger->info("Finished: Archive banner activated for $counter groups."); } - /** + /** * List all files that are not available for anon download. * * @command iasc_content:private-files