From 739e4e3c2102e47555235c137f7a67f52c6920f3 Mon Sep 17 00:00:00 2001 From: Penny Leach Date: Wed, 13 Jan 2010 02:42:01 +0000 Subject: [PATCH] mnet MDL-17082 removed all use of $_POST merged from MOODLE_19_STABLE --- admin/mnet/mnet_services.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/admin/mnet/mnet_services.php b/admin/mnet/mnet_services.php index 2bed53ec01..04c0116792 100644 --- a/admin/mnet/mnet_services.php +++ b/admin/mnet/mnet_services.php @@ -22,6 +22,10 @@ // force Go ahead with something we've been warned is strange $step = optional_param('step', NULL, PARAM_ALPHA); $hostid = optional_param('hostid', NULL, PARAM_INT); + $publishes = optional_param('publish', null, PARAM_BOOL); // optional_param cleans arrays too + $subscribes = optional_param('subscribe', null, PARAM_BOOL); // optional_param cleans arrays too + $exists = optional_param('subscribe', null, PARAM_BOOL); // optional_param cleans arrays too + $nocertstring = ''; $nocertmatch = ''; $badcert = ''; @@ -41,21 +45,21 @@ if (($form = data_submitted()) && confirm_sesskey()) { $mnet_peer->set_id($hostid); $treevals = array(); - foreach($_POST['exists'] as $key => $value) { - $host2service = $DB->get_record('mnet_host2service', array('hostid'=>$_POST['hostid'], 'serviceid'=>$key)); - $publish = (isset($_POST['publish'][$key]) && $_POST['publish'][$key] == 'on')? 1 : 0; - $subscribe = (isset($_POST['subscribe'][$key]) && $_POST['subscribe'][$key] == 'on')? 1 : 0; - + foreach($exists as $key => $value) { + $host2service = $DB->get_record('mnet_host2service', array('hostid'=>$hostid, 'serviceid'=>$key)); + $publish = array_key_exists($key, $publishes) ? $publishes[$key] : 0; + $subscribe = array_key_exists($key, $subscribes) ? $subscribes[$key] : 0; + if ($publish != 1 && $subscribe != 1) { if (false == $host2service) { // We don't have or need a record - do nothing! } else { // We don't need the record - delete it - $DB->delete_records('mnet_host2service', array('hostid' => $_POST['hostid'], 'serviceid'=>$key)); + $DB->delete_records('mnet_host2service', array('hostid' => $hostid, 'serviceid'=>$key)); } } elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) { $host2service = new stdClass(); - $host2service->hostid = $_POST['hostid']; + $host2service->hostid = $hostid; $host2service->serviceid = $key; $host2service->publish = $publish; -- 2.39.5