You are here

function privatemsg_filter_form in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_form()
  2. 7.2 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_form()
  3. 7 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_form()

Form to show and allow modification of tagging information of a conversation.

1 string reference to 'privatemsg_filter_form'
privatemsg_filter_privatemsg_view_messages_alter in privatemsg_filter/privatemsg_filter.module
Hook into the view messages page to add a form for tagging purposes.

File

privatemsg_filter/privatemsg_filter.module, line 671
Allows users to tag private messages and to filter based upon those tags.

Code

function privatemsg_filter_form(&$form_state) {
  global $user;
  $thread_id = arg(2);

  // Get a list of current tags for this thread
  $query = _privatemsg_assemble_query(array(
    'tags',
    'privatemsg_filter',
  ), $user, array(
    $thread_id,
  ));
  $results = db_query($query['query']);
  $count = db_result(db_query($query['count']));
  $tags = '';
  while ($tag = db_fetch_array($results)) {
    $tags .= $tag['tag'] . ', ';
  }
  $form['tags'] = array(
    '#type' => 'fieldset',
    '#title' => t('Tags'),
    '#access' => privatemsg_user_access('tag private messages'),
    '#collapsible' => TRUE,
    '#collapsed' => empty($count) ? TRUE : FALSE,
  );
  $form['tags']['user_id'] = array(
    '#type' => 'value',
    '#value' => $user->uid,
  );
  $form['tags']['thread_id'] = array(
    '#type' => 'value',
    '#value' => $thread_id,
  );
  $form['tags']['tags'] = array(
    '#type' => 'textfield',
    '#title' => t('Tags for this conversation'),
    '#description' => t('Separate multiple tags with commas.'),
    '#size' => 50,
    '#default_value' => $tags,
    '#autocomplete_path' => 'messages/filter/tag-autocomplete',
  );
  $form['tags']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Tag this conversation'),
    '#submit' => array(
      'privatemsg_filter_form_submit',
    ),
  );
  return $form;
}