mirror of
https://github.com/e107inc/e107.git
synced 2025-01-16 20:28:28 +01:00
Allow user to unsubscribe from userclasses (newsletter/email notifications etc.) via an email link.
This commit is contained in:
parent
a708211cb3
commit
d4f38c96ed
@ -35,14 +35,14 @@ Allows admins to send mail to those subscribed to one or more newsletters
|
||||
|
||||
class user_mailout
|
||||
{
|
||||
protected $mailCount = 0;
|
||||
protected $mailRead = 0;
|
||||
// protected $mailCount = 0;
|
||||
// protected $mailRead = 0;
|
||||
//public $mailerSource = 'newsletter'; // Plugin name (core mailer is special case) Must be directory for this file
|
||||
public $mailerName = LAN_PLUGIN_NEWSLETTER_NAME; // Text to identify the source of selector (displayed on left of admin page)
|
||||
public $mailerEnabled = TRUE; // Mandatory - set to FALSE to disable this plugin (e.g. due to permissions restrictions)
|
||||
private $selectorActive = FALSE; // Set TRUE if we've got a valid selector to start returning entries
|
||||
private $targets = array(); // Used to store potential recipients
|
||||
private $ourDB;
|
||||
// private $selectorActive = FALSE; // Set TRUE if we've got a valid selector to start returning entries
|
||||
// private $targets = array(); // Used to store potential recipients
|
||||
// private $ourDB;
|
||||
|
||||
|
||||
// Constructor
|
||||
@ -71,20 +71,20 @@ class user_mailout
|
||||
{
|
||||
if($mode == 'check') // check that a matching email,id,creation-date exists.
|
||||
{
|
||||
return e107::getDb()->select('user','*', 'user_class!="" AND user_id='.intval($data['id'])." AND user_join=".intval($data['date'])." AND user_email=\"".$data['email']."\"", true);
|
||||
$ucl = intval($data['userclass']);
|
||||
|
||||
return e107::getDb()->select('user','*', 'FIND_IN_SET('.$ucl.',user_class) AND user_id='.intval($data['id'])." AND user_join=".intval($data['date'])." AND user_email=\"".$data['email']."\"");
|
||||
}
|
||||
|
||||
print_a($data);
|
||||
// print_a($data);
|
||||
|
||||
if($mode == 'process') // Update record. Return true on success, and false on error.
|
||||
{
|
||||
$update = array(
|
||||
'cust_subscribed' => 0,
|
||||
'cust_unsubscribed' => time(),
|
||||
'WHERE' => "user_id=".intval($data['id'])." AND cust_datestamp=".intval($data['date'])." AND cust_email=\"".$data['email']."\""
|
||||
);
|
||||
$uid = intval($data['id']);
|
||||
$ucl = intval($data['userclass']);
|
||||
|
||||
return e107::getSystemUser($uid)->removeClass($ucl); // best way to remove userclass from user.
|
||||
|
||||
// return e107::getDb()->update('user',$update);
|
||||
}
|
||||
|
||||
}
|
||||
|
80
signup.php
80
signup.php
@ -832,92 +832,12 @@ function render_email($userInfo, $preview = FALSE)
|
||||
$userInfo['user_website'] = "www.test-site.com"; // This may not be defined
|
||||
$userInfo['user_id'] = 0;
|
||||
$userInfo['user_sess'] = "1234567890ABCDEFGHIJKLMNOP";
|
||||
$userInfo['user_email'] = 'cameron@teslapower.solar';
|
||||
$userInfo['activation_url'] = 'http://whereever.to.activate.com/';
|
||||
}
|
||||
|
||||
return e107::getSystemUser($userInfo['user_id'], false)->renderEmail('signup', $userInfo);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
global $pref,$SIGNUPEMAIL_LINKSTYLE,$SIGNUPEMAIL_SUBJECT,$SIGNUPEMAIL_TEMPLATE;
|
||||
*
|
||||
define('RETURNADDRESS', (substr(SITEURL, -1) == "/" ? SITEURL."signup.php?activate.".$userInfo['user_id'].".".$userInfo['user_sess'] : SITEURL."/signup.php?activate.".$userInfo['user_id'].".".$userInfo['user_sess'].".".e_LAN));
|
||||
$pass_show = ($pref['user_reg_secureveri'])? '*******' : $userInfo['user_password'];
|
||||
|
||||
if (file_exists(THEME.'email_template.php'))
|
||||
{
|
||||
require_once(THEME.'email_template.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(e_CORE.'templates/email_template.php');
|
||||
}
|
||||
|
||||
$ret['mail_recipient_id'] = $userInfo['user_id'];
|
||||
if (vartrue($SIGNUPEMAIL_CC)) { $ret['mail_copy_to'] = $SIGNUPEMAIL_CC; }
|
||||
if (vartrue($SIGNUPEMAIL_BCC)) { $ret['mail_bcopy_to'] = $SIGNUPEMAIL_BCC; }
|
||||
if (vartrue($SIGNUPEMAIL_ATTACHMENTS)) { $ret['mail_attach'] = $SIGNUPEMAIL_ATTACHMENTS; }
|
||||
|
||||
$style = ($SIGNUPEMAIL_LINKSTYLE) ? "style='{$SIGNUPEMAIL_LINKSTYLE}'" : "";
|
||||
|
||||
$search[0] = '{LOGINNAME}';
|
||||
$replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email'];
|
||||
|
||||
$search[1] = '{PASSWORD}';
|
||||
$replace[1] = $pass_show;
|
||||
|
||||
$search[2] = '{ACTIVATION_LINK}';
|
||||
$replace[2] = "<a href='".RETURNADDRESS."' {$style}>".RETURNADDRESS."</a>";
|
||||
|
||||
$search[3] = '{SITENAME}';
|
||||
$replace[3] = SITENAME;
|
||||
|
||||
$search[4] = '{SITEURL}';
|
||||
$replace[4] = "<a href='".SITEURL."' {$style}>".SITEURL."</a>";
|
||||
|
||||
$search[5] = '{USERNAME}';
|
||||
$replace[5] = $userInfo['user_name'];
|
||||
|
||||
$search[6] = '{USERURL}';
|
||||
$replace[6] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : "";
|
||||
|
||||
|
||||
|
||||
$subject = str_replace($search,$replace,$SIGNUPEMAIL_SUBJECT);
|
||||
$ret['mail_subject'] = $subject;
|
||||
$ret['send_html'] = TRUE;
|
||||
|
||||
$HEAD = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
|
||||
$HEAD .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n";
|
||||
$HEAD .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
|
||||
$HEAD .= ($SIGNUPEMAIL_USETHEME == 1) ? "<link rel=\"stylesheet\" href=\"".SITEURL.THEME."style.css\" type=\"text/css\" />\n" : "";
|
||||
$HEAD .= ($preview) ? "<title>".LAN_SIGNUP_58."</title>\n" : "";
|
||||
if($SIGNUPEMAIL_USETHEME == 2)
|
||||
{
|
||||
$CSS = file_get_contents(THEME."style.css");
|
||||
$HEAD .= "<style>\n".$CSS."\n</style>";
|
||||
}
|
||||
|
||||
$HEAD .= "</head>\n";
|
||||
if(vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE))
|
||||
{
|
||||
$HEAD .= "<body background=\"".$SIGNUPEMAIL_BACKGROUNDIMAGE."\" >\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$HEAD .= "<body>\n";
|
||||
}
|
||||
$FOOT = "\n</body>\n</html>\n";
|
||||
|
||||
$ret['mail_body'] = str_replace($search,$replace,$HEAD.$SIGNUPEMAIL_TEMPLATE.$FOOT);
|
||||
$ret['preview'] = $ret['mail_body']; // Non-standard field
|
||||
|
||||
return $ret;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,20 +15,26 @@ class unsubscribe
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$frm = e107::getForm();
|
||||
$tp = e107::getParser();
|
||||
|
||||
// $this->simulation();
|
||||
|
||||
$mailoutPlugins = e107::getConfig()->get('e_mailout_list');
|
||||
|
||||
if(!vartrue($_GET['id']))
|
||||
if(empty($_GET['id']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$tmp = base64_decode($_GET['id']);
|
||||
|
||||
|
||||
parse_str($tmp,$data);
|
||||
|
||||
|
||||
$data['plugin'] = $tp->filter($data['plugin'],'str');
|
||||
$data['email'] = $tp->filter($data['email'],'email');
|
||||
|
||||
|
||||
|
||||
e107::getMessage()->addDebug(print_a($data,true));
|
||||
|
||||
$plugin = vartrue($data['plugin'],false);
|
||||
@ -40,28 +46,39 @@ class unsubscribe
|
||||
return;
|
||||
}
|
||||
|
||||
$ml = e107::getAddon($plugin,'e_mailout');
|
||||
|
||||
$ml = e107::getAddon($plugin, 'e_mailout');
|
||||
|
||||
if(!empty($data['userclass'])) // userclass unsubscribe.
|
||||
{
|
||||
$data['userclass'] = intval($data['userclass']);
|
||||
$listName = e107::getUserClass()->getName($data['userclass']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$listName = $ml->mailerName;
|
||||
}
|
||||
|
||||
if(vartrue($_POST['remove']) && !empty($data))
|
||||
{
|
||||
if($ml->unsubscribe('process',$data)!=false)
|
||||
{
|
||||
$text = "<p><b>".$data['email']."</b> has been removed from ".$ml->mailerName.".</p>";
|
||||
$text = "<p><b>".$data['email']."</b> has been removed from ".$listName.".</p>";
|
||||
$mes->addSuccess($text);
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = "<p>There was a problem when attempting to remove <b>".$data['email']."</b> from ".$ml->mailerName.".</p>";
|
||||
$text = "<p>There was a problem when attempting to remove <b>".$data['email']."</b> from ".$listName.".</p>";
|
||||
$mes->addError($text);
|
||||
}
|
||||
|
||||
echo "<div class='container'>".$mes->render()."</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($ml->unsubscribe('check',$data) != false)
|
||||
{
|
||||
$text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>".$data['email']."</b> from the ".$ml->mailerName.".</p>";
|
||||
$text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>".$data['email']."</b> from <i>".$listName."</i>.</p>";
|
||||
$text .= $frm->open('unsub','post',e_REQUEST_URI);
|
||||
$text .= $frm->button('remove','Remove ','submit');
|
||||
$text .= $frm->close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user