Index: content_profile/includes/handler/content_profile_views_handler_relationship.inc
===================================================================
--- content_profile/includes/handler/content_profile_views_handler_relationship.inc	(revision 0)
+++ content_profile/includes/handler/content_profile_views_handler_relationship.inc	(revision 0)
@@ -0,0 +1,55 @@
+<?php 
+// $Id$
+
+/**
+ * Specialized relationship handler to adding content profiles.
+ */
+class content_profile_views_handler_relationship extends views_handler_relationship {
+  function options(&$options) {
+    parent::options($options);
+
+    $options['type'] = '';
+  }
+
+  /**
+   * Adds a form element for choosing the right content type.
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $form['type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Content type'),
+      '#default_value' => $this->options['type'],
+      '#options' => content_profile_get_types('names'),
+      '#required' => TRUE,
+    );
+  }
+
+  /**
+   * Called to implement a relationship in a query.
+   */
+  function query() {
+    // Figure out what base table this relationship brings to the party.
+    $join = new views_join();
+    $join->definition = array(
+      'table' => 'node',
+      'field' => 'uid',
+      'left_table' => 'users',
+      'left_field' => 'uid',
+      'extra' => array(
+        array('field' => 'type', 'value' => $this->options['type']),
+      ),
+    );
+
+    if (!empty($this->options['required'])) {
+      $join->definition['type'] = 'INNER';
+    }
+
+    $join->construct();
+    $this->ensure_my_table();
+
+    $alias = $join->definition['table'] .'_'. $join->definition['left_table'];
+    $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
+  }
+}
Index: content_profile/includes/content_profile.views.inc
===================================================================
--- content_profile/includes/content_profile.views.inc	(revision 0)
+++ content_profile/includes/content_profile.views.inc	(revision 0)
@@ -0,0 +1,42 @@
+<?php
+// $Id: content_profile.views.inc,v 1.1.2.3 2008/07/24 09:57:57 fago Exp $
+
+/**
+ * @file content_profile.views.inc
+ * Provides support for the Views module.
+ */
+
+/**
+ * Implementation of hook_views_data_alter().
+ */
+function content_profile_views_data_alter(&$data) {
+  // node relationship for profiles
+  $data['users']['content_profile_rel'] = array(
+    'group' => t('Node'),
+    'title' => t('Content Profile'),
+    'help' => t('Create a relationship to a content profile of the user.'),
+    'relationship' => array(
+      'handler' => 'content_profile_views_handler_relationship',
+      'base' => 'node',
+      'base field' => 'uid',
+      'label' => t('Content Profile'),
+    ),
+  );
+}
+
+
+/**
+ * Implementation of hook_views_handlers().
+ */
+function content_profile_views_handlers() {
+  return array(
+  'info' => array(
+    'path' => drupal_get_path('module', 'content_profile') .'/includes',
+    ),
+  'handlers' => array(
+    'content_profile_views_handler_relationship' => array(
+     'parent' => 'views_handler_relationship',
+     ),
+    ),
+  );
+}
\ No newline at end of file
Index: content_profile/content_profile.module
===================================================================
--- content_profile/content_profile.module	(revision 5642)
+++ content_profile/content_profile.module	(working copy)
@@ -32,6 +32,16 @@ function content_profile_menu() {
   return $items;
 }
 
+/**
+ * Implementation of hook_views_api().
+ */
+function content_profile_views_api() {
+  return array(
+    'api' => 2,
+    'path' => drupal_get_path('module', 'content_profile') . '/includes'
+  );
+}
+
 
 /**
  * Menu callback; content profile settings.
