You are here

function commons_trusted_contacts_messages_popup in Drupal Commons 7.3

Menu callback; Write Private Message popup form.

Parameters

$account: The addressee's account.

3 string references to 'commons_trusted_contacts_messages_popup'
commons_origins_preprocess_form in themes/commons/commons_origins/template.php
Implements hook_preprocess_form().
commons_origins_preprocess_form_content in themes/commons/commons_origins/template.php
Implements hook_preprocess_form_content().
commons_trusted_contacts_menu in modules/commons/commons_trusted_contacts/commons_trusted_contacts.module
Implements hook_menu().

File

modules/commons/commons_trusted_contacts/commons_trusted_contacts.module, line 1174

Code

function commons_trusted_contacts_messages_popup($form, &$form_state, $account) {
  global $user;

  // Include original functions.
  module_load_include('inc', 'privatemsg', 'privatemsg.pages');
  $form = privatemsg_new($form, $form_state, $account->uid, 'New private message from ' . $user->name);
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
  );
  $wrapper = entity_metadata_wrapper('user', $account);
  $picture_path = empty($account->picture) ? variable_get('user_picture_default') : $wrapper
    ->value()->picture->uri;
  $form['user_picture'] = array(
    '#theme' => 'image_style',
    '#style_name' => '50x50_avatar',
    '#path' => $picture_path,
    '#prefix' => '<div class="user-picture">',
    '#suffix' => '</div>',
    '#weight' => -50,
  );
  $form['body']['#format'] = 'plain_text';
  unset($form['token']);
  $form['subject']['#type'] = 'hidden';
  $form['recipient']['#type'] = 'hidden';
  drupal_set_title(t('Direct Message @recipient', array(
    '@recipient' => format_username($account),
  )));
  return $form;
}