} } } else { if ($page->action == SYNCH_ACTION_UPDATE) { // action is update if (update_record('synch_servers', $object)) { $page->message = 'The server has been successfully updated. Continue <a href="' . $securewwwroot . $defaultReturnUrl . '" >selecting content</a>'; $page->action == SYNCH_ACTION_READ; } } } // Update the server object with the new parameters $page->server->fromObject($object); } $empty = synch_empty($page->server->id); if (synch_empty($page->server->serverId)) { // Adding a new host $page->action = 1; //create } else { // If there is an id Get the server details from the db $record = get_record('synch_servers', 'serverId', $page->server->serverId); // Update the server object with the new parameters $page->server->fromObject($record); $page->action = 3; //update } /// We've established they can see the user's name at least, so what about the rest? $featuretitle = get_string('synch', 'synch'); $pagetitle = 'Edit Server'; $nav = '<a href="' . $securewwwroot . '/synch/">' . get_string('synchronise', 'synch') . '</a> -> ' . $pagetitle;
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; }