fault or $client->getError()) { throw new Exception(__FUNCTION__.' - '.$client->getError(), EXC_WS); } $_WSDL[$wsdl_file] = $client; } if(SOAP_DEBUG) echo '
ClientWSDL::'.$WSDL.'
'; return $_WSDL[$wsdl_file]; } /* * @param string * @param array * @param string */ function WS_call($function, $params, $wsdl='WsClickeduMoodle') { $Client = ClientWSDL($wsdl); switch($function) { case 'Login': $result = $Client->call($function, array($params)); break; default: $result = $Client->call($function, $params); break; } if (SOAP_DEBUG) { echo '
WS_call:'.$function.'
'; echo '
'.print_r($params,true).'
'; echo '
'.print_r($result,true).'
'; } if ($result['Code'] === 1) { return $result['Result']; } else if ($Client->fault or $Client->getError()) { throw new Exception(__FUNCTION__.':'.$function.' - '.$Client->getError(), EXC_WS); } else { //throw new Exception(__FUNCTION__.':'.$function.' - '.$result['Description'], EXC_WS); } return false; } /* * */ function WS_Login() { global $CFG; if (isset($CFG->center)) $SchoolCode = $CFG->center; else if (isset($CFG->ws_school)) $SchoolCode = $CFG->ws_school; else $SchoolCode = $CFG->wwwroot; if (empty($CFG->ws_user) or empty($CFG->ws_password) or empty($SchoolCode)) { throw new Exception(__FUNCTION__.' required params (user,password,school)', EXC_WS); } $params = array(); $params['User'] = (string)$CFG->ws_user; $params['Password'] = (string)$CFG->ws_password; $params['SchoolCode'] = (string)$SchoolCode; $Client = ClientWSDL('WsClickedu'); $result = $Client->call('Login', array($params)); if (SOAP_DEBUG) { echo '
WS_Login
'; echo '
'.print_r($params,true).'
'; echo '
'.print_r($result,true).'
'; } if ($result['Code'] === 1) { return $result['Result']; } else if ($Client->fault or $Client->getError()) { throw new Exception(__FUNCTION__.' -> '.$Client->getError(), EXC_WS); } else { throw new Exception(__FUNCTION__.' >- '.$result['Description'], EXC_WS); } } /* * @param string * @param string */ function WS_getUsers($Licences, $date) { $Paramms = array(); $Params['Licences'] = (string)$Licences; $Params['datemodified'] = (string)$date; $Client = ClientWSDL('WsClickedu'); $a = WS_call('getUsers', $Params); return $a; } /* * @param string */ function WS_getUsersCourse($Licences) { $Paramms = array(); $Params['Licences'] = (string)$Licences; $Client = ClientWSDL('WsClickedu'); return WS_call('getUsersCourse', $Params); } /* * @param string * @param int */ function WS_getUser($Licences, $idnumber) { $Paramms = array(); $Params['Licences'] = (string)$Licences; $Params['idnumber'] = (int)$idnumber; return WS_call('getUser', $Params); } /* * @param string * @param int */ function WS_getCourses($Licences, $userid=NULL) { $Paramms = array(); $Params['Licences'] = (string)$Licences; $Params['userid'] = (int)$userid; return WS_call('getCourses', $Params); } /* * @param string * @param int */ function WS_getContentCourse($Licences, $idnumber) { $Paramms = array(); $Params['Licences'] = (string)$Licences; $Params['idnumber'] = (int)$idnumber; return WS_call('getContentCourse', $Params); } ?>