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


PHP mnet_environment::init方法代码示例

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


在下文中一共展示了mnet_environment::init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: mnet_get_hostname_from_uri

 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package mnet
 */
require_once $CFG->dirroot . '/mnet/xmlrpc/xmlparser.php';
require_once $CFG->dirroot . '/mnet/peer.php';
require_once $CFG->dirroot . '/mnet/environment.php';
/// CONSTANTS ///////////////////////////////////////////////////////////
define('RPC_OK', 0);
define('RPC_NOSUCHFILE', 1);
define('RPC_NOSUCHCLASS', 2);
define('RPC_NOSUCHFUNCTION', 3);
define('RPC_FORBIDDENFUNCTION', 4);
define('RPC_NOSUCHMETHOD', 5);
define('RPC_FORBIDDENMETHOD', 6);
$MNET = new mnet_environment();
$MNET->init();
/**
 * Strip extraneous detail from a URL or URI and return the hostname
 *
 * @param  string  $uri  The URI of a file on the remote computer, optionally
 *                       including its http:// prefix like
 *                       http://www.example.com/index.html
 * @return string        Just the hostname
 */
function mnet_get_hostname_from_uri($uri = null)
{
    $count = preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $uri, $matches);
    if ($count > 0) {
        return $matches[1];
    }
    return false;
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:lib.php

示例4: get_mnet_environment

/**
 * helper function to load up and initialise the mnet environment
 * this must be called before you use mnet functions.
 *
 * @return mnet_environment the equivalent of old $MNET global
 */
function get_mnet_environment()
{
    global $CFG;
    require_once $CFG->dirroot . '/mnet/lib.php';
    static $instance = null;
    if (empty($instance)) {
        $instance = new mnet_environment();
        $instance->init();
    }
    return $instance;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:17,代码来源:moodlelib.php

示例5: xmldb_main_upgrade


//.........这里部分代码省略.........
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('enabled_xpath', XMLDB_INDEX_NOTUNIQUE, array('enabled', 'xmlrpc_path'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_service');
        $table->comment = 'A service is a group of functions';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('description', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('apiversion', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('offer', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_service2rpc');
        $table->comment = 'Group functions or methods under a service';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f = $table->addFieldInfo('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        $f = $table->addFieldInfo('rpcid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('unique', XMLDB_INDEX_UNIQUE, array('rpcid', 'serviceid'));
        // Create the table
        $result = $result && create_table($table);
        //
        // Prime MNET configuration entries -- will be needed later by auth/mnet
        //
        include_once $CFG->dirroot . '/mnet/lib.php';
        $env = new mnet_environment();
        $env->init();
        unset($env);
        // add mnethostid to user-
        $table = new XMLDBTable('user');
        $field = new XMLDBField('mnethostid');
        $field->setType(XMLDB_TYPE_INTEGER);
        $field->setLength(10);
        $field->setNotNull(true);
        $field->setSequence(null);
        $field->setEnum(null);
        $field->setDefault('0');
        $field->setPrevious("deleted");
        $field->setNext("username");
        $result = $result && add_field($table, $field);
        // The default mnethostid is zero... we need to update this for all
        // users of the local IdP service.
        set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'mnethostid', '0');
        $index = new XMLDBIndex('username');
        $index->setUnique(true);
        $index->setFields(array('username'));
        drop_index($table, $index);
        $index->setFields(array('mnethostid', 'username'));
        if (!add_index($table, $index)) {
            notify(get_string('duplicate_usernames', 'mnet', 'http://docs.moodle.org/en/DuplicateUsernames'));
        }
        unset($table, $field, $index);
        /**
         ** auth/mnet tables
         **/
        $table = new XMLDBTable('mnet_session');
        $table->comment = 'Store session data from users migrating to other sites';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:upgrade.php

示例6: is_mnet_remote_user

/**
 * Returns whether or not the user object is a remote MNET user. This function
 * is in moodlelib because it does not rely on loading any of the MNET code.
 *
 * @param object $user A valid user object
 * @return bool        True if the user is from a remote Moodle.
 */
function is_mnet_remote_user($user)
{
    global $CFG;
    if (!isset($CFG->mnet_localhost_id)) {
        include_once $CFG->dirroot . '/mnet/lib.php';
        $env = new mnet_environment();
        $env->init();
        unset($env);
    }
    return !empty($user->mnethostid) && $user->mnethostid != $CFG->mnet_localhost_id;
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:18,代码来源:moodlelib.php

示例7: ensure_environment

 /**
  * Set the MNET environment
  * @global <type> $MNET
  */
 private function ensure_environment()
 {
     global $MNET;
     if (empty($MNET)) {
         $MNET = new mnet_environment();
         $MNET->init();
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:12,代码来源:repository.class.php

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

示例9: ensure_environment

 private function ensure_environment()
 {
     global $MNET;
     if (empty($MNET)) {
         $MNET = new mnet_environment();
         $MNET->init();
     }
     // no idea why this happens :(
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:9,代码来源:lib.php

示例10: xmldb_main_upgrade


//.........这里部分代码省略.........
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('enabled_xpath', XMLDB_INDEX_NOTUNIQUE, array('enabled', 'xmlrpc_path'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_service');
        $table->comment = 'A service is a group of functions';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('description', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('apiversion', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, NULL, null, null, null);
        $f = $table->addFieldInfo('offer', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_service2rpc');
        $table->comment = 'Group functions or methods under a service';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f = $table->addFieldInfo('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        $f = $table->addFieldInfo('rpcid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('unique', XMLDB_INDEX_UNIQUE, array('rpcid', 'serviceid'));
        // Create the table
        $result = $result && create_table($table);
        //
        // Prime MNET configuration entries -- will be needed later by auth/mnet
        //
        include_once $CFG->dirroot . '/mnet/lib.php';
        $env = new mnet_environment();
        $env->init();
        unset($env);
        // add mnethostid to user-
        $table = new XMLDBTable('user');
        $field = new XMLDBField('mnethostid');
        $field->setType(XMLDB_TYPE_INTEGER);
        $field->setLength(10);
        $field->setNotNull(true);
        $field->setSequence(null);
        $field->setEnum(null);
        $field->setDefault('0');
        $field->setPrevious("deleted");
        $field->setNext("username");
        $result = $result && add_field($table, $field);
        // The default mnethostid is zero... we need to update this for all
        // users of the local IdP service.
        set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'mnethostid', '0');
        $index = new XMLDBIndex('username');
        $index->setUnique(true);
        $index->setFields(array('username'));
        drop_index($table, $index);
        $index->setFields(array('mnethostid', 'username'));
        if (!add_index($table, $index)) {
            notify(get_string('duplicate_usernames', 'mnet', 'http://docs.moodle.org/en/DuplicateUsernames'));
        }
        unset($table, $field, $index);
        /**
         ** auth/mnet tables
         **/
        $table = new XMLDBTable('mnet_session');
        $table->comment = 'Store session data from users migrating to other sites';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
开发者ID:veritech,项目名称:pare-project,代码行数:67,代码来源:upgrade.php


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