You are here

social_event_enrolments_export.module in Open Social 8.8

The Social Event Enrolments Export module.

File

modules/social_features/social_event/modules/social_event_enrolments_export/social_event_enrolments_export.module
View source
<?php

/**
 * @file
 * The Social Event Enrolments Export module.
 */

/**
 * Implements hook_file_download().
 */
function social_event_enrolments_export_file_download($uri) {
  $scheme = \Drupal::service('file_system')
    ->uriScheme($uri);
  $target = file_uri_target($uri);
  $access = \Drupal::currentUser()
    ->hasPermission('administer users');
  if ($scheme === 'private' && preg_match('/^csv\\/export-enrollments-([a-f0-9]{12})\\.csv$/i', $target) && $access) {
    return [
      'Content-disposition' => 'attachment; filename="' . basename($target) . '"',
    ];
  }
}

/**
 * Implements hook_social_event_action_ACTION_ID_finish().
 */
function social_event_enrolments_export_social_event_managers_action_social_event_enrolments_export_enrollments_action_finish($success) {
  if ($success) {
    return [
      'singular' => '1 selected enrollee has been exported successfully',
      'plural' => '@count selected enrollees have been exported successfully',
    ];
  }
  return [
    'singular' => '1 selected enrollee has not been exported successfully',
    'plural' => '@count selected enrollees have not been exported successfully',
  ];
}