A couple of stylistic comments on this.
array_intersect( (array)$removegroup, $changeable['remove'] ) );
array_intersect( (array)$removegroup, $changeable[1] ) ); $addgroup = array_unique(
array_intersect( (array)$addgroup, $changeable['add'] ) );
array_intersect( (array)$addgroup, $changeable[0] ) );
Numeric indexes are much less readable than string indexes in this case. If you really want you could use named constants, but you really should not use magical meanings like 1 = remove, 0 = add. It's confusing.
switch($retval[0])
{
While this is a stylistic quibble, MediaWiki code does consistently use K&R-style braces, with the opening brace on the same line, i.e.:
switch($retval[0]) {
This is documented in docs/design.txt, and helps to give the code a more consistent look.
function fetchUser_real( $username ) {
Likewise, we only rarely use underscores. This should have been fetchUserReal. Consistent function naming conventions make things easier to remember and work with: you only have to remember the function's name, not the name *plus* how the name is formatted.