/** * Checks the autopromote condition for a user. */ static function AutopromoteCondition($cond_type, $args, $user, &$result) { global $fbUserRightsFromGroup; // Probably a redundant check, but with PHP you can never be too sure... if (!$fbUserRightsFromGroup) { // No group to pull rights from, so the user can't be a member $result = false; return true; } $types = array(APCOND_FB_INGROUP => 'member', APCOND_FB_ISOFFICER => 'officer', APCOND_FB_ISADMIN => 'admin'); $type = $types[$cond_type]; switch ($type) { case 'member': case 'officer': case 'admin': // Connect to the Facebook API and ask if the user is in the group $fb = new FBConnectAPI(); $rights = $fb->getGroupRights($user); $result = $rights[$type]; } return true; }