You are here

function flag_handler_relationship_content::options_form in Flag 7.2

Same name and namespace in other branches
  1. 6.2 includes/flag_handler_relationships.inc \flag_handler_relationship_content::options_form()
  2. 6 includes/flag_handler_relationships.inc \flag_handler_relationship_content::options_form()
  3. 7.3 includes/views/flag_handler_relationships.inc \flag_handler_relationship_content::options_form()

Provide the label widget that all fields should have.

Overrides views_handler_relationship::options_form

File

includes/flag_handler_relationships.inc, line 92
Contains various relationship handlers.

Class

flag_handler_relationship_content
Specialized relationship handler associating flags and content.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $content_type = $this->definition['flag type'];
  $form['label']['#description'] .= ' ' . t('The name of the selected flag makes a good label.');
  $form['flag'] = flag_views_flag_config_form('radios', $content_type, $this->options['flag']);
  $form['user_scope'] = array(
    '#type' => 'radios',
    '#title' => t('By'),
    '#options' => array(
      'current' => t('Current user'),
      'any' => t('Any user'),
    ),
    '#default_value' => $this->options['user_scope'],
  );
  $form['required']['#title'] = t('Include only flagged content');
  $form['required']['#description'] = t('If checked, only content that has this flag will be included. Leave unchecked to include all content; or, in combination with the <em>Flagged</em> filter, <a href="@unflagged-url">to limit the results to specifically unflagged content</a>.', array(
    '@unflagged-url' => 'http://drupal.org/node/299335',
  ));
  if (!$form['flag']['#options']) {
    $form = array(
      'error' => array(
        '#markup' => '<p class="error form-item">' . t('No %type flags exist. You must first <a href="@create-url">create a %type flag</a> before being able to use this relationship type.', array(
          '%type' => $content_type,
          '@create-url' => url(FLAG_ADMIN_PATH),
        )) . '</p>',
      ),
    );
    $form_state['no flags exist'] = TRUE;
  }
  if (module_exists('session_api')) {
    $form['session_warning'] = array(
      '#markup' => '<p class="warning form-item">' . t('<strong>Warning</strong>: Adding this relationship for any flag that contains <strong>anonymous flagging access</strong> will disable page caching for anonymous users when this view is executed. (But this is only true when the relationship is constrained to "Current user", not to "Any user".) It is recommended to create a dedicated page for views containing anonymous user data.') . '</p>',
    );
  }
}