Skip to content

Commit

Permalink
mnet: it is $USER->mnet_foreign_host_array instead of $SESSION->mnet_…
Browse files Browse the repository at this point in the history
…foreign_host_array. $SESSION is fraught with peril as it persists acros logins/logouts
  • Loading branch information
martinlanghoff committed Jan 19, 2007
1 parent f320363 commit 0743661
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions auth/mnet/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ function confirm_mnet_session($token, $remotewwwroot) {
}

if($key == 'myhosts') {
$SESSION->mnet_foreign_host_array = array();
$localuser->mnet_foreign_host_array = array();
foreach($val as $somecourse) {
$name = clean_param($somecourse['name'], PARAM_ALPHANUM);
$url = clean_param($somecourse['url'], PARAM_URL);
$count = clean_param($somecourse['count'], PARAM_INT);
$url_is_local = stristr($url , $CFG->wwwroot);
if (!empty($name) && !empty($count) && empty($url_is_local)) {
$SESSION->mnet_foreign_host_array[] = array('name' => $name, 'url' => $url, 'count' => $count);
$localuser->mnet_foreign_host_array[] = array('name' => $name,
'url' => $url,
'count' => $count);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions auth/mnet/land.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
$USER = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
load_all_capabilities();

if (!empty($localuser->mnet_foreign_host_array)) {
$USER->mnet_foreign_host_array = $localuser->mnet_foreign_host_array;
}

// redirect
redirect($CFG->wwwroot . $wantsurl);

Expand Down
6 changes: 3 additions & 3 deletions blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function get_content() {
}

function get_remote_courses() {
global $THEME, $CFG, $USER, $SESSION;
global $THEME, $CFG, $USER;
$icon = '<img src="'.$CFG->pixpath.'/i/mnethost.gif" class="icon" alt="'.get_string('course').'" />';

// only for logged in users!
Expand All @@ -111,10 +111,10 @@ function get_remote_courses() {
}

if ($USER->mnethostid != $CFG->mnet_localhost_id) {
if (!empty($SESSION->mnet_foreign_host_array) && is_array($SESSION->mnet_foreign_host_array)) {
if (!empty($USER->mnet_foreign_host_array) && is_array($USER->mnet_foreign_host_array)) {
$this->content->items[] = get_string('remotemoodles','mnet');
$this->content->icons[] = '';
foreach($SESSION->mnet_foreign_host_array as $somehost) {
foreach($USER->mnet_foreign_host_array as $somehost) {
$this->content->items[] = $somehost['count'].get_string('courseson','mnet').'<a title="'.$somehost['name'].'" href="'.$somehost['url'].'">'.$somehost['name'].'</a>';
$this->content->icons[] = $icon;
}
Expand Down

0 comments on commit 0743661

Please sign in to comment.