diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php index 7424da3db11..d425d700cdc 100644 --- a/htdocs/adherent.class.php +++ b/htdocs/adherent.class.php @@ -592,6 +592,12 @@ class Adherent $err+=1; } } + if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1) + { + if(!$this->add_to_glasnost()){ + $err+=1; + } + } if ($err>0){ // error return 0; @@ -615,6 +621,12 @@ class Adherent $err+=1; } } + if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1) + { + if(!$this->del_to_glasnost()){ + $err+=1; + } + } if ($err>0){ // error return 0; @@ -623,6 +635,168 @@ class Adherent } } + /* + * Rajoute cet utilisateur au serveur glasnost + * + */ + Function add_to_glasnost() + { + if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 && + defined('MAIN_GLASNOST_SERVEUR') && MAIN_GLASNOST_SERVEUR != '' && + defined('MAIN_GLASNOST_USER') && MAIN_GLASNOST_USER != '' && + defined('MAIN_GLASNOST_PASS') && MAIN_GLASNOST_PASS != '' + ){ + // application token is not useful here + $applicationtoken=''; + list($success, $response) = + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication"), + XMLRPC_prepare('getUserIdAndToken'), + XMLRPC_prepare(array("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication","$applicationtoken",MAIN_GLASNOST_USER,MAIN_GLASNOST_PASS)) + ) + ); + if ($success){ + $userid=$response[0]; + $usertoken=$response[1]; + }else{ + return 0; + } + + list($success,$response)= + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"), + XMLRPC_prepare('addObject'), + XMLRPC_prepare(array( + "glasnost://".MAIN_GLASNOST_SERVEUR."/people", + "$applicationtoken", + $usertoken, + array( + '__thingCategory__'=>'object', + '__thingName__'=> 'Person', + 'firstName'=>$this->prenom, + 'lastName'=>$this->nom, + 'login'=>$this->login, + 'email'=>$this->email + ) + ) + ) + ) + ); + if ($success){ + $personid=$response[0]; + }else{ + return 0; + } + return 1; + }else{ + return 0; + } + } + + /* + * efface cet utilisateur du serveur glasnost + * + */ + Function del_to_glasnost() + { + if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 && + defined('MAIN_GLASNOST_SERVEUR') && MAIN_GLASNOST_SERVEUR != '' && + defined('MAIN_GLASNOST_USER') && MAIN_GLASNOST_USER != '' && + defined('MAIN_GLASNOST_PASS') && MAIN_GLASNOST_PASS != '' + ){ + // application token is not useful here + $applicationtoken=''; + list($success, $response) = + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication"), + XMLRPC_prepare('getUserIdAndToken'), + XMLRPC_prepare(array("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication","$applicationtoken",MAIN_GLASNOST_USER,MAIN_GLASNOST_PASS)) + ) + ); + if ($success){ + $userid=$response[0]; + $usertoken=$response[1]; + }else{ + return 0; + } + // recuperation du personID + list($success,$response)= + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"), + XMLRPC_prepare('getObjectByLogin'), + XMLRPC_prepare(array( + "glasnost://".MAIN_GLASNOST_SERVEUR."/people", + "$applicationtoken", + $usertoken, + $this->login + ) + ) + ) + ); + if ($success){ + $personid=$response['id']; + }else{ + return 0; + } + if (defined('MAIN_GLASNOST_DEFAULT_GROUPID') && MAIN_GLASNOST_DEFAULT_GROUPID != ''){ + // recuperation des personne de ce groupe + list($success,$response)= + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/groups"), + XMLRPC_prepare('getObject'), + XMLRPC_prepare(array( + "glasnost://".MAIN_GLASNOST_SERVEUR."/groups", + "$applicationtoken", + $usertoken, + MAIN_GLASNOST_DEFAULT_GROUPID + ) + ) + ) + ); + if ($success){ + $groupids=$response['membersSet']; + }else{ + return 0; + } + // TODO faire la verification que le user n'est pas dans ce + // groupe par defaut. si il y ai il faut l'effacer et + // modifier le groupe + } + // suppression du personID + list($success,$response)= + XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001', + '/RPC2', + 'callGateway', + array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"), + XMLRPC_prepare('deleteObject'), + XMLRPC_prepare(array( + "glasnost://".MAIN_GLASNOST_SERVEUR."/people", + "$applicationtoken", + $usertoken, + $personid + ) + ) + ) + ); + if ($success){ + return 1; + }else{ + return 0; + } + }else{ + return 0; + } + } /* * * diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index c2dbe77dac6..9ad600353d4 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -26,7 +26,7 @@ require($GLOBALS["DOCUMENT_ROOT"]."/adherent_type.class.php"); require($GLOBALS["DOCUMENT_ROOT"]."/adherents/adherent_options.class.php"); require($GLOBALS["DOCUMENT_ROOT"]."/cotisation.class.php"); require($GLOBALS["DOCUMENT_ROOT"]."/paiement.class.php"); - +require($GLOBALS["DOCUMENT_ROOT"]."/adherents/XML-RPC.functions.php"); $db = new Db(); $adho = new AdherentOptions($db); @@ -137,21 +137,31 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] // error $errmsg="echec du rajout de l'utilisateur aux mailing-lists"; } - - /* - if ($conf->adherent->use_mailman == 1) - { - foreach ($conf->adherent->mailman_lists as $key) - { - $adh->del_to_mailman($adh->email,$key,$conf->adherent->mailman_dir); - } - } - */ } - llxHeader(); +if ($HTTP_POST_VARS["action"] == 'confirm_add_glasnost' && $HTTP_POST_VARS["confirm"] == yes) +{ + $adh = new Adherent($db, $rowid); + $adh->fetch($rowid); + define("XMLRPC_DEBUG", 1); + $adh->add_to_glasnost(); + if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){ + XMLRPC_debug_print(); + } +} + +if ($HTTP_POST_VARS["action"] == 'confirm_del_glasnost' && $HTTP_POST_VARS["confirm"] == yes) +{ + $adh = new Adherent($db, $rowid); + $adh->fetch($rowid); + define("XMLRPC_DEBUG", 1); + $adh->del_to_glasnost(); + if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){ + XMLRPC_debug_print(); + } +} /* ************************************************************************** */ /* */ /* Création d'une fiche */ @@ -170,6 +180,7 @@ if ($errmsg != ''){ $adho->fetch_optionals(); if ($action == 'create') { + /* $sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; $sql .= " FROM societe as s, llx_facture as f WHERE f.fk_soc = s.idp"; $sql .= " AND f.rowid = $facid"; @@ -183,6 +194,7 @@ if ($action == 'create') { $total = $obj->total; } } + */ // $adho = new AdherentOptions($db); //$myattr=$adho->fetch_name_optionals(); @@ -344,6 +356,55 @@ if ($rowid > 0) print "\n"; } + /* + * Confirmation de l'ajout dans glasnost + * + */ + + if ($action == 'add_glasnost') + { + + print '
\n"; + } + + /* + * Confirmation de la suppression dans glasnost + * + */ + + if ($action == 'del_glasnost') + { + + print '\n"; + } print "