Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/webservice/testclient_forms.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once($CFG->libdir.'/formslib.php');
00004 
00005 
00006 class webservice_test_client_form extends moodleform {
00007     public function definition() {
00008         global $CFG;
00009 
00010         $mform = $this->_form;
00011         list($functions, $protocols) = $this->_customdata;
00012 
00013         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00014 
00015         $authmethod = array('simple' => 'simple', 'token' => 'token');
00016         $mform->addElement('select', 'authmethod', get_string('authmethod', 'webservice'), $authmethod);
00017 
00018         $mform->addElement('select', 'protocol', get_string('protocol', 'webservice'), $protocols);
00019 
00020         $mform->addElement('select', 'function', get_string('function', 'webservice'), $functions);
00021 
00022         $this->add_action_buttons(false, get_string('select'));
00023     }
00024 }
00025 
00026 // === Test client forms ===
00027 
00028 class moodle_user_create_users_form extends moodleform {
00029     public function definition() {
00030         global $CFG;
00031 
00032         $mform = $this->_form;
00033 
00034 
00035         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00036 
00037         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00038         $data = $this->_customdata;
00039         if ($data['authmethod'] == 'simple') {
00040             $mform->addElement('text', 'wsusername', 'wsusername');
00041             $mform->addElement('text', 'wspassword', 'wspassword');
00042         } else  if ($data['authmethod'] == 'token') {
00043             $mform->addElement('text', 'token', 'token');
00044         }
00045 
00046         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00047         $mform->setType('authmethod', PARAM_SAFEDIR);
00048 
00050         $mform->addElement('text', 'username', 'username');
00051         $mform->addElement('text', 'password', 'password');
00052         $mform->addElement('text', 'firstname', 'firstname');
00053         $mform->addElement('text', 'lastname', 'lastname');
00054         $mform->addElement('text', 'email', 'email');
00055 
00056         $mform->addElement('text', 'customfieldtype', 'customfieldtype');
00057         $mform->addElement('text', 'customfieldvalue', 'customfieldvalue');
00058 
00059         $mform->addElement('hidden', 'function');
00060         $mform->setType('function', PARAM_SAFEDIR);
00061 
00062         $mform->addElement('hidden', 'protocol');
00063         $mform->setType('protocol', PARAM_SAFEDIR);
00064 
00065 
00066 
00067         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00068 
00069         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00070     }
00071 
00072     public function get_params() {
00073         if (!$data = $this->get_data()) {
00074             return null;
00075         }
00076 
00077         //set customfields
00078         if (!empty($data->customfieldtype)) {
00079             $data->customfields = array(array('type' => $data->customfieldtype, 'value' => $data->customfieldvalue));
00080         }
00081 
00082         // remove unused from form data
00083         unset($data->submitbutton);
00084         unset($data->protocol);
00085         unset($data->function);
00086         unset($data->wsusername);
00087         unset($data->wspassword);
00088         unset($data->token);
00089         unset($data->authmethod);
00090         unset($data->customfieldtype);
00091         unset($data->customfieldvalue);
00092 
00093         $params = array();
00094         $params['users'] = array();
00095         $params['users'][] = (array)$data;
00096 
00097         return $params;
00098     }
00099 }
00100 
00101 
00102 class moodle_user_update_users_form extends moodleform {
00103     public function definition() {
00104         global $CFG;
00105 
00106         $mform = $this->_form;
00107 
00108 
00109         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00110 
00111         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00112         $data = $this->_customdata;
00113         if ($data['authmethod'] == 'simple') {
00114             $mform->addElement('text', 'wsusername', 'wsusername');
00115             $mform->addElement('text', 'wspassword', 'wspassword');
00116         } else  if ($data['authmethod'] == 'token') {
00117             $mform->addElement('text', 'token', 'token');
00118         }
00119 
00120         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00121         $mform->setType('authmethod', PARAM_SAFEDIR);
00122 
00124         $mform->addElement('text', 'id', 'id');
00125         $mform->addRule('id', get_string('required'), 'required', null, 'client');
00126         $mform->addElement('text', 'username', 'username');
00127         $mform->addElement('text', 'password', 'password');
00128         $mform->addElement('text', 'firstname', 'firstname');
00129         $mform->addElement('text', 'lastname', 'lastname');
00130         $mform->addElement('text', 'email', 'email');
00131 
00132 
00133         $mform->addElement('text', 'customfieldtype', 'customfieldtype');
00134         $mform->addElement('text', 'customfieldvalue', 'customfieldvalue');
00135 
00136         $mform->addElement('hidden', 'function');
00137         $mform->setType('function', PARAM_SAFEDIR);
00138 
00139         $mform->addElement('hidden', 'protocol');
00140         $mform->setType('protocol', PARAM_SAFEDIR);
00141 
00142 
00143 
00144         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00145 
00146         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00147     }
00148 
00149     public function get_params() {
00150         if (!$data = $this->get_data()) {
00151             return null;
00152         }
00153 
00154         //set customfields
00155         if (!empty($data->customfieldtype)) {
00156             $data->customfields = array(array('type' => $data->customfieldtype, 'value' => $data->customfieldvalue));
00157         }
00158 
00159         // remove unused from form data
00160         unset($data->submitbutton);
00161         unset($data->protocol);
00162         unset($data->function);
00163         unset($data->wsusername);
00164         unset($data->wspassword);
00165         unset($data->token);
00166         unset($data->authmethod);
00167         unset($data->customfieldtype);
00168         unset($data->customfieldvalue);
00169 
00170         foreach($data as $key => $value) {
00171             if (empty($value)) {
00172                  unset($data->{$key});
00173             }
00174         }
00175 
00176         $params = array();
00177         $params['users'] = array();
00178         $params['users'][] = (array)$data;
00179 
00180         return $params;
00181     }
00182 }
00183 
00184 
00185 class moodle_user_delete_users_form extends moodleform {
00186     public function definition() {
00187         global $CFG;
00188 
00189         $mform = $this->_form;
00190 
00191 
00192         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00193 
00194         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00195         $data = $this->_customdata;
00196         if ($data['authmethod'] == 'simple') {
00197             $mform->addElement('text', 'wsusername', 'wsusername');
00198             $mform->addElement('text', 'wspassword', 'wspassword');
00199         } else  if ($data['authmethod'] == 'token') {
00200             $mform->addElement('text', 'token', 'token');
00201         }
00202 
00203         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00204         $mform->setType('authmethod', PARAM_SAFEDIR);
00205 
00207         $mform->addElement('text', 'userids[0]', 'userids[0]');
00208         $mform->addElement('text', 'userids[1]', 'userids[1]');
00209         $mform->addElement('text', 'userids[2]', 'userids[2]');
00210         $mform->addElement('text', 'userids[3]', 'userids[3]');
00212 
00213         $mform->addElement('hidden', 'function');
00214         $mform->setType('function', PARAM_SAFEDIR);
00215 
00216         $mform->addElement('hidden', 'protocol');
00217         $mform->setType('protocol', PARAM_SAFEDIR);
00218 
00219 
00220 
00221         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00222 
00223         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00224     }
00225 
00226     public function get_params() {
00227         if (!$data = $this->get_data()) {
00228             return null;
00229         }
00230         // remove unused from form data
00231         unset($data->submitbutton);
00232         unset($data->protocol);
00233         unset($data->function);
00234         unset($data->wsusername);
00235         unset($data->wspassword);
00236         unset($data->token);
00237         unset($data->authmethod);
00238 
00240         $params = array();
00241         $params['userids'] = array();
00242         for ($i=0; $i<10; $i++) {
00243             if (empty($data->userids[$i])) {
00244                 continue;
00245             }
00246             $params['userids'][] = $data->userids[$i];
00247         }
00249 
00250         return $params;
00251     }
00252 }
00253 
00254 
00255 class moodle_user_get_users_by_id_form extends moodleform {
00256     public function definition() {
00257         global $CFG;
00258 
00259         $mform = $this->_form;
00260 
00261 
00262         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00263 
00264         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00265         $data = $this->_customdata;
00266         if ($data['authmethod'] == 'simple') {
00267             $mform->addElement('text', 'wsusername', 'wsusername');
00268             $mform->addElement('text', 'wspassword', 'wspassword');
00269         } else  if ($data['authmethod'] == 'token') {
00270             $mform->addElement('text', 'token', 'token');
00271         }
00272 
00273         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00274         $mform->setType('authmethod', PARAM_SAFEDIR);
00275 
00277         $mform->addElement('text', 'userids[0]', 'userids[0]');
00278         $mform->addElement('text', 'userids[1]', 'userids[1]');
00279         $mform->addElement('text', 'userids[2]', 'userids[2]');
00280         $mform->addElement('text', 'userids[3]', 'userids[3]');
00282 
00283         $mform->addElement('hidden', 'function');
00284         $mform->setType('function', PARAM_SAFEDIR);
00285 
00286         $mform->addElement('hidden', 'protocol');
00287         $mform->setType('protocol', PARAM_SAFEDIR);
00288 
00289 
00290 
00291         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00292 
00293         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00294     }
00295 
00296     public function get_params() {
00297         if (!$data = $this->get_data()) {
00298             return null;
00299         }
00300         // remove unused from form data
00301         unset($data->submitbutton);
00302         unset($data->protocol);
00303         unset($data->function);
00304         unset($data->wsusername);
00305         unset($data->wspassword);
00306         unset($data->token);
00307         unset($data->authmethod);
00308 
00310         $params = array();
00311         $params['userids'] = array();
00312         for ($i=0; $i<10; $i++) {
00313             if (empty($data->userids[$i])) {
00314                 continue;
00315             }
00316             $params['userids'][] = $data->userids[$i];
00317         }
00319 
00320         return $params;
00321     }
00322 }
00323 
00324 class moodle_group_create_groups_form extends moodleform {
00325     public function definition() {
00326         global $CFG;
00327 
00328         $mform = $this->_form;
00329 
00330 
00331         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00332 
00333         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00334         $data = $this->_customdata;
00335         if ($data['authmethod'] == 'simple') {
00336             $mform->addElement('text', 'wsusername', 'wsusername');
00337             $mform->addElement('text', 'wspassword', 'wspassword');
00338         } else  if ($data['authmethod'] == 'token') {
00339             $mform->addElement('text', 'token', 'token');
00340         }
00341 
00342         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00343         $mform->setType('authmethod', PARAM_SAFEDIR);
00344 
00345         $mform->addElement('text', 'courseid', 'courseid');
00346         $mform->addElement('text', 'name', 'name');
00347         $mform->addElement('text', 'description', 'description');
00348         $mform->addElement('text', 'enrolmentkey', 'enrolmentkey');
00349 
00350         $mform->addElement('hidden', 'function');
00351         $mform->setType('function', PARAM_SAFEDIR);
00352 
00353         $mform->addElement('hidden', 'protocol');
00354         $mform->setType('protocol', PARAM_SAFEDIR);
00355 
00356 
00357 
00358         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00359 
00360         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00361     }
00362 
00363     public function get_params() {
00364         if (!$data = $this->get_data()) {
00365             return null;
00366         }
00367         // remove unused from form data
00368         unset($data->submitbutton);
00369         unset($data->protocol);
00370         unset($data->function);
00371         unset($data->wsusername);
00372         unset($data->wspassword);
00373         unset($data->token);
00374         unset($data->authmethod);
00375 
00376         $params = array();
00377         $params['groups'] = array();
00378         $params['groups'][] = (array)$data;
00379 
00380         return $params;
00381     }
00382 }
00383 
00384 class moodle_group_get_groups_form extends moodleform {
00385     public function definition() {
00386         global $CFG;
00387 
00388         $mform = $this->_form;
00389 
00390         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00391 
00392         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00393         $data = $this->_customdata;
00394         if ($data['authmethod'] == 'simple') {
00395             $mform->addElement('text', 'wsusername', 'wsusername');
00396             $mform->addElement('text', 'wspassword', 'wspassword');
00397         } else  if ($data['authmethod'] == 'token') {
00398             $mform->addElement('text', 'token', 'token');
00399         }
00400 
00401         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00402         $mform->setType('authmethod', PARAM_SAFEDIR);
00403         $mform->addElement('text', 'groupids[0]', 'groupids[0]');
00404         $mform->addElement('text', 'groupids[1]', 'groupids[1]');
00405         $mform->addElement('text', 'groupids[2]', 'groupids[2]');
00406         $mform->addElement('text', 'groupids[3]', 'groupids[3]');
00407 
00408         $mform->addElement('hidden', 'function');
00409         $mform->setType('function', PARAM_SAFEDIR);
00410 
00411         $mform->addElement('hidden', 'protocol');
00412         $mform->setType('protocol', PARAM_SAFEDIR);
00413 
00414         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00415     }
00416 
00417     public function get_params() {
00418         if (!$data = $this->get_data()) {
00419             return null;
00420         }
00421         // remove unused from form data
00422         unset($data->submitbutton);
00423         unset($data->protocol);
00424         unset($data->function);
00425         unset($data->wsusername);
00426         unset($data->wspassword);
00427         unset($data->token);
00428         unset($data->authmethod);
00429 
00430         $params = array();
00431         $params['groupids'] = array();
00432         for ($i=0; $i<10; $i++) {
00433             if (empty($data->groupids[$i])) {
00434                 continue;
00435             }
00436             $params['groupids'][] = $data->groupids[$i];
00437         }
00438 
00439         return $params;
00440     }
00441 }
00442 
00443 class moodle_group_get_course_groups_form extends moodleform {
00444     public function definition() {
00445         global $CFG;
00446 
00447         $mform = $this->_form;
00448 
00449         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00450 
00451         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00452         $data = $this->_customdata;
00453         if ($data['authmethod'] == 'simple') {
00454             $mform->addElement('text', 'wsusername', 'wsusername');
00455             $mform->addElement('text', 'wspassword', 'wspassword');
00456         } else  if ($data['authmethod'] == 'token') {
00457             $mform->addElement('text', 'token', 'token');
00458         }
00459 
00460         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00461         $mform->setType('authmethod', PARAM_SAFEDIR);
00462         $mform->addElement('text', 'courseid', 'courseid');
00463 
00464         $mform->addElement('hidden', 'function');
00465         $mform->setType('function', PARAM_SAFEDIR);
00466 
00467         $mform->addElement('hidden', 'protocol');
00468         $mform->setType('protocol', PARAM_SAFEDIR);
00469 
00470         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00471     }
00472 
00473     public function get_params() {
00474         if (!$data = $this->get_data()) {
00475             return null;
00476         }
00477         // remove unused from form data
00478         unset($data->submitbutton);
00479         unset($data->protocol);
00480         unset($data->function);
00481         unset($data->wsusername);
00482         unset($data->wspassword);
00483         unset($data->token);
00484         unset($data->authmethod);
00485 
00486         $params = array();
00487         $params['courseid'] = $data->courseid;
00488 
00489         return $params;
00490     }
00491 }
00492 
00493 class moodle_group_delete_groups_form extends moodleform {
00494     public function definition() {
00495         global $CFG;
00496 
00497         $mform = $this->_form;
00498 
00499         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00500 
00501         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00502         $data = $this->_customdata;
00503         if ($data['authmethod'] == 'simple') {
00504             $mform->addElement('text', 'wsusername', 'wsusername');
00505             $mform->addElement('text', 'wspassword', 'wspassword');
00506         } else  if ($data['authmethod'] == 'token') {
00507             $mform->addElement('text', 'token', 'token');
00508         }
00509 
00510         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00511         $mform->setType('authmethod', PARAM_SAFEDIR);
00512         $mform->addElement('text', 'groupids[0]', 'groupids[0]');
00513         $mform->addElement('text', 'groupids[1]', 'groupids[1]');
00514         $mform->addElement('text', 'groupids[2]', 'groupids[2]');
00515         $mform->addElement('text', 'groupids[3]', 'groupids[3]');
00516 
00517         $mform->addElement('hidden', 'function');
00518         $mform->setType('function', PARAM_SAFEDIR);
00519 
00520         $mform->addElement('hidden', 'protocol');
00521         $mform->setType('protocol', PARAM_SAFEDIR);
00522 
00523         $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
00524 
00525         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00526     }
00527 
00528     public function get_params() {
00529         if (!$data = $this->get_data()) {
00530             return null;
00531         }
00532         // remove unused from form data
00533         unset($data->submitbutton);
00534         unset($data->protocol);
00535         unset($data->function);
00536         unset($data->wsusername);
00537         unset($data->wspassword);
00538         unset($data->token);
00539         unset($data->authmethod);
00540 
00541         $params = array();
00542         $params['groupids'] = array();
00543         for ($i=0; $i<10; $i++) {
00544             if (empty($data->groupids[$i])) {
00545                 continue;
00546             }
00547             $params['groupids'][] = $data->groupids[$i];
00548         }
00549 
00550         return $params;
00551     }
00552 }
00553 
00554 class moodle_group_get_groupmembers_form extends moodleform {
00555     public function definition() {
00556         global $CFG;
00557 
00558         $mform = $this->_form;
00559 
00560         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00561 
00562         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00563         $data = $this->_customdata;
00564         if ($data['authmethod'] == 'simple') {
00565             $mform->addElement('text', 'wsusername', 'wsusername');
00566             $mform->addElement('text', 'wspassword', 'wspassword');
00567         } else  if ($data['authmethod'] == 'token') {
00568             $mform->addElement('text', 'token', 'token');
00569         }
00570 
00571         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00572         $mform->setType('authmethod', PARAM_SAFEDIR);
00573         $mform->addElement('text', 'groupids[0]', 'groupids[0]');
00574         $mform->addElement('text', 'groupids[1]', 'groupids[1]');
00575         $mform->addElement('text', 'groupids[2]', 'groupids[2]');
00576         $mform->addElement('text', 'groupids[3]', 'groupids[3]');
00577 
00578         $mform->addElement('hidden', 'function');
00579         $mform->setType('function', PARAM_SAFEDIR);
00580 
00581         $mform->addElement('hidden', 'protocol');
00582         $mform->setType('protocol', PARAM_SAFEDIR);
00583 
00584         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00585     }
00586 
00587     public function get_params() {
00588         if (!$data = $this->get_data()) {
00589             return null;
00590         }
00591         // remove unused from form data
00592         unset($data->submitbutton);
00593         unset($data->protocol);
00594         unset($data->function);
00595         unset($data->wsusername);
00596         unset($data->wspassword);
00597         unset($data->token);
00598         unset($data->authmethod);
00599 
00600         $params = array();
00601         $params['groupids'] = array();
00602         for ($i=0; $i<10; $i++) {
00603             if (empty($data->groupids[$i])) {
00604                 continue;
00605             }
00606             $params['groupids'][] = $data->groupids[$i];
00607         }
00608 
00609         return $params;
00610     }
00611 }
00612 
00613 class moodle_group_add_groupmembers_form extends moodleform {
00614     public function definition() {
00615         global $CFG;
00616 
00617         $mform = $this->_form;
00618 
00619         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00620 
00621         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00622         $data = $this->_customdata;
00623         if ($data['authmethod'] == 'simple') {
00624             $mform->addElement('text', 'wsusername', 'wsusername');
00625             $mform->addElement('text', 'wspassword', 'wspassword');
00626         } else  if ($data['authmethod'] == 'token') {
00627             $mform->addElement('text', 'token', 'token');
00628         }
00629 
00630         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00631         $mform->setType('authmethod', PARAM_SAFEDIR);
00632         $mform->addElement('text', 'userid[0]', 'userid[0]');
00633         $mform->addElement('text', 'groupid[0]', 'groupid[0]');
00634         $mform->addElement('text', 'userid[1]', 'userid[1]');
00635         $mform->addElement('text', 'groupid[1]', 'groupid[1]');
00636 
00637         $mform->addElement('hidden', 'function');
00638         $mform->setType('function', PARAM_SAFEDIR);
00639 
00640         $mform->addElement('hidden', 'protocol');
00641         $mform->setType('protocol', PARAM_SAFEDIR);
00642 
00643         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00644     }
00645 
00646     public function get_params() {
00647         if (!$data = $this->get_data()) {
00648             return null;
00649         }
00650         // remove unused from form data
00651         unset($data->submitbutton);
00652         unset($data->protocol);
00653         unset($data->function);
00654         unset($data->wsusername);
00655         unset($data->wspassword);
00656         unset($data->token);
00657         unset($data->authmethod);
00658 
00659         $params = array();
00660         $params['members'] = array();
00661         for ($i=0; $i<10; $i++) {
00662             if (empty($data->groupid[$i]) or empty($data->userid[$i])) {
00663                 continue;
00664             }
00665             $params['members'][] = array('userid'=>$data->userid[$i], 'groupid'=>$data->groupid[$i]);
00666         }
00667 
00668         return $params;
00669     }
00670 }
00671 
00672 class moodle_group_delete_groupmembers_form extends moodleform {
00673     public function definition() {
00674         global $CFG;
00675 
00676         $mform = $this->_form;
00677 
00678         $mform->addElement('header', 'wstestclienthdr', get_string('testclient', 'webservice'));
00679 
00680         //note: these values are intentionally PARAM_RAW - we want users to test any rubbish as parameters
00681         $data = $this->_customdata;
00682         if ($data['authmethod'] == 'simple') {
00683             $mform->addElement('text', 'wsusername', 'wsusername');
00684             $mform->addElement('text', 'wspassword', 'wspassword');
00685         } else  if ($data['authmethod'] == 'token') {
00686             $mform->addElement('text', 'token', 'token');
00687         }
00688 
00689         $mform->addElement('hidden', 'authmethod', $data['authmethod']);
00690         $mform->setType('authmethod', PARAM_SAFEDIR);
00691         $mform->addElement('text', 'userid[0]', 'userid[0]');
00692         $mform->addElement('text', 'groupid[0]', 'groupid[0]');
00693         $mform->addElement('text', 'userid[1]', 'userid[1]');
00694         $mform->addElement('text', 'groupid[1]', 'groupid[1]');
00695 
00696         $mform->addElement('hidden', 'function');
00697         $mform->setType('function', PARAM_SAFEDIR);
00698 
00699         $mform->addElement('hidden', 'protocol');
00700         $mform->setType('protocol', PARAM_SAFEDIR);
00701 
00702         $this->add_action_buttons(true, get_string('execute', 'webservice'));
00703     }
00704 
00705     public function get_params() {
00706         if (!$data = $this->get_data()) {
00707             return null;
00708         }
00709         // remove unused from form data
00710         unset($data->submitbutton);
00711         unset($data->protocol);
00712         unset($data->function);
00713         unset($data->wsusername);
00714         unset($data->wspassword);
00715         unset($data->token);
00716         unset($data->authmethod);
00717 
00718         $params = array();
00719         $params['members'] = array();
00720         for ($i=0; $i<10; $i++) {
00721             if (empty($data->groupid[$i]) or empty($data->userid[$i])) {
00722                 continue;
00723             }
00724             $params['members'][] = array('userid'=>$data->userid[$i], 'groupid'=>$data->groupid[$i]);
00725         }
00726 
00727         return $params;
00728     }
00729 }
 All Data Structures Namespaces Files Functions Variables Enumerations