Version Description
- Fixes errors due to absence of EXIF
- Fixes duplicate comment box on lightbox
- Fixes multimedia display on single media view
- Rewrites activity uploader to fix a lot of issues with themes
Download this release
Release Info
Developer | saurabhshukla |
Plugin | ![]() |
Version | 2.7.6 |
Comparing to | |
See all releases |
Code changes from version 2.7.5 to 2.7.6
- app/admin/BPMediaAdmin.php +15 -0
- app/assets/js/admin.js +226 -147
- app/assets/js/bp-media-activity-uploader.js +216 -138
- app/assets/js/main.js +10 -5
- app/helper/BPMediaSettings.php +9 -1
- app/importers/BPMediaAlbumimporter.php +221 -0
- app/importers/BPMediaImporter.php +137 -92
- app/main/BuddyPressMedia.php +5 -4
- app/main/activity/BPMediaActivity.php +1 -2
- app/main/includes/BPMediaActions.php +2 -2
- app/main/includes/BPMediaFunction.php +1 -6
- app/main/includes/BPMediaHostWordpress.php +1008 -1001
- index.php +2 -5
- readme.txt +9 -3
app/admin/BPMediaAdmin.php
CHANGED
@@ -27,6 +27,8 @@ if (!class_exists('BPMediaAdmin')) {
|
|
27 |
add_action('wp_ajax_bp_media_submit_request', array($this->bp_media_support, 'submit_request'), 1);
|
28 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
29 |
add_action('wp_ajax_bp_media_linkback', array($this, 'linkback'), 1);
|
|
|
|
|
30 |
add_action('wp_ajax_bp_media_convert_videos_form', array($this, 'convert_videos_mailchimp_send'), 1);
|
31 |
add_filter('plugin_row_meta', array($this, 'plugin_meta_premium_addon_link'), 1, 4);
|
32 |
if (is_admin()) {
|
@@ -57,6 +59,9 @@ if (!class_exists('BPMediaAdmin')) {
|
|
57 |
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
|
58 |
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
59 |
) . '#privacy_enabled');
|
|
|
|
|
|
|
60 |
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION);
|
61 |
}
|
62 |
|
@@ -66,11 +71,17 @@ if (!class_exists('BPMediaAdmin')) {
|
|
66 |
* @global string BP_MEDIA_TXT_DOMAIN
|
67 |
*/
|
68 |
public function menu() {
|
|
|
69 |
add_menu_page(__('BuddyPress Media Component', BP_MEDIA_TXT_DOMAIN), __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
|
70 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN), __('Settings', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
|
71 |
if (!BPMediaPrivacy::is_installed()) {
|
72 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Database Update', BP_MEDIA_TXT_DOMAIN), __('Update Database', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-privacy', array($this, 'privacy_page'));
|
73 |
}
|
|
|
|
|
|
|
|
|
|
|
74 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Addons', BP_MEDIA_TXT_DOMAIN), __('Addons', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-addons', array($this, 'addons_page'));
|
75 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Support', BP_MEDIA_TXT_DOMAIN), __('Support ', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-support', array($this, 'support_page'));
|
76 |
if (bp_get_option('bp-media-survey', true)) {
|
@@ -89,6 +100,10 @@ if (!class_exists('BPMediaAdmin')) {
|
|
89 |
$this->render_page('bp-media-privacy');
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
92 |
public function convert_videos_page() {
|
93 |
$this->render_page('bp-media-convert-videos');
|
94 |
}
|
27 |
add_action('wp_ajax_bp_media_submit_request', array($this->bp_media_support, 'submit_request'), 1);
|
28 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
29 |
add_action('wp_ajax_bp_media_linkback', array($this, 'linkback'), 1);
|
30 |
+
// add_action('wp_ajax_bp_media_bp_album_import', 'BPMediaAlbumimporter::bpmedia_ajax_import_callback', 1);
|
31 |
+
// add_action('wp_ajax_bp_media_bp_album_cleanup', 'BPMediaAlbumimporter::cleanup_after_install');
|
32 |
add_action('wp_ajax_bp_media_convert_videos_form', array($this, 'convert_videos_mailchimp_send'), 1);
|
33 |
add_filter('plugin_row_meta', array($this, 'plugin_meta_premium_addon_link'), 1, 4);
|
34 |
if (is_admin()) {
|
59 |
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
|
60 |
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
61 |
) . '#privacy_enabled');
|
62 |
+
wp_localize_script('bp-media-admin', 'settings_bp_album_import_url', add_query_arg(
|
63 |
+
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
64 |
+
));
|
65 |
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION);
|
66 |
}
|
67 |
|
71 |
* @global string BP_MEDIA_TXT_DOMAIN
|
72 |
*/
|
73 |
public function menu() {
|
74 |
+
global $wpdb;
|
75 |
add_menu_page(__('BuddyPress Media Component', BP_MEDIA_TXT_DOMAIN), __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
|
76 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN), __('Settings', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
|
77 |
if (!BPMediaPrivacy::is_installed()) {
|
78 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Database Update', BP_MEDIA_TXT_DOMAIN), __('Update Database', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-privacy', array($this, 'privacy_page'));
|
79 |
}
|
80 |
+
$bp_album_active = BPMediaImporter::_active('bp-album/loader.php');
|
81 |
+
$table = "{$wpdb->base_prefix}bp_album";
|
82 |
+
if (BPMediaImporter::table_exists($table) && $bp_album_active!=-1) {
|
83 |
+
add_submenu_page('bp-media-settings', __('BP Album Import', BP_MEDIA_TXT_DOMAIN), __('BP Album Importer', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-bp-album-importer', array($this, 'bp_album_importer_page'));
|
84 |
+
}
|
85 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Addons', BP_MEDIA_TXT_DOMAIN), __('Addons', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-addons', array($this, 'addons_page'));
|
86 |
add_submenu_page('bp-media-settings', __('BuddyPress Media Support', BP_MEDIA_TXT_DOMAIN), __('Support ', BP_MEDIA_TXT_DOMAIN), 'manage_options', 'bp-media-support', array($this, 'support_page'));
|
87 |
if (bp_get_option('bp-media-survey', true)) {
|
100 |
$this->render_page('bp-media-privacy');
|
101 |
}
|
102 |
|
103 |
+
public function bp_album_importer_page() {
|
104 |
+
$this->render_page('bp-media-bp-album-importer');
|
105 |
+
}
|
106 |
+
|
107 |
public function convert_videos_page() {
|
108 |
$this->render_page('bp-media-convert-videos');
|
109 |
}
|
app/assets/js/admin.js
CHANGED
@@ -1,159 +1,238 @@
|
|
1 |
jQuery(document).ready(function(){
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
/* Select Request */
|
25 |
-
jQuery('#bp-media-settings-boxes').on('change', '#select-request', function(){
|
26 |
-
if(jQuery(this).val()){
|
27 |
-
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
28 |
-
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html('<div class="support_form_laoder"></div>');
|
29 |
-
var data = {
|
30 |
-
action: 'bp_media_select_request',
|
31 |
-
form: jQuery(this).val()
|
32 |
-
};
|
33 |
-
|
34 |
-
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
35 |
-
jQuery.post(ajaxurl, data, function(response) {
|
36 |
-
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
37 |
-
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
|
38 |
-
});
|
39 |
-
}
|
40 |
-
});
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
function
|
75 |
-
return jQuery.post(ajaxurl, data, function(response){
|
76 |
-
if(response != 0){
|
77 |
-
var redirect = false;
|
78 |
-
var progw = Math.ceil((((parseInt(response)*20)+parseInt(data.values['finished']))/parseInt(data.values['total'])) *100);
|
79 |
-
console.log(progw);
|
80 |
-
if(progw>100){progw=100;redirect=true};
|
81 |
-
jQuery('#rtprogressbar>div').css('width',progw+'%');
|
82 |
-
finished = jQuery('#rtprivacyinstaller span.finished').html();
|
83 |
-
jQuery('#rtprivacyinstaller span.finished').html(parseInt(finished)+data.count);
|
84 |
-
if ( redirect ) {
|
85 |
-
jQuery.post(ajaxurl, { action: 'bp_media_privacy_redirect' }, function(response){
|
86 |
-
window.location = settings_url;
|
87 |
-
});
|
88 |
-
}
|
89 |
-
} else {
|
90 |
-
jQuery('#map_progress_msgs').html('<div class="map_mapping_failure">Row '+response+' failed.</div>');
|
91 |
-
}
|
92 |
-
});
|
93 |
-
}
|
94 |
-
|
95 |
-
jQuery('#rtprivacyinstall').click(function(e){
|
96 |
e.preventDefault();
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
$values [jQuery(this).attr('name')]=[jQuery(this).val()];
|
105 |
-
|
106 |
-
});
|
107 |
-
$data = {};
|
108 |
-
for(var i=1;i<=$values['steps'][0];i++ ){
|
109 |
-
$count=20;
|
110 |
-
if(i==$values['steps'][0]){
|
111 |
-
$count=parseInt($values['laststep'][0]);
|
112 |
-
if($count==0){$count=20};
|
113 |
-
}
|
114 |
-
newvals = {
|
115 |
-
'page':i,
|
116 |
-
'action':'bp_media_privacy_install',
|
117 |
-
'count':$count,
|
118 |
-
'values':$values
|
119 |
-
}
|
120 |
-
$data[i] = newvals;
|
121 |
-
}
|
122 |
-
var $startingpoint = jQuery.Deferred();
|
123 |
-
$startingpoint.resolve();
|
124 |
-
jQuery.each($data, function(i, v){
|
125 |
-
$startingpoint = $startingpoint.pipe( function() {
|
126 |
-
return fireRequest(v);
|
127 |
-
});
|
128 |
-
});
|
129 |
-
|
130 |
-
|
131 |
-
}
|
132 |
});
|
133 |
-
});
|
134 |
|
135 |
-
jQuery('#
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
jQuery(
|
140 |
-
|
141 |
-
|
142 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
-
jQuery('#video-transcoding-main-container').on('click','.video-transcoding-survey',function(e){
|
145 |
-
e.preventDefault();
|
146 |
-
var data = {
|
147 |
-
action: 'bp_media_convert_videos_form',
|
148 |
-
email: jQuery('.email').val(),
|
149 |
-
url: jQuery('.url').val(),
|
150 |
-
choice: jQuery('input[name="choice"]:checked').val(),
|
151 |
-
interested: jQuery('input[name="interested"]:checked').val()
|
152 |
-
}
|
153 |
-
jQuery.post(ajaxurl, data, function(response){
|
154 |
-
jQuery('#video-transcoding-main-container').html('<p><strong>'+response+'</strong></p>');
|
155 |
});
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
});
|
1 |
jQuery(document).ready(function(){
|
2 |
|
3 |
+
/* Linkback */
|
4 |
+
jQuery('#spread-the-word').on('click','#bp-media-add-linkback',function(){
|
5 |
+
var data = {
|
6 |
+
action: 'bp_media_linkback',
|
7 |
+
linkback: jQuery('#bp-media-add-linkback:checked').length
|
8 |
+
};
|
9 |
+
jQuery.post(bp_media_admin_ajax,data,function(response){
|
10 |
+
});
|
11 |
+
})
|
12 |
+
|
13 |
+
/* Fetch Feed */
|
14 |
+
var bp_media_news_section = jQuery('#latest-news');
|
15 |
+
if(bp_media_news_section.length>0){
|
16 |
+
var data = {
|
17 |
+
action: 'bp_media_fetch_feed'
|
18 |
+
};
|
19 |
+
jQuery.post(bp_media_admin_ajax,data,function(response){
|
20 |
+
bp_media_news_section.find('.inside').html(response);
|
21 |
+
});
|
22 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
/* Select Request */
|
25 |
+
jQuery('#bp-media-settings-boxes').on('change', '#select-request', function(){
|
26 |
+
if(jQuery(this).val()){
|
27 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
28 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html('<div class="support_form_laoder"></div>');
|
29 |
+
var data = {
|
30 |
+
action: 'bp_media_select_request',
|
31 |
+
form: jQuery(this).val()
|
32 |
+
};
|
33 |
+
|
34 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
35 |
+
jQuery.post(ajaxurl, data, function(response) {
|
36 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
37 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
|
38 |
+
});
|
39 |
+
}
|
40 |
+
});
|
41 |
|
42 |
+
/* Cancel Request */
|
43 |
+
jQuery('#bp-media-settings-boxes').on('click', '#cancel-request', function(){
|
44 |
+
if(jQuery(this).val()){
|
45 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
46 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html('<div class="support_form_laoder"></div>');
|
47 |
+
var data = {
|
48 |
+
action: 'bp_media_cancel_request'
|
49 |
+
};
|
50 |
+
|
51 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
52 |
+
jQuery.post(ajaxurl, data, function(response) {
|
53 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
54 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
|
55 |
+
});
|
56 |
+
}
|
57 |
+
});
|
58 |
+
|
59 |
+
/* Submit Request */
|
60 |
+
jQuery('.bp-media-support').on('submit', '#bp_media_settings_form', function(e){
|
61 |
+
e.preventDefault();
|
62 |
+
var data = {
|
63 |
+
action: 'bp_media_submit_request',
|
64 |
+
form_data: jQuery('form').serialize()
|
65 |
+
};
|
66 |
+
|
67 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
68 |
+
jQuery.post(ajaxurl, data, function(response) {
|
69 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
|
70 |
+
jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
|
71 |
+
});
|
72 |
+
});
|
73 |
+
|
74 |
+
function fireRequest(data) {
|
75 |
+
return jQuery.post(ajaxurl, data, function(response){
|
76 |
+
if(response != 0){
|
77 |
+
var redirect = false;
|
78 |
+
var progw = Math.ceil((((parseInt(response)*20)+parseInt(data.values['finished']))/parseInt(data.values['total'])) *100);
|
79 |
+
console.log(progw);
|
80 |
+
if(progw>100){
|
81 |
+
progw=100;
|
82 |
+
redirect=true
|
83 |
+
};
|
84 |
+
jQuery('#rtprogressbar>div').css('width',progw+'%');
|
85 |
+
finished = jQuery('#rtprivacyinstaller span.finished').html();
|
86 |
+
jQuery('#rtprivacyinstaller span.finished').html(parseInt(finished)+data.count);
|
87 |
+
if ( redirect ) {
|
88 |
+
jQuery.post(ajaxurl, {
|
89 |
+
action: 'bp_media_privacy_redirect'
|
90 |
+
}, function(response){
|
91 |
+
window.location = settings_url;
|
92 |
+
});
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
jQuery('#map_progress_msgs').html('<div class="map_mapping_failure">Row '+response+' failed.</div>');
|
96 |
+
}
|
97 |
+
});
|
98 |
+
}
|
99 |
+
|
100 |
+
jQuery('#rtprivacyinstall').click(function(e){
|
101 |
+
e.preventDefault();
|
102 |
+
$progress_parent = jQuery('#rtprivacyinstaller');
|
103 |
+
$progress_parent.find('.rtprivacytype').each(function(){
|
104 |
+
$type=jQuery(this).attr('id');
|
105 |
+
if($type=='total'){
|
106 |
+
$values=[];
|
107 |
+
jQuery(this).find('input').each(function(){
|
108 |
+
|
109 |
+
$values [jQuery(this).attr('name')]=[jQuery(this).val()];
|
110 |
+
|
111 |
+
});
|
112 |
+
$data = {};
|
113 |
+
for(var i=1;i<=$values['steps'][0];i++ ){
|
114 |
+
$count=20;
|
115 |
+
if(i==$values['steps'][0]){
|
116 |
+
$count=parseInt($values['laststep'][0]);
|
117 |
+
if($count==0){
|
118 |
+
$count=20
|
119 |
+
};
|
120 |
+
}
|
121 |
+
newvals = {
|
122 |
+
'page':i,
|
123 |
+
'action':'bp_media_privacy_install',
|
124 |
+
'count':$count,
|
125 |
+
'values':$values
|
126 |
+
}
|
127 |
+
$data[i] = newvals;
|
128 |
+
}
|
129 |
+
var $startingpoint = jQuery.Deferred();
|
130 |
+
$startingpoint.resolve();
|
131 |
+
jQuery.each($data, function(i, v){
|
132 |
+
$startingpoint = $startingpoint.pipe( function() {
|
133 |
+
return fireRequest(v);
|
134 |
+
});
|
135 |
+
});
|
136 |
+
|
137 |
+
|
138 |
+
}
|
139 |
+
});
|
140 |
+
});
|
141 |
+
|
142 |
+
function fireimportRequest(data) {
|
143 |
+
return jQuery.post(ajaxurl, data, function(response){
|
144 |
+
cleanup = false;
|
145 |
+
if(response != 0){
|
146 |
+
var redirect = false;
|
147 |
+
var progw = Math.ceil((((parseInt(response)*20)+parseInt(data.values['finished']))/parseInt(data.values['total'])) *100);
|
148 |
+
if(progw>100){
|
149 |
+
progw=100;
|
150 |
+
cleanup=true
|
151 |
+
};
|
152 |
+
jQuery('#rtprogressbar>div').css('width',progw+'%');
|
153 |
+
finished = jQuery('#bpmedia-bpalbumimport span.finished').html();
|
154 |
+
jQuery('#bpmedia-bpalbumimport span.finished').html(parseInt(finished)+data.count);
|
155 |
+
if ( cleanup ) {
|
156 |
+
window.location = document.URL;
|
157 |
+
}
|
158 |
+
} else {
|
159 |
+
jQuery('#map_progress_msgs').html('<div class="map_mapping_failure">Row '+response+' failed.</div>');
|
160 |
+
}
|
161 |
+
});
|
162 |
+
}
|
163 |
|
164 |
+
jQuery('#bpmedia-bpalbumimport-cleanup').click(function(e){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
e.preventDefault();
|
166 |
+
jQuery.post(ajaxurl, {
|
167 |
+
action: 'bp_media_bp_album_cleanup'
|
168 |
+
}, function(response){
|
169 |
+
window.location = settings_bp_album_import_url;
|
170 |
+
});
|
171 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
});
|
|
|
173 |
|
174 |
+
jQuery('#bpmedia-bpalbumimport').click(function(e){
|
175 |
+
e.preventDefault();
|
176 |
+
$progress_parent = jQuery('#bpmedia-bpalbumimport');
|
177 |
+
$values=[];
|
178 |
+
jQuery(this).parent().find('input').each(function(){
|
179 |
+
$values [jQuery(this).attr('name')]=[jQuery(this).val()];
|
180 |
+
|
181 |
+
});
|
182 |
+
console.log($values);
|
183 |
+
|
184 |
+
$data = {};
|
185 |
+
for(var i=1;i<=$values['steps'][0];i++ ){
|
186 |
+
$count=20;
|
187 |
+
if(i==$values['steps'][0]){
|
188 |
+
$count=parseInt($values['laststep'][0]);
|
189 |
+
if($count==0){
|
190 |
+
$count=20
|
191 |
+
};
|
192 |
+
}
|
193 |
+
newvals = {
|
194 |
+
'page':i,
|
195 |
+
'action':'bp_media_bp_album_import',
|
196 |
+
'count':$count,
|
197 |
+
'values':$values
|
198 |
+
}
|
199 |
+
$data[i] = newvals;
|
200 |
+
}
|
201 |
+
console.log($data);
|
202 |
+
var $startingpoint = jQuery.Deferred();
|
203 |
+
$startingpoint.resolve();
|
204 |
+
jQuery.each($data, function(i, v){
|
205 |
+
$startingpoint = $startingpoint.pipe( function() {
|
206 |
+
return fireimportRequest(v);
|
207 |
+
});
|
208 |
+
});
|
209 |
+
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
});
|
212 |
+
|
213 |
+
jQuery('#bp-media-settings-boxes').on('click','.interested',function(){
|
214 |
+
jQuery('.interested-container').removeClass('hidden');
|
215 |
+
jQuery('.choice-free').attr('required','required');
|
216 |
+
});
|
217 |
+
jQuery('#bp-media-settings-boxes').on('click','.not-interested',function(){
|
218 |
+
jQuery('.interested-container').addClass('hidden');
|
219 |
+
jQuery('.choice-free').removeAttr('required');
|
220 |
+
});
|
221 |
+
|
222 |
+
jQuery('#video-transcoding-main-container').on('click','.video-transcoding-survey',function(e){
|
223 |
+
e.preventDefault();
|
224 |
+
var data = {
|
225 |
+
action: 'bp_media_convert_videos_form',
|
226 |
+
email: jQuery('.email').val(),
|
227 |
+
url: jQuery('.url').val(),
|
228 |
+
choice: jQuery('input[name="choice"]:checked').val(),
|
229 |
+
interested: jQuery('input[name="interested"]:checked').val()
|
230 |
+
}
|
231 |
+
jQuery.post(ajaxurl, data, function(response){
|
232 |
+
jQuery('#video-transcoding-main-container').html('<p><strong>'+response+'</strong></p>');
|
233 |
+
});
|
234 |
+
return false;
|
235 |
+
});
|
236 |
+
|
237 |
|
238 |
});
|
app/assets/js/bp-media-activity-uploader.js
CHANGED
@@ -4,142 +4,220 @@
|
|
4 |
*/
|
5 |
|
6 |
jQuery(document).ready(function(){
|
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 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
});
|
4 |
*/
|
5 |
|
6 |
jQuery(document).ready(function(){
|
7 |
+
if ( jQuery('#bp-media-activity-upload-ui').length > 0 ) {
|
8 |
+
|
9 |
+
jQuery('#whats-new').off('focus');
|
10 |
+
jQuery('#whats-new').on('focus', function(){
|
11 |
+
jQuery("#whats-new-options").css('height','auto');
|
12 |
+
jQuery("form#whats-new-form textarea").animate({
|
13 |
+
height:'50px'
|
14 |
+
});
|
15 |
+
jQuery("#aw-whats-new-submit").prop("disabled", false);
|
16 |
+
});
|
17 |
+
|
18 |
+
jQuery("input#aw-whats-new-submit").off('click');
|
19 |
+
jQuery("input#aw-whats-new-submit").on('click',function() {
|
20 |
+
var button = jQuery(this);
|
21 |
+
var form = button.parent().parent().parent().parent();
|
22 |
+
|
23 |
+
form.children().each( function() {
|
24 |
+
if ( jQuery.nodeName(this, "textarea") || jQuery.nodeName(this, "input") )
|
25 |
+
jQuery(this).prop( 'disabled', true );
|
26 |
+
});
|
27 |
+
|
28 |
+
/* Remove any errors */
|
29 |
+
jQuery('div.error').remove();
|
30 |
+
button.addClass('loading');
|
31 |
+
button.prop('disabled', true);
|
32 |
+
|
33 |
+
/* Default POST values */
|
34 |
+
var object = '';
|
35 |
+
var item_id = jQuery("#whats-new-post-in").val();
|
36 |
+
var content = jQuery("#bp-media-dummy-update").val();
|
37 |
+
|
38 |
+
/* Set object for non-profile posts */
|
39 |
+
if ( item_id > 0 ) {
|
40 |
+
object = jQuery("#whats-new-post-object").val();
|
41 |
+
}
|
42 |
+
|
43 |
+
jQuery.post( ajaxurl, {
|
44 |
+
action: 'post_update',
|
45 |
+
'cookie': encodeURIComponent(document.cookie),
|
46 |
+
'_wpnonce_post_update': jQuery("input#_wpnonce_post_update").val(),
|
47 |
+
'content': content,
|
48 |
+
'object': object,
|
49 |
+
'item_id': item_id,
|
50 |
+
'_bp_as_nonce': jQuery('#_bp_as_nonce').val() || ''
|
51 |
+
},
|
52 |
+
function(response) {
|
53 |
+
|
54 |
+
form.children().each( function() {
|
55 |
+
if ( jQuery.nodeName(this, "textarea") || jQuery.nodeName(this, "input") ) {
|
56 |
+
jQuery(this).prop( 'disabled', false );
|
57 |
+
}
|
58 |
+
});
|
59 |
+
|
60 |
+
/* Check for errors and append if found. */
|
61 |
+
if ( response[0] + response[1] == '-1' ) {
|
62 |
+
form.prepend( response.substr( 2, response.length ) );
|
63 |
+
jQuery( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
|
64 |
+
} else {
|
65 |
+
if ( 0 == jQuery("ul.activity-list").length ) {
|
66 |
+
jQuery("div.error").slideUp(100).remove();
|
67 |
+
jQuery("div#message").slideUp(100).remove();
|
68 |
+
jQuery("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
|
69 |
+
}
|
70 |
+
|
71 |
+
jQuery("ul#activity-stream").prepend(response);
|
72 |
+
jQuery("ul#activity-stream li:first").addClass('new-update');
|
73 |
+
|
74 |
+
if ( 0 != jQuery("#latest-update").length ) {
|
75 |
+
var l = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").html();
|
76 |
+
var v = jQuery("ul#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
|
77 |
+
|
78 |
+
var ltext = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").text();
|
79 |
+
|
80 |
+
var u = '';
|
81 |
+
if ( ltext != '' )
|
82 |
+
u = l + ' ';
|
83 |
+
|
84 |
+
u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
|
85 |
+
|
86 |
+
jQuery("#latest-update").slideUp(300,function(){
|
87 |
+
jQuery("#latest-update").html( u );
|
88 |
+
jQuery("#latest-update").slideDown(300);
|
89 |
+
});
|
90 |
+
}
|
91 |
+
|
92 |
+
jQuery("li.new-update").hide().slideDown( 300 );
|
93 |
+
jQuery("li.new-update").removeClass( 'new-update' );
|
94 |
+
jQuery("textarea#whats-new").val('');
|
95 |
+
}
|
96 |
+
|
97 |
+
jQuery("#whats-new-options").animate({
|
98 |
+
height:'0px'
|
99 |
+
});
|
100 |
+
jQuery("form#whats-new-form textarea").animate({
|
101 |
+
height:'20px'
|
102 |
+
});
|
103 |
+
jQuery("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
|
104 |
+
});
|
105 |
+
|
106 |
+
return false;
|
107 |
+
});
|
108 |
+
|
109 |
+
$dummy_update_box = jQuery('<input id="bp-media-dummy-update" type="hidden" name="whats-new" />');
|
110 |
+
$update_container = jQuery('#whats-new-textarea');
|
111 |
+
$update_container.append($dummy_update_box);
|
112 |
+
|
113 |
+
jQuery('#whats-new').on('keyup',function(){
|
114 |
+
$this = jQuery(this);
|
115 |
+
$that = jQuery('#bp-media-update-text');
|
116 |
+
$that.val($this.val()).change();
|
117 |
+
});
|
118 |
+
jQuery('#bp-media-update-text').on('change',function(){
|
119 |
+
bp_media_overwrite();
|
120 |
+
});
|
121 |
+
jQuery('#bp-media-update-json').on('change',function(){
|
122 |
+
bp_media_overwrite();
|
123 |
+
});
|
124 |
+
|
125 |
+
$bp_media_activity_is_multiple_upload = false;
|
126 |
+
$bp_media_activity_uploader=new plupload.Uploader(bp_media_uploader_params);
|
127 |
+
$bp_media_activity_album_selected = false;
|
128 |
+
$bp_media_activity_uploader.init();
|
129 |
+
|
130 |
+
$bp_media_activity_uploader.bind('FilesAdded', function(up, files) {
|
131 |
+
//bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
|
132 |
+
$bp_media_activity_is_multiple_upload = files.length>1;
|
133 |
+
jQuery.each(files, function(i, file) {
|
134 |
+
$bp_media_activity_extension = file.name.substr( (file.name.lastIndexOf('.') +1) );
|
135 |
+
jQuery('#bp-media-activity-uploaded-files').append('<div id="bp-media-activity-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' + file.name + ' (' + plupload.formatSize(file.size) + ')(<b>0%</b>)</div><div class="bp-media-progress-completed"></div></div>');
|
136 |
+
});
|
137 |
+
// bp_media_activity_album_selected = jQuery('#bp-media-activity-selected-album').val();
|
138 |
+
$bp_media_activity_album_selected = default_album;
|
139 |
+
$bp_media_activity_uploader.start();
|
140 |
+
do_bp_jazz();
|
141 |
+
up.refresh(); // Reposition Flash/Silverlight
|
142 |
+
});
|
143 |
+
$bp_media_activity_uploader.bind('UploadProgress', function(up, file) {
|
144 |
+
jQuery('input#aw-whats-new-submit').prop('disabled',true).addClass('loading');
|
145 |
+
jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
|
146 |
+
jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
|
147 |
+
});
|
148 |
+
|
149 |
+
$bp_media_activity_uploader.bind('Error', function(up, err) {
|
150 |
+
jQuery('#bp-media-activity-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
|
151 |
+
', Message: ' + err.message +
|
152 |
+
(err.file ? ', File: ' + err.file.name : '') +
|
153 |
+
'</p></div>'
|
154 |
+
);
|
155 |
+
up.refresh();
|
156 |
+
});
|
157 |
+
$bp_media_activity_uploader.bind('FileUploaded', function(up, file,response) {
|
158 |
+
jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-text b').html("100%");
|
159 |
+
$album_arr = [];
|
160 |
+
$val = jQuery('#bp-media-update-json').val();
|
161 |
+
if($val!=''){
|
162 |
+
$album_arr= JSON.parse($val);
|
163 |
+
}
|
164 |
+
$album_arr.push(parseInt(response.response));
|
165 |
+
$album_json =JSON.stringify($album_arr);
|
166 |
+
jQuery('#bp-media-update-json').val($album_json).change();
|
167 |
+
jQuery('#aw-whats-new-submit').prop('disabled',false).removeClass('loading');
|
168 |
+
|
169 |
+
});
|
170 |
+
$bp_media_activity_uploader.bind('BeforeUpload',function(up){
|
171 |
+
up.settings.multipart_params.is_multiple_upload = $bp_media_activity_is_multiple_upload;
|
172 |
+
up.settings.multipart_params.bp_media_album_id = $bp_media_activity_album_selected;
|
173 |
+
up.settings.multipart_params.is_activity = true;
|
174 |
+
});
|
175 |
+
//jQuery("#aw-whats-new-submit").off( 'click');
|
176 |
+
|
177 |
+
jQuery("#aw-whats-new-submit").on( 'click', function() {
|
178 |
+
$latest = '';
|
179 |
+
$val = bp_media_stringify();
|
180 |
+
jQuery("#bp-media-dummy-update").val('');
|
181 |
+
jQuery("#bp-media-update-json").val('');
|
182 |
+
jQuery("#bp-media-update-txt").val('');
|
183 |
+
jQuery("#bp-media-activity-uploaded-files").empty();
|
184 |
+
setTimeout(function(){
|
185 |
+
if($val!=''){
|
186 |
+
$album_arr= JSON.parse($val);
|
187 |
+
$lastid = parseInt($album_arr.length) - 1;
|
188 |
+
$media_id = $album_arr[parseInt($lastid)];
|
189 |
+
$activity = (jQuery('#activity-stream').find('li').first().attr('id')).split('-');
|
190 |
+
$activity_id = $activity[1];
|
191 |
+
var data = {
|
192 |
+
action: 'bp_media_get_latest_activity',
|
193 |
+
content : $val,
|
194 |
+
id: $activity_id
|
195 |
+
};
|
196 |
+
jQuery.get(ajaxurl,data,function(response){
|
197 |
+
$latest = response;
|
198 |
+
jQuery('#latest-update').html($latest);
|
199 |
+
});
|
200 |
+
}
|
201 |
+
},1000);
|
202 |
+
});
|
203 |
+
|
204 |
+
$bp_media_activity_uploader.bind('UploadComplete',function(response){
|
205 |
+
|
206 |
+
});
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
function bp_media_stringify(){
|
211 |
+
$album_json = jQuery('#bp-media-update-json').val();
|
212 |
+
$update_txt = jQuery('#bp-media-update-text').val();
|
213 |
+
$activity = {
|
214 |
+
'media':$album_json,
|
215 |
+
'update_txt':encodeURIComponent($update_txt)
|
216 |
+
};
|
217 |
+
return JSON.stringify($activity);
|
218 |
+
}
|
219 |
+
|
220 |
+
function bp_media_overwrite(){
|
221 |
+
jQuery('#bp-media-dummy-update').val(bp_media_stringify());
|
222 |
+
}
|
223 |
});
|
app/assets/js/main.js
CHANGED
@@ -6,9 +6,12 @@ function bp_media_create_element(id){
|
|
6 |
return false;
|
7 |
}
|
8 |
var $current;
|
|
|
|
|
|
|
9 |
jQuery(document).ready(function(){
|
10 |
|
11 |
-
jQuery('
|
12 |
jQuery(this).mediaelementplayer({
|
13 |
enableKeyboard: false,
|
14 |
startVolume: 1,
|
@@ -19,10 +22,10 @@ jQuery(document).ready(function(){
|
|
19 |
}
|
20 |
});
|
21 |
});
|
22 |
-
jQuery('
|
23 |
|
24 |
jQuery('ul#activity-stream').on('DOMNodeInserted', function(){
|
25 |
-
jQuery('ul#activity-stream
|
26 |
})
|
27 |
|
28 |
|
@@ -94,7 +97,7 @@ jQuery(document).ready(function(){
|
|
94 |
}
|
95 |
);
|
96 |
});
|
97 |
-
|
98 |
if ( bp_media_vars.lightbox > 0 ) {
|
99 |
jQuery('#bp-media-list').on('click','li a',function(e){
|
100 |
e.preventDefault();
|
@@ -171,6 +174,7 @@ jQuery(document).ready(function(){
|
|
171 |
'opacity': 90
|
172 |
});
|
173 |
do_fixes($medialoaded);
|
|
|
174 |
});
|
175 |
}
|
176 |
function transit_media($current){
|
@@ -183,6 +187,7 @@ jQuery(document).ready(function(){
|
|
183 |
$medialoaded.empty();
|
184 |
$medialoaded.append($mediacontent);
|
185 |
do_fixes($medialoaded);
|
|
|
186 |
});
|
187 |
}
|
188 |
|
@@ -334,7 +339,7 @@ jQuery(document).ready(function(){
|
|
334 |
|
335 |
var a_id = ids[2]
|
336 |
var c_id = target.attr('href').substr( 10, target.attr('href').length );
|
337 |
-
var form = jQuery( '#ac-form-' + a_id );
|
338 |
|
339 |
form.css( 'display', 'none' );
|
340 |
form.removeClass('root');
|
6 |
return false;
|
7 |
}
|
8 |
var $current;
|
9 |
+
|
10 |
+
//window.onbeforeunload= function() { return "Custom message here"; };
|
11 |
+
|
12 |
jQuery(document).ready(function(){
|
13 |
|
14 |
+
jQuery('body').on('mediapreview','.bp_media_content video,.bp_media_content audio', function(){
|
15 |
jQuery(this).mediaelementplayer({
|
16 |
enableKeyboard: false,
|
17 |
startVolume: 1,
|
22 |
}
|
23 |
});
|
24 |
});
|
25 |
+
jQuery('.bp_media_content video,.bp_media_content audio').trigger('mediapreview');
|
26 |
|
27 |
jQuery('ul#activity-stream').on('DOMNodeInserted', function(){
|
28 |
+
jQuery('ul#activity-stream .bp_media_content video,ul#activity-stream .bp_media_content audio').trigger('mediapreview');
|
29 |
})
|
30 |
|
31 |
|
97 |
}
|
98 |
);
|
99 |
});
|
100 |
+
|
101 |
if ( bp_media_vars.lightbox > 0 ) {
|
102 |
jQuery('#bp-media-list').on('click','li a',function(e){
|
103 |
e.preventDefault();
|
174 |
'opacity': 90
|
175 |
});
|
176 |
do_fixes($medialoaded);
|
177 |
+
jQuery('.bp_media_content video,.bp_media_content audio').trigger('mediapreview');
|
178 |
});
|
179 |
}
|
180 |
function transit_media($current){
|
187 |
$medialoaded.empty();
|
188 |
$medialoaded.append($mediacontent);
|
189 |
do_fixes($medialoaded);
|
190 |
+
jQuery('.bp_media_content video,.bp_media_content audio').trigger('mediapreview');
|
191 |
});
|
192 |
}
|
193 |
|
339 |
|
340 |
var a_id = ids[2]
|
341 |
var c_id = target.attr('href').substr( 10, target.attr('href').length );
|
342 |
+
var form = jQuery( '.bp-media-ajax-single #ac-form-' + a_id );
|
343 |
|
344 |
form.css( 'display', 'none' );
|
345 |
form.removeClass('root');
|
app/helper/BPMediaSettings.php
CHANGED
@@ -29,7 +29,7 @@ if (!class_exists('BPMediaSettings')) {
|
|
29 |
* @global BPMediaAddon $bp_media_addon
|
30 |
*/
|
31 |
public function settings() {
|
32 |
-
global $bp_media, $bp_media_addon;
|
33 |
add_settings_section('bpm-settings', __('Enabled Media Types', BP_MEDIA_TXT_DOMAIN), is_multisite() ? array($this, 'network_notices') : '', 'bp-media-settings');
|
34 |
add_settings_field('bpm-image', __('Photos', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
|
35 |
'setting' => 'bp_media_options',
|
@@ -151,6 +151,14 @@ if (!class_exists('BPMediaSettings')) {
|
|
151 |
add_filter('bp_media_add_sub_tabs', array($bp_media_privacy, 'ui'), 99, 2);
|
152 |
add_settings_section('bpm-privacy', __('Update Database', BP_MEDIA_TXT_DOMAIN), array($bp_media_privacy, 'init'), 'bp-media-privacy');
|
153 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
add_settings_section('bpm-convert-videos', '', array($this, 'convert_videos_form'), 'bp-media-convert-videos');
|
156 |
|
29 |
* @global BPMediaAddon $bp_media_addon
|
30 |
*/
|
31 |
public function settings() {
|
32 |
+
global $bp_media, $bp_media_addon, $wpdb;
|
33 |
add_settings_section('bpm-settings', __('Enabled Media Types', BP_MEDIA_TXT_DOMAIN), is_multisite() ? array($this, 'network_notices') : '', 'bp-media-settings');
|
34 |
add_settings_field('bpm-image', __('Photos', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
|
35 |
'setting' => 'bp_media_options',
|
151 |
add_filter('bp_media_add_sub_tabs', array($bp_media_privacy, 'ui'), 99, 2);
|
152 |
add_settings_section('bpm-privacy', __('Update Database', BP_MEDIA_TXT_DOMAIN), array($bp_media_privacy, 'init'), 'bp-media-privacy');
|
153 |
}
|
154 |
+
|
155 |
+
$bp_album_active = BPMediaImporter::_active('bp-album/loader.php');
|
156 |
+
$table = "{$wpdb->base_prefix}bp_album";
|
157 |
+
if (BPMediaImporter::table_exists($table) && $bp_album_active!=-1) {
|
158 |
+
$bp_media_album_importer = new BPMediaAlbumimporter();
|
159 |
+
add_filter('bp_media_add_sub_tabs', array($bp_media_album_importer, 'tab'), 99, 2);
|
160 |
+
add_settings_section('bpm-bp-album-importer', __('BP Album Importer', BP_MEDIA_TXT_DOMAIN), array($bp_media_album_importer, 'ui'), 'bp-media-bp-album-importer');
|
161 |
+
}
|
162 |
|
163 |
add_settings_section('bpm-convert-videos', '', array($this, 'convert_videos_form'), 'bp-media-convert-videos');
|
164 |
|
app/importers/BPMediaAlbumimporter.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* To change this template, choose Tools | Templates
|
5 |
+
* and open the template in the editor.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Description of BPMediaBPAlbumImporter
|
10 |
+
*
|
11 |
+
* @author saurabh
|
12 |
+
*/
|
13 |
+
class BPMediaAlbumimporter extends BPMediaImporter {
|
14 |
+
|
15 |
+
function __construct() {
|
16 |
+
global $wpdb;
|
17 |
+
parent::__construct();
|
18 |
+
$this->path = 'bp-album/loader.php';
|
19 |
+
$this->active = $this->_active($this->path);
|
20 |
+
$table = "{$wpdb->base_prefix}bp_album";
|
21 |
+
if (BPMediaImporter::table_exists($table) && $this->active != -1 && !$this->column_exists('import_status')) {
|
22 |
+
$this->update_table();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
function update_table() {
|
27 |
+
if ($this->column_exists('import_status'))
|
28 |
+
return;
|
29 |
+
global $wpdb;
|
30 |
+
return $wpdb->query(
|
31 |
+
"ALTER TABLE {$wpdb->base_prefix}bp_album ADD COLUMN
|
32 |
+
import_status TINYINT (1) NOT NULL DEFAULT 0"
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
function column_exists($column) {
|
37 |
+
global $wpdb;
|
38 |
+
return $wpdb->query(
|
39 |
+
"SHOW COLUMNS FROM {$wpdb->base_prefix}bp_album LIKE '$column'"
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
function tab($tabs, $tab) {
|
44 |
+
$idle_class = 'nav-tab';
|
45 |
+
$active_class = 'nav-tab nav-tab-active';
|
46 |
+
$tabs[] = array(
|
47 |
+
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-bp-album-importer'), 'admin.php')),
|
48 |
+
'title' => __('Import BP-Album', BP_MEDIA_TXT_DOMAIN),
|
49 |
+
'name' => __('Import BP-Album', BP_MEDIA_TXT_DOMAIN),
|
50 |
+
'class' => ($tab == 'bp-media-bp-album-importer') ? $active_class : $idle_class
|
51 |
+
);
|
52 |
+
return $tabs;
|
53 |
+
}
|
54 |
+
|
55 |
+
function ui() {
|
56 |
+
$this->progress = new rtProgress();
|
57 |
+
$total = $this->get_total_count();
|
58 |
+
$finished = $this->get_completed_count();
|
59 |
+
|
60 |
+
|
61 |
+
//(isset($total) && isset($finished) && is_array($total) && is_array($finished)){
|
62 |
+
echo '<div id="bpmedia-bpalbumimporter">';
|
63 |
+
if ($finished != $total) {
|
64 |
+
if (!$total) {
|
65 |
+
echo '<p><strong>' . __('You have nothing to import') . '</strong></p>';
|
66 |
+
} elseif ($this->active != 1) {
|
67 |
+
echo '<div id="setting-error-bp-album-importer" class="error settings-error below-h2">
|
68 |
+
<p><strong>' . __('This process is irreversible. Please take a backup of your database and files, before proceeding.', BP_MEDIA_TXT_DOMAIN) . '</strong></p></div>';
|
69 |
+
echo '<strong>';
|
70 |
+
echo '<span class="finished">' . $finished . '</span> / <span class="total">' . $total . '</span>';
|
71 |
+
echo '</strong>';
|
72 |
+
$progress = 100;
|
73 |
+
if ($total != 0) {
|
74 |
+
$todo = $total - $finished;
|
75 |
+
$steps = ceil($todo / 20);
|
76 |
+
$laststep = $todo % 20;
|
77 |
+
$progress = $this->progress->progress($finished, $total);
|
78 |
+
echo '<input type="hidden" value="' . $finished . '" name="finished"/>';
|
79 |
+
echo '<input type="hidden" value="' . $total . '" name="total"/>';
|
80 |
+
echo '<input type="hidden" value="' . $todo . '" name="todo"/>';
|
81 |
+
echo '<input type="hidden" value="' . $steps . '" name="steps"/>';
|
82 |
+
echo '<input type="hidden" value="' . $laststep . '" name="laststep"/>';
|
83 |
+
$this->progress->progress_ui($progress);
|
84 |
+
echo "<br>";
|
85 |
+
}
|
86 |
+
echo '<button id="bpmedia-bpalbumimport" class="button button-primary">';
|
87 |
+
_e('Start', BP_MEDIA_TXT_DOMAIN);
|
88 |
+
echo '</button>';
|
89 |
+
} else {
|
90 |
+
$install_link = wp_nonce_url(admin_url('plugins.php?action=deactivate&plugin=' . urlencode($this->path)), 'deactivate-plugin_' . $this->path);
|
91 |
+
echo '<p><strong>' . sprintf(__('Please <a href="%s">deactivate</a> BP-Album first', BP_MEDIA_TXT_DOMAIN), $install_link) . '</strong></p>';
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
echo '<p class="info">';
|
95 |
+
_e('All media from BP Album has been imported. However, there are a lot of extra files and a database table eating up your resources. Would you like to delete them now?', BP_MEDIA_TXT_DOMAIN);
|
96 |
+
echo '</p>';
|
97 |
+
echo '<div id="setting-error-bp-album-importer" class="error settings-error below-h2">
|
98 |
+
<p><strong>' . __('This process is irreversible. Please take a backup of your database and files, before proceeding.', BP_MEDIA_TXT_DOMAIN) . '</strong></p></div>';
|
99 |
+
echo '<button id="bpmedia-bpalbumimport-cleanup" class="button button-primary">';
|
100 |
+
_e('Clean Up', BP_MEDIA_TXT_DOMAIN);
|
101 |
+
echo '</button>';
|
102 |
+
}
|
103 |
+
echo '</div>';
|
104 |
+
}
|
105 |
+
|
106 |
+
function create_album($author_id, $album_name = 'BP Album') {
|
107 |
+
global $bp_media, $wpdb;
|
108 |
+
|
109 |
+
if (array_key_exists('bp_album_import_name', $bp_media->options)) {
|
110 |
+
if ($bp_media->options['bp_album_import_name'] != '') {
|
111 |
+
$album_name = $bp_media->options['bp_album_import_name'];
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
$query = "SELECT ID from $wpdb->posts WHERE post_type='bp_media_album' AND post_status = 'publish' AND post_author = $author_id AND post_title LIKE '{$album_name}'";
|
116 |
+
$result = $wpdb->get_results($query);
|
117 |
+
if (count($result) < 1) {
|
118 |
+
$album = new BPMediaAlbum();
|
119 |
+
$album->add_album($album_name, $author_id);
|
120 |
+
$album_id = $album->get_id();
|
121 |
+
} else {
|
122 |
+
$album_id = $result[0]->ID;
|
123 |
+
}
|
124 |
+
$wpdb->update($wpdb->prefix . 'bp_activity', array('secondary_item_id' => -999), array('id' => get_post_meta($album_id, 'bp_media_child_activity', true)));
|
125 |
+
|
126 |
+
return $album_id;
|
127 |
+
}
|
128 |
+
|
129 |
+
function get_total_count() {
|
130 |
+
global $wpdb;
|
131 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
132 |
+
if ($this->table_exists($table) && $this->active != -1) {
|
133 |
+
return $wpdb->query("SELECT * FROM $table");
|
134 |
+
}
|
135 |
+
return 0;
|
136 |
+
}
|
137 |
+
|
138 |
+
function get_completed_count() {
|
139 |
+
global $wpdb;
|
140 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
141 |
+
if ($this->table_exists($table) && $this->active != -1) {
|
142 |
+
return $wpdb->query("SELECT * FROM $table WHERE import_status!=0");
|
143 |
+
}
|
144 |
+
return 0;
|
145 |
+
}
|
146 |
+
|
147 |
+
static function batch_import($offset = 0, $count = 20) {
|
148 |
+
global $wpdb;
|
149 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
150 |
+
$bp_album_data = $wpdb->get_results("SELECT * FROM $table WHERE import_status=0 LIMIT $count OFFSET $offset");
|
151 |
+
return $bp_album_data;
|
152 |
+
}
|
153 |
+
|
154 |
+
static function bpmedia_ajax_import_callback() {
|
155 |
+
|
156 |
+
$page = isset($_GET['page']) ? $_GET['page'] : 1;
|
157 |
+
$count = isset($_GET['count']) ? $_GET['count'] : 20;
|
158 |
+
$offset = ($page > 1) ? (($page - 1) * 20 + $count) : 0;
|
159 |
+
|
160 |
+
$bp_album_data = BPMediaAlbumimporter::batch_import($offset, $count);
|
161 |
+
global $wpdb;
|
162 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
163 |
+
|
164 |
+
foreach ($bp_album_data as &$bp_album_item) {
|
165 |
+
|
166 |
+
if (get_site_option('bp_media_bp_album_importer_base_path') == '') {
|
167 |
+
$base_path = pathinfo($bp_album_item->pic_org_path);
|
168 |
+
update_site_option('bp_media_bp_album_importer_base_path', $base_path['dirname']);
|
169 |
+
}
|
170 |
+
$album_id = BPMediaAlbumimporter::create_album($bp_album_item->owner_id, 'BP Album');
|
171 |
+
$imported_media_id = BPMediaImporter::add_media(
|
172 |
+
$album_id, $bp_album_item->title, $bp_album_item->description, $bp_album_item->pic_org_path, $bp_album_item->privacy, $bp_album_item->owner_id
|
173 |
+
);
|
174 |
+
$wpdb->update($table, array('import_status' => $imported_media_id), array('id' => $bp_album_item->id), array('%d'), array('%d'));
|
175 |
+
BPMediaAlbumimporter::update_recorded_time_and_comments($imported_media_id, $bp_album_item->id, "{$wpdb->base_prefix}bp_album");
|
176 |
+
}
|
177 |
+
|
178 |
+
echo $page;
|
179 |
+
die();
|
180 |
+
}
|
181 |
+
|
182 |
+
static function cleanup_after_install() {
|
183 |
+
global $wpdb;
|
184 |
+
$table = $wpdb->base_prefix . 'bp_album';
|
185 |
+
$dir = get_site_option('bp_media_bp_album_importer_base_path');
|
186 |
+
BPMediaImporter::cleanup($table, $dir);
|
187 |
+
die();
|
188 |
+
}
|
189 |
+
|
190 |
+
static function update_recorded_time_and_comments($media, $bp_album_id, $table) {
|
191 |
+
global $wpdb;
|
192 |
+
if (function_exists('bp_activity_add')) {
|
193 |
+
if (!is_object($media)) {
|
194 |
+
try {
|
195 |
+
$media = new BPMediaHostWordpress($media);
|
196 |
+
} catch (exception $e) {
|
197 |
+
return false;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
$activity_id = get_post_meta($media->get_id(), 'bp_media_child_activity', true);
|
201 |
+
|
202 |
+
if ($activity_id) {
|
203 |
+
$date_uploaded = $wpdb->get_var("SELECT date_uploaded from $table WHERE id = $bp_album_id");
|
204 |
+
$old_activity_id = $wpdb->get_var("SELECT id from {$wpdb->prefix}bp_activity WHERE component = 'album' AND type = 'bp_album_picture' AND item_id = $bp_album_id");
|
205 |
+
$comments = $wpdb->get_results("SELECT id,secondary_item_id from {$wpdb->prefix}bp_activity WHERE component = 'activity' AND type = 'activity_comment' AND item_id = $old_activity_id");
|
206 |
+
foreach ($comments as $comment) {
|
207 |
+
$update = array('item_id' => $activity_id);
|
208 |
+
if ($comment->secondary_item_id == $old_activity_id) {
|
209 |
+
$update['secondary_item_id'] = $activity_id;
|
210 |
+
}
|
211 |
+
$wpdb->update($wpdb->prefix . 'bp_activity', $update, array('id' => $comment->id));
|
212 |
+
BP_Activity_Activity::rebuild_activity_comment_tree($activity_id);
|
213 |
+
}
|
214 |
+
$wpdb->update($wpdb->prefix . 'bp_activity', array('date_recorded' => $date_uploaded), array('id' => $activity_id));
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
?>
|
app/importers/BPMediaImporter.php
CHANGED
@@ -12,104 +12,149 @@
|
|
12 |
*/
|
13 |
class BPMediaImporter {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
var $import_steps;
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
function table_exists($table){
|
27 |
-
global $wpdb;
|
28 |
-
|
29 |
-
if($wpdb->query("SHOW TABLES LIKE '".$table."'")==1){
|
30 |
-
return true;
|
31 |
-
}
|
32 |
|
|
|
33 |
return false;
|
34 |
-
}
|
35 |
-
|
36 |
-
static function _active($path) {
|
37 |
-
if ( ! function_exists( 'is_plugin_inactive' ) ) {
|
38 |
-
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
39 |
-
}
|
40 |
-
global $wpdb;
|
41 |
-
$plugin_name = $path;
|
42 |
-
$is_active = is_plugin_active( $plugin_name );
|
43 |
-
if ( $is_active == true )
|
44 |
-
return 1;
|
45 |
-
$is_inactive = is_plugin_inactive( $plugin_name );
|
46 |
-
if ( $is_inactive == true )
|
47 |
-
return 0;
|
48 |
-
if ( ! $is_active && ! $is_inactive )
|
49 |
-
return -1;
|
50 |
-
}
|
51 |
-
|
52 |
-
static function file_array($filepath){
|
53 |
-
|
54 |
-
$path_info = pathinfo($filepath);
|
55 |
-
|
56 |
-
$file['error'] = '';
|
57 |
-
$file['name'] = $path_info['basename'];
|
58 |
-
$file['type'] = mime_content_type($filepath);
|
59 |
-
$file['tmp_name'] = $filepath;
|
60 |
-
$file['size'] = filesize( $filepath);
|
61 |
-
|
62 |
-
return $file;
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
function create_album($album_name = '',$author_id=1){
|
67 |
-
|
68 |
-
global $bp_media;
|
69 |
-
|
70 |
-
if(array_key_exists('bp_album_import_name',$bp_media->options)){
|
71 |
-
if($bp_media->options['bp_album_import_name']!=''){
|
72 |
-
$album_name = $bp_media->options['bp_album_import_name'];
|
73 |
-
}
|
74 |
-
}
|
75 |
-
$found_album = BuddyPressMedia::get_wall_album();
|
76 |
-
|
77 |
-
if(count($found_album)< 1){
|
78 |
-
$album = new BPMediaAlbum();
|
79 |
-
$album->add_album($album_name,$author_id);
|
80 |
-
$album_id = $album->get_id();
|
81 |
-
}else{
|
82 |
-
$album_id = $found_album[0]->ID;
|
83 |
-
}
|
84 |
-
return $album_id;
|
85 |
-
}
|
86 |
-
|
87 |
-
static function add_media($album_id, $title='',$description='',$filepath='',$privacy=0,$author_id=false){
|
88 |
-
|
89 |
-
|
90 |
-
$files = BPMediaImporter::file_array($filepath);
|
91 |
-
|
92 |
-
|
93 |
-
$bp_imported_media =new BPMediaHostWordpress();
|
94 |
-
|
95 |
-
$imported_media_id = $bp_imported_media->add_media($title, $description, $album_id, 0, false, false, $files);
|
96 |
-
|
97 |
-
wp_update_post($args=array('ID'=>$imported_media_id,'post_author'=> $author_id));
|
98 |
-
|
99 |
-
$bp_album_privacy = $privacy;
|
100 |
-
if($bp_album_privacy == 10)
|
101 |
-
$bp_album_privacy = 6;
|
102 |
-
|
103 |
-
$privacy = new BPMediaPrivacy();
|
104 |
-
$privacy->save($bp_album_privacy,$imported_media_id);
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
function cleanup(){
|
109 |
-
return;
|
110 |
-
|
111 |
-
}
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
}
|
115 |
|
12 |
*/
|
13 |
class BPMediaImporter {
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
var $active;
|
19 |
+
var $import_steps;
|
20 |
|
21 |
+
function __construct() {
|
|
|
22 |
|
23 |
+
}
|
24 |
|
25 |
+
function table_exists($table) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
//for 2.7.6 please remove for 2.8
|
28 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
global $wpdb;
|
31 |
+
|
32 |
+
if ($wpdb->query("SHOW TABLES LIKE '" . $table . "'") == 1) {
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
static function _active($path) {
|
40 |
+
|
41 |
+
//for 2.7.6 please remove for 2.8
|
42 |
+
return -1;
|
43 |
+
|
44 |
+
if (!function_exists('is_plugin_inactive')) {
|
45 |
+
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
46 |
+
}
|
47 |
+
if (is_plugin_active($path))
|
48 |
+
return 1;
|
49 |
+
$plugins = get_plugins();
|
50 |
+
if (array_key_exists($path, $plugins)) {
|
51 |
+
return 0;
|
52 |
+
} else {
|
53 |
+
return -1;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
static function file_array($filepath) {
|
58 |
+
|
59 |
+
$path_info = pathinfo($filepath);
|
60 |
+
|
61 |
+
$file['error'] = '';
|
62 |
+
$file['name'] = $path_info['basename'];
|
63 |
+
$file['type'] = mime_content_type($filepath);
|
64 |
+
$file['tmp_name'] = $filepath;
|
65 |
+
$file['size'] = filesize($filepath);
|
66 |
+
|
67 |
+
return $file;
|
68 |
+
}
|
69 |
+
|
70 |
+
static function make_copy($filepath) {
|
71 |
+
$upload_dir = wp_upload_dir();
|
72 |
+
$path_info = pathinfo($filepath);
|
73 |
+
$tmp_dir = trailingslashit($upload_dir['basedir']) . 'bp-album-importer';
|
74 |
+
$newpath = trailingslashit($tmp_dir) . $path_info['basename'];
|
75 |
+
if (!is_dir($tmp_dir)) {
|
76 |
+
wp_mkdir_p($tmp_dir);
|
77 |
+
}
|
78 |
+
if (copy($filepath, $newpath)) {
|
79 |
+
return BPMediaImporter::file_array($newpath);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
function create_album($album_name = '', $author_id = 1) {
|
84 |
+
|
85 |
+
global $bp_media;
|
86 |
+
|
87 |
+
if (array_key_exists('bp_album_import_name', $bp_media->options)) {
|
88 |
+
if ($bp_media->options['bp_album_import_name'] != '') {
|
89 |
+
$album_name = $bp_media->options['bp_album_import_name'];
|
90 |
+
}
|
91 |
+
}
|
92 |
+
$found_album = BuddyPressMedia::get_wall_album();
|
93 |
+
|
94 |
+
if (count($found_album) < 1) {
|
95 |
+
$album = new BPMediaAlbum();
|
96 |
+
$album->add_album($album_name, $author_id);
|
97 |
+
$album_id = $album->get_id();
|
98 |
+
} else {
|
99 |
+
$album_id = $found_album[0]->ID;
|
100 |
+
}
|
101 |
+
return $album_id;
|
102 |
+
}
|
103 |
+
|
104 |
+
static function add_media($album_id, $title = '', $description = '', $filepath = '', $privacy = 0, $author_id = false) {
|
105 |
+
|
106 |
+
|
107 |
+
$files = BPMediaImporter::make_copy($filepath);
|
108 |
+
if ($files) {
|
109 |
+
|
110 |
+
$bp_imported_media = new BPMediaHostWordpress();
|
111 |
+
// add_filter('bp_media_force_hide_activity', create_function('', 'return true;'));
|
112 |
+
$imported_media_id = $bp_imported_media->add_media($title, $description, $album_id, 0, false, false, $files);
|
113 |
+
|
114 |
+
wp_update_post($args = array('ID' => $imported_media_id, 'post_author' => $author_id));
|
115 |
+
|
116 |
+
$bp_album_privacy = $privacy;
|
117 |
+
if ($bp_album_privacy == 10)
|
118 |
+
$bp_album_privacy = 6;
|
119 |
+
|
120 |
+
$privacy = new BPMediaPrivacy();
|
121 |
+
$privacy->save($bp_album_privacy, $imported_media_id);
|
122 |
+
return $imported_media_id;
|
123 |
+
}
|
124 |
+
return 0;
|
125 |
+
}
|
126 |
+
|
127 |
+
static function cleanup($table, $directory) {
|
128 |
+
global $wpdb;
|
129 |
+
$wpdb->query("DROP TABLE IF EXISTS $table");
|
130 |
+
$wpdb->query(
|
131 |
+
$wpdb->prepare(
|
132 |
+
"
|
133 |
+
DELETE FROM {$wpdb->base_prefix}bp_activity
|
134 |
+
WHERE component = %s
|
135 |
+
", 'album'
|
136 |
+
)
|
137 |
+
);
|
138 |
+
if (is_dir($directory)) {
|
139 |
+
BPMediaImporter::delete($directory);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
static function delete($path) {
|
144 |
+
if (is_dir($path) === true) {
|
145 |
+
$files = array_diff(scandir($path), array('.', '..'));
|
146 |
+
|
147 |
+
foreach ($files as $file) {
|
148 |
+
BPMediaImporter::delete(realpath($path) . '/' . $file);
|
149 |
+
}
|
150 |
+
|
151 |
+
return rmdir($path);
|
152 |
+
} else if (is_file($path) === true) {
|
153 |
+
return unlink($path);
|
154 |
+
}
|
155 |
+
|
156 |
+
return false;
|
157 |
+
}
|
158 |
|
159 |
}
|
160 |
|
app/main/BuddyPressMedia.php
CHANGED
@@ -356,11 +356,12 @@ class BuddyPressMedia {
|
|
356 |
// new BPMediaActivity();
|
357 |
$class_construct = array(
|
358 |
'activity' => false,
|
359 |
-
'filters'
|
360 |
-
'actions'
|
361 |
'function' => false,
|
362 |
-
'privacy'
|
363 |
-
|
|
|
364 |
);
|
365 |
$class_construct = apply_filters('bpmedia_class_construct', $class_construct);
|
366 |
|
356 |
// new BPMediaActivity();
|
357 |
$class_construct = array(
|
358 |
'activity' => false,
|
359 |
+
'filters' => false,
|
360 |
+
'actions' => false,
|
361 |
'function' => false,
|
362 |
+
'privacy' => false,
|
363 |
+
'download' => false,
|
364 |
+
'albumimporter' => false
|
365 |
);
|
366 |
$class_construct = apply_filters('bpmedia_class_construct', $class_construct);
|
367 |
|
app/main/activity/BPMediaActivity.php
CHANGED
@@ -35,7 +35,6 @@ if ( ! class_exists( 'BPMediaActivity' ) ) {
|
|
35 |
|
36 |
public function scripts() {
|
37 |
wp_enqueue_script( 'json2' );
|
38 |
-
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' ), BP_MEDIA_VERSION );
|
39 |
}
|
40 |
|
41 |
public function activity_uploader() {
|
@@ -64,7 +63,7 @@ if ( ! class_exists( 'BPMediaActivity' ) ) {
|
|
64 |
|
65 |
public function get_text( $content ) {
|
66 |
$activity_json = $this->decode( $content );
|
67 |
-
$activity_text = $activity_json[ 'update_txt' ];
|
68 |
return $activity_text;
|
69 |
}
|
70 |
|
35 |
|
36 |
public function scripts() {
|
37 |
wp_enqueue_script( 'json2' );
|
|
|
38 |
}
|
39 |
|
40 |
public function activity_uploader() {
|
63 |
|
64 |
public function get_text( $content ) {
|
65 |
$activity_json = $this->decode( $content );
|
66 |
+
$activity_text = rawurldecode($activity_json[ 'update_txt' ]);
|
67 |
return $activity_text;
|
68 |
}
|
69 |
|
app/main/includes/BPMediaActions.php
CHANGED
@@ -478,7 +478,7 @@ class BPMediaActions {
|
|
478 |
'multi_selection' => true,
|
479 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
480 |
);
|
481 |
-
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'), BP_MEDIA_VERSION);
|
482 |
wp_localize_script('bp-media-activity-uploader', 'bp_media_uploader_params', $params);
|
483 |
wp_localize_script('bp-media-activity-uploader', 'activity_ajax_url', admin_url('admin-ajax.php'));
|
484 |
if (bp_is_active('groups') && bp_get_current_group_id())
|
@@ -503,7 +503,7 @@ class BPMediaActions {
|
|
503 |
'multi_selection' => true,
|
504 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
505 |
);
|
506 |
-
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'), BP_MEDIA_VERSION);
|
507 |
wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
|
508 |
}
|
509 |
}
|
478 |
'multi_selection' => true,
|
479 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
480 |
);
|
481 |
+
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'), BP_MEDIA_VERSION, true);
|
482 |
wp_localize_script('bp-media-activity-uploader', 'bp_media_uploader_params', $params);
|
483 |
wp_localize_script('bp-media-activity-uploader', 'activity_ajax_url', admin_url('admin-ajax.php'));
|
484 |
if (bp_is_active('groups') && bp_get_current_group_id())
|
503 |
'multi_selection' => true,
|
504 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
505 |
);
|
506 |
+
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'), BP_MEDIA_VERSION, true);
|
507 |
wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
|
508 |
}
|
509 |
}
|
app/main/includes/BPMediaFunction.php
CHANGED
@@ -97,12 +97,7 @@ class BPMediaFunction {
|
|
97 |
* @return type
|
98 |
*/
|
99 |
function conditional_override_allowed_tags($content, $activity = null) {
|
100 |
-
|
101 |
-
|
102 |
-
if ($activity != null && in_array($activity->type, $bp_media->activity_types)) {
|
103 |
-
add_filter('bp_activity_allowed_tags', 'BPMediaFunction::override_allowed_tags', 1);
|
104 |
-
}
|
105 |
-
|
106 |
return $content;
|
107 |
}
|
108 |
|
97 |
* @return type
|
98 |
*/
|
99 |
function conditional_override_allowed_tags($content, $activity = null) {
|
100 |
+
add_filter('bp_activity_allowed_tags', 'BPMediaFunction::override_allowed_tags', 1);
|
|
|
|
|
|
|
|
|
|
|
101 |
return $content;
|
102 |
}
|
103 |
|
app/main/includes/BPMediaHostWordpress.php
CHANGED
@@ -2,1018 +2,1025 @@
|
|
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 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
$attachment = array( );
|
139 |
-
$url = $file[ 'url' ];
|
140 |
-
$file = $file[ 'file' ];
|
141 |
-
$title = $name;
|
142 |
-
$content = $description;
|
143 |
-
$attachment = array(
|
144 |
-
'post_mime_type' => $type,
|
145 |
-
'guid' => $url,
|
146 |
-
'post_title' => $title,
|
147 |
-
'post_content' => $content,
|
148 |
-
'post_parent' => $post_id,
|
149 |
-
);
|
150 |
-
switch ( $type ) {
|
151 |
-
case 'video/mp4' :
|
152 |
-
case 'video/quicktime' :
|
153 |
-
$type = 'video';
|
154 |
-
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
155 |
-
try {
|
156 |
-
$getID3 = new getID3;
|
157 |
-
$vid_info = $getID3->analyze( $file );
|
158 |
-
} catch ( Exception $e ) {
|
159 |
-
unlink( $file );
|
160 |
-
$activity_content = false;
|
161 |
-
throw new Exception( __( 'MP4 file you have uploaded is corrupt.', BP_MEDIA_TXT_DOMAIN ) );
|
162 |
-
}
|
163 |
-
if ( is_array( $vid_info ) ) {
|
164 |
-
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' ] ) ) {
|
165 |
-
if ( ! ($vid_info[ 'fileformat' ] == 'mp4' && $vid_info[ 'video' ][ 'fourcc' ] == 'avc1') ) {
|
166 |
-
unlink( $file );
|
167 |
-
$activity_content = false;
|
168 |
-
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 ) );
|
169 |
-
}
|
170 |
-
} else {
|
171 |
-
unlink( $file );
|
172 |
-
$activity_content = false;
|
173 |
-
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 ) );
|
174 |
-
}
|
175 |
-
} else {
|
176 |
-
unlink( $file );
|
177 |
-
$activity_content = false;
|
178 |
-
throw new Exception( __( 'The MP4 file you have uploaded is not a video file.', BP_MEDIA_TXT_DOMAIN ) );
|
179 |
-
}
|
180 |
-
break;
|
181 |
-
case 'audio/mpeg' :
|
182 |
-
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
183 |
-
try {
|
184 |
-
$getID3 = new getID3;
|
185 |
-
$file_info = $getID3->analyze( $file );
|
186 |
-
} catch ( Exception $e ) {
|
187 |
-
unlink( $file );
|
188 |
-
$activity_content = false;
|
189 |
-
throw new Exception( __( 'MP3 file you have uploaded is currupt.', BP_MEDIA_TXT_DOMAIN ) );
|
190 |
-
}
|
191 |
-
if ( is_array( $file_info ) ) {
|
192 |
-
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' ] ) ) {
|
193 |
-
if ( ! ($file_info[ 'fileformat' ] == 'mp3' && $file_info[ 'audio' ][ 'dataformat' ] == 'mp3') ) {
|
194 |
-
unlink( $file );
|
195 |
-
$activity_content = false;
|
196 |
-
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
197 |
-
}
|
198 |
-
} else {
|
199 |
-
unlink( $file );
|
200 |
-
$activity_content = false;
|
201 |
-
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
202 |
-
}
|
203 |
-
} else {
|
204 |
-
unlink( $file );
|
205 |
-
$activity_content = false;
|
206 |
-
throw new Exception( __( 'The MP3 file you have uploaded is not an audio file.', BP_MEDIA_TXT_DOMAIN ) );
|
207 |
-
}
|
208 |
-
$type = 'audio';
|
209 |
-
break;
|
210 |
-
case 'image/gif' :
|
211 |
-
case 'image/jpeg' :
|
212 |
-
case 'image/png' :
|
213 |
-
$type = 'image';
|
214 |
-
break;
|
215 |
-
default :
|
216 |
-
unlink( $file );
|
217 |
-
$activity_content = false;
|
218 |
-
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 ) );
|
219 |
-
}
|
220 |
-
echo $attachment_id = wp_insert_attachment( $attachment, $file, $post_id );
|
221 |
-
if ( ! is_wp_error( $attachment_id ) ) {
|
222 |
-
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
|
223 |
-
} else {
|
224 |
-
unlink( $file );
|
225 |
-
throw new Exception( __( 'Error creating attachment for the media file, please try again', BP_MEDIA_TXT_DOMAIN ) );
|
226 |
-
}
|
227 |
-
$this->id = $attachment_id;
|
228 |
-
$this->name = $name;
|
229 |
-
$this->description = $description;
|
230 |
-
$this->type = $type;
|
231 |
-
$this->owner = get_current_user_id();
|
232 |
-
$this->album_id = $post_id;
|
233 |
-
$this->group_id = $group;
|
234 |
-
$this->set_permalinks();
|
235 |
-
if ( $group == 0 ) {
|
236 |
-
update_post_meta( $attachment_id, 'bp-media-key', get_current_user_id() );
|
237 |
-
} else {
|
238 |
-
update_post_meta( $attachment_id, 'bp-media-key', (-$group ) );
|
239 |
-
}
|
240 |
-
do_action( 'bp_media_after_add_media', $this, $is_multiple, $is_activity, $group );
|
241 |
-
return $attachment_id;
|
242 |
-
}
|
243 |
-
|
244 |
-
function get_media_thumbnail( $size = 'thumbnail' ) {
|
245 |
-
$thumb = '';
|
246 |
-
if ( in_array( $this->type, array( 'image', 'video', 'audio' ) ) ) {
|
247 |
-
if ( $this->thumbnail_id ) {
|
248 |
-
$medium_array = image_downsize( $this->thumbnail_id, $size );
|
249 |
-
$thumb_url = $medium_array[ 0 ];
|
250 |
-
} else {
|
251 |
-
$thumb_url = BP_MEDIA_URL . 'app/assets/img/' . $this->type . '_thumb.png';
|
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 |
-
|