diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php index 966b071fe8a..5238ac4376c 100644 --- a/htdocs/adherent.class.php +++ b/htdocs/adherent.class.php @@ -678,12 +678,13 @@ class Adherent ){ $mdpass=md5($this->pass); $htpass=crypt($this->pass,initialiser_sel()); - $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; + $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->prenom." ".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; $mydb=new Db('mysql',MAIN_SPIP_SERVEUR,MAIN_SPIP_USER,MAIN_SPIP_PASS,MAIN_SPIP_DB); $result = $mydb->query($query); if ($result) { + $mydb->close(); return 1; } else @@ -713,6 +714,7 @@ class Adherent if ($result) { + $mydb->close(); return 1; } else @@ -723,6 +725,44 @@ class Adherent } } + /* + * + * est-ce que cet utilisateur est dans spip + * + */ + Function is_in_spip() + { + if (defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1 && + defined('MAIN_SPIP_SERVEUR') && MAIN_SPIP_SERVEUR != '' && + defined('MAIN_SPIP_USER') && MAIN_SPIP_USER != '' && + defined('MAIN_SPIP_PASS') && MAIN_SPIP_PASS != '' && + defined('MAIN_SPIP_DB') && MAIN_SPIP_DB != '' + ){ + $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'"; + $mydb=new Db('mysql',MAIN_SPIP_SERVEUR,MAIN_SPIP_USER,MAIN_SPIP_PASS,MAIN_SPIP_DB); + $result = $mydb->query($query); + + if ($result) + { + if ($mydb->num_rows()){ + # nous avons au moins une reponse + $mydb->close(); + return 1; + }else{ + # nous n'avons pas de reponse => n'existe pas + $mydb->close(); + return 0; + } + } + else + { + # error + $this->errorstr=$mydb->error(); + return -1; + } + } + } + /* * Rajoute cet utilisateur au serveur glasnost * @@ -892,6 +932,63 @@ class Adherent return 0; } } + + /* + * efface cet utilisateur du serveur glasnost + * + */ + Function is_in_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']; + return 1; + }else{ + $this->errorstr=$response['faultString']; + return 0; + } + }else{ + $this->errorstr="Constantes de connection non definies"; + return 0; + } + } /* * * diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 68f48172ae5..1f15309534f 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -559,17 +559,17 @@ if ($rowid > 0) if ($adht->vote == 'yes' && defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1){ define("XMLRPC_DEBUG", 1); + /* - * Case 1 + * Case 1 & 2 */ - print "[id&action=add_glasnost\">Ajout dans Glasnost]\n"; - - - /* - * Case 2 - */ - - print "[id&action=del_glasnost\">Suppression dans Glasnost]\n"; + if ($adh->is_in_glasnost() == 1){ + print "-\n"; + print "[id&action=del_glasnost\">Suppression dans Glasnost]\n"; + }else{ + print "[id&action=add_glasnost\">Ajout dans Glasnost]\n"; + print "-\n"; + } }else{ /* * Case 1 @@ -584,16 +584,16 @@ if ($rowid > 0) if (defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1){ /* - * Case 3 + * Case 3 & 4 */ - print "[id&action=add_spip\">Ajout dans Spip]\n"; - - - /* - * Case 4 - */ - - print "[id&action=del_spip\">Suppression dans Spip]\n"; + if ($adh->is_in_spip() == 1){ + print "-\n"; + print "[id&action=del_spip\">Suppression dans Spip]\n"; + }else{ + print "[id&action=add_spip\">Ajout dans Spip]\n"; + print "-\n"; + } + }else{ /* * Case 3 diff --git a/htdocs/user.class.php3 b/htdocs/user.class.php3 index 9c11fe0f231..9d6806a1c29 100644 --- a/htdocs/user.class.php3 +++ b/htdocs/user.class.php3 @@ -44,7 +44,8 @@ class User { $this->db = $DB; $this->id = $id; - + $this->comm = 0; + $this->compta = 0; $this->limite_liste = 20; return 1;