rtMedia for WordPress, BuddyPress and bbPress - Version 3.7.9

Version Description

  • Added new database table to store activity privacy
Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 3.7.9
Comparing to
See all releases

Code changes from version 3.7.8 to 3.7.9

app/admin/RTMediaAdmin.php CHANGED
@@ -106,6 +106,9 @@ if ( ! class_exists( 'RTMediaAdmin' ) ){
106
add_action( 'admin_init', array( $this, 'rtmedia_bp_add_update_type' ) );
107
add_action( 'wp_ajax_rtmedia_hide_inspirebook_release_notice', array( $this, 'rtmedia_hide_inspirebook_release_notice' ), 1 );
108
$rtmedia_media_import = new RTMediaMediaSizeImporter(); // do not delete this line. We only need to create object of this class if we are in admin section
109
add_action( 'admin_notices', array( $this, 'rtmedia_admin_notices' ) );
110
add_action( 'network_admin_notices', array( $this, 'rtmedia_network_admin_notices' ) );
111
106
add_action( 'admin_init', array( $this, 'rtmedia_bp_add_update_type' ) );
107
add_action( 'wp_ajax_rtmedia_hide_inspirebook_release_notice', array( $this, 'rtmedia_hide_inspirebook_release_notice' ), 1 );
108
$rtmedia_media_import = new RTMediaMediaSizeImporter(); // do not delete this line. We only need to create object of this class if we are in admin section
109
+ if( class_exists( 'BuddyPress' ) ){
110
+ $rtmedia_activity_upgrade = new RTMediaActivityUpgrade();
111
+ }
112
add_action( 'admin_notices', array( $this, 'rtmedia_admin_notices' ) );
113
add_action( 'network_admin_notices', array( $this, 'rtmedia_network_admin_notices' ) );
114
app/helper/RTMediaActivityModel.php ADDED
@@ -0,0 +1,53 @@
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: ritz <ritesh.patel@rtcamp.com>
5
+ * Date: 11/9/14
6
+ * Time: 2:32 PM
7
+ */
8
+
9
+ if( !class_exists( 'RTDBModel' ) ){
10
+ return;
11
+ }
12
+
13
+ class RTMediaActivityModel extends RTDBModel {
14
+
15
+ function __construct () {
16
+ parent::__construct ( 'rtm_activity' );
17
+ }
18
+
19
+ function get( $columns, $offset=false, $per_page=false, $order_by= 'activity_id DESC' ) {
20
+ $columns['blog_id'] = get_current_blog_id();
21
+ return parent::get( $columns, $offset, $per_page, $order_by );
22
+ }
23
+
24
+ function insert( $row ) {
25
+ $row['blog_id'] = get_current_blog_id();
26
+ return parent::insert( $row );
27
+ }
28
+
29
+ function update( $data, $where ) {
30
+ $where['blog_id'] = get_current_blog_id();
31
+ return parent::update( $data, $where );
32
+ }
33
+
34
+ public function check( $activity_id = "") {
35
+ if( $activity_id == "" ){
36
+ return false;
37
+ }
38
+
39
+ $columns = array(
40
+ 'activity_id' => $activity_id,
41
+ 'blog_id' => get_current_blog_id(),
42
+ );
43
+
44
+ $results = $this->get( $columns );
45
+
46
+ if( $results ){
47
+ return true;
48
+ } else {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ }
app/importers/RTMediaActivityUpgrade.php ADDED
@@ -0,0 +1,243 @@
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: ritz <ritesh.patel@rtcamp.com>
5
+ * Date: 11/9/14
6
+ * Time: 1:56 PM
7
+ */
8
+
9
+ class RTMediaActivityUpgrade {
10
+
11
+ function __construct(){
12
+ add_filter( "rtmedia_filter_admin_pages_array", array( $this, "rtmedia_add_admin_page_array" ), 11, 1 );
13
+ add_action( 'admin_init', array( $this, 'add_admin_notice' ) );
14
+ add_action( 'admin_menu', array( $this, 'menu' ), 10 );
15
+ add_action( 'wp_ajax_rtmedia_activity_upgrade', array( $this, 'rtmedia_activity_upgrade' ) );
16
+ add_action( 'wp_ajax_rtmedia_activity_done_upgrade', array( $this, 'rtmedia_activity_done_upgrade' ) );
17
+ }
18
+
19
+ function menu() {
20
+ add_submenu_page( 'rtmedia-setting', __( 'Media activity upgrade', 'rtmedia' ), __( 'Media activity upgrade', 'rtmedia' ), 'manage_options', 'rtmedia-activity-upgrade', array( $this, 'init' ) );
21
+ }
22
+
23
+ function rtmedia_add_admin_page_array( $admin_pages ) {
24
+ $admin_pages[ ] = "rtmedia_page_rtmedia-activity-upgrade";
25
+
26
+ return $admin_pages;
27
+ }
28
+
29
+ function rtmedia_activity_done_upgrade(){
30
+ rtmedia_update_site_option( 'rtmedia_activity_done_upgrade', true );
31
+ die();
32
+ }
33
+
34
+ function add_admin_notice(){
35
+ $pending = $this->get_pending_count();
36
+ $upgrade_done = rtmedia_get_site_option( 'rtmedia_activity_done_upgrade' );
37
+ if( $upgrade_done ){
38
+ return;
39
+ }
40
+ if ( $pending < 0 ){
41
+ $pending = 0;
42
+ }
43
+ rtmedia_update_site_option( "rtmedia_media_activity_upgrade_pending", $pending );
44
+ if ( $pending > 0 ){
45
+ if ( ! ( isset ( $_REQUEST[ "page" ] ) && $_REQUEST[ "page" ] == "rtmedia-activity-upgrade" ) ){
46
+ $site_option = get_site_option( "rtmedia_activity_upgrade_notice" );
47
+ if ( ! $site_option || $site_option != "hide" ){
48
+ rtmedia_update_site_option( "rtmedia_activity_upgrade_notice", "show" );
49
+ add_action( 'admin_notices', array( &$this, 'add_rtmedia_media_activity_upgrade_notice' ) );
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ function rtmedia_activity_upgrade( $lastid = 0, $limit = 1 ){
56
+ global $wpdb;
57
+ $rtmedia_model = new RTMediaModel();
58
+ $rtmedia_activity_model = new RTMediaActivityModel();
59
+ $activity_sql = " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit " . $limit;
60
+ if( isset( $_REQUEST['last_id'] ) ) {
61
+ $lastid = $_REQUEST['last_id'];
62
+ }
63
+ if( $lastid ){
64
+ $activity_sql = " SELECT *, max(privacy) as max_privacy FROM {$rtmedia_model->table_name} WHERE activity_id > " . $lastid ." AND activity_id is NOT NULL GROUP BY activity_id ORDER BY id limit " . $limit;
65
+ }
66
+ $activity_data = $wpdb->get_results( $activity_sql );
67
+ if( is_array( $activity_data ) && !empty( $activity_data ) ){
68
+ $rtmedia_activity_model->insert( array( 'activity_id' => $activity_data[0]->activity_id, 'user_id' => $activity_data[0]->media_author, 'privacy' => $activity_data[0]->max_privacy ) );
69
+ }
70
+ $this->return_upgrade( $activity_data[0] );
71
+ }
72
+
73
+ function return_upgrade( $activity_data, $upgrade = true ){
74
+ $total = $this->get_total_count();
75
+ $pending = $this->get_pending_count( $activity_data->activity_id );
76
+ $done = $total - $pending;
77
+ if ( $pending < 0 ){
78
+ $pending = 0;
79
+ $done = $total;
80
+ }
81
+ if ( $done > $total ){
82
+ $done = $total;
83
+ }
84
+ rtmedia_update_site_option( 'rtmedia_media_activity_upgrade_pending', $pending );
85
+ $pending_time = rtmedia_migrate_formatseconds( $pending ). " (estimated)";
86
+ echo json_encode( array( "status" => true, "done" => $done, "total" => $total, "pending" => $pending_time, "activity_id" => $activity_data->activity_id, "imported" => $upgrade ) );
87
+ die();
88
+ }
89
+
90
+ function add_rtmedia_media_activity_upgrade_notice(){
91
+ if ( current_user_can( 'manage_options' ) ){
92
+ echo "<div class='error rtmedia-activity-upgrade-notice'><p><strong>rtMedia</strong>: Database table structure for rtMedia has been updated. Please <a href='" . admin_url( "admin.php?page=rtmedia-activity-upgrade" ) . "'>Click Here</a> to upgrade rtMedia activities. </p> </div>";
93
+ }
94
+ }
95
+
96
+ function get_pending_count( $activity_id = false ){
97
+ global $wpdb;
98
+ $rtmedia_activity_model = new RTMediaActivityModel();
99
+ $rtmedia_model = new RTMediaModel();
100
+ $query_pending = " SELECT count( DISTINCT activity_id) as pending from {$rtmedia_model->table_name} where activity_id NOT IN( SELECT activity_id from {$rtmedia_activity_model->table_name} ) AND activity_id > 0 ";
101
+ $last_imported = $this->get_last_imported();
102
+ if( $last_imported ){
103
+ $query_pending .= " AND activity_id>{$last_imported} ";
104
+ }
105
+ $pending_count = $wpdb->get_results( $query_pending );
106
+ if ( $pending_count && sizeof( $pending_count ) > 0 ){
107
+ return $pending_count[ 0 ]->pending;
108
+ }
109
+ return 0;
110
+ }
111
+
112
+ function get_total_count(){
113
+ global $wpdb;
114
+ $rtmedia_model = new RTMediaModel();
115
+ $query_total = " SELECT count( DISTINCT activity_id) as total FROM {$rtmedia_model->table_name} WHERE activity_id > 0 ";
116
+ $total_count = $wpdb->get_results( $query_total );
117
+ if ( $total_count && sizeof( $total_count ) > 0 ){
118
+ return $total_count[ 0 ]->total;
119
+ }
120
+ return 0;
121
+ }
122
+
123
+ function get_last_imported(){
124
+ global $wpdb;
125
+ $rtmedia_activity_model = new RTMediaActivityModel();
126
+ $last_query = " SELECT activity_id from {$rtmedia_activity_model->table_name} ORDER BY activity_id DESC limit 1 ";
127
+ $last_imported = $wpdb->get_results( $last_query );
128
+ if ( $last_imported && sizeof( $last_imported ) > 0 && isset( $last_imported[0] ) && isset( $last_imported[0]->activity_id ) ){
129
+ return $last_imported[ 0 ]->activity_id;
130
+ }
131
+ return 0;
132
+ }
133
+
134
+ function init(){
135
+ $prog = new rtProgress();
136
+ $pending = $this->get_pending_count();
137
+ $total = $this->get_total_count();
138
+ $last_id = $this->get_last_imported();
139
+ $done = $total - $pending;
140
+ $admin_ajax = admin_url( 'admin-ajax.php' );
141
+ ?>
142
+ <div class="wrap">
143
+ <h2>rtMedia: Upgrade rtMedia activity</h2>
144
+ <?php
145
+ echo '<span class="pending">' . rtmedia_migrate_formatseconds( $total - $done ) . ' (estimated)</span><br />';
146
+ echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
147
+ echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
148
+
149
+ $temp = $prog->progress( $done, $total );
150
+ $prog->progress_ui( $temp, true );
151
+ ?>
152
+ <script type="text/javascript">
153
+ var fail_id = new Array();
154
+ var ajax_data;
155
+ jQuery( document ).ready( function ( e ) {
156
+ jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-has-current-submenu" )
157
+ jQuery( "#toplevel_page_rtmedia-settings" ).removeClass( "wp-not-current-submenu" )
158
+ jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-menu-open" )
159
+ jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-menu-open" )
160
+ jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-has-current-submenu" )
161
+ if ( db_total < 1 )
162
+ jQuery( "#submit" ).attr( 'disabled', "disabled" );
163
+ } )
164
+ function db_start_migration( db_done, db_total, last_id ) {
165
+
166
+ if ( db_done < db_total ) {
167
+ jQuery( "#rtMediaSyncing" ).show();
168
+ ajax_data = {
169
+ "action": "rtmedia_activity_upgrade",
170
+ "done": db_done,
171
+ "last_id" : last_id
172
+ }
173
+ jQuery.ajax( {
174
+ url: '<?php echo $admin_ajax; ?>',
175
+ type: 'post',
176
+ data: ajax_data,
177
+ success: function ( sdata ) {
178
+
179
+ try {
180
+ data = JSON.parse( sdata );
181
+ } catch ( e ) {
182
+ jQuery( "#submit" ).attr( 'disabled', "" );
183
+ }
184
+ if ( data.status ) {
185
+ done = parseInt( data.done );
186
+ total = parseInt( data.total );
187
+ var progw = Math.ceil( (done / total) * 100 );
188
+ if ( progw > 100 ) {
189
+ progw = 100;
190
+ }
191
+ ;
192
+ jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
193
+ jQuery( 'span.finished' ).html( done );
194
+ jQuery( 'span.total' ).html( total );
195
+ jQuery( 'span.pending' ).html( data.pending );
196
+ if( data.imported === false ) {
197
+ fail_id.push(data.activity_id);
198
+ }
199
+ db_start_migration( done, total, parseInt( data.activity_id ) );
200
+ } else {
201
+ alert( "Migration completed." );
202
+ jQuery( "#rtMediaSyncing" ).hide();
203
+ }
204
+ },
205
+ error: function () {
206
+ alert( "Error During Migration, Please Refresh Page then try again" );
207
+ jQuery( "#submit" ).removeAttr( 'disabled' );
208
+ }
209
+ } );
210
+ } else {
211
+ data = {
212
+ action: 'rtmedia_activity_done_upgrade'
213
+ }
214
+ jQuery.post( '<?php echo $admin_ajax; ?>', data, function(){
215
+ alert( "Database upgrade completed." );
216
+ } );
217
+ if( fail_id.length > 0 ) {
218
+ rtm_show_file_error();
219
+ }
220
+ jQuery( "#rtMediaSyncing" ).hide();
221
+ }
222
+ }
223
+ function rtm_show_file_error() {
224
+ jQuery( 'span.pending' ).html( "Some activities are failed to upgrade, Don't worry about that." );
225
+ }
226
+ var db_done = <?php echo $done; ?>;
227
+ var db_total = <?php echo $total; ?>;
228
+ var last_id = <?php echo $last_id; ?>;
229
+ jQuery( document ).on( 'click', '#submit', function ( e ) {
230
+ e.preventDefault();
231
+ db_start_migration( db_done, db_total, last_id );
232
+ jQuery( this ).attr( 'disabled', 'disabled' );
233
+ } );
234
+ </script>
235
+ <hr/>
236
+ <?php if ( ! ( isset ( $rtmedia_error ) && $rtmedia_error === true ) ){ ?>
237
+ <input type="button" id="submit" value="start" class="button button-primary"/>
238
+ <?php } ?>
239
+ </div>
240
+ <?php
241
+ }
242
+
243
+ }
app/main/controllers/activity/RTMediaBuddyPressActivity.php CHANGED
@@ -139,6 +139,13 @@ class RTMediaBuddyPressActivity {
139
}
140
}
141
bp_activity_update_meta ( $activity_id, 'rtmedia_privacy', $privacy );
142
}
143
}
144
139
}
140
}
141
bp_activity_update_meta ( $activity_id, 'rtmedia_privacy', $privacy );
142
+ // insert/update activity details in rtmedia activity table
143
+ $rtmedia_activity_model = new RTMediaActivityModel();
144
+ if( ! $rtmedia_activity_model->check( $activity_id ) ){
145
+ $rtmedia_activity_model->insert( array( 'activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy ) );
146
+ } else {
147
+ $rtmedia_activity_model->update( array( 'activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy ), array( 'activity_id' => $activity_id ) );
148
+ }
149
}
150
}
151
app/main/controllers/media/RTMediaMedia.php CHANGED
@@ -207,6 +207,25 @@ class RTMediaMedia {
207
208
$status = $this->model->update ( $data, $where );
209
210
/* action to perform any task after updating a media */
211
do_action ( 'rtmedia_after_update_media', $id );
212
@@ -532,6 +551,14 @@ class RTMediaMedia {
532
array( 'activity_id' => $activity_id ), array( 'id' => $media->id )
533
);
534
535
return $activity_id;
536
}
537
207
208
$status = $this->model->update ( $data, $where );
209
210
+ // insert/update activity details in rtmedia activity table
211
+ $media_model = new RTMediaModel();
212
+ $media = $media_model->get( array( 'id' => $id ) );
213
+ $rtmedia_activity_model = new RTMediaActivityModel();
214
+ $similar_media = $media_model->get( array( 'activity_id' => $media[0]->activity_id ) );
215
+ $max_privacy = 0;
216
+
217
+ foreach( $similar_media as $s_media ){
218
+ if( $s_media->privacy > $max_privacy ){
219
+ $max_privacy = $s_media->privacy;
220
+ }
221
+ }
222
+
223
+ if( ! $rtmedia_activity_model->check( $media[0]->activity_id ) ){
224
+ $rtmedia_activity_model->insert( array( 'activity_id' => $media[0]->activity_id, 'user_id' => $media[0]->media_author, 'privacy' => $max_privacy ) );
225
+ } else {
226
+ $rtmedia_activity_model->update( array( 'activity_id' => $media[0]->activity_id, 'user_id' => $media[0]->media_author, 'privacy' => $max_privacy ), array( 'activity_id' => $media[0]->activity_id ) );
227
+ }
228
+
229
/* action to perform any task after updating a media */
230
do_action ( 'rtmedia_after_update_media', $id );
231
551
array( 'activity_id' => $activity_id ), array( 'id' => $media->id )
552
);
553
554
+ // insert/update activity details in rtmedia activity table
555
+ $rtmedia_activity_model = new RTMediaActivityModel();
556
+ if( ! $rtmedia_activity_model->check( $activity_id ) ){
557
+ $rtmedia_activity_model->insert( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy ) );
558
+ } else {
559
+ $rtmedia_activity_model->update( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy ), array( 'activity_id' => $activity_id ) );
560
+ }
561
+
562
return $activity_id;
563
}
564
app/main/controllers/privacy/RTMediaPrivacy.php CHANGED
@@ -291,45 +291,76 @@ class RTMediaPrivacy {
291
$where = '' ;
292
global $bp , $wpdb ;
293
$rtmedia_model = new RTMediaModel() ;
294
- if ( is_user_logged_in () ) {
295
- $user = get_current_user_id () ;
296
- }
297
- else {
298
- $user = 0 ;
299
- }
300
301
- $where .= " (m.max_privacy is NULL OR m.max_privacy <= 0) " ;
302
-
303
- if ( $user ) {
304
- $where .= "OR ((m.max_privacy=20)" ;
305
- $where .= " OR (a.user_id={$user} AND m.max_privacy >= 40)" ;
306
- if ( class_exists ( 'BuddyPress' ) ) {
307
- if ( bp_is_active ( 'friends' ) ) {
308
- $friendship = new RTMediaFriends() ;
309
- $friends = $friendship -> get_friends_cache ( $user ) ;
310
- if ( isset($friends) && ! empty ( $friends ) != "" ){
311
- $where .= " OR (m.max_privacy=40 AND a.user_id IN ('" . implode ( "','" , $friends ) . "'))" ;
312
- }
313
- }
314
- }
315
- $where .= ')' ;
316
- }
317
- if ( function_exists ( "bp_core_get_table_prefix" ) ){
318
- $bp_prefix = bp_core_get_table_prefix () ;
319
- }
320
- else{
321
- $bp_prefix = "" ;
322
- }
323
-
324
- if ( strpos ( $select_sql , "SELECT DISTINCT" ) === false ){
325
- $select_sql = str_replace ( "SELECT" , "SELECT DISTINCT" , $select_sql ) ;
326
- }
327
-
328
- $media_table = "SELECT *, max( privacy ) as max_privacy from {$rtmedia_model->table_name} group by activity_id";
329
330
- $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID LEFT JOIN ( $media_table ) m ON ( a.id = m.activity_id AND m.blog_id = '". get_current_blog_id()."' ) ";
331
- $where_sql = $where_sql . " AND (NOT EXISTS (SELECT m.activity_id FROM {$bp_prefix}bp_activity_meta m WHERE m.meta_key='rtmedia_privacy' AND m.activity_id=a.id) OR ( {$where} ) )";
332
- $newsql = "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}";
333
return $newsql;
334
}
335
291
$where = '' ;
292
global $bp , $wpdb ;
293
$rtmedia_model = new RTMediaModel() ;
294
295
+ if ( is_user_logged_in () ) {
296
+ $user = get_current_user_id () ;
297
+ }
298
+ else {
299
+ $user = 0 ;
300
+ }
301
302
+ $activity_upgrade_done = rtmedia_get_site_option( 'rtmedia_activity_done_upgrade' );
303
+
304
+ // admin has upgraded rtmedia activity so we can use rt_rtm_activity table for rtmedia related activity filters
305
+ if( $activity_upgrade_done ){
306
+ $rtmedia_activity_model = new RTMediaActivityModel();
307
+ $where .= " (ra.privacy is NULL OR ra.privacy <= 0) " ;
308
+ if ( $user ) {
309
+ $where .= "OR ((ra.privacy=20)" ;
310
+ $where .= " OR (a.user_id={$user} AND ra.privacy >= 40)" ;
311
+ if ( class_exists ( 'BuddyPress' ) ) {
312
+ if ( bp_is_active ( 'friends' ) ) {
313
+ $friendship = new RTMediaFriends() ;
314
+ $friends = $friendship -> get_friends_cache ( $user ) ;
315
+ if ( isset($friends) && ! empty ( $friends ) != "" ){
316
+ $where .= " OR (ra.privacy=40 AND a.user_id IN ('" . implode ( "','" , $friends ) . "'))" ;
317
+ }
318
+ }
319
+ }
320
+ $where .= ')' ;
321
+ }
322
+ if ( function_exists ( "bp_core_get_table_prefix" ) ){
323
+ $bp_prefix = bp_core_get_table_prefix () ;
324
+ }
325
+ else{
326
+ $bp_prefix = "" ;
327
+ }
328
+ if ( strpos ( $select_sql , "SELECT DISTINCT" ) === false ){
329
+ $select_sql = str_replace ( "SELECT" , "SELECT DISTINCT" , $select_sql ) ;
330
+ }
331
+ $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID LEFT JOIN {$rtmedia_model->table_name} m ON ( a.id = m.activity_id AND m.blog_id = '". get_current_blog_id()."' ) LEFT JOIN {$rtmedia_activity_model->table_name} ra ON ( a.id = ra.activity_id and ra.blog_id = '". get_current_blog_id()."' ) ";
332
+ $where_sql = $where_sql . " AND (NOT EXISTS (SELECT m.activity_id FROM {$bp_prefix}bp_activity_meta m WHERE m.meta_key='rtmedia_privacy' AND m.activity_id=a.id) OR ( {$where} ) )";
333
+ $newsql = "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}";
334
+ } else {
335
+ $where .= " (m.max_privacy is NULL OR m.max_privacy <= 0) " ;
336
+ if ( $user ) {
337
+ $where .= "OR ((m.max_privacy=20)" ;
338
+ $where .= " OR (a.user_id={$user} AND m.max_privacy >= 40)" ;
339
+ if ( class_exists ( 'BuddyPress' ) ) {
340
+ if ( bp_is_active ( 'friends' ) ) {
341
+ $friendship = new RTMediaFriends() ;
342
+ $friends = $friendship -> get_friends_cache ( $user ) ;
343
+ if ( isset($friends) && ! empty ( $friends ) != "" ){
344
+ $where .= " OR (m.max_privacy=40 AND a.user_id IN ('" . implode ( "','" , $friends ) . "'))" ;
345
+ }
346
+ }
347
+ }
348
+ $where .= ')' ;
349
+ }
350
+ if ( function_exists ( "bp_core_get_table_prefix" ) ){
351
+ $bp_prefix = bp_core_get_table_prefix () ;
352
+ }
353
+ else{
354
+ $bp_prefix = "" ;
355
+ }
356
+ if ( strpos ( $select_sql , "SELECT DISTINCT" ) === false ){
357
+ $select_sql = str_replace ( "SELECT" , "SELECT DISTINCT" , $select_sql ) ;
358
+ }
359
+ $media_table = "SELECT *, max( privacy ) as max_privacy from {$rtmedia_model->table_name} group by activity_id";
360
+ $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID LEFT JOIN ( $media_table ) m ON ( a.id = m.activity_id AND m.blog_id = '". get_current_blog_id()."' ) ";
361
+ $where_sql = $where_sql . " AND (NOT EXISTS (SELECT m.activity_id FROM {$bp_prefix}bp_activity_meta m WHERE m.meta_key='rtmedia_privacy' AND m.activity_id=a.id) OR ( {$where} ) )";
362
+ $newsql = "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}";
363
+ }
364
return $newsql;
365
}
366
app/schema/rtm_activity.schema ADDED
@@ -0,0 +1,10 @@
1
+ CREATE TABLE %s (
2
+ activity_id bigint(20) NULL DEFAULT NULL ,
3
+ user_id bigint(20) NOT NULL,
4
+ privacy int(3) NULL DEFAULT NULL ,
5
+ blog_id bigint(20) NULL DEFAULT NULL,
6
+ KEY activity_id (activity_id),
7
+ KEY user_id (user_id),
8
+ KEY privacy (privacy)
9
+ )
10
+ DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci;
index.php CHANGED
@@ -4,7 +4,7 @@
4
Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
Plugin URI: http://rtcamp.com/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
7
- Version: 3.7.8
8
Author: rtCamp
9
Text Domain: rtmedia
10
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
4
Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
Plugin URI: http://rtcamp.com/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
7
+ Version: 3.7.9
8
Author: rtCamp
9
Text Domain: rtmedia
10
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
readme.txt CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
6
License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
Requires at least: WordPress 3.6
8
Tested up to: WordPress 3.9 + BuddyPress 2.0
9
- Stable tag: 3.7.8
10
11
Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works mobile/tablets devices.
12
@@ -133,6 +133,9 @@ http://www.youtube.com/watch?v=dJrykKQGDcs
133
134
Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
135
136
= 3.7.8 =
137
* Fix video player issue in BuddyPress activity
138
@@ -804,8 +807,8 @@ Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_sou
804
805
== Upgrade Notice ==
806
807
- = 3.7.8 =
808
- Requires BuddyPress 1.7 or higher, if using BuddyPress. Fix video player issue in BuddyPress activity.
809
810
== Sponsors ==
811
6
License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
Requires at least: WordPress 3.6
8
Tested up to: WordPress 3.9 + BuddyPress 2.0
9
+ Stable tag: 3.7.9
10
11
Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works mobile/tablets devices.
12
133
134
Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
135
136
+ = 3.7.9 =
137
+ * Added new database table to store activity privacy
138
+
139
= 3.7.8 =
140
* Fix video player issue in BuddyPress activity
141
807
808
== Upgrade Notice ==
809
810
+ = 3.7.9 =
811
+ Requires BuddyPress 1.7 or higher, if using BuddyPress. Added new database table to store activity privacy.
812
813
== Sponsors ==
814