original_string: protected static function validate_database($databaseid) {
          global $DB;
  
          // Request and permission validation.
          $database = $DB->get_record('data', array('id' => $databaseid), '*', MUST_EXIST);
          list($course, $cm) = get_course_and_cm_from_instance($database, 'data');
  
          $context = context_module::instance($cm->id);
          self::validate_context($context);
          require_capability('mod/data:viewentry', $context);
  
          return array($database, $course, $cm, $context);
      }
code: protected static function validate_database($databaseid) {
          global $DB;
  
          // Request and permission validation.
          $database = $DB->get_record('data', array('id' => $databaseid), '*', MUST_EXIST);
          list($course, $cm) = get_course_and_cm_from_instance($database, 'data');
  
          $context = context_module::instance($cm->id);
          self::validate_context($context);
          require_capability('mod/data:viewentry', $context);
  
          return array($database, $course, $cm, $context);
      }
code_tokens: protected static function validate_database ( $ databaseid ) { global $ DB ; // Request and permission validation. $ database = $ DB -> get_record ( 'data' , array ( 'id' => $ databaseid ) , '*' , MUST_EXIST ) ; list ( $ course , $ cm ) = get_course_and_cm_from_instance ( $ database , 'data' ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; require_capability ( 'mod/data:viewentry' , $ context ) ; return array ( $ database , $ course , $ cm , $ context ) ; }
docstring: Utility function for validating a database.
  
  @param int $databaseid database instance id
  @return array array containing the database object, course, context and course module objects
  @since  Moodle 3.3
docstring_tokens: Utility function for validating a database .