original_string: public function process_enrolment($data) {
          global $DB;
  
          if (!isset($this->plugins)) {
              $this->plugins = enrol_get_plugins(true);
          }
  
          $data = (object)$data;
  
          // Process only if parent instance have been mapped.
          if ($enrolid = $this->get_new_parentid('enrol')) {
              $oldinstancestatus = ENROL_INSTANCE_ENABLED;
              $oldenrolid = $this->get_old_parentid('enrol');
              if (isset($this->originalstatus[$oldenrolid])) {
                  $oldinstancestatus = $this->originalstatus[$oldenrolid];
              }
              if ($instance = $DB->get_record('enrol', array('id'=>$enrolid))) {
                  // And only if user is a mapped one.
                  if ($userid = $this->get_mappingid('user', $data->userid)) {
                      if (isset($this->plugins[$instance->enrol])) {
                          $this->plugins[$instance->enrol]->restore_user_enrolment($this, $data, $instance, $userid, $oldinstancestatus);
                      }
                  }
              }
          }
      }
code: public function process_enrolment($data) {
          global $DB;
  
          if (!isset($this->plugins)) {
              $this->plugins = enrol_get_plugins(true);
          }
  
          $data = (object)$data;
  
          // Process only if parent instance have been mapped.
          if ($enrolid = $this->get_new_parentid('enrol')) {
              $oldinstancestatus = ENROL_INSTANCE_ENABLED;
              $oldenrolid = $this->get_old_parentid('enrol');
              if (isset($this->originalstatus[$oldenrolid])) {
                  $oldinstancestatus = $this->originalstatus[$oldenrolid];
              }
              if ($instance = $DB->get_record('enrol', array('id'=>$enrolid))) {
                  // And only if user is a mapped one.
                  if ($userid = $this->get_mappingid('user', $data->userid)) {
                      if (isset($this->plugins[$instance->enrol])) {
                          $this->plugins[$instance->enrol]->restore_user_enrolment($this, $data, $instance, $userid, $oldinstancestatus);
                      }
                  }
              }
          }
      }
code_tokens: public function process_enrolment ( $ data ) { global $ DB ; if ( ! isset ( $ this -> plugins ) ) { $ this -> plugins = enrol_get_plugins ( true ) ; } $ data = ( object ) $ data ; // Process only if parent instance have been mapped. if ( $ enrolid = $ this -> get_new_parentid ( 'enrol' ) ) { $ oldinstancestatus = ENROL_INSTANCE_ENABLED ; $ oldenrolid = $ this -> get_old_parentid ( 'enrol' ) ; if ( isset ( $ this -> originalstatus [ $ oldenrolid ] ) ) { $ oldinstancestatus = $ this -> originalstatus [ $ oldenrolid ] ; } if ( $ instance = $ DB -> get_record ( 'enrol' , array ( 'id' => $ enrolid ) ) ) { // And only if user is a mapped one. if ( $ userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ) { if ( isset ( $ this -> plugins [ $ instance -> enrol ] ) ) { $ this -> plugins [ $ instance -> enrol ] -> restore_user_enrolment ( $ this , $ data , $ instance , $ userid , $ oldinstancestatus ) ; } } } } }
docstring: Create user enrolments.
  
  This has to be called after creation of enrolment instances
  and before adding of role assignments.
  
  Roles are assigned in restore_ras_and_caps_structure_step::process_assignment() processing afterwards.
  
  @param mixed $data
  @return void
docstring_tokens: Create user enrolments .