original_string: public function handle_remote_request(tool_installaddon_renderer $output, $request) {
  
          if (is_null($request)) {
              return;
          }
  
          $data = $this->decode_remote_request($request);
  
          if ($data === false) {
              echo $output->remote_request_invalid_page($this->index_url());
              exit();
          }
  
          list($plugintype, $pluginname) = core_component::normalize_component($data->component);
          $pluginman = core_plugin_manager::instance();
  
          $plugintypepath = $pluginman->get_plugintype_root($plugintype);
  
          if (file_exists($plugintypepath.'/'.$pluginname)) {
              echo $output->remote_request_alreadyinstalled_page($data, $this->index_url());
              exit();
          }
  
          if (!$pluginman->is_plugintype_writable($plugintype)) {
              $continueurl = $this->index_url(array('installaddonrequest' => $request));
              echo $output->remote_request_permcheck_page($data, $plugintypepath, $continueurl, $this->index_url());
              exit();
          }
  
          if (!$pluginman->is_remote_plugin_installable($data->component, $data->version, $reason)) {
              $data->reason = $reason;
              echo $output->remote_request_non_installable_page($data, $this->index_url());
              exit();
          }
  
          $continueurl = $this->index_url(array(
              'installremote' => $data->component,
              'installremoteversion' => $data->version
          ));
  
          echo $output->remote_request_confirm_page($data, $continueurl, $this->index_url());
          exit();
      }
code: public function handle_remote_request(tool_installaddon_renderer $output, $request) {
  
          if (is_null($request)) {
              return;
          }
  
          $data = $this->decode_remote_request($request);
  
          if ($data === false) {
              echo $output->remote_request_invalid_page($this->index_url());
              exit();
          }
  
          list($plugintype, $pluginname) = core_component::normalize_component($data->component);
          $pluginman = core_plugin_manager::instance();
  
          $plugintypepath = $pluginman->get_plugintype_root($plugintype);
  
          if (file_exists($plugintypepath.'/'.$pluginname)) {
              echo $output->remote_request_alreadyinstalled_page($data, $this->index_url());
              exit();
          }
  
          if (!$pluginman->is_plugintype_writable($plugintype)) {
              $continueurl = $this->index_url(array('installaddonrequest' => $request));
              echo $output->remote_request_permcheck_page($data, $plugintypepath, $continueurl, $this->index_url());
              exit();
          }
  
          if (!$pluginman->is_remote_plugin_installable($data->component, $data->version, $reason)) {
              $data->reason = $reason;
              echo $output->remote_request_non_installable_page($data, $this->index_url());
              exit();
          }
  
          $continueurl = $this->index_url(array(
              'installremote' => $data->component,
              'installremoteversion' => $data->version
          ));
  
          echo $output->remote_request_confirm_page($data, $continueurl, $this->index_url());
          exit();
      }
code_tokens: public function handle_remote_request ( tool_installaddon_renderer $ output , $ request ) { if ( is_null ( $ request ) ) { return ; } $ data = $ this -> decode_remote_request ( $ request ) ; if ( $ data === false ) { echo $ output -> remote_request_invalid_page ( $ this -> index_url ( ) ) ; exit ( ) ; } list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ data -> component ) ; $ pluginman = core_plugin_manager :: instance ( ) ; $ plugintypepath = $ pluginman -> get_plugintype_root ( $ plugintype ) ; if ( file_exists ( $ plugintypepath . '/' . $ pluginname ) ) { echo $ output -> remote_request_alreadyinstalled_page ( $ data , $ this -> index_url ( ) ) ; exit ( ) ; } if ( ! $ pluginman -> is_plugintype_writable ( $ plugintype ) ) { $ continueurl = $ this -> index_url ( array ( 'installaddonrequest' => $ request ) ) ; echo $ output -> remote_request_permcheck_page ( $ data , $ plugintypepath , $ continueurl , $ this -> index_url ( ) ) ; exit ( ) ; } if ( ! $ pluginman -> is_remote_plugin_installable ( $ data -> component , $ data -> version , $ reason ) ) { $ data -> reason = $ reason ; echo $ output -> remote_request_non_installable_page ( $ data , $ this -> index_url ( ) ) ; exit ( ) ; } $ continueurl = $ this -> index_url ( array ( 'installremote' => $ data -> component , 'installremoteversion' => $ data -> version ) ) ; echo $ output -> remote_request_confirm_page ( $ data , $ continueurl , $ this -> index_url ( ) ) ; exit ( ) ; }
docstring: Hook method to handle the remote request to install an add-on
  
  This is used as a callback when the admin picks a plugin version in the
  Moodle Plugins directory and is redirected back to their site to install
  it.
  
  This hook is called early from admin/tool/installaddon/index.php page so that
  it has opportunity to take over the UI and display the first confirmation screen.
  
  @param tool_installaddon_renderer $output
  @param string|null $request
docstring_tokens: Hook method to handle the remote request to install an add - on