Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/Resources/views/editCounter/rights_changes_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
{% set index = 0 %}
{% for timestamp, change in rightsChanges if index < 10 or not(is_sub_request) %}
<tr>
<td class="sort-entry--date" data-value="{{ timestamp }}">
<td class="{{ change.grantType == 'pending' ? 'pending ' : '' }}sort-entry--date" data-value="{{ timestamp }}">
{% if change.logId is not empty %}
{{ wiki.logLink(change.type == 'local' ? project : metaProject, change.logId, timestamp|trans|date_format) }}
{% else %}
{{ timestamp|trans|date_format }}
{% endif %}
</td>
<td class="sort-entry--rights" data-value="{{ change.added|length + change.removed|length }}">
<td class="{{ change.grantType == 'pending' ? 'pending ' : '' }}sort-entry--rights" data-value="{{ change.added|length + change.removed|length }}">
{% for right in change.added %}
<div class="diff-pos">{{ ec.rightsName(right)|trim }}</div>
{% endfor %}
{% for right in change.removed %}
<div class="diff-neg" dir="ltr">-{{ ec.rightsName(right)|trim }}</div>
{% endfor %}
</td>
<td class="sort-entry--admin" data-value="{{ change.admin }}">
<td class="{{ change.grantType == 'pending' ? 'pending ' : '' }}sort-entry--admin" data-value="{{ change.admin }}">
{{ wiki.userLink(change.admin, change.type == 'local' ? project : metaProject) }}
</td>
<td class="sort-entry--summary" data-value="{{ change.comment }}">
{% if change.automatic %}
<i class="text-muted">{{ msg('automatic') }}</i>
{% else %}
{% if change.grantType == 'manual' %}
{{ change.comment|wikify(change.type == 'local' ? project : metaProject)|raw }}
{% else %}
<i class="text-muted">{{ msg('automatic') }}</i>
{% endif %}
</td>
</tr>
Expand Down
16 changes: 11 additions & 5 deletions app/Resources/views/editCounter/rights_changes_table.wikitext.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
{% endfor %}
{% for timestamp, change in rightsChanges %}
|-
|{% if change.logId is not empty %} style="white-space: nowrap;" | {% if change.type == 'local' %}[[Special:Redirect/logid/{{ change.logId }}|{{ timestamp|trans|date_format }}]]{% else %}[https://meta.wikimedia.org/wiki/Special:Redirect/logid/{{ change.logId }} {{ timestamp|trans|date_format }}]{% endif %}{% endif %}
| style="white-space: nowrap;" | {% if change.logId is not empty %}{#
#}{% if change.type == 'local' %}{#
#}[[Special:Redirect/logid/{{ change.logId }}|{{ timestamp|trans|date_format }}]]{#
#}{% else %}{#
#}[https://meta.wikimedia.org/wiki/Special:Redirect/logid/{{ change.logId }} {{ timestamp|trans|date_format }}]{#
#}{% endif %}{#
#}{% else %}{#
#}{{ timestamp|trans|date_format }}{#
#}{% endif %}

| {% for right in change.added %}
<span style="color:#006400">+{{ ec.rightsName(right)|trim }}</span>{% if not loop.last %}, {% endif %}
Expand All @@ -18,9 +26,7 @@

|{% if change.admin is not empty %} <span class="plainlinks">[{% verbatim %}{{{% endverbatim %}fullurl:User:{{ change.admin }}}} {{ change.admin }}]</span>{% endif %}

| {% if change.automatic %}''{{ msg('automatic') }}''
{% else %}
{{ change.comment }}
{% endif %}
| {% if change.grantType == 'manual' %}{{ change.comment }}{% else %}''{{ msg('automatic') }}''{% endif %}

{% endfor %}
|}
20 changes: 10 additions & 10 deletions src/Xtools/UserRights.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getRightsChanges()
'comment' => null,
'added' => ['autoconfirmed'],
'removed' => [],
'automatic' => true,
'grantType' => strtotime($acDate) > time() ? 'pending' : 'automatic',
'type' => 'local',
];
krsort($this->rightsChanges);
Expand Down Expand Up @@ -116,9 +116,13 @@ public function getRightsStates()
$former
);

