summaryrefslogtreecommitdiff
path: root/includes/logging/RightsLogFormatter.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:02 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:02 -0400
commit1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch)
treef1fdd326034e05177596851be6a7127615d81498 /includes/logging/RightsLogFormatter.php
parent9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff)
parentf6d65e533c62f6deb21342d4901ece24497b433e (diff)
Merge commit 'f6d65'
# Conflicts: # skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'includes/logging/RightsLogFormatter.php')
-rw-r--r--includes/logging/RightsLogFormatter.php65
1 files changed, 51 insertions, 14 deletions
diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php
index ac252aeb..352bda58 100644
--- a/includes/logging/RightsLogFormatter.php
+++ b/includes/logging/RightsLogFormatter.php
@@ -67,20 +67,8 @@ class RightsLogFormatter extends LogFormatter {
return $params;
}
- $oldGroups = $params[3];
- $newGroups = $params[4];
-
- // Less old entries
- if ( $oldGroups === '' ) {
- $oldGroups = array();
- } elseif ( is_string( $oldGroups ) ) {
- $oldGroups = array_map( 'trim', explode( ',', $oldGroups ) );
- }
- if ( $newGroups === '' ) {
- $newGroups = array();
- } elseif ( is_string( $newGroups ) ) {
- $newGroups = array_map( 'trim', explode( ',', $newGroups ) );
- }
+ $oldGroups = $this->makeGroupArray( $params[3] );
+ $newGroups = $this->makeGroupArray( $params[4] );
$userName = $this->entry->getTarget()->getText();
if ( !$this->plaintext && count( $oldGroups ) ) {
@@ -110,4 +98,53 @@ class RightsLogFormatter extends LogFormatter {
return $params;
}
+
+ protected function getParametersForApi() {
+ $entry = $this->entry;
+ $params = $entry->getParameters();
+
+ static $map = array(
+ '4:array:oldgroups',
+ '5:array:newgroups',
+ '4::oldgroups' => '4:array:oldgroups',
+ '5::newgroups' => '5:array:newgroups',
+ );
+ foreach ( $map as $index => $key ) {
+ if ( isset( $params[$index] ) ) {
+ $params[$key] = $params[$index];
+ unset( $params[$index] );
+ }
+ }
+
+ // Really old entries does not have log params
+ if ( isset( $params['4:array:oldgroups'] ) ) {
+ $params['4:array:oldgroups'] = $this->makeGroupArray( $params['4:array:oldgroups'] );
+ }
+ if ( isset( $params['5:array:newgroups'] ) ) {
+ $params['5:array:newgroups'] = $this->makeGroupArray( $params['5:array:newgroups'] );
+ }
+
+ return $params;
+ }
+
+ public function formatParametersForApi() {
+ $ret = parent::formatParametersForApi();
+ if ( isset( $ret['oldgroups'] ) ) {
+ ApiResult::setIndexedTagName( $ret['oldgroups'], 'g' );
+ }
+ if ( isset( $ret['newgroups'] ) ) {
+ ApiResult::setIndexedTagName( $ret['newgroups'], 'g' );
+ }
+ return $ret;
+ }
+
+ private function makeGroupArray( $group ) {
+ // Migrate old group params from string to array
+ if ( $group === '' ) {
+ $group = array();
+ } elseif ( is_string( $group ) ) {
+ $group = array_map( 'trim', explode( ',', $group ) );
+ }
+ return $group;
+ }
}