You are here

function privatemsg_tags_form in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg_filter/privatemsg_filter.admin.inc \privatemsg_tags_form()
  2. 6 privatemsg_filter/privatemsg_filter.admin.inc \privatemsg_tags_form()
  3. 7.2 privatemsg_filter/privatemsg_filter.admin.inc \privatemsg_tags_form()

A form to edit existing or create new tags.

Parameters

$form_state Form state array:

$tag_id Tag Id if an edit form should be displayed, NULL for a create: new tag form.

1 string reference to 'privatemsg_tags_form'
privatemsg_filter_menu in privatemsg_filter/privatemsg_filter.module
Implements hook_menu().

File

privatemsg_filter/privatemsg_filter.admin.inc, line 68
Admin menu callbacks for privatemsg_filter module.

Code

function privatemsg_tags_form($form, &$form_state, $tag_id = NULL) {
  $form = array();
  if ($tag_id) {
    $tag = db_query('SELECT * from {pm_tags} pmt WHERE pmt.tag_id = :tag_id', array(
      ':tag_id' => $tag_id,
    ))
      ->fetchAssoc();
    $form['tag_id'] = array(
      '#value' => $tag_id,
      '#type' => 'value',
    );
    drupal_set_title(t('Edit @tag', array(
      '@tag' => $tag['tag'],
    )));
  }
  $form['tag'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => empty($tag_id) ? NULL : $tag['tag'],
  );
  $form['public'] = array(
    '#title' => t('Public'),
    '#type' => 'checkbox',
    '#default_value' => empty($tag_id) ? TRUE : $tag['public'],
    '#description' => t('Public tags are visible for all users, private tags are only visible if they use them.'),
  );
  $form['submit'] = array(
    '#value' => empty($tag_id) ? t('Create tag') : t('Save tag'),
    '#type' => 'submit',
  );
  return $form;
}