2002-12-30 16:13:28 +01:00
|
|
|
|
<?PHP
|
2003-02-03 12:56:05 +01:00
|
|
|
|
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
|
|
|
|
|
*
|
2002-12-30 16:13:28 +01:00
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class Adherent
|
|
|
|
|
|
{
|
|
|
|
|
|
var $id;
|
|
|
|
|
|
var $db;
|
|
|
|
|
|
var $prenom;
|
|
|
|
|
|
var $nom;
|
|
|
|
|
|
var $societe;
|
|
|
|
|
|
var $adresse;
|
|
|
|
|
|
var $cp;
|
|
|
|
|
|
var $ville;
|
|
|
|
|
|
var $pays;
|
|
|
|
|
|
var $typeid;
|
2002-12-30 16:57:44 +01:00
|
|
|
|
var $morphy;
|
2002-12-30 16:13:28 +01:00
|
|
|
|
var $email;
|
|
|
|
|
|
var $public;
|
|
|
|
|
|
var $commentaire;
|
|
|
|
|
|
var $statut;
|
2003-01-13 18:01:30 +01:00
|
|
|
|
var $login;
|
|
|
|
|
|
var $pass;
|
2003-01-22 18:51:49 +01:00
|
|
|
|
var $naiss;
|
|
|
|
|
|
var $photo;
|
2003-03-03 18:39:23 +01:00
|
|
|
|
// var $public;
|
2003-02-10 18:36:55 +01:00
|
|
|
|
var $array_options;
|
2002-12-30 16:13:28 +01:00
|
|
|
|
|
|
|
|
|
|
var $errorstr;
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2002-12-30 17:29:21 +01:00
|
|
|
|
Function Adherent($DB, $id='')
|
2002-12-30 16:13:28 +01:00
|
|
|
|
{
|
|
|
|
|
|
$this->db = $DB ;
|
2002-12-30 17:29:21 +01:00
|
|
|
|
$this->id = $id;
|
|
|
|
|
|
$this->statut = -1;
|
2003-01-22 18:51:49 +01:00
|
|
|
|
// l'adherent n'est pas public par defaut
|
|
|
|
|
|
$this->public = 0;
|
2003-02-10 18:36:55 +01:00
|
|
|
|
// les champs optionnels sont vides
|
|
|
|
|
|
$this->array_options=array();
|
2002-12-30 16:13:28 +01:00
|
|
|
|
}
|
2003-03-03 00:35:52 +01:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* function envoyant un email au destinataire (recipient) avec le text fourni en parametre.
|
2003-03-03 18:39:23 +01:00
|
|
|
|
* La particularite de cette fonction est de remplacer certains champs par leur valeur pour l'adherent
|
2003-03-03 00:35:52 +01:00
|
|
|
|
* en l'occurrence :
|
2003-03-03 18:39:23 +01:00
|
|
|
|
* %PRENOM% : est remplace par le prenom
|
|
|
|
|
|
* %NOM% : est remplace par nom
|
|
|
|
|
|
* %INFOS% : l'ensemble des attributs de cet adherent
|
|
|
|
|
|
* %SERVEUR% : URL du serveur web
|
|
|
|
|
|
* ...
|
2003-03-03 00:35:52 +01:00
|
|
|
|
*/
|
2003-03-03 18:39:23 +01:00
|
|
|
|
Function send_an_email($recipients,$text,$subject="Vos coordonnees sur %SERVEUR%")
|
2003-03-03 00:35:52 +01:00
|
|
|
|
{
|
2003-03-03 18:39:23 +01:00
|
|
|
|
$patterns = array (
|
|
|
|
|
|
'/%PRENOM%/',
|
|
|
|
|
|
'/%NOM%/',
|
|
|
|
|
|
'/%INFOS%/',
|
|
|
|
|
|
'/%INFO%/',
|
|
|
|
|
|
'/%SERVEUR%/',
|
|
|
|
|
|
'/%SOCIETE%/',
|
|
|
|
|
|
'/%ADRESSE%/',
|
|
|
|
|
|
'/%CP%/',
|
|
|
|
|
|
'/%VILLE%/',
|
|
|
|
|
|
'/%PAYS%/',
|
|
|
|
|
|
'/%EMAIL%/',
|
|
|
|
|
|
'/%NAISS%/',
|
|
|
|
|
|
'/%PHOTO%/',
|
|
|
|
|
|
'/%LOGIN%/',
|
|
|
|
|
|
'/%PASS%/'
|
|
|
|
|
|
);
|
|
|
|
|
|
$infos = "Prenom : $this->prenom\nNom : $this->nom\nSociete : $this->societe\nAdresse : $this->adresse\nCP : $this->cp\nVille : $this->ville\nPays : $this->pays\nEmail : $this->email\nLogin : $this->login\nPassword : $this->pass\nDate de naissance : $this->naiss\nPhoto : $this->photo\n";
|
|
|
|
|
|
if ($this->public == 1){
|
|
|
|
|
|
$infos.="Fiche Publique : Oui\n";
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$infos.="Fiche Publique : Non\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
$replace = array (
|
|
|
|
|
|
$this->prenom,
|
|
|
|
|
|
$this->nom,
|
|
|
|
|
|
$infos,
|
|
|
|
|
|
$infos,
|
|
|
|
|
|
"http://".$_SERVER["SERVER_NAME"]."/",
|
|
|
|
|
|
$this->societe,
|
|
|
|
|
|
$this->adresse,
|
|
|
|
|
|
$this->cp,
|
|
|
|
|
|
$this->ville,
|
|
|
|
|
|
$this->pays,
|
|
|
|
|
|
$this->email,
|
|
|
|
|
|
$this->naiss,
|
|
|
|
|
|
$this->photo,
|
|
|
|
|
|
$this->login,
|
|
|
|
|
|
$this->pass
|
|
|
|
|
|
);
|
|
|
|
|
|
$texttosend = preg_replace ($patterns, $replace, $text);
|
|
|
|
|
|
$subjectosend = preg_replace ($patterns, $replace, $subject);
|
2003-03-10 17:55:11 +01:00
|
|
|
|
if (defined('MAIN_MAIL_FROM') && MAIN_MAIL_FROM != ''){
|
|
|
|
|
|
return mail($recipients,$subjectosend,$texttosend,"From: ".MAIN_MAIL_FROM."\nReply-To: ".MAIN_MAIL_FROM."\nX-Mailer: PHP/" . phpversion());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return mail($recipients,$subjectosend,$texttosend);
|
|
|
|
|
|
}
|
2003-03-03 00:35:52 +01:00
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function print_error_list()
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = sizeof($this->errorstr);
|
|
|
|
|
|
for ($i = 0 ; $i < $num ; $i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<li>" . $this->errorstr[$i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function check($minimum=0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$err = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->societe)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((strlen(trim($this->nom)) + strlen(trim($this->prenom))) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Vous devez saisir vos nom et pr<70>nom ou le nom de votre soci<63>t<EFBFBD>.";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->adresse)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "L'adresse saisie est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->cp)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le code postal saisi est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->ville)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "La ville saisie est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->email)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "L'email saisi est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-01-13 18:01:30 +01:00
|
|
|
|
if (strlen(trim($this->login)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le login saisi est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(trim($this->pass)) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le pass saisi est invalide";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
$this->amount = trim($this->amount);
|
|
|
|
|
|
|
|
|
|
|
|
$map = range(0,9);
|
|
|
|
|
|
for ($i = 0; $i < strlen($this->amount) ; $i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!isset($map[substr($this->amount, $i, 1)] ))
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le montant du don contient un/des caract<63>re(s) invalide(s)";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
$amount_invalid = 1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (! $amount_invalid)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->amount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le montant du don est null";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->amount < $minimum && $minimum > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$error_string[$err] = "Le montant minimum du don est de $minimum";
|
|
|
|
|
|
$err++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Return errors
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if ($err)
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->errorstr = $error_string;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Cr<EFBFBD>ation
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function create($userid)
|
|
|
|
|
|
{
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Insertion dans la base
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$this->date = $this->db->idate($this->date);
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO llx_adherent (datec)";
|
|
|
|
|
|
$sql .= " VALUES (now())";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
$this->id = $this->db->last_insert_id();
|
|
|
|
|
|
return $this->update();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<h2><br>$sql<br></h2>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Mise <EFBFBD> jour
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE llx_adherent SET ";
|
|
|
|
|
|
$sql .= "prenom = '".$this->prenom ."'";
|
|
|
|
|
|
$sql .= ",nom='".$this->nom."'";
|
|
|
|
|
|
$sql .= ",societe='".$this->societe."'";
|
|
|
|
|
|
$sql .= ",adresse='".$this->adresse."'";
|
|
|
|
|
|
$sql .= ",cp='".$this->cp."'";
|
|
|
|
|
|
$sql .= ",ville='".$this->ville."'";
|
|
|
|
|
|
$sql .= ",pays='".$this->pays."'";
|
|
|
|
|
|
$sql .= ",note='".$this->commentaire."'";
|
|
|
|
|
|
$sql .= ",email='".$this->email."'";
|
2003-01-13 18:01:30 +01:00
|
|
|
|
$sql .= ",login='".$this->login."'";
|
|
|
|
|
|
$sql .= ",pass='".$this->pass."'";
|
2003-01-22 18:51:49 +01:00
|
|
|
|
$sql .= ",naiss='".$this->naiss."'";
|
|
|
|
|
|
$sql .= ",photo='".$this->photo."'";
|
|
|
|
|
|
$sql .= ",public='".$this->public."'";
|
2002-12-30 16:13:28 +01:00
|
|
|
|
$sql .= ",statut=".$this->statut;
|
|
|
|
|
|
$sql .= ",fk_adherent_type=".$this->typeid;
|
2002-12-30 16:57:44 +01:00
|
|
|
|
$sql .= ",morphy='".$this->morphy."'";
|
2002-12-30 16:13:28 +01:00
|
|
|
|
|
|
|
|
|
|
$sql .= " WHERE rowid = $this->id";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
2003-02-13 19:15:18 +01:00
|
|
|
|
|
|
|
|
|
|
if (!$result)
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<h2><br>$sql<br></h2>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(sizeof($this->array_options) > 0 ){
|
|
|
|
|
|
$sql = "REPLACE INTO llx_adherent_options SET adhid = $this->id";
|
|
|
|
|
|
foreach($this->array_options as $key => $value){
|
|
|
|
|
|
// recupere le nom de l'attribut
|
|
|
|
|
|
$attr=substr($key,8);
|
|
|
|
|
|
$sql.=",$attr = '".$this->array_options[$key]."'";
|
|
|
|
|
|
}
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-12-30 16:13:28 +01:00
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<h2><br>$sql<br></h2>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2003-02-03 12:56:05 +01:00
|
|
|
|
* Suppression de l'adh<EFBFBD>rent
|
2002-12-30 16:13:28 +01:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function delete($rowid)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
$result = 0;
|
|
|
|
|
|
$sql = "DELETE FROM llx_adherent WHERE rowid = $rowid";
|
|
|
|
|
|
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( $this->db->affected_rows() )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "DELETE FROM llx_cotisation WHERE fk_adherent = $rowid";
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( $this->db->affected_rows() )
|
|
|
|
|
|
{
|
|
|
|
|
|
$result = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-02-13 19:15:18 +01:00
|
|
|
|
$sql = "DELETE FROM llx_adherent_options WHERE adhid = $rowid";
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( $this->db->affected_rows() )
|
|
|
|
|
|
{
|
|
|
|
|
|
$result = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "Err : ".$this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Fetch
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2003-01-29 18:36:37 +01:00
|
|
|
|
/* Fetch adherent corresponding to login passed in argument */
|
|
|
|
|
|
Function fetch_login($login){
|
2003-02-03 12:39:48 +01:00
|
|
|
|
$sql = "SELECT rowid FROM llx_adherent WHERE login='$login' LIMIT 1";
|
2003-01-29 18:36:37 +01:00
|
|
|
|
if ( $this->db->query( $sql) ){
|
|
|
|
|
|
if ($this->db->num_rows()){
|
|
|
|
|
|
$obj = $this->db->fetch_object(0);
|
2003-02-03 12:39:48 +01:00
|
|
|
|
$this->fetch($obj->rowid);
|
2003-01-29 18:36:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* Fetch adherent corresponding to rowid passed in argument */
|
2002-12-30 16:13:28 +01:00
|
|
|
|
Function fetch($rowid)
|
|
|
|
|
|
{
|
2003-01-22 18:51:49 +01:00
|
|
|
|
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.pays, d.note, d.email, d.login, d.pass, d.naiss, d.photo, d.fk_adherent_type, d.morphy, t.libelle as type";
|
2002-12-30 16:13:28 +01:00
|
|
|
|
$sql .= ",".$this->db->pdate("d.datefin")." as datefin";
|
2002-12-30 17:20:38 +01:00
|
|
|
|
$sql .= " FROM llx_adherent as d, llx_adherent_type as t";
|
|
|
|
|
|
$sql .= " WHERE d.rowid = $rowid AND d.fk_adherent_type = t.rowid";
|
2002-12-30 16:13:28 +01:00
|
|
|
|
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->db->num_rows())
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$obj = $this->db->fetch_object(0);
|
|
|
|
|
|
|
|
|
|
|
|
$this->id = $obj->rowid;
|
|
|
|
|
|
$this->typeid = $obj->fk_adherent_type;
|
2002-12-30 17:20:38 +01:00
|
|
|
|
$this->type = $obj->type;
|
|
|
|
|
|
$this->statut = $obj->statut;
|
2003-01-22 18:51:49 +01:00
|
|
|
|
$this->public = $obj->public;
|
2002-12-30 16:13:28 +01:00
|
|
|
|
$this->date = $obj->datedon;
|
|
|
|
|
|
$this->prenom = stripslashes($obj->prenom);
|
|
|
|
|
|
$this->nom = stripslashes($obj->nom);
|
|
|
|
|
|
$this->societe = stripslashes($obj->societe);
|
|
|
|
|
|
$this->adresse = stripslashes($obj->adresse);
|
|
|
|
|
|
$this->cp = stripslashes($obj->cp);
|
|
|
|
|
|
$this->ville = stripslashes($obj->ville);
|
|
|
|
|
|
$this->email = stripslashes($obj->email);
|
2003-01-13 18:01:30 +01:00
|
|
|
|
$this->login = stripslashes($obj->login);
|
|
|
|
|
|
$this->pass = stripslashes($obj->pass);
|
2003-01-22 18:51:49 +01:00
|
|
|
|
$this->naiss = stripslashes($obj->naiss);
|
|
|
|
|
|
$this->photo = stripslashes($obj->photo);
|
2002-12-30 16:13:28 +01:00
|
|
|
|
$this->pays = stripslashes($obj->pays);
|
|
|
|
|
|
$this->datefin = $obj->datefin;
|
|
|
|
|
|
$this->commentaire = stripslashes($obj->note);
|
2002-12-30 17:04:55 +01:00
|
|
|
|
$this->morphy = $obj->morphy;
|
2002-12-30 16:13:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2003-02-10 18:36:55 +01:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* fetch optional attribute
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function fetch_optionals($rowid)
|
|
|
|
|
|
{
|
|
|
|
|
|
$tab=array();
|
|
|
|
|
|
$sql = "SELECT *";
|
|
|
|
|
|
$sql .= " FROM llx_adherent_options";
|
|
|
|
|
|
$sql .= " WHERE adhid=$rowid";
|
|
|
|
|
|
|
|
|
|
|
|
if ( $this->db->query( $sql) ){
|
|
|
|
|
|
if ($this->db->num_rows()){
|
|
|
|
|
|
|
|
|
|
|
|
//$obj = $this->db->fetch_object(0);
|
|
|
|
|
|
$tab = $this->db->fetch_array();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($tab as $key => $value){
|
|
|
|
|
|
if ($key != 'optid' && $key != 'tms' && $key != 'adhid'){
|
|
|
|
|
|
// we can add this attribute to adherent object
|
|
|
|
|
|
$this->array_options["options_$key"]=$value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
|
2003-02-10 18:36:55 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* fetch optional attribute name
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function fetch_name_optionals()
|
|
|
|
|
|
{
|
|
|
|
|
|
$array_name_options=array();
|
|
|
|
|
|
$sql = "SHOW COLUMNS FROM llx_adherent_options";
|
2002-12-30 16:13:28 +01:00
|
|
|
|
|
2003-02-10 18:36:55 +01:00
|
|
|
|
if ( $this->db->query( $sql) ){
|
|
|
|
|
|
if ($this->db->num_rows()){
|
|
|
|
|
|
//$tab = $this->db->fetch_object();
|
|
|
|
|
|
//$array_name_options[]=$tab->Field;
|
|
|
|
|
|
while ($tab = $this->db->fetch_object()){
|
|
|
|
|
|
if ($tab->Field != 'optid' && $tab->Field != 'tms' && $tab->Field != 'adhid'){
|
|
|
|
|
|
// we can add this attribute to adherent object
|
|
|
|
|
|
$array_name_options[]=$tab->Field;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $array_name_options;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return array();
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
return array() ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Cotisation
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function cotisation($date, $montant)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO llx_cotisation (fk_adherent, dateadh, cotisation)";
|
|
|
|
|
|
$sql .= " VALUES ($this->id, ".$this->db->idate($date).", $montant)";
|
|
|
|
|
|
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( $this->db->affected_rows() )
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$datefin = mktime(12, 0 , 0,
|
|
|
|
|
|
strftime("%m",$date),
|
|
|
|
|
|
strftime("%d",$date),
|
|
|
|
|
|
strftime("%Y",$date)+1) - (24 * 3600);
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE llx_adherent SET datefin = ".$this->db->idate($datefin)." WHERE rowid =". $this->id;
|
|
|
|
|
|
|
|
|
|
|
|
if ( $this->db->query( $sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "Err : ".$this->db->error();
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-12-30 17:29:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Validation
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function validate($userid)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE llx_adherent SET ";
|
|
|
|
|
|
$sql .= "statut=1";
|
|
|
|
|
|
$sql .= ",fk_user_valid=".$userid;
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " WHERE rowid = $this->id";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<h2><br>$sql<br></h2>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2002-12-30 22:07:11 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* R<EFBFBD>siliation
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
Function resiliate($userid)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "UPDATE llx_adherent SET ";
|
|
|
|
|
|
$sql .= "statut=0";
|
|
|
|
|
|
$sql .= ",fk_user_valid=".$userid;
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " WHERE rowid = $this->id";
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $this->db->error();
|
|
|
|
|
|
print "<h2><br>$sql<br></h2>";
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2002-12-30 17:29:21 +01:00
|
|
|
|
|
2003-03-03 18:39:23 +01:00
|
|
|
|
/*
|
2003-03-05 18:22:02 +01:00
|
|
|
|
* Ajoute le user aux differents abonneents automatiques
|
|
|
|
|
|
* (mailing-list, spip, glasnost etc etc ..)
|
2003-03-03 18:39:23 +01:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
2003-03-07 19:53:17 +01:00
|
|
|
|
Function add_to_abo($adht)
|
2003-03-03 18:39:23 +01:00
|
|
|
|
{
|
2003-03-05 18:22:02 +01:00
|
|
|
|
$err=0;
|
|
|
|
|
|
// mailman
|
|
|
|
|
|
if (defined("MAIN_USE_MAILMAN") && MAIN_USE_MAILMAN == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!$this->add_to_mailman()){
|
|
|
|
|
|
$err+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-07 19:53:17 +01:00
|
|
|
|
if ($adht->vote == 'yes' &&
|
|
|
|
|
|
defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 &&
|
|
|
|
|
|
defined("MAIN_USE_GLASNOST_AUTO") && MAIN_USE_GLASNOST_AUTO ==1
|
|
|
|
|
|
)
|
2003-03-06 20:33:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
if(!$this->add_to_glasnost()){
|
|
|
|
|
|
$err+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-07 19:53:17 +01:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-05 18:22:02 +01:00
|
|
|
|
if ($err>0){
|
|
|
|
|
|
// error
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* supprime le user des differents abonnements automatiques
|
|
|
|
|
|
* (mailing-list, spip, glasnost etc etc ..)
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2003-03-07 19:53:17 +01:00
|
|
|
|
Function del_to_abo($adht)
|
2003-03-05 18:22:02 +01:00
|
|
|
|
{
|
|
|
|
|
|
$err=0;
|
|
|
|
|
|
// mailman
|
|
|
|
|
|
if (defined("MAIN_USE_MAILMAN") && MAIN_USE_MAILMAN == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!$this->del_to_mailman()){
|
|
|
|
|
|
$err+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-07 19:53:17 +01:00
|
|
|
|
if ($adht->vote == 'yes' &&
|
|
|
|
|
|
defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 &&
|
|
|
|
|
|
defined("MAIN_USE_GLASNOST_AUTO") && MAIN_USE_GLASNOST_AUTO ==1
|
|
|
|
|
|
)
|
2003-03-06 20:33:23 +01:00
|
|
|
|
{
|
|
|
|
|
|
if(!$this->del_to_glasnost()){
|
|
|
|
|
|
$err+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-07 19:53:17 +01:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-05 18:22:02 +01:00
|
|
|
|
if ($err>0){
|
|
|
|
|
|
// error
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
2003-03-03 18:39:23 +01:00
|
|
|
|
}
|
2002-12-30 17:29:21 +01:00
|
|
|
|
|
2003-03-07 19:53:17 +01:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
* 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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-06 20:33:23 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* 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{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr=$response['faultString'];
|
2003-03-06 20:33:23 +01:00
|
|
|
|
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{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr=$response['faultString'];
|
2003-03-06 20:33:23 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}else{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr="Constantes de connection non definies";
|
2003-03-06 20:33:23 +01:00
|
|
|
|
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{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr=$response['faultString'];
|
2003-03-06 20:33:23 +01:00
|
|
|
|
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{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr=$response['faultString'];
|
2003-03-06 20:33:23 +01:00
|
|
|
|
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{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr=$response['faultString'];
|
2003-03-06 20:33:23 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr="Constantes de connection non definies";
|
2003-03-06 20:33:23 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-03 18:39:23 +01:00
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2003-03-05 18:22:02 +01:00
|
|
|
|
Function add_to_mailman()
|
2003-03-03 18:39:23 +01:00
|
|
|
|
{
|
2003-03-05 18:22:02 +01:00
|
|
|
|
if (defined("MAIN_MAILMAN_URL") && MAIN_MAILMAN_URL != '' && defined("MAIN_MAILMAN_LISTS") && MAIN_MAILMAN_LISTS != '')
|
|
|
|
|
|
{
|
|
|
|
|
|
$lists=explode(',',MAIN_MAILMAN_LISTS);
|
|
|
|
|
|
foreach ($lists as $list)
|
|
|
|
|
|
{
|
|
|
|
|
|
// on remplace dans l'url le nom de la liste ainsi
|
|
|
|
|
|
// que l'email et le mot de passe
|
|
|
|
|
|
$patterns = array (
|
|
|
|
|
|
'/%LISTE%/',
|
|
|
|
|
|
'/%EMAIL%/',
|
|
|
|
|
|
'/%PASS%/'
|
|
|
|
|
|
);
|
|
|
|
|
|
$replace = array (
|
|
|
|
|
|
$list,
|
|
|
|
|
|
$this->email,
|
|
|
|
|
|
$this->pass
|
|
|
|
|
|
);
|
|
|
|
|
|
$curl_url = preg_replace ($patterns, $replace, MAIN_MAILMAN_URL);
|
|
|
|
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL,"$curl_url");
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/");
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_POST, 0);
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
|
|
|
|
|
|
//--- Start buffering
|
|
|
|
|
|
//ob_start();
|
|
|
|
|
|
$result=curl_exec ($ch);
|
|
|
|
|
|
logfile($result);
|
|
|
|
|
|
//--- End buffering and clean output
|
|
|
|
|
|
//ob_end_clean();
|
|
|
|
|
|
if (curl_error($ch) > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// error
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
curl_close ($ch);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}else{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr="Constantes de connection non definies";
|
2003-03-05 18:22:02 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2003-03-03 18:39:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-05 18:22:02 +01:00
|
|
|
|
Function del_to_mailman()
|
2003-03-03 18:39:23 +01:00
|
|
|
|
{
|
2003-03-05 18:22:02 +01:00
|
|
|
|
if (defined("MAIN_MAILMAN_UNSUB_URL") && MAIN_MAILMAN_UNSUB_URL != '' && defined("MAIN_MAILMAN_LISTS") && MAIN_MAILMAN_LISTS != '')
|
|
|
|
|
|
{
|
|
|
|
|
|
$lists=explode(',',MAIN_MAILMAN_LISTS);
|
|
|
|
|
|
foreach ($lists as $list)
|
|
|
|
|
|
{
|
|
|
|
|
|
// on remplace dans l'url le nom de la liste ainsi
|
|
|
|
|
|
// que l'email et le mot de passe
|
|
|
|
|
|
$patterns = array (
|
|
|
|
|
|
'/%LISTE%/',
|
|
|
|
|
|
'/%EMAIL%/',
|
|
|
|
|
|
'/%PASS%/'
|
|
|
|
|
|
);
|
|
|
|
|
|
$replace = array (
|
|
|
|
|
|
$list,
|
|
|
|
|
|
$this->email,
|
|
|
|
|
|
$this->pass
|
|
|
|
|
|
);
|
|
|
|
|
|
$curl_url = preg_replace ($patterns, $replace, MAIN_MAILMAN_UNSUB_URL);
|
|
|
|
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL,"$curl_url");
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/");
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_POST, 0);
|
|
|
|
|
|
//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
|
|
|
|
|
|
//--- Start buffering
|
|
|
|
|
|
//ob_start();
|
|
|
|
|
|
$result=curl_exec ($ch);
|
|
|
|
|
|
logfile($result);
|
|
|
|
|
|
//--- End buffering and clean output
|
|
|
|
|
|
//ob_end_clean();
|
|
|
|
|
|
if (curl_error($ch) > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// error
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
curl_close ($ch);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}else{
|
2003-03-07 19:53:17 +01:00
|
|
|
|
$this->errorstr="Constantes de connection non definies";
|
2003-03-05 18:22:02 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2003-03-03 18:39:23 +01:00
|
|
|
|
}
|
2002-12-30 16:13:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
?>
|