From 8bc663e85ef84568101499f7dcdee7a04df9e9ab Mon Sep 17 00:00:00 2001 From: Adrian Greeve <adrian@moodle.com> Date: Thu, 14 Aug 2014 15:58:35 +0800 Subject: [PATCH 1/2] MDL-39888 mnet: Removal of an old sql statement invloving the mdl_log table. --- auth/mnet/auth.php | 113 ++------------------------------------------- 1 file changed, 3 insertions(+), 110 deletions(-) diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index aa8e1cead42..ef3d1fc89f5 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -764,74 +764,6 @@ class auth_plugin_mnet extends auth_plugin_base { join("\n", $mnet_request->error)); break; } - $mnethostlogssql = " - SELECT - l.id as remoteid, l.time, l.userid, l.ip, l.course, l.module, l.cmid, - l.action, l.url, l.info, u.username - FROM - {user} u - INNER JOIN {log} l on l.userid = u.id - WHERE - u.mnethostid = ? - AND l.id > ? - AND l.course IS NOT NULL - ORDER by l.id ASC"; - - $mnethostlogs = $DB->get_records_sql($mnethostlogssql, array($mnethostid, $mnet_request->response['last log id']), 0, 500); - - if ($mnethostlogs == false) { - continue; - } - - $processedlogs = array(); - - foreach($mnethostlogs as $hostlog) { - try { - // Get impersonalised course information. If it is cached there will be no DB queries. - $modinfo = get_fast_modinfo($hostlog->course, -1); - $hostlog->coursename = $modinfo->get_course()->fullname; - if (!empty($hostlog->cmid) && isset($modinfo->cms[$hostlog->cmid])) { - $hostlog->resource_name = $modinfo->cms[$hostlog->cmid]->name; - } else { - $hostlog->resource_name = ''; - } - } catch (moodle_exception $e) { - // Course not found - continue; - } - - $processedlogs[] = array ( - 'remoteid' => $hostlog->remoteid, - 'time' => $hostlog->time, - 'userid' => $hostlog->userid, - 'ip' => $hostlog->ip, - 'course' => $hostlog->course, - 'coursename' => $hostlog->coursename, - 'module' => $hostlog->module, - 'cmid' => $hostlog->cmid, - 'action' => $hostlog->action, - 'url' => $hostlog->url, - 'info' => $hostlog->info, - 'resource_name' => $hostlog->resource_name, - 'username' => $hostlog->username - ); - } - - unset($hostlog); - - $mnet_request = new mnet_xmlrpc_client(); - $mnet_request->set_method('auth/mnet/auth.php/refresh_log'); - - // set $token and $useragent parameters - $mnet_request->add_param($processedlogs); - - if ($mnet_request->send($mnet_peer) === true) { - if ($mnet_request->response['code'] > 0) { - debugging($mnet_request->response['message']); - } - } else { - debugging("Server side error has occured on host $mnet_peer->ip: " .join("\n", $mnet_request->error)); - } } } @@ -839,52 +771,13 @@ class auth_plugin_mnet extends auth_plugin_base { * Receives an array of log entries from an SP and adds them to the mnet_log * table * + * @deprecated since Moodle 2.8 Please don't use this function for recording mnet logs. * @param array $array An array of usernames * @return string "All ok" or an error message */ function refresh_log($array) { - global $CFG, $DB; - $remoteclient = get_mnet_remote_client(); - - // We don't want to output anything to the client machine - $start = ob_start(); - - $returnString = ''; - $transaction = $DB->start_delegated_transaction(); - $useridarray = array(); - - foreach($array as $logEntry) { - $logEntryObj = (object)$logEntry; - $logEntryObj->hostid = $remoteclient->id; - - if (isset($useridarray[$logEntryObj->username])) { - $logEntryObj->userid = $useridarray[$logEntryObj->username]; - } else { - $logEntryObj->userid = $DB->get_field('user', 'id', array('username'=>$logEntryObj->username, 'mnethostid'=>(int)$logEntryObj->hostid)); - if ($logEntryObj->userid == false) { - $logEntryObj->userid = 0; - } - $useridarray[$logEntryObj->username] = $logEntryObj->userid; - } - - unset($logEntryObj->username); - - $logEntryObj = $this->trim_logline($logEntryObj); - $insertok = $DB->insert_record('mnet_log', $logEntryObj, false); - - if ($insertok) { - $remoteclient->last_log_id = $logEntryObj->remoteid; - } else { - $returnString .= 'Record with id '.$logEntryObj->remoteid." failed to insert.\n"; - } - } - $remoteclient->commit(); - $transaction->allow_commit(); - - $end = ob_end_clean(); - - if (empty($returnString)) return array('code' => 0, 'message' => 'All ok'); - return array('code' => 1, 'message' => $returnString); + debugging('refresh_log() is deprecated, The transfer of logs through mnet are no longer recorded.', DEBUG_DEVELOPER); + return array('code' => 0, 'message' => 'All ok'); } /** From 1899519c6b306ad57cb9f0c306b5bb2d4eed4e8e Mon Sep 17 00:00:00 2001 From: Adrian Greeve <adrian@moodle.com> Date: Thu, 14 Aug 2014 16:01:43 +0800 Subject: [PATCH 2/2] MDL-39888 mnet: Removed tab and links to the log report. The link would include parameters which generates warnings on the log report page. --- admin/mnet/tabs.php | 9 --------- auth/upgrade.txt | 3 +++ lang/en/mnet.php | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/admin/mnet/tabs.php b/admin/mnet/tabs.php index efc0118cc07..0107d758285 100644 --- a/admin/mnet/tabs.php +++ b/admin/mnet/tabs.php @@ -34,21 +34,12 @@ if (!defined('MOODLE_INTERNAL')) { } $strmnetservices = get_string('mnetservices', 'mnet'); -$strmnetlog = get_string('mnetlog', 'mnet'); $strmnetedithost = get_string('reviewhostdetails', 'mnet'); -$logurl = $CFG->wwwroot. - '/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id. - '%2F1&user='.'0'. - '&date=0'. - '&modid=&modaction=0&logformat=showashtml'; $tabs = array(); if (isset($mnet_peer->id) && $mnet_peer->id > 0) { $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false); $tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false); - if ($mnet_peer->application->name == 'moodle' && $mnet_peer->id != $CFG->mnet_all_hosts_id) { - $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false); - } $tabs[] = new tabobject('mnetprofilefields', 'profilefields.php?hostid=' . $mnet_peer->id, get_string('profilefields', 'mnet'), get_string('profilefields', 'mnet'), false); } else { $tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false); diff --git a/auth/upgrade.txt b/auth/upgrade.txt index 5b511346168..5308808806b 100644 --- a/auth/upgrade.txt +++ b/auth/upgrade.txt @@ -6,6 +6,9 @@ information provided here is intended especially for developers. * \core\session\manager::session_exists() now verifies the session is active instead of only checking the session data is present in low level session handler +* MNet is no longer sending logs between the client and parent sites. auth_plugin_mnet::refresh_log() is now deprecated. There is + no alternative. Please don't use this function. + === 2.7 === * If you are returning a url in method change_password_url() from config, please make sure it is set before trying to use it. diff --git a/lang/en/mnet.php b/lang/en/mnet.php index e1d4908c929..d2469c8ca76 100644 --- a/lang/en/mnet.php +++ b/lang/en/mnet.php @@ -132,7 +132,6 @@ $string['mnetidprovider'] = 'MNet ID provider'; $string['mnetidproviderdesc'] = 'You can use this facility to retrieve a link that you can log in at, if you can provide the correct email address to match the username you previously tried to log in with.'; $string['mnetidprovidermsg'] = 'You should be able to login at your {$a} provider.'; $string['mnetidprovidernotfound'] = 'Sorry, but no further information could be found.'; -$string['mnetlog'] = 'Logs'; $string['mnetpeers'] = 'Peers'; $string['mnetservices'] = 'Services'; $string['mnet_session_prohibited'] = 'Users from your home server are not currently permitted to roam to {$a}.';