original_string: public function sync(progress_trace $trace) {
          if (!enrol_is_enabled('flatfile')) {
              return 2;
          }
  
          $mailadmins = $this->get_config('mailadmins', 0);
  
          if ($mailadmins) {
              $buffer = new progress_trace_buffer(new text_progress_trace(), false);
              $trace = new combined_progress_trace(array($trace, $buffer));
          }
  
          $processed = false;
  
          $processed = $this->process_file($trace) || $processed;
          $processed = $this->process_buffer($trace) || $processed;
          $processed = $this->process_expirations($trace) || $processed;
  
          if ($processed and $mailadmins) {
              if ($log = $buffer->get_buffer()) {
                  $eventdata = new \core\message\message();
                  $eventdata->courseid          = SITEID;
                  $eventdata->modulename        = 'moodle';
                  $eventdata->component         = 'enrol_flatfile';
                  $eventdata->name              = 'flatfile_enrolment';
                  $eventdata->userfrom          = get_admin();
                  $eventdata->userto            = get_admin();
                  $eventdata->subject           = 'Flatfile Enrolment Log';
                  $eventdata->fullmessage       = $log;
                  $eventdata->fullmessageformat = FORMAT_PLAIN;
                  $eventdata->fullmessagehtml   = '';
                  $eventdata->smallmessage      = '';
                  message_send($eventdata);
              }
              $buffer->reset_buffer();
          }
  
          return 0;
      }
code: public function sync(progress_trace $trace) {
          if (!enrol_is_enabled('flatfile')) {
              return 2;
          }
  
          $mailadmins = $this->get_config('mailadmins', 0);
  
          if ($mailadmins) {
              $buffer = new progress_trace_buffer(new text_progress_trace(), false);
              $trace = new combined_progress_trace(array($trace, $buffer));
          }
  
          $processed = false;
  
          $processed = $this->process_file($trace) || $processed;
          $processed = $this->process_buffer($trace) || $processed;
          $processed = $this->process_expirations($trace) || $processed;
  
          if ($processed and $mailadmins) {
              if ($log = $buffer->get_buffer()) {
                  $eventdata = new \core\message\message();
                  $eventdata->courseid          = SITEID;
                  $eventdata->modulename        = 'moodle';
                  $eventdata->component         = 'enrol_flatfile';
                  $eventdata->name              = 'flatfile_enrolment';
                  $eventdata->userfrom          = get_admin();
                  $eventdata->userto            = get_admin();
                  $eventdata->subject           = 'Flatfile Enrolment Log';
                  $eventdata->fullmessage       = $log;
                  $eventdata->fullmessageformat = FORMAT_PLAIN;
                  $eventdata->fullmessagehtml   = '';
                  $eventdata->smallmessage      = '';
                  message_send($eventdata);
              }
              $buffer->reset_buffer();
          }
  
          return 0;
      }
code_tokens: public function sync ( progress_trace $ trace ) { if ( ! enrol_is_enabled ( 'flatfile' ) ) { return 2 ; } $ mailadmins = $ this -> get_config ( 'mailadmins' , 0 ) ; if ( $ mailadmins ) { $ buffer = new progress_trace_buffer ( new text_progress_trace ( ) , false ) ; $ trace = new combined_progress_trace ( array ( $ trace , $ buffer ) ) ; } $ processed = false ; $ processed = $ this -> process_file ( $ trace ) || $ processed ; $ processed = $ this -> process_buffer ( $ trace ) || $ processed ; $ processed = $ this -> process_expirations ( $ trace ) || $ processed ; if ( $ processed and $ mailadmins ) { if ( $ log = $ buffer -> get_buffer ( ) ) { $ eventdata = new \ core \ message \ message ( ) ; $ eventdata -> courseid = SITEID ; $ eventdata -> modulename = 'moodle' ; $ eventdata -> component = 'enrol_flatfile' ; $ eventdata -> name = 'flatfile_enrolment' ; $ eventdata -> userfrom = get_admin ( ) ; $ eventdata -> userto = get_admin ( ) ; $ eventdata -> subject = 'Flatfile Enrolment Log' ; $ eventdata -> fullmessage = $ log ; $ eventdata -> fullmessageformat = FORMAT_PLAIN ; $ eventdata -> fullmessagehtml = '' ; $ eventdata -> smallmessage = '' ; message_send ( $ eventdata ) ; } $ buffer -> reset_buffer ( ) ; } return 0 ; }
docstring: Execute synchronisation.
  @param progress_trace
  @return int exit code, 0 means ok, 2 means plugin disabled
docstring_tokens: Execute synchronisation .