rtMedia for WordPress, BuddyPress and bbPress - Version 2.6.1

Version Description

  • Fixed warnings that appeared on non-upgrade of database.
Download this release

Release Info

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

Code changes from version 2.6 to 2.6.1

app/assets/img/donate.gif ADDED
Binary file
app/assets/img/donate.png ADDED
Binary file
app/helper/rtPluginInfo.php CHANGED
File without changes
app/helper/rtPluginUpdate.php CHANGED
File without changes
app/helper/rtPluginUpdateChecker.php CHANGED
File without changes
app/main/includes/BPMediaActions.php CHANGED
@@ -7,354 +7,354 @@
7
*/
8
class BPMediaActions {
9
10
- /**
11
- *
12
- * @global type $bp_media_options
13
- */
14
- function __construct() {
15
- add_action('bp_media_before_content', 'BPMediaActions::show_messages');
16
- add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'), 11);
17
- add_action('bp_before_activity_delete', 'BPMediaActions::delete_activity_handler');
18
- add_action('wp_enqueue_scripts', array($this, 'upload_enqueue'));
19
- add_action('init', 'BPMediaActions::init_count');
20
- add_action('bp_activity_entry_meta', array($this, 'action_buttons'));
21
- add_action('bp_media_before_delete_media', 'BPMediaActions::delete_media_handler');
22
- add_action('bp_media_after_add_album', array($this, 'album_create_activity'));
23
- add_action('bp_media_after_add_album', array($this,'update_count'), 99,2);
24
- add_action('bp_media_album_updated', 'BPMediaActions::album_activity_update');
25
- add_action('bp_media_album_updated', array($this,'update_count'), 99,2);
26
- add_action('bp_media_after_edit_album', array($this,'update_count'), 99,2);
27
- add_action('bp_media_after_delete_album', array($this,'update_count'), 99,1);
28
- add_action('bp_media_after_delete_media', array($this, 'album_activity_sync'));
29
- add_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4);
30
- add_action('wp_ajax_bp_media_load_more', array($this, 'load_more'));
31
- add_action('wp_ajax_nopriv_bp_media_load_more', array($this, 'load_more'));
32
- add_action('wp_ajax_bp_media_set_album_cover', array($this, 'set_album_cover'));
33
- add_action('delete_attachment', array($this, 'delete_attachment_handler'));
34
- add_action('wp_ajax_bp_media_add_album', array($this, 'add_album'));
35
- add_action('bp_media_after_privacy_install', array($this,'update_count'));
36
- add_action('bp_media_no_object_after_add_media', array($this,'update_count'), 99,2);
37
- add_action('bp_media_after_update_media', array($this,'update_count'), 99,2);
38
- add_action('bp_media_after_delete_media', array($this,'update_count'), 99,1);
39
- $linkback = bp_get_option('bp_media_add_linkback', false);
40
- if ($linkback)
41
- add_action('bp_footer', array($this, 'footer'));
42
- }
43
-
44
- /**
45
- * Handles the uploads and creates respective posts for the upload
46
- *
47
- * @since BuddyPress Media 2.0
48
- */
49
-
50
- /**
51
- *
52
- * @global type $bp
53
- * @global type $bp_media_options
54
- * @return type
55
- */
56
- static function handle_uploads() {
57
- global $bp, $bp_media;
58
- $bp_media_options = $bp_media->options;
59
- if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
60
- /** This section can help in the group activity handling */
61
// if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id'])) {
62
// remove_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 3);
63
// add_action('bp_media_after_add_media', 'BPMediaGroupAction::bp_media_groups_activity_create_after_add_media', 10, 2);
64
//// add_filter('bp_media_force_hide_activity', 'BPMediaGroupAction::bp_media_groups_force_hide_activity');
65
// }
66
- /* @var $bp_media_entry BPMediaHostWordpress */
67
- if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
68
- if (!preg_match('/audio|video|image/i', $_FILES['bp_media_file']['type'], $result) || !isset($result[0])) {
69
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
70
- return;
71
- }
72
- $type = $result[0];
73
- switch ($result[0]) {
74
- case 'image' :
75
- if ($bp_media_options['images_enabled'] == false) {
76
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Image uploads are disabled');
77
- return;
78
- }
79
- break;
80
- case 'video' :
81
- if ($bp_media_options['videos_enabled'] == false) {
82
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Video uploads are disabled');
83
- return;
84
- }
85
- break;
86
- case 'audio' :
87
- if ($bp_media_options['audio_enabled'] == false) {
88
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Audio uploads are disabled');
89
- return;
90
- }
91
- break;
92
- default :
93
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
94
- return;
95
- }
96
- $class_name = apply_filters('bp_media_transcoder', 'BPMediaHostWordpress', $type);
97
- $bp_media_entry = new $class_name();
98
- try {
99
- $title = isset($_POST['bp_media_title']) ? ($_POST['bp_media_title'] != "") ? $_POST['bp_media_title'] : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME) : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME);
100
- $album_id = isset($_POST['bp_media_album_id']) ? intval($_POST['bp_media_album_id']) : 0;
101
- $is_multiple = isset($_POST['is_multiple_upload']) ? ($_POST['is_multiple_upload'] == 'true' ? true : false) : false;
102
- $is_activity = isset($_POST['is_activity']) ? ($_POST['is_activity'] == 'true' ? true : false) : false;
103
- $description = isset($_POST['bp_media_description']) ? $_POST['bp_media_description'] : '';
104
- $group_id = isset($_POST['bp_media_group_id']) ? intval($_POST['bp_media_group_id']) : 0;
105
- $entry = $bp_media_entry->add_media($title, $description, $album_id, $group_id, $is_multiple, $is_activity);
106
- if (!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
107
- $bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', BP_MEDIA_TXT_DOMAIN);
108
- } catch (Exception $e) {
109
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
110
- }
111
- } else {
112
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', BP_MEDIA_TXT_DOMAIN);
113
- }
114
- }
115
- }
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');
155
- wp_enqueue_script('bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js');
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');
173
- wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
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)
348
- $user = bp_displayed_user_id();
349
- if ($user < 1) {
350
- $bp_media_count = null;
351
- return false;
352
- }
353
- $count = bp_get_user_meta($user, 'bp_media_count', true);
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
- } else {
358
$total = array(
359
'images' => 0,
360
'videos' => 0,
@@ -363,45 +363,47 @@ class BPMediaActions {
363
'total' => 0
364
);
365
$total_count = 0;
366
-
367
- foreach($count as $level=>$counts){
368
- if($level<=$current_access){
369
- foreach($counts as $media=>$number){
370
- if(array_key_exists($media,$enabled)||array_key_exists($media.'s',$enabled)){
371
- if($enabled[$media]){
372
- $medias = $media;
373
- if($media!='audio')$medias .='s';
374
- $total[$medias] = $total[$medias] + $number;
375
- if($media!='album'){
376
- $total_count = $total_count+$total[$medias];
377
}
378
}
379
}
380
}
381
- $total['total']= $total_count;
382
}
383
}
384
385
- $bp_media_count = $total;
386
- }
387
- add_filter('bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
388
389
- if (bp_current_component() == BP_MEDIA_SLUG) {
390
- add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
391
- add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
392
- add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
393
- add_filter('bp_get_options_nav_' . BP_MEDIA_ALBUMS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
394
- }
395
- return true;
396
- }
397
398
public function update_count() {
399
global $bp;
400
$user_id = $bp->loggedin_user->id;
401
- global $wpdb;
402
403
- $query =
404
- "SELECT
405
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
406
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
407
SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
@@ -415,384 +417,383 @@ class BPMediaActions {
415
pmp.meta_key = 'bp_media_privacy' AND
416
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
417
GROUP BY pmp.meta_value";
418
- $result = $wpdb->get_results($query);
419
- if (!is_array($result))
420
- return false;
421
- foreach ($result as $level=>$obj) {
422
- $formatted[$level] = array(
423
- 'image'=>$obj->Images,
424
- 'video'=>$obj->Videos,
425
- 'audio'=>$obj->Audio,
426
- 'album'=>$obj->Albums,
427
- );
428
- }
429
- bp_update_user_meta($user_id, 'bp_media_count', $formatted);
430
- return true;
431
- }
432
-
433
-
434
- /**
435
- * Displays the footer of the BuddyPress Media Plugin if enabled through the dashboard options page
436
- *
437
- * @since BuddyPress Media 2.0
438
- */
439
- function footer() {
440
- ?>
441
- <div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
442
- <?php
443
- }
444
-
445
- function upload_enqueue() {
446
// echo 'action=' . bp_current_action();
447
// echo '<br />';
448
// echo 'activity=' . bp_is_activity_component();
449
// echo '<br />';
450
// echo 'group=' . bp_is_group_home();
451
- if (bp_is_activity_component() || bp_is_group_home()) {
452
- $params = array(
453
- 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
454
- 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
455
- 'browse_button' => 'bp-media-activity-upload-browse-button',
456
- 'container' => 'bp-media-activity-upload-ui',
457
- 'drop_element' => 'drag-drop-area',
458
- 'filters' => apply_filters('bp_media_plupload_files_filter', array(array('title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3"))),
459
- 'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
460
- 'multipart' => true,
461
- 'urlstream_upload' => true,
462
- 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
463
- 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
464
- 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
465
- 'multi_selection' => true,
466
- 'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
467
- );
468
- 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'));
469
- wp_localize_script('bp-media-activity-uploader', 'bp_media_uploader_params', $params);
470
- wp_localize_script('bp-media-activity-uploader', 'activity_ajax_url', admin_url('admin-ajax.php'));
471
- } 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))) {
472
- $params = array(
473
- 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
474
- 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
475
- 'browse_button' => 'bp-media-upload-browse-button',
476
- 'container' => 'bp-media-upload-ui',
477
- 'drop_element' => 'drag-drop-area',
478
- 'filters' => apply_filters('bp_media_plupload_files_filter', array(array('title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3"))),
479
- 'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
480
- 'multipart' => true,
481
- 'urlstream_upload' => true,
482
- 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
483
- 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
484
- 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
485
- 'multi_selection' => true,
486
- 'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
487
- );
488
- 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'));
489
- wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
490
- }
491
- wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
492
- }
493
494
//This is used only on the uploads page so its added as action in the screens function of upload page.
495
496
- /**
497
- * Called on bp_init by screen functions
498
- *
499
- * @uses global $bp, $bp_media_albums_query
500
- *
501
- * @since BuddyPress Media 2.2
502
- */
503
-
504
- /**
505
- *
506
- * @global type $bp
507
- * @global WP_Query $bp_media_albums_query
508
- */
509
- function albums_set_query() {
510
- global $bp, $bp_media_albums_query;
511
- 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])) {
512
- $paged = $bp->action_variables[1];
513
- } else {
514
- $paged = 1;
515
- }
516
- if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
517
- $args = array(
518
- 'post_type' => 'bp_media_album',
519
- 'author' => $bp->displayed_user->id,
520
- 'paged' => $paged,
521
- 'meta_key' => 'bp-media-key',
522
- 'meta_value' => $bp->displayed_user->id,
523
- 'meta_compare' => '='
524
- );
525
- $bp_media_albums_query = new WP_Query($args);
526
- }
527
- }
528
-
529
- function filter_entries() {
530
- global $bp_media;
531
- $enabled = $bp_media->enabled();
532
- if (isset($enabled['upload']))
533
- unset($enabled['upload']);
534
- if (isset($enabled['album']))
535
- unset($enabled['album']);
536
- foreach ($enabled as $type => $active) {
537
- if ($active == true) {
538
- $filters[] = $type;
539
- }
540
- }
541
-
542
- if (count($filters) == 1)
543
- $filters = $filters[0];
544
- return $filters;
545
- }
546
-
547
- /**
548
- * Function to return the media for the ajax requests
549
- */
550
-
551
- /**
552
- *
553
- * @global type $bp
554
- * @global WP_Query $bp_media_query
555
- * @global type $bp_media_posts_per_page
556
- */
557
- function load_more() {
558
-
559
- global $bp, $bp_media_query, $bp_media;
560
- $page = isset($_POST['page']) ? $_POST['page'] : die();
561
- $current_action = isset($_POST['current_action']) ? $_POST['current_action'] : null;
562
- $action_variables = isset($_POST['action_variables']) ? $_POST['action_variables'] : null;
563
- $displayed_user = isset($_POST['displayed_user']) ? $_POST['displayed_user'] : null;
564
- $loggedin_user = isset($_POST['loggedin_user']) ? $_POST['loggedin_user'] : null;
565
- $current_group = isset($_POST['current_group']) ? $_POST['current_group'] : null;
566
- $album_id = isset($_POST['album_id']) ? $_POST['album_id'] : false;
567
- if ($current_group) {
568
- $type_var = isset($action_variables[0]) ? $action_variables[0] : '';
569
- } else {
570
- $type_var = $current_action;
571
- }
572
-
573
- if($current_action=='albums'){
574
- if(isset($action_variables[1])){
575
- $album_id= $action_variables[1];
576
}
577
}
578
-
579
- if ((!$displayed_user || intval($displayed_user) == 0) && (!$current_group || intval($current_group) == 0)) {
580
- die();
581
- }
582
- switch ($type_var) {
583
- case BP_MEDIA_IMAGES_SLUG:
584
- $type = 'image';
585
- break;
586
- case BP_MEDIA_AUDIO_SLUG:
587
- $type = 'audio';
588
- break;
589
- case BP_MEDIA_VIDEOS_SLUG:
590
- $type = 'video';
591
- break;
592
- default :
593
- $type = null;
594
- }
595
-
596
- $query = new BPMediaQuery();
597
- $args = $query->init($type,$album_id,false, $page);
598
- $bp_media_query = new WP_Query($args);
599
- if (isset($bp_media_query->posts) && is_array($bp_media_query->posts) && count($bp_media_query->posts)) {
600
- foreach ($bp_media_query->posts as $attachment) {
601
- try {
602
- $media = new BPMediaHostWordpress($attachment->ID);
603
- echo $media->get_media_gallery_content();
604
- } catch (exception $e) {
605
- die();
606
- }
607
- }
608
- }
609
- die();
610
- }
611
-
612
- /**
613
- *
614
- * @global type $bp_media_count
615
- * @param type $attachment_id
616
- * @return boolean
617
- */
618
- function delete_attachment_handler($attachment_id) {
619
- if (get_post_meta($attachment_id, 'bp-media-key')) {
620
- do_action('bp_media_before_delete_media', $attachment_id);
621
- global $bp_media_count;
622
- $attachment = get_post($attachment_id);
623
- preg_match_all('/audio|video|image/i', $attachment->post_mime_type, $result);
624
- if (isset($result[0][0]))
625
- $type = $result[0][0];
626
- else
627
- return false;
628
- BPMediaActions::init_count($attachment->post_author);
629
- switch ($type) {
630
- case 'image':
631
- $images = intval($bp_media_count['images']) ? intval($bp_media_count['images']) : 0;
632
- $bp_media_count['images'] = $images - 1;
633
- break;
634
- case 'audio':
635
- $bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
636
- break;
637
- case 'video':
638
- $bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
639
- break;
640
- default:
641
- return false;
642
- }
643
- bp_update_user_meta($attachment->post_author, 'bp_media_count', $bp_media_count);
644
- do_action('bp_media_after_delete_media', $attachment_id);
645
- return true;
646
- }
647
- }
648
-
649
- /**
650
- * Function to create new album called via ajax request
651
- */
652
- function add_album() {
653
- if (isset($_POST['bp_media_album_name']) && $_POST['bp_media_album_name'] != '') {
654
- $album = new BPMediaAlbum();
655
- if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id']) > 0) {
656
- $group_id = intval($_POST['bp_media_group_id']);
657
- if (BPMediaGroupLoader::user_can_create_album($group_id, get_current_user_id())) {
658
- try {
659
- $album->add_album($_POST['bp_media_album_name'], 0, $group_id);
660
- echo $album->get_id();
661
- } catch (exception $e) {
662
- echo '0';
663
- }
664
- } else {
665
- echo '0';
666
- }
667
- } else {
668
- try {
669
- $album->add_album($_POST['bp_media_album_name']);
670
- echo $album->get_id();
671
- } catch (exception $e) {
672
- echo '0';
673
- }
674
- }
675
- } else {
676
- echo '0';
677
- }
678
- die();
679
- }
680
-
681
- function add_new_from_activity() {
682
- BPMediaTemplateFunctions::show_upload_form_multiple_activity();
683
- }
684
685
//add_action('bp_after_activity_post_form','add_new_from_activity');
686
687
- /**
688
- *
689
- * @param type $album
690
- */
691
- function album_create_activity($album) {
692
- /* @var $album BP_Media_Album */
693
- $args = array(
694
- 'action' => apply_filters('bp_media_album_created', sprintf(__('%1$s created an album %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($album->get_owner()), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>')),
695
- 'component' => BP_MEDIA_SLUG,
696
- 'type' => 'album_created',
697
- 'primary_link' => $album->get_url(),
698
- 'user_id' => $album->get_owner(),
699
- 'item_id' => $album->get_id()
700
- );
701
- $activity_id = BPMediaFunction::record_activity($args);
702
- update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
703
- }
704
-
705
- /**
706
- *
707
- * @param type $album_id
708
- */
709
- function album_activity_update($album_id) {
710
- BPMediaFunction::update_album_activity($album_id);
711
- }
712
-
713
- /**
714
- *
715
- * @param type $media_id
716
- */
717
- function album_activity_sync($media_id) {
718
- $album_id = wp_get_post_parent_id($media_id);
719
- BPMediaFunction::update_album_activity($album_id, false, $media_id);
720
- }
721
-
722
- /**
723
- *
724
- * @param BPMediaHostWordpress $media
725
- * @param type $hidden
726
- * @return boolean
727
- */
728
- static function activity_create_after_add_media($media, $hidden = false, $activity = false, $group = false) {
729
- if (function_exists('bp_activity_add')) {
730
- if (!is_object($media)) {
731
- try {
732
- $media = new BPMediaHostWordpress($media);
733
- } catch (exception $e) {
734
- return false;
735
- }
736
- }
737
- $activity_content = $media->get_media_activity_content();
738
- new BPMediaLog($activity_content);
739
- $args = array(
740
- 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media->get_author()), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>')),
741
- 'content' => $activity_content,
742
- 'primary_link' => $media->get_url(),
743
- 'item_id' => $media->get_id(),
744
- 'type' => 'media_upload',
745
- 'user_id' => $media->get_author()
746
- );
747
-
748
- $hidden = apply_filters('bp_media_force_hide_activity', $hidden);
749
-
750
- if ($activity || $hidden) {
751
- $args['secondary_item_id'] = -999;
752
- } else {
753
- $update_activity_id = get_post_meta($media->get_id(), 'bp_media_child_activity', true);
754
- if ($update_activity_id) {
755
- $args['id'] = $update_activity_id;
756
- $args['secondary_item_id'] = false;
757
- }
758
- }
759
-
760
- if ($hidden) {
761
- do_action('bp_media_album_updated', $media->get_album_id());
762
- }
763
-
764
- if ($group) {
765
- $group_info = groups_get_group(array('group_id' => $group));
766
- if ('public' != $group_info->status) {
767
- $args['hide_sitewide'] = 1;
768
- }
769
- }
770
-
771
- $activity_id = BPMediaFunction::record_activity($args);
772
-
773
- if ($group)
774
- bp_activity_update_meta($activity_id, 'group_id', $group);
775
-
776
- if (!$update_activity_id)
777
- add_post_meta($media->get_id(), 'bp_media_child_activity', $activity_id);
778
- }
779
- }
780
-
781
- public function set_album_cover() {
782
- $id = $_POST['post_id'];
783
- $album_id = $_POST['album_id'];
784
- $album_cover = get_post_thumbnail_id($album_id);
785
- $text = NULL;
786
- if ($album_cover && ($album_cover == $id)) {
787
- delete_post_thumbnail($album_id);
788
- $text = __('Set as Album Cover', BP_MEDIA_TXT_DOMAIN);
789
- } else {
790
- set_post_thumbnail($album_id, $id);
791
- $text = __('Unset as Album Cover', BP_MEDIA_TXT_DOMAIN);
792
- }
793
- echo $text;
794
- die;
795
- }
796
797
}
798
?>
7
*/
8
class BPMediaActions {
9
10
+ /**
11
+ *
12
+ * @global type $bp_media_options
13
+ */
14
+ function __construct() {
15
+ add_action( 'bp_media_before_content', 'BPMediaActions::show_messages' );
16
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ), 11 );
17
+ add_action( 'bp_before_activity_delete', 'BPMediaActions::delete_activity_handler' );
18
+ add_action( 'wp_enqueue_scripts', array( $this, 'upload_enqueue' ) );
19
+ add_action( 'init', 'BPMediaActions::init_count' );
20
+ add_action( 'bp_activity_entry_meta', array( $this, 'action_buttons' ) );
21
+ add_action( 'bp_media_before_delete_media', 'BPMediaActions::delete_media_handler' );
22
+ add_action( 'bp_media_after_add_album', array( $this, 'album_create_activity' ) );
23
+ add_action( 'bp_media_after_add_album', array( $this, 'update_count' ), 99, 2 );
24
+ add_action( 'bp_media_album_updated', 'BPMediaActions::album_activity_update' );
25
+ add_action( 'bp_media_album_updated', array( $this, 'update_count' ), 99, 2 );
26
+ add_action( 'bp_media_after_edit_album', array( $this, 'update_count' ), 99, 2 );
27
+ add_action( 'bp_media_after_delete_album', array( $this, 'update_count' ), 99, 1 );
28
+ add_action( 'bp_media_after_delete_media', array( $this, 'album_activity_sync' ) );
29
+ add_action( 'bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4 );
30
+ add_action( 'wp_ajax_bp_media_load_more', array( $this, 'load_more' ) );
31
+ add_action( 'wp_ajax_nopriv_bp_media_load_more', array( $this, 'load_more' ) );
32
+ add_action( 'wp_ajax_bp_media_set_album_cover', array( $this, 'set_album_cover' ) );
33
+ add_action( 'delete_attachment', array( $this, 'delete_attachment_handler' ) );
34
+ add_action( 'wp_ajax_bp_media_add_album', array( $this, 'add_album' ) );
35
+ add_action( 'bp_media_after_privacy_install', array( $this, 'update_count' ) );
36
+ add_action( 'bp_media_no_object_after_add_media', array( $this, 'update_count' ), 99, 2 );
37
+ add_action( 'bp_media_after_update_media', array( $this, 'update_count' ), 99, 2 );
38
+ add_action( 'bp_media_after_delete_media', array( $this, 'update_count' ), 99, 1 );
39
+ $linkback = bp_get_option( 'bp_media_add_linkback', false );
40
+ if ( $linkback )
41
+ add_action( 'bp_footer', array( $this, 'footer' ) );
42
+ }
43
+
44
+ /**
45
+ * Handles the uploads and creates respective posts for the upload
46
+ *
47
+ * @since BuddyPress Media 2.0
48
+ */
49
+
50
+ /**
51
+ *
52
+ * @global type $bp
53
+ * @global type $bp_media_options
54
+ * @return type
55
+ */
56
+ static function handle_uploads() {
57
+ global $bp, $bp_media;
58
+ $bp_media_options = $bp_media->options;
59
+ if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'wp_handle_upload' ) {
60
+ /** This section can help in the group activity handling */
61
// if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id'])) {
62
// remove_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 3);
63
// add_action('bp_media_after_add_media', 'BPMediaGroupAction::bp_media_groups_activity_create_after_add_media', 10, 2);
64
//// add_filter('bp_media_force_hide_activity', 'BPMediaGroupAction::bp_media_groups_force_hide_activity');
65
// }
66
+ /* @var $bp_media_entry BPMediaHostWordpress */
67
+ if ( isset( $_FILES ) && is_array( $_FILES ) && array_key_exists( 'bp_media_file', $_FILES ) && $_FILES[ 'bp_media_file' ][ 'name' ] != '' ) {
68
+ if ( ! preg_match( '/audio|video|image/i', $_FILES[ 'bp_media_file' ][ 'type' ], $result ) || ! isset( $result[ 0 ] ) ) {
69
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'File uploaded is not supported' );
70
+ return;
71
+ }
72
+ $type = $result[ 0 ];
73
+ switch ( $result[ 0 ] ) {
74
+ case 'image' :
75
+ if ( $bp_media_options[ 'images_enabled' ] == false ) {
76
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Image uploads are disabled' );
77
+ return;
78
+ }
79
+ break;
80
+ case 'video' :
81
+ if ( $bp_media_options[ 'videos_enabled' ] == false ) {
82
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Video uploads are disabled' );
83
+ return;
84
+ }
85
+ break;
86
+ case 'audio' :
87
+ if ( $bp_media_options[ 'audio_enabled' ] == false ) {
88
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Audio uploads are disabled' );
89
+ return;
90
+ }
91
+ break;
92
+ default :
93
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'File uploaded is not supported' );
94
+ return;
95
+ }
96
+ $class_name = apply_filters( 'bp_media_transcoder', 'BPMediaHostWordpress', $type );
97
+ $bp_media_entry = new $class_name();
98
+ try {
99
+ $title = isset( $_POST[ 'bp_media_title' ] ) ? ($_POST[ 'bp_media_title' ] != "") ? $_POST[ 'bp_media_title' ] : pathinfo( $_FILES[ 'bp_media_file' ][ 'name' ], PATHINFO_FILENAME ) : pathinfo( $_FILES[ 'bp_media_file' ][ 'name' ], PATHINFO_FILENAME );
100
+ $album_id = isset( $_POST[ 'bp_media_album_id' ] ) ? intval( $_POST[ 'bp_media_album_id' ] ) : 0;
101
+ $is_multiple = isset( $_POST[ 'is_multiple_upload' ] ) ? ($_POST[ 'is_multiple_upload' ] == 'true' ? true : false) : false;
102
+ $is_activity = isset( $_POST[ 'is_activity' ] ) ? ($_POST[ 'is_activity' ] == 'true' ? true : false) : false;
103
+ $description = isset( $_POST[ 'bp_media_description' ] ) ? $_POST[ 'bp_media_description' ] : '';
104
+ $group_id = isset( $_POST[ 'bp_media_group_id' ] ) ? intval( $_POST[ 'bp_media_group_id' ] ) : 0;
105
+ $entry = $bp_media_entry->add_media( $title, $description, $album_id, $group_id, $is_multiple, $is_activity );
106
+ if ( ! isset( $bp->{BP_MEDIA_SLUG}->messages[ 'updated' ][ 0 ] ) )
107
+ $bp->{BP_MEDIA_SLUG}->messages[ 'updated' ][ 0 ] = __( 'Upload Successful', BP_MEDIA_TXT_DOMAIN );
108
+ } catch ( Exception $e ) {
109
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = $e->getMessage();
110
+ }
111
+ } else {
112
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'You did not specified a file to upload', BP_MEDIA_TXT_DOMAIN );
113
+ }
114
+ }
115
+ }
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' );
155
+ wp_enqueue_script( 'bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js' );
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' );
173
+ wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css' );
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 )
348
+ $user = bp_displayed_user_id();
349
+ if ( $user < 1 ) {
350
+ $bp_media_count = null;
351
+ return false;
352
+ }
353
+ $count = bp_get_user_meta( $user, 'bp_media_count', true );
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
+ } else {
358
$total = array(
359
'images' => 0,
360
'videos' => 0,
363
'total' => 0
364
);
365
$total_count = 0;
366
+ if ( isset( $count ) && is_array( $count ) ) {
367
+ foreach ( $count as $level => $counts ) {
368
+ if ( $level <= $current_access ) {
369
+ foreach ( $counts as $media => $number ) {
370
+ if ( array_key_exists( $media, $enabled ) || array_key_exists( $media . 's', $enabled ) ) {
371
+ if ( $enabled[ $media ] ) {
372
+ $medias = $media;
373
+ if ( $media != 'audio' )
374
+ $medias .='s';
375
+ $total[ $medias ] = $total[ $medias ] + $number;
376
+ if ( $media != 'album' ) {
377
+ $total_count = $total_count + $total[ $medias ];
378
+ }
379
}
380
}
381
}
382
+ $total[ 'total' ] = $total_count;
383
}
384
}
385
}
386
387
+ $bp_media_count = $total;
388
+ }
389
+ add_filter( 'bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'BPMediaFilters::items_count_filter', 10, 2 );
390
391
+ if ( bp_current_component() == BP_MEDIA_SLUG ) {
392
+ add_filter( 'bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'BPMediaFilters::items_count_filter', 10, 2 );
393
+ add_filter( 'bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2 );
394
+ add_filter( 'bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'BPMediaFilters::items_count_filter', 10, 2 );
395
+ add_filter( 'bp_get_options_nav_' . BP_MEDIA_ALBUMS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2 );
396
+ }
397
+ return true;
398
+ }
399
400
public function update_count() {
401
global $bp;
402
$user_id = $bp->loggedin_user->id;
403
+ global $wpdb;
404
405
+ $query =
406
+ "SELECT
407
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
408
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
409
SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
417
pmp.meta_key = 'bp_media_privacy' AND
418
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
419
GROUP BY pmp.meta_value";
420
+ $result = $wpdb->get_results( $query );
421
+ if ( ! is_array( $result ) )
422
+ return false;
423
+ foreach ( $result as $level => $obj ) {
424
+ $formatted[ $level ] = array(
425
+ 'image' => $obj->Images,
426
+ 'video' => $obj->Videos,
427
+ 'audio' => $obj->Audio,
428
+ 'album' => $obj->Albums,
429
+ );
430
+ }
431
+ bp_update_user_meta( $user_id, 'bp_media_count', $formatted );
432
+ return true;
433
+ }
434
+
435
+ /**
436
+ * Displays the footer of the BuddyPress Media Plugin if enabled through the dashboard options page
437
+ *
438
+ * @since BuddyPress Media 2.0
439
+ */
440
+ function footer() {
441
+ ?>
442
+ <div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
443
+ <?php
444
+ }
445
+
446
+ function upload_enqueue() {
447
// echo 'action=' . bp_current_action();
448
// echo '<br />';
449
// echo 'activity=' . bp_is_activity_component();
450
// echo '<br />';
451
// echo 'group=' . bp_is_group_home();
452
+ if ( bp_is_activity_component() || bp_is_group_home() ) {
453
+ $params = array(
454
+ 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
455
+ 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
456
+ 'browse_button' => 'bp-media-activity-upload-browse-button',
457
+ 'container' => 'bp-media-activity-upload-ui',
458
+ 'drop_element' => 'drag-drop-area',
459
+ 'filters' => apply_filters( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3" ) ) ),
460
+ 'max_file_size' => min( array( ini_get( 'upload_max_filesize' ), ini_get( 'post_max_size' ) ) ),
461
+ 'multipart' => true,
462
+ 'urlstream_upload' => true,
463
+ 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
464
+ 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
465
+ 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
466
+ 'multi_selection' => true,
467
+ 'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
468
+ );
469
+ 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' ) );
470
+ wp_localize_script( 'bp-media-activity-uploader', 'bp_media_uploader_params', $params );
471
+ wp_localize_script( 'bp-media-activity-uploader', 'activity_ajax_url', admin_url( 'admin-ajax.php' ) );
472
+ } 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 ) ) ) {
473
+ $params = array(
474
+ 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
475
+ 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
476
+ 'browse_button' => 'bp-media-upload-browse-button',
477
+ 'container' => 'bp-media-upload-ui',
478
+ 'drop_element' => 'drag-drop-area',
479
+ 'filters' => apply_filters( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3" ) ) ),
480
+ 'max_file_size' => min( array( ini_get( 'upload_max_filesize' ), ini_get( 'post_max_size' ) ) ),
481
+ 'multipart' => true,
482
+ 'urlstream_upload' => true,
483
+ 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
484
+ 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
485
+ 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
486
+ 'multi_selection' => true,
487
+ 'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
488
+ );
489
+ 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' ) );
490
+ wp_localize_script( 'bp-media-uploader', 'bp_media_uploader_params', $params );
491
+ }
492
+ wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css' );
493
+ }
494
495
//This is used only on the uploads page so its added as action in the screens function of upload page.
496
497
+ /**
498
+ * Called on bp_init by screen functions
499
+ *
500
+ * @uses global $bp, $bp_media_albums_query
501
+ *
502
+ * @since BuddyPress Media 2.2
503
+ */
504
+
505
+ /**
506
+ *
507
+ * @global type $bp
508
+ * @global WP_Query $bp_media_albums_query
509
+ */
510
+ function albums_set_query() {
511
+ global $bp, $bp_media_albums_query;
512
+ 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 ] ) ) {
513
+ $paged = $bp->action_variables[ 1 ];
514
+ } else {
515
+ $paged = 1;
516
+ }
517
+ if ( $bp->current_action == BP_MEDIA_ALBUMS_SLUG ) {
518
+ $args = array(
519
+ 'post_type' => 'bp_media_album',
520
+ 'author' => $bp->displayed_user->id,
521
+ 'paged' => $paged,
522
+ 'meta_key' => 'bp-media-key',
523
+ 'meta_value' => $bp->displayed_user->id,
524
+ 'meta_compare' => '='
525
+ );
526
+ $bp_media_albums_query = new WP_Query( $args );
527
+ }
528
+ }
529
+
530
+ function filter_entries() {
531
+ global $bp_media;
532
+ $enabled = $bp_media->enabled();
533
+ if ( isset( $enabled[ 'upload' ] ) )
534
+ unset( $enabled[ 'upload' ] );
535
+ if ( isset( $enabled[ 'album' ] ) )
536
+ unset( $enabled[ 'album' ] );
537
+ foreach ( $enabled as $type => $active ) {
538
+ if ( $active == true ) {
539
+ $filters[ ] = $type;
540
+ }
541
+ }
542
+
543
+ if ( count( $filters ) == 1 )
544
+ $filters = $filters[ 0 ];
545
+ return $filters;
546
+ }
547
+
548
+ /**
549
+ * Function to return the media for the ajax requests
550
+ */
551
+
552
+ /**
553
+ *
554
+ * @global type $bp
555
+ * @global WP_Query $bp_media_query
556
+ * @global type $bp_media_posts_per_page
557
+ */
558
+ function load_more() {
559
+
560
+ global $bp, $bp_media_query, $bp_media;
561
+ $page = isset( $_POST[ 'page' ] ) ? $_POST[ 'page' ] : die();
562
+ $current_action = isset( $_POST[ 'current_action' ] ) ? $_POST[ 'current_action' ] : null;
563
+ $action_variables = isset( $_POST[ 'action_variables' ] ) ? $_POST[ 'action_variables' ] : null;
564
+ $displayed_user = isset( $_POST[ 'displayed_user' ] ) ? $_POST[ 'displayed_user' ] : null;
565
+ $loggedin_user = isset( $_POST[ 'loggedin_user' ] ) ? $_POST[ 'loggedin_user' ] : null;
566
+ $current_group = isset( $_POST[ 'current_group' ] ) ? $_POST[ 'current_group' ] : null;
567
+ $album_id = isset( $_POST[ 'album_id' ] ) ? $_POST[ 'album_id' ] : false;
568
+ if ( $current_group ) {
569
+ $type_var = isset( $action_variables[ 0 ] ) ? $action_variables[ 0 ] : '';
570
+ } else {
571
+ $type_var = $current_action;
572
+ }
573
+
574
+ if ( $current_action == 'albums' ) {
575
+ if ( isset( $action_variables[ 1 ] ) ) {
576
+ $album_id = $action_variables[ 1 ];
577
}
578
}
579
+
580
+ if ( ( ! $displayed_user || intval( $displayed_user ) == 0) && ( ! $current_group || intval( $current_group ) == 0) ) {
581
+ die();
582
+ }
583
+ switch ( $type_var ) {
584
+ case BP_MEDIA_IMAGES_SLUG:
585
+ $type = 'image';
586
+ break;
587
+ case BP_MEDIA_AUDIO_SLUG:
588
+ $type = 'audio';
589
+ break;
590
+ case BP_MEDIA_VIDEOS_SLUG:
591
+ $type = 'video';
592
+ break;
593
+ default :
594
+ $type = null;
595
+ }
596
+
597
+ $query = new BPMediaQuery();
598
+ $args = $query->init( $type, $album_id, false, $page );
599
+ $bp_media_query = new WP_Query( $args );
600
+ if ( isset( $bp_media_query->posts ) && is_array( $bp_media_query->posts ) && count( $bp_media_query->posts ) ) {
601
+ foreach ( $bp_media_query->posts as $attachment ) {
602
+ try {
603
+ $media = new BPMediaHostWordpress( $attachment->ID );
604
+ echo $media->get_media_gallery_content();
605
+ } catch ( exception $e ) {
606
+ die();
607
+ }
608
+ }
609
+ }
610
+ die();
611
+ }
612
+
613
+ /**
614
+ *
615
+ * @global type $bp_media_count
616
+ * @param type $attachment_id
617
+ * @return boolean
618
+ */
619
+ function delete_attachment_handler( $attachment_id ) {
620
+ if ( get_post_meta( $attachment_id, 'bp-media-key' ) ) {
621
+ do_action( 'bp_media_before_delete_media', $attachment_id );
622
+ global $bp_media_count;
623
+ $attachment = get_post( $attachment_id );
624
+ preg_match_all( '/audio|video|image/i', $attachment->post_mime_type, $result );
625
+ if ( isset( $result[ 0 ][ 0 ] ) )
626
+ $type = $result[ 0 ][ 0 ];
627
+ else
628
+ return false;
629
+ BPMediaActions::init_count( $attachment->post_author );
630
+ switch ( $type ) {
631
+ case 'image':
632
+ $images = intval( $bp_media_count[ 'images' ] ) ? intval( $bp_media_count[ 'images' ] ) : 0;
633
+ $bp_media_count[ 'images' ] = $images - 1;
634
+ break;
635
+ case 'audio':
636
+ $bp_media_count[ 'audio' ] = intval( $bp_media_count[ 'audio' ] ) - 1;
637
+ break;
638
+ case 'video':
639
+ $bp_media_count[ 'videos' ] = intval( $bp_media_count[ 'videos' ] ) - 1;
640
+ break;
641
+ default:
642
+ return false;
643
+ }
644
+ bp_update_user_meta( $attachment->post_author, 'bp_media_count', $bp_media_count );
645
+ do_action( 'bp_media_after_delete_media', $attachment_id );
646
+ return true;
647
+ }
648
+ }
649
+
650
+ /**
651
+ * Function to create new album called via ajax request
652
+ */
653
+ function add_album() {
654
+ if ( isset( $_POST[ 'bp_media_album_name' ] ) && $_POST[ 'bp_media_album_name' ] != '' ) {
655
+ $album = new BPMediaAlbum();
656
+ if ( isset( $_POST[ 'bp_media_group_id' ] ) && intval( $_POST[ 'bp_media_group_id' ] ) > 0 ) {
657
+ $group_id = intval( $_POST[ 'bp_media_group_id' ] );
658
+ if ( BPMediaGroupLoader::user_can_create_album( $group_id, get_current_user_id() ) ) {
659
+ try {
660
+ $album->add_album( $_POST[ 'bp_media_album_name' ], 0, $group_id );
661
+ echo $album->get_id();
662
+ } catch ( exception $e ) {
663
+ echo '0';
664
+ }
665
+ } else {
666
+ echo '0';
667
+ }
668
+ } else {
669
+ try {
670
+ $album->add_album( $_POST[ 'bp_media_album_name' ] );
671
+ echo $album->get_id();
672
+ } catch ( exception $e ) {
673
+ echo '0';
674
+ }
675
+ }
676
+ } else {
677
+ echo '0';
678
+ }
679
+ die();
680
+ }
681
+
682
+ function add_new_from_activity() {
683
+ BPMediaTemplateFunctions::show_upload_form_multiple_activity();
684
+ }
685
686
//add_action('bp_after_activity_post_form','add_new_from_activity');
687
688
+ /**
689
+ *
690
+ * @param type $album
691
+ */
692
+ function album_create_activity( $album ) {
693
+ /* @var $album BP_Media_Album */
694
+ $args = array(
695
+ 'action' => apply_filters( 'bp_media_album_created', sprintf( __( '%1$s created an album %2$s', BP_MEDIA_TXT_DOMAIN ), bp_core_get_userlink( $album->get_owner() ), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>' ) ),
696
+ 'component' => BP_MEDIA_SLUG,
697
+ 'type' => 'album_created',
698
+ 'primary_link' => $album->get_url(),
699
+ 'user_id' => $album->get_owner(),
700
+ 'item_id' => $album->get_id()
701
+ );
702
+ $activity_id = BPMediaFunction::record_activity( $args );
703
+ update_post_meta( $album->get_id(), 'bp_media_child_activity', $activity_id );
704
+ }
705
+
706
+ /**
707
+ *
708
+ * @param type $album_id
709
+ */
710
+ function album_activity_update( $album_id ) {
711
+ BPMediaFunction::update_album_activity( $album_id );
712
+ }
713
+
714
+ /**
715
+ *
716
+ * @param type $media_id
717
+ */
718
+ function album_activity_sync( $media_id ) {
719
+ $album_id = wp_get_post_parent_id( $media_id );
720
+ BPMediaFunction::update_album_activity( $album_id, false, $media_id );
721
+ }
722
+
723
+ /**
724
+ *
725
+ * @param BPMediaHostWordpress $media
726
+ * @param type $hidden
727
+ * @return boolean
728
+ */
729
+ static function activity_create_after_add_media( $media, $hidden = false, $activity = false, $group = false ) {
730
+ if ( function_exists( 'bp_activity_add' ) ) {
731
+ if ( ! is_object( $media ) ) {
732
+ try {
733
+ $media = new BPMediaHostWordpress( $media );
734
+ } catch ( exception $e ) {
735
+ return false;
736
+ }
737
+ }
738
+ $activity_content = $media->get_media_activity_content();
739
+ new BPMediaLog( $activity_content );
740
+ $args = array(
741
+ 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN ), bp_core_get_userlink( $media->get_author() ), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>' ) ),
742
+ 'content' => $activity_content,
743
+ 'primary_link' => $media->get_url(),
744
+ 'item_id' => $media->get_id(),
745
+ 'type' => 'media_upload',
746
+ 'user_id' => $media->get_author()
747
+ );
748
+
749
+ $hidden = apply_filters( 'bp_media_force_hide_activity', $hidden );
750
+
751
+ if ( $activity || $hidden ) {
752
+ $args[ 'secondary_item_id' ] = -999;
753
+ } else {
754
+ $update_activity_id = get_post_meta( $media->get_id(), 'bp_media_child_activity', true );
755
+ if ( $update_activity_id ) {
756
+ $args[ 'id' ] = $update_activity_id;
757
+ $args[ 'secondary_item_id' ] = false;
758
+ }
759
+ }
760
+
761
+ if ( $hidden ) {
762
+ do_action( 'bp_media_album_updated', $media->get_album_id() );
763
+ }
764
+
765
+ if ( $group ) {
766
+ $group_info = groups_get_group( array( 'group_id' => $group ) );
767
+ if ( 'public' != $group_info->status ) {
768
+ $args[ 'hide_sitewide' ] = 1;
769
+ }
770
+ }
771
+
772
+ $activity_id = BPMediaFunction::record_activity( $args );
773
+
774
+ if ( $group )
775
+ bp_activity_update_meta( $activity_id, 'group_id', $group );
776
+
777
+ if ( ! $update_activity_id )
778
+ add_post_meta( $media->get_id(), 'bp_media_child_activity', $activity_id );
779
+ }
780
+ }
781
+
782
+ public function set_album_cover() {
783
+ $id = $_POST[ 'post_id' ];
784
+ $album_id = $_POST[ 'album_id' ];
785
+ $album_cover = get_post_thumbnail_id( $album_id );
786
+ $text = NULL;
787
+ if ( $album_cover && ($album_cover == $id) ) {
788
+ delete_post_thumbnail( $album_id );
789
+ $text = __( 'Set as Album Cover', BP_MEDIA_TXT_DOMAIN );
790
+ } else {
791
+ set_post_thumbnail( $album_id, $id );
792
+ $text = __( 'Unset as Album Cover', BP_MEDIA_TXT_DOMAIN );
793
+ }
794
+ echo $text;
795
+ die;
796
+ }
797
798
}
799
?>
app/main/includes/BPMediaHostWordpress.php CHANGED
File without changes
app/main/privacy/BPMediaPrivacy.php CHANGED
File without changes
app/main/query/BPMediaQuery.php CHANGED
@@ -13,7 +13,6 @@ if ( ! defined( 'ABSPATH' ) )
13
*/
14
class BPMediaQuery {
15
16
-
17
function init( $type = false, $album_id=false, $count=false, $page=false,$docount = false ) {
18
$args = $this->prepare_args( $type,$album_id,$page, $docount,$count );
19
return $this->return_result( $args, $docount );
13
*/
14
class BPMediaQuery {
15
16
function init( $type = false, $album_id=false, $count=false, $page=false,$docount = false ) {
17
$args = $this->prepare_args( $type,$album_id,$page, $docount,$count );
18
return $this->return_result( $args, $docount );
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.1
7
Author: rtCamp
8
Text Domain: buddypress-media
9
Author URI: http://rtcamp.com
languages/buddypress-media-de.mo CHANGED
File without changes
languages/buddypress-media-es.mo CHANGED
File without changes
languages/buddypress-media-fr.mo CHANGED
File without changes
languages/buddypress-media-it.mo CHANGED
File without changes
languages/buddypress-media-ja.mo CHANGED
File without changes
languages/buddypress-media-nl.mo CHANGED
File without changes
languages/buddypress-media-pt_BR.mo CHANGED
File without changes
languages/buddypress-media.mo CHANGED
File without changes
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,9 @@ 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 =
121
* Added Privacy for Media.
122
* Added crude support for activity privacy (due for revision)
@@ -275,5 +278,5 @@ Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-medi
275
* HTML5 Video Tag Support (with fallback)
276
277
== Upgrade Notice ==
278
- =2.6=
279
Adds privacy support and a couple of other fixes
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.1
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
+ = 2.6.1 =
121
+ * Fixed warnings that appeared on non-upgrade of database.
122
+
123
= 2.6 =
124
* Added Privacy for Media.
125
* Added crude support for activity privacy (due for revision)
278
* HTML5 Video Tag Support (with fallback)
279
280
== Upgrade Notice ==
281
+ = 2.6.1 =
282
Adds privacy support and a couple of other fixes