Commit d564ec5f authored by Brendan Blaine's avatar Brendan Blaine Committed by Neil Drumm
Browse files

Issue #3277561 by B_man, drumm: Remove commit summary on profile page

parent baf7b7fb
Loading
Loading
Loading
Loading
+0 −78
Original line number Diff line number Diff line
@@ -219,84 +219,6 @@ function versioncontrol_project_views_api() {
  );
}

/**
 * Implements hook_field_extra_fields().
 */
function versioncontrol_project_field_extra_fields() {
  return array(
    'user' => array(
      'user' => array(
        'display' => array(
          'versioncontrol_project_user_commits' => array(
            'label' => t('Projects'),
            'description' => t('Projects a user has committed to.'),
            'weight' => 0,
          ),
        ),
      ),
    ),
  );
}

/**
 * Implements hook_user_view().
 */
function versioncontrol_project_user_view($account, $view_mode) {
  // Print a list of projects the specified user contributed to.
  if (!empty($account->uid)) {
    // @todo replace with EFQ
    $query = db_select('versioncontrol_operations', 'o')
      ->fields('n', array('nid', 'title'))
      ->fields('t', array('field_project_type_value'))
      ->orderBy('commits', 'DESC')
      ->groupBy('n.nid')
      ->condition(
        db_and()
          ->condition('o.author_uid', $account->uid)
          ->condition(
            db_or()
              ->condition('t.field_project_type_value', 'full')
              ->condition('t.field_project_type_value', NULL, 'IS NULL')
              ->condition(
                db_and()
                  ->condition('t.field_project_type_value', 'sandbox')
                  ->condition('n.uid', $account->uid)
              )
          )
      );
    $query->innerJoin('versioncontrol_project_projects', 'vcp', 'vcp.repo_id = o.repo_id');
    $query->innerJoin('node', 'n', 'n.status = 1 AND n.nid = vcp.nid');
    $query->leftJoin('field_data_field_project_type', 't', 't.entity_id = n.nid');
    $query->addExpression('COUNT(o.vc_op_id)', 'commits');
    $result = $query->execute();

    $total = 0;
    $projects = array();
    foreach ($result as $project) {
      $project_link = l($project->title, 'node/' . $project->nid, [
        'attributes' => [
          'class' => [
            drupal_html_class('project-type-' . ($project->field_project_type_value ?: 'full')),
          ],
        ],
      ]);
      $projects[] = format_plural($project->commits, '!project (1 commit)', '!project (@count commits)', array('!project' => $project_link));
      $total += $project->commits;
    }
    if ($total > 0) {
      $projects[] = format_plural($total, 'Total: 1 commit', 'Total: @count commits');
    }
    if (!empty($projects)) {
      $account->content['versioncontrol_project_user_commits'] = array(
        '#theme' => 'item_list',
        '#items' => $projects,
        '#title' => t('Projects'),
        '#attributes' => array('class' => 'versioncontrol-project-user-commits'),
      );
    }
  }
}

/**
 * Gets the auth data related to a project's repository.
 *