-
Notifications
You must be signed in to change notification settings - Fork 709
/
mc_user_profile_api.php
71 lines (60 loc) · 2.31 KB
/
mc_user_profile_api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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/>.
/**
* MantisConnect - A webservice interface to Mantis Bug Tracker
*
* @package MantisBT
* @link http://www.mantisbt.org
*/
/**
* Returns all the profiles for the user, including the global ones
*
* @param string $p_username The user's username
* @param string $p_password The user's password
* @param integer $p_page_number
* @param integer $p_per_page
*
*/
function mc_user_profiles_get_all( $p_username, $p_password, $p_page_number, $p_per_page ) {
$t_user_id = mci_check_login( $p_username, $p_password );
if ( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}
if ( !mci_has_readonly_access( $t_user_id ) ) {
return mci_soap_fault_access_denied( $t_user_id );
}
$t_results = array();
$t_start = max ( array ( 0, $p_page_number - 1 ) ) * $p_per_page;
foreach ( profile_get_all_for_user( $t_user_id ) as $t_profile_row ) {
$t_result = array(
'id' => $t_profile_row['id'],
'description' => $t_profile_row['description'],
'os' => $t_profile_row['os'],
'os_build' => $t_profile_row['os_build'],
'platform' => $t_profile_row['platform']
);
if ( $t_profile_row['user_id'] != 0 )
$t_result['user_id'] = mci_account_get_array_by_id( $t_profile_row['user_id'] );
$t_results[] = $t_result;
}
// the profile_api does not implement pagination in the backend, so we emulate it here
// we can always push the pagination in the database, but this seems unlikely in the
// near future, as the number of profiles is expected to be small
$t_paged_results = array_slice ( $t_results, $t_start, $p_per_page );
return array (
'total_results' => count ( $t_results),
'results' => $t_paged_results
);
}