Skip to content

Commit

Permalink
Merge pull request #70 from buddypress/notifications
Browse files Browse the repository at this point in the history
Adding support for the Notifications Commands
  • Loading branch information
renatonascalves authored Aug 31, 2018
2 parents d5634e1 + e67aef0 commit d05eb1b
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 24 deletions.
14 changes: 14 additions & 0 deletions component.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,18 @@ protected function get_field_id( $field_id ) {
protected function sanitize_string( $type ) {
return strtolower( str_replace( '-', '_', $type ) );
}

/**
* Pull up a random active component.
*
* @since 1.1
*
* @return string
*/
protected function get_random_component() {
$c = buddypress()->active_components;
$ca = $this->get_components_and_actions();

return array_rand( array_flip( array_intersect( array_keys( $c ), array_keys( $ca ) ) ) );
}
}
16 changes: 0 additions & 16 deletions components/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,22 +669,6 @@ public function delete_comment( $args, $assoc_args ) {
}
}

/**
* Pull up a random active component for use in activity items.
*
* @since 1.1
*
* @return string
*/
protected function get_random_component() {
$c = buddypress()->active_components;

// Core components that accept activity items.
$ca = $this->get_components_and_actions();

return array_rand( array_flip( array_intersect( array_keys( $c ), array_keys( $ca ) ) ) );
}

/**
* Get a random type from a component.
*
Expand Down
4 changes: 2 additions & 2 deletions components/buddypress.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class BuddyPress extends BuddypressCommand {
*/
private function command_to_array( $command ) {
$dump = array(
'name' => $command->get_name(),
'name' => $command->get_name(),
'description' => $command->get_shortdesc(),
'longdesc' => $command->get_longdesc(),
'longdesc' => $command->get_longdesc(),
);

foreach ( $command->get_subcommands() as $subcommand ) {
Expand Down
4 changes: 3 additions & 1 deletion components/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function _list( $args, $assoc_args ) {
// Inactive components.
$inactive_components = array_diff( array_keys( $components ), array_keys( $active_components ) );

$current_components = array();
$current_components = array();
switch ( $status ) {
case 'all':
$index = 0;
Expand All @@ -219,6 +219,7 @@ public function _list( $args, $assoc_args ) {
$index++;

$info = $components[ $component ];

$current_components[] = array(
'number' => $index,
'id' => $component,
Expand All @@ -235,6 +236,7 @@ public function _list( $args, $assoc_args ) {
$index++;

$info = $components[ $component ];

$current_components[] = array(
'number' => $index,
'id' => $component,
Expand Down
8 changes: 4 additions & 4 deletions components/friend.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public function remove( $args, $assoc_args ) {
*
* ## EXAMPLES
*
* $ wp bp friend accept_invitation 2161
* $ wp bp friend accept-invitation 2161
* Success: Friendship successfully accepted.
*
* $ wp bp friend accept 2161
* Success: Friendship successfully accepted.
*
* @alias accept_invitation
* @alias accept-invitation
*/
public function accept( $args, $assoc_args ) {
foreach ( $args as $friendship_id ) {
Expand All @@ -158,13 +158,13 @@ public function accept( $args, $assoc_args ) {
*
* ## EXAMPLES
*
* $ wp bp friend reject_invitation 2161
* $ wp bp friend reject-invitation 2161
* Success: Friendship successfully accepted.
*
* $ wp bp friend reject 2161 151 2121
* Success: Friendship successfully accepted.
*
* @alias reject_invitation
* @alias reject-invitation
*/
public function reject( $args, $assoc_args ) {
foreach ( $args as $friendship_id ) {
Expand Down
Loading

0 comments on commit d05eb1b

Please sign in to comment.