You are here

function theme_pm_block_user_actions in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 pm_block_user/pm_block_user.admin.inc \theme_pm_block_user_actions()
  2. 6 pm_block_user/pm_block_user.module \theme_pm_block_user_actions()
  3. 7 pm_block_user/pm_block_user.module \theme_pm_block_user_actions()

Theme the user actions form.

Related topics

1 theme call to theme_pm_block_user_actions()
pm_block_user_settings in pm_block_user/pm_block_user.admin.inc
Menu callback for blocked user settings.

File

pm_block_user/pm_block_user.module, line 117
Allows users to block other users from sending them any messages

Code

function theme_pm_block_user_actions($form) {

  // @todo: Something is wrong, remove this hack.
  $form = $form['form'];
  $rows = array();
  $headers = array(
    t('If the author has the role'),
    t('And the recipient has the role'),
    t('Action'),
    t('Enabled'),
    '',
  );
  $form_data = element_children($form);
  foreach ($form_data as $key) {

    // Build the table row.
    $row = array(
      'data' => array(
        array(
          'data' => drupal_render($form[$key]['author']),
        ),
        array(
          'data' => drupal_render($form[$key]['recipient']),
        ),
        array(
          'data' => drupal_render($form[$key]['action']),
        ),
        array(
          'data' => drupal_render($form[$key]['enabled']),
        ),
        array(
          'data' => drupal_render($form[$key]['remove']),
        ),
      ),
    );

    // Add additional attributes to the row, such as a class for this row.
    if (isset($form[$key]['#attributes'])) {
      $row = array_merge($row, $form[$key]['#attributes']);
    }
    $rows[] = $row;
  }

  // If there are no rows, output some instructions for the user.
  if (empty($form_data)) {
    $rows[] = array(
      array(
        'data' => t("No rules have been added. All users may block private messages from each other. To limit which users may be blocked, click 'Add new rule'."),
        'colspan' => '5',
      ),
    );
  }
  $output = theme('table', array(
    'header' => $headers,
    'rows' => $rows,
  ));
  $output .= drupal_render_children($form);
  return $output;
}