Changeset 27706
- Timestamp:
- 03/25/2014 12:13:40 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ms.php
r27029 r27706 687 687 * @since 3.0.0 688 688 * @param int $user_id ID of the user to be granted Super Admin privileges. 689 * @return bool True on success, false on failure. This can fail when the user is 690 * already a super admin or when the $super_admins global is defined. 689 691 */ 690 692 function grant_super_admin( $user_id ) { 691 global $super_admins;692 693 693 // If global super_admins override is defined, there is nothing to do here. 694 if ( isset( $ super_admins ) )694 if ( isset( $GLOBALS['super_admins'] ) ) { 695 695 return false; 696 } 696 697 697 698 /** … … 730 731 * @since 3.0.0 731 732 * @param int $user_id ID of the user Super Admin privileges to be revoked from. 733 * @return bool True on success, false on failure. This can fail when the user's email 734 * is the network admin email or when the $super_admins global is defined. 732 735 */ 733 736 function revoke_super_admin( $user_id ) { 734 global $super_admins;735 736 737 // If global super_admins override is defined, there is nothing to do here. 737 if ( isset( $ super_admins ) )738 if ( isset( $GLOBALS['super_admins'] ) ) { 738 739 return false; 740 } 739 741 740 742 /** -
trunk/tests/phpunit/tests/ms.php
r27359 r27706 1301 1301 $this->assertQueryTrue( 'is_author', 'is_archive' ); 1302 1302 } 1303 1304 /** 1305 * @ticket 27205 1306 */ 1307 function test_granting_super_admins() { 1308 if ( isset( $GLOBALS['super_admins'] ) ) { 1309 $old_global = $GLOBALS['super_admins']; 1310 unset( $GLOBALS['super_admins'] ); 1311 } 1312 1313 $user_id = $this->factory->user->create(); 1314 1315 $this->assertFalse( is_super_admin( $user_id ) ); 1316 $this->assertFalse( revoke_super_admin( $user_id ) ); 1317 $this->assertTrue( grant_super_admin( $user_id ) ); 1318 $this->assertTrue( is_super_admin( $user_id ) ); 1319 $this->assertFalse( grant_super_admin( $user_id ) ); 1320 $this->assertTrue( revoke_super_admin( $user_id ) ); 1321 1322 // None of these operations should set the $super_admins global. 1323 $this->assertFalse( isset( $GLOBALS['super_admins'] ) ); 1324 1325 // Try with two users. 1326 $second_user = $this->factory->user->create(); 1327 $this->assertTrue( grant_super_admin( $user_id ) ); 1328 $this->assertTrue( grant_super_admin( $second_user ) ); 1329 $this->assertTrue( is_super_admin( $second_user ) ); 1330 $this->assertTrue( is_super_admin( $user_id ) ); 1331 $this->assertTrue( revoke_super_admin( $user_id ) ); 1332 $this->assertTrue( revoke_super_admin( $second_user ) ); 1333 1334 if ( isset( $old_global ) ) { 1335 $GLOBALS['super_admins'] = $old_global; 1336 } 1337 } 1303 1338 } 1304 1339
Note: See TracChangeset
for help on using the changeset viewer.