You are here

function _privatemsg_action_form in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 privatemsg.pages.inc \_privatemsg_action_form()
  2. 7.2 privatemsg.pages.inc \_privatemsg_action_form()
  3. 7 privatemsg.pages.inc \_privatemsg_action_form()

Returns a form which handles and displays thread actions.

Additional actions can be added with the privatemsg_thread_operations hook. It is also possible to extend this form with additional buttons or other elements, in that case, the definitions in the above hook need no label tag, instead, the submit button key needs to match with the key of the operation.

Return value

The FAPI definitions for the thread action form.

See also

hook_privatemsg_thread_operations()

1 call to _privatemsg_action_form()
privatemsg_list in ./privatemsg.module
List messages.

File

./privatemsg.module, line 2171
Allows users to send private messages to other users.

Code

function _privatemsg_action_form() {
  $form = array(
    '#type' => 'fieldset',
    '#title' => t('Actions'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#weight' => 15,
  );
  if (privatemsg_user_access('delete privatemsg')) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
  }

  // Display all operations which have a label.
  $options = array(
    0 => t('More actions...'),
  );
  foreach (module_invoke_all('privatemsg_thread_operations') as $operation => $array) {
    if (isset($array['label'])) {
      $options[$operation] = $array['label'];
    }
  }
  $form['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 0,
  );
  $form['submit'] = array(
    '#prefix' => '<div class="privatemsg-op-button">',
    '#suffix' => '</div>',
    '#type' => 'submit',
    '#value' => t('Execute'),
    '#submit' => array(
      'privatemsg_list_submit',
    ),
    '#attributes' => array(
      'class' => 'privatemsg-action-button',
    ),
  );

  // JS for hiding the execute button.
  drupal_add_js(drupal_get_path('module', 'privatemsg') . '/privatemsg-list.js');
  return $form;
}