original_string: public static function update_type($extension, $newextension, $mimetype, $coreicon,
              array $groups = array(), $corestring = '', $customdescription = '',
              $defaulticon = false) {
  
          // Extension must exist.
          $extension = (string)$extension;
          $mimetypes = get_mimetypes_array();
          if (!array_key_exists($extension, $mimetypes)) {
              throw new coding_exception('Extension ' . $extension . ' not found');
          }
  
          // If there's a new extension then this must not exist.
          $newextension = (string)$newextension;
          if ($newextension !== $extension) {
              if ($newextension === '' || $newextension[0] === '.') {
                  throw new coding_exception('Invalid extension .' . $newextension);
              }
              if (array_key_exists($newextension, $mimetypes)) {
                  throw new coding_exception('Extension ' . $newextension . ' already exists');
              }
          }
  
          // For default icon, check there isn't already something with default icon
          // set for that MIME type (unless it's this).
          if ($defaulticon) {
              foreach ($mimetypes as $ext => $type) {
                  if ($ext !== $extension && $type['type'] === $mimetype &&
                          !empty($type['defaulticon'])) {
                      throw new coding_exception('MIME type ' . $mimetype .
                              ' already has a default icon set');
                  }
              }
          }
  
          // Delete the old extension and then add the new one (may be same). This
          // will correctly handle cases when a default type is involved.
          self::delete_type($extension);
          self::add_type($newextension, $mimetype, $coreicon, $groups, $corestring,
                  $customdescription, $defaulticon);
      }
code: public static function update_type($extension, $newextension, $mimetype, $coreicon,
              array $groups = array(), $corestring = '', $customdescription = '',
              $defaulticon = false) {
  
          // Extension must exist.
          $extension = (string)$extension;
          $mimetypes = get_mimetypes_array();
          if (!array_key_exists($extension, $mimetypes)) {
              throw new coding_exception('Extension ' . $extension . ' not found');
          }
  
          // If there's a new extension then this must not exist.
          $newextension = (string)$newextension;
          if ($newextension !== $extension) {
              if ($newextension === '' || $newextension[0] === '.') {
                  throw new coding_exception('Invalid extension .' . $newextension);
              }
              if (array_key_exists($newextension, $mimetypes)) {
                  throw new coding_exception('Extension ' . $newextension . ' already exists');
              }
          }
  
          // For default icon, check there isn't already something with default icon
          // set for that MIME type (unless it's this).
          if ($defaulticon) {
              foreach ($mimetypes as $ext => $type) {
                  if ($ext !== $extension && $type['type'] === $mimetype &&
                          !empty($type['defaulticon'])) {
                      throw new coding_exception('MIME type ' . $mimetype .
                              ' already has a default icon set');
                  }
              }
          }
  
          // Delete the old extension and then add the new one (may be same). This
          // will correctly handle cases when a default type is involved.
          self::delete_type($extension);
          self::add_type($newextension, $mimetype, $coreicon, $groups, $corestring,
                  $customdescription, $defaulticon);
      }
code_tokens: public static function update_type ( $ extension , $ newextension , $ mimetype , $ coreicon , array $ groups = array ( ) , $ corestring = '' , $ customdescription = '' , $ defaulticon = false ) { // Extension must exist. $ extension = ( string ) $ extension ; $ mimetypes = get_mimetypes_array ( ) ; if ( ! array_key_exists ( $ extension , $ mimetypes ) ) { throw new coding_exception ( 'Extension ' . $ extension . ' not found' ) ; } // If there's a new extension then this must not exist. $ newextension = ( string ) $ newextension ; if ( $ newextension !== $ extension ) { if ( $ newextension === '' || $ newextension [ 0 ] === '.' ) { throw new coding_exception ( 'Invalid extension .' . $ newextension ) ; } if ( array_key_exists ( $ newextension , $ mimetypes ) ) { throw new coding_exception ( 'Extension ' . $ newextension . ' already exists' ) ; } } // For default icon, check there isn't already something with default icon // set for that MIME type (unless it's this). if ( $ defaulticon ) { foreach ( $ mimetypes as $ ext => $ type ) { if ( $ ext !== $ extension && $ type [ 'type' ] === $ mimetype && ! empty ( $ type [ 'defaulticon' ] ) ) { throw new coding_exception ( 'MIME type ' . $ mimetype . ' already has a default icon set' ) ; } } } // Delete the old extension and then add the new one (may be same). This // will correctly handle cases when a default type is involved. self :: delete_type ( $ extension ) ; self :: add_type ( $ newextension , $ mimetype , $ coreicon , $ groups , $ corestring , $ customdescription , $ defaulticon ) ; }
docstring: Updates an entry in the list of filetypes in config.
  
  @param string $extension File extension without dot, e.g. 'doc'
  @param string $newextension New file extension (same if not changing)
  @param string $mimetype MIME type e.g. 'application/msword'
  @param string $coreicon Core icon to use e.g. 'document'
  @param array $groups Array of group strings that this type belongs to
  @param string $corestring Custom lang string name in mimetypes.php
  @param string $customdescription Custom description (plain text/multilang)
  @param bool $defaulticon True if this should be the default icon for the type
  @throws coding_exception If the new extension already exists, or otherwise invalid
docstring_tokens: Updates an entry in the list of filetypes in config .