You are here

public function FeedsUserProcessor::rolesListSummaryCallback in Feeds 7.2

Mapping configuration summary callback for target "roles_list".

File

plugins/FeedsUserProcessor.inc, line 480
Contains FeedsUserProcessor.

Class

FeedsUserProcessor
Feeds processor plugin. Create users from feed items.

Code

public function rolesListSummaryCallback(array $mapping, $target, array $form, array $form_state) {
  $options = array();

  // Add in defaults.
  $defaults = $this
    ->rolesListDefaults();
  $mapping += $defaults;
  $mapping['allowed_roles'] += $defaults['allowed_roles'];

  // Role search.
  $role_search_options = $this
    ->rolesListRoleSearchOptions();
  $options[] = t('Search roles by: <strong>@search</strong>', array(
    '@search' => $role_search_options[$mapping['role_search']],
  ));

  // Allowed roles.
  $role_names = array();
  $roles = user_roles(TRUE);
  foreach (array_filter($mapping['allowed_roles']) as $rid => $enabled) {
    $role_names[] = $roles[$rid];
  }
  if (empty($role_names)) {
    $role_names = array(
      '<' . t('none') . '>',
    );
  }
  $options[] = t('Allowed roles: %roles', array(
    '%roles' => implode(', ', $role_names),
  ));

  // Autocreate.
  if ($mapping['autocreate']) {
    $options[] = t('Automatically create roles');
  }
  else {
    $options[] = t('Only assign existing roles');
  }

  // Revoke roles.
  if ($mapping['revoke_roles']) {
    $options[] = t('Revoke roles: yes');
  }
  else {
    $options[] = t('Revoke roles: no');
  }
  return implode('<br />', $options);
}