flag_handler_filter_flagged.inc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @file
  4. * Contains the flagged content filter handler.
  5. */
  6. /**
  7. * Handler to filter for content that has not been flagged.
  8. *
  9. * @ingroup views
  10. */
  11. class flag_handler_filter_flagged extends views_handler_filter_boolean_operator {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['value'] = array('default' => 1);
  15. return $options;
  16. }
  17. function options_form(&$form, &$form_state) {
  18. parent::options_form($form, $form_state);
  19. $form['value']['#type'] = 'radios';
  20. $form['value']['#title'] = t('Status');
  21. $form['value']['#options'] = array(
  22. 1 => t('Flagged'),
  23. 0 => t('Not flagged'),
  24. 'All' => t('All'),
  25. );
  26. $form['value']['#default_value'] = empty($this->options['value']) ? '0' : $this->options['value'];
  27. $form['value']['#description'] = '<p>' . t('This filter is only needed if the relationship used has the "Include only flagged content" option <strong>unchecked</strong>. Otherwise, this filter is useless, because all records are already limited to flagged content.') . '</p><p>' . t('By choosing <em>Not flagged</em>, it is possible to create a list of content <a href="@unflagged-url">that is specifically not flagged</a>.', array('@unflagged-url' => 'http://drupal.org/node/299335')) . '</p>';
  28. }
  29. function query() {
  30. $operator = $this->value ? 'IS NOT' : 'IS';
  31. $this->query->add_where($this->options['group'], $this->relationship . '.uid', NULL, $operator . ' NULL');
  32. }
  33. }