Commit bfc015f6 authored by Henrique Recidive's avatar Henrique Recidive
Browse files

Issue #776216 by colan, Pedro Lozano, q0rban, phayes: Views integration.

parent 3e563427
Loading
Loading
Loading
Loading
+10 −0
Changes for uuid.module: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -135,6 +135,16 @@ function uuid_node_load($node) {
  }
}

/**
 * Implementation of hook_views_api().
 */
function uuid_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'uuid'),
  );
}

/**
 * Returns the node associated with a UUID. Uses db_rewrite_sql() to ensure
 * node_access rules are preserved.

uuid.views.inc

0 → 100644
+59 −0
Changes for uuid.views.inc: 59 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Views Implementation for UUID.
 */

/**
 * Implementation of hook_views_data().
 */
function uuid_views_data() {
  $data = array();

  module_load_include('install', 'uuid');
  $tables = uuid_schema();

  foreach ($tables as $table => $schema) {
    $base_table = str_replace('uuid_', '', $table);

    $field = array_shift(array_keys($schema['fields']));

    $data[$table]['table'] = array(
      'group' => 'UUID',
      'join' => array(
        $base_table => array(
          'left_field' => $field,
          'field' => $field,
        ),
      )
    );

    $data[$table]['uuid'] = array(
      'title' => t('@table UUID', array('@table' => ucwords($base_table))),
      'help' => t(
        'Universally Unique Identifier for @table objects.',
        array('@table' => ucwords($base_table))
      ),
      'field' => array(
        'handler' => 'views_handler_field',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_string',
        'allow empty' => TRUE,
        'help' => 'Filter on a UUID',
      ),
      'argument' => array(
        'handler' => 'views_handler_argument_string',
        'help' => 'Argument on a UUID',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
        'help' => 'Sort on UUID',
      ),
    );
  }

  return $data;
}