Bizarrement il manquait 1 peu de code dans le plugin
J'ai modifie 1 peu mais n'ai pas teste l'envoi de mail et l'activation, mais ce devrait etre bon, enfin j'espere
Activation.class.php
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) Octolys Development */
/* email : thelia@octolys.fr */
/* web : http://www.octolys.fr */
/* */
/* 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 */
/* */
/*************************************************************************************/
?>
<?php
include_once(realpath(dirname(__FILE__))."/../../../classes/PluginsClassiques.class.php");
include_once(realpath(dirname(__FILE__))."/../../../classes/Client.class.php");
include_once(realpath(dirname(__FILE__))."/../../../fonctions/divers.php");
include_once(realpath(dirname(__FILE__))."/../../../classes/Message.class.php");
include_once(realpath(dirname(__FILE__))."/../../../classes/Messagedesc.class.php");
include_once(realpath(dirname(__FILE__))."/../../../classes/Variable.class.php");
include_once(realpath(dirname(__FILE__))."/../../../lib/phpMailer/class.phpmailer.php");
class Activation extends PluginsClassiques{
var $id;
var $ref;
var $raison;
var $entreprise;
var $siret;
var $nom;
var $prenom;
var $telfixe;
var $telport;
var $email;
var $motdepasse;
var $adresse1;
var $adresse2;
var $adresse3;
var $cpostal;
var $ville;
var $pays;
var $parrain;
var $type;
var $pourcentage;
var $token;
var $table="attente";
var $bddvars = array("id", "ref", "raison", "entreprise", "siret", "nom", "prenom", "telfixe", "telport", "email", "motdepasse", "adresse1", "adresse2", "adresse3", "cpostal", "ville", "pays", "parrain", "type", "pourcentage","token");
function Activation(){
$this->PluginsClassiques();
}
function init(){
$query=mysql_query("CREATE TABLE `attente` (
`id` int(11) NOT NULL auto_increment,
`ref` text NOT NULL,
`raison` smallint(6) NOT NULL default '0',
`entreprise` text NOT NULL,
`siret` text NOT NULL,
`nom` text NOT NULL,
`prenom` text NOT NULL,
`adresse1` varchar(40) NOT NULL default '',
`adresse2` varchar(40) NOT NULL default '',
`adresse3` varchar(40) NOT NULL default '',
`cpostal` varchar(10) NOT NULL default '',
`ville` varchar(30) NOT NULL default '',
`pays` mediumint(9) NOT NULL default '0',
`telfixe` text NOT NULL,
`telport` text NOT NULL,
`email` text NOT NULL,
`motdepasse` text NOT NULL,
`parrain` int(11) NOT NULL default '0',
`type` smallint(6) NOT NULL default '0',
`pourcentage` int(11) NOT NULL default '0',
`token` text NOT NULL,
PRIMARY KEY (`id`)
)");
$message = new Message();
if($message->charger("mailactivation")) return;
$message->nom = "mailactivation";
$lastid = $message->add();
$messagedesc = new Messagedesc();
$messagedesc->message = $lastid;
$messagedesc->lang = 1;
$messagedesc->titre = "Activation";
$messagedesc->chapo = "";
$messagedesc->description = "Bonjour __RAISON__ __NOM__,\n Pour activer votre compte veuillez cliquer sur le lien suivant __ADRESSE__ \nMerci";
$messagedesc->add();
}
function charger($id){
return $this->getVars("select * from $this->table where id=$id");
}
function charger_mail($email){
return $this->getVars("select * from $this->table where email=\"$email\"");
}
function action(){
global $action;
if($action == "activation"){
$this->charger($_REQUEST["id"]);
$client = $this->inverse();
if($_REQUEST["token"] == $this->token){
$client->add();
$tclient = new Client();
$tclient->charger_mail($client->email);
$this->delete();
$_SESSION["navig"]->client = $tclient;
$_SESSION["navig"]->connecte=1;
redirige("?fond=confirmation");//rediriection sur une page annonçant que le client a bien active son compte
}
}
}
function apresclient(){
$client = new Client();
$client->charger_mail($_SESSION["navig"]->client->email);
$this->correspondance($client);
$this->token = gencode(30);
$enr = $this->add();
$this->charger_mail($this->email);
$client->delete();
//Envoi du mail pour activation du client
$message = new Message();
$message->charger("mailactivation");
$messagedesc = new Messagedesc();
$messagedesc->charger($message->id);
$body = $messagedesc->description;
$urlsite = new Variable();
$urlsite->charger("urlsite");
$emailcontact = new Variable();
$emailcontact->charger("emailcontact");
$adresse = $urlsite->valeur."/?fond=confirmation?action=activation&id=".$this->id."&token=".$this->token;
switch($this->raison){
case 1: $civi="Madame";
break;
case 2: $civi="Mademoiselle";
break;
case 3: $civi="Monsieur";
break;
default: $civi="";
break;
}
$body = str_replace("__ADRESSE__",$adresse,$body);
$body = str_replace("__RAISON__",$civi,$body);
$body = str_replace("__NOM__",$this->prenom,$body);
mail($this->email,"confirmation inscription",$body,"From: ".$urlsite->valeur." <".$emailcontact->valeur.">\r\n");
$_SESSION['navig']->client = new Client();
$_SESSION['navig']->connecte = 0;
redirige("?fond=nouveau");//redirection sur une page annonçant qu'1 email vient d'etre envoye pour activation
}
function correspondance($client){
$this->ref = $client->ref;
$this->raison = $client->raison;
$this->entreprise = $client->entreprise;
$this->siret = $client->siret;
$this->nom = $client->nom;
$this->prenom = $client->prenom;
$this->adresse1 = $client->adresse1;
$this->adresse2 = $client->adresse2;
$this->adresse3 = $client->adresse3;
$this->cpostal = $client->cpostal;
$this->ville = $client->ville;
$this->pays = $client->pays;
$this->telfixe = $client->telfixe;
$this->telport = $client->telport;
$this->email = $client->email;
$this->motdepasse = $client->motdepasse;
$this->parrain=$client->parrain;
$this->type = $client->type;
$this->pourcentage = $client->pourcentage;
}
function inverse(){
$client = new Client();
$client->ref = $this->ref;
$client->raison = $this->raison;
$client->entreprise = $this->entreprise;
$client->siret = $this->siret;
$client->nom = $this->nom;
$client->prenom = $this->prenom;
$client->adresse1 = $this->adresse1;
$client->adresse2 = $this->adresse2;
$client->adresse3 = $this->adresse3;
$client->cpostal = $this->cpostal;
$client->ville = $this->ville;
$client->pays = $this->pays;
$client->telfixe = $this->telfixe;
$client->telport = $this->telport;
$client->email = $this->email;
$client->motdepasse = $this->motdepasse;
$client->parrain=$this->parrain;
$client->type = $this->type;
$client->pourcentage = $this->pourcentage;
return $client;
}
}
?>
Il faut creer 2 pages:
nouveau.html <=annonçant qu'1 email vient d'etre envoye pour activation
confirmation.html <=page annonçant que le client a bien active son compte