original_string: public function edit_enrolment($userenrolment, $data) {
          //Only allow editing if the user has the appropriate capability
          //Already checked in /user/index.php but checking again in case this function is called from elsewhere
          list($instance, $plugin) = $this->get_user_enrolment_components($userenrolment);
          if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $this->context)) {
              if (!isset($data->status)) {
                  $data->status = $userenrolment->status;
              }
              $plugin->update_user_enrol($instance, $userenrolment->userid, $data->status, $data->timestart, $data->timeend);
              return true;
          }
          return false;
      }
code: public function edit_enrolment($userenrolment, $data) {
          //Only allow editing if the user has the appropriate capability
          //Already checked in /user/index.php but checking again in case this function is called from elsewhere
          list($instance, $plugin) = $this->get_user_enrolment_components($userenrolment);
          if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $this->context)) {
              if (!isset($data->status)) {
                  $data->status = $userenrolment->status;
              }
              $plugin->update_user_enrol($instance, $userenrolment->userid, $data->status, $data->timestart, $data->timeend);
              return true;
          }
          return false;
      }
code_tokens: public function edit_enrolment ( $ userenrolment , $ data ) { //Only allow editing if the user has the appropriate capability //Already checked in /user/index.php but checking again in case this function is called from elsewhere list ( $ instance , $ plugin ) = $ this -> get_user_enrolment_components ( $ userenrolment ) ; if ( $ instance && $ plugin && $ plugin -> allow_manage ( $ instance ) && has_capability ( "enrol/$instance->enrol:manage" , $ this -> context ) ) { if ( ! isset ( $ data -> status ) ) { $ data -> status = $ userenrolment -> status ; } $ plugin -> update_user_enrol ( $ instance , $ userenrolment -> userid , $ data -> status , $ data -> timestart , $ data -> timeend ) ; return true ; } return false ; }
docstring: Edits an enrolment
  
  @param stdClass $userenrolment
  @param stdClass $data
  @return bool
docstring_tokens: Edits an enrolment