function pm_block_user_list

7-1 pm_block_user.pages.inc pm_block_user_list()
7-2 pm_block_user.pages.inc pm_block_user_list()
6-2 pm_block_user.pages.inc pm_block_user_list()

Formbuilder function to build a simple form to block users.

2 string references to 'pm_block_user_list'
pm_block_user_menu in pm_block_user/pm_block_user.module
Implements hook_menu().
pm_block_user_theme in pm_block_user/pm_block_user.module
Implements hook_theme().

File

pm_block_user/pm_block_user.pages.inc, line 81
User menu callbacks for pm_block_user.module.

Code

function pm_block_user_list() {
  global $user;

  $form['new'] = array(
    '#type' => 'fieldset',
    '#title' => t('Block a user'),
  );
  $form['new']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#autocomplete_path' => 'messages/user/autocomplete',
    '#description' => t('Separate multiple names with commas.'),
    '#required' => TRUE,
  );
  $form['new']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Block user'),
    '#validate' => array('pm_block_user_block_validate'),
    '#submit' => array('pm_block_user_block_submit'),
  );

  $header = array(array(
      'data' => t('Username'),
      'field' => 'u.name',
      'sort' => 'asc',
    ), array('data' => t('Operations')));

  $select = db_select('pm_block_user', 'pmb')->extend('PagerDefault')->extend('TableSort')->fields('pmb', array('author'))->condition('pmb.recipient', $user->uid)->limit(20)->orderByHeader($header);

  // Only show existing users, therefore join users.
  $select->innerJoin('users', 'u', 'u.uid = pmb.author');

  $rows = array();
  foreach ($select->execute() as $row) {
    $rows[] = array(theme('username', array('account' => user_load($row->author))), l(t('unblock'), 'messages/block/' . $row->author, array('query' => drupal_get_destination())));
  }
  $form['#header'] = $header;
  $form['#rows'] = $rows;
  return $form;
}