Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/auth/mnet/jump.php
Go to the documentation of this file.
00001 <?php
00002 
00015 require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
00016 
00017 // grab the GET params - wantsurl could be anything - take it
00018 // with PARAM_RAW
00019 $hostid = optional_param('hostid', '0', PARAM_INT);
00020 $hostwwwroot = optional_param('hostwwwroot', '', PARAM_URL);
00021 $wantsurl = optional_param('wantsurl', '', PARAM_RAW);
00022 
00023 $url = new moodle_url('/auth/mnet/jump.php');
00024 if ($hostid !== '0') $url->param('hostid', $hostid);
00025 if ($hostwwwroot !== '') $url->param('hostwwwroot', $hostwwwroot);
00026 if ($wantsurl !== '') $url->param('wantsurl', $wantsurl);
00027 $PAGE->set_url($url);
00028 
00029 if (!isloggedin() or isguestuser()) {
00030     $SESSION->wantsurl = $PAGE->url->out(false);
00031     redirect(get_login_url());
00032 }
00033 
00034 if (!is_enabled_auth('mnet')) {
00035     print_error('mnetdisable');
00036 }
00037 
00038 // If hostid hasn't been specified, try getting it using wwwroot
00039 if (!$hostid) {
00040     $hostwwwroot = trim($hostwwwroot);
00041     $hostwwwroot = rtrim($hostwwwroot, '/');
00042 
00043     // ensure the wwwroot starts with a http or https prefix
00044     if (strtolower(substr($hostwwwroot, 0, 4)) != 'http') {
00045         $hostwwwroot = 'http://'.$hostwwwroot;
00046     }
00047     $hostid = $DB->get_field('mnet_host', 'id', array('wwwroot' => $hostwwwroot));
00048 }
00049 
00050 // start the mnet session and redirect browser to remote URL
00051 $mnetauth = get_auth_plugin('mnet');
00052 $url      = $mnetauth->start_jump_session($hostid, $wantsurl);
00053 
00054 if (empty($url)) {
00055     print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
00056 }
00057 redirect($url);
00058 
00059 
 All Data Structures Namespaces Files Functions Variables Enumerations