Example #1
0
/**
 * @param boolean $result
 * @param EM_Event $EM_Event
 * @return boolean
 */
function em_event_submission_emails($result, $EM_Event)
{
    if ($result) {
        //if this is just published, we need to email the user about the publication, or send to pending mode again for review
        $cant_publish_event = $EM_Event->is_individual() && !user_can($EM_Event->get_contact()->ID, 'publish_events');
        $cant_publish_recurring_event = $EM_Event->is_recurring() && !user_can($EM_Event->get_contact()->ID, 'publish_recurring_events');
        $output_type = get_option('dbem_smtp_html') ? 'html' : 'email';
        if ($cant_publish_event || $cant_publish_recurring_event) {
            if ($EM_Event->is_published() && !$EM_Event->previous_status) {
                //only send email to users that can't publish events themselves and that were previously unpublished
                $approvals_count = get_post_meta($EM_Event->post_id, '_event_approvals_count', true);
                $approvals_count = $approvals_count > 0 ? $approvals_count : 0;
                if ($approvals_count == 1) {
                    $subject = $EM_Event->output(get_option('dbem_event_approved_email_subject'), 'raw');
                    $body = $EM_Event->output(get_option('dbem_event_approved_email_body'), $output_type);
                } else {
                    $subject = $EM_Event->output(get_option('dbem_event_reapproved_email_subject'), 'raw');
                    $body = $EM_Event->output(get_option('dbem_event_reapproved_email_body'), $output_type);
                }
                if ($EM_Event->event_owner == "") {
                    return true;
                }
                $EM_Event->email_send($subject, $body, $EM_Event->get_contact()->user_email);
            } elseif (!$EM_Event->get_status() && get_option('dbem_event_submitted_email_admin') != '') {
                $approvals_count = get_post_meta($EM_Event->post_id, '_event_approvals_count', true);
                $approvals_count = $approvals_count > 0 ? $approvals_count : 0;
                update_post_meta($EM_Event->post_id, '_event_approvals_count', $approvals_count + 1);
                $admin_emails = explode(',', str_replace(' ', '', get_option('dbem_event_submitted_email_admin')));
                //admin emails are in an array, single or multiple
                if (empty($admin_emails)) {
                    return true;
                }
                if ($approvals_count > 1) {
                    $subject = $EM_Event->output(get_option('dbem_event_resubmitted_email_subject'), 'raw');
                    $message = $EM_Event->output(get_option('dbem_event_resubmitted_email_body'), $output_type);
                } else {
                    $subject = $EM_Event->output(get_option('dbem_event_submitted_email_subject'), 'raw');
                    $message = $EM_Event->output(get_option('dbem_event_submitted_email_body'), $output_type);
                }
                //Send email to admins
                $EM_Event->email_send($subject, $message, $admin_emails);
            }
        } elseif (!current_user_can('list_users')) {
            if ($EM_Event->is_published() && !$EM_Event->previous_status) {
                $admin_emails = explode(',', str_replace(' ', '', get_option('dbem_event_submitted_email_admin')));
                //admin emails are in an array, single or multiple
                if (empty($admin_emails)) {
                    return true;
                }
                $subject = $EM_Event->output(get_option('dbem_event_published_email_subject'), 'raw');
                $body = $EM_Event->output(get_option('dbem_event_published_email_body'), $output_type);
                $EM_Event->email_send($subject, $body, $admin_emails);
            }
        }
    }
    return $result;
}
Example #2
0
/**
 * This is a temporary filter function which mimicks the old filters in the old 2.x placeholders function
 * @param string $result
 * @param EM_Event $event
 * @param string $placeholder
 * @param string $target
 * @return mixed
 */
function em_event_output_placeholder($result, $event, $placeholder, $target = 'html')
{
    if ($target == 'raw') {
        return $result;
    }
    if (in_array($placeholder, array("#_EXCERPT", '#_EVENTEXCERPT', "#_LOCATIONEXCERPT")) && $target == 'html') {
        $result = apply_filters('dbem_notes_excerpt', $result);
    } elseif ($placeholder == '#_CONTACTEMAIL' && $target == 'html') {
        $result = em_ascii_encode($event->get_contact()->user_email);
    } elseif (in_array($placeholder, array('#_EVENTNOTES', '#_NOTES', '#_DESCRIPTION', '#_LOCATIONNOTES', '#_CATEGORYNOTES', '#_CATEGORYDESCRIPTION'))) {
        if ($target == 'rss') {
            $result = apply_filters('dbem_notes_rss', $result);
            $result = apply_filters('the_content_rss', $result);
        } elseif ($target == 'map') {
            $result = apply_filters('dbem_notes_map', $result);
        } elseif ($target == 'ical') {
            $result = apply_filters('dbem_notes_ical', $result);
        } elseif ($target == "email") {
            $result = apply_filters('dbem_notes_email', $result);
        } else {
            //html
            $result = apply_filters('dbem_notes', $result);
        }
    } elseif (in_array($placeholder, array("#_NAME", '#_LOCATION', '#_TOWN', '#_ADDRESS', '#_LOCATIONNAME', "#_EVENTNAME", "#_LOCATIONNAME", '#_CATEGORY'))) {
        if ($target == "rss") {
            $result = apply_filters('dbem_general_rss', $result);
        } elseif ($target == "ical") {
            $result = apply_filters('dbem_general_ical', $result);
        } elseif ($target == "email") {
            $result = apply_filters('dbem_general_email', $result);
        } else {
            //html
            $result = apply_filters('dbem_general', $result);
        }
    }
    return $result;
}