当前位置: 首页>>代码示例>>PHP>>正文


PHP mnet_xmlrpc_client::send方法代码示例

本文整理汇总了PHP中mnet_xmlrpc_client::send方法的典型用法代码示例。如果您正苦于以下问题:PHP mnet_xmlrpc_client::send方法的具体用法?PHP mnet_xmlrpc_client::send怎么用?PHP mnet_xmlrpc_client::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mnet_xmlrpc_client的用法示例。


在下文中一共展示了mnet_xmlrpc_client::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function refresh_key()
 {
     global $CFG;
     // set up an RPC request
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     $mnetrequest = new mnet_xmlrpc_client();
     // Use any method - listServices is pretty lightweight.
     $mnetrequest->set_method('system/listServices');
     // Do RPC call and store response
     if ($mnetrequest->send($this) === true) {
         // Ok - we actually don't care about the result
         $temp = new mnet_peer();
         $temp->set_id($this->id);
         if ($this->public_key != $temp->public_key) {
             $newkey = clean_param($temp->public_key, PARAM_PEM);
             if (!empty($newkey)) {
                 $this->public_key = $newkey;
                 $this->updateparams->public_key = $newkey;
                 $this->commit();
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:25,代码来源:remote_client.php

示例2: mnet_get_externalprofilefields

function mnet_get_externalprofilefields($hostid)
{
    /// Setup MNET environment
    global $MNET, $CFG;
    if (empty($MNET)) {
        $MNET = new mnet_environment();
        $MNET->init();
    }
    /// Setup the server
    $host = get_record('mnet_host', 'id', $hostid);
    //we retrieve the server(host) from the 'mnet_host' table
    if (empty($host)) {
        error('Invalid Hostid');
    }
    $mnet_peer = new mnet_peer();
    //we create a new mnet_peer (server/host)
    $mnet_peer->set_wwwroot($host->wwwroot);
    //we set this mnet_peer with the host http address
    $client = new mnet_xmlrpc_client();
    //create a new client
    $client->set_method('auth/mnet/auth.php/get_user_profile_fields');
    //tell it which method we're going to call
    $client->send($mnet_peer);
    //Call the server
    if (!empty($client->response['faultString'])) {
        error("Mnet error:" . $client->response['faultString']);
    }
    return $client->response;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:29,代码来源:mnet_userprofile.php

示例3: vmoodle_get_remote_config

/**
 * fetches remotely a configuration value
 * @param object $mnethost a mnet host record.
 * @param string $configkey the configuration key
 * @param string $module the module (frankenstyle). If empty, will fetch into the global config scope.
 */
function vmoodle_get_remote_config($mnethost, $configkey, $module = '')
{
    global $CFG, $USER, $DB, $OUTPUT;
    if (empty($mnethost)) {
        return '';
    }
    if (!isset($USER)) {
        $user = $DB->get_record('user', array('username' => 'guest'));
    } else {
        if (empty($USER->id)) {
            $user = $DB->get_record('user', array('username' => 'guest'));
        } else {
            $user = $DB->get_record('user', array('id' => $USER->id));
        }
    }
    if (!($userhost = $DB->get_record('mnet_host', array('id' => $user->mnethostid)))) {
        return '';
    }
    $user->remoteuserhostroot = $userhost->wwwroot;
    $user->remotehostroot = $CFG->wwwroot;
    // get the sessions for each vmoodle that have same ID Number
    $rpcclient = new mnet_xmlrpc_client();
    $rpcclient->set_method('local/vmoodle/plugins/generic/rpclib.php/dataexchange_rpc_fetch_config');
    $rpcclient->add_param($user, 'struct');
    $rpcclient->add_param($configkey, 'string');
    $rpcclient->add_param($module, 'string');
    $mnet_host = new mnet_peer();
    if (empty($mnet_host)) {
        return;
    }
    $mnet_host->set_wwwroot($mnethost->wwwroot);
    if ($rpcclient->send($mnet_host)) {
        $response = json_decode($rpcclient->response);
        if ($response->status == 200) {
            return $response->value;
        } else {
            if (debugging()) {
                echo $OUTPUT->notification('Remote RPC error ' . implode('<br/>', $response->errors));
            }
        }
    } else {
        if (debugging()) {
            echo $OUTPUT->notification('Remote RPC failure ' . implode('<br/', $rpcclient->error));
        }
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:52,代码来源:lib.php

示例4: call

 function call($paramArray = null)
 {
     global $CFG;
     // For the demo, our 'remote' host is actually our local host.
     $wwwroot = $CFG->wwwroot;
     // mnet_peer pulls information about a remote host from the database.
     $mnet_peer = new mnet_peer();
     $mnet_peer->set_wwwroot($wwwroot);
     //$mnethostid = 1010000003;
     //$mnethostid = 1010000001;
     //$mnet_peer->set_id($mnethostid);
     $method = 'synch/mnet/synch.php/testResponse';
     //$paramArray = array();
     // Create a new request object
     $mnet_request = new mnet_xmlrpc_client();
     // Tell it the path to the method that we want to execute
     $mnet_request->set_method($method);
     global $Out;
     //$Out->print_r($paramArray, '$paramArray = ');
     if (!empty($paramArray)) {
         // Add parameters for your function. The mnet_concatenate_strings takes three
         // parameters, like mnet_concatenate_strings($string1, $string2, $string3)
         // PHP is weakly typed, so you can get away with calling most things strings,
         // unless it's non-scalar (i.e. an array or object or something).
         foreach ($paramArray as $param) {
             $mnet_request->add_param($param[0], $param[1]);
         }
     }
     //$Out->print_r($mnet_request->params, '$mnet_request->params = ');
     if (false && count($mnet_request->params)) {
         $Out->append('Your parameters are:<br />');
         while (list($key, $val) = each($mnet_request->params)) {
             $Out->append('&nbsp;&nbsp; <strong>' . $key . ':</strong> ' . $val . "<br/>\n");
         }
     }
     // We send the request:
     $mnet_request->send($mnet_peer);
     //$Out->append('$mnet_request->response = '.$mnet_request->response);
     //$Out->flush();
     return $mnet_request->response;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:41,代码来源:test_localWebService.php

示例5:

 function refresh_key()
 {
     // set up an RPC request
     $mnetrequest = new mnet_xmlrpc_client();
     // Use any method - listServices is pretty lightweight.
     $mnetrequest->set_method('system/listServices');
     // Do RPC call and store response
     if ($mnetrequest->send($this) === true) {
         // Ok - we actually don't care about the result
         $temp = new mnet_peer();
         $temp->set_id($this->id);
         if ($this->public_key != $temp->public_key) {
             $newkey = param_clean($temp->public_key, PARAM_PEM);
             if (!empty($newkey)) {
                 $this->public_key = $newkey;
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:21,代码来源:remote_client.php

示例6:

 /**
  * Does Foo
  *
  * @param int    $mnethostid The id of the remote mnethost
  * @return array              Whether the user can login from the remote host
  */
 function req_unenrol_user($userid, $courseid)
 {
     global $CFG;
     global $USER;
     global $MNET;
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     // in case the remote host doesn't have it
     $username = get_field('user', 'username', 'id', $userid);
     $course = get_record('mnet_enrol_course', 'id', $courseid);
     // get the Service Provider info
     $mnet_sp = new mnet_peer();
     $mnet_sp->set_id($course->hostid);
     // set up the RPC request
     $mnetrequest = new mnet_xmlrpc_client();
     $mnetrequest->set_method('enrol/mnet/enrol.php/unenrol_user');
     $mnetrequest->add_param($username);
     $mnetrequest->add_param($course->remoteid);
     // TODO - prevent removal of enrolments that are not of
     // type mnet...
     // Thunderbirds are go! Do RPC call and store response
     if ($mnetrequest->send($mnet_sp) === true) {
         if ($mnetrequest->response == true) {
             // remove enrolment cached in mnet_enrol_assignments
             delete_records_select('mnet_enrol_assignments', "userid={$userid} AND courseid={$course->id}");
             return true;
         }
     }
     return false;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:35,代码来源:enrol.php

示例7: mnet_get_service_info

/**
 * return an array information about services enabled for the given peer.
 * in two modes, fulldata or very basic data.
 *
 * @param mnet_peer $mnet_peer the peer to get information abut
 * @param boolean   $fulldata whether to just return which services are published/subscribed, or more information (defaults to full)
 *
 * @return array  If $fulldata is false, an array is returned like:
 *                publish => array(
 *                    serviceid => boolean,
 *                    serviceid => boolean,
 *                ),
 *                subscribe => array(
 *                    serviceid => boolean,
 *                    serviceid => boolean,
 *                )
 *                If $fulldata is true, an array is returned like:
 *                servicename => array(
 *                   apiversion => array(
 *                        name           => string
 *                        offer          => boolean
 *                        apiversion     => int
 *                        plugintype     => string
 *                        pluginname     => string
 *                        hostsubscribes => boolean
 *                        hostpublishes  => boolean
 *                   ),
 *               )
 */
function mnet_get_service_info(mnet_peer $mnet_peer, $fulldata=true) {
    global $CFG, $DB;

    $requestkey = (!empty($fulldata) ? 'fulldata' : 'mydata');

    static $cache = array();
    if (array_key_exists($mnet_peer->id, $cache)) {
        return $cache[$mnet_peer->id][$requestkey];
    }

    $id_list = $mnet_peer->id;
    if (!empty($CFG->mnet_all_hosts_id)) {
        $id_list .= ', '.$CFG->mnet_all_hosts_id;
    }

    $concat = $DB->sql_concat('COALESCE(h2s.id,0) ', ' \'-\' ', ' svc.id', '\'-\'', 'r.plugintype', '\'-\'', 'r.pluginname');

    $query = "
        SELECT DISTINCT
            $concat as id,
            svc.id as serviceid,
            svc.name,
            svc.offer,
            svc.apiversion,
            r.plugintype,
            r.pluginname,
            h2s.hostid,
            h2s.publish,
            h2s.subscribe
        FROM
            {mnet_service2rpc} s2r,
            {mnet_rpc} r,
            {mnet_service} svc
        LEFT JOIN
            {mnet_host2service} h2s
        ON
            h2s.hostid in ($id_list) AND
            h2s.serviceid = svc.id
        WHERE
            svc.offer = '1' AND
            s2r.serviceid = svc.id AND
            s2r.rpcid = r.id
        ORDER BY
            svc.name ASC";

    $resultset = $DB->get_records_sql($query);

    if (is_array($resultset)) {
        $resultset = array_values($resultset);
    } else {
        $resultset = array();
    }

    require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';

    $remoteservices = array();
    if ($mnet_peer->id != $CFG->mnet_all_hosts_id) {
        // Create a new request object
        $mnet_request = new mnet_xmlrpc_client();

        // Tell it the path to the method that we want to execute
        $mnet_request->set_method('system/listServices');
        $mnet_request->send($mnet_peer);
        if (is_array($mnet_request->response)) {
            foreach($mnet_request->response as $service) {
                $remoteservices[$service['name']][$service['apiversion']] = $service;
            }
        }
    }

    $myservices = array();
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:lib.php

示例8: get_file

 /**
  * Download a file
  * @global object $CFG
  * @param string $url the url of file
  * @param string $file save location
  * @return string the location of the file
  * @see curl package
  */
 public function get_file($url, $file = '')
 {
     global $CFG, $DB, $USER;
     ///set mnet environment and set the mnet host
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     $this->ensure_environment();
     $host = $DB->get_record('mnet_host', array('id' => $this->options['peer']));
     //retrieve the host url
     $mnet_peer = new mnet_peer();
     $mnet_peer->set_wwwroot($host->wwwroot);
     ///create the client and set the method to call
     $client = new mnet_xmlrpc_client();
     $client->set_method('repository/remotemoodle/repository.class.php/retrieveFile');
     $client->add_param($USER->username);
     $client->add_param($url);
     ///call the method and manage host error
     if (!$client->send($mnet_peer)) {
         $message = " ";
         foreach ($client->error as $errormessage) {
             $message .= "ERROR: {$errormessage} . ";
         }
         echo json_encode(array('e' => $message));
         exit;
     }
     $services = $client->response;
     //service contains the file content in the first case of the array,
     //and the filename in the second
     //the content has been encoded in base64, need to decode it
     $content = base64_decode($services[0]);
     $file = $services[1];
     //filename
     ///create a temporary folder with a file
     $path = $this->prepare_file($file);
     ///fill the file with the content
     $fp = fopen($path, 'w');
     fwrite($fp, $content);
     fclose($fp);
     return $path;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:47,代码来源:repository.class.php

示例9: list

        // tracker is local, use the rpc entry point anyway
        $result = tracker_rpc_post_issue($tracker->parent, $USER->id, json_encode($issue));
    } else {
        // tracker is remote, make an RPC call
        list($remoteid, $mnet_host) = explode('@', $tracker->parent);
        // get network tracker properties
        include_once $CFG->dirroot . "/mnet/xmlrpc/client.php";
        $rpcclient = new mnet_xmlrpc_client();
        $rpcclient->set_method('mod/tracker/rpclib.php/tracker_rpc_post_issue');
        $rpcclient->add_param($USER->username, 'string');
        $rpcclient->add_param($CFG->wwwroot, 'string');
        $rpcclient->add_param($remoteid, 'int');
        $rpcclient->add_param(json_encode($issue), 'string');
        $parent_mnet = new mnet_peer();
        $parent_mnet->set_wwwroot($mnet_host);
        $result = $rpcclient->send($parent_mnet);
    }
    if ($result) {
        if ($rpcclient->response['status'] == RPC_SUCCESS) {
            $issue->status = TRANSFERED;
            $issue->followid = $rpcclient->response['followid'];
            if (!update_record('tracker_issue', $issue)) {
                error("Could not update issue for cascade");
            }
        } else {
            error("Error on remote side<br/>" . $result->error);
        }
    } else {
        error("Error on sending cascade :<br/>" . implode('<br/>', $rpcclient->error));
    }
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:view.controller.php

示例10: taoview_call_mnet

function taoview_call_mnet($viewtype)
{
    /// Setup MNET environment
    global $MNET, $CFG;
    if (empty($MNET)) {
        $MNET = new mnet_environment();
        $MNET->init();
    }
    /// Setup the server
    $host = get_record('mnet_host', 'name', 'localmahara');
    //we retrieve the server(host) from the 'mnet_host' table
    if (empty($host)) {
        error('Mahara not configured');
    }
    $a = new stdclass();
    $a->link = $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . $host->id . '&wantsurl=local/taoview.php?view=' . $viewtype;
    echo '<div class="taoviwdesc">';
    print_string('toaddartefacts', 'local', $a);
    echo '</div>';
    $mnet_peer = new mnet_peer();
    //we create a new mnet_peer (server/host)
    $mnet_peer->set_wwwroot($host->wwwroot);
    //we set this mnet_peer with the host http address
    $client = new mnet_xmlrpc_client();
    //create a new client
    $client->set_method('local/mahara/rpclib.php/get_artefacts_by_viewtype');
    //tell it which method we're going to call
    $client->add_param($viewtype);
    $client->send($mnet_peer);
    //Call the server
    if (!empty($client->response['faultString'])) {
        error("Mahara error:" . $artefacts['faultString']);
    }
    return $client->response;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:35,代码来源:taoviewlib.php

示例11: local_mahara_mnet_call

function local_mahara_mnet_call()
{
    global $CFG, $MNET;
    if ($CFG->mnet_dispatcher_mode != 'strict') {
        return;
    }
    if (!($host = get_record('mnet_host', 'name', 'localmahara'))) {
        return;
    }
    require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
    if (empty($MNET)) {
        $MNET = new mnet_environment();
        $MNET->init();
    }
    $args = func_get_args();
    $method = array_shift($args);
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_wwwroot($host->wwwroot);
    $client = new mnet_xmlrpc_client();
    $client->set_method($method);
    foreach ($args as $a) {
        $client->add_param($a);
    }
    $client->send($mnet_peer);
    return $client->response;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:26,代码来源:lib.php

示例12: send

 /**
  * Send the request to the server or execute function if is a local call.
  * @param $host mnet_peer A mnet_peer object with details of the remote host we're connecting to.
  * @return boolean True if the request is successfull, False otherwise.
  */
 public function send($host)
 {
     global $CFG;
     // Defining result
     $return = false;
     $this->error = array();
     // Checking if is a local call
     if ($host->wwwroot == $CFG->wwwroot) {
         // Getting method
         $uri = explode('/', $this->method);
         $method = array_pop($uri);
         $file = implode('/', $uri);
         // Adding librairie
         if (!(include_once $CFG->dirroot . '/' . $file)) {
             $this->error[] = 'No such file.';
         } else {
             if (!function_exists($method)) {
                 $this->error[] = 'No such function.';
             } else {
                 $this->response = call_user_func_array($method, $this->params);
                 $result = true;
             }
         }
     } else {
         // Make the default remote call
         $result = parent::send($host);
     }
     // Capturing host errors
     $this->host_errors[$host->wwwroot] = $this->error;
     // Reseting errors for next send
     $this->error = array();
     // Returning result
     return $result;
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:39,代码来源:XmlRpc_Client.php

示例13: callRemoteMethod

 public function callRemoteMethod($method, $parameters, $server = null)
 {
     global $CFG, $SynchServerController;
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     // For the demo, our 'remote' host is actually our local host.
     $wwwroot = $CFG->wwwroot;
     //$method = 'synch/mnet/synch.php/getBackupById';
     // Get local server.
     $localServer = $SynchServerController->checkAndCreateLocalServer();
     global $Out;
     //$Out->print_r($localServer, '$localServer = ');
     // Cannot continue without a local server
     if (empty($localServer)) {
         return null;
     }
     if (empty($server)) {
         //$Out->append('Generating default remote server');
         //$server = new synch_modal_Server();
         //$server->mnetHostId = 1020000003;
         $server = $SynchServerController->getRemoteServer();
     }
     //$Out->print_r($server, '$server = ');
     // Cannot continue without a remote server to call
     if (empty($server) || synch_empty($server->mnetHostId)) {
         return null;
     }
     // mnet_peer pulls information about a remote host from the database.
     $mnet_peer = new mnet_peer();
     $mnet_peer->set_wwwroot($wwwroot);
     $mnethostid = $server->mnetHostId;
     $mnet_peer->set_id($mnethostid);
     // Create a new request object
     $mnet_request = new mnet_xmlrpc_client();
     // Tell it the path to the method that we want to execute
     $mnet_request->set_method($method);
     // Set the time out to something decent in seconds
     //$mnet_request->set_timeout(600);
     //set_time_limit(120);
     // Add parameters for your function. The mnet_concatenate_strings takes three
     // parameters, like mnet_concatenate_strings($string1, $string2, $string3)
     // PHP is weakly typed, so you can get away with calling most things strings,
     // unless it's non-scalar (i.e. an array or object or something).
     foreach ($parameters as $param) {
         $mnet_request->add_param($param[0], $param[1]);
     }
     // We send the request:
     $mnet_request->send($mnet_peer);
     return $mnet_request->response;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:49,代码来源:synch_synch_controller.php

示例14: mnetadmin_rpc_remote_enrol


//.........这里部分代码省略.........
                $course = $DB->get_record('course', array('idnumber' => $courseidentifier));
                break;
        }
        if (!$course) {
            $extresponse->status = RPC_FAILURE_RECORD;
            $extresponse->errors[] = "Unkown course {$courseidentifier} based on {$courseidfield}.";
            $extresponse->error = "Unkown course {$courseidentifier} based on {$courseidfield}.";
            if (function_exists('debug_trace')) {
                debug_trace("Unkown course based on {$courseidfield} with {$courseidentifier} ");
            }
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        }
        // Getting role if default.
        if (empty($rolename)) {
            $rolename = $course->defaultrolename;
        }
        if (function_exists('debug_trace')) {
            debug_trace("Bounce to mnetadmin_rpc_assignrole");
        }
        $extresponse = mnetadmin_rpc_assign_role($callinguser, $targetuser, $rolename, 'id', CONTEXT_COURSE, $course->id, $starttime, $endtime, $json_response);
        if (!$json_response) {
            return json_decode($extresponse);
        } else {
            return $extresponse;
        }
    } else {
        if (function_exists('debug_trace')) {
            debug_trace('remote source process');
        }
        // Make remote call.
        $userhostroot = $DB->get_field_select('mnet_host', 'wwwroot', " id = {$USER->mnethostid} AND deleted = 0 ");
        if (!$userhostroot) {
            $extresponse->error = 'Unkown user host root (or deleted).';
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        }
        if (!$DB->record_exists('mnet_host', array('wwwroot' => $whereroot, 'deleted' => 0))) {
            $extresponse->error = '$whereroot is unknown host or deleted.';
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        }
        $rpcclient = new mnet_xmlrpc_client();
        $rpcclient->set_method('local/vmoodle/plugins/roles/rpclib.php/mnetadmin_rpc_remote_enrol');
        $caller = new StdClass();
        $caller->username = $USER->username;
        $caller->remoteuserhostroot = $userhostroot;
        $caller->remotehostroot = $CFG->wwwroot;
        $rpcclient->add_param($caller, 'struct');
        // caller user
        $rpcclient->add_param($targetuser, 'string');
        $rpcclient->add_param($rolename, 'string');
        $rpcclient->add_param($whereroot, 'string');
        $rpcclient->add_param($courseidfield, 'string');
        $rpcclient->add_param($courseidentifier, 'string');
        $rpcclient->add_param($starttime, 'int');
        $rpcclient->add_param($endtime, 'int');
        $mnet_host = new mnet_peer();
        $mnet_host->set_wwwroot($whereroot);
        if (!$rpcclient->send($mnet_host)) {
            $extresponse->status = RPC_FAILURE;
            $extresponse->errors[] = 'REMOTE : ' . implode("<br/>\n", @$rpcclient->errors);
            $extresponse->error = 'REMOTE : ' . implode("<br/>\n", @$rpcclient->errors);
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        }
        $response = json_decode($rpcclient->response);
        if ($response->status == 200) {
            $extresponse->message = 'remote enrol success';
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        } else {
            $extresponse->status = RPC_FAILURE;
            $extresponse->errors = array();
            $extresponse->errors[] = 'Remote application errors : ';
            $extresponse->errors = array_merge($extresponse->errors, $response->errors);
            $extresponse->error = 'Remote application error.';
            if ($json_response) {
                return json_encode($extresponse);
            } else {
                return $extresponse;
            }
        }
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:101,代码来源:rpclib.php

示例15: send_intent

 /**
 * sends the 'content_intent' ping to mahara
 * if all goes well, this will set the 'token' and 'sendtype' member variables.
 */
 public function send_intent() {
     global $CFG, $DB;
     require_once($CFG->dirroot . '/mnet/xmlrpc/client.php');
     $client = new mnet_xmlrpc_client();
     $client->set_method('portfolio/mahara/lib.php/send_content_intent');
     $client->add_param($this->get('user')->username);
     $this->ensure_mnethost();
     if (!$client->send($this->mnethost)) {
         foreach ($client->error as $errormessage) {
             list($code, $message) = array_map('trim',explode(':', $errormessage, 2));
             $message .= "ERROR $code:<br/>$errormessage<br/>";
         }
         throw new portfolio_export_exception($this->get('exporter'), 'failedtoping', 'portfolio_mahara', '', $message);
     }
     // we should get back... the send type and a shared token
     $response = (object)$client->response;
     if (empty($response->sendtype) || empty($response->token)) {
         throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara');
     }
     switch ($response->sendtype) {
         case 'immediate':
             $this->sendtype = PORTFOLIO_MAHARA_IMMEDIATE;
             break;
         case 'queue':
             $this->sendtype = PORTFOLIO_MAHARA_QUEUE;
             break;
         case 'none':
         default:
             throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara');
     }
     $this->token = $response->token;
     $this->get('exporter')->save();
     // put the entry in the mahara queue table now too
     $q = new stdClass;
     $q->token = $this->token;
     $q->transferid = $this->get('exporter')->get('id');
     $DB->insert_record('portfolio_mahara_queue', $q);
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:42,代码来源:lib.php


注:本文中的mnet_xmlrpc_client::send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。