1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * BPDEV XMLRPC Classes |
---|
5 | * |
---|
6 | * Classes to add extra XMLRPC features |
---|
7 | * |
---|
8 | * @package BPDEV-Plugins |
---|
9 | * @subpackage BPDEV-XMLRPC |
---|
10 | * @link http://bp-dev.org/plugins/bpdev-xmlrpc |
---|
11 | * |
---|
12 | * @since 0.3 |
---|
13 | * @author Nicola Greco (notsecurity@gmail.com) |
---|
14 | * @thanks Burt Adsit for his code bpGroups |
---|
15 | * @thanks Beau Lebens for his support |
---|
16 | * |
---|
17 | */ |
---|
18 | |
---|
19 | require_once( ABSPATH . WPINC . '/class-IXR.php' ); |
---|
20 | |
---|
21 | class BPDEV_XMLRPC { |
---|
22 | |
---|
23 | /** |
---|
24 | * BPDEV_XMLRPC::query() |
---|
25 | * |
---|
26 | * Query the xmlrpc server. |
---|
27 | * |
---|
28 | * Send queries to another xmlrpc server |
---|
29 | * |
---|
30 | * @param string $xmlrpc_url |
---|
31 | * @param string $method |
---|
32 | * @param mixed $args |
---|
33 | * @param array $user |
---|
34 | * |
---|
35 | */ |
---|
36 | function query ( $xmlrpc_url, $method, $args = array(), $debug = false ) { |
---|
37 | |
---|
38 | if ( !$method ) |
---|
39 | return false; |
---|
40 | |
---|
41 | $client = new IXR_Client( $xmlrpc_url ); |
---|
42 | $client->debug = $debug; |
---|
43 | $client->timeout = 3; |
---|
44 | $client->useragent .= ' -- BPDEV XMLRPC Client /0.3'; |
---|
45 | |
---|
46 | if ( !is_array( $args ) ) |
---|
47 | $args = array(); |
---|
48 | |
---|
49 | if ( !$client->query( $method, $args ) ) |
---|
50 | die( 'Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage() ); |
---|
51 | |
---|
52 | return $client->getResponse(); |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * BPDEV_XMLRPC::add_method() |
---|
58 | * |
---|
59 | * Add method to xmlrpc |
---|
60 | * |
---|
61 | * Add new method that will be added to the wp ones |
---|
62 | * |
---|
63 | * @param string $method |
---|
64 | * @param string $callback |
---|
65 | * |
---|
66 | */ |
---|
67 | function add_method ( $method, $callback ) { |
---|
68 | |
---|
69 | global $bp; |
---|
70 | |
---|
71 | $bp->xmlrpc->methods["{$method}"] = $callback; |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * BPDEV_XMLRPC::methods() |
---|
77 | * |
---|
78 | * Load methods and add them to wp ones |
---|
79 | * |
---|
80 | * Adds methods stored with add_method() to wp |
---|
81 | * |
---|
82 | * @param array $methods |
---|
83 | * |
---|
84 | */ |
---|
85 | function methods ( $methods ) { |
---|
86 | |
---|
87 | global $bp; |
---|
88 | |
---|
89 | if ( !is_array( $bp->xmlrpc->methods ) ) |
---|
90 | $bp->xmlrpc->methods = array(); |
---|
91 | |
---|
92 | do_action( 'bpdev_xmlrpc_methods' ); |
---|
93 | |
---|
94 | $methods = array_merge( $methods, $bp->xmlrpc->methods ); |
---|
95 | |
---|
96 | return $methods; |
---|
97 | |
---|
98 | } |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | class BPDEV_XMLRPC_User { |
---|
103 | |
---|
104 | /** |
---|
105 | * BPDEV_XMLRPC_User::method() |
---|
106 | * |
---|
107 | * Add methods to XMLRPC |
---|
108 | * |
---|
109 | * Adds new methods for users to Wordpress XMLRPC Server |
---|
110 | * |
---|
111 | * @uses BPDEV_XMLRPC::add_method() Adds new method to WP XMLRPC Server |
---|
112 | * |
---|
113 | */ |
---|
114 | function methods () { |
---|
115 | |
---|
116 | BPDEV_XMLRPC::add_method( 'bp.editXProfile', array( 'BPDEV_XMLRPC_User', 'edit_xprofile' ) ); |
---|
117 | |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * BPDEV_XMLRPC::authenticate() |
---|
122 | * |
---|
123 | * Check if a user and password are ok |
---|
124 | * |
---|
125 | * @param string $user_login |
---|
126 | * @param string $user_pass |
---|
127 | * |
---|
128 | */ |
---|
129 | function authenticate ( $user_login, $user_pass ) { |
---|
130 | |
---|
131 | if ( !get_option( 'enable_xmlrpc' ) ) { |
---|
132 | // $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); |
---|
133 | return false; |
---|
134 | } |
---|
135 | |
---|
136 | if ( !user_pass_ok( $user_login, $user_pass ) ) { |
---|
137 | // $this->error = new IXR_Error(403, __('Bad login/pass combination.')); |
---|
138 | return false; |
---|
139 | } |
---|
140 | |
---|
141 | return true; |
---|
142 | |
---|
143 | } |
---|
144 | |
---|
145 | function edit_xprofile ( $args ) { |
---|
146 | } |
---|
147 | |
---|
148 | } |
---|
149 | add_action( 'bpdev_xmlrpc_methods', array( 'BPDEV_XMLRPC_User', 'methods' ) ); |
---|
150 | |
---|
151 | class BPDEV_XMLRPC_Groups { |
---|
152 | |
---|
153 | function methods() { |
---|
154 | |
---|
155 | /* Passive */ |
---|
156 | BPDEV_XMLRPC::add_method( 'bp.getGroup', array( 'BPDEV_XMLRPC_Groups', 'get_group' ) ); |
---|
157 | BPDEV_XMLRPC::add_method( 'bp.getGroupMembers', array( 'BPDEV_XMLRPC_Groups', 'get_members' ) ); |
---|
158 | BPDEV_XMLRPC::add_method( 'bp.getGroupNews', array( 'BPDEV_XMLRPC_Groups', 'get_news' ) ); |
---|
159 | BPDEV_XMLRPC::add_method( 'bp.getGroupDescription', array( 'BPDEV_XMLRPC_Groups', 'get_description' ) ); |
---|
160 | BPDEV_XMLRPC::add_method( 'bp.getGroupMeta', array( 'BPDEV_XMLRPC_Groups', 'get_meta' ) ); |
---|
161 | |
---|
162 | /* Active */ |
---|
163 | BPDEV_XMLRPC::add_method( 'bp.newGroup', array( 'BPDEV_XMLRPC_Groups', 'create_group' ) ); |
---|
164 | BPDEV_XMLRPC::add_method( 'bp.setGroupNews', array( 'BPDEV_XMLRPC_Groups', 'set_news' ) ); |
---|
165 | BPDEV_XMLRPC::add_method( 'bp.setGroupDescription', array( 'BPDEV_XMLRPC_Groups', 'set_description' ) ); |
---|
166 | BPDEV_XMLRPC::add_method( 'bp.setGroupName', array( 'BPDEV_XMLRPC_Groups', 'set_name' ) ); |
---|
167 | BPDEV_XMLRPC::add_method( 'bp.delGroup', array( 'BPDEV_XMLRPC_Groups', 'delete_group' ) ); |
---|
168 | BPDEV_XMLRPC::add_method( 'bp.newGroupWire', array( 'BPDEV_XMLRPC_Groups', 'post_wire' ) ); |
---|
169 | |
---|
170 | } |
---|
171 | /** |
---|
172 | * BPDEV_XMLRPC_Groups::get_group() |
---|
173 | * |
---|
174 | * Get all datas for the group_id |
---|
175 | * |
---|
176 | * @param array ( 'username', 'password', group_id ) |
---|
177 | * @return object $group All datas for the group_id |
---|
178 | * |
---|
179 | */ |
---|
180 | function get_group ( $args = array( 'username', 'password', 'group_id' ) ) { |
---|
181 | |
---|
182 | $user_login = $args[0]; |
---|
183 | $user_pass = $args[1]; |
---|
184 | $group_id = (int)$args[2]; |
---|
185 | |
---|
186 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
187 | |
---|
188 | $group = new BP_Groups_Group( (int)$group_id ); |
---|
189 | |
---|
190 | return $group; |
---|
191 | |
---|
192 | } |
---|
193 | |
---|
194 | /** |
---|
195 | * BPDEV_XMLRPC_Groups::get_members() |
---|
196 | * |
---|
197 | * Get the members count of group_id |
---|
198 | * |
---|
199 | * @param array ( 'username', 'password', group_id ) |
---|
200 | * @return string Members Count |
---|
201 | * |
---|
202 | */ |
---|
203 | function get_members ( $args = array( 'username', 'password', 'group_id' ) ) { |
---|
204 | |
---|
205 | $user_login = $args[0]; |
---|
206 | $user_pass = $args[1]; |
---|
207 | $group_id = (int)$args[2]; |
---|
208 | |
---|
209 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
210 | |
---|
211 | $members = groups_get_groupmeta( (int)$group_id , 'total_member_count' ); |
---|
212 | |
---|
213 | return $members; |
---|
214 | |
---|
215 | } |
---|
216 | |
---|
217 | /** |
---|
218 | * BPDEV_XMLRPC_Groups::get_news() |
---|
219 | * |
---|
220 | * Get the news field for the group_id |
---|
221 | * |
---|
222 | * @param array ( 'username', 'password', group_id ) |
---|
223 | * @return string News |
---|
224 | * |
---|
225 | */ |
---|
226 | function get_news( $args = array( 'username', 'password', 'group_id' ) ) { |
---|
227 | |
---|
228 | $user_login = $args[0]; |
---|
229 | $user_pass = $args[1]; |
---|
230 | $group_id = (int)$args[2]; |
---|
231 | |
---|
232 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
233 | |
---|
234 | $group = self::get_group( $args ); |
---|
235 | $news = $group->news; |
---|
236 | |
---|
237 | return $news; |
---|
238 | |
---|
239 | } |
---|
240 | |
---|
241 | /** |
---|
242 | * BPDEV_XMLRPC_Groups::get_description() |
---|
243 | * |
---|
244 | * Get the description field for the group_id |
---|
245 | * |
---|
246 | * @param array ( 'username', 'password', group_id ) |
---|
247 | * @return string Description |
---|
248 | * |
---|
249 | */ |
---|
250 | function get_description ( $args = array( 'username', 'password', 'group_id' ) ) { |
---|
251 | |
---|
252 | $user_login = $args[0]; |
---|
253 | $user_pass = $args[1]; |
---|
254 | $group_id = (int)$args[2]; |
---|
255 | |
---|
256 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
257 | |
---|
258 | $group = self::get_group( $args ); |
---|
259 | $description = $group->description; |
---|
260 | |
---|
261 | return $description; |
---|
262 | |
---|
263 | } |
---|
264 | /** |
---|
265 | * BPDEV_XMLRPC_Groups::get_meta() |
---|
266 | * |
---|
267 | * Get the meta value you asked or all meta values |
---|
268 | * |
---|
269 | * @param array ( 'username', 'password', group_id [, 'meta_key'] ) |
---|
270 | * @return string|array |
---|
271 | * |
---|
272 | */ |
---|
273 | function get_meta ( $args = array( 'username', 'password', 'group_id', 'meta_key' ) ) { |
---|
274 | |
---|
275 | $user_login = $args[0]; |
---|
276 | $user_pass = $args[1]; |
---|
277 | $group_id = (int)$args[2]; |
---|
278 | |
---|
279 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
280 | |
---|
281 | if ( $meta = groups_get_groupmeta( (int)$group_id, $meta_key ) ) |
---|
282 | return $meta; |
---|
283 | |
---|
284 | return false; |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | /** |
---|
289 | * BPDEV_XMLRPC_Groups::create_group() |
---|
290 | * |
---|
291 | * Create a new group |
---|
292 | * |
---|
293 | * @param array ( 'username', 'password', 'group_name', 'group_description', 'group_news', ['status', 'wire_settings', 'forum_settings'] ) |
---|
294 | * @return bool |
---|
295 | * |
---|
296 | */ |
---|
297 | function create_group ( $args = array( 'username', 'password', 'group_name', 'group_description', 'group_news', 'status', 'wire_settings', 'forum_settings' ) ) { |
---|
298 | |
---|
299 | $user_login = $args[0]; |
---|
300 | $user_pass = $args[1]; |
---|
301 | |
---|
302 | if ( !isset( $args[2] ) || !isset( $args[3] ) || !isset( $args[4] ) ) return false; |
---|
303 | |
---|
304 | $group_name = $args[2]; |
---|
305 | $group_description = $args[3]; |
---|
306 | $group_news = $args[4]; |
---|
307 | $group_status = ( '' != $args[5] ) ? $args[5] : 'public'; |
---|
308 | $wire_settings = ( '' != $args[6] ) ? (int)$args[6] : 1; |
---|
309 | $forum_settings = ( '' != $args[7] ) ? (int)$args[7] : 1; |
---|
310 | |
---|
311 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
312 | |
---|
313 | $user = get_userdatabylogin( $user_login ); |
---|
314 | |
---|
315 | $group_obj = new BP_Groups_Group( $group_id ); |
---|
316 | $group_obj->creator_id = $bp->loggedin_user->id; |
---|
317 | $group_obj->name = stripslashes( $group_name ); |
---|
318 | $group_obj->description = stripslashes( $group_description ); |
---|
319 | $group_obj->news = stripslashes( $group_news ); |
---|
320 | |
---|
321 | $slug = groups_check_slug( sanitize_title( $group_name ) ); |
---|
322 | |
---|
323 | $group_obj->slug = $slug; |
---|
324 | |
---|
325 | if ( 'private' == $_POST['group-status'] ) |
---|
326 | $group_obj->status = 'private'; |
---|
327 | else if ( 'hidden' == $_POST['group-status'] ) |
---|
328 | $group_obj->status = 'hidden'; |
---|
329 | else |
---|
330 | $group_obj->status = 'public'; |
---|
331 | |
---|
332 | $group_obj->is_invitation_only = 0; |
---|
333 | $group_obj->enable_wire = $wire_settings; |
---|
334 | $group_obj->enable_forum = $forum_settings; |
---|
335 | $group_obj->enable_photos = 1; |
---|
336 | $group_obj->photos_admin_only = 0; |
---|
337 | $group_obj->date_created = time(); |
---|
338 | |
---|
339 | if ( !$group_obj->save() ) return false; |
---|
340 | |
---|
341 | // Save the creator as the group administrator |
---|
342 | $admin = new BP_Groups_Member( $user->ID, $group_obj->id ); |
---|
343 | $admin->is_admin = 1; |
---|
344 | $admin->user_title = __('Group Admin', 'buddypress'); |
---|
345 | $admin->date_modified = time(); |
---|
346 | $admin->inviter_id = 0; |
---|
347 | $admin->is_confirmed = 1; |
---|
348 | |
---|
349 | if ( !$admin->save() ) return false; |
---|
350 | |
---|
351 | /* Set groupmeta */ |
---|
352 | groups_update_groupmeta( $group_obj->id, 'total_member_count', 1 ); |
---|
353 | groups_update_groupmeta( $group_obj->id, 'last_activity', time() ); |
---|
354 | groups_update_groupmeta( $group_obj->id, 'theme', 'buddypress' ); |
---|
355 | groups_update_groupmeta( $group_obj->id, 'stylesheet', 'buddypress' ); |
---|
356 | |
---|
357 | |
---|
358 | if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group_obj->id, 'forum_id' ) ) |
---|
359 | groups_new_group_forum(); |
---|
360 | |
---|
361 | if ( !$group_obj->save() ) return false; |
---|
362 | |
---|
363 | /* Record in activity streams */ |
---|
364 | groups_record_activity( array( 'item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'is_private' => 0 ) ); |
---|
365 | |
---|
366 | //do_action( 'groups_create_group_step2_save' ); |
---|
367 | |
---|
368 | if ( !$group_obj->save() ) return false; |
---|
369 | |
---|
370 | //do_action( 'groups_create_group_step3_save' ); |
---|
371 | |
---|
372 | groups_send_invites( $group_obj, true ); |
---|
373 | |
---|
374 | do_action( 'groups_created_group', $group_obj->id ); |
---|
375 | |
---|
376 | return $group_obj; |
---|
377 | |
---|
378 | } |
---|
379 | |
---|
380 | /** |
---|
381 | * BPDEV_XMLRPC_Groups::set_news() |
---|
382 | * |
---|
383 | * Set the group news |
---|
384 | * |
---|
385 | * @param array ( 'username', 'password', 'group_id', 'news' [, 'notify'] ) |
---|
386 | * @return bool |
---|
387 | * |
---|
388 | */ |
---|
389 | function set_news ( $args = array( 'username', 'password', 'group_id', 'news', 'notify' ) ) { |
---|
390 | |
---|
391 | $user_login = $args[0]; |
---|
392 | $user_pass = $args[1]; |
---|
393 | $group_id = (int)$args[2]; |
---|
394 | $group_news = $args[3]; |
---|
395 | $notify_members = ( '' != $args[4] ) ? (int)$args[4] : 0; |
---|
396 | |
---|
397 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
398 | $user = get_userdatabylogin( $user_login ); |
---|
399 | if ( !groups_is_group_admin( $user->ID, $group_id ) ) return false; |
---|
400 | |
---|
401 | $group = new BP_Groups_Group( $group_id, false, false ); |
---|
402 | $group->news = $group_news; |
---|
403 | |
---|
404 | if ( !$group->save() ) return false; |
---|
405 | |
---|
406 | if ( $notify_members ) { |
---|
407 | require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); |
---|
408 | groups_notification_group_updated( $group->id ); |
---|
409 | } |
---|
410 | |
---|
411 | return $group; |
---|
412 | |
---|
413 | } |
---|
414 | |
---|
415 | /** |
---|
416 | * BPDEV_XMLRPC_Groups::set_description() |
---|
417 | * |
---|
418 | * Set the group description |
---|
419 | * |
---|
420 | * @param array ( 'username', 'password', 'group_id', 'description' [, 'notify'] ) |
---|
421 | * @return bool |
---|
422 | * |
---|
423 | */ |
---|
424 | function set_description ( $args = array( 'username', 'password', 'group_id', 'description', 'notify' ) ) { |
---|
425 | |
---|
426 | $user_login = $args[0]; |
---|
427 | $user_pass = $args[1]; |
---|
428 | $group_id = (int)$args[2]; |
---|
429 | $group_description = $args[3]; |
---|
430 | $notify_members = ( '' != $args[4] ) ? (int)$args[4] : 0; |
---|
431 | |
---|
432 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
433 | $user = get_userdatabylogin( $user_login ); |
---|
434 | if ( !groups_is_group_admin( $user->ID, $group_id ) ) return false; |
---|
435 | |
---|
436 | $group = new BP_Groups_Group( $group_id, false, false ); |
---|
437 | $group->description = $group_description; |
---|
438 | |
---|
439 | if ( !$group->save() ) return false; |
---|
440 | |
---|
441 | if ( $notify_members ) { |
---|
442 | require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); |
---|
443 | groups_notification_group_updated( $group->id ); |
---|
444 | } |
---|
445 | |
---|
446 | return $group; |
---|
447 | |
---|
448 | } |
---|
449 | |
---|
450 | /** |
---|
451 | * BPDEV_XMLRPC_Groups::set_name() |
---|
452 | * |
---|
453 | * Set the group name |
---|
454 | * |
---|
455 | * @param array ( 'username', 'password', 'group_id', 'name' [, 'notify'] ) |
---|
456 | * @return bool |
---|
457 | * |
---|
458 | */ |
---|
459 | function set_name ( $args = array( 'username', 'password', 'group_id', 'name', 'notify' ) ) { |
---|
460 | |
---|
461 | $user_login = $args[0]; |
---|
462 | $user_pass = $args[1]; |
---|
463 | $group_id = (int)$args[2]; |
---|
464 | $group_name = $args[3]; |
---|
465 | $notify_members = ( '' != $args[4] ) ? (int)$args[4] : 0; |
---|
466 | |
---|
467 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
468 | $user = get_userdatabylogin( $user_login ); |
---|
469 | if ( !groups_is_group_admin( $user->ID, $group_id ) ) return false; |
---|
470 | |
---|
471 | $group = new BP_Groups_Group( $group_id, false, false ); |
---|
472 | $group->name = $group_name; |
---|
473 | |
---|
474 | if ( !$group->save() ) return false; |
---|
475 | |
---|
476 | if ( $notify_members ) { |
---|
477 | require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); |
---|
478 | groups_notification_group_updated( $group->id ); |
---|
479 | } |
---|
480 | |
---|
481 | return $group; |
---|
482 | |
---|
483 | } |
---|
484 | |
---|
485 | /** |
---|
486 | * BPDEV_XMLRPC_Groups::delete_group() |
---|
487 | * |
---|
488 | * Delete the group_id group |
---|
489 | * |
---|
490 | * @param array ( 'username', 'password', group_id ) |
---|
491 | * @return bool |
---|
492 | * |
---|
493 | */ |
---|
494 | function delete_group ( $args = array( 'username', 'password', 'group_id' ) ) { |
---|
495 | |
---|
496 | $user_login = $args[0]; |
---|
497 | $user_pass = $args[1]; |
---|
498 | $group_id = (int)$args[2]; |
---|
499 | |
---|
500 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
501 | $user = get_userdatabylogin( $user_login ); |
---|
502 | if ( !groups_is_group_admin( $user->ID, $group_id ) ) return false; |
---|
503 | |
---|
504 | $group = new BP_Groups_Group( $group_id, false, false ); |
---|
505 | |
---|
506 | if ( !$group->delete() ) return false; |
---|
507 | |
---|
508 | do_action( 'groups_group_deleted', $group_id ); |
---|
509 | |
---|
510 | return $group_id; |
---|
511 | |
---|
512 | } |
---|
513 | |
---|
514 | /** |
---|
515 | * BPDEV_XMLRPC_Groups::post_wire() |
---|
516 | * |
---|
517 | * Post on the group wire |
---|
518 | * |
---|
519 | * @param array ( 'username', 'password', 'group_id', 'wire_content' ) |
---|
520 | * @return bool |
---|
521 | * |
---|
522 | */ |
---|
523 | function post_wire ( $args = array( 'username', 'password', 'group_id', 'wire_content' ) ) { |
---|
524 | |
---|
525 | $user_login = $args[0]; |
---|
526 | $user_pass = $args[1]; |
---|
527 | $group_id = (int)$args[2]; |
---|
528 | |
---|
529 | if ( isset( $args[3] ) && $args[3] ) |
---|
530 | $wire_content = $args[3]; |
---|
531 | else |
---|
532 | return false; |
---|
533 | |
---|
534 | if ( !BPDEV_XMLRPC_User::authenticate ( $user_login, $user_pass ) ) return false; |
---|
535 | $user = get_userdatabylogin( $user_login ); |
---|
536 | if ( !BP_Groups_Member::check_is_member( $user->ID, $group_id ) ) return false; |
---|
537 | |
---|
538 | // Check if the group is private |
---|
539 | $private = false; |
---|
540 | if ( $group_obj->status != 'public' ) |
---|
541 | $private = true; |
---|
542 | |
---|
543 | // Post the wire |
---|
544 | if ( $wire_post_id = bp_wire_new_post( $group_id, $content, $bp->groups->slug, $private ) ) { |
---|
545 | |
---|
546 | do_action( 'groups_new_wire_post', $group_id, $wire_post_id ); |
---|
547 | return $wire_post_id; |
---|
548 | } |
---|
549 | |
---|
550 | return false; |
---|
551 | |
---|
552 | |
---|
553 | } |
---|
554 | |
---|
555 | } |
---|
556 | |
---|
557 | ?> |
---|