original_string: public function process(base_moodleform $form = null) {
          if (optional_param('cancel', false, PARAM_BOOL)) {
              redirect(new moodle_url('/course/view.php', array('id' => $this->get_ui()->get_controller()->get_courseid())));
          }
  
          // First decide whether a substage is needed.
          $rc = $this->ui->get_controller();
          if ($rc->get_status() == backup::STATUS_SETTING_UI) {
              $rc->finish_ui();
          }
          if ($rc->get_status() == backup::STATUS_NEED_PRECHECK) {
              if (!$rc->precheck_executed()) {
                  $rc->execute_precheck(true);
              }
              $results = $rc->get_precheck_results();
              if (!empty($results)) {
                  $this->substage = self::SUBSTAGE_PRECHECKS;
              }
          }
  
          $substage = optional_param('substage', null, PARAM_INT);
          if (empty($this->substage) && !empty($substage)) {
              $this->substage = $substage;
              // Now check whether that substage has already been submit.
              if ($this->substage == self::SUBSTAGE_PRECHECKS && optional_param('sesskey', null, PARAM_RAW) == sesskey()) {
                  $info = $rc->get_info();
                  if (!empty($info->role_mappings->mappings)) {
                      foreach ($info->role_mappings->mappings as $key => &$mapping) {
                          $mapping->targetroleid = optional_param('mapping'.$key, $mapping->targetroleid, PARAM_INT);
                      }
                      $info->role_mappings->modified = true;
                  }
                  // We've processed the substage now setting it back to none so we
                  // can move to the next stage.
                  $this->substage = self::SUBSTAGE_NONE;
              }
          }
  
          return empty($this->substage);
      }
code: public function process(base_moodleform $form = null) {
          if (optional_param('cancel', false, PARAM_BOOL)) {
              redirect(new moodle_url('/course/view.php', array('id' => $this->get_ui()->get_controller()->get_courseid())));
          }
  
          // First decide whether a substage is needed.
          $rc = $this->ui->get_controller();
          if ($rc->get_status() == backup::STATUS_SETTING_UI) {
              $rc->finish_ui();
          }
          if ($rc->get_status() == backup::STATUS_NEED_PRECHECK) {
              if (!$rc->precheck_executed()) {
                  $rc->execute_precheck(true);
              }
              $results = $rc->get_precheck_results();
              if (!empty($results)) {
                  $this->substage = self::SUBSTAGE_PRECHECKS;
              }
          }
  
          $substage = optional_param('substage', null, PARAM_INT);
          if (empty($this->substage) && !empty($substage)) {
              $this->substage = $substage;
              // Now check whether that substage has already been submit.
              if ($this->substage == self::SUBSTAGE_PRECHECKS && optional_param('sesskey', null, PARAM_RAW) == sesskey()) {
                  $info = $rc->get_info();
                  if (!empty($info->role_mappings->mappings)) {
                      foreach ($info->role_mappings->mappings as $key => &$mapping) {
                          $mapping->targetroleid = optional_param('mapping'.$key, $mapping->targetroleid, PARAM_INT);
                      }
                      $info->role_mappings->modified = true;
                  }
                  // We've processed the substage now setting it back to none so we
                  // can move to the next stage.
                  $this->substage = self::SUBSTAGE_NONE;
              }
          }
  
          return empty($this->substage);
      }
code_tokens: public function process ( base_moodleform $ form = null ) { if ( optional_param ( 'cancel' , false , PARAM_BOOL ) ) { redirect ( new moodle_url ( '/course/view.php' , array ( 'id' => $ this -> get_ui ( ) -> get_controller ( ) -> get_courseid ( ) ) ) ) ; } // First decide whether a substage is needed. $ rc = $ this -> ui -> get_controller ( ) ; if ( $ rc -> get_status ( ) == backup :: STATUS_SETTING_UI ) { $ rc -> finish_ui ( ) ; } if ( $ rc -> get_status ( ) == backup :: STATUS_NEED_PRECHECK ) { if ( ! $ rc -> precheck_executed ( ) ) { $ rc -> execute_precheck ( true ) ; } $ results = $ rc -> get_precheck_results ( ) ; if ( ! empty ( $ results ) ) { $ this -> substage = self :: SUBSTAGE_PRECHECKS ; } } $ substage = optional_param ( 'substage' , null , PARAM_INT ) ; if ( empty ( $ this -> substage ) && ! empty ( $ substage ) ) { $ this -> substage = $ substage ; // Now check whether that substage has already been submit. if ( $ this -> substage == self :: SUBSTAGE_PRECHECKS && optional_param ( 'sesskey' , null , PARAM_RAW ) == sesskey ( ) ) { $ info = $ rc -> get_info ( ) ; if ( ! empty ( $ info -> role_mappings -> mappings ) ) { foreach ( $ info -> role_mappings -> mappings as $ key => & $ mapping ) { $ mapping -> targetroleid = optional_param ( 'mapping' . $ key , $ mapping -> targetroleid , PARAM_INT ) ; } $ info -> role_mappings -> modified = true ; } // We've processed the substage now setting it back to none so we // can move to the next stage. $ this -> substage = self :: SUBSTAGE_NONE ; } } return empty ( $ this -> substage ) ; }
docstring: Processes the final stage.
  
  In this case it checks to see if there is a sub stage that we need to display
  before execution, if there is we gear up to display the subpage, otherwise
  we return true which will lead to execution of the restore and the loading
  of the completed stage.
  
  @param base_moodleform $form
docstring_tokens: Processes the final stage .