示例#1
0
/**
 * send a generic email
 * $p_notify_type: use check who she get notified of such event.
 * $p_message_id: message id to be translated and included at the top of the email message.
 * Return false if it were problems sending email * @param string
 * @param int $p_bug_id
 * @param string $p_notify_type
 * @param int $p_message_id
 * @param array $p_header_optional_params = null
 * @param array $p_extra_user_ids_to_email
 * @return bool
 */
function email_generic($p_bug_id, $p_notify_type, $p_message_id = null, $p_header_optional_params = null, $p_extra_user_ids_to_email = array())
{
    $t_ok = true;
    if (ON === config_get('enable_email_notification')) {
        ignore_user_abort(true);
        bugnote_get_all_bugnotes($p_bug_id);
        # @todo yarick123: email_collect_recipients(...) will be completely rewritten to provide additional information such as language, user access,..
        # @todo yarick123:sort recipients list by language to reduce switches between different languages
        $t_recipients = email_collect_recipients($p_bug_id, $p_notify_type, $p_extra_user_ids_to_email);
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        if (is_array($t_recipients)) {
            # send email to every recipient
            foreach ($t_recipients as $t_user_id => $t_user_email) {
                log_event(LOG_EMAIL, sprintf("Issue = #%d, Type = %s, Msg = '%s', User = @U%d, Email = '%s'.", $p_bug_id, $p_notify_type, $p_message_id, $t_user_id, $t_user_email));
                # load (push) user language here as build_visible_bug_data assumes current language
                lang_push(user_pref_get_language($t_user_id, $t_project_id));
                $t_visible_bug_data = email_build_visible_bug_data($t_user_id, $p_bug_id, $p_message_id);
                $t_ok = email_bug_info_to_one_user($t_visible_bug_data, $p_message_id, $t_project_id, $t_user_id, $p_header_optional_params) && $t_ok;
                lang_pop();
            }
        }
        # Only trigger the draining of the email queue if cronjob is disabled and email notifications are enabled.
        if (OFF == config_get('email_send_using_cronjob')) {
            email_send_all();
        }
    }
    return $t_ok;
}
示例#2
0
/**
 * Sends a generic email to the specific set of recipients.
 *
 * @param integer $p_bug_id                  A bug identifier
 * @param string  $p_notify_type             Notification type
 * @param array   $p_recipients              Array of recipients (key: user id, value: email address)
 * @param integer $p_message_id              Message identifier
 * @param array   $p_header_optional_params  Optional Parameters (default null)
 * @return void
 */
function email_generic_to_recipients($p_bug_id, $p_notify_type, array $p_recipients, $p_message_id = null, array $p_header_optional_params = null)
{
    if (OFF == config_get('enable_email_notification')) {
        return;
    }
    ignore_user_abort(true);
    bugnote_get_all_bugnotes($p_bug_id);
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    if (is_array($p_recipients)) {
        # send email to every recipient
        foreach ($p_recipients as $t_user_id => $t_user_email) {
            log_event(LOG_EMAIL_VERBOSE, 'Issue = #%d, Type = %s, Msg = \'%s\', User = @U%d, Email = \'%s\'.', $p_bug_id, $p_notify_type, $p_message_id, $t_user_id, $t_user_email);
            # load (push) user language here as build_visible_bug_data assumes current language
            lang_push(user_pref_get_language($t_user_id, $t_project_id));
            $t_visible_bug_data = email_build_visible_bug_data($t_user_id, $p_bug_id, $p_message_id);
            email_bug_info_to_one_user($t_visible_bug_data, $p_message_id, $t_user_id, $p_header_optional_params);
            lang_pop();
        }
    }
}
示例#3
0
/**
 * send a generic email
 * $p_notify_type: use check who she get notified of such event.
 * $p_message_id: message id to be translated and included at the top of the email message.
 * Return false if it were problems sending email
 * @param integer $p_bug_id                  A bug identifier.
 * @param string  $p_notify_type             Notification type.
 * @param integer $p_message_id              Message identifier.
 * @param array   $p_header_optional_params  Optional Parameters (default null).
 * @param array   $p_extra_user_ids_to_email Array of additional users to email.
 * @return void
 */
