You are here

function advuser_multiple_confirm in Advanced User 5

1 call to advuser_multiple_confirm()
advuser_admin_users_form in ./advuser.module

File

./advuser.module, line 386

Code

function advuser_multiple_confirm($all, $action, $user_func) {
  $edit = $_POST['edit'];
  $form = array();
  $form['users'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );

  // array filter returns only elements with true values
  if ($all) {
    $filter = advuser_admin_user_build_filter_query();
    $result = db_query('SELECT u.* FROM {users} u ' . $filter['join'] . ' LEFT JOIN {profile_values} pv ON u.uid = pv.uid LEFT JOIN {profile_fields} pf on pv.fid = pf.fid ' . $filter['where'] . ' GROUP BY u.uid ' . $filter['having'] . ' ORDER BY u.login DESC', $filter['args']);
    while ($usr = db_fetch_object($result)) {
      $user_array[$usr->uid] = '';
    }
  }
  else {
    $user_array = array_filter($edit['users']);
  }
  foreach ($user_array as $uid => $value) {
    $name = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
    $form['users'][$uid] = array(
      '#type' => 'hidden',
      '#value' => $uid,
      '#prefix' => '<li>',
      '#suffix' => check_plain($name) . "</li>\n",
    );
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => $action,
  );
  if (function_exists($user_func)) {
    $user_func($all, $form);
  }
  $operations = advuser_admin_users_operations();
  return confirm_form($user_func, $form, t('Are you sure you want to update these items?'), 'admin/user/advuser', t('This action cannot be undone.'), $operations[$action][0], t('Cancel'));
}