From 807abaa8180cd50922ebdec09d8c71927f116ec8 Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 11:12:28 +0530 Subject: [PATCH 01/12] more changes for media type disabling --- app/main/BPMediaGroupLoader.php | 15 ++++++++++++++- app/main/BuddyPressMedia.php | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/main/BPMediaGroupLoader.php b/app/main/BPMediaGroupLoader.php index 822f102a6..d99891f95 100755 --- a/app/main/BPMediaGroupLoader.php +++ b/app/main/BPMediaGroupLoader.php @@ -20,11 +20,18 @@ class BPMediaGroupLoader { * */ function __construct() { + global $bp_media; + $enabled = $bp_media->enabled(); + + if (class_exists('BPMediaGroupsExtension')) : bp_register_group_extension('BPMediaGroupsExtension'); + if($enabled['images']) new BPMediaGroupImage (); new BPMediaGroupAlbum(); + if($enabled['audio']) new BPMediaGroupMusic(); + if($enabled['videos']) new BPMediaGroupVideo(); new BPMediaGroupUpload(); endif; @@ -73,6 +80,7 @@ function custom_nav() { } switch ($bp->current_action) { case BP_MEDIA_IMAGES_SLUG: + case BP_MEDIA_VIDEOS_SLUG: case BP_MEDIA_AUDIO_SLUG: case BP_MEDIA_ALBUMS_SLUG: @@ -130,7 +138,9 @@ function multipart_params_handler($multipart_params) { * @return boolean */ static function navigation_menu() { - global $bp; + global $bp,$bp_media; + $enabled = $bp_media->enabled(); + if (!isset($bp->current_action) || $bp->current_action != BP_MEDIA_SLUG) return false; $bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG); @@ -142,6 +152,7 @@ static function navigation_menu() { } // if (BPMediaGroup::can_upload()) { + $bp_media_nav[BP_MEDIA_IMAGES_SLUG] = array( 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . BP_MEDIA_SLUG, 'label' => BP_MEDIA_IMAGES_LABEL, @@ -162,10 +173,12 @@ static function navigation_menu() { ); } } else { + if($enabled[strtolower($type)]){ $bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array( 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'), 'label' => constant('BP_MEDIA_' . $type . '_LABEL'), ); + } } } diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index f675e6558..1e779af66 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -529,6 +529,33 @@ function widgets_init() { register_widget('BPMediaWidget'); } + /** + * + */ + function enabled(){ + $options = $this->options; + $enabled= array( + 'images' => false, + 'videos' => false, + 'audio' => false, + 'albums' => true + ); + if( array_key_exists( 'images_enabled', $options )){ + if($options['images_enabled']==1 ) + $enabled['images']=true; + } + if( array_key_exists( 'videos_enabled', $options )){ + if($options['videos_enabled']==1 ) + $enabled['video']=true; + } + if( array_key_exists( 'audio_enabled', $options )){ + if($options['audio_enabled']==1 ) + $enabled['audio']=true; + } + + return $enabled; + } + } From 8a00fc145e2335013058aee9ce9f6b0f3be677d6 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Wed, 13 Feb 2013 11:24:14 +0530 Subject: [PATCH 02/12] Repositioned the album selection dropdown & refactored the uploader ui --- app/assets/css/main.css | 40 ++++++++-- app/assets/img/pixel-bg.png | Bin 0 -> 950 bytes app/assets/js/bp-media-uploader.js | 13 +++- app/main/profile/BPMediaTemplate.php | 110 ++++++++++++++------------- 4 files changed, 100 insertions(+), 63 deletions(-) create mode 100644 app/assets/img/pixel-bg.png diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 1deb5da39..a4c8c4f4f 100755 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -34,9 +34,38 @@ div.bp_media_title{margin-bottom:10px;} .bp-media-rss{background-position: 35px 0px;} .bp-media-rss:hover{background-position: 35px 36px;} /*#bp-media-upload-ui{position: relative;}*/ +#item-body:after,ul.bp-media-gallery.item-list:after{content: " ";clear: both;display: block;text-indent: -9999em;} +#item-body{position: relative;} +.bp-media-area-allocate{height: 10px;width: 100%;display: block;} +li #bp-media-upload-ui {padding: 0;max-width: 158px;} +#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;min-height: 140px;text-align: center;background: url('../img/drag-drop-bg.png') repeat scroll 0 0 transparent;overflow: hidden;} +li #bp-media-upload-ui #drag-drop-area{width: 100%;max-width: 150px;min-height: 150px;} +#bp-media-upload-ui .drag-drop-space{margin: 18px auto 0;max-width: 400px;overflow: hidden;} +#bp-media-upload-ui .drag-drop-inside{float: left;margin: 0 auto 15px;width: 47%;} +.albums #bp-media-upload-ui .drag-drop-inside{float: none;width: auto;} +li #bp-media-upload-ui .drag-drop-inside,li #bp-media-upload-ui #bp-media-album-prompt{float: none;margin: 0 auto 15px;max-width: 100%;width: auto;} +li #bp-media-upload-ui #bp-media-album-prompt{margin: 12px auto 0;max-width: 144px;} +#bp-media-upload-ui #bp-media-album-prompt{float: right;margin: 12px auto 0;width: 45%;} +#bp-media-upload-ui .drag-drop-inside p.drag-drop-info{font-size: 20px;line-height: 100%;} + +#bp-media-upload-ui .drag-drop-buttons input,#bp-media-album-prompt input.button{-moz-box-sizing: content-box;border-color: #BBBBBB;border-radius: 15px;border-style: solid;border-width: 1px;color: #464646;cursor: pointer;font-size: 13px !important;line-height: 13px;padding: 5px 10px;text-decoration: none;} +#bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px 4px;text-decoration: none;} +#bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;} +li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: none;} +li #bp-media-upload-ui .drag-drop-space p.drag-drop-buttons{display: block;} +#bp-media-album-prompt div.hide{display: none;margin: 0;} +#bp-media-album-prompt > p{font-size: 20px;} +#bp-media-upload-ui .drag-drop-inside p,#bp-media-album-prompt #bp_media_album_new{margin-bottom: 12px;font-size: 14px;} +#bp-media-album-prompt #bp_media_album_new{max-width: 90%;} +li #bp-media-album-prompt #bp_media_album_new{margin: 0 0 5px;max-width: 134px;width: 94%;} +#bp-media-upload-ui .drag-drop-to{width: 22px;line-height: 22px;margin: 40px auto 0;float: left;} +li #bp-media-upload-ui .drag-drop-to{width: 100%;line-height: 22px;margin: 0;float: none;} +#bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: left;font-size: 14px;line-height: 22px;margin: 30px auto 0;width: 22px;} +li #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: none;font-size: 14px;line-height: 22px;margin: 0 auto;width: 22px;} +#bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;} -#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 150px;width: 150px;} +/*#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 150px;width: 150px;} .upload #bp-media-upload-ui #drag-drop-area{height: auto; width: 100%;} #bp-media-upload-ui .drag-drop-inside{margin:auto;width: 100%;} #bp-media-album-prompt{margin: 0;position: absolute;right: 0;text-align: right;top: 2px;min-width: 200px;} @@ -48,13 +77,12 @@ div.bp_media_title{margin-bottom:10px;} #bp-media-album-prompt input.button{height: 25px;margin-left: 5px;padding: 0 10px;position: relative;top: -1px;} div.bp-media-area-allocate{display: block;height: 15px;} div.bp_media_create_album{text-align: right} -#bp_media_album_name{margin-bottom: 6px;} -#item-body:after,ul.bp-media-gallery.item-list:after{content: " ";clear: both;display: block;text-indent: -9999em;} -#item-body{position: relative;} +#bp_media_album_name{margin-bottom: 6px;}*/ -#bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 12px 0;} +/*#bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 12px 0;} #bp-media-upload-ui .drag-drop-info{font-size: 20px;} -#bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;color: #464646;text-decoration: none;font-size: 12px!important;line-height: 13px;padding: 3px 8px;cursor: pointer;border-width: 1px;border-style: solid;-webkit-border-radius: 11px;border-radius: 11px;-moz-box-sizing: content-box;-webkit-box-sizing: content-box;box-sizing: content-box;} +#bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;color: #464646;text-decoration: none;font-size: 12px!important;line-height: 13px;padding: 3px 8px;cursor: pointer;border-width: 1px;border-style: solid;-webkit-border-radius: 11px;border-radius: 11px;-moz-box-sizing: content-box;-webkit-box-sizing: content-box;box-sizing: content-box;}*/ + #bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;left: 0;margin-top: 5px;position: absolute;top: 155px;width: 100%;} #bp-media-uploaded-files .error{padding: 5px;text-align: center;} .bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)} diff --git a/app/assets/img/pixel-bg.png b/app/assets/img/pixel-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..0899e16ed9cfbecb23aebcdea9b83616e57ce64f GIT binary patch literal 950 zcmaJ=zi-n(7`4biRS~HZ5}i(NCq#UA&M$1mL~WeVRCN@RNDUH09s814iG9YtU?&sm z)(uwv2E@Y1z{0}ZjSXfb7KFr9&S{)75G?tA>Am;8@4N3V+O5ag?cHrb5VFl9y~F37 z#~x^`9nU`uv{!ZEYwo2POX_sJeG3p z8*Y9hH)#de=aF?1I4_9Z2&fB|DXY$AFKDCQifeE7f;Vy@Hv^N4{p+IBBi=p9a^1Fk zvu=Fi@oo=zTi@=#e9xc6{ic4'+new_album_name+''); jQuery('#bp-media-album-prompt div.hide').hide(); jQuery('#bp-media-album-prompt select').show(); - jQuery('#bp-media-album-prompt span').show(); + if ( in_list == 0 ) { + jQuery('#bp-media-album-prompt p').show(); + } } }); } @@ -289,7 +295,8 @@ jQuery(document).ready(function(){ jQuery('#bp-media-album-prompt select option').removeAttr('selected'); jQuery('#bp-media-album-prompt select option[value=' + selected + ']').attr('selected', 'selected'); jQuery('#bp-media-album-prompt select').show(); - jQuery('#bp-media-album-prompt span').show(); + if ( in_list == 0 ) + jQuery('#bp-media-album-prompt p').show(); }); //Normal Uplaoder diff --git a/app/main/profile/BPMediaTemplate.php b/app/main/profile/BPMediaTemplate.php index 7370c30d7..e742e66db 100755 --- a/app/main/profile/BPMediaTemplate.php +++ b/app/main/profile/BPMediaTemplate.php @@ -17,67 +17,69 @@ class BPMediaTemplate { */ function upload_form_multiple() { global $bp_media_current_album; - $post_wall = __('Wall Posts', BP_MEDIA_TXT_DOMAIN); - if (!isset($bp_media_current_album)) { - ?> -
- -
- -
-
- - - -
-
- - + $post_wall = __('Wall Posts', BP_MEDIA_TXT_DOMAIN); ?>
+

-

+

+
+ +
+
+

+
+ +
+
+ + + +
+
+ + +
+
-
Date: Wed, 13 Feb 2013 11:38:22 +0530 Subject: [PATCH 03/12] adding more refined tabs --- app/main/BPMediaComponent.php | 26 +++++-------------- app/main/BPMediaGroupLoader.php | 8 +++--- app/main/BuddyPressMedia.php | 3 ++- ...aGroupAlbum.php => BPMediaGroupAlbums.php} | 4 +-- ...iaGroupMusic.php => BPMediaGroupAudio.php} | 4 +-- ...aGroupImage.php => BPMediaGroupImages.php} | 4 +-- ...aGroupVideo.php => BPMediaGroupVideos.php} | 4 +-- 7 files changed, 21 insertions(+), 32 deletions(-) rename app/main/group/dummy/{BPMediaGroupAlbum.php => BPMediaGroupAlbums.php} (66%) rename app/main/group/dummy/{BPMediaGroupMusic.php => BPMediaGroupAudio.php} (66%) rename app/main/group/dummy/{BPMediaGroupImage.php => BPMediaGroupImages.php} (66%) mode change 100755 => 100644 rename app/main/group/dummy/{BPMediaGroupVideo.php => BPMediaGroupVideos.php} (66%) diff --git a/app/main/BPMediaComponent.php b/app/main/BPMediaComponent.php index 03cd3faa3..081cb962c 100755 --- a/app/main/BPMediaComponent.php +++ b/app/main/BPMediaComponent.php @@ -70,30 +70,18 @@ function setup_globals() { function setup_nav() { global $bp, $bp_media; - $enabled= array( - 'images' => false, - 'videos' => false, - 'audio' => false, - ); + $enabled = $bp_media->enabled(); /* Upload Screen */ - $bp_media_upload = new BPMediaUploadScreen( + + foreach ($enabled as $active){ + $bp_media_upload = new BPMediaUploadScreen( 'upload', BP_MEDIA_UPLOAD_SLUG ); - $options = $bp_media->options; - - if( array_key_exists( 'images_enabled', $options ) - && $options['images_enabled']==1 ){ - $enabled['images']=true; - } - if( array_key_exists( 'videos_enabled', $options ) - && $options['videos_enabled']==1 ){ - $enabled['videos']=true; - } - if( array_key_exists( 'audio_enabled', $options ) - && $options['audio_enabled']==1 ){ - $enabled['audio']=true; } + + $enabled = $bp_media->enabled(); + /* Media Screens */ if($enabled['images']){ diff --git a/app/main/BPMediaGroupLoader.php b/app/main/BPMediaGroupLoader.php index d99891f95..db865a2e2 100755 --- a/app/main/BPMediaGroupLoader.php +++ b/app/main/BPMediaGroupLoader.php @@ -27,12 +27,12 @@ function __construct() { if (class_exists('BPMediaGroupsExtension')) : bp_register_group_extension('BPMediaGroupsExtension'); if($enabled['images']) - new BPMediaGroupImage (); - new BPMediaGroupAlbum(); + new BPMediaGroupImages (); + new BPMediaGroupAlbums(); if($enabled['audio']) - new BPMediaGroupMusic(); + new BPMediaGroupAudio(); if($enabled['videos']) - new BPMediaGroupVideo(); + new BPMediaGroupVideos(); new BPMediaGroupUpload(); endif; add_action('bp_actions', array($this, 'custom_nav'), 999); diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index 1e779af66..3325dc958 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -538,7 +538,8 @@ function enabled(){ 'images' => false, 'videos' => false, 'audio' => false, - 'albums' => true + 'albums' => true, + 'upload' => true ); if( array_key_exists( 'images_enabled', $options )){ if($options['images_enabled']==1 ) diff --git a/app/main/group/dummy/BPMediaGroupAlbum.php b/app/main/group/dummy/BPMediaGroupAlbums.php similarity index 66% rename from app/main/group/dummy/BPMediaGroupAlbum.php rename to app/main/group/dummy/BPMediaGroupAlbums.php index 8363819cf..6df44ed02 100755 --- a/app/main/group/dummy/BPMediaGroupAlbum.php +++ b/app/main/group/dummy/BPMediaGroupAlbums.php @@ -7,11 +7,11 @@ */ if (class_exists('BP_Group_Extension')) : - class BPMediaGroupAlbum extends BPMediaGroupElementExtension { + class BPMediaGroupAlbums extends BPMediaGroupElementExtension { function __construct() { parent::__construct(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_ALBUMS_SLUG); - bp_register_group_extension("BPMediaGroupAlbum"); + bp_register_group_extension("BPMediaGroupAlbums"); } } diff --git a/app/main/group/dummy/BPMediaGroupMusic.php b/app/main/group/dummy/BPMediaGroupAudio.php similarity index 66% rename from app/main/group/dummy/BPMediaGroupMusic.php rename to app/main/group/dummy/BPMediaGroupAudio.php index 5b207614e..99dd336b6 100755 --- a/app/main/group/dummy/BPMediaGroupMusic.php +++ b/app/main/group/dummy/BPMediaGroupAudio.php @@ -5,11 +5,11 @@ * @author faishal */ if ( class_exists( 'BP_Group_Extension' ) ) : -class BPMediaGroupMusic extends BPMediaGroupElementExtension { +class BPMediaGroupAudio extends BPMediaGroupElementExtension { function __construct() { parent::__construct(BP_MEDIA_AUDIO_LABEL, BP_MEDIA_AUDIO_SLUG); - bp_register_group_extension("BPMediaGroupMusic"); + bp_register_group_extension("BPMediaGroupAudio"); } } diff --git a/app/main/group/dummy/BPMediaGroupImage.php b/app/main/group/dummy/BPMediaGroupImages.php old mode 100755 new mode 100644 similarity index 66% rename from app/main/group/dummy/BPMediaGroupImage.php rename to app/main/group/dummy/BPMediaGroupImages.php index 43f579962..d129f8114 --- a/app/main/group/dummy/BPMediaGroupImage.php +++ b/app/main/group/dummy/BPMediaGroupImages.php @@ -5,11 +5,11 @@ * @author faishal */ if ( class_exists( 'BP_Group_Extension' ) ) : -class BPMediaGroupImage extends BPMediaGroupElementExtension { +class BPMediaGroupImages extends BPMediaGroupElementExtension { function __construct() { parent::__construct(BP_MEDIA_IMAGES_LABEL, BP_MEDIA_IMAGES_SLUG); - bp_register_group_extension("BPMediaGroupImage"); + bp_register_group_extension("BPMediaGroupImages"); } } diff --git a/app/main/group/dummy/BPMediaGroupVideo.php b/app/main/group/dummy/BPMediaGroupVideos.php similarity index 66% rename from app/main/group/dummy/BPMediaGroupVideo.php rename to app/main/group/dummy/BPMediaGroupVideos.php index fb36c1e21..dd48e09c2 100755 --- a/app/main/group/dummy/BPMediaGroupVideo.php +++ b/app/main/group/dummy/BPMediaGroupVideos.php @@ -5,11 +5,11 @@ * @author faishal */ if ( class_exists( 'BP_Group_Extension' ) ) : -class BPMediaGroupVideo extends BPMediaGroupElementExtension { +class BPMediaGroupVideos extends BPMediaGroupElementExtension { function __construct() { parent::__construct(BP_MEDIA_VIDEOS_LABEL, BP_MEDIA_VIDEOS_SLUG); - bp_register_group_extension("BPMediaGroupVideo"); + bp_register_group_extension("BPMediaGroupVideos"); } } From 9b22778be4a3d0026f3afddaea104872522d2d67 Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 12:21:03 +0530 Subject: [PATCH 04/12] Added duplicate wall posts album merge --- app/assets/js/bp-media-uploader.js | 13 +- app/importers/BPMediaImporter.php | 4 +- app/main/BuddyPressMedia.php | 1042 ++++++++++++++-------------- index.php | 1 + 4 files changed, 545 insertions(+), 515 deletions(-) diff --git a/app/assets/js/bp-media-uploader.js b/app/assets/js/bp-media-uploader.js index 1213a5acd..60de7b482 100755 --- a/app/assets/js/bp-media-uploader.js +++ b/app/assets/js/bp-media-uploader.js @@ -238,12 +238,8 @@ jQuery(document).ready(function(){ } var selected = jQuery('#bp-media-album-prompt select').val(); - var in_list = 0; if(jQuery('#'+bp_media_uploader_params.container).length==0) return false; - if ( jQuery('#bp-media-album-prompt p').css('display') == 'none' ) { - in_list = 1; - } jQuery('#bp-media-album-prompt select').change(function() { if ( jQuery(this).val() == 'create_new' ) { @@ -251,7 +247,7 @@ jQuery(document).ready(function(){ 'width':jQuery('#bp-media-album-prompt select').width()+20 }); jQuery('#bp-media-album-prompt select').hide(); - jQuery('#bp-media-album-prompt p').hide(); + jQuery('#bp-media-album-prompt span').hide(); jQuery('#bp-media-album-prompt div.hide').show(); } else selected = jQuery(this).val(); @@ -283,9 +279,7 @@ jQuery(document).ready(function(){ jQuery('#bp-media-selected-album').prepend(''); jQuery('#bp-media-album-prompt div.hide').hide(); jQuery('#bp-media-album-prompt select').show(); - if ( in_list == 0 ) { - jQuery('#bp-media-album-prompt p').show(); - } + jQuery('#bp-media-album-prompt span').show(); } }); } @@ -295,8 +289,7 @@ jQuery(document).ready(function(){ jQuery('#bp-media-album-prompt select option').removeAttr('selected'); jQuery('#bp-media-album-prompt select option[value=' + selected + ']').attr('selected', 'selected'); jQuery('#bp-media-album-prompt select').show(); - if ( in_list == 0 ) - jQuery('#bp-media-album-prompt p').show(); + jQuery('#bp-media-album-prompt span').show(); }); //Normal Uplaoder diff --git a/app/importers/BPMediaImporter.php b/app/importers/BPMediaImporter.php index ca048c6e4..a5a50793c 100755 --- a/app/importers/BPMediaImporter.php +++ b/app/importers/BPMediaImporter.php @@ -65,14 +65,14 @@ static function file_array($filepath){ function create_album($album_name = '',$author_id=1){ - global $bp_media,$wpdb; + global $bp_media; if(array_key_exists('bp_album_import_name',$bp_media->options)){ if($bp_media->options['bp_album_import_name']!=''){ $album_name = $bp_media->options['bp_album_import_name']; } } - $found_album = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}posts WHERE post_title='Wall Posts' AND post_type='bp_media_album'"); + $found_album = BuddyPressMedia::get_wall_album(); if(count($found_album)< 1){ $album = new BPMediaAlbum(); diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index 3325dc958..bcfc49da7 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -3,8 +3,8 @@ /** * Don't load this file directly! */ -if (!defined('ABSPATH')) - exit; +if ( ! defined( 'ABSPATH' ) ) + exit; /** * BuddyPress Media @@ -20,544 +20,580 @@ */ class BuddyPressMedia { - /** - * - * @var string The text domain for loading translations - */ - public $text_domain = 'buddypress-media'; - - /** - * - * @var array BuddyPress Media settings - */ - public $options = array(); - - /** - * - * @var string Email address the admin support form should send to - */ - public $support_email = 'support@rtcamp.com'; - - /** - * - * @var string Support forum url - */ - public $support_url = 'http://rtcamp.com/support/forum/buddypress-media/'; - - /** - * - * @var object/array The query that fetches media (photos, video and audio) - */ - public $query; - - /** - * - * @var object/array The query that fetches albums - */ - public $albums_query; - - /** - * - * @var int Count - */ - public $count = null; - - /** - * - * @var int Number of media items to show in one view. - */ - public $posts_per_page = 10; - - /** - * - * @var array The types of activity BuddyPress Media creates - */ - public $activity_types = array( - 'media_upload', - 'album_updated', - 'album_created' - ); - - /** - * - * @var array A cache for activities that are hidden by BuddyPress Media - */ - public $hidden_activity_cache = array(); - - /** - * - * @var type - */ - public $loader; - - /** - * - * @var type - */ - public $group_loader; - - /** - * Constructs the class - * Defines constants and excerpt lengths, initiates admin notices, - * loads and initiates the plugin, loads translations. - * Initialises media counter - * - * @global int $bp_media_counter Media counter - */ - public function __construct() { - /** - * Define constants - */ - $this->constants(); - /** - * Define excerpt lengths - */ - $this->excerpt_lengths(); - /** - * Add admin notice for BuddyPress dependance - */ - add_action('admin_notices', array($this, 'bp_exists')); - /** - * Activate the plugin! - */ - register_activation_hook(__FILE__, array($this, 'activate')); - - /** - * Hook it to BuddyPress - */ - add_action('bp_include', array($this, 'init')); - /** - * Add the widget - */ - add_action('widgets_init', array($this, 'widgets_init'), 1); - /** - * Load translations - */ - add_action('plugins_loaded', array($this, 'load_translation')); - /** - * Initialise media counter - */ - global $bp_media_counter; - $bp_media_counter = 0; - } - - /** - * Checks if BuddyPress is installed! - */ - public function bp_exists() { - if (!class_exists('BuddyPress')) { - echo '
+ /** + * + * @var string The text domain for loading translations + */ + public $text_domain = 'buddypress-media'; + + /** + * + * @var array BuddyPress Media settings + */ + public $options = array( ); + + /** + * + * @var string Email address the admin support form should send to + */ + public $support_email = 'support@rtcamp.com'; + + /** + * + * @var string Support forum url + */ + public $support_url = 'http://rtcamp.com/support/forum/buddypress-media/'; + + /** + * + * @var object/array The query that fetches media (photos, video and audio) + */ + public $query; + + /** + * + * @var object/array The query that fetches albums + */ + public $albums_query; + + /** + * + * @var int Count + */ + public $count = null; + + /** + * + * @var int Number of media items to show in one view. + */ + public $posts_per_page = 10; + + /** + * + * @var array The types of activity BuddyPress Media creates + */ + public $activity_types = array( + 'media_upload', + 'album_updated', + 'album_created' + ); + + /** + * + * @var array A cache for activities that are hidden by BuddyPress Media + */ + public $hidden_activity_cache = array( ); + + /** + * + * @var type + */ + public $loader; + + /** + * + * @var type + */ + public $group_loader; + + /** + * Constructs the class + * Defines constants and excerpt lengths, initiates admin notices, + * loads and initiates the plugin, loads translations. + * Initialises media counter + * + * @global int $bp_media_counter Media counter + */ + public function __construct() { + /** + * Define constants + */ + $this->constants(); + /** + * Define excerpt lengths + */ + $this->excerpt_lengths(); + /** + * Add admin notice for BuddyPress dependance + */ + add_action( 'admin_notices', array( $this, 'bp_exists' ) ); + /** + * Activate the plugin! + */ + register_activation_hook( __FILE__, array( $this, 'activate' ) ); + + /** + * Hook it to BuddyPress + */ + add_action( 'bp_include', array( $this, 'init' ) ); + /** + * Add the widget + */ + add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 ); + /** + * Load translations + */ + add_action( 'plugins_loaded', array( $this, 'load_translation' ) ); + /** + * Initialise media counter + */ + global $bp_media_counter; + $bp_media_counter = 0; + } + + /** + * Checks if BuddyPress is installed! + */ + public function bp_exists() { + if ( ! class_exists( 'BuddyPress' ) ) { + echo '

' . __( - 'BuddyPress is not installed.', $this->text_domain - ) - . '

+ 'BuddyPress is not installed.', $this->text_domain + ) + . '

' - . sprintf( - __( - 'To use BuddyPress Media, + . sprintf( + __( + 'To use BuddyPress Media, BuddyPress must be installed first.', $this->text_domain - ), 'http://wordpress.org/extend/plugins/buddypress/' - ) - . '

+ ), 'http://wordpress.org/extend/plugins/buddypress/' + ) + . '

'; - } - } + } + } + + /** + * Populates $options with saved settings + */ + public function get_option() { + $this->options = bp_get_option( 'bp_media_options' ); + } + + /** + * Defines all the constants if undefined. Can be overridden by + * defining them elsewhere, say wp-config.php + */ + public function constants() { + /* Text domain */ + if ( ! defined( 'BP_MEDIA_TXT_DOMAIN' ) ) + define( 'BP_MEDIA_TXT_DOMAIN', $this->text_domain ); + + /* If the plugin is installed. */ + if ( ! defined( 'BP_MEDIA_IS_INSTALLED' ) ) + define( 'BP_MEDIA_IS_INSTALLED', 1 ); + + /* Current Version. */ + if ( ! defined( 'BP_MEDIA_VERSION' ) ) + define( 'BP_MEDIA_VERSION', '2.4' ); + + /* Required Version */ + if ( ! defined( 'BP_MEDIA_REQUIRED_BP' ) ) + define( 'BP_MEDIA_REQUIRED_BP', '1.6.2' ); + + /* Database Version */ + if ( ! defined( 'BP_MEDIA_DB_VERSION' ) ) + define( 'BP_MEDIA_DB_VERSION', '2.1' ); + + /* Slug Constants for building urls */ + + /* Media slug */ + if ( ! defined( 'BP_MEDIA_SLUG' ) ) + define( 'BP_MEDIA_SLUG', 'media' ); + + /* Upload slug */ + if ( ! defined( 'BP_MEDIA_UPLOAD_SLUG' ) ) + define( 'BP_MEDIA_UPLOAD_SLUG', 'upload' ); + + /* Delete slug */ + if ( ! defined( 'BP_MEDIA_DELETE_SLUG' ) ) + define( 'BP_MEDIA_DELETE_SLUG', 'delete' ); + + /* Photos slug */ + if ( ! defined( 'BP_MEDIA_IMAGES_SLUG' ) ) + define( 'BP_MEDIA_IMAGES_SLUG', 'photos' ); + + if ( ! defined( 'BP_MEDIA_IMAGES_ENTRY_SLUG' ) ) + define( 'BP_MEDIA_IMAGES_ENTRY_SLUG', 'view' ); + + if ( ! defined( 'BP_MEDIA_IMAGES_EDIT_SLUG' ) ) + define( 'BP_MEDIA_IMAGES_EDIT_SLUG', 'edit' ); - /** - * Populates $options with saved settings - */ - public function get_option() { - $this->options = bp_get_option('bp_media_options'); - } + /* Videos slug */ + if ( ! defined( 'BP_MEDIA_VIDEOS_SLUG' ) ) + define( 'BP_MEDIA_VIDEOS_SLUG', 'videos' ); - /** - * Defines all the constants if undefined. Can be overridden by - * defining them elsewhere, say wp-config.php - */ - public function constants() { - /* Text domain */ - if (!defined('BP_MEDIA_TXT_DOMAIN')) - define('BP_MEDIA_TXT_DOMAIN', $this->text_domain); + if ( ! defined( 'BP_MEDIA_VIDEOS_ENTRY_SLUG' ) ) + define( 'BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch' ); - /* If the plugin is installed. */ - if (!defined('BP_MEDIA_IS_INSTALLED')) - define('BP_MEDIA_IS_INSTALLED', 1); + if ( ! defined( 'BP_MEDIA_VIDEOS_EDIT_SLUG' ) ) + define( 'BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit' ); - /* Current Version. */ - if (!defined('BP_MEDIA_VERSION')) - define('BP_MEDIA_VERSION', '2.4'); + /* Audio slug */ + if ( ! defined( 'BP_MEDIA_AUDIO_SLUG' ) ) + define( 'BP_MEDIA_AUDIO_SLUG', 'music' ); - /* Required Version */ - if (!defined('BP_MEDIA_REQUIRED_BP')) - define('BP_MEDIA_REQUIRED_BP', '1.6.2'); + if ( ! defined( 'BP_MEDIA_AUDIO_ENTRY_SLUG' ) ) + define( 'BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen' ); - /* Database Version */ - if (!defined('BP_MEDIA_DB_VERSION')) - define('BP_MEDIA_DB_VERSION', '2.1'); + if ( ! defined( 'BP_MEDIA_AUDIO_EDIT_SLUG' ) ) + define( 'BP_MEDIA_AUDIO_EDIT_SLUG', 'edit' ); - /* Slug Constants for building urls */ + /* Albums slug */ + if ( ! defined( 'BP_MEDIA_ALBUMS_SLUG' ) ) + define( 'BP_MEDIA_ALBUMS_SLUG', 'albums' ); - /* Media slug */ - if (!defined('BP_MEDIA_SLUG')) - define('BP_MEDIA_SLUG', 'media'); + if ( ! defined( 'BP_MEDIA_ALBUMS_ENTRY_SLUG' ) ) + define( 'BP_MEDIA_ALBUMS_ENTRY_SLUG', 'list' ); - /* Upload slug */ - if (!defined('BP_MEDIA_UPLOAD_SLUG')) - define('BP_MEDIA_UPLOAD_SLUG', 'upload'); + if ( ! defined( 'BP_MEDIA_ALBUMS_EDIT_SLUG' ) ) + define( 'BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit' ); - /* Delete slug */ - if (!defined('BP_MEDIA_DELETE_SLUG')) - define('BP_MEDIA_DELETE_SLUG', 'delete'); + /* UI Labels loaded via text domain, can be translated */ + if ( ! defined( 'BP_MEDIA_LABEL' ) ) + define( 'BP_MEDIA_LABEL', __( 'Media', $this->text_domain ) ); - /* Photos slug */ - if (!defined('BP_MEDIA_IMAGES_SLUG')) - define('BP_MEDIA_IMAGES_SLUG', 'photos'); - - if (!defined('BP_MEDIA_IMAGES_ENTRY_SLUG')) - define('BP_MEDIA_IMAGES_ENTRY_SLUG', 'view'); - - if (!defined('BP_MEDIA_IMAGES_EDIT_SLUG')) - define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit'); - - /* Videos slug */ - if (!defined('BP_MEDIA_VIDEOS_SLUG')) - define('BP_MEDIA_VIDEOS_SLUG', 'videos'); - - if (!defined('BP_MEDIA_VIDEOS_ENTRY_SLUG')) - define('BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch'); - - if (!defined('BP_MEDIA_VIDEOS_EDIT_SLUG')) - define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit'); - - /* Audio slug */ - if (!defined('BP_MEDIA_AUDIO_SLUG')) - define('BP_MEDIA_AUDIO_SLUG', 'music'); - - if (!defined('BP_MEDIA_AUDIO_ENTRY_SLUG')) - define('BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen'); - - if (!defined('BP_MEDIA_AUDIO_EDIT_SLUG')) - define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit'); - - /* Albums slug */ - if (!defined('BP_MEDIA_ALBUMS_SLUG')) - define('BP_MEDIA_ALBUMS_SLUG', 'albums'); - - if (!defined('BP_MEDIA_ALBUMS_ENTRY_SLUG')) - define('BP_MEDIA_ALBUMS_ENTRY_SLUG', 'list'); - - if (!defined('BP_MEDIA_ALBUMS_EDIT_SLUG')) - define('BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit'); - - /* UI Labels loaded via text domain, can be translated */ - if (!defined('BP_MEDIA_LABEL')) - define('BP_MEDIA_LABEL', __('Media', $this->text_domain)); - - if (!defined('BP_MEDIA_LABEL_SINGULAR')) - define('BP_MEDIA_LABEL_SINGULAR', __('Media', $this->text_domain)); - - if (!defined('BP_MEDIA_IMAGES_LABEL')) - define('BP_MEDIA_IMAGES_LABEL', __('Photos', $this->text_domain)); - - if (!defined('BP_MEDIA_IMAGES_LABEL_SINGULAR')) - define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('Photo', $this->text_domain)); - - if (!defined('BP_MEDIA_VIDEOS_LABEL')) - define('BP_MEDIA_VIDEOS_LABEL', __('Videos', $this->text_domain)); - - if (!defined('BP_MEDIA_VIDEOS_LABEL_SINGULAR')) - define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', $this->text_domain)); - - if (!defined('BP_MEDIA_AUDIO_LABEL')) - define('BP_MEDIA_AUDIO_LABEL', __('Music', $this->text_domain)); - - if (!defined('BP_MEDIA_AUDIO_LABEL_SINGULAR')) - define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('Music', $this->text_domain)); - - if (!defined('BP_MEDIA_ALBUMS_LABEL')) - define('BP_MEDIA_ALBUMS_LABEL', __('Albums', $this->text_domain)); - - if (!defined('BP_MEDIA_ALBUMS_LABEL_SINGULAR')) - define('BP_MEDIA_ALBUMS_LABEL_SINGULAR', __('Album', $this->text_domain)); - - if (!defined('BP_MEDIAUPLOAD_LABEL')) - define('BP_MEDIA_UPLOAD_LABEL', __('Upload', $this->text_domain)); - - /* Support Email constant */ - if (!defined('BP_MEDIA_SUPPORT_EMAIL')) - define('BP_MEDIA_SUPPORT_EMAIL', $this->support_email); - } - - /** - * Hooks the plugin into BuddyPress via 'bp_include' action. - * Initialises the plugin's functionalities, options, - * loads media for Profiles and Groups. - * Creates Admin panels - * Loads accessory functions - * - * @global BPMediaAdmin $bp_media_admin - */ - function init() { - - /** - * Load options/settings - */ - $this->get_option(); - - if (defined('BP_VERSION') && - version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '>=')) { - /** - * Add a settings link to the Plugin list screen - */ - add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2); - /** - * Load BuddyPress Media for profiles - */ - $this->loader = new BPMediaLoader(); - /** - * Load BuddyPress Media for groups - */ - if (array_key_exists('enable_on_group', $this->options)) { - if ($this->options['enable_on_group']) { - $this->group_loader = new BPMediaGroupLoader(); - } - } - - - /** - * Load accessory functions - */ - new BPMediaActivity(); - new BPMediaFilters(); - new BPMediaActions(); - new BPMediaFunction(); - } - - /** - * Add admin notices - */ - add_action('admin_notices', array($this, 'admin_notice')); - /** - * Initialise Admin Panels - */ - global $bp_media_admin; - $bp_media_admin = new BPMediaAdmin(); - } - - /** - * Loads translations - */ - static function load_translation() { - load_plugin_textdomain(BP_MEDIA_TXT_DOMAIN, false, basename(BP_MEDIA_PATH) . '/languages/'); - } - - /** - * Add a settings link to the BuddyPress Media entry - * in the list of active plugins screen - * - * @param array $links - * @param string $file - * @return array - */ - function settings_link($links, $file) { - /* create link */ - $plugin_name = plugin_basename(BP_MEDIA_PATH . 'index.php'); - $admin_link = $this->get_admin_url( - add_query_arg( - array( - 'page' => 'bp-media-settings'), 'admin.php' - ) - ); - if ($file == $plugin_name) { - array_unshift( - $links, sprintf( - '%s', $admin_link, __('Settings', $this->text_domain) - ) - ); - } - return $links; - } - - /** - * Default media sizes - * - * @return array - */ - function media_sizes() { - $def_sizes = array( - 'activity_image' => array( - 'width' => 320, - 'height' => 240 - ), - 'activity_video' => array( - 'width' => 320, - 'height' => 240 - ), - 'activity_audio' => array( - 'width' => 320, - ), - 'single_image' => array( - 'width' => 800, - 'height' => 0 - ), - 'single_video' => array( - 'width' => 640, - 'height' => 480 - ), - 'single_audio' => array( - 'width' => 640, - ), - ); - - /** Can be filtered by a theme or an extension/plugin */ - return apply_filters('bpmedia_media_sizes', $def_sizes); - } - - /** - * Defines default length of strings and excerpts displayed in activities - * and media tabs - * - * @global array $bp_media_default_excerpts - */ - function excerpt_lengths() { - global $bp_media_default_excerpts; - $def_excerpt = array( - 'single_entry_title' => 100, - 'single_entry_description' => 500, - 'activity_entry_title' => 50, - 'activity_entry_description' => 500 - ); - - $bp_media_default_excerpts = apply_filters( - 'bpmedia_excerpt_lengths', $def_excerpt - ); - } - - /** - * Admin notices for dependencies and compatibility - * - * @global object/array $current_user - */ - public function admin_notice() { - global $current_user; - $user_id = $current_user->ID; - if (isset($_GET['bp_media_nag_ignore']) - && '0' == $_GET['bp_media_nag_ignore']) { - add_user_meta($user_id, 'bp_media_ignore_notice', 'true', true); - } - /* Check that the user hasn't already clicked to ignore the message */ - if (!get_user_meta($user_id, 'bp_media_ignore_notice')) { - if (defined('BP_VERSION')) { - if (version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '<')) { - echo '

'; - printf( - __( - 'The BuddyPress version installed is an + if ( ! defined( 'BP_MEDIA_LABEL_SINGULAR' ) ) + define( 'BP_MEDIA_LABEL_SINGULAR', __( 'Media', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_IMAGES_LABEL' ) ) + define( 'BP_MEDIA_IMAGES_LABEL', __( 'Photos', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_IMAGES_LABEL_SINGULAR' ) ) + define( 'BP_MEDIA_IMAGES_LABEL_SINGULAR', __( 'Photo', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL' ) ) + define( 'BP_MEDIA_VIDEOS_LABEL', __( 'Videos', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR' ) ) + define( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR', __( 'Video', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_AUDIO_LABEL' ) ) + define( 'BP_MEDIA_AUDIO_LABEL', __( 'Music', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_AUDIO_LABEL_SINGULAR' ) ) + define( 'BP_MEDIA_AUDIO_LABEL_SINGULAR', __( 'Music', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL' ) ) + define( 'BP_MEDIA_ALBUMS_LABEL', __( 'Albums', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR' ) ) + define( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR', __( 'Album', $this->text_domain ) ); + + if ( ! defined( 'BP_MEDIAUPLOAD_LABEL' ) ) + define( 'BP_MEDIA_UPLOAD_LABEL', __( 'Upload', $this->text_domain ) ); + + /* Support Email constant */ + if ( ! defined( 'BP_MEDIA_SUPPORT_EMAIL' ) ) + define( 'BP_MEDIA_SUPPORT_EMAIL', $this->support_email ); + } + + /** + * Hooks the plugin into BuddyPress via 'bp_include' action. + * Initialises the plugin's functionalities, options, + * loads media for Profiles and Groups. + * Creates Admin panels + * Loads accessory functions + * + * @global BPMediaAdmin $bp_media_admin + */ + function init() { + + /** + * Load options/settings + */ + $this->get_option(); + + if ( defined( 'BP_VERSION' ) && + version_compare( BP_VERSION, BP_MEDIA_REQUIRED_BP, '>=' ) ) { + /** + * Add a settings link to the Plugin list screen + */ + add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 ); + /** + * Load BuddyPress Media for profiles + */ + $this->loader = new BPMediaLoader(); + /** + * Load BuddyPress Media for groups + */ + if ( array_key_exists( 'enable_on_group', $this->options ) ) { + if ( $this->options[ 'enable_on_group' ] ) { + $this->group_loader = new BPMediaGroupLoader(); + } + } + + + /** + * Load accessory functions + */ + new BPMediaActivity(); + new BPMediaFilters(); + new BPMediaActions(); + new BPMediaFunction(); + } + + /** + * Add admin notices + */ + add_action( 'admin_notices', array( $this, 'admin_notice' ) ); + /** + * Initialise Admin Panels + */ + global $bp_media_admin; + $bp_media_admin = new BPMediaAdmin(); + } + + /** + * Loads translations + */ + static function load_translation() { + load_plugin_textdomain( BP_MEDIA_TXT_DOMAIN, false, basename( BP_MEDIA_PATH ) . '/languages/' ); + } + + /** + * Add a settings link to the BuddyPress Media entry + * in the list of active plugins screen + * + * @param array $links + * @param string $file + * @return array + */ + function settings_link( $links, $file ) { + /* create link */ + $plugin_name = plugin_basename( BP_MEDIA_PATH . 'index.php' ); + $admin_link = $this->get_admin_url( + add_query_arg( + array( + 'page' => 'bp-media-settings' ), 'admin.php' + ) + ); + if ( $file == $plugin_name ) { + array_unshift( + $links, sprintf( + '%s', $admin_link, __( 'Settings', $this->text_domain ) + ) + ); + } + return $links; + } + + /** + * Default media sizes + * + * @return array + */ + function media_sizes() { + $def_sizes = array( + 'activity_image' => array( + 'width' => 320, + 'height' => 240 + ), + 'activity_video' => array( + 'width' => 320, + 'height' => 240 + ), + 'activity_audio' => array( + 'width' => 320, + ), + 'single_image' => array( + 'width' => 800, + 'height' => 0 + ), + 'single_video' => array( + 'width' => 640, + 'height' => 480 + ), + 'single_audio' => array( + 'width' => 640, + ), + ); + + /** Can be filtered by a theme or an extension/plugin */ + return apply_filters( 'bpmedia_media_sizes', $def_sizes ); + } + + /** + * Defines default length of strings and excerpts displayed in activities + * and media tabs + * + * @global array $bp_media_default_excerpts + */ + function excerpt_lengths() { + global $bp_media_default_excerpts; + $def_excerpt = array( + 'single_entry_title' => 100, + 'single_entry_description' => 500, + 'activity_entry_title' => 50, + 'activity_entry_description' => 500 + ); + + $bp_media_default_excerpts = apply_filters( + 'bpmedia_excerpt_lengths', $def_excerpt + ); + } + + /** + * Admin notices for dependencies and compatibility + * + * @global object/array $current_user + */ + public function admin_notice() { + global $current_user; + $user_id = $current_user->ID; + if ( isset( $_GET[ 'bp_media_nag_ignore' ] ) + && '0' == $_GET[ 'bp_media_nag_ignore' ] ) { + add_user_meta( $user_id, 'bp_media_ignore_notice', 'true', true ); + } + /* Check that the user hasn't already clicked to ignore the message */ + if ( ! get_user_meta( $user_id, 'bp_media_ignore_notice' ) ) { + if ( defined( 'BP_VERSION' ) ) { + if ( version_compare( BP_VERSION, BP_MEDIA_REQUIRED_BP, '<' ) ) { + echo '

'; + printf( + __( + 'The BuddyPress version installed is an older version and is not supported, please update BuddyPress to use BuddyPress Media Plugin. X', $this->text_domain - ), '?bp_media_nag_ignore=0' - ); - echo "

"; - } - } else { - echo '

'; - printf( - __( - 'You have not installed BuddyPress. + ), '?bp_media_nag_ignore=0' + ); + echo "

"; + } + } else { + echo '

'; + printf( + __( + 'You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin. X', $this->text_domain - ), '?bp_media_nag_ignore=0' - ); - echo "

"; - } - } - } - - /** - * Plugin activation, checks for old database and updates it. - * - */ - public function activate() { - $bpmquery = new WP_Query( - array( - 'post_type' => 'bp_media', - 'posts_per_page' => 1 - ) - ); - if ($bpmquery->found_posts > 0) { - update_site_option('bp_media_db_version', '1.0'); - } else { - switch (get_site_option('bp_media_db_version', false, false)) { - case '2.0': - break; - default: - update_site_option( - 'bp_media_db_version', BP_MEDIA_DB_VERSION - ); - } - } - } - - /** - * Provides the right admin url to work with - * - * @param string $path - * @param string $scheme - * @return string The proper admin url for single/multisite installs - */ - function get_admin_url($path = '', $scheme = 'admin') { - - // Links belong in network admin - if (is_multisite()) - $url = network_admin_url($path, $scheme); - - // Links belong in site admin - else - $url = admin_url($path, $scheme); - - return $url; - } - - /** - * Registers and activates the BuddyPress Media Widgets - */ - function widgets_init() { - register_widget('BPMediaWidget'); - } + ), '?bp_media_nag_ignore=0' + ); + echo "

"; + } + } + } /** + * Plugin activation, checks for old database and updates it. * */ - function enabled(){ + public function activate() { + $bpmquery = new WP_Query( + array( + 'post_type' => 'bp_media', + 'posts_per_page' => 1 + ) + ); + if ( $bpmquery->found_posts > 0 ) { + update_site_option( 'bp_media_db_version', '1.0' ); + } else { + switch ( get_site_option( 'bp_media_db_version', false, false ) ) { + case '2.0': + break; + default: + update_site_option( + 'bp_media_db_version', BP_MEDIA_DB_VERSION + ); + } + } + } + + /** + * Provides the right admin url to work with + * + * @param string $path + * @param string $scheme + * @return string The proper admin url for single/multisite installs + */ + function get_admin_url( $path = '', $scheme = 'admin' ) { + + // Links belong in network admin + if ( is_multisite() ) + $url = network_admin_url( $path, $scheme ); + + // Links belong in site admin + else + $url = admin_url( $path, $scheme ); + + return $url; + } + + /** + * Registers and activates the BuddyPress Media Widgets + */ + function widgets_init() { + register_widget( 'BPMediaWidget' ); + } + + /** + * + */ + function enabled() { $options = $this->options; - $enabled= array( - 'images' => false, - 'videos' => false, - 'audio' => false, - 'albums' => true, - 'upload' => true + $enabled = array( + 'images' => false, + 'videos' => false, + 'audio' => false, + 'albums' => true, + 'upload' => true ); - if( array_key_exists( 'images_enabled', $options )){ - if($options['images_enabled']==1 ) - $enabled['images']=true; + if ( array_key_exists( 'images_enabled', $options ) ) { + if ( $options[ 'images_enabled' ] == 1 ) + $enabled[ 'images' ] = true; } - if( array_key_exists( 'videos_enabled', $options )){ - if($options['videos_enabled']==1 ) - $enabled['video']=true; + if ( array_key_exists( 'videos_enabled', $options ) ) { + if ( $options[ 'videos_enabled' ] == 1 ) + $enabled[ 'video' ] = true; } - if( array_key_exists( 'audio_enabled', $options )){ - if($options['audio_enabled']==1 ) - $enabled['audio']=true; + if ( array_key_exists( 'audio_enabled', $options ) ) { + if ( $options[ 'audio_enabled' ] == 1 ) + $enabled[ 'audio' ] = true; } return $enabled; } + static function get_wall_album( $group_id = false ) { + global $wpdb; + $group_id = ( ! $group_id) ? '1' : $group_id; + $album_name = __( 'Wall Posts', BP_MEDIA_TXT_DOMAIN ); + $query = "SELECT ID FROM {$wpdb->prefix}posts ps LEFT JOIN {$wpdb->prefix}postmeta pm ON ps.ID= pm.post_id WHERE ps.post_title LIKE '{$album_name}' AND ps.post_type='bp_media_album' AND pm.meta_key='bp-media-key' AND pm.meta_value ='{$group_id}'"; + print_r( $query ); + $wall_albums = $wpdb->get_results( $query, ARRAY_A ); + print_r( $wall_albums ); + wp_die( 'yay' ); + + if ( count( $wall_albums ) > 1 ) { + return BuddyPressMedia::merge_duplicate_wall_albums( $wall_albums ); + } else { + return $wall_albums[ 0 ][ 'ID' ]; + } + } + static function merge_duplicate_wall_albums( $wall_albums ) { + global $wpdb; + $album_id = $wall_albums[ 0 ][ 'ID' ]; + unset( $wall_albums[ 0 ] ); + foreach ( $wall_albums as $album ) { + $query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_parent={$album[ 'ID' ]} AND post_type='attachment'"; + $media = $wpdb->get_results( $query, ARRAY_A ); + foreach ( $media as $file ) { + $wpdb->update( + $wpdb->prefix . 'posts', + array( + ' post_parent' => $album_id + ), + array( 'ID' => $file['ID'] ), + array( '%d' ), + array( '%d' ) + ); + } + } + } } diff --git a/index.php b/index.php index 7279015fc..52c11a31e 100755 --- a/index.php +++ b/index.php @@ -74,6 +74,7 @@ function buddypress_media_autoloader( $class_name ) { */ global $bp_media; $bp_media = new BuddyPressMedia(); +BuddyPressMedia::get_wall_album(); //add_action('init','BPMediaBPAlbumImporter'); //BPMediaBPAlbumImporter::bpmedia_ajax_import_callback(); From 32b463396fe42e3a95fa3917ac2300c2926efb8e Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 12:23:24 +0530 Subject: [PATCH 05/12] debugged merge albums --- app/main/BuddyPressMedia.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index bcfc49da7..fb436ffbd 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -561,11 +561,11 @@ static function get_wall_album( $group_id = false ) { global $wpdb; $group_id = ( ! $group_id) ? '1' : $group_id; $album_name = __( 'Wall Posts', BP_MEDIA_TXT_DOMAIN ); - $query = "SELECT ID FROM {$wpdb->prefix}posts ps LEFT JOIN {$wpdb->prefix}postmeta pm ON ps.ID= pm.post_id WHERE ps.post_title LIKE '{$album_name}' AND ps.post_type='bp_media_album' AND pm.meta_key='bp-media-key' AND pm.meta_value ='{$group_id}'"; - print_r( $query ); + $query = "SELECT ID FROM {$wpdb->prefix}posts ps LEFT JOIN + {$wpdb->prefix}postmeta pm ON ps.ID= pm.post_id WHERE ps.post_title + LIKE '{$album_name}' AND ps.post_type='bp_media_album' AND + pm.meta_key='bp-media-key' AND pm.meta_value ='{$group_id}'"; $wall_albums = $wpdb->get_results( $query, ARRAY_A ); - print_r( $wall_albums ); - wp_die( 'yay' ); if ( count( $wall_albums ) > 1 ) { return BuddyPressMedia::merge_duplicate_wall_albums( $wall_albums ); @@ -579,7 +579,8 @@ static function merge_duplicate_wall_albums( $wall_albums ) { $album_id = $wall_albums[ 0 ][ 'ID' ]; unset( $wall_albums[ 0 ] ); foreach ( $wall_albums as $album ) { - $query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_parent={$album[ 'ID' ]} AND post_type='attachment'"; + $query = "SELECT ID FROM {$wpdb->prefix}posts WHERE + post_parent={$album[ 'ID' ]} AND post_type='attachment'"; $media = $wpdb->get_results( $query, ARRAY_A ); foreach ( $media as $file ) { $wpdb->update( From 01d51029b59791dc5fb9c3a2f5488becfe63d2f8 Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 12:25:13 +0530 Subject: [PATCH 06/12] added removal of duplicate albums --- app/main/BuddyPressMedia.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index fb436ffbd..d208b6d76 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -593,7 +593,10 @@ static function merge_duplicate_wall_albums( $wall_albums ) { array( '%d' ) ); } + + wp_delete_post($album['ID'],true); } + } } From 7355db6659a6a5a3b9b9870fd6662125f674d2de Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Wed, 13 Feb 2013 15:06:52 +0530 Subject: [PATCH 07/12] Added responsiveness to the media list --- app/assets/css/main.css | 66 ++++++++++++---------------- app/assets/js/bp-media-uploader.js | 15 ++++--- app/main/profile/BPMediaTemplate.php | 2 +- 3 files changed, 37 insertions(+), 46 deletions(-) diff --git a/app/assets/css/main.css b/app/assets/css/main.css index a4c8c4f4f..85f20ede4 100755 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -40,7 +40,7 @@ div.bp_media_title{margin-bottom:10px;} .bp-media-area-allocate{height: 10px;width: 100%;display: block;} li #bp-media-upload-ui {padding: 0;max-width: 158px;} #bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;min-height: 140px;text-align: center;background: url('../img/drag-drop-bg.png') repeat scroll 0 0 transparent;overflow: hidden;} -li #bp-media-upload-ui #drag-drop-area{width: 100%;max-width: 150px;min-height: 150px;} +li #bp-media-upload-ui #drag-drop-area{max-width: 150px;min-height: 150px;} #bp-media-upload-ui .drag-drop-space{margin: 18px auto 0;max-width: 400px;overflow: hidden;} #bp-media-upload-ui .drag-drop-inside{float: left;margin: 0 auto 15px;width: 47%;} .albums #bp-media-upload-ui .drag-drop-inside{float: none;width: auto;} @@ -50,39 +50,21 @@ li #bp-media-upload-ui #bp-media-album-prompt{margin: 12px auto 0;max-width: 144 #bp-media-upload-ui .drag-drop-inside p.drag-drop-info{font-size: 20px;line-height: 100%;} #bp-media-upload-ui .drag-drop-buttons input,#bp-media-album-prompt input.button{-moz-box-sizing: content-box;border-color: #BBBBBB;border-radius: 15px;border-style: solid;border-width: 1px;color: #464646;cursor: pointer;font-size: 13px !important;line-height: 13px;padding: 5px 10px;text-decoration: none;} -#bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px 4px;text-decoration: none;} -#bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;} +li #bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px;text-decoration: none;margin-top: 5px;} +#bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;margin: 10px 0;} li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: none;} li #bp-media-upload-ui .drag-drop-space p.drag-drop-buttons{display: block;} #bp-media-album-prompt div.hide{display: none;margin: 0;} #bp-media-album-prompt > p{font-size: 20px;} #bp-media-upload-ui .drag-drop-inside p,#bp-media-album-prompt #bp_media_album_new{margin-bottom: 12px;font-size: 14px;} #bp-media-album-prompt #bp_media_album_new{max-width: 90%;} -li #bp-media-album-prompt #bp_media_album_new{margin: 0 0 5px;max-width: 134px;width: 94%;} +li #bp-media-album-prompt #bp_media_album_new{margin: 0;max-width: 134px;width: 94%;} #bp-media-upload-ui .drag-drop-to{width: 22px;line-height: 22px;margin: 40px auto 0;float: left;} li #bp-media-upload-ui .drag-drop-to{width: 100%;line-height: 22px;margin: 0;float: none;} #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: left;font-size: 14px;line-height: 22px;margin: 30px auto 0;width: 22px;} li #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: none;font-size: 14px;line-height: 22px;margin: 0 auto;width: 22px;} #bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;} -/*#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 150px;width: 150px;} -.upload #bp-media-upload-ui #drag-drop-area{height: auto; width: 100%;} -#bp-media-upload-ui .drag-drop-inside{margin:auto;width: 100%;} -#bp-media-album-prompt{margin: 0;position: absolute;right: 0;text-align: right;top: 2px;min-width: 200px;} -#bp-media-album-prompt span{float: left;line-height: 25px;margin-right: 15px;} -#bp-media-album-prompt .bp-media-album-content{float: left;} -#bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;} -#bp-media-album-prompt div.hide{display: none;position: absolute;right: 0;top: 0;z-index: 100;position: relative;} -#bp-media-album-prompt #bp_media_album_new {width: 160px;} -#bp-media-album-prompt input.button{height: 25px;margin-left: 5px;padding: 0 10px;position: relative;top: -1px;} -div.bp-media-area-allocate{display: block;height: 15px;} -div.bp_media_create_album{text-align: right} -#bp_media_album_name{margin-bottom: 6px;}*/ - -/*#bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 12px 0;} -#bp-media-upload-ui .drag-drop-info{font-size: 20px;} -#bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;color: #464646;text-decoration: none;font-size: 12px!important;line-height: 13px;padding: 3px 8px;cursor: pointer;border-width: 1px;border-style: solid;-webkit-border-radius: 11px;border-radius: 11px;-moz-box-sizing: content-box;-webkit-box-sizing: content-box;box-sizing: content-box;}*/ - #bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;left: 0;margin-top: 5px;position: absolute;top: 155px;width: 100%;} #bp-media-uploaded-files .error{padding: 5px;text-align: center;} .bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)} @@ -206,19 +188,27 @@ background-image: -webkit-gradient(linear,left bottom,left top,color-stop(1, #F7 img.bp-media-donation-image{display:block;margin: 10px auto;} #donate form{text-align: center;} -/* BuddyPress Media Image Uploader album selection */ -/*#bp-media-album-prompt, #bp-media-album-new { background: none repeat scroll 0 0 #FFFFFF;border: 1px solid #AAAAAA;border-radius: 5px 5px 5px 5px;display: none;padding: 3px;z-index: 110000;left: 40%;position: fixed;top: 35%;width: 300px; } -#bp-media-album-new { z-index: 120000; } -.bp-media-album-title { background: url("../img/Popup-title-bg.png") repeat-x scroll 50% 50% #CCCCCC;border: 1px solid #AAAAAA;border-radius: 5px 5px 5px 5px;color: #222222;display: block;font-weight: bold;padding: 0;margin-bottom: 10px; } -.bp-media-album-title span { background: none repeat scroll 0 0 transparent;display: block;font-size: 16px;padding: 10px; } -#bp-media-create-album-close, #bp-media-create-album-close:active, #bp-media-close, #bp-media-close:active { border-radius: 3px 3px 3px 3px;cursor: pointer;display: block;padding: 0 7px 2px;position: absolute;right: 8px;top: 11px;z-index: 10; } -#bp-media-create-album-close:hover, #bp-media-create-album-close:focus, #bp-media-close:hover, #bp-media-close:focus { background: none repeat scroll 0 0 #545454;color: #CFCFCF; } -.bp-media-album-content { display: block;padding: 5px; } -.bp-media-album-content label { display: block;font-size: 14px;margin: 0 0 0 3px; } -#bp-media-album-prompt select { min-width: 140px; } -.select-btn-div { border-top: 1px solid #AAAAAA;margin: 15px 0 0;padding: 5px 5px 5px 30px;text-align: right; } -.select-btn-div .btn { float: right;font-size: 14px;margin: 5px;padding: 10px 25px; } -#bp-media-album-new > label { font-size: 14px; } -#bp-media-album-new input[type="text"] { width: 98%; } -#custom-overlay { background: none repeat scroll 0 0 #000000;bottom: 0;left: 0;min-height: 360px;opacity: 0.7;position: fixed;right: 0;top: 0;z-index: 105000; } -div.error{margin: 5px 0 15px; background-color: #ffebe8; border-color: #c00;padding: 0 .6em;-webkit-border-radius: 3px;border-radius: 3px;border-width: 1px;border-style: solid;}*/ \ No newline at end of file +@media (max-width: 980px) { + #item-body ul.bp-media-gallery li{width: 23%;} + li #bp-media-upload-ui #drag-drop-area{min-height: auto;} +} +@media (max-width: 850px) { + #item-body ul.bp-media-gallery li{width: 31%;} + +} +@media (max-width: 480px) { + #item-body ul.bp-media-gallery li{width: 48%;} + li #bp-media-upload-ui{max-width: 170px;} + ul.bp-media-gallery li img,li #bp-media-upload-ui #drag-drop-area{max-width: 170px;width: 100%;} + li #bp-media-upload-ui #drag-drop-area{max-width: 162px;} + #bp-media-upload-ui .drag-drop-space{margin: 23px auto 10px;} + li #bp-media-upload-ui .drag-drop-inside{margin: 0 auto 23px;} +} +@media (max-width: 379px) { + #bp-media-upload-ui{min-height: 190px;} + #item-body ul.bp-media-gallery li{width: 95%;} + #bp-media-upload-ui .drag-drop-inside{float: none;width: 100%;} + #bp-media-album-in{float: none;margin: 0 auto;} + #bp-media-upload-ui #bp-media-album-prompt{margin: 15px auto 15px;float: none;width: 100%} + #bp-media-upload-ui .drag-drop-inside p,#bp-media-album-prompt #bp_media_album_new{margin-bottom: 5px;} +} \ No newline at end of file diff --git a/app/assets/js/bp-media-uploader.js b/app/assets/js/bp-media-uploader.js index 60de7b482..3998fc352 100755 --- a/app/assets/js/bp-media-uploader.js +++ b/app/assets/js/bp-media-uploader.js @@ -238,16 +238,15 @@ jQuery(document).ready(function(){ } var selected = jQuery('#bp-media-album-prompt select').val(); + var in_list = 0; if(jQuery('#'+bp_media_uploader_params.container).length==0) return false; + if ( jQuery('#bp-media-album-prompt p').css('display') == 'none' ) + in_list = 1; jQuery('#bp-media-album-prompt select').change(function() { - if ( jQuery(this).val() == 'create_new' ) { - jQuery('#bp_media_album_new').css({ - 'width':jQuery('#bp-media-album-prompt select').width()+20 - }); jQuery('#bp-media-album-prompt select').hide(); - jQuery('#bp-media-album-prompt span').hide(); + jQuery('#bp-media-album-prompt p').hide(); jQuery('#bp-media-album-prompt div.hide').show(); } else selected = jQuery(this).val(); @@ -279,7 +278,8 @@ jQuery(document).ready(function(){ jQuery('#bp-media-selected-album').prepend(''); jQuery('#bp-media-album-prompt div.hide').hide(); jQuery('#bp-media-album-prompt select').show(); - jQuery('#bp-media-album-prompt span').show(); + if ( in_list == 0 ) + jQuery('#bp-media-album-prompt p').show(); } }); } @@ -289,7 +289,8 @@ jQuery(document).ready(function(){ jQuery('#bp-media-album-prompt select option').removeAttr('selected'); jQuery('#bp-media-album-prompt select option[value=' + selected + ']').attr('selected', 'selected'); jQuery('#bp-media-album-prompt select').show(); - jQuery('#bp-media-album-prompt span').show(); + if ( in_list == 0 ) + jQuery('#bp-media-album-prompt p').show(); }); //Normal Uplaoder diff --git a/app/main/profile/BPMediaTemplate.php b/app/main/profile/BPMediaTemplate.php index e742e66db..ab1a44895 100755 --- a/app/main/profile/BPMediaTemplate.php +++ b/app/main/profile/BPMediaTemplate.php @@ -69,7 +69,7 @@ function upload_form_multiple() {
- +
From 781ef907a359e824541378f4b0e55a238c80abeb Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Wed, 13 Feb 2013 15:24:32 +0530 Subject: [PATCH 08/12] Added responsiveness to the media list --- app/assets/css/main.css | 4 +++- app/main/profile/BPMediaTemplate.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 85f20ede4..861aba35f 100755 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -53,6 +53,7 @@ li #bp-media-upload-ui #bp-media-album-prompt{margin: 12px auto 0;max-width: 144 li #bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px;text-decoration: none;margin-top: 5px;} #bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;margin: 10px 0;} li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: none;} +.albums li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: block;} li #bp-media-upload-ui .drag-drop-space p.drag-drop-buttons{display: block;} #bp-media-album-prompt div.hide{display: none;margin: 0;} #bp-media-album-prompt > p{font-size: 20px;} @@ -65,7 +66,8 @@ li #bp-media-upload-ui .drag-drop-to{width: 100%;line-height: 22px;margin: 0;flo li #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: none;font-size: 14px;line-height: 22px;margin: 0 auto;width: 22px;} #bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;} -#bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;left: 0;margin-top: 5px;position: absolute;top: 155px;width: 100%;} +#bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;margin-top: 5px;width: 100%;} +li #bp-media-uploaded-files{left: 0;position: absolute;top: 155px;} #bp-media-uploaded-files .error{padding: 5px;text-align: center;} .bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)} .bp-media-progress-text{z-index: 10;position: relative;width: 100%;padding: 0 8px;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);color: rgba(0, 0, 0, 0.6);font-size:16px;line-height: 28px;height: 28px;} diff --git a/app/main/profile/BPMediaTemplate.php b/app/main/profile/BPMediaTemplate.php index ab1a44895..582c38374 100755 --- a/app/main/profile/BPMediaTemplate.php +++ b/app/main/profile/BPMediaTemplate.php @@ -78,8 +78,8 @@ function upload_form_multiple() { -
+
Date: Wed, 13 Feb 2013 15:28:25 +0530 Subject: [PATCH 09/12] Debuggin tab disabling --- app/main/BPMediaComponent.php | 59 ++++++++++++------------------ app/main/BPMediaGroupLoader.php | 64 +++++++++++++++++++-------------- app/main/BuddyPressMedia.php | 33 +++++++++++++---- 3 files changed, 86 insertions(+), 70 deletions(-) diff --git a/app/main/BPMediaComponent.php b/app/main/BPMediaComponent.php index 081cb962c..e3ae66a54 100755 --- a/app/main/BPMediaComponent.php +++ b/app/main/BPMediaComponent.php @@ -71,51 +71,35 @@ function setup_nav() { global $bp, $bp_media; $enabled = $bp_media->enabled(); - /* Upload Screen */ + $default_tab = $bp_media->default_tab(); + $defaults_tab = $bp_media->defaults_tab(); - foreach ($enabled as $active){ - $bp_media_upload = new BPMediaUploadScreen( + /* Upload Screen */ + $bp_media_upload = new BPMediaUploadScreen( 'upload', BP_MEDIA_UPLOAD_SLUG ); - } - - $enabled = $bp_media->enabled(); /* Media Screens */ - - if($enabled['images']){ - $bp_media_image = new BPMediaScreen( - 'image', - BP_MEDIA_IMAGES_SLUG - ); - } - if($enabled['videos']){ - $bp_media_video = new BPMediaScreen( - 'video', - BP_MEDIA_VIDEOS_SLUG + foreach ($enabled as $tab=>$active){ + if($active==true){ + $tabs = $tab; + if($tabs!='audio'&&$tabs!='upload'){ + $tabs .= 's'; + } + if($tab!='upload'){ + ${'bp_media_'.$tab} = new BPMediaScreen( + $tab, + constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG') ); + } } - if($enabled['audio']){ - $bp_media_audio = new BPMediaScreen( - 'audio', - BP_MEDIA_AUDIO_SLUG - ); } - - - - /* Album Screen */ - $bp_media_album = new BPMediaAlbumScreen( - 'album', - BP_MEDIA_ALBUMS_SLUG - ); - /* Switch between different screens depending on context */ switch ($bp->current_component) { case BP_MEDIA_IMAGES_SLUG: - if ( $enabled['images'] && is_numeric($bp->current_action)) { + if ( $enabled['image'] && is_numeric($bp->current_action)) { $bp->action_variables[0] = $bp->current_action; $bp->current_action = BP_MEDIA_IMAGES_ENTRY_SLUG; } @@ -127,7 +111,7 @@ function setup_nav() { } break; case BP_MEDIA_VIDEOS_SLUG: - if ($enabled['videos'] && is_numeric($bp->current_action)) { + if ($enabled['video'] && is_numeric($bp->current_action)) { $bp->action_variables[0] = $bp->current_action; $bp->current_action = BP_MEDIA_VIDEOS_ENTRY_SLUG; } @@ -141,12 +125,13 @@ function setup_nav() { } /* Create the main navigation on profile */ + echo $default_tab; $main_nav = array( 'name' => __(BP_MEDIA_LABEL, BP_MEDIA_TXT_DOMAIN), 'slug' => BP_MEDIA_SLUG, 'position' => 80, - 'screen_function' => array($bp_media_image, 'screen'), - 'default_subnav_slug' => BP_MEDIA_IMAGES_SLUG + 'screen_function' => array(${'bp_media_'.$default_tab}, 'screen'), + 'default_subnav_slug' => constant('BP_MEDIA_'.strtoupper($default_tab).'_SLUG') ); /* Create an empty sub navigation */ @@ -156,7 +141,7 @@ function setup_nav() { parent::setup_nav($main_nav, $sub_nav); /* Set up individual screens for each nav/sub nav */ - if($enabled['images']){ + if($enabled['image']){ bp_core_new_nav_item(array( 'name' => __(BP_MEDIA_IMAGES_LABEL, BP_MEDIA_TXT_DOMAIN), 'slug' => BP_MEDIA_IMAGES_SLUG, @@ -230,7 +215,7 @@ function setup_nav() { )); } - if($enabled['videos']){ + if($enabled['video']){ bp_core_new_nav_item(array( 'name' => __(BP_MEDIA_VIDEOS_LABEL, BP_MEDIA_TXT_DOMAIN), 'slug' => BP_MEDIA_VIDEOS_SLUG, diff --git a/app/main/BPMediaGroupLoader.php b/app/main/BPMediaGroupLoader.php index db865a2e2..8166f096f 100755 --- a/app/main/BPMediaGroupLoader.php +++ b/app/main/BPMediaGroupLoader.php @@ -26,14 +26,16 @@ function __construct() { if (class_exists('BPMediaGroupsExtension')) : bp_register_group_extension('BPMediaGroupsExtension'); - if($enabled['images']) - new BPMediaGroupImages (); - new BPMediaGroupAlbums(); - if($enabled['audio']) - new BPMediaGroupAudio(); - if($enabled['videos']) - new BPMediaGroupVideos(); - new BPMediaGroupUpload(); + foreach (array('image','video', 'audio', 'album', 'upload') as $type){ + if($enabled[$type]){ + $types = $type; + if($types!='audio'&&$types!='upload'){ + $types .= 's'; + } + $grp_class = 'BPMediaGroup'.ucfirst($types); + new $grp_class(); + } + } endif; add_action('bp_actions', array($this, 'custom_nav'), 999); add_filter('bp_media_multipart_params_filter', @@ -140,43 +142,51 @@ function multipart_params_handler($multipart_params) { static function navigation_menu() { global $bp,$bp_media; $enabled = $bp_media->enabled(); + $default_tab = $bp_media->default_tab(); + $defaults_tab = $bp_media->defaults_tab(); + echo $default_tab; + $default_const = 'BP_MEDIA_'.strtoupper($defaults_tab).'_SLUG'; if (!isset($bp->current_action) || $bp->current_action != BP_MEDIA_SLUG) return false; - $bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG); - $bp_media_image = new BPMediaScreen('image', BP_MEDIA_IMAGES_SLUG); - $current_tab = BP_MEDIA_IMAGES_SLUG; + ${'bp_media_'.$default_tab} = new BPMediaScreen($defaults_tab, constant($default_const)); + $current_tab = constant($default_const); - if (isset($bp->action_variables[0])) { - $current_tab = $bp->action_variables[0]; - } + //if (isset($bp->action_variables[0])) { + //$current_tab = $bp->action_variables[0]; + //} // if (BPMediaGroup::can_upload()) { - - $bp_media_nav[BP_MEDIA_IMAGES_SLUG] = array( + echo($default_tab); + $bp_media_nav[constant($default_const)] = array( 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . BP_MEDIA_SLUG, - 'label' => BP_MEDIA_IMAGES_LABEL, - 'screen_function' => array($bp_media_image, 'screen') + 'label' => constant('BP_MEDIA_'.strtoupper($defaults_tab).'_LABEL'), + 'screen_function' => array(${'bp_media_'.$default_tab}, 'screen') ); // } else { // $bp_media_nav = array(); // } - foreach (array('VIDEOS', 'AUDIO', 'ALBUMS', 'UPLOAD') as $type) { - if ($type == 'UPLOAD') { + foreach (array('IMAGES','VIDEOS', 'AUDIO', 'ALBUMS', 'UPLOAD') as $types) { + if ($types == 'UPLOAD') { + if (BPMediaGroupLoader::can_upload()) { - $bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array( - 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'), - 'label' => constant('BP_MEDIA_' . $type . '_LABEL'), + $bp_media_nav[constant('BP_MEDIA_' . $types . '_SLUG')] = array( + 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $types . '_SLUG'), + 'label' => constant('BP_MEDIA_' . $types . '_LABEL'), // 'screen_function' => array( $bp_media_upload, 'upload_screen' ), 'user_has_access' => BPMediaGroupLoader::can_upload() ); } } else { - if($enabled[strtolower($type)]){ - $bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array( - 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'), - 'label' => constant('BP_MEDIA_' . $type . '_LABEL'), + $type = $types; + if($types!='AUDIO'){ + $type = substr($types, 0, -1); + } + if($enabled[strtolower($type)] && $default_tab!=strtolower($type)){ + $bp_media_nav[constant('BP_MEDIA_' . $types . '_SLUG')] = array( + 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $types . '_SLUG'), + 'label' => constant('BP_MEDIA_' . $types . '_LABEL'), ); } } diff --git a/app/main/BuddyPressMedia.php b/app/main/BuddyPressMedia.php index d208b6d76..168237b2e 100755 --- a/app/main/BuddyPressMedia.php +++ b/app/main/BuddyPressMedia.php @@ -252,10 +252,12 @@ public function constants() { /* UI Labels loaded via text domain, can be translated */ if ( ! defined( 'BP_MEDIA_LABEL' ) ) - define( 'BP_MEDIA_LABEL', __( 'Media', $this->text_domain ) ); + define( 'BP_MEDIA_LABEL', __( 'Media', + $this->text_domain ) ); if ( ! defined( 'BP_MEDIA_LABEL_SINGULAR' ) ) - define( 'BP_MEDIA_LABEL_SINGULAR', __( 'Media', $this->text_domain ) ); + define( 'BP_MEDIA_LABEL_SINGULAR', __( 'Media', + $this->text_domain ) ); if ( ! defined( 'BP_MEDIA_IMAGES_LABEL' ) ) define( 'BP_MEDIA_IMAGES_LABEL', __( 'Photos', $this->text_domain ) ); @@ -535,15 +537,15 @@ function widgets_init() { function enabled() { $options = $this->options; $enabled = array( - 'images' => false, - 'videos' => false, + 'image' => false, + 'video' => false, 'audio' => false, - 'albums' => true, + 'album' => true, 'upload' => true ); if ( array_key_exists( 'images_enabled', $options ) ) { if ( $options[ 'images_enabled' ] == 1 ) - $enabled[ 'images' ] = true; + $enabled[ 'image' ] = true; } if ( array_key_exists( 'videos_enabled', $options ) ) { if ( $options[ 'videos_enabled' ] == 1 ) @@ -557,6 +559,25 @@ function enabled() { return $enabled; } + function default_tab(){ + $enabled = $this->enabled(); + unset($enabled['upload']); + unset($enabled['album']); + foreach($enabled as $tab=>$value){ + if($value==true){ + return $tab; + } + } + } + + function defaults_tab(){ + $defaults_tab = $this->default_tab(); + if($defaults_tab!='audio'){ + $defaults_tab .= 's'; + } + return $defaults_tab; + } + static function get_wall_album( $group_id = false ) { global $wpdb; $group_id = ( ! $group_id) ? '1' : $group_id; From b8b11c5fd41b7a5fa13bb561842a87487925a97d Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Wed, 13 Feb 2013 15:35:42 +0530 Subject: [PATCH 10/12] Added responsiveness to the media list --- app/assets/css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 861aba35f..1f6086636 100755 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -53,7 +53,7 @@ li #bp-media-upload-ui #bp-media-album-prompt{margin: 12px auto 0;max-width: 144 li #bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px;text-decoration: none;margin-top: 5px;} #bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;margin: 10px 0;} li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: none;} -.albums li #bp-media-album-prompt > p,li #bp-media-upload-ui .drag-drop-space p{display: block;} +.albums li #bp-media-album-prompt > p,.albums li #bp-media-upload-ui .drag-drop-space p{display: block;} li #bp-media-upload-ui .drag-drop-space p.drag-drop-buttons{display: block;} #bp-media-album-prompt div.hide{display: none;margin: 0;} #bp-media-album-prompt > p{font-size: 20px;} From 137cfb058c9bcc169b488e1a5b8fe947fa578a2f Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 17:44:16 +0530 Subject: [PATCH 11/12] Finished media type control on Profile --- app/main/BPMediaComponent.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main/BPMediaComponent.php b/app/main/BPMediaComponent.php index e3ae66a54..38d5652b1 100755 --- a/app/main/BPMediaComponent.php +++ b/app/main/BPMediaComponent.php @@ -125,13 +125,12 @@ function setup_nav() { } /* Create the main navigation on profile */ - echo $default_tab; $main_nav = array( 'name' => __(BP_MEDIA_LABEL, BP_MEDIA_TXT_DOMAIN), 'slug' => BP_MEDIA_SLUG, 'position' => 80, 'screen_function' => array(${'bp_media_'.$default_tab}, 'screen'), - 'default_subnav_slug' => constant('BP_MEDIA_'.strtoupper($default_tab).'_SLUG') + 'default_subnav_slug' => constant('BP_MEDIA_'.strtoupper($defaults_tab).'_SLUG') ); /* Create an empty sub navigation */ From b24ab3c9b4bd718baa4176fcfbafcd529625b292 Mon Sep 17 00:00:00 2001 From: yapapaya Date: Wed, 13 Feb 2013 18:19:37 +0530 Subject: [PATCH 12/12] fixed albums screen --- app/main/BPMediaComponent.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/main/BPMediaComponent.php b/app/main/BPMediaComponent.php index 38d5652b1..72fbf93a8 100755 --- a/app/main/BPMediaComponent.php +++ b/app/main/BPMediaComponent.php @@ -75,10 +75,7 @@ function setup_nav() { $defaults_tab = $bp_media->defaults_tab(); /* Upload Screen */ - $bp_media_upload = new BPMediaUploadScreen( - 'upload', - BP_MEDIA_UPLOAD_SLUG - ); + /* Media Screens */ foreach ($enabled as $tab=>$active){ @@ -87,7 +84,17 @@ function setup_nav() { if($tabs!='audio'&&$tabs!='upload'){ $tabs .= 's'; } - if($tab!='upload'){ + if($tab=='upload'){ + ${'bp_media_'.$tab} = new BPMediaUploadScreen( + $tab, + constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG') + ); + }elseif($tab=='album'){ + $bp_media_album = new BPMediaAlbumScreen( + $tab, + constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG') + ); + }else{ ${'bp_media_'.$tab} = new BPMediaScreen( $tab, constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG')