I'd like to list all the content posted by the current user's subusers defined by the Subuser module. (The teacher wants to see al his students' content). Using Drupal 6.x and Views 2.x

(The subuser module does not support this, and could not achieve this even with Table Wizard.)

The subuser_relationship table is very straightforward:

* rid // primary key
* parent_id // parent user id
* uid // child uid

Can you help me how to write the necessary mymodule_hook_views_data() function for Views in my module?

This is what I wrote so far, but unsure if it is correct:

$data['subuser_relationship']['table']['join'] = array(
'node' => array(
'field' => 'uid',
'left_table' => 'node',
'left_field' => 'uid',
),

'node' => array(
'field' => 'nid',
'left_table' => 'node',
'left_field' => 'nid',
)

);

I read many topics and Views documentation, but I did not find the detailed information about what to write into this $data array..

Comments

Jb33’s picture

I just found that I only had to add the table relationship into the module like this:

  $data['subuser_relationship']['table']['join']['node'] = array(
      'field' => 'uid',
      'left_field' => 'uid',
    );

This helped me to join it to my query. This table has a field introduced this way:

$data['subuser_relationship']['parent_id'] = array(
    'title' => t('Parent Id'),
    'help' => t('The ID of the Parent User.'),
    'field' => array(
      'handler' => 'views_handler_field_user',
      'click sortable' => TRUE,
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_user_uid',
      'name field' => 'title',
      'numeric' => TRUE,
      'validate type' => 'uid',
    ),
    'relationship' => array(
      'base' => 'users',
      'field' => 'uid',
      'handler' => 'views_handler_relationship',
      'label' => t('Parent'),
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

I read the Views doc over and over but do not understand how to enable filtering this parent_id to be equal to the current user id. Can I put multiple filter entries on this field?