//if ($handler== $handler2){ if ($reporter == $reporter2) { $list .= " \n\n"; //$list .= string_get_bug_view_url_with_fqdn( $id, $handler2 ); $list .= string_get_bug_view_url_with_fqdn($id, $reporter2); } else { // now send the grouped email $body = $t_rem_body1 . " <br><br>\n\n"; $body .= $list . " <br>\n\n"; $body .= $t_rem_body2; //$result = email_group_reminder( $handler2, $body); $result = email_group_reminder($reporter2, $body); //$handler2 = $handler ; $reporter2 = $reporter; //$list= string_get_bug_view_url_with_fqdn( $id, $handler2 ); $list = string_get_bug_view_url_with_fqdn($id, $reporter2); } $list .= " <br>\n"; } // handle last grouped email if ($results) { $body = $t_rem_body1 . " \n\n"; $body .= $list . " \n\n"; $body .= $t_rem_body2; //why the handler? Feedback reminder email should go to the Reporter! //$result = email_group_reminder( $handler2, $body); $result = email_group_reminder($reporter2, $body); } else { echo 'Query-Manager had no results ' . $query; echo '<br>'; }
/** * Process $p_string, looking for bug ID references and creating bug view * links for them. * * Returns the processed string. * * If $p_include_anchor is true, include the href tag, otherwise just insert * the URL * * The bug tag ('#' by default) must be at the beginning of the string or * preceeded by a character that is not a letter, a number or an underscore * * if $p_include_anchor = false, $p_fqdn is ignored and assumed to true. * @param string $p_string String to be processed. * @param boolean $p_include_anchor Whether to include the href tag or just the URL. * @param boolean $p_detail_info Whether to include more detailed information (e.g. title attribute / project) in the returned string. * @param boolean $p_fqdn Whether to return an absolute or relative link. * @return string */ function string_process_bug_link($p_string, $p_include_anchor = true, $p_detail_info = true, $p_fqdn = false) { static $s_bug_link_callback = array(); $t_tag = config_get('bug_link_tag'); # bail if the link tag is blank if ('' == $t_tag || $p_string == '') { return $p_string; } if (!isset($s_bug_link_callback[$p_include_anchor][$p_detail_info][$p_fqdn])) { if ($p_include_anchor) { $s_bug_link_callback[$p_include_anchor][$p_detail_info][$p_fqdn] = function ($p_array) use($p_detail_info, $p_fqdn) { if (bug_exists((int) $p_array[2])) { $t_project_id = bug_get_field((int) $p_array[2], 'project_id'); $t_view_bug_threshold = config_get('view_bug_threshold', null, null, $t_project_id); if (access_has_bug_level($t_view_bug_threshold, (int) $p_array[2])) { return $p_array[1] . string_get_bug_view_link((int) $p_array[2], (bool) $p_detail_info, (bool) $p_fqdn); } } return $p_array[0]; }; # end of bug link callback closure } else { $s_bug_link_callback[$p_include_anchor][$p_detail_info][$p_fqdn] = function ($p_array) { if (bug_exists((int) $p_array[2])) { # Create link regardless of user's access to the bug return $p_array[1] . string_get_bug_view_url_with_fqdn((int) $p_array[2]); } return $p_array[0]; }; # end of bug link callback closure } } $p_string = preg_replace_callback('/(^|[^\\w&])' . preg_quote($t_tag, '/') . '(\\d+)\\b/', $s_bug_link_callback[$p_include_anchor][$p_detail_info][$p_fqdn], $p_string); return $p_string; }
/** * Build the bug raw data visible for specified user to be translated and sent by email to the user * (Filter the bug data according to user access level) * return array with bug data. See usage in email_format_bug_message(...) * @param int $p_user_id * @param int $p_bug_id * @param string $p_message_id * @return array */ function email_build_visible_bug_data($p_user_id, $p_bug_id, $p_message_id) { $t_project_id = bug_get_field($p_bug_id, 'project_id'); $t_user_access_level = user_get_access_level($p_user_id, $t_project_id); $t_user_bugnote_order = user_pref_get_pref($p_user_id, 'bugnote_order'); $t_user_bugnote_limit = user_pref_get_pref($p_user_id, 'email_bugnote_limit'); $row = bug_get_extended_row($p_bug_id); $t_bug_data = array(); $t_bug_data['email_bug'] = $p_bug_id; if ($p_message_id !== 'email_notification_title_for_action_bug_deleted') { $t_bug_data['email_bug_view_url'] = string_get_bug_view_url_with_fqdn($p_bug_id); } if (access_compare_level($t_user_access_level, config_get('view_handler_threshold'))) { if (0 != $row['handler_id']) { $t_bug_data['email_handler'] = user_get_name($row['handler_id']); } else { $t_bug_data['email_handler'] = ''; } } $t_bug_data['email_reporter'] = user_get_name($row['reporter_id']); $t_bug_data['email_project_id'] = $row['project_id']; $t_bug_data['email_project'] = project_get_field($row['project_id'], 'name'); $t_category_name = category_full_name($row['category_id'], false); $t_bug_data['email_category'] = $t_category_name; $t_bug_data['email_date_submitted'] = $row['date_submitted']; $t_bug_data['email_last_modified'] = $row['last_updated']; $t_bug_data['email_status'] = $row['status']; $t_bug_data['email_severity'] = $row['severity']; $t_bug_data['email_priority'] = $row['priority']; $t_bug_data['email_reproducibility'] = $row['reproducibility']; $t_bug_data['email_resolution'] = $row['resolution']; $t_bug_data['email_fixed_in_version'] = $row['fixed_in_version']; if (!is_blank($row['target_version']) && access_compare_level($t_user_access_level, config_get('roadmap_view_threshold'))) { $t_bug_data['email_target_version'] = $row['target_version']; } $t_bug_data['email_summary'] = $row['summary']; $t_bug_data['email_description'] = $row['description']; $t_bug_data['email_additional_information'] = $row['additional_information']; $t_bug_data['email_steps_to_reproduce'] = $row['steps_to_reproduce']; $t_bug_data['set_category'] = '[' . $t_bug_data['email_project'] . '] ' . $t_category_name; $t_bug_data['custom_fields'] = custom_field_get_linked_fields($p_bug_id, $t_user_access_level); $t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes($p_bug_id, $t_user_bugnote_order, $t_user_bugnote_limit, $p_user_id); # put history data if (ON == config_get('history_default_visible') && access_compare_level($t_user_access_level, config_get('view_history_threshold'))) { $t_bug_data['history'] = history_get_raw_events_array($p_bug_id, $p_user_id); } # Sponsorship Information if (config_get('enable_sponsorship') == ON && access_has_bug_level(config_get('view_sponsorship_total_threshold'), $p_bug_id, $p_user_id)) { $t_sponsorship_ids = sponsorship_get_all_ids($p_bug_id); $t_bug_data['sponsorship_total'] = sponsorship_get_amount($t_sponsorship_ids); if (access_has_bug_level(config_get('view_sponsorship_details_threshold'), $p_bug_id, $p_user_id)) { $t_bug_data['sponsorships'] = array(); foreach ($t_sponsorship_ids as $id) { $t_bug_data['sponsorships'][] = sponsorship_get($id); } } } $t_bug_data['relations'] = relationship_get_summary_text($p_bug_id); return $t_bug_data; }
function formatBugEntry($data) { lang_push(user_pref_get_language($data['handler_id'])); $p_visible_bug_data = $data; $p_visible_bug_data['email_project'] = project_get_name($data['project_id']); $p_visible_bug_data['email_category'] = category_get_name($data['category_id']); $t_email_separator1 = config_get('email_separator1'); $t_email_separator2 = config_get('email_separator2'); $p_visible_bug_data['email_bug'] = $data['id']; $p_visible_bug_data['email_status'] = get_enum_element('status', $p_visible_bug_data['status'], $data['handler_id'], $data['project_id']); $p_visible_bug_data['email_severity'] = get_enum_element('severity', $p_visible_bug_data['severity']); $p_visible_bug_data['email_priority'] = get_enum_element('priority', $p_visible_bug_data['priority']); $p_visible_bug_data['email_reproducibility'] = get_enum_element('reproducibility', $p_visible_bug_data['reproducibility']); $p_visible_bug_data['email_summary'] = $data['summary']; $t_message = $t_email_separator1 . " \n"; $t_message .= string_get_bug_view_url_with_fqdn($data['id'], $data['handler_id']) . " \n"; $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_project'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_bug'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_category'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_priority'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_status'); $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_summary'); $t_message .= $t_email_separator1 . " \n\n\n"; return $t_message; }
function string_process_bug_link($p_string, $p_include_anchor = true, $p_detail_info = true, $p_fqdn = false) { $t_tag = config_get('bug_link_tag'); # bail if the link tag is blank if ('' == $t_tag) { return $p_string; } preg_match_all('/(^|.+?)(?:(?<=^|\\W)' . preg_quote($t_tag, '/') . '(\\d+)|$)/s', $p_string, $t_matches, PREG_SET_ORDER); $t_result = ''; if ($p_include_anchor) { foreach ($t_matches as $t_match) { $t_result .= $t_match[1]; if (isset($t_match[2])) { $t_bug_id = $t_match[2]; if (bug_exists($t_bug_id)) { $t_result .= string_get_bug_view_link($t_bug_id, null, $p_detail_info, $p_fqdn); } else { $t_result .= $t_bug_id; } } } } else { foreach ($t_matches as $t_match) { $t_result .= $t_match[1]; if (isset($t_match[2])) { $t_bug_id = $t_match[2]; # We might as well create the link here even if the bug # doesn't exist. In the case above we don't want to do # the summary lookup on a non-existant bug. But here, we # can create the link and by the time it is clicked on, the # bug may exist. $t_result .= string_get_bug_view_url_with_fqdn($t_bug_id, null); } } } return $t_result; }
function format_value($bug, $field_name) { $values = array('id' => function ($bug) { return sprintf('%s <%s>', $bug->id, string_get_bug_view_url_with_fqdn($bug->id)); }, 'project_id' => function ($bug) { return project_get_name($bug->project_id); }, 'reporter_id' => function ($bug) { return '@' . user_get_name($bug->reporter_id); }, 'handler_id' => function ($bug) { return empty($bug->handler_id) ? plugin_lang_get('no_user') : '@' . user_get_name($bug->handler_id); }, 'duplicate_id' => function ($bug) { return sprintf('%s <%s>', $bug->duplicate_id, string_get_bug_view_url_with_fqdn($bug->duplicate_id)); }, 'priority' => function ($bug) { return get_enum_element('priority', $bug->priority); }, 'severity' => function ($bug) { return get_enum_element('severity', $bug->severity); }, 'reproducibility' => function ($bug) { return get_enum_element('reproducibility', $bug->reproducibility); }, 'status' => function ($bug) { return get_enum_element('status', $bug->status); }, 'resolution' => function ($bug) { return get_enum_element('resolution', $bug->resolution); }, 'projection' => function ($bug) { return get_enum_element('projection', $bug->projection); }, 'category_id' => function ($bug) { return category_full_name($bug->category_id, false); }, 'eta' => function ($bug) { return get_enum_element('eta', $bug->eta); }, 'view_state' => function ($bug) { return $bug->view_state == VS_PRIVATE ? lang_get('private') : lang_get('public'); }, 'sponsorship_total' => function ($bug) { return sponsorship_format_amount($bug->sponsorship_total); }, 'os' => function ($bug) { return $bug->os; }, 'os_build' => function ($bug) { return $bug->os_build; }, 'platform' => function ($bug) { return $bug->platform; }, 'version' => function ($bug) { return $bug->version; }, 'fixed_in_version' => function ($bug) { return $bug->fixed_in_version; }, 'target_version' => function ($bug) { return $bug->target_version; }, 'build' => function ($bug) { return $bug->build; }, 'summary' => function ($bug) { return HipChatPlugin::clean_summary(bug_format_summary($bug->id, SUMMARY_FIELD)); }, 'last_updated' => function ($bug) { return date(config_get('short_date_format'), $bug->last_updated); }, 'date_submitted' => function ($bug) { return date(config_get('short_date_format'), $bug->date_submitted); }, 'due_date' => function ($bug) { return date(config_get('short_date_format'), $bug->due_date); }, 'description' => function ($bug) { return string_display_links($bug->description); }, 'steps_to_reproduce' => function ($bug) { return string_display_links($bug->steps_to_reproduce); }, 'additional_information' => function ($bug) { return string_display_links($bug->additional_information); }); // Discover custom fields. $t_related_custom_field_ids = custom_field_get_linked_ids($bug->project_id); foreach ($t_related_custom_field_ids as $t_id) { $t_def = custom_field_get_definition($t_id); $values['custom_' . $t_def['name']] = function ($bug) use($t_id) { return custom_field_get_value($t_id, $bug->id); }; } if (isset($values[$field_name])) { $func = $values[$field_name]; return $func($bug); } else { return sprintf(plugin_lang_get('unknown_field'), $field_name); } }
echo "<br>"; if ($start) { $man2 = $manager; $start = false; } if ($manager == $man2) { $list .= " \n\n"; $list .= string_get_bug_view_url_with_fqdn($id, $man2); } else { // now send the grouped email $body = $t_rem_body1 . " \n\n"; $body .= $list . " \n\n"; $body .= $t_rem_body2; $result = email_group_reminder($man2, $body); $man2 = $manager; $list = string_get_bug_view_url_with_fqdn($id, $man2); $list .= " \n\n"; } } // handle last one if ($resnum > 0) { // now send the grouped email $body = $t_rem_body1 . " \n\n"; $body .= $list . " \n\n"; $body .= $t_rem_body2; $result = email_group_reminder($man2, $body); } else { echo 'Query-Manager had no results ' . $query; echo '<br>'; } //
$results = db_query_bound($query); if (!$results) { echo 'Query failed.'; exit(1); } # Loop through all assigned bugs, building a list of what to email $emails = array(); while ($row = db_fetch_array($results)) { # New recipient if (!isset($emails[$row['handler_id']])) { $emails[$row['handler_id']] = array('recipient' => array('email' => $row['email'], 'name' => $row['realname']), 'bugs' => array()); } # Add current bug to this recipient's list $emails[$row['handler_id']]['bugs'][$row['bug_id']] = $row['summary']; } # Construct and send emails foreach ($emails as $email) { # Build list of issues with summary and link $list = ''; foreach ($email['bugs'] as $bug_id => $summary) { $url = string_get_bug_view_url_with_fqdn($bug_id); $list .= " * {$summary}\n {$url}\n"; } # Queue email for sending (and send it, if cron sending is disabled) $message = "Assigned to " . $email['recipient']['name'] . ":\n\n{$list}\n"; $subject = config_get('plugin_Reminder_reminder_subject'); email_store($email['recipient']['email'], $subject, $message); if (OFF == config_get('email_send_using_cronjob')) { email_send_all(); } }