From 995087b904ff0e302d397e23092573004bc2d084 Mon Sep 17 00:00:00 2001 From: peterbulmer Date: Thu, 30 Oct 2008 01:16:47 +0000 Subject: [PATCH] MDL-17038 Change to use sensible variable names Author: Peter Bulmer --- auth/mnet/auth.php | 54 ++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index 32b773ab4fa..5b6991f5fbc 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -772,7 +772,7 @@ class auth_plugin_mnet extends auth_plugin_base { join("\n", $mnet_request->error)); break; } - $query = " + $mnethostlogsssql = " SELECT mhostlogs.remoteid, mhostlogs.time, mhostlogs.userid, mhostlogs.ip, mhostlogs.course, mhostlogs.module, mhostlogs.cmid, mhostlogs.action, @@ -795,49 +795,51 @@ class auth_plugin_mnet extends auth_plugin_base { INNER JOIN {course} c on c.id = mhostlogs.course ORDER by mhostlogs.remoteid ASC"; - $results = $DB->get_records_sql($query, array($mnethostid, $mnet_request->response['last log id'])); + $mnethostlogs = $DB->get_records_sql($mnethostlogssql, array($mnethostid, $mnet_request->response['last log id'])); - if (false == $results) continue; + if (false == $mnethostlogs) continue; - $param = array(); + $processedlogs = array(); - foreach($results as $result) { - if (!empty($result->modinfo) && !empty($result->cmid)) { - $modinfo = unserialize($result->modinfo); - unset($result->modinfo); + foreach($mnethostlogs as $hostlog) { + // Extract the name of the relevant module instance from the + // course modinfo if possible. + if (!empty($hostlog->modinfo) && !empty($hostlog->cmid)) { + $modinfo = unserialize($hostlog->modinfo); + unset($hostlog->modinfo); $modulearray = array(); foreach($modinfo as $module) { $modulearray[$module->cm] = urldecode($module->name); } - $result->resource_name = $modulearray[$result->cmid]; + $hostlog->resource_name = $modulearray[$hostlog->cmid]; } else { - $result->resource_name = ''; + $hostlog->resource_name = ''; } - $param[] = array ( - 'remoteid' => $result->remoteid, - 'time' => $result->time, - 'userid' => $result->userid, - 'ip' => $result->ip, - 'course' => $result->course, - 'coursename' => $result->coursename, - 'module' => $result->module, - 'cmid' => $result->cmid, - 'action' => $result->action, - 'url' => $result->url, - 'info' => $result->info, - 'resource_name' => $result->resource_name, - 'username' => $result->username + $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($result); + 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($param); + $mnet_request->add_param($processedlogs); if ($mnet_request->send($mnet_peer) === true) { if ($mnet_request->response['code'] > 0) {