diff --git a/e107_plugins/user/e_mailout.php b/e107_plugins/user/e_mailout.php index 6a650472c..5d4439e08 100644 --- a/e107_plugins/user/e_mailout.php +++ b/e107_plugins/user/e_mailout.php @@ -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); } } diff --git a/signup.php b/signup.php index 398b3330b..3bfdf71de 100644 --- a/signup.php +++ b/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] = "".RETURNADDRESS.""; - - $search[3] = '{SITENAME}'; - $replace[3] = SITENAME; - - $search[4] = '{SITEURL}'; - $replace[4] = "".SITEURL.""; - - $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 = "\n"; - $HEAD .= "\n"; - $HEAD .= "\n"; - $HEAD .= ($SIGNUPEMAIL_USETHEME == 1) ? "\n" : ""; - $HEAD .= ($preview) ? "".LAN_SIGNUP_58."\n" : ""; - if($SIGNUPEMAIL_USETHEME == 2) - { - $CSS = file_get_contents(THEME."style.css"); - $HEAD .= ""; - } - - $HEAD .= "\n"; - if(vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE)) - { - $HEAD .= "\n"; - } - else - { - $HEAD .= "\n"; - } - $FOOT = "\n\n\n"; - - $ret['mail_body'] = str_replace($search,$replace,$HEAD.$SIGNUPEMAIL_TEMPLATE.$FOOT); - $ret['preview'] = $ret['mail_body']; // Non-standard field - - return $ret; - - */ } diff --git a/unsubscribe.php b/unsubscribe.php index 0e8ef1715..47fae9a2c 100644 --- a/unsubscribe.php +++ b/unsubscribe.php @@ -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 = "

".$data['email']." has been removed from ".$ml->mailerName.".

"; + $text = "

".$data['email']." has been removed from ".$listName.".

"; $mes->addSuccess($text); } else { - $text = "

There was a problem when attempting to remove ".$data['email']." from ".$ml->mailerName.".

"; + $text = "

There was a problem when attempting to remove ".$data['email']." from ".$listName.".

"; $mes->addError($text); } echo "
".$mes->render()."
"; return; } - + + if($ml->unsubscribe('check',$data) != false) { - $text = "

We are very sorry for the inconvenience.
Please click the button below to remove ".$data['email']." from the ".$ml->mailerName.".

"; + $text = "

We are very sorry for the inconvenience.
Please click the button below to remove ".$data['email']." from ".$listName.".

"; $text .= $frm->open('unsub','post',e_REQUEST_URI); $text .= $frm->button('remove','Remove ','submit'); $text .= $frm->close();