From c863dc389c77cae888677ad475e7f38edefc79a8 Mon Sep 17 00:00:00 2001
From: Petr Skoda <skodak@moodle.org>
Date: Thu, 5 Nov 2009 20:04:27 +0000
Subject: [PATCH] MDL-12886 more external groups api

---
 lib/db/services.php             |  4 +--
 version.php                     |  2 +-
 webservice/testclient_forms.php | 50 +++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/lib/db/services.php b/lib/db/services.php
index c0acfbd57d..8ca0d9b9b9 100644
--- a/lib/db/services.php
+++ b/lib/db/services.php
@@ -59,7 +59,7 @@ $functions = array(
         'description' => 'Deletes all specified groups.',
         'type'        => 'delete',
     ),
-/*
+
     'moodle_group_get_groupmembers' => array(
         'classname'   => 'moodle_group_external',
         'methodname'  => 'get_groupmembers',
@@ -67,7 +67,7 @@ $functions = array(
         'description' => 'Returns group members.',
         'type'        => 'read',
     ),
-
+/*
     'moodle_group_add_groupmembers' => array(
         'classname'   => 'moodle_group_external',
         'methodname'  => 'add_groupmembers',
diff --git a/version.php b/version.php
index abbf67203e..388db8abc3 100644
--- a/version.php
+++ b/version.php
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2009110400;  // YYYYMMDD   = date of the last version bump
+    $version = 2009110500;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20091105)';  // Human-friendly version name
diff --git a/webservice/testclient_forms.php b/webservice/testclient_forms.php
index 687db3cedd..6ce6b6b572 100644
--- a/webservice/testclient_forms.php
+++ b/webservice/testclient_forms.php
@@ -207,3 +207,53 @@ class moodle_group_delete_groups_form extends moodleform {
         return $params;
     }
 }
+
+
+class moodle_group_get_groupmembers_form extends moodleform {
+    public function definition() {
+        global $CFG;
+
+        $mform = $this->_form;
+
+        $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
+
+        //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
+        $mform->addElement('text', 'wsusername', 'wsusername');
+        $mform->addElement('text', 'wspassword', 'wspassword');
+        $mform->addElement('text', 'groupids[0]', 'groupids[0]');
+        $mform->addElement('text', 'groupids[1]', 'groupids[1]');
+        $mform->addElement('text', 'groupids[2]', 'groupids[2]');
+        $mform->addElement('text', 'groupids[3]', 'groupids[3]');
+
+        $mform->addElement('hidden', 'function');
+        $mform->setType('function', PARAM_SAFEDIR);
+
+        $mform->addElement('hidden', 'protocol');
+        $mform->setType('protocol', PARAM_SAFEDIR);
+
+        $this->add_action_buttons(true, get_string('execute', 'webservice'));
+    }
+
+    public function get_params() {
+        if (!$data = $this->get_data()) {
+            return null;
+        }
+        // remove unused from form data
+        unset($data->submitbutton);
+        unset($data->protocol);
+        unset($data->function);
+        unset($data->wsusername);
+        unset($data->wspassword);
+
+        $params = array();
+        $params['groupids'] = array();
+        for ($i=0; $i<10; $i++) {
+            if (empty($data->groupids[$i])) {
+                continue;
+            }
+            $params['groupids'][] = $data->groupids[$i];
+        }
+
+        return $params;
+    }
+}
-- 
2.39.5