/** * Send message when bug created. */ function bug_add($p_event, $p_bug_data) { $p_bug_id = $p_bug_data->id; if (check_user_from_projects_table($p_bug_id)) { if (ON == plugin_config_get('send_mes_new_bug')) { $t_recipients = email_collect_recipients($p_bug_id, 'new', array()); if (is_array($t_recipients)) { foreach ($t_recipients as $t_user_id => $t_user_email) { send_msg(get_xmpp_login($t_user_id), gen_add_bug_msg($t_user_id, $p_bug_id)); } } //send_msg( get_xmpp_login( $reporter_user_id ), gen_add_bug_msg( $reporter_user_id, $p_bug_data->id ) ); } } }
/** * 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; }
/** * send notices when a relationship is DELETED * @param integer $p_bug_id A bug identifier. * @param integer $p_related_bug_id Related bug identifier. * @param integer $p_rel_type Relationship type. * @return void */ function email_relationship_deleted($p_bug_id, $p_related_bug_id, $p_rel_type) { $t_opt = array(); $t_opt[] = bug_format_id($p_related_bug_id); global $g_relationships; if (!isset($g_relationships[$p_rel_type])) { trigger_error(ERROR_RELATIONSHIP_NOT_FOUND, ERROR); } log_event(LOG_EMAIL, 'Issue #%d relationship to issue #%d (relationship type %s) deleted.', $p_bug_id, $p_related_bug_id, $g_relationships[$p_rel_type]['#description']); $t_recipients = email_collect_recipients($p_bug_id, 'relation'); # Recipient has to have access to both bugs to get the notification. $t_recipients = email_filter_recipients_for_bug($p_bug_id, $t_recipients); $t_recipients = email_filter_recipients_for_bug($p_related_bug_id, $t_recipients); email_generic_to_recipients($p_bug_id, 'relation', $t_recipients, $g_relationships[$p_rel_type]['#notify_deleted'], $t_opt); }
/** * 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(); } } }
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; }