Commit 8d09d384 authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

Improve unsubscription

parent 3e58d01e
......@@ -313,22 +313,24 @@ class Mailjobs
{
$db =& Db::globaldb();
$row = array();
$sqlstr = "SELECT mr.id_mail,mj.track,mj.track_redirect,mr.id_p,mr.email,mj.id_topic
$sqlstr = "SELECT mr.id_mail,mj.track,mj.track_redirect,mr.id_p,mr.email,mj.id_topic,mr.status
FROM mailjob_recipients mr
INNER JOIN sendmail mj ON mr.id_mail=mj.id_mail WHERE mr.identifier='$identifier' ";
$db->query_single($row, $sqlstr);
$db->begin();
$db->lock( "mailjob_recipients" );
$res[] = $db->query( "UPDATE mailjob_recipients SET status=3 WHERE identifier='$identifier' " );
Db::finish( $res, $db);
$status = (int)$row['status'];
if($status!=3) {
$db->begin();
$db->lock( "mailjob_recipients" );
$res[] = $db->query( "UPDATE mailjob_recipients SET status=3 WHERE identifier='$identifier' " );
Db::finish( $res, $db);
}
$id_mail = (int)$row['id_mail'];
$id_p = (int)$row['id_p'];
$row['return'] = false;
if($id_mail>0 && $id_p>0)
{
$job = $this->MailJobGet($id_mail);
$row['return'] = true;
$row['return'] = $status!=3;
include_once(SERVER_ROOT."/../classes/people.php");
$pe = new People();
switch($job['id_module'])
......
......@@ -67,6 +67,8 @@ download_orig = Download
email = email
email_one = email (just one)
email_unsubscribe = Email %s has been unsubscribed. Many thanks
email_unsubscribe_already = Email %s already unsubscribed
email_unsubscribe_failed = Email not found, please contact %s
error = Error
error404_msg = Error 404 - Page not found
error_captcha = Invalid captcha
......
......@@ -67,6 +67,8 @@ download_orig = Scarica originale
email = email
email_one = email (solo una)
email_unsubscribe = L'email %s è stata rimossa
email_unsubscribe_already = L'email %s è già stata rimossa
email_unsubscribe_failed = Email non trovata, si prega di contattare %s
error = Errore
error404_msg = Errore 404 - Pagina non trovata
error_captcha = Captcha non valido
......
......@@ -45,18 +45,24 @@ if(isset($get['mjt']))
$mj = new Mailjobs();
$return = $mj->RecipientUnsubscribe($identifier);
$id_topic = (int)$return['id_topic'];
if($return['id_mail']!="" && $return['return'])
{
$fh->va->MessageSet("notice","email_unsubscribe",array($return['email']));
$l = new Layout();
if($return['id_mail']!="") {
if($return['return']) {
$fh->va->MessageSet("notice","email_unsubscribe",array($return['email']));
} else {
$fh->va->MessageSet("error","email_unsubscribe_already",array($return['email']));
}
} else {
$fh->va->MessageSet("error","email_unsubscribe_failed",array($l->ini->Get('staff_email')));
}
$l = new Layout;
$params = array('subtype'=>'unsub');
if($id_topic>0)
{
echo $l->Output("topic_home",$id_topic,$id_topic,1,array());
echo $l->Output("topic_home",$id_topic,$id_topic,1,$params);
}
else
{
echo $l->Output("homepage",0,0,1,array(),true);
echo $l->Output("homepage",0,0,1,$params,true);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment