[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # MantisConnect - A webservice interface to Mantis Bug Tracker 3 # Copyright (C) 2004-2007 Victor Boctor - vboctor@users.sourceforge.net 4 # This program is distributed under dual licensing. These include 5 # GPL and a commercial licenses. Victor Boctor reserves the right to 6 # change the license of future releases. 7 # See docs/ folder for more details 8 9 # -------------------------------------------------------- 10 # $Id: mc_filter_api.php,v 1.1 2007-07-18 06:52:55 vboctor Exp $ 11 # -------------------------------------------------------- 12 13 /** 14 * Get all user defined issue filters for the given project. 15 * 16 * @param string $p_username The name of the user trying to access the filters. 17 * @param string $p_password The password of the user. 18 * @param integer $p_project_id The id of the project to retrieve filters for. 19 * @return Array that represents a FilterDataArray structure 20 */ 21 function mc_filter_get( $p_username, $p_password, $p_project_id ) { 22 $t_user_id = mci_check_login( $p_username, $p_password ); 23 if ( $t_user_id === false ) { 24 return new soap_fault( 'Client', '', 'Access Denied' ); 25 } 26 if ( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) { 27 return new soap_fault( 'Client', '', 'Access Denied' ); 28 } 29 $t_result = array(); 30 foreach( filter_db_get_available_queries( $p_project_id, $t_user_id ) as $t_filter_row ) { 31 $t_filter = array(); 32 $t_filter['id'] = $t_filter_row['id']; 33 $t_filter['owner'] = mci_account_get_array_by_id( $t_filter_row['user_id'] ); 34 $t_filter['project_id'] = $t_filter_row['project_id']; 35 $t_filter['is_public'] = $t_filter_row['is_public']; 36 $t_filter['name'] = $t_filter_row['name']; 37 $t_filter['filter_string'] = $t_filter_row['filter_string']; 38 $t_result[] = $t_filter; 39 } 40 return $t_result; 41 } 42 43 44 /** 45 * Get all issues matching the specified filter. 46 * 47 * @param string $p_username The name of the user trying to access the filters. 48 * @param string $p_password The password of the user. 49 * @param integer $p_filter_id The id of the filter to apply. 50 * @param integer $p_page_number Start with the given page number (zero-based) 51 * @param integer $p_per_page Number of issues to display per page 52 * @return Array that represents an IssueDataArray structure 53 */ 54 function mc_filter_get_issues( $p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page ) { 55 $t_user_id = mci_check_login( $p_username, $p_password ); 56 $t_lang = mci_get_user_lang( $t_user_id ); 57 if ( $t_user_id === false ) { 58 return new soap_fault( 'Client', '', 'Access Denied' ); 59 } 60 if ( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) { 61 return new soap_fault( 'Client', '', 'Access Denied' ); 62 } 63 64 $t_page_count = 0; 65 $t_bug_count = 0; 66 $t_filter = filter_db_get_filter( $p_filter_id ); 67 $t_filter_detail = explode( '#', $t_filter, 2 ); 68 if ( !isset( $t_filter_detail[1] ) ) { 69 return new soap_fault( 'Server', '', 'Invalid Filter' ); 70 } 71 $t_filter = unserialize( $t_filter_detail[1] ); 72 $t_filter = filter_ensure_valid_filter( $t_filter ); 73 74 $t_result = array(); 75 $t_rows = filter_get_bug_rows( $p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id ); 76 foreach( $t_rows as $t_issue_data ) { 77 $t_id = $t_issue_data['id']; 78 79 $t_issue = array(); 80 $t_issue['id'] = $t_id; 81 $t_issue['view_state'] = mci_enum_get_array_by_id( $t_issue_data['view_state'], 'view_state', $t_lang); 82 $t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] ); 83 84 $t_issue['project'] = mci_project_as_array_by_id( $t_issue_data['project_id'] ); 85 $t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] ); 86 $t_issue['priority'] = mci_enum_get_array_by_id( $t_issue_data['priority'], 'priority', $t_lang ); 87 $t_issue['severity'] = mci_enum_get_array_by_id( $t_issue_data['severity'], 'severity', $t_lang ); 88 $t_issue['status'] = mci_enum_get_array_by_id( $t_issue_data['status'], 'status', $t_lang ); 89 90 $t_issue['reporter'] = mci_account_get_array_by_id( $t_issue_data['reporter_id'] ); 91 $t_issue['summary'] = $t_issue_data['summary']; 92 $t_issue['version'] = mci_null_if_empty( $t_issue_data['version'] ); 93 $t_issue['build'] = mci_null_if_empty( $t_issue_data['build'] ); 94 $t_issue['platform'] = mci_null_if_empty( $t_issue_data['platform'] ); 95 $t_issue['os'] = mci_null_if_empty( $t_issue_data['os'] ); 96 $t_issue['os_build'] = mci_null_if_empty( $t_issue_data['os_build'] ); 97 $t_issue['reproducibility'] = mci_enum_get_array_by_id( $t_issue_data['reproducibility'], 'reproducibility', $t_lang ); 98 $t_issue['date_submitted'] = timestamp_to_iso8601( $t_issue_data['date_submitted'] ); 99 $t_issue['sponsorship_total'] = $t_issue_data['sponsorship_total']; 100 101 if( !empty( $t_issue_data['handler_id'] ) ) { 102 $t_issue['handler'] = mci_account_get_array_by_id( $t_issue_data['handler_id'] ); 103 } 104 $t_issue['projection'] = mci_enum_get_array_by_id( $t_issue_data['projection'], 'projection', $t_lang ); 105 $t_issue['eta'] = mci_enum_get_array_by_id( $t_issue_data['eta'], 'eta', $t_lang ); 106 107 $t_issue['resolution'] = mci_enum_get_array_by_id( $t_issue_data['resolution'], 'resolution', $t_lang ); 108 $t_issue['fixed_in_version'] = mci_null_if_empty( $t_issue_data['fixed_in_version'] ); 109 110 $t_issue['description'] = bug_get_text_field( $t_id, 'description' ); 111 112 $t_steps_to_reproduce = bug_get_text_field( $t_id, 'steps_to_reproduce' ); 113 $t_issue['steps_to_reproduce'] = mci_null_if_empty( $t_steps_to_reproduce ); 114 115 $t_additional_information = bug_get_text_field( $t_id, 'additional_information' ); 116 $t_issue['additional_information'] = mci_null_if_empty( $t_additional_information ); 117 118 $t_issue['attachments'] = mci_issue_get_attachments( $t_issue_data['id'] ); 119 $t_issue['relationships'] = mci_issue_get_relationships( $t_issue_data['id'], $t_issue_id ); 120 $t_issue['notes'] = mci_issue_get_notes( $t_issue_data['id'] ); 121 $t_issue['custom_fields'] = mci_issue_get_custom_fields( $t_issue_data['id'] ); 122 123 $t_result[] = $t_issue; 124 } 125 126 return $t_result; 127 } 128 129 /** 130 * Get the issue headers that match the specified filter and paging details. 131 * 132 * @param string $p_username The name of the user trying to access the filters. 133 * @param string $p_password The password of the user. 134 * @param integer $p_filter_id The id of the filter to apply. 135 * @param integer $p_page_number Start with the given page number (zero-based) 136 * @param integer $p_per_page Number of issues to display per page 137 * @return Array that represents an IssueDataArray structure 138 */ 139 function mc_filter_get_issue_headers( $p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page ) { 140 $t_user_id = mci_check_login( $p_username, $p_password ); 141 if ( $t_user_id === false ) { 142 return new soap_fault( 'Client', '', 'Access Denied' ); 143 } 144 if ( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) { 145 return new soap_fault( 'Client', '', 'Access Denied' ); 146 } 147 148 $t_page_count = 0; 149 $t_bug_count = 0; 150 $t_filter = filter_db_get_filter( $p_filter_id ); 151 $t_filter_detail = explode( '#', $t_filter, 2 ); 152 if ( !isset( $t_filter_detail[1] ) ) { 153 return new soap_fault( 'Server', '', 'Invalid Filter' ); 154 } 155 $t_filter = unserialize( $t_filter_detail[1] ); 156 $t_filter = filter_ensure_valid_filter( $t_filter ); 157 158 $t_result = array(); 159 $t_rows = filter_get_bug_rows( $p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id ); 160 foreach( $t_rows as $t_issue_data ) { 161 $t_id = $t_issue_data['id']; 162 163 $t_issue = array(); 164 165 $t_issue['id'] = $t_id; 166 $t_issue['view_state'] = $t_issue_data['view_state']; 167 $t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] ); 168 169 $t_issue['project'] = $t_issue_data['project_id']; 170 $t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] ); 171 $t_issue['priority'] = $t_issue_data['priority']; 172 $t_issue['severity'] = $t_issue_data['severity']; 173 $t_issue['status'] = $t_issue_data['status']; 174 175 $t_issue['reporter'] = $t_issue_data['reporter_id']; 176 $t_issue['summary'] = $t_issue_data['summary']; 177 if( !empty( $t_issue_data['handler_id'] ) ) { 178 $t_issue['handler'] = $t_issue_data['handler_id']; 179 } 180 $t_issue['resolution'] = $t_issue_data['resolution']; 181 182 $t_issue['attachments_count'] = count( mci_issue_get_attachments( $t_issue_data['id'] ) ); 183 $t_issue['notes_count'] = count( mci_issue_get_notes( $t_issue_data['id'] ) ); 184 185 $t_result[] = $t_issue; 186 } 187 188 return $t_result; 189 } 190 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |