diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php index d425d700cdc..dc4f84d3b2d 100644 --- a/htdocs/adherent.class.php +++ b/htdocs/adherent.class.php @@ -582,7 +582,7 @@ class Adherent * (mailing-list, spip, glasnost etc etc ..) * */ - Function add_to_abo() + Function add_to_abo($adht) { $err=0; // mailman @@ -592,12 +592,24 @@ class Adherent $err+=1; } } - if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1) + if ($adht->vote == 'yes' && + defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 && + defined("MAIN_USE_GLASNOST_AUTO") && MAIN_USE_GLASNOST_AUTO ==1 + ) { if(!$this->add_to_glasnost()){ $err+=1; } } + if ( + defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1 && + defined("MAIN_USE_SPIP_AUTO") && MAIN_USE_SPIP_AUTO ==1 + ) + { + if(!$this->add_to_spip()){ + $err+=1; + } + } if ($err>0){ // error return 0; @@ -611,7 +623,7 @@ class Adherent * (mailing-list, spip, glasnost etc etc ..) * */ - Function del_to_abo() + Function del_to_abo($adht) { $err=0; // mailman @@ -621,12 +633,24 @@ class Adherent $err+=1; } } - if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1) + if ($adht->vote == 'yes' && + defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 && + defined("MAIN_USE_GLASNOST_AUTO") && MAIN_USE_GLASNOST_AUTO ==1 + ) { if(!$this->del_to_glasnost()){ $err+=1; } } + if ( + defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1 && + defined("MAIN_USE_SPIP_AUTO") && MAIN_USE_SPIP_AUTO ==1 + ) + { + if(!$this->del_to_spip()){ + $err+=1; + } + } if ($err>0){ // error return 0; @@ -635,6 +659,66 @@ class Adherent } } + /* + * + * Ajoute cet utilisateur comme redacteur dans spip + * + */ + Function add_to_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 != '' + ){ + $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\")"; + $mydb=new Db('mysql',MAIN_SPIP_SERVEUR,MAIN_SPIP_USER,MAIN_SPIP_PASS,MAIN_SPIP_DB); + $result = $mydb->query($query); + + if ($result) + { + return 1; + } + else + { + $this->errorstr=$mydb->error(); + return 0; + } + } + } + + /* + * + * supprime cet utilisateur dans spip + * + */ + Function del_to_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 = "DELETE 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) + { + return 1; + } + else + { + $this->errorstr=$mydb->error(); + return 0; + } + } + } + /* * Rajoute cet utilisateur au serveur glasnost * @@ -661,6 +745,7 @@ class Adherent $userid=$response[0]; $usertoken=$response[1]; }else{ + $this->errorstr=$response['faultString']; return 0; } @@ -689,10 +774,12 @@ class Adherent if ($success){ $personid=$response[0]; }else{ + $this->errorstr=$response['faultString']; return 0; } return 1; }else{ + $this->errorstr="Constantes de connection non definies"; return 0; } } @@ -744,6 +831,7 @@ class Adherent if ($success){ $personid=$response['id']; }else{ + $this->errorstr=$response['faultString']; return 0; } if (defined('MAIN_GLASNOST_DEFAULT_GROUPID') && MAIN_GLASNOST_DEFAULT_GROUPID != ''){ @@ -766,6 +854,7 @@ class Adherent if ($success){ $groupids=$response['membersSet']; }else{ + $this->errorstr=$response['faultString']; return 0; } // TODO faire la verification que le user n'est pas dans ce @@ -791,9 +880,11 @@ class Adherent if ($success){ return 1; }else{ + $this->errorstr=$response['faultString']; return 0; } }else{ + $this->errorstr="Constantes de connection non definies"; return 0; } } @@ -847,6 +938,7 @@ class Adherent } return 1; }else{ + $this->errorstr="Constantes de connection non definies"; return 0; } } @@ -897,6 +989,7 @@ class Adherent } return 1; }else{ + $this->errorstr="Constantes de connection non definies"; return 0; } } diff --git a/htdocs/adherent_type.class.php b/htdocs/adherent_type.class.php index 938b6a20a28..e859f09dc2f 100644 --- a/htdocs/adherent_type.class.php +++ b/htdocs/adherent_type.class.php @@ -29,6 +29,7 @@ class AdherentType var $errorstr; var $mail_valid; // mail envoye lors de la validation var $commentaire; // commentaire + var $vote; // droit de vote ? /* * * @@ -97,6 +98,7 @@ class AdherentType $sql .= ",statut=".$this->statut; $sql .= ",cotisation='".$this->cotisation."'"; $sql .= ",note='".$this->commentaire."'"; + $sql .= ",vote='".$this->vote."'"; $sql .= ",mail_valid='".$this->mail_valid."'"; $sql .= " WHERE rowid = $this->id"; @@ -166,6 +168,7 @@ class AdherentType $this->cotisation = $obj->cotisation; $this->mail_valid = $obj->mail_valid; $this->commentaire = $obj->note; + $this->vote = $obj->vote; } } else diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 9ad600353d4..d58c6bc7544 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -106,21 +106,12 @@ if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] = $adh->send_an_email($adh->email,$conf->adherent->email_valid,$conf->adherent->email_valid_subject); } // rajoute l'utilisateur dans les divers abonnements .. - if (!$adh->add_to_abo()) + if (!$adh->add_to_abo($adht)) { // error - $errmsg="echec du rajout de l'utilisateur aux mailing-lists"; + $errmsg.="echec du rajout de l'utilisateur aux abonnements: ".$adh->errostr."
\n"; } - /* - if ($conf->adherent->use_mailman == 1) - { - foreach ($conf->adherent->mailman_lists as $key) - { - $adh->add_to_mailman($adh->email,$key,$conf->adherent->mailman_dir); - } - } - */ } if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] == yes) @@ -129,13 +120,16 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] $adh->resiliate($user->id); $adh->fetch($rowid); + $adht = new AdherentType($db); + $adht->fetch($adh->typeid); + $adh->send_an_email($adh->email,$conf->adherent->email_resil,$conf->adherent->email_resil_subject); // supprime l'utilisateur des divers abonnements .. - if (!$adh->del_to_abo()) + if (!$adh->del_to_abo($adht)) { // error - $errmsg="echec du rajout de l'utilisateur aux mailing-lists"; + $errmsg.="echec de la suppression de l'utilisateur aux abonnements: ".$adh->errostr."
\n"; } } @@ -145,10 +139,16 @@ if ($HTTP_POST_VARS["action"] == 'confirm_add_glasnost' && $HTTP_POST_VARS["conf { $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(); + $adht = new AdherentType($db); + $adht->fetch($adh->typeid); + if ($adht->vote == 'yes'){ + define("XMLRPC_DEBUG", 1); + if (!$adh->add_to_glasnost()){ + $errmsg.="Echec du rajout de l'utilisateur dans glasnost: ".$adh->errostr."
\n"; + } + if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){ + XMLRPC_debug_print(); + } } } @@ -156,12 +156,38 @@ if ($HTTP_POST_VARS["action"] == 'confirm_del_glasnost' && $HTTP_POST_VARS["conf { $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(); + $adht = new AdherentType($db); + $adht->fetch($adh->typeid); + if ($adht->vote == 'yes'){ + define("XMLRPC_DEBUG", 1); + if(!$adh->del_to_glasnost()){ + $errmsg.="Echec de la suppression de l'utilisateur dans glasnost: ".$adh->errostr."
\n"; + } + if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){ + XMLRPC_debug_print(); + } } } + +if ($HTTP_POST_VARS["action"] == 'confirm_del_spip' && $HTTP_POST_VARS["confirm"] == yes) +{ + $adh = new Adherent($db, $rowid); + $adh->fetch($rowid); + if(!$adh->del_to_spip()){ + $errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$adh->errostr."
\n"; + } +} + +if ($HTTP_POST_VARS["action"] == 'confirm_add_spip' && $HTTP_POST_VARS["confirm"] == yes) +{ + $adh = new Adherent($db, $rowid); + $adh->fetch($rowid); + if (!$adh->add_to_spip()){ + $errmsg.="Echec du rajout de l'utilisateur dans spip: ".$adh->errostr."
\n"; + } +} + + /* ************************************************************************** */ /* */ /* Création d'une fiche */ @@ -180,25 +206,6 @@ 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"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - if ($num) { - $obj = $db->fetch_object( 0); - - $total = $obj->total; - } - } - */ - // $adho = new AdherentOptions($db); - - //$myattr=$adho->fetch_name_optionals(); - print_titre("Nouvel adhérent"); print "
\n"; print ''; @@ -276,6 +283,8 @@ if ($rowid > 0) $adh->fetch($rowid); $adh->fetch_optionals($rowid); //$myattr=$adh->fetch_name_optionals(); + $adht = new AdherentType($db); + $adht->fetch($adh->typeid); print_titre("Edition de la fiche adhérent"); @@ -370,7 +379,7 @@ if ($rowid > 0) print ''; - print ''; - print '\n"; + print ''; + print '
Valider un adhérent
Etes-vous sur de vouloir ajouter cet adhérent dans glasnost ?'; + print '
Etes-vous sur de vouloir ajouter cet adhérent dans glasnost ? (serveur : '.MAIN_GLASNOST_SERVEUR.')'; $htmls = new Form($db); $htmls->selectyesno("confirm","no"); @@ -395,7 +404,57 @@ if ($rowid > 0) print '
Valider un adhérent
Etes-vous sur de vouloir effacer cet adhérent de glasnost ?'; + print '
Etes-vous sur de vouloir effacer cet adhérent de glasnost ? (serveur : '.MAIN_GLASNOST_SERVEUR.')'; + $htmls = new Form($db); + + $htmls->selectyesno("confirm","no"); + + print "
'; + print "
\n"; + } + + /* + * Confirmation de l'ajout dans spip + * + */ + + if ($action == 'add_spip') + { + + print '
'; + print ''; + print ''; + + print ''; + + print '\n"; + print ''; + print '
Valider un adhérent
Etes-vous sur de vouloir ajouter cet adhérent dans spip ? (serveur : '.MAIN_SPIP_SERVEUR.')'; + $htmls = new Form($db); + + $htmls->selectyesno("confirm","no"); + + print "
'; + print "
\n"; + } + + /* + * Confirmation de la suppression dans spip + * + */ + + if ($action == 'del_spip') + { + + print '
'; + print ''; + print ''; + + print ''; + + print ''; print ""; - print ""; + print ""; print "\n"; $var=True; @@ -112,6 +114,7 @@ if ($result) print "\n"; print ''; print ''; + print ''; print ''; print ""; $i++; @@ -125,30 +128,30 @@ else } -print "

Valider un adhérent
Etes-vous sur de vouloir effacer cet adhérent de glasnost ? (serveur : '.MAIN_SPIP_SERVEUR.')'; $htmls = new Form($db); $htmls->selectyesno("confirm","no"); @@ -409,18 +468,21 @@ if ($rowid > 0) print "\n"; print ''; - print "\n"; + print ''; print ''; - print ''; + print "\n"; print ''; + print ''; + + + print ''; - print ''; - + print ''; print ''; print ''; @@ -457,7 +519,7 @@ if ($rowid > 0) * Case 1 */ - print ''; + print ''; /* * Case 2 @@ -465,46 +527,80 @@ if ($rowid > 0) if ($adh->statut < 1) { - print "\n"; + print "\n"; } else { - print "\n"; + print "\n"; } /* * Case 3 */ if ($adh->statut == 1) { - print "\n"; + print "\n"; } else { - print "\n"; + print "\n"; } /* * Case 4 */ - print "\n"; + print "\n"; + + print "\n"; - if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1){ + if ($adht->vote == 'yes' && defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1){ define("XMLRPC_DEBUG", 1); /* - * Case 5 + * Case 1 */ - print "\n"; + print "\n"; /* - * Case 6 + * Case 2 */ - print "\n"; + print "\n"; + }else{ + /* + * Case 1 + */ + print "\n"; + + /* + * Case 2 + */ + print "\n"; } + if (defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1){ + /* + * Case 3 + */ + print "\n"; + + + /* + * Case 4 + */ + + print "\n"; + }else{ + /* + * Case 3 + */ + print "\n"; + /* + * Case 4 + */ + print "\n"; + } print "
Type$adh->type
Numero'.$adh->id.' Commentaires
Personne'.$adh->morphy.' 
Type$adh->type'; print nl2br($adh->commentaire).' 
Personne'.$adh->morphy.' 
Prénom'.$adh->prenom.' 
Nom'.$adh->nom.' 
Nom'.$adh->nom.' 
Société'.$adh->societe.' 
Adresse'.nl2br($adh->adresse).' 
[Editer][Editer][Valider l'adhésion][Valider l'adhésion]--[Résilier l'adhésion][Résilier l'adhésion]--[id&action=delete\">Supprimer][id&action=delete\">Supprimer]
[id&action=add_glasnost\">Ajout dans Glasnost][id&action=add_glasnost\">Ajout dans Glasnost][id&action=del_glasnost\">Suppression dans Glasnost][id&action=del_glasnost\">Suppression dans Glasnost]--[id&action=add_spip\">Ajout dans Spip][id&action=del_spip\">Suppression dans Spip]--

\n"; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 0a0f10ffa85..04c32df034f 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -39,6 +39,7 @@ if ($HTTP_POST_VARS["action"] == 'add' && $user->admin) $adht->cotisation = $HTTP_POST_VARS["cotisation"]; $adht->commentaire = $HTTP_POST_VARS["comment"]; $adht->mail_valid = $HTTP_POST_VARS["mail_valid"]; + $adht->vote = $HTTP_POST_VARS["vote"]; if ($adht->create($user->id) ) { @@ -55,6 +56,7 @@ if ($HTTP_POST_VARS["action"] == 'update' && $user->admin) $adht->cotisation = $HTTP_POST_VARS["cotisation"]; $adht->commentaire = $HTTP_POST_VARS["comment"]; $adht->mail_valid = $HTTP_POST_VARS["mail_valid"]; + $adht->vote = $HTTP_POST_VARS["vote"]; if ($adht->update($user->id) ) { @@ -87,7 +89,7 @@ print_titre("Configuration"); /* */ /* ************************************************************************** */ -$sql = "SELECT d.rowid, d.libelle, d.cotisation"; +$sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote"; $sql .= " FROM llx_adherent_type as d"; $result = $db->query($sql); @@ -100,7 +102,7 @@ if ($result) print '

IdLibelléCotisation ? LibelléCotisation ?Vote ? 
".$objp->rowid."'.$objp->libelle.''.$objp->cotisation.''.$objp->vote.'Editer
"; +print "

"; /* * Case 1 */ -print ''; +print ''; /* * Case 2 */ -print ""; +print ""; /* * Case 3 */ -print ""; +print ""; /* * Case 4 */ -print ""; +print ""; print "
[Nouveau Type][Nouveau Type]------

"; @@ -193,6 +196,11 @@ if ($action == 'create') { print ''; + print 'Droit de vote'; + + print ''; + print 'Commentaires :'; print ""; @@ -223,8 +231,10 @@ if ($rowid > 0 && $action == 'edit') print 'Libellé'.$adht->libelle.' '; print 'Soumis à cotisation'.$adht->cotisation.' '; - print 'Commentaires'; + print 'Droit de vote'.$adht->vote.' '; + + print 'Commentaires'; print ''; print nl2br($adht->commentaire).' '; @@ -253,7 +263,12 @@ if ($rowid > 0 && $action == 'edit') $htmls = new Form($db); $htmls->selectyesno("cotisation",$adht->cotisation); - + print ''; + + print 'Droit de vote'; + $htmls->selectyesno("vote",$adht->vote); + print ''; + print 'Commentaires :'; print ""; diff --git a/htdocs/lib/functions.inc.php3 b/htdocs/lib/functions.inc.php3 index 7a42aa7a35a..15bcb232dfa 100644 --- a/htdocs/lib/functions.inc.php3 +++ b/htdocs/lib/functions.inc.php3 @@ -671,4 +671,42 @@ function logfile($str,$log="/var/log/dolibarr/dolibarr.log") return 1; } } + +/* + * Fonctions reprise sur spip + * http://www.uzine.net/spip/ + */ +function creer_pass_aleatoire($longueur = 8, $sel = "") { + $seed = (double) (microtime() + 1) * time(); + srand($seed); + + for ($i = 0; $i < $longueur; $i++) { + if (!$s) { + if (!$s) $s = rand(); + $s = substr(md5(uniqid($s).$sel), 0, 16); + } + $r = unpack("Cr", pack("H2", $s.$s)); + $x = $r['r'] & 63; + if ($x < 10) $x = chr($x + 48); + else if ($x < 36) $x = chr($x + 55); + else if ($x < 62) $x = chr($x + 61); + else if ($x == 63) $x = '/'; + else $x = '.'; + $pass .= $x; + $s = substr($s, 2); + } + return $pass; +} + +/* + * Fonctions reprise sur spip + * http://www.uzine.net/spip/ + */ + +function initialiser_sel() { + global $htsalt; + + $htsalt = '$1$'.creer_pass_aleatoire(); +} + ?> diff --git a/mysql/data/data.sql b/mysql/data/data.sql index aa0ea6ca20f..9818cf12a74 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -62,6 +62,13 @@ INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_GLASNOST','0', INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_SERVEUR','glasnost.j1b.org','chaine','serveur glasnost'); INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_USER','user','chaine','Administrateur glasnost'); INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_PASS','password','chaine','password de l\'administrateur'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_GLASNOST_AUTO','1','yesno','inscription automatique a glasnost ?'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_SPIP','1','yesno','Utilisation de SPIP ?'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_SPIP_AUTO','1','yesno','Utilisation de SPIP automatiquement'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_SPIP_USER','user','chaine','user spip'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_SPIP_PASS','pass','chaine','Pass de connection'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_SPIP_SERVEUR','localhost','chaine','serveur spip'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_SPIP_DB','spip','chaine','db spip'); -- -- Constantes diff --git a/mysql/tables/llx_adherent_type.sql b/mysql/tables/llx_adherent_type.sql index c8bbf34e1c1..d2ddf44433c 100644 --- a/mysql/tables/llx_adherent_type.sql +++ b/mysql/tables/llx_adherent_type.sql @@ -29,6 +29,7 @@ create table llx_adherent_type statut smallint NOT NULL DEFAULT 0, libelle varchar(50), cotisation enum('yes','no') NOT NULL DEFAULT 'yes', + vote enum('yes','no') NOT NULL DEFAULT 'yes', note text, mail_valid text -- mail envoye a la validation );