function profile_views_data

Implements hook_views_data().

File

modules/profile.views.inc, line 13

Code

function profile_views_data() {
    $data['profile_values']['moved to'] = 'profile_value';
    // Define the base group of this table. Fields that don't have a group
    // defined will go into this field by default.
    $data['profile_value']['table']['group'] = t('Profile');
    $data['profile_value']['table']['join'] = array(
        'node' => array(
            'left_table' => 'profile_value',
            'left_field' => 'uid',
            'field' => 'uid',
        ),
        'users' => array(
            'left_table' => 'profile_value',
            'left_field' => 'uid',
            'field' => 'uid',
        ),
    );
    $fields = profile_views_get_fields();
    foreach ($fields as $field) {
        $table_name = 'profile_value_' . str_replace('-', '_', $field->name);
        $data[$table_name] = array(
            'table' => array(
                'group' => t('Profile'),
                'join' => array(
                    'node' => array(
                        'table' => 'profile_value',
                        'left_table' => 'users',
                        'left_field' => 'uid',
                        'field' => 'uid',
                        'extra' => array(
                            array(
                                'field' => 'fid',
                                'value' => $field->fid,
                            ),
                        ),
                    ),
                    'users' => array(
                        'table' => 'profile_value',
                        'left_field' => 'uid',
                        'field' => 'uid',
                        'extra' => array(
                            array(
                                'field' => 'fid',
                                'value' => $field->fid,
                            ),
                        ),
                    ),
                ),
            ),
        );
        // All fields in the table are named 'value'.
        $data[$table_name]['value'] = profile_views_fetch_field($field);
    }
    return $data;
}