You are here

function og_views_tables in Organic groups 5.2

Same name and namespace in other branches
  1. 5.8 og_views.inc \og_views_tables()
  2. 5 og_views.inc \og_views_tables()
  3. 5.3 og_views.inc \og_views_tables()
  4. 5.7 og_views.inc \og_views_tables()

Implementation of the hook_views_tables()

File

./og_views.inc, line 6

Code

function og_views_tables() {
  $types = variable_get('og_node_types', array(
    'og',
  ));
  foreach ($types as $type) {
    $type_options[$type] = node_get_types('name', $type);
  }
  return array(
    'og' => array(
      'name' => 'og',
      'join' => array(
        'left' => array(
          'table' => 'node',
          'field' => 'nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
      ),
      'fields' => array(
        'description' => array(
          'name' => t('Og: Group: Description'),
        ),
        'website' => array(
          'name' => t('Og: Group: Website'),
          'handler' => 'og_handler_field_website',
        ),
        'count' => array(
          'name' => t('Og: Group: Subscriber Count'),
          'handler' => 'og_handler_field_count',
          'sortable' => FALSE,
          'notafield' => TRUE,
        ),
        'selective' => array(
          'name' => t('Og: Group: Selective'),
        ),
        'subscribe' => array(
          'name' => t('Og: Group: Subscribe Link'),
          'handler' => 'og_handler_field_subscribe',
          'addlfields' => array(
            'selective',
          ),
          'sortable' => FALSE,
          'notafield' => TRUE,
        ),
        'notification' => array(
          'name' => t('Og: Group: Notification'),
          'handler' => 'og_handler_field_yesempty',
          'help' => t('Displays <em>yes</em> if group automatically sends email notifications to subscribers'),
        ),
        'language' => array(
          'name' => t('Og: Group: Language'),
          'help' => t('Displays the language selected for a given group'),
        ),
      ),
      'filters' => array(
        'directory' => array(
          'name' => t('Og: Group: List in directory'),
          'operator' => array(
            '=' => 'Equals',
          ),
          'list' => 'views_handler_operator_yesno',
          'list-type' => 'select',
          'help' => t('Admin specifies whether or not a group appears in the public listings.'),
        ),
      ),
    ),
    'og_ancestry' => array(
      'name' => 'og_ancestry',
      'join' => array(
        'left' => array(
          'table' => 'node',
          'field' => 'nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
      ),
      'filters' => array(
        'gid' => array(
          'name' => t('Og: Post in specified group'),
          'operator' => 'views_handler_operator_eqneq',
          'field' => 'group_nid',
          'help' => t('Filter for a given organic group. <em>Value</em> should be a numeric nid.'),
        ),
        'gtype' => array(
          'name' => t('Og: Post in specified group type'),
          'list' => variable_get('og_node_types', array(
            'og',
          )),
          'list-type' => 'list',
          'operator' => 'views_handler_operator_or',
          'value-type' => 'array',
          'field' => 'group_nid',
          'handler' => 'og_handler_filter_post_og_type',
          'help' => t('Filter for a given organic group type.'),
        ),
      ),
      'fields' => array(
        'is_public' => array(
          'name' => t('Og: Public'),
          'handler' => 'og_handler_field_yesempty',
          'help' => t('Displays <em>yes</em> if post is public according to OG.'),
        ),
      ),
    ),
    'og_node_data' => array(
      'name' => 'node',
      'join' => array(
        'left' => array(
          'table' => 'og_ancestry',
          'field' => 'group_nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
      ),
      'fields' => array(
        'title' => array(
          'name' => t('Og: Group names'),
          'handler' => 'og_handler_field_nodelink',
          'notafield' => TRUE,
          'help' => t('Display links to any groups that are affiliated with a post.'),
        ),
      ),
    ),
    'og_uid' => array(
      'name' => 'og_uid',
      'join' => array(
        'left' => array(
          'table' => 'node',
          'field' => 'nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
        'extra' => array(
          'is_active' => 1,
        ),
      ),
      'fields' => array(
        'mail_type' => array(
          'name' => t('Og: Subscription email'),
          'handler' => 'og_handler_field_yesempty',
          'sortable' => false,
          'help' => t('Does subscriber receive email notifications for a group.'),
        ),
        'managelink' => array(
          'name' => t('Og: Manage subscription link'),
          'handler' => 'og_handler_field_managelink',
          'sortable' => FALSE,
          'notafield' => TRUE,
        ),
        'is_admin' => array(
          'name' => t('Og: Is subscriber an admin in a group'),
          'handler' => 'og_handler_field_yesempty',
          'sortable' => FALSE,
        ),
      ),
      'filters' => array(
        'currentuidsimple' => array(
          'field' => 'uid',
          'name' => t('Og: Group in User Subbed Groups'),
          'operator' => 'views_handler_operator_eqneq',
          'list' => 'views_handler_filter_usercurrent',
          'list-type' => 'select',
          'help' => t('Groups are filtered to where current user is a member .'),
        ),
      ),
    ),
    'og_uid_node' => array(
      'name' => 'og_uid',
      'join' => array(
        'left' => array(
          'table' => 'og_node_data',
          'field' => 'nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
        'extra' => array(
          'is_active' => 1,
        ),
      ),
      'filters' => array(
        'currentuid' => array(
          'field' => 'uid',
          'name' => t('Og: Post in User Subbed Groups'),
          'operator' => 'views_handler_operator_eqneq',
          'list' => 'views_handler_filter_usercurrent',
          'list-type' => 'select',
          'help' => t('Posts are filtered to groups that current user is a member of.'),
        ),
      ),
    ),
    // pseudotable for adding filter on node table and eventually more
    'og_views' => array(
      'name' => 'node',
      'join' => array(
        'left' => array(
          'table' => 'node',
          'field' => 'nid',
        ),
        'right' => array(
          'field' => 'nid',
        ),
      ),
      // here's a filter that is limited to og content types to be used for exposed filters that should not contain other values
      'filters' => array(
        'og_type_selector' => array(
          'field' => 'type_selector',
          'name' => t('OG: type (selector)'),
          'list' => $type_options,
          'list-type' => 'list',
          'operator' => 'views_handler_operator_or',
          'value-type' => 'array',
          'help' => t('A node type selector that is limited to og-enabled node types. Use as exposed filter that only contains og node types.'),
        ),
        'og_type' => array(
          'field' => 'type',
          'name' => t('OG: type'),
          'operator' => array(
            '=' => t('Is'),
          ),
          'list' => array(
            'a group node',
          ),
          'list-type' => 'select',
          'handler' => 'og_handler_filter_og_type',
          'help' => t('Restrict to node types which have been designated behave as groups.'),
        ),
      ),
    ),
  );
}