/** * hook function for system event EVENT_NOTIFY_USER_INCLUDE * @param string $p_event * @param int $p_param contains the bug_id * @return array */ function notify_group_users($p_event, $p_param) { $t_bug_id = $p_param; $t_bug = bug_get($t_bug_id); //collect all user ids that can hold groups $t_users = array() + bug_get_monitors($t_bug_id); $t_users[] = $t_bug->reporter_id; $t_users[] = $t_bug->handler_id; //exclude the native users $t_all_groups = $this->get_all_groups(TRUE); $t_notify_groups = array_merge(array_intersect($t_users, $t_all_groups)); //get the users from the group(s) $t_group_users = array(); for ($i = 0; $i < count($t_notify_groups); $i++) { $t_group_users = array_merge($t_group_users, $this->get_all_users_from_group($t_notify_groups[$i])); } return $t_group_users; }
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. /** * This include file prints out the list of users monitoring the current * bug. $f_bug_id must be set and be set to the bug id * * @package MantisBT * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org * @copyright Copyright (C) 2002 - 2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net * @link http://www.mantisbt.org */ if (access_has_bug_level(config_get('show_monitor_list_threshold'), $f_bug_id)) { $t_users = bug_get_monitors($f_bug_id); $num_users = sizeof($t_users); echo '<a name="monitors" id="monitors" /><br />'; collapse_open('monitoring'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php collapse_icon('monitoring'); ?> <?php echo lang_get('users_monitoring_bug'); ?> </td> </tr>
/** * Returns an array for SOAP encoding from a BugData object * * @param BugData $p_issue_data A BugData object to process. * @param integer $p_user_id A valid user identifier. * @param string $p_lang A valid language string. * @return array The issue as an array */ function mci_issue_data_as_array(BugData $p_issue_data, $p_user_id, $p_lang) { $t_id = $p_issue_data->id; $t_issue = array(); $t_issue['id'] = $t_id; $t_issue['view_state'] = mci_enum_get_array_by_id($p_issue_data->view_state, 'view_state', $p_lang); $t_issue['last_updated'] = SoapObjectsFactory::newDateTimeVar($p_issue_data->last_updated); $t_issue['project'] = mci_project_as_array_by_id($p_issue_data->project_id); $t_issue['category'] = mci_get_category($p_issue_data->category_id); $t_issue['priority'] = mci_enum_get_array_by_id($p_issue_data->priority, 'priority', $p_lang); $t_issue['severity'] = mci_enum_get_array_by_id($p_issue_data->severity, 'severity', $p_lang); $t_issue['status'] = mci_enum_get_array_by_id($p_issue_data->status, 'status', $p_lang); $t_issue['reporter'] = mci_account_get_array_by_id($p_issue_data->reporter_id); $t_issue['summary'] = mci_sanitize_xml_string($p_issue_data->summary); $t_issue['version'] = mci_null_if_empty($p_issue_data->version); $t_issue['build'] = mci_null_if_empty($p_issue_data->build); $t_issue['profile_id'] = mci_null_if_empty($p_issue_data->profile_id); $t_issue['platform'] = mci_null_if_empty($p_issue_data->platform); $t_issue['os'] = mci_null_if_empty($p_issue_data->os); $t_issue['os_build'] = mci_null_if_empty($p_issue_data->os_build); $t_issue['reproducibility'] = mci_enum_get_array_by_id($p_issue_data->reproducibility, 'reproducibility', $p_lang); $t_issue['date_submitted'] = SoapObjectsFactory::newDateTimeVar($p_issue_data->date_submitted); $t_issue['sticky'] = $p_issue_data->sticky; $t_issue['sponsorship_total'] = $p_issue_data->sponsorship_total; if (!empty($p_issue_data->handler_id)) { $t_issue['handler'] = mci_account_get_array_by_id($p_issue_data->handler_id); } $t_issue['projection'] = mci_enum_get_array_by_id($p_issue_data->projection, 'projection', $p_lang); $t_issue['eta'] = mci_enum_get_array_by_id($p_issue_data->eta, 'eta', $p_lang); $t_issue['resolution'] = mci_enum_get_array_by_id($p_issue_data->resolution, 'resolution', $p_lang); $t_issue['fixed_in_version'] = mci_null_if_empty($p_issue_data->fixed_in_version); $t_issue['target_version'] = mci_null_if_empty($p_issue_data->target_version); $t_issue['description'] = mci_sanitize_xml_string(bug_get_text_field($t_id, 'description')); $t_steps_to_reproduce = bug_get_text_field($t_id, 'steps_to_reproduce'); $t_issue['steps_to_reproduce'] = mci_null_if_empty(mci_sanitize_xml_string($t_steps_to_reproduce)); $t_additional_information = bug_get_text_field($t_id, 'additional_information'); $t_issue['additional_information'] = mci_null_if_empty(mci_sanitize_xml_string($t_additional_information)); $t_issue['due_date'] = SoapObjectsFactory::newDateTimeVar($p_issue_data->due_date); $t_issue['attachments'] = mci_issue_get_attachments($p_issue_data->id); $t_issue['relationships'] = mci_issue_get_relationships($p_issue_data->id, $p_user_id); $t_issue['notes'] = mci_issue_get_notes($p_issue_data->id); $t_issue['custom_fields'] = mci_issue_get_custom_fields($p_issue_data->id); $t_issue['tags'] = mci_issue_get_tags_for_bug_id($p_issue_data->id, $p_user_id); $t_issue['monitors'] = mci_account_get_array_by_ids(bug_get_monitors($p_issue_data->id)); return $t_issue; }
/** * Sets the monitors of the specified issue * * <p>This functions performs access level checks and only performs operations which would * modify the existing monitors list.</p> * * @param int $p_issue_id the issue id to set the monitors for * @param int $p_user_id the user which requests the monitor change * @param array $p_monitors An array of arrays with the <em>id</em> field set to the id * of the users which should monitor this issue. */ function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { $t_existing_monitors = bug_get_monitors( $p_issue_id ); $t_monitors = array(); foreach ( $p_monitors as $t_monitor ) $t_monitors[] = $t_monitor['id']; foreach ( $t_monitors as $t_user_id ) { if ( $p_user_id == $t_user_id ) { if ( ! access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ) ) continue; } else { if ( !access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $p_issue_id ) ) continue; } if ( in_array( $p_user_id, $t_existing_monitors) ) continue; bug_monitor( $p_issue_id, $t_user_id); } foreach ( $t_existing_monitors as $t_user_id ) { if ( $p_user_id == $t_user_id ) { if ( ! access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ) ) continue; } else { if ( !access_has_bug_level( config_get( 'monitor_delete_others_bug_threshold' ), $p_issue_id ) ) continue; } if ( in_array( $p_user_id, $t_monitors) ) continue; bug_unmonitor( $p_issue_id, $t_user_id); } }
/** * Sets the monitors of the specified issue * * <p>This functions performs access level checks and only performs operations which would * modify the existing monitors list.</p> * * @param int $p_issue_id the issue id to set the monitors for * @param int $p_user_id the user which requests the monitor change * @param array $p_monitors An array of arrays with the <em>id</em> field set to the id * of the users which should monitor this issue. */ function mci_issue_set_monitors($p_issue_id, $p_requesting_user_id, $p_monitors) { if (bug_is_readonly($p_issue_id)) { return mci_soap_fault_access_denied($p_requesting_user_id, "Issue '{$p_issue_id}' is readonly"); } # 1. get existing monitor ids $t_existing_monitor_ids = bug_get_monitors($p_issue_id); # 2. build new monitors ids $t_new_monitor_ids = array(); foreach ($p_monitors as $t_monitor) { $t_monitor = SoapObjectsFactory::unwrapObject($t_monitor); $t_new_monitor_ids[] = $t_monitor['id']; } # 3. for each of the new monitor ids, add it if it does not already exist foreach ($t_new_monitor_ids as $t_user_id) { if ($p_requesting_user_id == $t_user_id) { if (!access_has_bug_level(config_get('monitor_bug_threshold'), $p_issue_id)) { continue; } } else { if (!access_has_bug_level(config_get('monitor_add_others_bug_threshold'), $p_issue_id)) { continue; } } if (in_array($t_user_id, $t_existing_monitor_ids)) { continue; } bug_monitor($p_issue_id, $t_user_id); } # 4. for each of the existing monitor ids, remove it if it is not found in the new monitor ids foreach ($t_existing_monitor_ids as $t_user_id) { if ($p_requesting_user_id == $t_user_id) { if (!access_has_bug_level(config_get('monitor_bug_threshold'), $p_issue_id)) { continue; } } else { if (!access_has_bug_level(config_get('monitor_delete_others_bug_threshold'), $p_issue_id)) { continue; } } if (in_array($t_user_id, $t_new_monitor_ids)) { continue; } bug_unmonitor($p_issue_id, $t_user_id); } }
/** * Sets the monitors of the specified issue * * <p>This functions performs access level checks and only performs operations which would * modify the existing monitors list.</p> * * @param int $p_issue_id the issue id to set the monitors for * @param int $p_user_id the user which requests the monitor change * @param array $p_monitors An array of arrays with the <em>id</em> field set to the id * of the users which should monitor this issue. */ function mci_issue_set_monitors($p_issue_id, $p_user_id, $p_monitors) { if (bug_is_readonly($p_issue_id)) { return mci_soap_fault_access_denied($p_user_id, "Issue '{$p_issue_id}' is readonly"); } $t_existing_monitors = bug_get_monitors($p_issue_id); $t_monitors = array(); foreach ($p_monitors as $t_monitor) { $t_monitors[] = $t_monitor['id']; } foreach ($t_monitors as $t_user_id) { if ($p_user_id == $t_user_id) { if (!access_has_bug_level(config_get('monitor_bug_threshold'), $p_issue_id)) { continue; } } else { if (!access_has_bug_level(config_get('monitor_add_others_bug_threshold'), $p_issue_id)) { continue; } } if (in_array($p_user_id, $t_existing_monitors)) { continue; } bug_monitor($p_issue_id, $t_user_id); } foreach ($t_existing_monitors as $t_user_id) { if ($p_user_id == $t_user_id) { if (!access_has_bug_level(config_get('monitor_bug_threshold'), $p_issue_id)) { continue; } } else { if (!access_has_bug_level(config_get('monitor_delete_others_bug_threshold'), $p_issue_id)) { continue; } } if (in_array($p_user_id, $t_monitors)) { continue; } bug_unmonitor($p_issue_id, $t_user_id); } }