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


PHP mnet_peer类代码示例

本文整理汇总了PHP中mnet_peer的典型用法代码示例。如果您正苦于以下问题:PHP mnet_peer类的具体用法?PHP mnet_peer怎么用?PHP mnet_peer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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

示例2: refresh_key

 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

示例3: run

 /**
  * Execute the command.
  * @param mixed $hosts The host where run the command (may be wwwroot or an array).
  * @throws Command_Exception.
  */
 public function run($hosts)
 {
     global $CFG, $USER;
     // Adding constants.
     require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
     // Checking capabilities.
     if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
         throw new Command_Exception('insuffisantcapabilities');
     }
     // Getting role
     $table = $this->getParameter('table')->getValue();
     // Creating XMLRPC client to read role configuration
     $rpc_client = new \local_vmoodle\XmlRpc_Client();
     $rpc_client->set_method('local/vmoodle/plugins/roles/rpclib.php/mnetadmin_rpc_get_role_allow_table');
     $rpc_client->add_param($table, 'string');
     $rpc_client->add_param('', 'string');
     // get for all roles
     // Initializing responses
     $responses = array();
     // Creating peers.
     $mnet_hosts = array();
     foreach ($hosts as $host => $name) {
         $mnet_host = new \mnet_peer();
         if ($mnet_host->bootstrap($host, null, 'moodle')) {
             $mnet_hosts[] = $mnet_host;
         } else {
             $responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
         }
     }
     // Sending requests.
     foreach ($mnet_hosts as $mnet_host) {
         // Sending request.
         if (!$rpc_client->send($mnet_host)) {
             $response = new \StdClass();
             $response->status = MNET_FAILURE;
             $response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
             if (debugging()) {
                 echo '<pre>';
                 var_dump($rpc_client);
                 echo '</pre>';
             }
         } else {
             $response = json_decode($rpc_client->response);
         }
         // Recording response.
         $responses[$mnet_host->wwwroot] = $response;
         // Recording capabilities.
         if ($response->status == RPC_SUCCESS) {
             $this->capabilities[$mnet_host->wwwroot] = $response->value;
         }
     }
     // Saving results.
     $this->results = $responses + $this->results;
     // Processing results.
     $this->_process();
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:61,代码来源:Command_Role_Allow_Compare.php

示例4: run

 /**
  * Execute the command.
  * @param mixed $host The hosts where run the command (may be wwwroot or an array).
  * @throws Command_SetConfig_Exception
  */
 public function run($hosts)
 {
     global $CFG, $USER;
     // Adding constants.
     require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
     // Checking host.
     if (!is_array($hosts)) {
         $hosts = array($hosts => 'Unnamed host');
     }
     // Checking capabilities.
     if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
         throw new Command_SetConfig_Exception('insuffisantcapabilities');
     }
     // Initializing responses.
     $responses = array();
     // Creating peers.
     $mnet_hosts = array();
     foreach ($hosts as $host => $name) {
         $mnet_host = new \mnet_peer();
         if ($mnet_host->bootstrap($host, null, 'moodle')) {
             $mnet_hosts[] = $mnet_host;
         } else {
             $responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
         }
     }
     // Getting command.
     $command = $this->isReturned();
     // Creating XMLRPC client.
     $rpc_client = new \local_vmoodle\XmlRpc_Client();
     $rpc_client->set_method('local/vmoodle/plugins/generic/rpclib.php/mnetadmin_rpc_set_config');
     $rpc_client->add_param($this->getParameter('key')->getValue(), 'string');
     $rpc_client->add_param($this->getParameter('value')->getValue(), 'string');
     $rpc_client->add_param(null, 'string');
     $rpc_client->add_param($command, 'boolean');
     // Sending requests.
     foreach ($mnet_hosts as $mnet_host) {
         // Sending request.
         if (!$rpc_client->send($mnet_host)) {
             $response = new StdClass();
             $response->status = MNET_FAILURE;
             $response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
             if (debugging()) {
                 echo '<pre>';
                 var_dump($rpc_client);
                 echo '</pre>';
             }
         } else {
             $response = json_decode($rpc_client->response);
         }
         // Recording response.
         $responses[$mnet_host->wwwroot] = $response;
     }
     // Saving results.
     $this->results = $responses + $this->results;
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:60,代码来源:Command_SetConfig.php

示例5: vmoodle_get_field

/**
 * Get fields values of a virtual platform via MNET service.
 * @param string $host The virtual platform to aim.
 * @param string $table The table to read.
 * @param mixed $select The value of id or alternative field.
 * @param string $fields The fileds to retrieve (optional).
 * @throws Vmoodle_Command_Sql_Exception.
 */
