Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPS-8323] Use drush command to generate a list of URLs that we want to query ELK for. #618

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

}