-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpgp.xmlrpc.php
178 lines (148 loc) · 5.06 KB
/
wpgp.xmlrpc.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php /* -*- Mode: php; c-basic-offset:4; -*- */
/* Copyright (C) 2012 Governo do Estado do Rio Grande do Sul
*
* Author: Lincoln de Sousa <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function wpgp_govr_getThemes($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_themes($args[1]);
}
function wpgp_govr_createContrib($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
/* Reading args */
return wpgp_db_govr_create_contrib(
$args[1], // title
$args[2], // themeid
$args[3], // content
$args[4], // userid
$args[5], // part
$args[6], // moderation
$args[7] // parent
);
}
function wpgp_govr_getTheme($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_theme($args[1]);
}
function wpgp_govr_getContrib($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_contrib($args[1], $args[2]);
}
function wpgp_govr_contribIsAggregated($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_contrib_is_aggregated($args[1]);
}
function wpgp_govr_getContribs($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_contribs(
$args[1], // theme_id
$args[2], // user_id
$args[3], // page
$args[4], // sortby
$args[5], // from
$args[6], // to
$args[7], // status
$args[8], // filter
$args[9] ? $args[9] : WPGP_RESULTS_PER_PAGE, // perpage
$args[10]
);
}
function wpgp_govr_getVotingContribs($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_voting_contribs(
$args[1], // theme_id
$args[2], // user_id
$args[3], // page
$args[4], // sortby
$args[5], // from
$args[6], // to
$args[7] ? $args[7] : WPGP_RESULTS_PER_PAGE // perpage
);
}
function wpgp_govr_getAggregatedContribs($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_aggregated_contribs($args[1]);
}
function wpgp_govr_contribUserCanVote($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_contrib_user_can_vote($args[1], $args[2]);
}
function wpgp_govr_contribVote($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_contrib_vote($args[1], $args[2]);
}
function wpgp_govr_getContribScore($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_contrib_score($args[1]);
}
function wpgp_govr_getUserStats($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_govr_get_user_stats($args[1]);
}
function wpgp_gove_getAudiences($args) {
if (!is_array($args = _exapi_method_header($args))) {
return $args;
}
return wpgp_db_gove_audience_list(
$args[1], /* sortby */
$args[2], /* search */
$args[3], /* filter */
$args[4], /* page */
$args[5] ? $args[5] : WPGP_RESULTS_PER_PAGE /* perpage */
);
}
/* Filter that registers our methods in the wordpress xmlrpc provider */
add_filter('xmlrpc_methods', function ($methods) {
$methods['govr.getTheme'] = 'wpgp_govr_getTheme';
$methods['govr.getThemes'] = 'wpgp_govr_getThemes';
$methods['govr.createContrib'] = 'wpgp_govr_createContrib';
$methods['govr.getContrib'] = 'wpgp_govr_getContrib';
$methods['govr.getContribs'] = 'wpgp_govr_getContribs';
$methods['govr.getVotingContribs'] = 'wpgp_govr_getVotingContribs';
$methods['govr.getAggregatedContribs'] = 'wpgp_govr_getAggregatedContribs';
$methods['govr.contribVote'] = 'wpgp_govr_contribVote';
$methods['govr.contribUserCanVote'] = 'wpgp_govr_contribUserCanVote';
$methods['govr.getContribScore'] = 'wpgp_govr_getContribScore';
$methods['govr.contribIsAggregated'] = 'wpgp_govr_contribIsAggregated';
$methods['govr.getUserStats'] = 'wpgp_govr_getUserStats';
$methods['gove.getAudiences'] = 'wpgp_gove_getAudiences';
return $methods;
});
?>