You are here

protected function HeartbeatActivityController::buildQuery in Heartbeat 7

Implements buildQuery().

Overrides DrupalDefaultEntityController::buildQuery

File

./heartbeat.entity.inc, line 143

Class

HeartbeatActivityController
Controller class for heartbeat activity.

Code

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
  $query = parent::buildQuery($ids, $conditions, $revision_id);
  $query
    ->addTag('translatable');
  $query
    ->addTag('heartbeat_activity_access');
  $query
    ->addField('base', 'variables', 'variables');
  $query
    ->addField('base', 'access', 'access');
  $query
    ->join('users', 'u', 'u.uid = base.uid');

  // Base table fields are automatically create in the parent.

  //$query->fields('base');
  $query
    ->fields('u');

  // Override the permission based on the user profile status.
  $query
    ->leftJoin('heartbeat_user_templates', 'hut', ' base.uid = hut.uid AND base.message_id = hut.message_id ');
  $query
    ->addField('hut', 'status', 'access_status');
  $query
    ->addField('base', 'access', 'access');
  $query
    ->addField('u', 'access', 'users_access');

  // This part is done by base.uaid in ($ids).

  //$query->condition('ha.uaid', $uaid);
  return $query;
}