/**
  * Create a Drupal user when the Chamilo user is registered
  * @param HookCreateUserEventInterface $hook The hook
  */
 public function hookCreateUser(HookCreateUserEventInterface $hook)
 {
     $data = $hook->getEventData();
     $drupalDomain = CreateDrupalUser::create()->get('drupal_domain');
     $drupalDomain = rtrim($drupalDomain, '/') . '/';
     if ($data['type'] === HOOK_EVENT_TYPE_POST) {
         $return = $data['return'];
         $originalPassword = $data['originalPassword'];
         $userInfo = api_get_user_info($return);
         $fields = array('name' => $userInfo['username'], 'pass' => $originalPassword, 'mail' => $userInfo['email'], 'status' => 1, 'init' => $userInfo['email']);
         $extraFields = array('first_name' => $userInfo['firstname'], 'last_name' => $userInfo['lastname']);
         $options = array('location' => $drupalDomain . 'sites/all/modules/chamilo/soap.php?wsdl', 'uri' => $drupalDomain);
         $client = new SoapClient(null, $options);
         $drupalUserId = false;
         if (isset($_SESSION['ws_drupal_user_id'])) {
             $drupalUserId = $_SESSION['ws_drupal_user_id'];
             return true;
         }
         if ($drupalUserId === false) {
             $drupalUserId = $client->addUser($fields, $extraFields);
         }
         if ($drupalUserId !== false) {
             UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId);
         }
     }
 }
function addQSUser($user)
{
    //**** addUser *****
    $wsdl = "http://ita-provisioner.cis.fiu.edu:8080/axis2/services/QuotaSystem?wsdl";
    $location = "http://ita-provisioner.cis.fiu.edu:8080/axis2/services/QuotaSystem";
    $result = false;
    try {
        $usernew = array('id' => $user->id, 'username' => $user->username, 'email' => $user->email);
        //$params = array('user' => $usernew);
        $client = new SoapClient($wsdl, array('location' => $location));
        $client->addUser($usernew);
        $result = true;
    } catch (Exception $e) {
        $result = false;
    } catch (SoapFault $soapfault) {
        $result = false;
    }
    return $result;
}
*/
function out($str)
{
    echo $str . "\n";
}
ini_set('soap.wsdl_cache_enabled', 0);
$username = '******';
//$_POST['username'];
$password = '******';
//md5($_POST['password']);
//$client = new SoapClient("https://srvfh13.fh-luebeck.de/moodle/moodleplugin.wsdl",array('trace'=>1,'login'=>$username,'password'=>$password));
$client = new SoapClient("https://www.myserver.com/moodle/moodleplugin.wsdl");
try {
    $sessid = '';
    out($sessid = $client->login($username, $password));
    out($client->addUser($sessid, 'testheinz', '1234', 'Heinz', 'Test', '*****@*****.**'));
    out($client->updateUser($sessid, 'testheinz', 'Heinzi', 'Tester', '*****@*****.**'));
    out($sessid = $client->logout($sessid));
    out($client->deleteUser($sessid, 'testheinz'));
    //echo $client->exportUsers(2, 'CF101');
    //echo $client->importCourses($xml_string,"Prova");
    //echo $client->exportCourses();
    //echo $client->exportCourses(3,"Prova");
    //echo $client->exportCategories();
} catch (SoapFault $sf) {
    //echo $client->__getLastRequest();
    echo $client->__getLastResponse();
    echo $sf->faultstring;
}
/*else
	{