668a669
>   volunteer_timeslots_organizer_notification($node, $user->uid);
872a874,933
> /**
>  * Send an e-mail with information to the event organizer
>  */
> function volunteer_timeslots_organizer_notification($node, $uid) {
>   static $organizer = array();
>   static $text = array();
>   
>   if (empty($organizer[$node->nid])) {
>     $organizer[$node->nid] = user_load(array('uid' => $node->timeslots_organizers[0], 'status' => 1));
>     if (empty($organizer[$node->nid])) {
>       watchdog('user', t("Volunteer timeslots: the user ID '%s' for node/%n could not be loaded.", array('%s' => $node->timeslots_organizers[0], '%n' => $node->nid)), WATCHDOG_ERROR);
>       $organizer[$node->nid]->mail = variable_get('site_mail', ini_get('sendmail_from'));
>     }
>   }
>   
>   $account = user_load(array('uid' => $uid, 'status' => 1)); 
>   if (empty($account)) {
>     watchdog('user', t("Volunteer timeslots: the user ID '%s' for node/%n could not be loaded.", array('%s' => $uid, '%n' => $node->nid)), WATCHDOG_ERROR);
>     return;
>   }
>   
>   // Compose the body:
>   if (empty($text[$node->nid])) {
>     switch (variable_get('event_timezone_display', 'event')) {
>       case 'event' :
>         include_once(EVENT_PATH .'/event_timezones.inc');
>         $start_offset = event_get_offset($node->timezone, $node->event_start);
>         break;
>       case 'user' :
>         $start_offset = $account->timezone;
>         break;
>       case 'site' :
>         $start_offset = variable_get('date_default_timezone', 0);
>         break;
>     }
>     $start_format = format_date($node->event_start, 'small', '', $start_offset);  
>     $message[] = t('User @user has changed their volunteer status for an event', array('@user' => $account->name));
>     $message[] = t('This is scheduled for @event_start. To see the event details, go to !url', array('@event_start' => $start_format, '!url' => url("node/".$node->nid, NULL, NULL, TRUE)));
>     $message[] = vt_mail_output(check_markup($node->body, $node->format, FALSE));
>     // Tidy up the body:
>     foreach ($message as $key => $value) {
>       $message[$key] = wordwrap($value);
>     }
>     $text[$node->nid] = implode("\n\n", $message);
>   }
> 
>   // Prepare all fields:
>   $to = $organizer[$node->nid]->mail;
>   $from = $organizer[$node->nid]->mail;
> 
>   // Format the subject:
>   $subject = '['. variable_get('site_name', 'drupal') .'] '. t('Event volunteer notification');
> 
>   // Prepare the body:
>   $body = $organizer[$node->nid]->name.",\n\n". $text[$node->nid];
> 
>   // Send the e-mail:
>   drupal_mail('volunteer_timeslots_organizer_notification', $to, $subject, $body, $from);
> }
> 
