You are here

class revisioning_handler_filter_node_revision_moderation in Revisioning 6.4

Same name and namespace in other branches
  1. 8 views/revisioning_handler_filter_node_revision_moderation.inc \revisioning_handler_filter_node_revision_moderation
  2. 6.3 views/revisioning_handler_filter_node_revision_moderation.inc \revisioning_handler_filter_node_revision_moderation
  3. 7 views/revisioning_handler_filter_node_revision_moderation.inc \revisioning_handler_filter_node_revision_moderation

Hierarchy

Expanded class hierarchy of revisioning_handler_filter_node_revision_moderation

1 string reference to 'revisioning_handler_filter_node_revision_moderation'
revisioning_views_data_alter in views/revisioning.views.inc
Implementation of hook_views_data_alter().

File

views/revisioning_handler_filter_node_revision_moderation.inc, line 11
Views filter override to filter on whether node is subject to moderation.

View source
class revisioning_handler_filter_node_revision_moderation extends views_handler_filter_in_operator {

  /**
   * Add a where clause to the query.
   */
  function query() {
    if (empty($this->value) || isset($this->value[0]) && isset($this->value[1])) {
      return;

      // don't filter if none or both options are set
    }
    $moderated_content_types = array();
    foreach (revisioning_moderated_content_types() as $moderated_content_type) {
      $moderated_content_types[] = "'{$moderated_content_type}'";
    }
    $this
      ->ensure_my_table();
    if (empty($moderated_content_types)) {
      if (isset($this->value[0]) && $this->value[0] == REVISIONING_MODERATED) {

        // None of the content types are moderated, so return nothing
        $this->query
          ->add_where($this->options['group'], '1 = 0');
      }
    }
    else {
      $where_clause = $this->table_alias . '.type IN (' . implode(',', $moderated_content_types) . ')';
      if (isset($this->value[0]) && $this->value[0] == REVISIONING_NOT_MODERATED) {
        $where_clause = "!({$where_clause})";
      }
      if ($this->operator == 'not in') {
        $where_clause = $where_clause[0] == '!' ? drupal_substr($where_clause, 1) : "!({$where_clause})";
      }
      $this->query
        ->add_where($this->options['group'], $where_clause);
    }
  }
  function get_value_options() {
    $this->value_title = t('Moderated');
    $this->value_options = array(
      REVISIONING_MODERATED => t('Moderated'),
      REVISIONING_NOT_MODERATED => t('Not moderated'),
    );
  }

}

Members