function email_generic($p_bug_id, $p_notify_type, $p_message_id = null, array $p_header_optional_params = null, array $p_extra_user_ids_to_email = array())
{
    if (OFF == config_get('enable_email_notification')) {
        return;
    }
    ignore_user_abort(true);
    bugnote_get_all_bugnotes($p_bug_id);
    # @todo yarick123: email_collect_recipients(...) will be completely rewritten to provide additional information such as language, user access,..
    # @todo yarick123:sort recipients list by language to reduce switches between different languages
    $t_recipients = email_collect_recipients($p_bug_id, $p_notify_type, $p_extra_user_ids_to_email);
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    if (is_array($t_recipients)) {
        # send email to every recipient
        foreach ($t_recipients as $t_user_id => $t_user_email) {
            log_event(LOG_EMAIL, 'Issue = #%d, Type = %s, Msg = \'%s\', User = @U%d, Email = \'%s\'.', $p_bug_id, $p_notify_type, $p_message_id, $t_user_id, $t_user_email);
            # load (push) user language here as build_visible_bug_data assumes current language
            lang_push(user_pref_get_language($t_user_id, $t_project_id));
            $t_visible_bug_data = email_build_visible_bug_data($t_user_id, $p_bug_id, $p_message_id);
            email_bug_info_to_one_user($t_visible_bug_data, $p_message_id, $t_project_id, $t_user_id, $p_header_optional_params);
            lang_pop();
        }
    }
}
示例#4
0
/**
 * send a generic email
 * $p_notify_type: use check who she get notified of such event.
 * $p_message_id: message id to be translated and included at the top of the email message.
 * Return false if it were problems sending email * @param string
 * @param int $p_bug_id
 * @param string $p_notify_type
 * @param int $p_message_id
 * @param array $p_header_optional_params = null
 * @param array $p_extra_user_ids_to_email
 * @return bool
 */
function email_generic_to_recipients($p_bug_id, $p_notify_type, array $p_recipients, $p_message_id = null, $p_header_optional_params = null)
{
    $t_ok = true;
    if (ON === config_get('enable_email_notification')) {
        ignore_user_abort(true);
        bugnote_get_all_bugnotes($p_bug_id);
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        if (is_array($p_recipients)) {
            # send email to every recipient
            foreach ($p_recipients as $t_user_id => $t_user_email) {
                log_event(LOG_EMAIL, sprintf("Issue = #%d, Type = %s, Msg = '%s', User = @U%d, Email = '%s'.", $p_bug_id, $p_notify_type, $p_message_id, $t_user_id, $t_user_email));
                # load (push) user language here as build_visible_bug_data assumes current language
                lang_push(user_pref_get_language($t_user_id, $t_project_id));
                $t_visible_bug_data = email_build_visible_bug_data($t_user_id, $p_bug_id, $p_message_id);
                $t_ok = email_bug_info_to_one_user($t_visible_bug_data, $p_message_id, $t_project_id, $t_user_id, $p_header_optional_params) && $t_ok;
                lang_pop();
            }
        }
        # Only trigger the draining of the email queue if cronjob is disabled and email notifications are enabled.
        if (OFF == config_get('email_send_using_cronjob')) {
            email_send_all();
        }
    }
    return $t_ok;
}
示例#5
0
function email_generic($p_bug_id, $p_notify_type, $p_message_id = null, $p_header_optional_params = null)
{
    $t_ok = true;
    if (ON === config_get('enable_email_notification')) {
        ignore_user_abort(true);
        # @@@ yarick123: email_collect_recipients(...) will be completely rewritten to provide additional
        #     information such as language, user access,..
        # @@@ yarick123:sort recipients list by language to reduce switches between different languages
        $t_recipients = email_collect_recipients($p_bug_id, $p_notify_type);
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        if (is_array($t_recipients)) {
            log_event(LOG_EMAIL, sprintf("bug=%d, type=%s, msg=%s, recipients=(%s)", $p_bug_id, $p_notify_type, $p_message_id, implode('. ', $t_recipients)));
            # send email to every recipient
            foreach ($t_recipients as $t_user_id => $t_user_email) {
                # load (push) user language here as build_visible_bug_data assumes current language
                lang_push(user_pref_get_language($t_user_id, $t_project_id));
                $t_visible_bug_data = email_build_visible_bug_data($t_user_id, $p_bug_id, $p_message_id);
                $t_ok = email_bug_info_to_one_user($t_visible_bug_data, $p_message_id, $t_project_id, $t_user_id, $p_header_optional_params) && $t_ok;
                lang_pop();
            }
        }
    }
    return $t_ok;
}