@@ 1362-1376 (lines=15) @@ | ||
1359 | /** |
|
1360 | * Load the groups from the database if they aren't already loaded. |
|
1361 | */ |
|
1362 | private function loadGroups() { |
|
1363 | if ( is_null( $this->mGroups ) ) { |
|
1364 | $db = ( $this->queryFlagsUsed & self::READ_LATEST ) |
|
1365 | ? wfGetDB( DB_MASTER ) |
|
1366 | : wfGetDB( DB_REPLICA ); |
|
1367 | $res = $db->select( 'user_groups', |
|
1368 | [ 'ug_group' ], |
|
1369 | [ 'ug_user' => $this->mId ], |
|
1370 | __METHOD__ ); |
|
1371 | $this->mGroups = []; |
|
1372 | foreach ( $res as $row ) { |
|
1373 | $this->mGroups[] = $row->ug_group; |
|
1374 | } |
|
1375 | } |
|
1376 | } |
|
1377 | ||
1378 | /** |
|
1379 | * Add the user to the group if he/she meets given criteria. |
|
@@ 3244-3262 (lines=19) @@ | ||
3241 | * |
|
3242 | * @return array Names of the groups the user has belonged to. |
|
3243 | */ |
|
3244 | public function getFormerGroups() { |
|
3245 | $this->load(); |
|
3246 | ||
3247 | if ( is_null( $this->mFormerGroups ) ) { |
|
3248 | $db = ( $this->queryFlagsUsed & self::READ_LATEST ) |
|
3249 | ? wfGetDB( DB_MASTER ) |
|
3250 | : wfGetDB( DB_REPLICA ); |
|
3251 | $res = $db->select( 'user_former_groups', |
|
3252 | [ 'ufg_group' ], |
|
3253 | [ 'ufg_user' => $this->mId ], |
|
3254 | __METHOD__ ); |
|
3255 | $this->mFormerGroups = []; |
|
3256 | foreach ( $res as $row ) { |
|
3257 | $this->mFormerGroups[] = $row->ufg_group; |
|
3258 | } |
|
3259 | } |
|
3260 | ||
3261 | return $this->mFormerGroups; |
|
3262 | } |
|
3263 | ||
3264 | /** |
|
3265 | * Get the user's edit count. |