Hi,
I ran into some issues that I resolved (patch supplied). I don't know if all these apply to all or just me but I'll present each point in my patch and you can judge for yourself.
This all applied to 4.6.x (I checked out a fresh copy from CVS for this, 1.3.2.1). Obviously, these comments/patches are not for 4.7 branch.
Also, the patch was made against the contributions/modules/emailpage/emailpage.module as checked out from cvs.
Hope this is of use to anyone.
--AjK
1st. I use "clean urls" and the links at the base of each node just didn't work for me. On closer inspection I found that the links needed a query operator rather than the concat. Eg, a link thus
emailpage&nid=$node->nid
becomes
emailpage?nid=$node->nid
in my patch.
2nd. I didn't really waant the email to come "from" a single admin defined address. I so I added in support for usering the registered users email address.
function emailpage_page() {
global $base_url;
becomes
function emailpage_page() {
global $user;
global $base_url;
then
$headers="Reply-To: ".variable_get('emailpage_ .......
becomes
$from_addr = variable_get('emailpage_sender_addy', "");
if(strlen($from_addr) > 0) {
$headers="Reply-To: ".variable_get('emailpage_ .......
}
else {
$headers = "Reply-To: ".$user->mail."\r\nFrom: ".$user->mail."\r\n";
}
then
mail($_POST['edit']['emailpage_addy'], $_POST['edit']['emailpage_sender']." ".variable_get('emailpage_subjec
t_line', "thought you'd like to see this"), $_COOKIE['referer']."\n\n".$_POST['edit']['emailpage_sender']." ".wordwr
ap(variable_get('emailpage_message',"someone thought you would like this page\n"), 72), $headers);
becomes
mail($_POST['edit']['emailpage_addy'],
$_POST['edit']['emailpage_sender']." ".variable_get('emailpage_subject_line', "thought you'd like to seet
his"),
$_COOKIE['referer']."\n\n".$_POST['edit']['emailpage_sender'].wordwrap(variable_get('emailpage_message',"
someone thought you would like this page\n").$user->name, 72),
$headers,
"-f" . $user->mail);
3rd. I wasn't really happy that after sending the email the user is thrown back to the home page.
So, I added in "going back" with a user message saying the email was sent
if($_GET['cid']) { // this takes care of links to specific comments
//$nodelink=$base_url.'/'.url('node/view/'.$_GET['nid']."#comment-".$_GET['cid']);
$nodelink=$base_url.'/'.url('node/'.$_GET['nid']."#comment-".$_GET['cid']);
$nodelink2 = '/'.url('node/'.$_GET['nid']."#comment-".$_GET['cid']);
} else {
//$nodelink=$base_url.'/'.url('node/view/'.$_GET['nid']);
$nodelink=$base_url.'/'.url('node/'.$_GET['nid']);
$nodelink2 = '/'.url('node/'.$_GET['nid']);
}
// Set the refering page in a cookie
// 5mins should be enuf for anyone to put in a valid email address ;-)
setcookie('referer', $nodelink, time()+300, '/', ".".$host['host']);
setcookie('referer2', $nodelink2, time()+300, '/', ".".$host['host']);
Notice here the new var $nodelink2 and the second cookie. This is used later to replace the simple drupal_goto() function thus:
drupal_set_message("An email to your friend at '".$_POST['edit']['emailpage_addy']."' has been sent");
if(isset($_COOKIE['referer2']) && strlen($_COOKIE['referer2']) > 0) {
drupal_goto($_COOKIE['referer2']);
}
else {
drupal_goto();
}
| Comment | File | Size | Author |
|---|---|---|---|
| emailpage.module.patch | 7.25 KB | AjK |
Comments
Comment #1
darren ohIssue 2 is addressed in CVS commit 45519. I was afraid that sites without clean URLs might not work if the links were changed, so I left them untouched.
Comment #2
AjK commentedDarren, it's normal to change a status to "fixed" rather than "closed". A bot will come along in a couple of weeks a sweep "fixed" to "closed" automatically.
Setting them to "closed" means they drop of the RSS feed radar and people don't see the "closure message". I only noticed this one as it came up on my "tracker". But I don't often look at that preffering to use "My issues" which doesn't show "closed" issues ;)
Comment #3
(not verified) commented