missing global $CFG ; line 577