]> git.mjollnir.org Git - moodle.git/commitdiff
mnet MDL-17082 removed all use of $_POST
authorPenny Leach <penny@liip.ch>
Wed, 13 Jan 2010 02:42:01 +0000 (02:42 +0000)
committerPenny Leach <penny@liip.ch>
Wed, 13 Jan 2010 02:42:01 +0000 (02:42 +0000)
merged from MOODLE_19_STABLE

admin/mnet/mnet_services.php

index 2bed53ec0182bed291c20e0172205de22c53f178..04c01167925a239bbebd66d21f17d05e7dcc9089 100644 (file)
     // 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 = '';
     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;