original_string: public function user_delete($user) {
          global $DB;
  
          $sql = "SELECT e.*
                    FROM {enrol} e
                    JOIN {user_enrolments} ue ON (ue.enrolid = e.id)
                   WHERE e.enrol = :name AND ue.userid = :userid";
          $params = array('name'=>$this->get_name(), 'userid'=>$user->id);
  
          $rs = $DB->get_recordset_sql($sql, $params);
          foreach($rs as $instance) {
              $this->unenrol_user($instance, $user->id);
          }
          $rs->close();
      }
code: public function user_delete($user) {
          global $DB;
  
          $sql = "SELECT e.*
                    FROM {enrol} e
                    JOIN {user_enrolments} ue ON (ue.enrolid = e.id)
                   WHERE e.enrol = :name AND ue.userid = :userid";
          $params = array('name'=>$this->get_name(), 'userid'=>$user->id);
  
          $rs = $DB->get_recordset_sql($sql, $params);
          foreach($rs as $instance) {
              $this->unenrol_user($instance, $user->id);
          }
          $rs->close();
      }
code_tokens: public function user_delete ( $ user ) { global $ DB ; $ sql = "SELECT e.*
                    FROM {enrol} e
                    JOIN {user_enrolments} ue ON (ue.enrolid = e.id)
                   WHERE e.enrol = :name AND ue.userid = :userid" ; $ params = array ( 'name' => $ this -> get_name ( ) , 'userid' => $ user -> id ) ; $ rs = $ DB -> get_recordset_sql ( $ sql , $ params ) ; foreach ( $ rs as $ instance ) { $ this -> unenrol_user ( $ instance , $ user -> id ) ; } $ rs -> close ( ) ; }
docstring: Called when user is about to be deleted
  @param object $user
  @return void
docstring_tokens: Called when user is about to be deleted