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 "