function vmoodle_get_field($host, $table, $select, $fields = '*')
{
    global $CFG, $USER, $DB;
    // Checking capabilities.
    if (!has_capability('local/vmoodle:execute', context_system::instance())) {
        throw new Command_Sql_Exception('unsiffisantcapability');
    }
    // Checking host.
    if (!$DB->get_record('mnet_host', array('wwwroot' => $host))) {
        throw new Command_Sql_Exception('invalidhost');
    }
    // Checking table.
    if (empty($table) || !is_string($table)) {
        throw new Command_Sql_Exception('invalidtable');
    }
    // Checking select.
    if (empty($select) || !is_array($select) && !is_int($select)) {
        throw new Command_Sql_Exception('invalidselect');
    }
    if (!is_array($select)) {
        $select = array('id' => $select);
    }
    // Checking field.
    if (empty($fields)) {
        throw new Command_Sql_Exception('invalidfields');
    }
    if (!is_array($fields)) {
        $fields = array($fields);
    }
    // Creating peer.
    $mnet_host = new mnet_peer();
    if (!$mnet_host->bootstrap($host, null, 'moodle')) {
        return (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'vmoodleadminset_sql', $host));
    }
    // Creating XMLRPC client.
    $rpc_client = new \bock_vmoodle\XmlRpc_Client();
    $rpc_client->add_param($table, 'string');
    $rpc_client->add_param($fields, 'array');
    $rpc_client->add_param($select, 'array');
    // Sending request.
    if (!$rpc_client->send($mnet_host)) {
        if (debugging()) {
            echo '<pre>';
            var_dump($rpc_client);
            echo '</pre>';
        }
    }
    // Returning result.
    return $rpc_client->response;
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:58,代码来源:lib.php

示例6: 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

示例7: 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

示例8: refresh_key

 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

