A hit on cron kills a site with ads needing expiration notifications sent. Here's the error:

Fatal error: Call to undefined function _ed_classified_notify_user_of_ad_expiration() in /var/www/drupalsites/drupal-6.9_arctest.eapdd.com/sites/all/modules/ed_classified/ed_classified_utils.inc on line 194

I'm not sure what other function that should be pointing at since I can't find one that accepts a $node argument. Any ideas?

Comments

barckhoff’s picture

Hi tomws,

It appears that the notifications part is still under construction. I tried changing the call to that missing function @line 203 in ed_classified_utils.inc from

_ed_classified_notify_user_of_ad_expiration($node);
to
_ed_classified_process_notification_emails($time);

Which *sort of* gets it to work, but there are issues with retrieving the recipient's emails and the from email formatting doesn't work (can be easily remedied by getting rid of the string for "Reply to:" etc.).

For the time being, until someone smarter than me can correct the notification functions, I've just commented out the line above to bypass the notification functions so that the cron will run.

tomws’s picture

I did the same thing to mine and just posted a note to the users that they won't get the expiration reminders.

mcurry’s picture

The cron job email problem is odd, and I've never heard anyone report it until now.

This module is not ready for use on a production site (I've never released an official 6.x build). This module is currently 'test only' for Drupal 6. Sorry.

I'll investigate this when I can but as you can see, I'm seeking a new maintainer due to my inability to maintain this module.

tomws’s picture

No complaints. I'm choosing to use a dev version because I need the functionality. Stuff happens. Users will live with it until a full version is ready.

milesgillham’s picture

I think I have a fix. I've added the missing function to ed_classified_notifications.inc

/**
 * Notify a user that their ad has expired.
 * @param $node The ad node.
 * This function sends a note to the user regarding their expired ad.
 */
function _ed_classified_notify_user_of_ad_expiration($node)
{
  $ad_author = user_load(array('uid'=>$node->uid));
  _ed_classified_send_user_notification_email($ad_author);
}

To do that I had to add an additional e-mail notification function telling the user that their ad has expired, as opposed to about to expire. So furthere down in that same file there is now:

/**
 * Send an email notification to the specified user
 */

function _ed_classified_send_user_notification_email(&$user) {
  $parms = array('!sitename' => variable_get('site_name', ''),
                 '!user_ads_url' => url('user/'.$user->uid . '/'. EDI_CLASSIFIED_MODULE_NAME, array('absolute' => TRUE)),
                 '!siteurl' => url('', array('absolute' => TRUE)));
  $subject = t(_ed_classified_variable_get('email_subj', EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ), $parms);
  $body = t(_ed_classified_variable_get('email_body', EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_BODY), $parms);
  $from = variable_get("site_mail", ini_get("sendmail_from")); // http://drupal.org/node/77689

  return drupal_mail(EDI_CLASSIFIED_MODULE_NAME . '-expiration-notify', $user->mail, $subject, $body,
                     $from, "Reply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
}

And for that to work, I added the following to ed_classified.module:

define('EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_BODY', 'A classified ad on !sitename (!siteurl) has expired.  Please sign in and visit !user_ads_url to check your ads.');
define('EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ', '!sitename notifiation: classified ad expired!');

I'll play around with it and test it out and see if I'm on the right track. I'll offer a patch if it's stable.

It's an extension of what is their, but I think down the track I'd rather genericise the email notification with parameters for subject/body. There's a number of todos in that file that probably need a closer look also.

Cheers,

Miles
---

milesgillham’s picture

Status: Active » Fixed

Code changes applied to 6.x development branch.

tomws’s picture

Thanks for your work! I hope to play around with this in the next few weeks.

milesgillham’s picture

No problems. That should since have been swept up in alpha3 release and alpha4 should be out within the next week.

Regards,

Miles

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.