original_string: final public static function delete_all_for_context($contextid, $downloadcontents = true) {
          global $DB;
          $repoids = $DB->get_fieldset_select('repository_instances', 'id', 'contextid = :contextid', array('contextid' => $contextid));
          if ($downloadcontents) {
              foreach ($repoids as $repoid) {
                  $repo = repository::get_repository_by_id($repoid, $contextid);
                  $repo->convert_references_to_local();
              }
          }
          cache::make('core', 'repositories')->purge();
          $DB->delete_records_list('repository_instances', 'id', $repoids);
          $DB->delete_records_list('repository_instance_config', 'instanceid', $repoids);
      }
code: final public static function delete_all_for_context($contextid, $downloadcontents = true) {
          global $DB;
          $repoids = $DB->get_fieldset_select('repository_instances', 'id', 'contextid = :contextid', array('contextid' => $contextid));
          if ($downloadcontents) {
              foreach ($repoids as $repoid) {
                  $repo = repository::get_repository_by_id($repoid, $contextid);
                  $repo->convert_references_to_local();
              }
          }
          cache::make('core', 'repositories')->purge();
          $DB->delete_records_list('repository_instances', 'id', $repoids);
          $DB->delete_records_list('repository_instance_config', 'instanceid', $repoids);
      }
code_tokens: final public static function delete_all_for_context ( $ contextid , $ downloadcontents = true ) { global $ DB ; $ repoids = $ DB -> get_fieldset_select ( 'repository_instances' , 'id' , 'contextid = :contextid' , array ( 'contextid' => $ contextid ) ) ; if ( $ downloadcontents ) { foreach ( $ repoids as $ repoid ) { $ repo = repository :: get_repository_by_id ( $ repoid , $ contextid ) ; $ repo -> convert_references_to_local ( ) ; } } cache :: make ( 'core' , 'repositories' ) -> purge ( ) ; $ DB -> delete_records_list ( 'repository_instances' , 'id' , $ repoids ) ; $ DB -> delete_records_list ( 'repository_instance_config' , 'instanceid' , $ repoids ) ; }
docstring: Delete all the instances associated to a context.
  
  This method is intended to be a callback when deleting
  a course or a user to delete all the instances associated
  to their context. The usual way to delete a single instance
  is to use {@link self::delete()}.
  
  @param int $contextid context ID.
  @param boolean $downloadcontents true to convert references to hard copies.
  @return void
docstring_tokens: Delete all the instances associated to a context .