// Remove the current rights for good measure. Autoconfirmed is a special case -- it can never be former,
// but will end up in $former from the above code.
$former = array_diff(array_unique($former), $currentRights, ['autoconfirmed']);

$this->rightsStates[$type] = [
'current' => $currentRights,
'former' => array_diff(array_unique($former), $currentRights),
'former' => $former,
];
}

Expand All @@ -139,7 +143,8 @@ private function getCurrentRightsAndChanges($type)
$currentRights = $this->user->getUserRights($this->project);
$rightsChanges = $this->getRightsChanges();

if (false !== $this->getAutoconfirmedTimestamp()) {
$acDate = $this->getAutoconfirmedTimestamp();
if (false !== $acDate && strtotime($acDate) <= time()) {
$currentRights[] = 'autoconfirmed';
}
} else {
Expand Down Expand Up @@ -254,7 +259,7 @@ private function processRightsChanges($logData)
'comment' => $row['log_comment'],
'added' => array_values($added),
'removed' => array_values($removed),
'automatic' => $row['log_action'] === 'autopromote',
'grantType' => $row['log_action'] === 'autopromote' ? 'automatic' : 'manual',
'type' => $row['type'],
];
}
Expand Down Expand Up @@ -294,7 +299,7 @@ private function setAutoRemovals($rightsChanges, $row, $params, $added)
'comment' => null,
'added' => [],
'removed' => [$entry],
'automatic' => true,
'grantType' => strtotime($expiry) > time() ? 'pending' : 'automatic',
'type' => $row['type'],
];
}
Expand Down Expand Up @@ -337,11 +342,6 @@ private function getAutoconfirmedTimestamp()
$thresholds['wgAutoConfirmAge'].' seconds'
))->format('YmdHis');

// If autoconfirmed date is in the future.
if (strtotime($acDate) > time()) {
return false;
}

// First check if they already had 10 edits made as of $acDate
$editsByAcDate = $this->getRepository()->getNumEditsByTimestamp(
$this->project,
Expand Down
12 changes: 6 additions & 6 deletions tests/Xtools/EditCounterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public function testUserRightsChanges()
'comment' => null,
'added' => [],
'removed' => ['ipblock-exempt', 'filemover'],
'automatic' => true,
'grantType' => 'automatic',
'type' => 'local',
],
20180108132810 => [
Expand All @@ -613,7 +613,7 @@ public function testUserRightsChanges()
'comment' => '',
'added' => [],
'removed' => ['templateeditor'],
'automatic' => false,
'grantType' => 'manual',
'type' => 'local',
],
20180108132758 => [
Expand All @@ -622,7 +622,7 @@ public function testUserRightsChanges()
'comment' => '',
'added' => ['ipblock-exempt', 'filemover', 'templateeditor'],
'removed' => [],
'automatic' => false,
'grantType' => 'manual',
'type' => 'local',
],
20150716002614 => [
Expand All @@ -631,7 +631,7 @@ public function testUserRightsChanges()
'comment' => 'Per user request.',
'added' => ['bureaucrat'],
'removed' => ['rollbacker'],
'automatic' => false,
'grantType' => 'manual',
'type' => 'meta',
],
20141222034127 => [
Expand All @@ -640,7 +640,7 @@ public function testUserRightsChanges()
'comment' => 'per request',
'added' => ['sysop'],
'removed' => [],
'automatic' => false,
'grantType' => 'manual',
'type' => 'meta',
],
], $this->editCounter->getRightsChanges());
Expand All @@ -664,7 +664,7 @@ public function testUserRightsChanges()
'comment' => 'per request',
'added' => ['sysop'],
'removed' => [],
'automatic' => false,
'grantType' => 'manual',
'type' => 'global',
],
], $this->editCounter->getGlobalRightsChanges());
Expand Down
4 changes: 4 additions & 0 deletions web/static/css/editcounter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@
width: calc(100% / 3);
}
}

.pending {
opacity: 0.5;
}
}