示例9: admin_externalpage_setup

}
$PAGE->set_url('/admin/mnet/peers.php');
admin_externalpage_setup($adminsection);
if (!extension_loaded('openssl')) {
    print_error('requiresopenssl', 'mnet');
}
if (!function_exists('curl_init')) {
    print_error('nocurl', 'mnet');
}
if (!function_exists('xmlrpc_encode_request')) {
    print_error('xmlrpc-missing', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
    set_config('mnet_dispatcher_mode', 'off');
}
$mnet_peer = new mnet_peer();
$simpleform = new mnet_simple_host_form();
// the one that goes on the bottom of the main page
$reviewform = null;
// set up later in different code branches, so mnet_peer can be passed to the constructor
// if the first form has been submitted, bootstrap the peer and load up the review form
if ($formdata = $simpleform->get_data()) {
    // ensure we remove trailing slashes
    $formdata->wwwroot = trim($formdata->wwwroot);
    $formdata->wwwroot = rtrim($formdata->wwwroot, '/');
    // ensure the wwwroot starts with a http or https prefix
    if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') {
        $formdata->wwwroot = 'http://' . $formdata->wwwroot;
    }
    $mnet_peer->set_applicationid($formdata->applicationid);
    $application = $DB->get_field('mnet_application', 'name', array('id' => $formdata->applicationid));
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:peers.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: resolve_theme

    /**
     * Work out the theme this page should use.
     *
     * This depends on numerous $CFG settings, and the properties of this page.
     *
     * @return string the name of the theme that should be used on this page.
     */
    protected function resolve_theme() {
        global $CFG, $USER, $SESSION;

        if (empty($CFG->themeorder)) {
            $themeorder = array('course', 'category', 'session', 'user', 'site');
        } else {
            $themeorder = $CFG->themeorder;
            // Just in case, make sure we always use the site theme if nothing else matched.
            $themeorder[] = 'site';
        }

        $mnetpeertheme = '';
        if (isloggedin() and isset($CFG->mnet_localhost_id) and $USER->mnethostid != $CFG->mnet_localhost_id) {
            require_once($CFG->dirroot.'/mnet/peer.php');
            $mnetpeer = new mnet_peer();
            $mnetpeer->set_id($USER->mnethostid);
            if ($mnetpeer->force_theme == 1 && $mnetpeer->theme != '') {
                $mnetpeertheme = $mnetpeer->theme;
            }
        }

        foreach ($themeorder as $themetype) {
            switch ($themetype) {
                case 'course':
                    if (!empty($CFG->allowcoursethemes) && !empty($this->_course->theme) && $this->devicetypeinuse == 'default') {
                        return $this->_course->theme;
                    }

                case 'category':
                    if (!empty($CFG->allowcategorythemes) && $this->devicetypeinuse == 'default') {
                        $categories = $this->categories;
                        foreach ($categories as $category) {
                            if (!empty($category->theme)) {
                                return $category->theme;
                            }
                        }
                    }

                case 'session':
                    if (!empty($SESSION->theme)) {
                        return $SESSION->theme;
                    }

                case 'user':
                    if (!empty($CFG->allowuserthemes) && !empty($USER->theme) && $this->devicetypeinuse == 'default') {
                        if ($mnetpeertheme) {
                            return $mnetpeertheme;
                        } else {
                            return $USER->theme;
                        }
                    }

                case 'site':
                    if ($mnetpeertheme) {
                        return $mnetpeertheme;
                    }
                    // First try for the device the user is using.
                    $devicetheme = get_selected_theme_for_device_type($this->devicetypeinuse);
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // Next try for the default device (as a fallback)
                    $devicetheme = get_selected_theme_for_device_type('default');
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // The default device theme isn't set up - use the overall default theme.
                    return theme_config::DEFAULT_THEME;
            }
        }
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:78,代码来源:pagelib.php

示例12: mnet_peer

        continue;
    }
    // Skip localhost
    if ($host->wwwroot == $CFG->wwwroot) {
        continue;
    }
    // Skip non-moodle hosts
    if ($host->applicationid != 1 && $host->applicationid != 2) {
        continue;
    }
    //TODO: get rid of magic numbers.
    echo '<p><a href="testclient.php?hostid=' . $host->id . '">' . $host->wwwroot . "</a></p>\n";
}
if (!empty($_GET['hostid']) && array_key_exists($_GET['hostid'], $hosts)) {
    $host = $hosts[$_GET['hostid']];
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_wwwroot($host->wwwroot);
    $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);
    $services = $mnet_request->response;
    $yesno = array('No', 'Yes');
    $servicenames = array();
    echo '<hr /><br /><h3>Services available on host: ' . $host->wwwroot . '</h3><table><tr valign="top"><th>&nbsp;&nbsp;Service ID&nbsp;&nbsp;</th><th>&nbsp;&nbsp;Service&nbsp;&nbsp;</th><th>&nbsp;&nbsp;Version&nbsp;&nbsp;</th><th>&nbsp;&nbsp;They Publish&nbsp;&nbsp;</th><th>&nbsp;&nbsp;They Subscribe&nbsp;&nbsp;</th><th></th></tr>';
    foreach ($services as $id => $service) {
        $sql = 'select c.id, c.parent_type, c.parent from ' . $CFG->prefix . 'mnet_service2rpc a,' . $CFG->prefix . 'mnet_service b, ' . $CFG->prefix . 'mnet_rpc c where a.serviceid = b.id and b.name=\'' . addslashes($service['name']) . '\' and c.id = a.rpcid ';
        echo '<tr valign="top">
                <td>' . $service['name'] . '</td>';
        if ($detail = get_record_sql($sql)) {
            $service['humanname'] = get_string($service['name'] . '_name', $detail->parent_type . '_' . $detail->parent);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:testclient.php

示例13: print_error

                print_error("hostexists", 'mnet', 'peers.php?step=update&amp;hostid=' . $mnet_peer->id, $mnet_peer->id);
            }
        }
        if ('input' == $form->step) {
            include './mnet_review.html';
        } elseif ('commit' == $form->step) {
            $bool = $mnet_peer->commit();
            if ($bool) {
                redirect('peers.php?step=update&amp;hostid=' . $mnet_peer->id, get_string('changessaved'));
            } else {
                print_error('invalidaction', 'error', 'index.php');
            }
        }
    }
} elseif (is_int($hostid)) {
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_id($hostid);
    $currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
    if ($currentkey == $mnet_peer->public_key) {
        unset($currentkey);
    }
    $form = new stdClass();
    if ($hostid != $CFG->mnet_all_hosts_id) {
        $credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
        include './mnet_review.html';
    } else {
        include './mnet_review_allhosts.html';
    }
} else {
    $hosts = $DB->get_records_sql('  SELECT 
                                    h.id, 
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:peers.php

示例14: req_unenrol_user

 /**
  * 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

示例15: dirname

 * @copyright  2007 Martin Langhoff
 * @copyright  2010 Penny Leach
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->libdir . '/adminlib.php';
$step = optional_param('step', 'verify', PARAM_ALPHA);
$hostid = required_param('hostid', PARAM_INT);
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$mnet = get_mnet_environment();
$PAGE->set_url('/admin/mnet/delete.php');
admin_externalpage_setup('mnetpeer' . $hostid);
require_sesskey();
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
if ('verify' == $step) {
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
    if ($live_users = $mnet_peer->count_live_sessions() > 0) {
        echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
    }
    $yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
    $nourl = new moodle_url('/admin/mnet/peers.php');
    echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
    echo $OUTPUT->footer();
} elseif ('delete' == $step) {
    $mnet_peer->delete();
    redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:delete.php


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