You are here

course_views_handler_relationship_ce_cr.inc in Course 7.2

File

views/handlers/course_views_handler_relationship_ce_cr.inc
View source
<?php

/**
 * Create a relationship from the course enrollment to course report.
 */
class course_views_handler_relationship_ce_cr extends views_handler_relationship {

  /**
   * 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_course();
    $join->definition = array(
      'table' => 'course_report',
      'field' => 'uid',
      'left_table' => !empty($this->relationship) ? $this->relationship : 'course_enrollment',
      'left_field' => 'uid',
      'extra' => array(
        array(
          'field' => 'nid',
          'value' => 'nid',
          'numeric' => TRUE,
        ),
      ),
    );
    $join
      ->construct();
    if ($this->options['required']) {
      $join->type = 'INNER';
    }
    $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);
  }

}

Classes

Namesort descending Description
course_views_handler_relationship_ce_cr Create a relationship from the course enrollment to course report.