| @@ 1399-1413 (lines=15) @@ | ||
| 1396 | /** |
|
| 1397 | * Load the groups from the database if they aren't already loaded. |
|
| 1398 | */ |
|
| 1399 | private function loadGroups() { |
|
| 1400 | if ( is_null( $this->mGroups ) ) { |
|
| 1401 | $db = ( $this->queryFlagsUsed & self::READ_LATEST ) |
|
| 1402 | ? wfGetDB( DB_MASTER ) |
|
| 1403 | : wfGetDB( DB_SLAVE ); |
|
| 1404 | $res = $db->select( 'user_groups', |
|
| 1405 | [ 'ug_group' ], |
|
| 1406 | [ 'ug_user' => $this->mId ], |
|
| 1407 | __METHOD__ ); |
|
| 1408 | $this->mGroups = []; |
|
| 1409 | foreach ( $res as $row ) { |
|
| 1410 | $this->mGroups[] = $row->ug_group; |
|
| 1411 | } |
|
| 1412 | } |
|
| 1413 | } |
|
| 1414 | ||
| 1415 | /** |
|
| 1416 | * Add the user to the group if he/she meets given criteria. |
|
| @@ 3330-3348 (lines=19) @@ | ||
| 3327 | * |
|
| 3328 | * @return array Names of the groups the user has belonged to. |
|
| 3329 | */ |
|
| 3330 | public function getFormerGroups() { |
|
| 3331 | $this->load(); |
|
| 3332 | ||
| 3333 | if ( is_null( $this->mFormerGroups ) ) { |
|
| 3334 | $db = ( $this->queryFlagsUsed & self::READ_LATEST ) |
|
| 3335 | ? wfGetDB( DB_MASTER ) |
|
| 3336 | : wfGetDB( DB_SLAVE ); |
|
| 3337 | $res = $db->select( 'user_former_groups', |
|
| 3338 | [ 'ufg_group' ], |
|
| 3339 | [ 'ufg_user' => $this->mId ], |
|
| 3340 | __METHOD__ ); |
|
| 3341 | $this->mFormerGroups = []; |
|
| 3342 | foreach ( $res as $row ) { |
|
| 3343 | $this->mFormerGroups[] = $row->ufg_group; |
|
| 3344 | } |
|
| 3345 | } |
|
| 3346 | ||
| 3347 | return $this->mFormerGroups; |
|
| 3348 | } |
|
| 3349 | ||
| 3350 | /** |
|
| 3351 | * Get the user's edit count. |
|