original_string: public static function get_role_names($data, &$errors = array()) {
          $rolenames = array();
          $rolesids = self::get_role_ids();
          $invalidroles = array();
          foreach ($data as $field => $value) {
  
              $matches = array();
              if (preg_match('/^role_(.+)?$/', $field, $matches)) {
                  if (!isset($rolesids[$matches[1]])) {
                      $invalidroles[] = $matches[1];
                      continue;
                  }
                  $rolenames['role_' . $rolesids[$matches[1]]] = $value;
              }
  
          }
  
          if (!empty($invalidroles)) {
              $errors['invalidroles'] = new lang_string('invalidroles', 'tool_uploadcourse', implode(', ', $invalidroles));
          }
  
          // Roles names.
          return $rolenames;
      }
code: public static function get_role_names($data, &$errors = array()) {
          $rolenames = array();
          $rolesids = self::get_role_ids();
          $invalidroles = array();
          foreach ($data as $field => $value) {
  
              $matches = array();
              if (preg_match('/^role_(.+)?$/', $field, $matches)) {
                  if (!isset($rolesids[$matches[1]])) {
                      $invalidroles[] = $matches[1];
                      continue;
                  }
                  $rolenames['role_' . $rolesids[$matches[1]]] = $value;
              }
  
          }
  
          if (!empty($invalidroles)) {
              $errors['invalidroles'] = new lang_string('invalidroles', 'tool_uploadcourse', implode(', ', $invalidroles));
          }
  
          // Roles names.
          return $rolenames;
      }
code_tokens: public static function get_role_names ( $ data , & $ errors = array ( ) ) { $ rolenames = array ( ) ; $ rolesids = self :: get_role_ids ( ) ; $ invalidroles = array ( ) ; foreach ( $ data as $ field => $ value ) { $ matches = array ( ) ; if ( preg_match ( '/^role_(.+)?$/' , $ field , $ matches ) ) { if ( ! isset ( $ rolesids [ $ matches [ 1 ] ] ) ) { $ invalidroles [ ] = $ matches [ 1 ] ; continue ; } $ rolenames [ 'role_' . $ rolesids [ $ matches [ 1 ] ] ] = $ value ; } } if ( ! empty ( $ invalidroles ) ) { $ errors [ 'invalidroles' ] = new lang_string ( 'invalidroles' , 'tool_uploadcourse' , implode ( ', ' , $ invalidroles ) ) ; } // Roles names. return $ rolenames ; }
docstring: Get the role renaming data from the passed data.
  
  @param array $data data to extract the names from.
  @param array $errors will be populated with errors found.
  @return array where the key is the role_<id>, the value is the new name.
docstring_tokens: Get the role renaming data from the passed data .