Version Description
- Fixed all warnings and errors with 2.6 thanks to dzapata79, Scott.
- Special thanks are due to Stephan Oberlander who let us use his site for testing and reproducing the errors!
Download this release
Release Info
Developer | saurabhshukla |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.6.5 |
Comparing to | |
See all releases |
Code changes from version 2.6.4 to 2.6.5
- app/main/includes/BPMediaActions.php +309 -284
- app/main/includes/BPMediaHostWordpress.php +911 -907
- app/main/privacy/BPMediaPrivacy.php +43 -34
- app/main/query/BPMediaQuery.php +11 -6
- index.php +1 -1
- readme.txt +8 -3
app/main/includes/BPMediaActions.php
CHANGED
@@ -116,232 +116,232 @@ class BPMediaActions {
|
|
116 |
|
117 |
//add_action('bp_init', 'handle_uploads');
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
$enabled = $bp_media->enabled();
|
346 |
$current_access = BPMediaPrivacy::current_access();
|
347 |
if ( ! $user )
|
@@ -354,28 +354,53 @@ class BPMediaActions {
|
|
354 |
if ( ! $count ) {
|
355 |
$bp_media_count = array( array( 'images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ) );
|
356 |
bp_update_user_meta( $user, 'bp_media_count', $bp_media_count );
|
357 |
-
$
|
358 |
} else {
|
359 |
$total = array(
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
);
|
366 |
$total_count = 0;
|
367 |
-
if ( isset( $count ) && is_array( $count ) ) {
|
368 |
foreach ( $count as $level => $counts ) {
|
369 |
if ( $level <= $current_access ) {
|
370 |
-
|
371 |
-
|
372 |
-
if ( $enabled
|
373 |
-
|
374 |
-
|
375 |
-
$
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
379 |
}
|
380 |
}
|
381 |
}
|
@@ -450,48 +475,48 @@ class BPMediaActions {
|
|
450 |
// echo 'activity=' . bp_is_activity_component();
|
451 |
// echo '<br />';
|
452 |
// echo 'group=' . bp_is_group_home();
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
|
496 |
//This is used only on the uploads page so its added as action in the screens function of upload page.
|
497 |
|
116 |
|
117 |
//add_action('bp_init', 'handle_uploads');
|
118 |
|
119 |
+
/**
|
120 |
+
* Displays the messages that other functions/methods creates according to the BuddyPress' formating
|
121 |
+
*
|
122 |
+
* @since BuddyPress Media 2.0
|
123 |
+
*/
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* @global type $bp
|
128 |
+
*/
|
129 |
+
static function show_messages() {
|
130 |
+
global $bp;
|
131 |
+
if ( is_array( $bp->{BP_MEDIA_SLUG}->messages ) ) {
|
132 |
+
$types = array( 'error', 'updated', 'info' );
|
133 |
+
foreach ( $types as $type ) {
|
134 |
+
if ( count( $bp->{BP_MEDIA_SLUG}->messages[ $type ] ) > 0 ) {
|
135 |
+
BPMediaFunction::show_formatted_error_message( $bp->{BP_MEDIA_SLUG}->messages[ $type ], $type );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media.
|
143 |
+
*
|
144 |
+
* @since BuddyPress Media 2.0
|
145 |
+
*/
|
146 |
+
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
* @global type $bp
|
150 |
+
*/
|
151 |
+
function enqueue_scripts_styles() {
|
152 |
+
|
153 |
+
wp_enqueue_script( 'jquery-ui-tabs' );
|
154 |
+
wp_enqueue_script( 'bp-media-mejs', BP_MEDIA_URL . 'lib/media-element/mediaelement-and-player.min.js', '', '2.6.2' );
|
155 |
+
wp_enqueue_script( 'bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js', '', '2.6.2' );
|
156 |
+
|
157 |
+
global $bp;
|
158 |
+
$cur_group_id = NULL;
|
159 |
+
if ( bp_is_active( "groups" ) )
|
160 |
+
$cur_group_id = bp_get_current_group_id();
|
161 |
+
$bp_media_vars = array(
|
162 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
163 |
+
'page' => 1,
|
164 |
+
'current_action' => $cur_group_id ? (empty( $bp->action_variables ) ? BP_MEDIA_IMAGES_SLUG : $bp->action_variables[ 0 ]) : (isset( $bp->current_action ) ? $bp->current_action : false),
|
165 |
+
'action_variables' => isset( $bp->action_variables ) ? (empty( $bp->action_variables ) ? array( BP_MEDIA_IMAGES_SLUG ) : $bp->action_variables) : array( BP_MEDIA_IMAGES_SLUG ),
|
166 |
+
'displayed_user' => bp_displayed_user_id(),
|
167 |
+
'loggedin_user' => bp_loggedin_user_id(),
|
168 |
+
'current_group' => $cur_group_id,
|
169 |
+
);
|
170 |
+
|
171 |
+
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
172 |
+
wp_enqueue_style( 'bp-media-mecss', BP_MEDIA_URL . 'lib/media-element/mediaelementplayer.min.css', '', '2.6.2' );
|
173 |
+
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '', '2.6.2' );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
*
|
178 |
+
* @global integer $bp_media_count
|
179 |
+
* @global object $wpdb
|
180 |
+
* @param array $args
|
181 |
+
* @return boolean
|
182 |
+
*/
|
183 |
+
static function delete_activity_handler( $args ) {
|
184 |
+
error_log( 'Delete delete :)' );
|
185 |
+
remove_action( 'bp_media_before_delete_media', 'BPMediaActions::delete_media_handler' );
|
186 |
+
global $bp_media_count, $wpdb;
|
187 |
+
if ( ! array_key_exists( 'id', $args ) )
|
188 |
+
return;
|
189 |
+
|
190 |
+
$activity_id = $args[ 'id' ];
|
191 |
+
if ( intval( $activity_id ) ) {
|
192 |
+
$query = "SELECT post_id from $wpdb->postmeta WHERE meta_key='bp_media_child_activity' AND meta_value={$activity_id}";
|
193 |
+
$result = $wpdb->get_results( $query );
|
194 |
+
if ( ! (is_array( $result ) && count( $result ) == 1 ) )
|
195 |
+
return;
|
196 |
+
$post_id = $result[ 0 ]->post_id;
|
197 |
+
try {
|
198 |
+
$post = get_post( $post_id );
|
199 |
+
if ( ! isset( $post->post_type ) )
|
200 |
+
return false;
|
201 |
+
switch ( $post->post_type ) {
|
202 |
+
case 'attachment':
|
203 |
+
$media = new BPMediaHostWordpress( $post_id );
|
204 |
+
$media->delete_media();
|
205 |
+
break;
|
206 |
+
case 'bp_media_album':
|
207 |
+
$album = new BPMediaAlbum( $post_id );
|
208 |
+
$album->delete_album();
|
209 |
+
break;
|
210 |
+
default:
|
211 |
+
wp_delete_post( $post_id );
|
212 |
+
}
|
213 |
+
} catch ( Exception $e ) {
|
214 |
+
error_log( 'Media tried to delete was already deleted' );
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
*
|
221 |
+
* @param type $media_id
|
222 |
+
* @return boolean
|
223 |
+
*/
|
224 |
+
static function delete_media_handler( $media_id ) {
|
225 |
+
/* @var $media BPMediaHostWordpress */
|
226 |
+
remove_action( 'bp_before_activity_delete', 'BPMediaActions::delete_activity_handler' );
|
227 |
+
$activity_id = get_post_meta( $media_id, 'bp_media_child_activity', true );
|
228 |
+
if ( $activity_id == NULL )
|
229 |
+
return false;
|
230 |
+
bp_activity_delete_by_activity_id( $activity_id );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Called on bp_init by screen functions
|
235 |
+
*
|
236 |
+
* @uses global $bp, $bp_media_query
|
237 |
+
*
|
238 |
+
* @since BuddyPress Media 2.0
|
239 |
+
*/
|
240 |
+
|
241 |
+
/**
|
242 |
+
*
|
243 |
+
* @global type $bp
|
244 |
+
* @global WP_Query $bp_media_query
|
245 |
+
* @global type $bp_media_posts_per_page
|
246 |
+
*/
|
247 |
+
function set_query() {
|
248 |
+
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
249 |
+
switch ( $bp->current_action ) {
|
250 |
+
case BP_MEDIA_IMAGES_SLUG:
|
251 |
+
$type = 'image';
|
252 |
+
break;
|
253 |
+
case BP_MEDIA_AUDIO_SLUG:
|
254 |
+
$type = 'audio';
|
255 |
+
break;
|
256 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
257 |
+
$type = 'video';
|
258 |
+
break;
|
259 |
+
default :
|
260 |
+
$type = null;
|
261 |
+
}
|
262 |
+
if ( isset( $bp->action_variables ) && is_array( $bp->action_variables ) && isset( $bp->action_variables[ 0 ] ) && $bp->action_variables[ 0 ] == 'page' && isset( $bp->action_variables[ 1 ] ) && is_numeric( $bp->action_variables[ 1 ] ) ) {
|
263 |
+
$paged = $bp->action_variables[ 1 ];
|
264 |
+
} else {
|
265 |
+
$paged = 1;
|
266 |
+
}
|
267 |
+
if ( $type ) {
|
268 |
+
$args = array(
|
269 |
+
'post_type' => 'attachment',
|
270 |
+
'post_status' => 'any',
|
271 |
+
'post_mime_type' => $type,
|
272 |
+
'author' => $bp->displayed_user->id,
|
273 |
+
'meta_key' => 'bp-media-key',
|
274 |
+
'meta_value' => $bp->displayed_user->id,
|
275 |
+
'meta_compare' => '=',
|
276 |
+
'paged' => $paged,
|
277 |
+
'posts_per_page' => $bp_media_posts_per_page
|
278 |
+
);
|
279 |
+
$bp_media_query = new WP_Query( $args );
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Adds a download button and edit button on single entry pages of media files.
|
285 |
+
*
|
286 |
+
* @uses $bp_media_options Global variable
|
287 |
+
*
|
288 |
+
* @since BuddyPress Media 2.0
|
289 |
+
*/
|
290 |
+
|
291 |
+
/**
|
292 |
+
*
|
293 |
+
* @global type $bp_media_current_entry
|
294 |
+
* @global type $bp_media_options
|
295 |
+
* @return boolean
|
296 |
+
*/
|
297 |
+
function action_buttons() {
|
298 |
+
if ( ! in_array( 'bp_media_current_entry', $GLOBALS ) )
|
299 |
+
return false;
|
300 |
+
global $bp_media_current_entry, $bp_media;
|
301 |
+
|
302 |
+
if ( $bp_media_current_entry != NULL ) {
|
303 |
+
$featured_post = get_post_meta( $bp_media_current_entry->get_id(), 'featured', true );
|
304 |
+
|
305 |
+
if ( bp_displayed_user_id() == bp_loggedin_user_id() )
|
306 |
+
echo '<a href="' . $bp_media_current_entry->get_edit_url()
|
307 |
+
. '" class="button item-button bp-secondary-action bp-media-edit" title="'
|
308 |
+
. __( 'Edit Media', BP_MEDIA_TXT_DOMAIN ) . '">' . __( 'Edit', BP_MEDIA_TXT_DOMAIN ) . '</a>';
|
309 |
+
if ( isset( $bp_media->options[ 'download_enabled' ] ) )
|
310 |
+
echo '<a href="' . $bp_media_current_entry->get_attachment_url()
|
311 |
+
. '" class="button item-button bp-secondary-action bp-media-download" title="'
|
312 |
+
. __( 'Download', BP_MEDIA_TXT_DOMAIN ) . '">' . __( 'Download', BP_MEDIA_TXT_DOMAIN ) . '</a>';
|
313 |
+
|
314 |
+
if ( (bp_displayed_user_id() == bp_loggedin_user_id()) && ($bp_media_current_entry->get_type() == 'image') ) {
|
315 |
+
if ( get_post_thumbnail_id( $bp_media_current_entry->get_album_id() ) != $bp_media_current_entry->get_id() )
|
316 |
+
echo '<a href="#" data-album-id="' . $bp_media_current_entry->get_album_id()
|
317 |
+
. '" data-post-id="' . $bp_media_current_entry->get_id()
|
318 |
+
. '" class="button item-button bp-secondary-action bp-media-featured" title="'
|
319 |
+
. __( 'Set as Album Cover', BP_MEDIA_TXT_DOMAIN ) . '">' . __( 'Set as Album Cover', BP_MEDIA_TXT_DOMAIN ) . '</a>';
|
320 |
+
else
|
321 |
+
echo '<a href="#" data-album-id="'
|
322 |
+
. $bp_media_current_entry->get_album_id() . '" data-post-id="' . $bp_media_current_entry->get_id()
|
323 |
+
. '" class="button item-button bp-secondary-action bp-media-featured" title="'
|
324 |
+
. __( 'Unset as Album Cover', BP_MEDIA_TXT_DOMAIN ) . '">' . __( 'Unset as Album Cover', BP_MEDIA_TXT_DOMAIN ) . '</a>';
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
/* Should be used with Content Disposition Type for media files set to attachment */
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Shows the media count of a user in the tabs
|
333 |
+
*
|
334 |
+
* @since BuddyPress Media 2.0
|
335 |
+
*/
|
336 |
+
|
337 |
+
/**
|
338 |
+
*
|
339 |
+
* @global type $bp_media_count
|
340 |
+
* @param type $user
|
341 |
+
* @return boolean
|
342 |
+
*/
|
343 |
+
static function init_count( $user = null ) {
|
344 |
+
global $bp_media_count, $bp_media;
|
345 |
$enabled = $bp_media->enabled();
|
346 |
$current_access = BPMediaPrivacy::current_access();
|
347 |
if ( ! $user )
|
354 |
if ( ! $count ) {
|
355 |
$bp_media_count = array( array( 'images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ) );
|
356 |
bp_update_user_meta( $user, 'bp_media_count', $bp_media_count );
|
357 |
+
$bp_media_count = bp_get_user_meta( $user, 'bp_media_count', true );
|
358 |
} else {
|
359 |
$total = array(
|
360 |
+
0 => array(
|
361 |
+
'images' => 0,
|
362 |
+
'videos' => 0,
|
363 |
+
'audio' => 0,
|
364 |
+
'albums' => 0,
|
365 |
+
'total' => 0
|
366 |
+
),
|
367 |
+
2 => array(
|
368 |
+
'images' => 0,
|
369 |
+
'videos' => 0,
|
370 |
+
'audio' => 0,
|
371 |
+
'albums' => 0,
|
372 |
+
'total' => 0
|
373 |
+
),
|
374 |
+
4 => array(
|
375 |
+
'images' => 0,
|
376 |
+
'videos' => 0,
|
377 |
+
'audio' => 0,
|
378 |
+
'albums' => 0,
|
379 |
+
'total' => 0
|
380 |
+
),
|
381 |
+
6 => array(
|
382 |
+
'images' => 0,
|
383 |
+
'videos' => 0,
|
384 |
+
'audio' => 0,
|
385 |
+
'albums' => 0,
|
386 |
+
'total' => 0
|
387 |
+
),
|
388 |
);
|
389 |
$total_count = 0;
|
390 |
+
if ( isset( $count ) && is_array( $count ) && count( $count ) > 0 ) {
|
391 |
foreach ( $count as $level => $counts ) {
|
392 |
if ( $level <= $current_access ) {
|
393 |
+
if ( isset( $counts ) && is_array( $counts ) && count( $counts ) > 0 ) {
|
394 |
+
foreach ( $counts as $media => $number ) {
|
395 |
+
if ( array_key_exists( $media, $enabled ) || array_key_exists( $media . 's', $enabled ) ) {
|
396 |
+
if ( $enabled[ $media ] ) {
|
397 |
+
$medias = $media;
|
398 |
+
if ( $media != 'audio' )
|
399 |
+
$medias .='s';
|
400 |
+
$total[ $medias ] = $total[ $medias ] + $number;
|
401 |
+
if ( $media != 'album' ) {
|
402 |
+
$total_count = $total_count + $total[ $medias ];
|
403 |
+
}
|
404 |
}
|
405 |
}
|
406 |
}
|
475 |
// echo 'activity=' . bp_is_activity_component();
|
476 |
// echo '<br />';
|
477 |
// echo 'group=' . bp_is_group_home();
|
478 |
+
if ( bp_is_activity_component() || bp_is_group_home() ) {
|
479 |
+
$params = array(
|
480 |
+
'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
|
481 |
+
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
482 |
+
'browse_button' => 'bp-media-activity-upload-browse-button',
|
483 |
+
'container' => 'bp-media-activity-upload-ui',
|
484 |
+
'drop_element' => 'drag-drop-area',
|
485 |
+
'filters' => apply_filters( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3" ) ) ),
|
486 |
+
'max_file_size' => min( array( ini_get( 'upload_max_filesize' ), ini_get( 'post_max_size' ) ) ),
|
487 |
+
'multipart' => true,
|
488 |
+
'urlstream_upload' => true,
|
489 |
+
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
490 |
+
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
491 |
+
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
492 |
+
'multi_selection' => true,
|
493 |
+
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
494 |
+
);
|
495 |
+
wp_enqueue_script( 'bp-media-activity-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-activity-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ), '2.6.2' );
|
496 |
+
wp_localize_script( 'bp-media-activity-uploader', 'bp_media_uploader_params', $params );
|
497 |
+
wp_localize_script( 'bp-media-activity-uploader', 'activity_ajax_url', admin_url( 'admin-ajax.php' ) );
|
498 |
+
} elseif ( in_array( bp_current_action(), array( BP_MEDIA_IMAGES_SLUG, BP_MEDIA_VIDEOS_SLUG, BP_MEDIA_AUDIO_SLUG, BP_MEDIA_SLUG, BP_MEDIA_ALBUMS_SLUG ) ) ) {
|
499 |
+
$params = array(
|
500 |
+
'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
|
501 |
+
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
502 |
+
'browse_button' => 'bp-media-upload-browse-button',
|
503 |
+
'container' => 'bp-media-upload-ui',
|
504 |
+
'drop_element' => 'drag-drop-area',
|
505 |
+
'filters' => apply_filters( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3" ) ) ),
|
506 |
+
'max_file_size' => min( array( ini_get( 'upload_max_filesize' ), ini_get( 'post_max_size' ) ) ),
|
507 |
+
'multipart' => true,
|
508 |
+
'urlstream_upload' => true,
|
509 |
+
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
510 |
+
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
511 |
+
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
512 |
+
'multi_selection' => true,
|
513 |
+
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
514 |
+
);
|
515 |
+
wp_enqueue_script( 'bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ), '2.6.2' );
|
516 |
+
wp_localize_script( 'bp-media-uploader', 'bp_media_uploader_params', $params );
|
517 |
+
}
|
518 |
+
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '', '2.6.2' );
|
519 |
+
}
|
520 |
|
521 |
//This is used only on the uploads page so its added as action in the screens function of upload page.
|
522 |
|
app/main/includes/BPMediaHostWordpress.php
CHANGED
@@ -2,69 +2,69 @@
|
|
2 |
|
3 |
class BPMediaHostWordpress {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
if (!'bp_media_album' == $media->post_type || !empty($media->post_mime_type))
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
// $required_access = BPMediaPrivacy::required_access($media->ID);
|
69 |
// $current_access = BPMediaPrivacy::current_access($media->ID);
|
70 |
// $has_access = BPMediaPrivacy::has_access($media->ID);
|
@@ -72,869 +72,873 @@ class BPMediaHostWordpress {
|
|
72 |
global $bp;
|
73 |
// $messages = BPMediaPrivacy::get_messages( $this->type,$bp->displayed_user->fullname );
|
74 |
$this->id = $media->ID;
|
75 |
-
$meta_key = get_post_meta($this->id, 'bp-media-key', true);
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
// if($this->group_id<=0){
|
86 |
// if(!$has_access){
|
87 |
// //throw new Exception($messages[$required_access]);
|
88 |
// }
|
89 |
// }
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
$this->mime_type = $media->post_mime_type;
|
96 |
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
do_action('bp_media_no_object_after_add_media', $this->id, $this->type);
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
|
|
|
|
|
|
|
|
873 |
// $this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail', true);
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
FROM $wpdb->posts
|
911 |
WHERE
|
912 |
post_title = $post_wall
|
913 |
AND post_author = '" . get_current_user_id() . "'
|
914 |
AND post_type='bp_media_album'"
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
FROM $wpdb->posts
|
920 |
INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
921 |
AND $wpdb->postmeta.meta_key = 'bp-media-key'
|
922 |
AND $wpdb->postmeta.meta_value = -$group
|
923 |
-
AND $wpdb->posts.post_title = $post_wall");
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
|
939 |
}
|
940 |
?>
|
2 |
|
3 |
class BPMediaHostWordpress {
|
4 |
|
5 |
+
/**
|
6 |
+
* Private variables not to be accessible outside this class' member functions
|
7 |
+
*/
|
8 |
+
protected $id, //id of the entry
|
9 |
+
$name, //Name of the entry
|
10 |
+
$description, //Description of the entry
|
11 |
+
$url, //URL of the entry
|
12 |
+
$type, //Type of the entry (Video, Image or Audio)
|
13 |
+
$owner, //Owner of the entry
|
14 |
+
$delete_url, //The delete url for the media
|
15 |
+
$thumbnail_id, //The thumbnail's id
|
16 |
+
$album_id, //The album id to which the media belongs
|
17 |
+
$edit_url, //The edit page's url for the media
|
18 |
+
$group_id; //The group id of the current media file if it belongs to a group
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructs a new BP_Media_Host_Wordpress element
|
22 |
+
*
|
23 |
+
* @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
|
24 |
+
*
|
25 |
+
* @since BuddyPress Media 2.0
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @param type $media_id
|
31 |
+
*/
|
32 |
+
function __construct( $media_id = '' ) {
|
33 |
+
if ( ! $media_id == '' ) {
|
34 |
+
$this->init( $media_id );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initializes the object with the variables from the post
|
40 |
+
*
|
41 |
+
* @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
|
42 |
+
*
|
43 |
+
* @since BuddyPress Media 2.0
|
44 |
+
*/
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @param type $media_id
|
49 |
+
* @return boolean
|
50 |
+
* @throws Exception
|
51 |
+
*/
|
52 |
+
function init( $media_id = '' ) {
|
53 |
+
if ( is_object( $media_id ) ) {
|
54 |
+
$media = $media_id;
|
55 |
+
} else {
|
56 |
+
$media = &get_post( $media_id );
|
57 |
+
}
|
58 |
+
if ( empty( $media->ID ) )
|
59 |
+
throw new Exception( __( 'Sorry, the requested media does not exist.', BP_MEDIA_TXT_DOMAIN ) );
|
60 |
+
if ( ! 'bp_media_album' == $media->post_type || ! empty( $media->post_mime_type ) )
|
61 |
+
preg_match_all( '/audio|video|image/i', $media->post_mime_type, $result );
|
62 |
+
else
|
63 |
+
$result[ 0 ][ 0 ] = 'album';
|
64 |
+
if ( isset( $result[ 0 ][ 0 ] ) )
|
65 |
+
$this->type = $result[ 0 ][ 0 ];
|
66 |
+
else
|
67 |
+
return false;
|
68 |
// $required_access = BPMediaPrivacy::required_access($media->ID);
|
69 |
// $current_access = BPMediaPrivacy::current_access($media->ID);
|
70 |
// $has_access = BPMediaPrivacy::has_access($media->ID);
|
72 |
global $bp;
|
73 |
// $messages = BPMediaPrivacy::get_messages( $this->type,$bp->displayed_user->fullname );
|
74 |
$this->id = $media->ID;
|
75 |
+
$meta_key = get_post_meta( $this->id, 'bp-media-key', true );
|
76 |
+
|
77 |
+
/**
|
78 |
+
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
79 |
+
* if the value is less than 0 it means it the group id to which the media belongs
|
80 |
+
* and if its greater than 0 then it means its the author id of the uploader
|
81 |
+
* But for use in the class, we use group_id as positive integer even though
|
82 |
+
* we use it as negative value in the bp-media-key meta key
|
83 |
+
*/
|
84 |
+
$this->group_id = $meta_key < 0 ? -$meta_key : 0;
|
85 |
// if($this->group_id<=0){
|
86 |
// if(!$has_access){
|
87 |
// //throw new Exception($messages[$required_access]);
|
88 |
// }
|
89 |
// }
|
90 |
|
91 |
+
$this->description = $media->post_content;
|
92 |
+
$this->name = $media->post_title;
|
93 |
+
$this->owner = $media->post_author;
|
94 |
+
$this->album_id = $media->post_parent;
|
95 |
$this->mime_type = $media->post_mime_type;
|
96 |
|
97 |
|
98 |
+
$this->set_permalinks();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Handles the uploaded media file and creates attachment post for the file.
|
103 |
+
*
|
104 |
+
* @since BuddyPress Media 2.0
|
105 |
+
*/
|
106 |
+
|
107 |
+
/**
|
108 |
+
*
|
109 |
+
* @global type $bp
|
110 |
+
* @global type $wpdb
|
111 |
+
* @global type $bp_media_count
|
112 |
+
* @global type $bp_media
|
113 |
+
* @param type $name
|
114 |
+
* @param type $description
|
115 |
+
* @param type $album_id
|
116 |
+
* @param type $group
|
117 |
+
* @param type $is_multiple
|
118 |
+
* @throws Exception
|
119 |
+
* @uses global var $_FILES
|
120 |
+
*/
|
121 |
+
function add_media( $name, $description, $album_id = 0, $group = 0, $is_multiple = false, $is_activity = false, $files = false ) {
|
122 |
+
do_action( 'bp_media_before_add_media' );
|
123 |
+
|
124 |
+
global $bp, $wpdb, $bp_media;
|
125 |
+
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
126 |
+
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
127 |
+
|
128 |
+
$post_id = $this->check_and_create_album( $album_id, $group );
|
129 |
+
|
130 |
+
if ( ! $files ) {
|
131 |
+
$files = $_FILES[ 'bp_media_file' ];
|
132 |
+
$file = wp_handle_upload( $files );
|
133 |
+
} else {
|
134 |
+
$file = wp_handle_sideload( $files );
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( isset( $file[ 'error' ] ) || $file === null ) {
|
138 |
+
throw new Exception( __( 'Error Uploading File', BP_MEDIA_TXT_DOMAIN ) );
|
139 |
+
}
|
140 |
+
|
141 |
+
$attachment = array( );
|
142 |
+
$url = $file[ 'url' ];
|
143 |
+
$type = $file[ 'type' ];
|
144 |
+
$file = $file[ 'file' ];
|
145 |
+
$title = $name;
|
146 |
+
$content = $description;
|
147 |
+
$attachment = array(
|
148 |
+
'post_mime_type' => $type,
|
149 |
+
'guid' => $url,
|
150 |
+
'post_title' => $title,
|
151 |
+
'post_content' => $content,
|
152 |
+
'post_parent' => $post_id,
|
153 |
+
);
|
154 |
+
switch ( $type ) {
|
155 |
+
case 'video/mp4' :
|
156 |
+
case 'video/quicktime' :
|
157 |
+
$type = 'video';
|
158 |
+
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
159 |
+
try {
|
160 |
+
$getID3 = new getID3;
|
161 |
+
$vid_info = $getID3->analyze( $file );
|
162 |
+
} catch ( Exception $e ) {
|
163 |
+
unlink( $file );
|
164 |
+
$activity_content = false;
|
165 |
+
throw new Exception( __( 'MP4 file you have uploaded is corrupt.', BP_MEDIA_TXT_DOMAIN ) );
|
166 |
+
}
|
167 |
+
if ( is_array( $vid_info ) ) {
|
168 |
+
if ( ! array_key_exists( 'error', $vid_info ) && array_key_exists( 'fileformat', $vid_info ) && array_key_exists( 'video', $vid_info ) && array_key_exists( 'fourcc', $vid_info[ 'video' ] ) ) {
|
169 |
+
if ( ! ($vid_info[ 'fileformat' ] == 'mp4' && $vid_info[ 'video' ][ 'fourcc' ] == 'avc1') ) {
|
170 |
+
unlink( $file );
|
171 |
+
$activity_content = false;
|
172 |
+
throw new Exception( __( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', BP_MEDIA_TXT_DOMAIN ) );
|
173 |
+
}
|
174 |
+
} else {
|
175 |
+
unlink( $file );
|
176 |
+
$activity_content = false;
|
177 |
+
throw new Exception( __( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', BP_MEDIA_TXT_DOMAIN ) );
|
178 |
+
}
|
179 |
+
} else {
|
180 |
+
unlink( $file );
|
181 |
+
$activity_content = false;
|
182 |
+
throw new Exception( __( 'The MP4 file you have uploaded is not a video file.', BP_MEDIA_TXT_DOMAIN ) );
|
183 |
+
}
|
184 |
+
break;
|
185 |
+
case 'audio/mpeg' :
|
186 |
+
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
187 |
+
try {
|
188 |
+
$getID3 = new getID3;
|
189 |
+
$file_info = $getID3->analyze( $file );
|
190 |
+
} catch ( Exception $e ) {
|
191 |
+
unlink( $file );
|
192 |
+
$activity_content = false;
|
193 |
+
throw new Exception( __( 'MP3 file you have uploaded is currupt.', BP_MEDIA_TXT_DOMAIN ) );
|
194 |
+
}
|
195 |
+
if ( is_array( $file_info ) ) {
|
196 |
+
if ( ! array_key_exists( 'error', $file_info ) && array_key_exists( 'fileformat', $file_info ) && array_key_exists( 'audio', $file_info ) && array_key_exists( 'dataformat', $file_info[ 'audio' ] ) ) {
|
197 |
+
if ( ! ($file_info[ 'fileformat' ] == 'mp3' && $file_info[ 'audio' ][ 'dataformat' ] == 'mp3') ) {
|
198 |
+
unlink( $file );
|
199 |
+
$activity_content = false;
|
200 |
+
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
201 |
+
}
|
202 |
+
} else {
|
203 |
+
unlink( $file );
|
204 |
+
$activity_content = false;
|
205 |
+
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
206 |
+
}
|
207 |
+
} else {
|
208 |
+
unlink( $file );
|
209 |
+
$activity_content = false;
|
210 |
+
throw new Exception( __( 'The MP3 file you have uploaded is not an audio file.', BP_MEDIA_TXT_DOMAIN ) );
|
211 |
+
}
|
212 |
+
$type = 'audio';
|
213 |
+
break;
|
214 |
+
case 'image/gif' :
|
215 |
+
case 'image/jpeg' :
|
216 |
+
case 'image/png' :
|
217 |
+
$type = 'image';
|
218 |
+
break;
|
219 |
+
default :
|
220 |
+
unlink( $file );
|
221 |
+
$activity_content = false;
|
222 |
+
throw new Exception( __( 'Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', BP_MEDIA_TXT_DOMAIN ) );
|
223 |
+
}
|
224 |
+
echo $attachment_id = wp_insert_attachment( $attachment, $file, $post_id );
|
225 |
+
if ( ! is_wp_error( $attachment_id ) ) {
|
226 |
+
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
|
227 |
+
} else {
|
228 |
+
unlink( $file );
|
229 |
+
throw new Exception( __( 'Error creating attachment for the media file, please try again', BP_MEDIA_TXT_DOMAIN ) );
|
230 |
+
}
|
231 |
+
$this->id = $attachment_id;
|
232 |
+
$this->name = $name;
|
233 |
+
$this->description = $description;
|
234 |
+
$this->type = $type;
|
235 |
+
$this->owner = get_current_user_id();
|
236 |
+
$this->album_id = $post_id;
|
237 |
+
$this->group_id = $group;
|
238 |
+
$this->set_permalinks();
|
239 |
+
if ( $group == 0 ) {
|
240 |
+
update_post_meta( $attachment_id, 'bp-media-key', get_current_user_id() );
|
241 |
+
} else {
|
242 |
+
update_post_meta( $attachment_id, 'bp-media-key', (-$group ) );
|
243 |
+
}
|
244 |
+
do_action( 'bp_media_after_add_media', $this, $is_multiple, $is_activity, $group );
|
245 |
+
do_action( 'bp_media_no_object_after_add_media', $this->id, $this->type );
|
246 |
+
return $attachment_id;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Fetches the content of the activity of media upload based on its type
|
251 |
+
*
|
252 |
+
*/
|
253 |
+
|
254 |
+
/**
|
255 |
+
*
|
256 |
+
* @global type $bp_media_counter
|
257 |
+
* @global type $bp_media_default_excerpts
|
258 |
+
* @global type $bp_media
|
259 |
+
* @return boolean|string
|
260 |
+
*/
|
261 |
+
function get_media_activity_content() {
|
262 |
+
global $bp_media_counter, $bp_media_default_excerpts, $bp_media;
|
263 |
+
$attachment_id = $this->id;
|
264 |
+
$activity_content = apply_filters( 'bp_media_single_activity_title', '<div class="bp_media_title"><a href="' . $this->url . '" title="' . __( $this->description, BP_MEDIA_TXT_DOMAIN ) . '">' . __( wp_html_excerpt( $this->name, $bp_media_default_excerpts[ 'activity_entry_title' ] ), BP_MEDIA_TXT_DOMAIN ) . '</a></div>' );
|
265 |
+
$activity_content .='<div class="bp_media_content">';
|
266 |
+
switch ( $this->type ) {
|
267 |
+
case 'video' :
|
268 |
+
if ( $this->thumbnail_id ) {
|
269 |
+
$image_array = image_downsize( $this->thumbnail_id, 'bp_media_activity_image' );
|
270 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<video poster="' . $image_array[ 0 ] . '" src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" height="240" type="video/mp4" id="bp_media_video_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none"></video></span><script>bp_media_create_element("bp_media_video_' . $this->id . '_' . $bp_media_counter . '");</script>', $this, true );
|
271 |
+
} else {
|
272 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<video src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" height="240" type="video/mp4" id="bp_media_video_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none"></video></span><script>bp_media_create_element("bp_media_video_' . $this->id . '_' . $bp_media_counter . '");</script>', $this, true );
|
273 |
+
}
|
274 |
+
break;
|
275 |
+
case 'audio' :
|
276 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<audio src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" type="audio/mp3" id="bp_media_audio_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none" ></audio></span><script>bp_media_create_element("bp_media_audio_' . $this->id . '_' . $bp_media_counter . '");</script>', $this, true );
|
277 |
+
$type = 'audio';
|
278 |
+
break;
|
279 |
+
case 'image' :
|
280 |
+
$image_array = image_downsize( $attachment_id, 'bp_media_activity_image' );
|
281 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<a href="' . $this->url . '" title="' . __( $this->name, BP_MEDIA_TXT_DOMAIN ) . '"><img src="' . $image_array[ 0 ] . '" id="bp_media_image_' . $this->id . '_' . $bp_media_counter ++ . '" alt="' . __( $this->name, BP_MEDIA_TXT_DOMAIN ) . '" /></a>', $this, true );
|
282 |
+
$type = 'image';
|
283 |
+
break;
|
284 |
+
default :
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
$activity_content .= '</div>';
|
288 |
+
$activity_content .= apply_filters( 'bp_media_single_activity_description', '<div class="bp_media_description">' . wp_html_excerpt( $this->description, $bp_media_default_excerpts[ 'activity_entry_description' ] ) . '</div>' );
|
289 |
+
return $activity_content;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Returns the single media entry's URL
|
294 |
+
*/
|
295 |
+
|
296 |
+
/**
|
297 |
+
*
|
298 |
+
* @return boolean
|
299 |
+
*/
|
300 |
+
function get_media_activity_url() {
|
301 |
+
if ( ! bp_is_activity_component() )
|
302 |
+
return false;
|
303 |
+
$activity_url = $this->url;
|
304 |
+
return $activity_url;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Returns the media activity's action text
|
309 |
+
*/
|
310 |
+
|
311 |
+
/**
|
312 |
+
*
|
313 |
+
* @global type $bp_media
|
314 |
+
* @return boolean
|
315 |
+
*/
|
316 |
+
function get_media_activity_action() {
|
317 |
+
global $bp_media;
|
318 |
+
if ( ! bp_is_activity_component() )
|
319 |
+
return false;
|
320 |
+
$activity_action = sprintf( __( "%s uploaded a media.", BP_MEDIA_TXT_DOMAIN ), bp_core_get_userlink( $this->owner ) );
|
321 |
+
return $activity_action;
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Returns the HTML for content of the single entry page of the Media Entry
|
326 |
+
*/
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* @global type $bp_media_default_excerpts
|
331 |
+
* @global type $bp_media
|
332 |
+
* @return boolean|string
|
333 |
+
*/
|
334 |
+
function get_media_single_content() {
|
335 |
+
global $bp_media_default_excerpts, $bp_media;
|
336 |
+
|
337 |
+
$default_sizes = $bp_media->media_sizes();
|
338 |
+
$content = '';
|
339 |
+
if ( $this->group_id > 0 ) {
|
340 |
+
|
341 |
+
$content .= '<div class="bp_media_author">' . __( "Uploaded by ", BP_MEDIA_TXT_DOMAIN ) . bp_core_get_userlink( $this->owner ) . '</div>';
|
342 |
+
}
|
343 |
+
$content .= '<div class="bp_media_content">';
|
344 |
+
switch ( $this->type ) {
|
345 |
+
case 'video' :
|
346 |
+
if ( $this->thumbnail_id ) {
|
347 |
+
$image_array = image_downsize( $this->thumbnail_id, 'bp_media_single_image' );
|
348 |
+
$content.=apply_filters( 'bp_media_single_content_filter', '<video poster="' . $image_array[ 0 ] . '" src="' . wp_get_attachment_url( $this->id ) . '" width="' . $default_sizes[ 'single_video' ][ 'width' ] . '" height="' . ($default_sizes[ 'single_video' ][ 'height' ] == 0 ? 'auto' : $default_sizes[ 'single_video' ][ 'height' ]) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>', $this );
|
349 |
+
} else {
|
350 |
+
$content.=apply_filters( 'bp_media_single_content_filter', '<video src="' . wp_get_attachment_url( $this->id ) . '" width="' . $default_sizes[ 'single_video' ][ 'width' ] . '" height="' . ($default_sizes[ 'single_video' ][ 'height' ] == 0 ? 'auto' : $default_sizes[ 'single_video' ][ 'height' ]) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>', $this );
|
351 |
+
}
|
352 |
+
break;
|
353 |
+
case 'audio' :
|
354 |
+
$content.=apply_filters( 'bp_media_single_content_filter', '<audio src="' . wp_get_attachment_url( $this->id ) . '" width="' . $default_sizes[ 'single_audio' ][ 'width' ] . '" type="audio/mp3" id="bp_media_audio_' . $this->id . '" controls="controls" preload="none" ></audio><script>bp_media_create_element("bp_media_audio_' . $this->id . '");</script>', $this );
|
355 |
+
break;
|
356 |
+
case 'image' :
|
357 |
+
$image_array = image_downsize( $this->id, 'bp_media_single_image' );
|
358 |
+
$content.=apply_filters( 'bp_media_single_content_filter', '<img src="' . $image_array[ 0 ] . '" id="bp_media_image_' . $this->id . '" />', $this );
|
359 |
+
break;
|
360 |
+
default :
|
361 |
+
return false;
|
362 |
+
}
|
363 |
+
$content .= '</div>';
|
364 |
+
$content .= '<div class="bp_media_description">' . wp_html_excerpt( $this->description, $bp_media_default_excerpts[ 'single_entry_description' ] ) . '</div>';
|
365 |
+
return $content;
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Returns the HTML for title of the single entry page of the Media Entry
|
370 |
+
*/
|
371 |
+
|
372 |
+
/**
|
373 |
+
*
|
374 |
+
* @global type $bp_media_default_excerpts
|
375 |
+
* @global type $bp_media
|
376 |
+
* @return string
|
377 |
+
*/
|
378 |
+
function get_media_single_title() {
|
379 |
+
global $bp_media_default_excerpts, $bp_media;
|
380 |
+
$content = wp_html_excerpt( $this->name, $bp_media_default_excerpts[ 'single_entry_title' ] );
|
381 |
+
return $content;
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
386 |
+
*/
|
387 |
+
|
388 |
+
/**
|
389 |
+
*
|
390 |
+
* @global type $bp_media
|
391 |
+
* @return boolean
|
392 |
+
*/
|
393 |
+
function get_media_gallery_content() {
|
394 |
+
global $bp_media;
|
395 |
+
$attachment = $this->id;
|
396 |
+
switch ( $this->type ) {
|
397 |
+
case 'video' :
|
398 |
+
if ( $this->thumbnail_id ) {
|
399 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
400 |
+
$thumb_url = $medium_array[ 0 ];
|
401 |
+
} else {
|
402 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/video_thumb.png';
|
403 |
+
}
|
404 |
+
?>
|
405 |
+
<li>
|
406 |
+
<a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>">
|
407 |
+
<img src="<?php echo apply_filters( 'bp_media_video_thumb', $thumb_url, $attachment, $this->type ); ?>" />
|
408 |
+
</a>
|
409 |
+
<h3 title="<?php echo $this->name; ?>"><a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>"><?php echo $this->name; ?></a></h3>
|
410 |
+
</li>
|
411 |
+
<?php
|
412 |
+
break;
|
413 |
+
case 'audio' :
|
414 |
+
if ( $this->thumbnail_id ) {
|
415 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
416 |
+
$thumb_url = $medium_array[ 0 ];
|
417 |
+
} else {
|
418 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/audio_thumb.png';
|
419 |
+
}
|
420 |
+
?>
|
421 |
+
<li>
|
422 |
+
<a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>">
|
423 |
+
<img src="<?php echo $thumb_url ?>" />
|
424 |
+
</a>
|
425 |
+
<h3 title="<?php echo $this->name; ?>"><a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>"><?php echo $this->name ?></a></h3>
|
426 |
+
</li>
|
427 |
+
<?php
|
428 |
+
break;
|
429 |
+
case 'image' :
|
430 |
+
$medium_array = image_downsize( $attachment, 'thumbnail' );
|
431 |
+
$medium_path = $medium_array[ 0 ];
|
432 |
+
?>
|
433 |
+
<li>
|
434 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
435 |
+
<img src="<?php echo $medium_path ?>" />
|
436 |
+
</a>
|
437 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>"><?php echo $this->name ?></a></h3>
|
438 |
+
</li>
|
439 |
+
<?php
|
440 |
+
break;
|
441 |
+
default :
|
442 |
+
return false;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
function show_comment_form_wordpress() {
|
447 |
+
query_posts( 'attachment_id=' . $this->id );
|
448 |
+
while ( have_posts() ): the_post();
|
449 |
+
add_action( 'comment_form', 'BPMediaFunction::wp_comment_form_mod' );
|
450 |
+
comments_template();
|
451 |
+
endwhile;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Outputs the comments and comment form in the single media entry page
|
456 |
+
*/
|
457 |
+
|
458 |
+
/**
|
459 |
+
*
|
460 |
+
* @global type $bp_media
|
461 |
+
* @return boolean
|
462 |
+
*/
|
463 |
+
function show_comment_form() {
|
464 |
+
global $bp_media;
|
465 |
+
$activity_id = get_post_meta( $this->id, 'bp_media_child_activity', true );
|
466 |
+
if ( ! $activity_id || ! function_exists( 'bp_has_activities' ) )
|
467 |
+
return false;
|
468 |
+
if ( bp_has_activities( array(
|
469 |
+
'display_comments' => 'stream',
|
470 |
+
'include' => $activity_id,
|
471 |
+
'max' => 1
|
472 |
+
) ) ) {
|
473 |
+
while ( bp_activities() ) {
|
474 |
+
bp_the_activity();
|
475 |
+
do_action( 'bp_before_activity_entry' );
|
476 |
+
?>
|
477 |
+
<div class="activity">
|
478 |
+
<ul id="activity-stream" class="activity-list item-list">
|
479 |
+
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
480 |
+
<div class="activity-content">
|
481 |
+
<?php do_action( 'bp_activity_entry_content' ); ?>
|
482 |
+
<?php if ( is_user_logged_in() ) : ?>
|
483 |
+
<div class="activity-meta no-ajax">
|
484 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
485 |
+
<a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf( __( 'Comment <span>%s</span>', BP_MEDIA_TXT_DOMAIN ), bp_activity_get_comment_count() ); ?></a>
|
486 |
+
<?php endif; ?>
|
487 |
+
<?php if ( bp_activity_can_favorite() ) : ?>
|
488 |
+
<?php if ( ! bp_get_activity_is_favorite() ) : ?>
|
489 |
+
<a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e( 'Mark as Favorite', BP_MEDIA_TXT_DOMAIN ); ?>"><?php _e( 'Favorite', BP_MEDIA_TXT_DOMAIN ) ?></a>
|
490 |
+
<?php else : ?>
|
491 |
+
<a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Remove Favorite', BP_MEDIA_TXT_DOMAIN ); ?>"><?php _e( 'Remove Favorite', BP_MEDIA_TXT_DOMAIN ) ?></a>
|
492 |
+
<?php endif; ?>
|
493 |
+
<?php endif; ?>
|
494 |
+
<?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?>
|
495 |
+
<?php do_action( 'bp_activity_entry_meta' ); ?>
|
496 |
+
</div>
|
497 |
+
<?php endif; ?>
|
498 |
+
</div>
|
499 |
+
<?php do_action( 'bp_before_activity_entry_comments' ); ?>
|
500 |
+
<?php if ( ( is_user_logged_in() && bp_activity_can_comment() ) || bp_activity_get_comment_count() ) : ?>
|
501 |
+
<div class="activity-comments">
|
502 |
+
<?php bp_activity_comments(); ?>
|
503 |
+
<?php if ( is_user_logged_in() ) : ?>
|
504 |
+
<form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>>
|
505 |
+
<div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?></div>
|
506 |
+
<div class="ac-reply-content">
|
507 |
+
<div class="ac-textarea">
|
508 |
+
<textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
|
509 |
+
</div>
|
510 |
+
<input type="submit" name="ac_form_submit" value="<?php _e( 'Post', BP_MEDIA_TXT_DOMAIN ); ?>" /> <?php _e( 'or press esc to cancel.', BP_MEDIA_TXT_DOMAIN ); ?>
|
511 |
+
<input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
|
512 |
+
</div>
|
513 |
+
<?php do_action( 'bp_activity_entry_comments' ); ?>
|
514 |
+
<?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ); ?>
|
515 |
+
</form>
|
516 |
+
<?php endif; ?>
|
517 |
+
</div>
|
518 |
+
<?php endif; ?>
|
519 |
+
<?php do_action( 'bp_after_activity_entry_comments' ); ?>
|
520 |
+
</li>
|
521 |
+
</ul>
|
522 |
+
</div>
|
523 |
+
<?php
|
524 |
+
}
|
525 |
+
}
|
526 |
+
else {
|
527 |
+
?>
|
528 |
+
<div class="activity">
|
529 |
+
<ul id="activity-stream" class="activity-list item-list">
|
530 |
+
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
531 |
+
<div class="activity-content">
|
532 |
+
<?php do_action( 'bp_activity_entry_content' ); ?>
|
533 |
+
<?php if ( is_user_logged_in() ) : ?>
|
534 |
+
<div class="activity-meta no-ajax">
|
535 |
+
<a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow"><?php _e( "Delete", BP_MEDIA_TXT_DOMAIN ); ?></a>
|
536 |
+
</div>
|
537 |
+
<?php endif; ?>
|
538 |
+
</div>
|
539 |
+
</li>
|
540 |
+
</ul>
|
541 |
+
</div>
|
542 |
+
<?php
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Returns the URL of the single media entry page
|
548 |
+
*/
|
549 |
+
|
550 |
+
/**
|
551 |
+
*
|
552 |
+
* @return type
|
553 |
+
*/
|
554 |
+
function get_url() {
|
555 |
+
return $this->url;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Returns the URL of the attached media file
|
560 |
+
*/
|
561 |
+
|
562 |
+
/**
|
563 |
+
*
|
564 |
+
* @return type
|
565 |
+
*/
|
566 |
+
function get_attachment_url() {
|
567 |
+
return wp_get_attachment_url( $this->id );
|
568 |
+
}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Updates the media entry
|
572 |
+
*
|
573 |
+
* @param array $args Array with the following keys:<br/>
|
574 |
+
* 'name' <br/>
|
575 |
+
* 'description'<br/>
|
576 |
+
* 'owner'
|
577 |
+
*
|
578 |
+
* @return bool True when the update is successful, False when the update fails
|
579 |
+
*/
|
580 |
+
|
581 |
+
/**
|
582 |
+
*
|
583 |
+
* @param type $args
|
584 |
+
* @return type
|
585 |
+
*/
|
586 |
+
function update_media( $args = array( ) ) {
|
587 |
+
$defaults = array(
|
588 |
+
'name' => $this->name,
|
589 |
+
'description' => $this->description,
|
590 |
+
'owner' => $this->owner
|
591 |
+
);
|
592 |
+
$args = wp_parse_args( $args, $defaults );
|
593 |
+
$post = get_post( $this->id, ARRAY_A );
|
594 |
+
$post[ 'post_title' ] = esc_html( $args[ 'name' ] );
|
595 |
+
$post[ 'post_content' ] = esc_html( $args[ 'description' ] );
|
596 |
+
$post[ 'post_author' ] = $args[ 'owner' ];
|
597 |
+
$result = wp_update_post( $post );
|
598 |
+
$this->init( $this->id );
|
599 |
+
do_action( 'bp_media_after_update_media', $this->id, $this->type );
|
600 |
+
return $result;
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* Updates activity content's title and description sync with the editing of Media
|
605 |
+
*
|
606 |
+
*/
|
607 |
+
|
608 |
+
/**
|
609 |
+
*
|
610 |
+
* @global type $wpdb
|
611 |
+
* @global type $bp
|
612 |
+
* @global type $current_user
|
613 |
+
* @global type $bp_media
|
614 |
+
*/
|
615 |
+
function update_media_activity() {
|
616 |
+
global $wpdb, $bp, $current_user, $bp_media;
|
617 |
+
$q = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id );
|
618 |
+
$activities = $wpdb->get_results( $q );
|
619 |
+
if ( isset( $activities ) && count( $activities ) > 0 ) {
|
620 |
+
$activities_template = new BP_Activity_Template( array(
|
621 |
+
'max' => TRUE,
|
622 |
+
'user_id' => $current_user,
|
623 |
+
'in' => $activities[ 0 ]->id
|
624 |
+
) );
|
625 |
+
foreach ( $activities_template->activities as $activity ) {
|
626 |
+
$args = array(
|
627 |
+
'content' => $this->get_media_activity_content(),
|
628 |
+
'id' => $activity->id,
|
629 |
+
'type' => 'media_upload',
|
630 |
+
'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN ), bp_core_get_userlink( $this->get_author() ), '<a href="' . $this->get_url() . '">' . $this->get_media_activity_type() . '</a>' ) ),
|
631 |
+
'primary_link' => $this->get_url(),
|
632 |
+
'item_id' => $this->get_id(),
|
633 |
+
'recorded_time' => $activity->date_recorded,
|
634 |
+
'user_id' => $this->get_author()
|
635 |
+
);
|
636 |
+
$activity_id = BPMediaFunction::record_activity( $args );
|
637 |
+
}
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
/**
|
642 |
+
* Deletes the Media Entry
|
643 |
+
*/
|
644 |
+
|
645 |
+
/**
|
646 |
+
*
|
647 |
+
* @global type $bp_media_count
|
648 |
+
*/
|
649 |
+
function delete_media() {
|
650 |
+
do_action( 'bp_media_before_delete_media', $this->id );
|
651 |
+
wp_delete_attachment( $this->id, true );
|
652 |
+
do_action( 'bp_media_after_delete_media', $this->id );
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Function to return the content to be placed in the activity of album
|
657 |
+
*/
|
658 |
+
|
659 |
+
/**
|
660 |
+
*
|
661 |
+
* @return boolean|string
|
662 |
+
*/
|
663 |
+
function get_album_activity_content() {
|
664 |
+
$attachment = $this->id;
|
665 |
+
switch ( $this->type ) {
|
666 |
+
case 'video' :
|
667 |
+
if ( $this->thumbnail_id ) {
|
668 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
669 |
+
$thumb_url = $medium_array[ 0 ];
|
670 |
+
} else {
|
671 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/video_thumb.png';
|
672 |
+
}
|
673 |
+
break;
|
674 |
+
case 'audio' :
|
675 |
+
if ( $this->thumbnail_id ) {
|
676 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
677 |
+
$thumb_url = $medium_array[ 0 ];
|
678 |
+
} else {
|
679 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/audio_thumb.png';
|
680 |
+
}
|
681 |
+
break;
|
682 |
+
case 'image' :
|
683 |
+
$medium_array = image_downsize( $attachment, 'thumbnail' );
|
684 |
+
$thumb_url = $medium_array[ 0 ];
|
685 |
+
break;
|
686 |
+
default :
|
687 |
+
return false;
|
688 |
+
}
|
689 |
+
$content = '<li>';
|
690 |
+
$content .= '<a href="' . $this->url . '" title="' . $this->name . '">';
|
691 |
+
$content .= '<img src="' . $thumb_url . '" />';
|
692 |
+
$content .= '</a>';
|
693 |
+
$content .= '</li>';
|
694 |
+
return $content;
|
695 |
+
}
|
696 |
+
|
697 |
+
/**
|
698 |
+
* Returns the description of the Media Entry
|
699 |
+
*/
|
700 |
+
|
701 |
+
/**
|
702 |
+
*
|
703 |
+
* @return type
|
704 |
+
*/
|
705 |
+
function get_content() {
|
706 |
+
return $this->description;
|
707 |
+
}
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Returns the owner id of the Media Entry
|
711 |
+
*/
|
712 |
+
|
713 |
+
/**
|
714 |
+
*
|
715 |
+
* @return type
|
716 |
+
*/
|
717 |
+
function get_author() {
|
718 |
+
return $this->owner;
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Returns the id of the Media Entry
|
723 |
+
*/
|
724 |
+
|
725 |
+
/**
|
726 |
+
*
|
727 |
+
* @return type
|
728 |
+
*/
|
729 |
+
function get_id() {
|
730 |
+
return $this->id;
|
731 |
+
}
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Returns the edit url of the Media Entry
|
735 |
+
*/
|
736 |
+
|
737 |
+
/**
|
738 |
+
*
|
739 |
+
* @return type
|
740 |
+
*/
|
741 |
+
function get_edit_url() {
|
742 |
+
return $this->edit_url;
|
743 |
+
}
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Returns the delete url of the Media Entry
|
747 |
+
*/
|
748 |
+
|
749 |
+
/**
|
750 |
+
*
|
751 |
+
* @return type
|
752 |
+
*/
|
753 |
+
function get_delete_url() {
|
754 |
+
return $this->delete_url;
|
755 |
+
}
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Returns the type of activity
|
759 |
+
*/
|
760 |
+
|
761 |
+
/**
|
762 |
+
*
|
763 |
+
* @return string
|
764 |
+
*/
|
765 |
+
function get_media_activity_type() {
|
766 |
+
switch ( $this->type ) {
|
767 |
+
case 'image':
|
768 |
+
return BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
769 |
+
case 'video':
|
770 |
+
return BP_MEDIA_VIDEOS_LABEL_SINGULAR;
|
771 |
+
case 'audio':
|
772 |
+
return BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
773 |
+
default:
|
774 |
+
return 'Media';
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* Returns the album id
|
780 |
+
*/
|
781 |
+
|
782 |
+
/**
|
783 |
+
*
|
784 |
+
* @return type
|
785 |
+
*/
|
786 |
+
function get_album_id() {
|
787 |
+
return $this->album_id;
|
788 |
+
}
|
789 |
+
|
790 |
+
/**
|
791 |
+
* Returns the title of the media
|
792 |
+
*/
|
793 |
+
|
794 |
+
/**
|
795 |
+
*
|
796 |
+
* @return type
|
797 |
+
*/
|
798 |
+
function get_title() {
|
799 |
+
return $this->name;
|
800 |
+
}
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Returns the type of media
|
804 |
+
*/
|
805 |
+
|
806 |
+
/**
|
807 |
+
*
|
808 |
+
* @return type
|
809 |
+
*/
|
810 |
+
function get_type() {
|
811 |
+
return $this->type;
|
812 |
+
}
|
813 |
+
|
814 |
+
/**
|
815 |
+
* Returns the thumbnail id
|
816 |
+
*/
|
817 |
+
function get_thumbnail_id() {
|
818 |
+
return $this->thumbnail_id;
|
819 |
+
}
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Returns the group id of the media, 0 if it does not belong to a group
|
823 |
+
*/
|
824 |
+
|
825 |
+
/**
|
826 |
+
*
|
827 |
+
* @return type
|
828 |
+
*/
|
829 |
+
function get_group_id() {
|
830 |
+
return $this->group_id;
|
831 |
+
}
|
832 |
+
|
833 |
+
/**
|
834 |
+
* Sets the permalinks of the media depending upon whether its in member directory
|
835 |
+
* or group and acording to the media type
|
836 |
+
*/
|
837 |
+
|
838 |
+
/**
|
839 |
+
*
|
840 |
+
* @return boolean
|
841 |
+
*/
|
842 |
+
protected function set_permalinks() {
|
843 |
+
if ( class_exists( 'BP_Group_Extension' ) ) {
|
844 |
+
if ( $this->group_id > 0 ) {
|
845 |
+
$current_group = new BP_Groups_Group( $this->group_id );
|
846 |
+
$pre_url = bp_get_group_permalink( $current_group );
|
847 |
+
} else {
|
848 |
+
$pre_url = bp_core_get_user_domain( $this->owner );
|
849 |
+
}
|
850 |
+
} else {
|
851 |
+
$pre_url = bp_core_get_user_domain( $this->owner );
|
852 |
+
}
|
853 |
+
switch ( $this->type ) {
|
854 |
+
case 'video' :
|
855 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . $this->id );
|
856 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id );
|
857 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
858 |
+
$this->thumbnail_id = get_post_meta( $this->id, 'bp_media_thumbnail', true );
|
859 |
+
break;
|
860 |
+
case 'audio' :
|
861 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . $this->id );
|
862 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id );
|
863 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
864 |
+
$this->thumbnail_id = get_post_meta( $this->id, 'bp_media_thumbnail', true );
|
865 |
+
break;
|
866 |
+
case 'image' :
|
867 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . $this->id );
|
868 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id );
|
869 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
870 |
+
$image_array = image_downsize( $this->id, 'bp_media_single_image' );
|
871 |
+
$this->thumbnail_id = $this->id;
|
872 |
+
break;
|
873 |
+
case 'album' :
|
874 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id );
|
875 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id );
|
876 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
877 |
// $this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail', true);
|
878 |
+
break;
|
879 |
+
default :
|
880 |
+
return false;
|
881 |
+
}
|
882 |
+
return true;
|
883 |
+
}
|
884 |
+
|
885 |
+
/**
|
886 |
+
* Checks if the album given exists if not, creates a new one according to context
|
887 |
+
*/
|
888 |
+
|
889 |
+
/**
|
890 |
+
*
|
891 |
+
* @global type $wpdb
|
892 |
+
* @param type $album_id
|
893 |
+
* @param type $group
|
894 |
+
* @return type
|
895 |
+
*/
|
896 |
+
function check_and_create_album( $album_id, $group ) {
|
897 |
+
global $wpdb;
|
898 |
+
$post_wall = __( 'Wall Posts', BP_MEDIA_TXT_DOMAIN );
|
899 |
+
$create_new_album_flag = false;
|
900 |
+
if ( $album_id != 0 ) {
|
901 |
+
$album = get_post( $album_id );
|
902 |
+
if ( $album->post_author != get_current_user_id() && $group == 0 ) {
|
903 |
+
$create_new_album_flag = true;
|
904 |
+
} else {
|
905 |
+
$post_id = $album->ID;
|
906 |
+
}
|
907 |
+
} else {
|
908 |
+
$create_new_album_flag = true;
|
909 |
+
}
|
910 |
+
if ( $create_new_album_flag ) {
|
911 |
+
if ( $group == 0 ) {
|
912 |
+
$post_id = $wpdb->get_var(
|
913 |
+
"SELECT ID
|
914 |
FROM $wpdb->posts
|
915 |
WHERE
|
916 |
post_title = $post_wall
|
917 |
AND post_author = '" . get_current_user_id() . "'
|
918 |
AND post_type='bp_media_album'"
|
919 |
+
);
|
920 |
+
} else {
|
921 |
+
$post_id = $wpdb->get_var(
|
922 |
+
"SELECT wp_posts.ID
|
923 |
FROM $wpdb->posts
|
924 |
INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
925 |
AND $wpdb->postmeta.meta_key = 'bp-media-key'
|
926 |
AND $wpdb->postmeta.meta_value = -$group
|
927 |
+
AND $wpdb->posts.post_title = $post_wall" );
|
928 |
+
}
|
929 |
+
if ( $post_id == null ) {
|
930 |
+
$album = new BPMediaAlbum();
|
931 |
+
if ( $group == 0 )
|
932 |
+
$album->add_album( $post_wall, get_current_user_id(), $group );
|
933 |
+
else {
|
934 |
+
$current_user = wp_get_current_user();
|
935 |
+
$album->add_album( $current_user->display_name . '\'s Album', get_current_user_id(), $group );
|
936 |
+
}
|
937 |
+
$post_id = $album->get_id();
|
938 |
+
}
|
939 |
+
}
|
940 |
+
return $post_id;
|
941 |
+
}
|
942 |
|
943 |
}
|
944 |
?>
|
app/main/privacy/BPMediaPrivacy.php
CHANGED
@@ -31,7 +31,7 @@ class BPMediaPrivacy {
|
|
31 |
|
32 |
public function set_option_redirect() {
|
33 |
bp_update_option( 'bp_media_privacy_installed', true );
|
34 |
-
do_action('bp_media_after_privacy_install');
|
35 |
echo true;
|
36 |
die();
|
37 |
}
|
@@ -54,15 +54,15 @@ class BPMediaPrivacy {
|
|
54 |
static function is_installed() {
|
55 |
$settings = new BPMediaPrivacySettings();
|
56 |
$total = $settings->get_total_count();
|
57 |
-
if(is_array($total) && !empty($total)){
|
58 |
$total = $total[ 0 ]->Total;
|
59 |
-
}else{
|
60 |
$total = 0;
|
61 |
}
|
62 |
$finished = $settings->get_completed_count();
|
63 |
-
if(is_array($finished) && !empty($finished)){
|
64 |
$finished = $finished[ 0 ]->Finished;
|
65 |
-
}else{
|
66 |
$finished = 0;
|
67 |
}
|
68 |
if ( $total === $finished )
|
@@ -76,6 +76,7 @@ class BPMediaPrivacy {
|
|
76 |
|
77 |
static function get_site_default() {
|
78 |
global $bp_media;
|
|
|
79 |
$options = $bp_media->options;
|
80 |
if ( array_key_exists( 'privacy_enabled', $options ) ) {
|
81 |
if ( array_key_exists( 'default_privacy_level', $options ) ) {
|
@@ -131,20 +132,20 @@ class BPMediaPrivacy {
|
|
131 |
static function ui_html( $privacy_level ) {
|
132 |
?>
|
133 |
<div id="bp-media-upload-privacy-wrap">
|
134 |
-
|
135 |
-
|
136 |
-
<?php
|
137 |
-
$settings = BPMediaPrivacy::get_settings();
|
138 |
-
foreach ( $settings as $level => &$msg ) {
|
139 |
-
?>
|
140 |
-
<li>
|
141 |
-
<input type="radio" name="bp_media_privacy" class="set-privacy-radio" id="bp-media-privacy-<?php echo $msg[ 0 ]; ?>" value="<?php echo $level; ?>" <?php checked( $level, $privacy_level, TRUE ); ?> >
|
142 |
-
<label class="album-set-privacy-label" for="bp-media-privacy-<?php echo $msg[ 0 ]; ?>"><?php echo $msg[ 1 ]; ?></label>
|
143 |
-
</li>
|
144 |
<?php
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
</div>
|
149 |
<?php
|
150 |
}
|
@@ -155,18 +156,21 @@ class BPMediaPrivacy {
|
|
155 |
if ( ! $level ) {
|
156 |
$level = BPMediaPrivacy::default_privacy();
|
157 |
}
|
|
|
|
|
|
|
158 |
$this->save( $level, $object_id );
|
159 |
-
if($type=='album'){
|
160 |
$args = array(
|
161 |
-
'post_type'=> 'attachment',
|
162 |
-
'post_parent'=> $object_id,
|
163 |
-
'post_status'=> 'any',
|
164 |
-
'posts_per_page'=> -1
|
165 |
);
|
166 |
|
167 |
-
$child_query = new WP_Query($args);
|
168 |
$children = $child_query->posts;
|
169 |
-
foreach($children as $child){
|
170 |
$this->save( $level, $child->ID );
|
171 |
}
|
172 |
}
|
@@ -174,9 +178,10 @@ class BPMediaPrivacy {
|
|
174 |
|
175 |
function save( $level = 0, $object_id = false ) {
|
176 |
|
177 |
-
if ( ! array_key_exists( $level, $this->
|
178 |
return false;
|
179 |
|
|
|
180 |
return $this->save_by_object( $level, $object_id );
|
181 |
}
|
182 |
|
@@ -194,8 +199,8 @@ class BPMediaPrivacy {
|
|
194 |
|
195 |
foreach ( $activities->activities as $key => $activity ) {
|
196 |
if ( $activity != null && in_array( $activity->type, $bp_media->activity_types ) ) {
|
197 |
-
$has_access = BPMediaPrivacy::has_access($activity->item_id);
|
198 |
-
if (
|
199 |
|
200 |
unset( $activities->activities[ $key ] );
|
201 |
$activities->activity_count = $activities->activity_count - 1;
|
@@ -240,9 +245,9 @@ class BPMediaPrivacy {
|
|
240 |
$parent_privacy = get_post_meta( $parent, 'bp_media_privacy', true );
|
241 |
|
242 |
if ( $privacy === false ) {
|
243 |
-
if($parent_privacy!==false){
|
244 |
$privacy = $parent_privacy;
|
245 |
-
}else{
|
246 |
$privacy = BPMediaPrivacy::default_privacy();
|
247 |
}
|
248 |
}
|
@@ -259,10 +264,14 @@ class BPMediaPrivacy {
|
|
259 |
$current_privacy = 6;
|
260 |
}
|
261 |
if ( isset( $bp->displayed_user->id ) )
|
262 |
-
if ( ! (bp_is_my_profile())
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
}
|
268 |
}
|
31 |
|
32 |
public function set_option_redirect() {
|
33 |
bp_update_option( 'bp_media_privacy_installed', true );
|
34 |
+
do_action( 'bp_media_after_privacy_install' );
|
35 |
echo true;
|
36 |
die();
|
37 |
}
|
54 |
static function is_installed() {
|
55 |
$settings = new BPMediaPrivacySettings();
|
56 |
$total = $settings->get_total_count();
|
57 |
+
if ( is_array( $total ) && ! empty( $total ) ) {
|
58 |
$total = $total[ 0 ]->Total;
|
59 |
+
} else {
|
60 |
$total = 0;
|
61 |
}
|
62 |
$finished = $settings->get_completed_count();
|
63 |
+
if ( is_array( $finished ) && ! empty( $finished ) ) {
|
64 |
$finished = $finished[ 0 ]->Finished;
|
65 |
+
} else {
|
66 |
$finished = 0;
|
67 |
}
|
68 |
if ( $total === $finished )
|
76 |
|
77 |
static function get_site_default() {
|
78 |
global $bp_media;
|
79 |
+
$site_privacy = false;
|
80 |
$options = $bp_media->options;
|
81 |
if ( array_key_exists( 'privacy_enabled', $options ) ) {
|
82 |
if ( array_key_exists( 'default_privacy_level', $options ) ) {
|
132 |
static function ui_html( $privacy_level ) {
|
133 |
?>
|
134 |
<div id="bp-media-upload-privacy-wrap">
|
135 |
+
<label for="bp-media-upload-set-privacy"><?php _e( 'Set default privacy levels for your media', BP_MEDIA_TXT_DOMAIN ); ?></label>
|
136 |
+
<ul id="bp-media-upload-set-privacy">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
<?php
|
138 |
+
$settings = BPMediaPrivacy::get_settings();
|
139 |
+
foreach ( $settings as $level => &$msg ) {
|
140 |
+
?>
|
141 |
+
<li>
|
142 |
+
<input type="radio" name="bp_media_privacy" class="set-privacy-radio" id="bp-media-privacy-<?php echo $msg[ 0 ]; ?>" value="<?php echo $level; ?>" <?php checked( $level, $privacy_level, TRUE ); ?> >
|
143 |
+
<label class="album-set-privacy-label" for="bp-media-privacy-<?php echo $msg[ 0 ]; ?>"><?php echo $msg[ 1 ]; ?></label>
|
144 |
+
</li>
|
145 |
+
<?php
|
146 |
+
}
|
147 |
+
?>
|
148 |
+
</ul>
|
149 |
</div>
|
150 |
<?php
|
151 |
}
|
156 |
if ( ! $level ) {
|
157 |
$level = BPMediaPrivacy::default_privacy();
|
158 |
}
|
159 |
+
if(!$level){
|
160 |
+
$level = '0';
|
161 |
+
}
|
162 |
$this->save( $level, $object_id );
|
163 |
+
if ( $type == 'album' ) {
|
164 |
$args = array(
|
165 |
+
'post_type' => 'attachment',
|
166 |
+
'post_parent' => $object_id,
|
167 |
+
'post_status' => 'any',
|
168 |
+
'posts_per_page' => -1
|
169 |
);
|
170 |
|
171 |
+
$child_query = new WP_Query( $args );
|
172 |
$children = $child_query->posts;
|
173 |
+
foreach ( $children as $child ) {
|
174 |
$this->save( $level, $child->ID );
|
175 |
}
|
176 |
}
|
178 |
|
179 |
function save( $level = 0, $object_id = false ) {
|
180 |
|
181 |
+
if ( ! array_key_exists( $level, $this->get_settings() ) )
|
182 |
return false;
|
183 |
|
184 |
+
|
185 |
return $this->save_by_object( $level, $object_id );
|
186 |
}
|
187 |
|
199 |
|
200 |
foreach ( $activities->activities as $key => $activity ) {
|
201 |
if ( $activity != null && in_array( $activity->type, $bp_media->activity_types ) ) {
|
202 |
+
$has_access = BPMediaPrivacy::has_access( $activity->item_id );
|
203 |
+
if ( ! $has_access ) {
|
204 |
|
205 |
unset( $activities->activities[ $key ] );
|
206 |
$activities->activity_count = $activities->activity_count - 1;
|
245 |
$parent_privacy = get_post_meta( $parent, 'bp_media_privacy', true );
|
246 |
|
247 |
if ( $privacy === false ) {
|
248 |
+
if ( $parent_privacy !== false ) {
|
249 |
$privacy = $parent_privacy;
|
250 |
+
} else {
|
251 |
$privacy = BPMediaPrivacy::default_privacy();
|
252 |
}
|
253 |
}
|
264 |
$current_privacy = 6;
|
265 |
}
|
266 |
if ( isset( $bp->displayed_user->id ) )
|
267 |
+
if ( ! (bp_is_my_profile()) ) {
|
268 |
+
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
269 |
+
if ( bp_get_current_group_id() == 0 ) {
|
270 |
+
$is_friend = friends_check_friendship_status( $bp->loggedin_user->id, $bp->displayed_user->id );
|
271 |
+
if ( $is_friend == 'is_friend' ) {
|
272 |
+
$current_privacy = 4;
|
273 |
+
}
|
274 |
+
}
|
275 |
}
|
276 |
}
|
277 |
}
|
app/main/query/BPMediaQuery.php
CHANGED
@@ -48,11 +48,13 @@ class BPMediaQuery {
|
|
48 |
}
|
49 |
|
50 |
function prepare_meta_query() {
|
51 |
-
|
|
|
|
|
|
|
52 |
if ( ! bp_is_groups_component() ) {
|
53 |
$meta_query[ ] = $this->privacy_query();
|
54 |
}
|
55 |
-
$meta_query[ ] = $this->group_query( $group );
|
56 |
return $meta_query;
|
57 |
}
|
58 |
|
@@ -104,12 +106,15 @@ class BPMediaQuery {
|
|
104 |
function get_limit_offset( $limit, $page ) {
|
105 |
global $bp;
|
106 |
$my_profile = false;
|
107 |
-
if (
|
108 |
-
|
|
|
|
|
|
|
109 |
$my_profile = true;
|
110 |
}
|
111 |
-
}
|
112 |
-
if (
|
113 |
$my_profile = true;
|
114 |
}
|
115 |
}
|
48 |
}
|
49 |
|
50 |
function prepare_meta_query() {
|
51 |
+
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
52 |
+
$group = bp_is_current_component( 'groups' );
|
53 |
+
$meta_query[ ] = $this->group_query( $group );
|
54 |
+
}
|
55 |
if ( ! bp_is_groups_component() ) {
|
56 |
$meta_query[ ] = $this->privacy_query();
|
57 |
}
|
|
|
58 |
return $meta_query;
|
59 |
}
|
60 |
|
106 |
function get_limit_offset( $limit, $page ) {
|
107 |
global $bp;
|
108 |
$my_profile = false;
|
109 |
+
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
110 |
+
if ( bp_get_current_group_id() == 0 ) {
|
111 |
+
$my_profile = true;
|
112 |
+
}
|
113 |
+
if ( groups_is_user_member( $bp->loggedin_user->id, bp_get_current_group_id() ) ) {
|
114 |
$my_profile = true;
|
115 |
}
|
116 |
+
}else{
|
117 |
+
if ( bp_is_my_profile() ) {
|
118 |
$my_profile = true;
|
119 |
}
|
120 |
}
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videosand audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
-
Version: 2.6.
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videosand audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
+
Version: 2.6.5
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
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: 3.5
|
8 |
Tested up to: 3.5
|
9 |
-
Stable tag: 2.6.
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
@@ -117,6 +117,11 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
117 |
|
118 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
119 |
|
|
|
|
|
|
|
|
|
|
|
120 |
= 2.6.4 =
|
121 |
* Improved group compatibility
|
122 |
|
@@ -287,5 +292,5 @@ Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-medi
|
|
287 |
* HTML5 Video Tag Support (with fallback)
|
288 |
|
289 |
== Upgrade Notice ==
|
290 |
-
= 2.6.
|
291 |
-
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.5
|
8 |
Tested up to: 3.5
|
9 |
+
Stable tag: 2.6.5
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
117 |
|
118 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
119 |
|
120 |
+
|
121 |
+
= 2.6.5 =
|
122 |
+
* Fixed all warnings and errors with 2.6 thanks to [dzapata79](http://wordpress.org/support/profile/dzapata79), [Scott](http://wordpress.org/support/profile/davidsons).
|
123 |
+
* Special thanks are due to [Stephan Oberlander](http://rtcamp.com/support/users/stephan/) who let us use his site for testing and reproducing the errors!
|
124 |
+
|
125 |
= 2.6.4 =
|
126 |
* Improved group compatibility
|
127 |
|
292 |
* HTML5 Video Tag Support (with fallback)
|
293 |
|
294 |
== Upgrade Notice ==
|
295 |
+
= 2.6.5 =
|
296 |
+
Bug fixes
|