This moodle block can be integrated in the course context. If it is displayed by a teacher a code can be generated. This code can be entered by other users on their dashboard (if the block is shown!) and allows those users to enrol directly into that course.
It seems that PARAM_TEXT is too benevolent for the things it is used for. Would not some more strict type such as PARAM_ALPHANUM be more appropriate?