Skip to:
Content

BuddyPress.org

Opened 15 years ago

Closed 15 years ago

#889 closed enhancement (fixed)

Activity Streams: Requested codebase change for Privacy Component usage

Reported by: jeffsayre's profile jeffsayre Owned by:
Milestone: 1.1 Priority: critical
Severity: Version:
Component: Keywords: privacy component, component_action, activity streams
Cc:

Description

One object type that needs to come under privacy control is activity streams. Activity streams are associated with a particular action that is set in component_action. Currently, there is no practical way of programatically grabbing all activity streams as component_action is a key set in many, different associative arrays that are simply hardcoded in various places.

It would be nice if there was a single place in each component where all possible activity actions (component_actions) are set once.

Here is what I propose. With this change, it makes it possible to establish a series of functions that will allow users to set and control privacy levels for all component_actions in any component that follows this new variable naming scheme.

In function bp_xxx_setup_globals(), add this new line:

/* Sets up the array container for all component actions */
$bp->activity_actions->xxx = array( array( 'first_action', __('translatable displayed action text') ), array(...) ) );

This multi-dimensional array uses a numerical key versus an associative key which allows for easier array element referencing whenever a component_action needs to be referenced.


An example:

In line 480 of bp-blogs.php, notice how all other values are referenced, not hardcoded. Only component_action is hardcoded. This would change that.

Instead of:

bp_blogs_record_activity( array( ... 'component_action' => 'new_blog_comment', ...) );

It would now be:

bp_blogs_record_activity( array( ... 'component_action' => $bp->activity_actions->blogs[2][0], ...) );

Here are all the suggested activity_actions for each BP component. This covers all the component_actions currently referenced in the BP codebase.

$bp->activity_actions->friends = array( array( 'friendship_request', __('Friendship Requested') ), array( 'friendship_accepted', __('Friendship Accepted') ) ); /* Note: currently friendship_request does not get added to activity tables */

$bp->activity_actions->xprofile = array( array( 'updated_profile', __('Updated Profile') ) );

$bp->activity_actions->blogs = array( array( 'new_blog', __('Registered New Blog')), array( 'new_blog_post', __('Made New Blog Post')), array( 'new_blog_comment', __('Made new Blog Comment') ) );

$bp->activity_actions->wire = array( array( 'new_wire_post', __('Posted to Wire') ) );

$bp->activity_actions->messages = array( array( 'message_sent', __('Sent Private Message') ) ); /* Note: currently message_sent does not get added to activity tables */

$bp->activity_actions->groups = array( array( 'joined_group', __('Joined a Group')), array( 'created_group', __('Created a Group')), array( 'new_forum_post', __('Made New Forum Post')), array( 'new_forum_topic', __('Started New Forum Topic') ) );

Change History (7)

#1 @jeffsayre
15 years ago

I can give you a list of all files, line numbers, and changes that need to be made to implement this change.

#2 follow-up: @apeatling
15 years ago

A couple of things off the top of my head right now:

$bp->activity_actions->blogs[2][0]

has no contextual meaning when reading the code. If someone just looks at that, they are going to have no idea what it means.

$bp->activity->actions

Would be better, since this is part of the activity component and is only used if this is active.

#3 in reply to: ↑ 2 @jeffsayre
15 years ago

Replying to apeatling:

A couple of things off the top of my head right now:

$bp->activity_actions->blogs[2][0]

has no contextual meaning when reading the code. If someone just looks at that, they are going to have no idea what it means.

This is true, but these also have little meaning:

$recorded_comment->blog_id --or-- $recorded_commment_id --or-- $friendship->initiator_user_id -- etc.

These are used in the action arrays as well.

Referencing the array numerically offers considerable programmatic advantage as well. Associative arrays are very limiting since you must know the content of the key. In certain places, the use of associative arrays makes it more difficult to extended BP. It also means that you have to hardcode the words into the codebase where ever you need to reference the array. This makes it difficult to extend.

I think developers are sensible enough to understand the meaning of $bp->activity_actions->blogs[2][0]. All they need to do is look in a single place, the global variable definition function, to get their exact answer.


$bp->activity->actions

Would be better, since this is part of the activity component and is only used if this is active.

True. But building on the above comment, if you think that

$bp->activity_actions->blogs[2][0]

is difficult to comprehend, then

$bp->activity->actions[2][0]

will truly be meaningless.

Perhaps it makes sense to give it more meaning like:

$bp->component_actions->blog


Also, there is an advantage to using this mutli-dimensional variable construct

$bp->activity_actions->blogs

This allows anyone writing a plugin to easily access each components actions. Without this, I have no way of easily separating out the component_action groupings for output display: Friends Activities, Xprofile Activities, Blogs Activities, etc.

#4 @jeffsayre
15 years ago

Okay, there is a nice advantage to using the following construct as we discussed on IRC:

$bp->activity->actions->xxx

This does place all activity related actions in the activity object, making it much easier to disable activity stream privacy when the activity component has been disabled by the Site admin.

#5 @jeffsayre
15 years ago

Okay, with your suggestions, Andy, I propose this:

/* Adds to the component actions array container */
$bp->activity_actions->privacy = array( array( 'updated_privacy_settings', __('Updated Privacy Settings') ) );

An example:

$bp->activity->actions->privacy->updated_privacy_settings = array( 'key' => 'updated_privacy_settings', 'value' => __( 'Updated Privacy Settings', 'bp-authz' ) );

#6 @jeffsayre
15 years ago

Obviously, ignore my last post. It was mistaken. Where's the edit button?

Here's what I propose--based on your suggestion:

Basic premise:

 /* Adds your custom component actions to activity action object array --> the array container for all component actions */
 $bp->activity->actions->example->activity_action_here = array( 'key' => 'xxx', 'value' => __( 'xxx', 'example' ) );

An example:

/* Adds to the component actions object array container */
$bp->activity->actions->privacy->updated_privacy_settings = array( 'key' => 'updated_privacy_settings', 'value' => __( 'Updated Privacy Settings', 'bp-authz' ) );

#7 @apeatling
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Added in r1750

Note: See TracTickets for help on using tickets.