original_string: function permission_to_call($mnet_peer) {
          global $DB, $CFG, $USER;
  
          // Executing any system method is permitted.
          $system_methods = array('system/listMethods', 'system/methodSignature', 'system/methodHelp', 'system/listServices');
          if (in_array($this->method, $system_methods) ) {
              return true;
          }
  
          $hostids = array($mnet_peer->id);
          if (!empty($CFG->mnet_all_hosts_id)) {
              $hostids[] = $CFG->mnet_all_hosts_id;
          }
          // At this point, we don't care if the remote host implements the
          // method we're trying to call. We just want to know that:
          // 1. The method belongs to some service, as far as OUR host knows
          // 2. We are allowed to subscribe to that service on this mnet_peer
  
          list($hostidsql, $hostidparams) = $DB->get_in_or_equal($hostids);
  
          $sql = "SELECT r.id
                    FROM {mnet_remote_rpc} r
              INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id
              INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid
                   WHERE r.xmlrpcpath = ?
                         AND h2s.subscribe = ?
                         AND h2s.hostid $hostidsql";
  
          $params = array($this->method, 1);
          $params = array_merge($params, $hostidparams);
  
          if ($DB->record_exists_sql($sql, $params)) {
              return true;
          }
  
          $this->error[] = '7:User with ID '. $USER->id .
                           ' attempted to call unauthorised method '.
                           $this->method.' on host '.
                           $mnet_peer->wwwroot;
          return false;
      }
code: function permission_to_call($mnet_peer) {
          global $DB, $CFG, $USER;
  
          // Executing any system method is permitted.
          $system_methods = array('system/listMethods', 'system/methodSignature', 'system/methodHelp', 'system/listServices');
          if (in_array($this->method, $system_methods) ) {
              return true;
          }
  
          $hostids = array($mnet_peer->id);
          if (!empty($CFG->mnet_all_hosts_id)) {
              $hostids[] = $CFG->mnet_all_hosts_id;
          }
          // At this point, we don't care if the remote host implements the
          // method we're trying to call. We just want to know that:
          // 1. The method belongs to some service, as far as OUR host knows
          // 2. We are allowed to subscribe to that service on this mnet_peer
  
          list($hostidsql, $hostidparams) = $DB->get_in_or_equal($hostids);
  
          $sql = "SELECT r.id
                    FROM {mnet_remote_rpc} r
              INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id
              INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid
                   WHERE r.xmlrpcpath = ?
                         AND h2s.subscribe = ?
                         AND h2s.hostid $hostidsql";
  
          $params = array($this->method, 1);
          $params = array_merge($params, $hostidparams);
  
          if ($DB->record_exists_sql($sql, $params)) {
              return true;
          }
  
          $this->error[] = '7:User with ID '. $USER->id .
                           ' attempted to call unauthorised method '.
                           $this->method.' on host '.
                           $mnet_peer->wwwroot;
          return false;
      }
code_tokens: function permission_to_call ( $ mnet_peer ) { global $ DB , $ CFG , $ USER ; // Executing any system method is permitted. $ system_methods = array ( 'system/listMethods' , 'system/methodSignature' , 'system/methodHelp' , 'system/listServices' ) ; if ( in_array ( $ this -> method , $ system_methods ) ) { return true ; } $ hostids = array ( $ mnet_peer -> id ) ; if ( ! empty ( $ CFG -> mnet_all_hosts_id ) ) { $ hostids [ ] = $ CFG -> mnet_all_hosts_id ; } // At this point, we don't care if the remote host implements the // method we're trying to call. We just want to know that: // 1. The method belongs to some service, as far as OUR host knows // 2. We are allowed to subscribe to that service on this mnet_peer list ( $ hostidsql , $ hostidparams ) = $ DB -> get_in_or_equal ( $ hostids ) ; $ sql = "SELECT r.id
                    FROM {mnet_remote_rpc} r
              INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id
              INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid
                   WHERE r.xmlrpcpath = ?
                         AND h2s.subscribe = ?
                         AND h2s.hostid $hostidsql" ; $ params = array ( $ this -> method , 1 ) ; $ params = array_merge ( $ params , $ hostidparams ) ; if ( $ DB -> record_exists_sql ( $ sql , $ params ) ) { return true ; } $ this -> error [ ] = '7:User with ID ' . $ USER -> id . ' attempted to call unauthorised method ' . $ this -> method . ' on host ' . $ mnet_peer -> wwwroot ; return false ; }
docstring: Check that we are permitted to call method on specified peer
  
  @param object $mnet_peer A mnet_peer object with details of the remote host we're connecting to
  @return bool True if we permit calls to method on specified peer, False otherwise.
docstring_tokens: Check that we are permitted to call method on specified peer