Commit 6b28b10b authored by Marco Villegas's avatar Marco Villegas
Browse files

Issue #1259724: Allow commits to be seen in commit log of both the committer and author.

- Create a special views argument handler to catch author_uid and
  committer_uid with an OR.
- Modify commitlog_user_commits default view to use the new argument.
parent 8be236a3
Loading
Loading
Loading
Loading
+4 −4
Changes for commitlog/includes/views/default_views/commitlog_user_commits.view.php: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ $handler->override_option('sorts', array(
  ),
));
$handler->override_option('arguments', array(
  'uid' => array(
  'attribution' => array(
    'default_action' => 'not found',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
@@ -314,9 +314,9 @@ $handler->override_option('arguments', array(
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'id' => 'attribution',
    'table' => 'versioncontrol_operations',
    'field' => 'attribution',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
+33 −0
Changes for includes/views/handlers/versioncontrol_handler_argument_operation_attribution_uid.inc: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * @file
 * Contains the attribution argument handler.
 */

/**
 * Specialized argument handler for repo_id argument.
 */
class versioncontrol_handler_argument_operation_attribution_uid extends views_handler_argument_user_uid {
  function query() {
    $this->ensure_my_table();
    $this->query->add_field($this->table_alias, 'author_uid');
    $this->query->add_field($this->table_alias, 'committer_uid');

    if (!empty($this->options['break_phrase'])) {
      views_break_phrase($this->argument, $this);
    }
    else {
      $this->value = array($this->argument);
    }

    if (count($this->value) > 1) {
      $operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
      $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
      $this->query->add_where(0, "$this->table_alias.$this->real_field $operator ($placeholders)", $this->value);
    }
    else {
      $operator = empty($this->options['not']) ? '=' : '!=';
      $this->query->add_where(0, "$this->table_alias.author_uid $operator %d OR $this->table_alias.committer_uid $operator %d", $this->argument, $this->argument);
    }
  }
}
+4 −1
Changes for includes/views/versioncontrol.views.inc: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ function versioncontrol_views_data() {
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
      'handler' => 'versioncontrol_handler_argument_operation_attribution_uid',
    ),
  );

@@ -669,6 +669,9 @@ function versioncontrol_views_handlers() {
      'versioncontrol_handler_argument_repository_repo_id' => array(
        'parent' => 'views_handler_argument_numeric',
      ),
      'versioncontrol_handler_argument_operation_attribution_uid' => array(
        'parent' => 'views_handler_argument_user_uid',
      ),
    ),
  );
  return $ret;