You are here

function user_prune_preview in User Prune 7

Collecting information for preview table.

1 string reference to 'user_prune_preview'
user_prune_form in ./user_prune.module
Implements hook_form().

File

./user_prune.module, line 438
Module API The main module file. Implementing forms and functions.

Code

function user_prune_preview($form, &$form_state) {
  $values = $form_state['values'];

  // Fetch the SQL.
  $sql = user_prune_build_sql($values);
  $result = db_query($sql);
  $rows = array();
  foreach ($result as $row) {
    if ($row->Lastaccess == 0) {
      $rowlastaccess = 'Never';
    }
    else {
      $rowlastaccess = format_date($row->Lastaccess, 'short');
    }
    if ($row->Lastlogin == 0) {
      $rowlastlogin = 'Never';
    }
    else {
      $rowlastlogin = format_date($row->Lastlogin, 'short');
    }
    if ($row->Status == 1) {
      $rowstatus = 'Active';
    }
    else {
      $rowstatus = 'Blocked';
    }
    $rows[] = array(
      $row->uid,
      $row->Name,
      format_date($row->Created, 'short'),
      $rowlastaccess,
      $rowlastlogin,
      $rowstatus,
    );
  }
  variable_set('preview_header', array(
    'User ID',
    'Name',
    'Created',
    'Last access',
    'Last login',
    'Status',
  ));
  variable_set('preview_rows', $rows);
  variable_set('preview_form_values', 1);
  variable_set('user_prune_time_year_preview', $values['user_prune_time_year']);
  variable_set('user_prune_time_month_preview', $values['user_prune_time_month']);
  variable_set('user_prune_time_day_preview', $values['user_prune_time_day']);
  variable_set('user_prune_time_hour_preview', $values['user_prune_time_hour']);
  variable_set('user_prune_time_minute_preview', $values['user_prune_time_minute']);
  variable_set('user_prune_user_status_preview', $values['user_prune_user_status']);
  variable_set('user_prune_cron_checkbox_preview', $values['user_prune_cron_checkbox']);
  variable_set('user_prune_user_roles_checkbox_preview', $values['user_prune_user_roles_checkbox']);
  variable_set('user_prune_no_comment_preview', $values['user_prune_no_comment']);
  variable_set('user_prune_no_node_preview', $values['user_prune_no_node']);
  variable_set('user_prune_cancel_method', $values['user_prune_cancel_method']);
  if (module_exists('subscriptions')) {
    variable_set('user_prune_no_subscriptions_preview', $values['user_prune_no_subscriptions']);
  }
  if (module_exists('og')) {
    variable_set('user_prune_no_og_preview', $values['user_prune_no_og']);
  }
  if (module_exists('entityform')) {
    variable_set('user_prune_no_entityform_preview', $values['user_prune_no_entityform']);
  }
  if (module_exists('tmgmt')) {
    variable_set('user_prune_no_tmgmt_preview', $values['user_prune_no_tmgmt']);
  }
  variable_set('user_prune_prune_per_run_preview', $values['user_prune_prune_per_run']);
  variable_set('user_prune_never_logged_in_preview', $values['user_prune_never_logged_in']);
}