In order, the lines do the following:
- Load the Moodle config + main library files
- Get the 'id' paramater from the URL (/mod/mymodulename/view.php?id=xxx) and store it in $cmid
- Use $cmid to load the course module record ( http://docs.moodle.org/dev/Course_module ), MUST_EXIST means an error will be shown if it is not found
- Load the $course record for the course that the course module is in (again, throw an error if it doesn't exist).