public static function generate_shortname_callback($fullname, $idnumber, $block) {
        switch ($block[3]) {
            case 'f':
                $repl = $fullname;
                break;
            case 'i':
                $repl = $idnumber;
                break;
            default:
                return $block[0];
        }

        switch ($block[1]) {
            case '+':
                $repl = core_text::strtoupper($repl);
                break;
            case '-':
                $repl = core_text::strtolower($repl);
                break;
            case '~':
                $repl = core_text::strtotitle($repl);
                break;
        }

        if (!empty($block[2])) {
            $repl = core_text::substr($repl, 0, $block[2]);
        }

        return $repl;
    }
public static function generate_shortname_callback($fullname, $idnumber, $block) {
        switch ($block[3]) {
            case 'f':
                $repl = $fullname;
                break;
            case 'i':
                $repl = $idnumber;
                break;
            default:
                return $block[0];
        }

        switch ($block[1]) {
            case '+':
                $repl = core_text::strtoupper($repl);
                break;
            case '-':
                $repl = core_text::strtolower($repl);
                break;
            case '~':
                $repl = core_text::strtotitle($repl);
                break;
        }

        if (!empty($block[2])) {
            $repl = core_text::substr($repl, 0, $block[2]);
        }

        return $repl;
    }
public static function generate_shortname_callback ( $ fullname , $ idnumber , $ block ) { switch ( $ block [ 3 ] ) { case 'f' : $ repl = $ fullname ; break ; case 'i' : $ repl = $ idnumber ; break ; default : return $ block [ 0 ] ; } switch ( $ block [ 1 ] ) { case '+' : $ repl = core_text :: strtoupper ( $ repl ) ; break ; case '-' : $ repl = core_text :: strtolower ( $ repl ) ; break ; case '~' : $ repl = core_text :: strtotitle ( $ repl ) ; break ; } if ( ! empty ( $ block [ 2 ] ) ) { $ repl = core_text :: substr ( $ repl , 0 , $ block [ 2 ] ) ; } return $ repl ; }
Callback used when generating a shortname based on a template.

@param string $fullname full name.
@param string $idnumber ID number.
@param array $block result from preg_replace_callback.
@return string
Callback used when generating a shortname based on a template .