original_string: public static function get_fields($databaseid) {
          global $PAGE;
  
          $params = array('databaseid' => $databaseid);
          $params = self::validate_parameters(self::get_fields_parameters(), $params);
          $fields = $warnings = array();
  
          list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);
  
          // Check database is open in time.
          $canmanageentries = has_capability('mod/data:manageentries', $context);
          data_require_time_available($database, $canmanageentries);
  
          $fieldinstances = data_get_field_instances($database);
  
          foreach ($fieldinstances as $fieldinstance) {
              $record = $fieldinstance->field;
              // Now get the configs the user can see with his current permissions.
              $configs = $fieldinstance->get_config_for_external();
              foreach ($configs as $name => $value) {
                  // Overwrite.
                  $record->{$name} = $value;
              }
  
              $exporter = new field_exporter($record, array('context' => $context));
              $fields[] = $exporter->export($PAGE->get_renderer('core'));
          }
  
          $result = array(
              'fields' => $fields,
              'warnings' => $warnings
          );
          return $result;
      }
code: public static function get_fields($databaseid) {
          global $PAGE;
  
          $params = array('databaseid' => $databaseid);
          $params = self::validate_parameters(self::get_fields_parameters(), $params);
          $fields = $warnings = array();
  
          list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);
  
          // Check database is open in time.
          $canmanageentries = has_capability('mod/data:manageentries', $context);
          data_require_time_available($database, $canmanageentries);
  
          $fieldinstances = data_get_field_instances($database);
  
          foreach ($fieldinstances as $fieldinstance) {
              $record = $fieldinstance->field;
              // Now get the configs the user can see with his current permissions.
              $configs = $fieldinstance->get_config_for_external();
              foreach ($configs as $name => $value) {
                  // Overwrite.
                  $record->{$name} = $value;
              }
  
              $exporter = new field_exporter($record, array('context' => $context));
              $fields[] = $exporter->export($PAGE->get_renderer('core'));
          }
  
          $result = array(
              'fields' => $fields,
              'warnings' => $warnings
          );
          return $result;
      }
code_tokens: public static function get_fields ( $ databaseid ) { global $ PAGE ; $ params = array ( 'databaseid' => $ databaseid ) ; $ params = self :: validate_parameters ( self :: get_fields_parameters ( ) , $ params ) ; $ fields = $ warnings = array ( ) ; list ( $ database , $ course , $ cm , $ context ) = self :: validate_database ( $ params [ 'databaseid' ] ) ; // Check database is open in time. $ canmanageentries = has_capability ( 'mod/data:manageentries' , $ context ) ; data_require_time_available ( $ database , $ canmanageentries ) ; $ fieldinstances = data_get_field_instances ( $ database ) ; foreach ( $ fieldinstances as $ fieldinstance ) { $ record = $ fieldinstance -> field ; // Now get the configs the user can see with his current permissions. $ configs = $ fieldinstance -> get_config_for_external ( ) ; foreach ( $ configs as $ name => $ value ) { // Overwrite. $ record -> { $ name } = $ value ; } $ exporter = new field_exporter ( $ record , array ( 'context' => $ context ) ) ; $ fields [ ] = $ exporter -> export ( $ PAGE -> get_renderer ( 'core' ) ) ; } $ result = array ( 'fields' => $ fields , 'warnings' => $ warnings ) ; return $ result ; }
docstring: Return the list of configured fields for the given database.
  
  @param int $databaseid the database id
  @return array of warnings and the fields
  @since Moodle 3.3
  @throws moodle_exception
docstring_tokens: Return the list of configured fields for the given database .