Plugin Directory

Changeset 916303


Ignore:
Timestamp:
05/17/2014 11:54:17 PM (12 years ago)
Author:
megainfo
Message:

update to 1.3.3

Location:
buddypress-activity-privacy/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • buddypress-activity-privacy/trunk/history.txt

    r916054 r916303  
    100100- Fix visibility of "Last update" activity on member header and members loop.
    101101- Beta Integration with buddypress-media plugin (rtMedia for WordPress, BuddyPress and bbPress).
     102
     103Version 1.3.3 (May 18, 2014)
     104--------------------------------------------------------------
     105- Fix bugs on integration with rtMedia.
  • buddypress-activity-privacy/trunk/includes/bp-activity-privacy-integrations.php

    r916052 r916303  
    162162
    163163// Integration with rTmedia
    164 
    165 
    166 /**
    167  * Check the privacy for each medias and remove
    168  * the not authorized medias from media array
    169  */
    170 function bp_ap_rtmedia(){
    171     global $rtmedia_query;
    172     have_rtmedia ();
    173 
    174     $is_super_admin = is_super_admin();
    175     $bp_displayed_user_id = bp_displayed_user_id();
    176     $bp_loggedin_user_id = bp_loggedin_user_id();
    177 
    178     if ( ( !empty($bp_displayed_user_id)  && $bp_displayed_user_id == $bp_loggedin_user_id ) ||  $is_super_admin )
    179         return;
    180 
    181     $count_removed_media = 0;
    182     if (!empty($rtmedia_query->media)) {
    183         foreach ($rtmedia_query->media as $key => $media) {
    184 
    185             $activities = bp_activity_get_specific( array( 'activity_ids' => $media->activity_id ) );
     164if( function_exists('rtmedia_autoloader') ) {
     165
     166    /**
     167     * Check the privacy for each medias and remove
     168     * the not authorized medias from media array
     169     */
     170    function bp_ap_rtmedia(){
     171        global $rtmedia_query;
     172        have_rtmedia ();
     173
     174        $is_super_admin = is_super_admin();
     175        $bp_displayed_user_id = bp_displayed_user_id();
     176        $bp_loggedin_user_id = bp_loggedin_user_id();
     177
     178        if ( ( !empty($bp_displayed_user_id)  && $bp_displayed_user_id == $bp_loggedin_user_id ) ||  $is_super_admin )
     179            return;
     180
     181        $count_removed_media = 0;
     182        if (!empty($rtmedia_query->media)) {
     183            foreach ($rtmedia_query->media as $key => $media) {
     184
     185                $activities = bp_activity_get_specific( array( 'activity_ids' => $media->activity_id ) );
     186                $activity = $activities["activities"][0];
     187               
     188                $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
     189                if ($remove_from_stream) {
     190                    unset($rtmedia_query->media[$key]);
     191                    $count_removed_media++;
     192                }   
     193            }
     194            //rearrange array keys
     195            $rtmedia_query->media = array_values($rtmedia_query->media);
     196
     197            $rtmedia_query->media_count = $rtmedia_query->media_count - $count_removed_media;
     198        }
     199    }
     200    add_action('rtmedia_before_media', 'bp_ap_rtmedia');
     201    add_action('rtmedia_after_media_gallery_title', 'bp_ap_rtmedia');
     202
     203    /**
     204     * Update media count user meta each time a user
     205     * visit the profile page.
     206     */
     207    function bp_ap_rtmedia_update_member_medias_count(){
     208        global $bp, $wpdb;
     209
     210        $is_super_admin = is_super_admin();
     211        $bp_displayed_user_id = bp_displayed_user_id();
     212        $bp_loggedin_user_id = bp_loggedin_user_id();
     213        //if ($bp_displayed_user_id == $bp_loggedin_user_id)
     214        //  return;
     215
     216        global $rtmedia, $rtmedia_query;
     217
     218        $allowed_media_types = array();
     219        foreach ( $rtmedia->allowed_types as $value ) {
     220            $allowed_media_types[ ] = $value['name'];
     221        }
     222        $allowed_media_types = implode("','", $allowed_media_types);
     223        $allowed_media_types = "'".$allowed_media_types."'";
     224
     225        $table_name = $rtmedia_query->model->table_name;
     226
     227        $r = $wpdb->get_results( $wpdb->prepare( "SELECT activity_id, media_type
     228                                   from {$table_name}
     229                                  where media_type IN ({$allowed_media_types})
     230                                    and context = 'profile'
     231                                    and media_author = %d   
     232                                    and blog_id = %d", $bp_displayed_user_id, get_current_blog_id() ) );
     233
     234
     235        $removed_media_count = array();
     236        foreach ( $r as $my_r ) {
     237            $activities = bp_activity_get_specific( array( 'activity_ids' => $my_r->activity_id ) );
    186238            $activity = $activities["activities"][0];
     239
     240            $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
    187241           
    188             $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
    189242            if ($remove_from_stream) {
    190                 unset($rtmedia_query->media[$key]);
    191                 $count_removed_media++;
    192             }   
    193         }
    194         //rearrange array keys
    195         $rtmedia_query->media = array_values($rtmedia_query->media);
    196 
    197         $rtmedia_query->media_count = $rtmedia_query->media_count - $count_removed_media;
    198     }
     243                $removed_media_count[$my_r->media_type]++;
     244            }
     245     
     246        }
     247
     248        $rtMediaNav = new RTMediaNav();
     249        $rtMediaNav->refresh_counts( $bp_displayed_user_id, array( "context" => 'profile', 'media_author' => $bp_displayed_user_id )  );
     250        $media_count = $rtMediaNav->get_counts( $bp_displayed_user_id );
     251
     252        $count = array();
     253        $count[0] = new stdClass();
     254        if ( !empty($media_count) ){
     255            // merga and sum all media by privacy
     256            foreach ($media_count as $media) {
     257                foreach ($media as $key => $value) {
     258                    if ( !isset($count[0]->{$key}) )
     259                        $count[0]->{$key} = 0;
     260
     261                    $count[0]->{$key} += $value;
     262                }
     263            }
     264            $media_count = $count;
     265        }
     266
     267        $total = null;
     268        if ( !empty($removed_media_count) && !empty($media_count) ) {
     269            $total = 0;
     270            foreach ($removed_media_count as $key => $value) {
     271                $media_count[0]->{$key} -= $value;
     272                $total += $media_count[0]->{$key};
     273            }
     274        }
     275
     276        if ( isset($total) ) {
     277            $slug = apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG );
     278
     279            foreach ($bp->bp_nav as $key => $value) {
     280                if ($value['slug'] == $slug) {
     281                    $bp->bp_nav[$key]['name'] = RTMEDIA_MEDIA_LABEL . '<span>' . $total . '</span>';
     282                    break;
     283                }
     284            }
     285        }
     286
     287        // update metadata
     288        update_user_meta ( $bp_displayed_user_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count );
     289    }
     290    add_action('bp_after_member_header', 'bp_ap_rtmedia_update_member_medias_count');
     291
     292
     293    /**
     294     * clear the media count user meta to force recomputing
     295     * it after each visit of profile page
     296     */
     297    function bp_ap_rtmedia_reset_member_medias_count(){
     298        global $bp;
     299        $bp_displayed_user_id = bp_displayed_user_id();
     300        update_user_meta ( $bp_displayed_user_id, 'rtmedia_counts_' . get_current_blog_id(), null );
     301    }
     302    add_action('bp_after_member_body', 'bp_ap_rtmedia_reset_member_medias_count');
     303    //add_action('rtmedia_after_media_gallery', 'bp_activity_privacy_rtmedia_reset_count');
     304
     305
     306    /**
     307     * Update media count user meta each time a user
     308     * visit the profile page.
     309     */
     310    function bp_ap_rtmedia_update_group_medias_count(){
     311        global $bp, $wpdb;
     312
     313        $is_super_admin = is_super_admin();
     314        $bp_group_id = bp_get_group_id();
     315        $bp_loggedin_user_id = bp_loggedin_user_id();
     316        //if ($bp_displayed_user_id == $bp_loggedin_user_id)
     317        //  return;
     318       
     319        global $rtmedia, $rtmedia_query;
     320
     321        $allowed_media_types = array();
     322        foreach ( $rtmedia->allowed_types as $value ) {
     323            $allowed_media_types[ ] = $value['name'];
     324        }
     325        $allowed_media_types = implode("','", $allowed_media_types);
     326        $allowed_media_types = "'".$allowed_media_types."'";
     327
     328        $table_name = $rtmedia_query->model->table_name;
     329
     330        $r = $wpdb->get_results( $wpdb->prepare( "SELECT activity_id, media_type
     331                                   from {$table_name}
     332                                  where media_type IN ({$allowed_media_types})
     333                                    and context = 'group'
     334                                    and context_id = %d 
     335                                    and blog_id = %d", $bp_group_id, get_current_blog_id() ) );
     336
     337        $removed_media_count = array();
     338        foreach ( $r as $my_r ) {
     339            $activities = bp_activity_get_specific( array( 'activity_ids' => $my_r->activity_id ) );
     340            $activity = $activities["activities"][0];
     341
     342            $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
     343           
     344            if ($remove_from_stream) {
     345                $removed_media_count[$my_r->media_type]++;
     346            }
     347
     348        }
     349
     350        $rtMediaNav = new RTMediaNav();
     351        $rtMediaNav->refresh_counts( $bp_group_id, array( "context" => 'group', 'context_id' => $bp_group_id ) );
     352        $media_count = $rtMediaNav->get_counts( $bp_group_id, array( "context" => 'group', 'context_id' => $bp_group_id ) );
     353
     354        $count = array();
     355        $count[0] = new stdClass();
     356        if ( !empty($media_count) ){
     357            // merga and sum all media by privacy
     358            foreach ($media_count as $media) {
     359                foreach ($media as $key => $value) {
     360                    if ( !isset($count[0]->{$key}) )
     361                        $count[0]->{$key} = 0;
     362
     363                    $count[0]->{$key} += $value;
     364                }
     365            }
     366            $media_count = $count;
     367        }
     368
     369        $total = 0;
     370        if ( !empty($removed_media_count) && !empty($media_count) ) {
     371            foreach ($removed_media_count as $key => $value) {
     372                $media_count[0]->{$key} -= $value;
     373                $total += $media_count[0]->{$key};
     374            }
     375
     376            $slug = apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG );
     377            $nav = reset($bp->bp_options_nav);
     378            $kkey = key($bp->bp_options_nav);
     379            foreach ($nav as $key => $value) {
     380                if ($value['slug'] == $slug)  {
     381                    $bp->bp_options_nav[$kkey][$key]['name'] = RTMEDIA_MEDIA_LABEL . '<span>' . $total . '</span>';
     382                    break;
     383                }
     384            }
     385
     386        }
     387
     388        // update metadata
     389        groups_update_groupmeta ( $bp_group_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count );
     390
     391    }
     392    add_action('bp_after_group_header', 'bp_ap_rtmedia_update_group_medias_count');
     393
     394
     395
     396    /**
     397     * clear the media count user meta to force recomputing
     398     * it after each visit of profile page
     399     */
     400    function bp_ap_rtmedia_reset_group_medias_count(){
     401        global $bp, $groups_template;
     402
     403        $bp_group_id = bp_get_group_id();
     404        if ( !isset($bp_group_id) ) {
     405            $bp_group_id = $groups_template->group->group_id;
     406        }
     407        //  bp_get_group_id() return null in media tab ( $groups_template->group is  stdClass on bp_after_group_body)
     408       
     409        groups_update_groupmeta ( $bp_group_id, 'rtmedia_counts_' . get_current_blog_id(), null );
     410
     411    }
     412    add_action('bp_after_group_body', 'bp_ap_rtmedia_reset_group_medias_count');
     413
     414
     415
     416    function bp_ap_rtmedia_add_edit_fields(){
     417        global $bp, $rtmedia_query, $rtmedia_media;
     418
     419        if ( isset($rtmedia_media) ) {
     420            $activity_id = $rtmedia_media->activity_id;
     421            /*
     422            if ( isset( $rtmedia_query->query[ 'context' ] ) && $rtmedia_query->query[ 'context' ] == 'group' ){
     423                //if context is group i.e editing a group media, dont show the privacy dropdown
     424                // group media
     425            } else {
     426                // profile media
     427            }
     428            */
     429
     430            $visibility = bp_activity_get_meta( $activity_id, 'activity-privacy' );
     431
     432            global $bp_activity_privacy;
     433
     434            if ($rtmedia_media->context == 'group')
     435                $group_id = $rtmedia_media->context_id;
     436            else
     437                $group_id = null;
     438
     439            //if is not a group activity or a new blog post
     440            if( !isset( $group_id ) )
     441                $visibility_levels = bp_get_profile_activity_visibility_levels();   
     442            else
     443                $visibility_levels = bp_get_groups_activity_visibility_levels();
     444           
     445            //sort visibility_levels by position
     446            uasort ($visibility_levels, 'bp_activity_privacy_cmp_position');
     447
     448            $html = '<select class="bp-ap-media-selectbox" name="visibility" >';
     449            foreach ($visibility_levels as $visibility_level) {
     450                if( $visibility_level["disabled"] )
     451                    continue;
     452                $html .= '<option class="" ' . ( $visibility_level['id'] == $visibility ? " selected='selected'" : '' ) . ' value="' . $visibility_level["id"] . '">&nbsp;' . $visibility_level["label"] . '</option>';
     453            }
     454            $html .= '</select>';
     455
     456            $html = apply_filters( 'bp_get_update_activitiy_visibility_selectbox', $html );
     457
     458            echo "<div class=''><label for='privacy'>" . __( 'Privacy : ', 'rtmedia' ) . "</label>   " . $html . "  </div>";
     459
     460        }
     461    }
     462    add_action('rtmedia_add_edit_fields', 'bp_ap_rtmedia_add_edit_fields');
     463
     464    /**
     465     * Update the privacy value of the activity related to the media
     466     */
     467    function bp_ap_rtmedia_after_update_media( $media_id ){
     468      if ( isset($media_id) ){
     469        global $bp, $wpdb, $rtmedia, $rtmedia_query;
     470
     471        // get the activity id related to the media
     472        $table_name = $rtmedia_query->model->table_name;
     473        $activity_id = $wpdb->get_var( $wpdb->prepare( "SELECT activity_id
     474                                   from {$table_name}
     475                                  where id = %d", $media_id ) );
     476
     477        $visibility = esc_attr($_POST['visibility']);
     478        bp_activity_update_meta( $activity_id, 'activity-privacy', $visibility );
     479
     480      }
     481
     482    }
     483    add_action('rtmedia_after_update_media', 'bp_ap_rtmedia_after_update_media');
     484
    199485}
    200 add_action('rtmedia_before_media', 'bp_ap_rtmedia');
    201 add_action('rtmedia_after_media_gallery_title', 'bp_ap_rtmedia');
    202 
    203 /**
    204  * Update media count user meta each time a user
    205  * visit the profile page.
    206  */
    207 function bp_ap_rtmedia_update_member_medias_count(){
    208     global $bp, $wpdb;
    209 
    210     $is_super_admin = is_super_admin();
    211     $bp_displayed_user_id = bp_displayed_user_id();
    212     $bp_loggedin_user_id = bp_loggedin_user_id();
    213     //if ($bp_displayed_user_id == $bp_loggedin_user_id)
    214     //  return;
    215 
    216     global $rtmedia, $rtmedia_query;
    217 
    218     $allowed_media_types = array();
    219     foreach ( $rtmedia->allowed_types as $value ) {
    220         $allowed_media_types[ ] = $value['name'];
    221     }
    222     $allowed_media_types = implode("','", $allowed_media_types);
    223     $allowed_media_types = "'".$allowed_media_types."'";
    224 
    225     $table_name = $rtmedia_query->model->table_name;
    226 
    227     $r = $wpdb->get_results( $wpdb->prepare( "SELECT activity_id, media_type
    228                                from {$table_name}
    229                               where media_type IN ({$allowed_media_types})
    230                                 and context = 'profile'
    231                                 and media_author = %d   
    232                                 and blog_id = %d", $bp_displayed_user_id, get_current_blog_id() ) );
    233 
    234 
    235     $removed_media_count = array();
    236     foreach ( $r as $my_r ) {
    237         $activities = bp_activity_get_specific( array( 'activity_ids' => $my_r->activity_id ) );
    238         $activity = $activities["activities"][0];
    239 
    240         $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
    241        
    242         if ($remove_from_stream) {
    243             $removed_media_count[$my_r->media_type]++;
    244         }
    245  
    246     }
    247 
    248     $rtMediaNav = new RTMediaNav();
    249     $rtMediaNav->refresh_counts( $bp_displayed_user_id, array( "context" => 'profile', 'media_author' => $bp_displayed_user_id )  );
    250     $media_count = $rtMediaNav->get_counts( $bp_displayed_user_id );
    251 
    252     $count = array();
    253     $count[0] = new stdClass();
    254     if ( !empty($media_count) ){
    255         // merga and sum all media by privacy
    256         foreach ($media_count as $media) {
    257             foreach ($media as $key => $value) {
    258                 if ( !isset($count[0]->{$key}) )
    259                     $count[0]->{$key} = 0;
    260 
    261                 $count[0]->{$key} += $value;
    262             }
    263         }
    264         $media_count = $count;
    265     }
    266 
    267     $total = null;
    268     if ( !empty($removed_media_count) && !empty($media_count) ) {
    269         $total = 0;
    270         foreach ($removed_media_count as $key => $value) {
    271             $media_count[0]->{$key} -= $value;
    272             $total += $media_count[0]->{$key};
    273         }
    274     }
    275 
    276     if ( isset($total) ) {
    277         $slug = apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG );
    278 
    279         foreach ($bp->bp_nav as $key => $value) {
    280             if ($value['slug'] == $slug) {
    281                 $bp->bp_nav[$key]['name'] = RTMEDIA_MEDIA_LABEL . '<span>' . $total . '</span>';
    282                 break;
    283             }
    284         }
    285     }
    286 
    287     // update metadata
    288     update_user_meta ( $bp_displayed_user_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count );
    289 }
    290 add_action('bp_after_member_header', 'bp_ap_rtmedia_update_member_medias_count');
    291 
    292 
    293 /**
    294  * clear the media count user meta to force recomputing
    295  * it after each visit of profile page
    296  */
    297 function bp_ap_rtmedia_reset_member_medias_count(){
    298     global $bp;
    299     $bp_displayed_user_id = bp_displayed_user_id();
    300     update_user_meta ( $bp_displayed_user_id, 'rtmedia_counts_' . get_current_blog_id(), null );
    301 }
    302 add_action('bp_after_member_body', 'bp_ap_rtmedia_reset_member_medias_count');
    303 //add_action('rtmedia_after_media_gallery', 'bp_activity_privacy_rtmedia_reset_count');
    304 
    305 
    306 /**
    307  * Update media count user meta each time a user
    308  * visit the profile page.
    309  */
    310 function bp_ap_rtmedia_update_group_medias_count(){
    311     global $bp, $wpdb;
    312 
    313     $is_super_admin = is_super_admin();
    314     $bp_group_id = bp_get_group_id();
    315     $bp_loggedin_user_id = bp_loggedin_user_id();
    316     //if ($bp_displayed_user_id == $bp_loggedin_user_id)
    317     //  return;
    318    
    319     global $rtmedia, $rtmedia_query;
    320 
    321     $allowed_media_types = array();
    322     foreach ( $rtmedia->allowed_types as $value ) {
    323         $allowed_media_types[ ] = $value['name'];
    324     }
    325     $allowed_media_types = implode("','", $allowed_media_types);
    326     $allowed_media_types = "'".$allowed_media_types."'";
    327 
    328     $table_name = $rtmedia_query->model->table_name;
    329 
    330     $r = $wpdb->get_results( $wpdb->prepare( "SELECT activity_id, media_type
    331                                from {$table_name}
    332                               where media_type IN ({$allowed_media_types})
    333                                 and context = 'group'
    334                                 and context_id = %d 
    335                                 and blog_id = %d", $bp_group_id, get_current_blog_id() ) );
    336 
    337     $removed_media_count = array();
    338     foreach ( $r as $my_r ) {
    339         $activities = bp_activity_get_specific( array( 'activity_ids' => $my_r->activity_id ) );
    340         $activity = $activities["activities"][0];
    341 
    342         $remove_from_stream = bp_visibility_is_activity_invisible( $activity, $bp_loggedin_user_id, $is_super_admin, $bp_displayed_user_id );
    343        
    344         if ($remove_from_stream) {
    345             $removed_media_count[$my_r->media_type]++;
    346         }
    347 
    348     }
    349 
    350     $rtMediaNav = new RTMediaNav();
    351     $rtMediaNav->refresh_counts( $bp_group_id, array( "context" => 'group', 'context_id' => $bp_group_id ) );
    352     $media_count = $rtMediaNav->get_counts( $bp_group_id, array( "context" => 'group', 'context_id' => $bp_group_id ) );
    353 
    354     $count = array();
    355     $count[0] = new stdClass();
    356     if ( !empty($media_count) ){
    357         // merga and sum all media by privacy
    358         foreach ($media_count as $media) {
    359             foreach ($media as $key => $value) {
    360                 if ( !isset($count[0]->{$key}) )
    361                     $count[0]->{$key} = 0;
    362 
    363                 $count[0]->{$key} += $value;
    364             }
    365         }
    366         $media_count = $count;
    367     }
    368 
    369     $total = 0;
    370     if ( !empty($removed_media_count) && !empty($media_count) ) {
    371         foreach ($removed_media_count as $key => $value) {
    372             $media_count[0]->{$key} -= $value;
    373             $total += $media_count[0]->{$key};
    374         }
    375 
    376         $slug = apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG );
    377         $nav = reset($bp->bp_options_nav);
    378         $kkey = key($bp->bp_options_nav);
    379         foreach ($nav as $key => $value) {
    380             if ($value['slug'] == $slug)  {
    381                 $bp->bp_options_nav[$kkey][$key]['name'] = RTMEDIA_MEDIA_LABEL . '<span>' . $total . '</span>';
    382                 break;
    383             }
    384         }
    385 
    386     }
    387 
    388     // update metadata
    389     groups_update_groupmeta ( $bp_group_id, 'rtmedia_counts_' . get_current_blog_id(), $media_count );
    390 
    391 }
    392 add_action('bp_after_group_header', 'bp_ap_rtmedia_update_group_medias_count');
    393 
    394 
    395 
    396 /**
    397  * clear the media count user meta to force recomputing
    398  * it after each visit of profile page
    399  */
    400 function bp_ap_rtmedia_reset_group_medias_count(){
    401     global $bp, $groups_template;
    402 
    403     $bp_group_id = bp_get_group_id();
    404     if ( !isset($bp_group_id) ) {
    405         $bp_group_id = $groups_template->group->group_id;
    406     }
    407     //  bp_get_group_id() return null in media tab ( $groups_template->group is  stdClass on bp_after_group_body)
    408    
    409     groups_update_groupmeta ( $bp_group_id, 'rtmedia_counts_' . get_current_blog_id(), null );
    410 
    411 }
    412 add_action('bp_after_group_body', 'bp_ap_rtmedia_reset_group_medias_count');
    413 
    414 
    415 
    416 function bp_ap_rtmedia_add_edit_fields(){
    417     global $bp, $rtmedia_query, $rtmedia_media;
    418 
    419     if ( isset($rtmedia_media) ) {
    420         $activity_id = $rtmedia_media->activity_id;
    421         /*
    422         if ( isset( $rtmedia_query->query[ 'context' ] ) && $rtmedia_query->query[ 'context' ] == 'group' ){
    423             //if context is group i.e editing a group media, dont show the privacy dropdown
    424             // group media
    425         } else {
    426             // profile media
    427         }
    428         */
    429 
    430         $visibility = bp_activity_get_meta( $activity_id, 'activity-privacy' );
    431 
    432         global $bp_activity_privacy;
    433 
    434         if ($rtmedia_media->context == 'group')
    435             $group_id = $rtmedia_media->context_id;
    436         else
    437             $group_id = null;
    438 
    439         //if is not a group activity or a new blog post
    440         if( !isset( $group_id ) )
    441             $visibility_levels = bp_get_profile_activity_visibility_levels();   
    442         else
    443             $visibility_levels = bp_get_groups_activity_visibility_levels();
    444        
    445         //sort visibility_levels by position
    446         uasort ($visibility_levels, 'bp_activity_privacy_cmp_position');
    447 
    448         $html = '<select class="bp-ap-media-selectbox" name="visibility" >';
    449         foreach ($visibility_levels as $visibility_level) {
    450             if( $visibility_level["disabled"] )
    451                 continue;
    452             $html .= '<option class="" ' . ( $visibility_level['id'] == $visibility ? " selected='selected'" : '' ) . ' value="' . $visibility_level["id"] . '">&nbsp;' . $visibility_level["label"] . '</option>';
    453         }
    454         $html .= '</select>';
    455 
    456         $html = apply_filters( 'bp_get_update_activitiy_visibility_selectbox', $html );
    457 
    458         echo "<div class=''><label for='privacy'>" . __( 'Privacy : ', 'rtmedia' ) . "</label>   " . $html . "  </div>";
    459 
    460     }
    461 }
    462 add_action('rtmedia_add_edit_fields', 'bp_ap_rtmedia_add_edit_fields');
    463 
    464 /**
    465  * Update the privacy value of the activity related to the media
    466  */
    467 function bp_ap_rtmedia_after_update_media( $media_id ){
    468   if ( isset($media_id) ){
    469     global $bp, $wpdb, $rtmedia, $rtmedia_query;
    470 
    471     // get the activity id related to the media
    472     $table_name = $rtmedia_query->model->table_name;
    473     $activity_id = $wpdb->get_var( $wpdb->prepare( "SELECT activity_id
    474                                from {$table_name}
    475                               where id = %d", $media_id ) );
    476 
    477     $visibility = esc_attr($_POST['visibility']);
    478     bp_activity_update_meta( $activity_id, 'activity-privacy', $visibility );
    479 
    480   }
    481 
    482 }
    483 add_action('rtmedia_after_update_media', 'bp_ap_rtmedia_after_update_media');
    484 
  • buddypress-activity-privacy/trunk/loader.php

    r916054 r916303  
    44Plugin URI:
    55Description: Add the ability for members to choose who can read/see his activities and media files.
    6 Version: 1.3.2
     6Version: 1.3.3
    77Requires at least:  WP 3.4, BuddyPress 1.5
    8 Tested up to: BuddyPress 2.0.1
     8Tested up to: BuddyPress 1.5, 2.0.1
    99License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
    1010Author: Meg@Info
     
    1919
    2020/*************************************************************************************************************
    21  --- BuddyPress Activity Privacy 1.3.2 ---
     21 --- BuddyPress Activity Privacy 1.3.3 ---
    2222 *************************************************************************************************************/
    2323
     
    2727// Define a constant that will hold the current version number of the component
    2828// This can be useful if you need to run update scripts or do compatibility checks in the future
    29 define( 'BP_ACTIVITY_PRIVACY_VERSION', '1.3.2' );
     29define( 'BP_ACTIVITY_PRIVACY_VERSION', '1.3.3' );
    3030
    3131// Define a constant that we can use to construct file paths throughout the component
  • buddypress-activity-privacy/trunk/readme.txt

    r916054 r916303  
    44Requires at least: WordPress 3.4, BuddyPress 1.5
    55Tested up to: WordPress 3.9 / BuddyPress 2.0.1
    6 Stable tag: 1.3.2
     6Stable tag: 1.3.3
    77
    88
     
    7676== Changelog ==
    7777
     78= 1.3.3 =
     79- Fix bugs on integration with rtMedia.
     80
    7881= 1.3.2 =
    7982- Fix issues when Buddypress Follow is activate.
Note: See TracChangeset for help on using the changeset viewer.