rtMedia for WordPress, BuddyPress and bbPress - Version 2.4

Version Description

  • Total code overhaul. Fixed a lot of bugs and optimised a lot of other code.
  • Added proper translation support!
  • Removed extra jQuery UI scripts and styles, for speed and optimisation
Download this release

Release Info

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

Code changes from version 2.3.2 to 2.4

Files changed (167) hide show
  1. app/admin/BPMediaAdmin.php +292 -0
  2. includes/css/bp-media-style.css → app/assets/css/main.css +60 -26
  3. app/assets/img/Popup-title-bg.png +0 -0
  4. {includes → app/assets}/img/audio_thumb.png +0 -0
  5. {includes → app/assets}/img/bp_media_social.png +0 -0
  6. {includes → app/assets}/img/bpm-icon-16.png +0 -0
  7. {includes → app/assets}/img/bpm-icon-32.png +0 -0
  8. app/assets/img/coming-soon.png +0 -0
  9. {includes → app/assets}/img/donate.gif +0 -0
  10. {includes → app/assets}/img/donate.png +0 -0
  11. {includes → app/assets}/img/image_thumb.png +0 -0
  12. app/assets/img/loader.gif +0 -0
  13. {includes → app/assets}/img/logo_medibp_32.png +0 -0
  14. {includes → app/assets}/img/rtCamp-bullet.png +0 -0
  15. {includes → app/assets}/img/rtcamp-logo.png +0 -0
  16. {includes → app/assets}/img/video_thumb.png +0 -0
  17. app/assets/js/admin.js +70 -0
  18. app/assets/js/bp-media-uploader.js +128 -0
  19. app/assets/js/main.js +102 -0
  20. app/helper/BPMediaAddon.php +93 -0
  21. app/helper/BPMediaBranding.php +20 -0
  22. app/helper/BPMediaFeed.php +56 -0
  23. app/helper/BPMediaLog.php +19 -0
  24. app/helper/BPMediaSettings.php +200 -0
  25. app/helper/BPMediaSupport.php +186 -0
  26. app/helper/BPMediaUpgrade.php +174 -0
  27. app/helper/BPMediaWidget.php +29 -0
  28. app/main/BPMediaLoader.php +72 -0
  29. app/main/BuddyPressMedia.php +296 -0
  30. app/main/group/BPMediaGroup.php +211 -0
  31. app/main/group/BPMediaGroupAction.php +128 -0
  32. app/main/group/BPMediaGroupElementExtension.php +124 -0
  33. app/main/group/BPMediaGroupsExtension.php +136 -0
  34. app/main/group/dummy/BPMediaGroupAlbum.php +17 -0
  35. app/main/group/dummy/BPMediaGroupImage.php +17 -0
  36. app/main/group/dummy/BPMediaGroupMusic.php +17 -0
  37. app/main/group/dummy/BPMediaGroupVideo.php +17 -0
  38. app/main/includes/BPMediaActions.php +582 -0
  39. app/main/includes/BPMediaComponent.php +366 -0
  40. app/main/includes/BPMediaFilters.php +377 -0
  41. app/main/includes/BPMediaFunction.php +236 -0
  42. includes/bp-media-class-wordpress.php → app/main/includes/BPMediaHostWordpress.php +60 -55
  43. app/main/includes/BPMediaTemplateFunctions.php +283 -0
  44. app/main/includes/BPMediaUpgradeScript.php +125 -0
  45. app/main/includes/BPMediaUtils.php +806 -0
  46. includes/lib/bootstrap.php → app/main/includes/bp-media-upload-handler.php +13 -12
  47. includes/bp-media-class-album.php → app/main/profile/BPMediaAlbum.php +19 -18
  48. app/main/profile/BPMediaAlbumScreen.php +147 -0
  49. app/main/profile/BPMediaScreen.php +411 -0
  50. app/main/profile/BPMediaTemplate.php +214 -0
  51. app/main/profile/BPMediaUploadScreen.php +140 -0
  52. app/main/widgets/BPMediaPopularMedia.php +93 -0
  53. app/main/widgets/BPMediaRecentMedia.php +202 -0
  54. config/index.php +6 -0
  55. includes/bp-media-actions.php +0 -589
  56. includes/bp-media-admin.php +0 -530
  57. includes/bp-media-filters.php +0 -369
  58. includes/bp-media-functions.php +0 -265
  59. includes/bp-media-groups-actions.php +0 -118
  60. includes/bp-media-groups-loader.php +0 -333
  61. includes/bp-media-groups-screens.php +0 -172
  62. includes/bp-media-loader.php +0 -537
  63. includes/bp-media-screens.php +0 -627
  64. includes/bp-media-shortcodes.php +0 -53
  65. includes/bp-media-template-functions.php +0 -282
  66. includes/bp-media-upgrade-script.php +0 -120
  67. includes/bp-media-upload-handler.php +0 -12
  68. includes/bp-media-widgets.php +0 -293
  69. includes/css/bp-media-admin.css +0 -39
  70. includes/css/bp-media-uploader.css +0 -98
  71. includes/js/bp-media-uploader.js +0 -113
  72. includes/js/bp-media.js +0 -109
  73. index.php +69 -0
  74. lang/buddypress-media.po +872 -0
  75. {includes/lib → lib}/getid3/extension.cache.dbm.php +0 -0
  76. {includes/lib → lib}/getid3/extension.cache.mysql.php +0 -0
  77. {includes/lib → lib}/getid3/getid3.lib.php +0 -0
  78. {includes/lib → lib}/getid3/getid3.php +0 -0
  79. {includes/lib → lib}/getid3/module.archive.gzip.php +0 -0
  80. {includes/lib → lib}/getid3/module.archive.rar.php +0 -0
  81. {includes/lib → lib}/getid3/module.archive.szip.php +0 -0
  82. {includes/lib → lib}/getid3/module.archive.tar.php +0 -0
  83. {includes/lib → lib}/getid3/module.archive.zip.php +0 -0
  84. {includes/lib → lib}/getid3/module.audio-video.asf.php +0 -0
  85. {includes/lib → lib}/getid3/module.audio-video.bink.php +0 -0
  86. {includes/lib → lib}/getid3/module.audio-video.flv.php +0 -0
  87. {includes/lib → lib}/getid3/module.audio-video.matroska.php +0 -0
  88. {includes/lib → lib}/getid3/module.audio-video.mpeg.php +0 -0
  89. {includes/lib → lib}/getid3/module.audio-video.nsv.php +0 -0
  90. {includes/lib → lib}/getid3/module.audio-video.quicktime.php +0 -0
  91. {includes/lib → lib}/getid3/module.audio-video.real.php +0 -0
  92. {includes/lib → lib}/getid3/module.audio-video.riff.php +0 -0
  93. {includes/lib → lib}/getid3/module.audio-video.swf.php +0 -0
  94. {includes/lib → lib}/getid3/module.audio.aa.php +0 -0
  95. {includes/lib → lib}/getid3/module.audio.aac.php +0 -0
  96. {includes/lib → lib}/getid3/module.audio.ac3.php +0 -0
  97. {includes/lib → lib}/getid3/module.audio.au.php +0 -0
  98. {includes/lib → lib}/getid3/module.audio.avr.php +0 -0
  99. {includes/lib → lib}/getid3/module.audio.bonk.php +0 -0
  100. {includes/lib → lib}/getid3/module.audio.dss.php +0 -0
  101. {includes/lib → lib}/getid3/module.audio.dts.php +0 -0
  102. {includes/lib → lib}/getid3/module.audio.flac.php +0 -0
  103. {includes/lib → lib}/getid3/module.audio.la.php +0 -0
  104. {includes/lib → lib}/getid3/module.audio.lpac.php +0 -0
  105. {includes/lib → lib}/getid3/module.audio.midi.php +0 -0
  106. {includes/lib → lib}/getid3/module.audio.mod.php +0 -0
  107. {includes/lib → lib}/getid3/module.audio.monkey.php +0 -0
  108. {includes/lib → lib}/getid3/module.audio.mp3.php +0 -0
  109. {includes/lib → lib}/getid3/module.audio.mpc.php +0 -0
  110. {includes/lib → lib}/getid3/module.audio.ogg.php +0 -0
  111. {includes/lib → lib}/getid3/module.audio.optimfrog.php +0 -0
  112. {includes/lib → lib}/getid3/module.audio.rkau.php +0 -0
  113. {includes/lib → lib}/getid3/module.audio.shorten.php +0 -0
  114. {includes/lib → lib}/getid3/module.audio.tta.php +0 -0
  115. {includes/lib → lib}/getid3/module.audio.voc.php +0 -0
  116. {includes/lib → lib}/getid3/module.audio.vqf.php +0 -0
  117. {includes/lib → lib}/getid3/module.audio.wavpack.php +0 -0
  118. {includes/lib → lib}/getid3/module.graphic.bmp.php +0 -0
  119. {includes/lib → lib}/getid3/module.graphic.efax.php +0 -0
  120. {includes/lib → lib}/getid3/module.graphic.gif.php +0 -0
  121. {includes/lib → lib}/getid3/module.graphic.jpg.php +0 -0
  122. {includes/lib → lib}/getid3/module.graphic.pcd.php +0 -0
  123. {includes/lib → lib}/getid3/module.graphic.png.php +0 -0
  124. {includes/lib → lib}/getid3/module.graphic.svg.php +0 -0
  125. {includes/lib → lib}/getid3/module.graphic.tiff.php +0 -0
  126. {includes/lib → lib}/getid3/module.misc.cue.php +0 -0
  127. {includes/lib → lib}/getid3/module.misc.exe.php +0 -0
  128. {includes/lib → lib}/getid3/module.misc.iso.php +0 -0
  129. {includes/lib → lib}/getid3/module.misc.msoffice.php +0 -0
  130. {includes/lib → lib}/getid3/module.misc.par2.php +0 -0
  131. {includes/lib → lib}/getid3/module.misc.pdf.php +0 -0
  132. {includes/lib → lib}/getid3/module.tag.apetag.php +0 -0
  133. {includes/lib → lib}/getid3/module.tag.id3v1.php +0 -0
  134. {includes/lib → lib}/getid3/module.tag.id3v2.php +0 -0
  135. {includes/lib → lib}/getid3/module.tag.lyrics3.php +0 -0
  136. {includes/lib → lib}/getid3/module.tag.xmp.php +0 -0
  137. {includes/lib → lib}/getid3/write.apetag.php +0 -0
  138. {includes/lib → lib}/getid3/write.id3v1.php +0 -0
  139. {includes/lib → lib}/getid3/write.id3v2.php +0 -0
  140. {includes/lib → lib}/getid3/write.lyrics3.php +0 -0
  141. {includes/lib → lib}/getid3/write.metaflac.php +0 -0
  142. {includes/lib → lib}/getid3/write.php +0 -0
  143. {includes/lib → lib}/getid3/write.real.php +0 -0
  144. {includes/lib → lib}/getid3/write.vorbiscomment.php +0 -0
  145. lib/index.php +8 -0
  146. {includes → lib}/media-element/background.png +0 -0
  147. {includes → lib}/media-element/bigplay.png +0 -0
  148. {includes → lib}/media-element/controls-ted.png +0 -0
  149. {includes → lib}/media-element/controls-wmp-bg.png +0 -0
  150. {includes → lib}/media-element/controls-wmp.png +0 -0
  151. {includes → lib}/media-element/controls.png +0 -0
  152. {includes → lib}/media-element/flashmediaelement.swf +0 -0
  153. {includes → lib}/media-element/jquery.js +0 -0
  154. {includes → lib}/media-element/loading.gif +0 -0
  155. {includes → lib}/media-element/mediaelement-and-player.js +0 -0
  156. {includes → lib}/media-element/mediaelement-and-player.min.js +0 -0
  157. {includes → lib}/media-element/mediaelement.js +0 -0
  158. {includes → lib}/media-element/mediaelement.min.js +0 -0
  159. {includes → lib}/media-element/mediaelementplayer.css +0 -0
  160. {includes → lib}/media-element/mediaelementplayer.js +0 -0
  161. {includes → lib}/media-element/mediaelementplayer.min.css +0 -0
  162. {includes → lib}/media-element/mediaelementplayer.min.js +0 -0
  163. {includes → lib}/media-element/mejs-skins.css +0 -0
  164. {includes → lib}/media-element/silverlightmediaelement.xap +0 -0
  165. loader.php +0 -155
  166. log/index.php +9 -0
  167. readme.txt +10 -5
app/admin/BPMediaAdmin.php ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaAdmin
4
+ *
5
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaAdmin')) {
9
+
10
+ class BPMediaAdmin {
11
+
12
+ public $bp_media_upgrade;
13
+ public $bp_media_settings;
14
+ public $bp_media_feed;
15
+
16
+ public function __construct() {
17
+ $bp_media_feed = new BPMediaFeed();
18
+ add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
19
+ $bp_media_support = new BPMediaSupport();
20
+ add_action('wp_ajax_bp_media_select_request', array($bp_media_support, 'get_form'), 1);
21
+ add_action('wp_ajax_cancel_request', create_function('', 'do_settings_sections("bp-media-support"); die();'), 1);
22
+ add_action('wp_ajax_bp_media_submit_request', array($bp_media_support, 'submit_request'), 1);
23
+ add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
24
+ if (is_admin()) {
25
+ add_action('admin_enqueue_scripts', array($this, 'ui'));
26
+ add_action(bp_core_admin_hook(), array($this, 'menu'));
27
+ if (current_user_can('manage_options'))
28
+ add_action('bp_admin_tabs', array($this, 'tab'));
29
+ if (is_multisite())
30
+ add_action('network_admin_edit_bp_media_options', array($this, 'save_multisite_options'));
31
+ }
32
+ $this->bp_media_upgrade = new BPMediaUpgrade();
33
+ $this->bp_media_settings = new BPMediaSettings();
34
+ }
35
+
36
+ /**
37
+ * Generates the Admin UI
38
+ *
39
+ * @param string $hook
40
+ */
41
+ public function ui($hook) {
42
+ $admin_ajax = admin_url('admin-ajax.php');
43
+ wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js');
44
+ wp_localize_script('bp-media-admin', 'bp_media_admin_ajax', $admin_ajax);
45
+ wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css');
46
+ }
47
+
48
+ /**
49
+ * Admin Menu
50
+ *
51
+ * @global string BP_MEDIA_TXT_DOMAIN
52
+ */
53
+ public function menu() {
54
+ 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'));
55
+ 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'));
56
+ 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'));
57
+ 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'));
58
+ }
59
+
60
+ /**
61
+ * Render the BuddyPress Media Settings page
62
+ */
63
+ public function settings_page() {
64
+ $this->render_page('bp-media-settings', true);
65
+ }
66
+
67
+ /**
68
+ * Render the BuddyPress Media Addons page
69
+ */
70
+ public function addons_page() {
71
+ $this->render_page('bp-media-addons');
72
+ }
73
+
74
+ /**
75
+ * Render the BuddyPress Media Support page
76
+ */
77
+ public function support_page() {
78
+ $this->render_page('bp-media-support');
79
+ }
80
+
81
+ static function get_current_tab() {
82
+ return isset($_GET['page']) ? $_GET['page'] : "bp-media-settings";
83
+ }
84
+
85
+ /**
86
+ * Render BPMedia Settings
87
+ *
88
+ * @global string BP_MEDIA_TXT_DOMAIN
89
+ */
90
+ public function render_page($page, $is_settings = false) {
91
+ ?>
92
+
93
+ <div class="wrap bp-media-admin <?php echo $this->get_current_tab(); ?>">
94
+ <div id="icon-buddypress" class="icon32"><br></div>
95
+ <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs(__('Media', BP_MEDIA_TXT_DOMAIN)); ?></h2>
96
+ <?php settings_errors(); ?>
97
+ <div class="columns-2">
98
+ <h3 class="bp-media-settings-tabs"><?php
99
+ $this->sub_tabs();
100
+ ?>
101
+ </h3>
102
+
103
+ <div id="bp-media-settings-boxes">
104
+ <?php
105
+ $settings_url = ( is_multisite() ) ? network_admin_url('network/edit.php?action=bp_media_options') : 'options.php';
106
+ ?>
107
+ <form id="bp_media_settings_form" name="bp_media_settings_form" action="<?php echo $settings_url; ?>" method="post" enctype="multipart/form-data">
108
+ <div class="bp-media-metabox-holder"><?php
109
+ // if (isset($_REQUEST['request_type'])) {
110
+ // bp_media_bug_report_form($_REQUEST['request_type']);
111
+ // } else {
112
+ if ($is_settings) {
113
+ settings_fields('bp_media');
114
+ do_settings_sections($page);
115
+ submit_button();
116
+ } else {
117
+ do_settings_sections($page);
118
+ }
119
+ ?>
120
+ </div>
121
+
122
+ </form>
123
+ </div><!-- .bp-media-settings-boxes -->
124
+ <div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
125
+ <?php $this->admin_sidebar(); ?>
126
+ </div>
127
+ </div><!-- .metabox-holder -->
128
+ </div><!-- .bp-media-admin --><?php
129
+ }
130
+
131
+ /**
132
+ * Adds a tab for Media settings in the BuddyPress settings page
133
+ *
134
+ * @global type $bp_media
135
+ */
136
+ public function tab() {
137
+
138
+ $tabs_html = '';
139
+ $idle_class = 'nav-tab';
140
+ $active_class = 'nav-tab nav-tab-active';
141
+ $tabs = array();
142
+
143
+ // Check to see which tab we are on
144
+ $tab = $this->get_current_tab();
145
+ /* BuddyPress Media */
146
+ $tabs[] = array(
147
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
148
+ 'title' => __('Buddypress Media', BP_MEDIA_TXT_DOMAIN),
149
+ 'name' => __('Buddypress Media', BP_MEDIA_TXT_DOMAIN),
150
+ 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
151
+ );
152
+
153
+ foreach ($tabs as $tab) {
154
+ $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
155
+ }
156
+ echo $tabs_html;
157
+ }
158
+
159
+ /**
160
+ * Adds a sub tabs to the BuddyPress Media settings page
161
+ *
162
+ * @global type $bp_media
163
+ */
164
+ public function sub_tabs() {
165
+ $tabs_html = '';
166
+ $idle_class = 'nav-tab';
167
+ $active_class = 'nav-tab nav-tab-active';
168
+ $tabs = array();
169
+
170
+ // Check to see which tab we are on
171
+ $tab = $this->get_current_tab();
172
+ /* BuddyPress Media */
173
+ $tabs[] = array(
174
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
175
+ 'title' => __('Buddypress Media Settings', BP_MEDIA_TXT_DOMAIN),
176
+ 'name' => __('Settings', BP_MEDIA_TXT_DOMAIN),
177
+ 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
178
+ );
179
+
180
+ $tabs[] = array(
181
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
182
+ 'title' => __('Buddypress Media Addons', BP_MEDIA_TXT_DOMAIN),
183
+ 'name' => __('Addons', BP_MEDIA_TXT_DOMAIN),
184
+ 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
185
+ );
186
+
187
+ $tabs[] = array(
188
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
189
+ 'title' => __('Buddypress Media Support', BP_MEDIA_TXT_DOMAIN),
190
+ 'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
191
+ 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
192
+ );
193
+
194
+ $i = '1';
195
+ foreach ($tabs as $tab) {
196
+ $tabs_html.= '<a title="' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
197
+ $i++;
198
+ }
199
+ echo $tabs_html;
200
+ }
201
+
202
+ /*
203
+ * Updates the media count of all users.
204
+ */
205
+
206
+ public function update_count() {
207
+ global $wpdb;
208
+ $query =
209
+ "SELECT
210
+ post_author,
211
+ SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
212
+ SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
213
+ SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
214
+ SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums,
215
+ COUNT(*) as Total
216
+ FROM
217
+ $wpdb->posts RIGHT JOIN $wpdb->postmeta on wp_postmeta.post_id = wp_posts.id
218
+ WHERE
219
+ `meta_key` = 'bp-media-key' AND
220
+ `meta_value` > 0 AND
221
+ ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
222
+ GROUP BY post_author";
223
+ $result = $wpdb->get_results($query);
224
+ if (!is_array($result))
225
+ return false;
226
+
227
+ foreach ($result as $obj) {
228
+
229
+ $count = array(
230
+ 'images' => isset($obj->Images) ? $obj->Images : 0,
231
+ 'videos' => isset($obj->Videos) ? $obj->Videos : 0,
232
+ 'audio' => isset($obj->Audio) ? $obj->Audio : 0,
233
+ 'albums' => isset($obj->Albums) ? $obj->Albums : 0
234
+ );
235
+ bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
236
+ }
237
+ return true;
238
+ }
239
+
240
+ /* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
241
+
242
+ public function save_multisite_options() {
243
+ update_site_option('bp_media_options', $_POST['bp_media_options']);
244
+ // redirect to settings page in network
245
+ wp_redirect(
246
+ add_query_arg(
247
+ array('page' => 'bp-media-settings', 'updated' => 'true'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
248
+ )
249
+ );
250
+ exit;
251
+ }
252
+
253
+ /* Admin Sidebar */
254
+
255
+ public function admin_sidebar() {
256
+ global $bp_media;
257
+ $branding = '<a href="http://rtcamp.com" title="' . __('Empowering The Web With WordPress', BP_MEDIA_TXT_DOMAIN) . '" id="logo"><img src="' . BP_MEDIA_URL . 'app/assets/img/rtcamp-logo.png" alt="' . __('rtCamp', BP_MEDIA_TXT_DOMAIN) . '" /></a>
258
+ <ul id="social">
259
+ <li><a href="' . sprintf('%s', 'http://www.facebook.com/rtCamp.solutions/') . '" title="' . __('Become a fan on Facebook', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-facebook bp-media-social">' . __('Facebook', BP_MEDIA_TXT_DOMAIN) . '</a></li>
260
+ <li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-twitter bp-media-social">' . __('Twitter', BP_MEDIA_TXT_DOMAIN) . '</a></li>
261
+ <li><a href="' . sprintf('%s', 'http://feeds.feedburner.com/rtcamp/') . '" title="' . __('Subscribe to our feeds', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-rss bp-media-social">' . __('RSS Feed', BP_MEDIA_TXT_DOMAIN) . '</a></li>
262
+ </ul>';
263
+ new BPMediaWidget('branding', '', $branding);
264
+
265
+ $support = '<p><ul>
266
+ <li>' . sprintf('<a href="%s">' . __("Read FAQ", BP_MEDIA_TXT_DOMAIN) . '</a>', 'http://rtcamp.com/buddypress-media/faq/') . '</li>
267
+ <li>' . sprintf('<a href="%s">' . __("Free Support Forum", BP_MEDIA_TXT_DOMAIN) . '</a>', $bp_media->support_url) . '</li>
268
+ <li>' . sprintf('<a href="%s">' . __("Github Issue Tracker", BP_MEDIA_TXT_DOMAIN) . '</a>', 'https://github.com/rtCamp/buddypress-media/issues/') . '</li>
269
+ <li>' . sprintf('<a href="%s">' . __("Hire us!", BP_MEDIA_TXT_DOMAIN) . '</a> ' . __("To get professional customisation/setup service.", BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/buddypress-media/hire/') . '</li>
270
+ </ul></p>';
271
+ new BPMediaWidget('support', __('Need Help?', BP_MEDIA_TXT_DOMAIN), $support);
272
+
273
+ $donate = '<span><a href="http://rtcamp.com/donate/" title="' . __('Help the development keep going.', BP_MEDIA_TXT_DOMAIN) . '"><img class="bp-media-donation-image" src ="' . BP_MEDIA_URL . 'app/assets/img/donate.gif" /></a></span>
274
+ <p>' . sprintf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', BP_MEDIA_TXT_DOMAIN)) . '</p>';
275
+ new BPMediaWidget('donate', __('Donate', BP_MEDIA_TXT_DOMAIN), $donate);
276
+
277
+ $addons = '<ul>
278
+ <li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="' . __('BuddyPress Media Kaltura', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-Kaltura', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add support for Kaltura.com/Kaltura-CE based video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
279
+ <li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="' . __('BuddyPress Media FFMPEG', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-FFMPEG', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add FFMEG-based audio/video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
280
+ </ul>
281
+ <h4>' . sprintf(__('Are you a developer?', BP_MEDIA_TXT_DOMAIN)) . '</h4>
282
+ <p>' . sprintf(__('If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href="%s">More info!</a>', BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/contact/') . '</p></h4>';
283
+ new BPMediaWidget('premium-addons', __('Premium Addons', BP_MEDIA_TXT_DOMAIN), $addons);
284
+
285
+ $news = '<img src ="' . admin_url('/images/wpspin_light.gif') . '" /> Loading...';
286
+ new BPMediaWidget('latest-news', __('Latest News', BP_MEDIA_TXT_DOMAIN), $news);
287
+ }
288
+
289
+ }
290
+
291
+ }
292
+ ?>
includes/css/bp-media-style.css → app/assets/css/main.css RENAMED
@@ -17,9 +17,9 @@ ul.bp-media-gallery li span img{height: 150px;}
17
  li.media div.activity-content div.activity-inner p{display:none;}
18
  div.bp_media_title{margin-bottom:10px;}
19
  #bp-media-footer {color: #4D4D4D;text-align: center;text-shadow: #FAFAFA 1px 1px 0;}
20
- #wpbody-content div.metabox-fixed{width: 280px;margin-right: -300px;float: right;}
21
  #wpbody-content div.wrap.bp-media-admin .columns-2{margin-right:300px;padding-top: 0;margin-top: 15px;width: 600px}
22
- #wpbody-content .bp-media-settings-tabs{margin-bottom: 15px}
23
  #wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
24
  #wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
25
 
@@ -72,10 +72,10 @@ div.bp_media_title{margin-bottom:10px;}
72
  #adminmenu li.toplevel_page_bp-media-settings:hover .wp-menu-image a,
73
  #adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
74
  #adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
75
- #bp-media-settings-boxes{overflow: hidden;width: 100%;float: left;}
76
  .nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
77
  .nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
78
- .metabox-holder .postbox#bp_media_latest_news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left top no-repeat; padding-left: 19px;}
79
  #branding #logo{text-align:center;padding: 10px 0;display:block;}
80
  ul#social{display:block;text-align:center;margin:0;}
81
  ul#social li{display:inline;}
@@ -89,17 +89,21 @@ ul#activity-stream li.media.album_updated ul li{float: left;margin-right:2%}
89
  #bp-media-addons-list_metabox {background: #ffffff}
90
  .products ul:after, ul.products:after {clear: both;content: "";display: block;}
91
  .products ul, ul.products {clear: both;list-style: none outside none;margin: 0 0 14px;padding: 0;}
92
- .products {margin: 0;}
93
- ul.products li.product.first { }
94
- ul.products li.product {margin: 20px 10px 30px;padding: 0;position: relative;overflow: hidden}
95
- ul.products li.product h4 {background: none repeat scroll 0 0 transparent;border: 0 none;color: #006999;cursor: pointer;font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size: 20px;font-weight: normal;line-height: 26px;margin: 0 0 10px;}
96
- ul.products li.product a {text-decoration: none;}
97
- ul.products li.product a img, div.product div.images img {box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);}
98
- ul.products li.product a img {box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.3);display: block;height: auto;margin: 5px 15px 5px 5px;transition: all 0.2s ease-in-out 0s;float: left; width: 200px}
99
-
100
- ul.products li.product .price, ul.products li.product .price .amount, ul.products li.product .price ins {color: #85AD74;font-size: 25px;font-weight: bold;}
101
- ul.products li.product .price {line-height: 1.4em;color: #85AD74;display: block;font-weight: normal;margin-bottom: 0.5em;}
102
- /*ul.products li.product .add_to_cart_button{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
 
 
 
 
103
  background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
104
  background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
105
  background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
@@ -107,31 +111,61 @@ background-image: -ms-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
107
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #F7F6F7),color-stop(1, #DFDBDF));
108
  border: 1px solid #C7C0C7;border-radius: 2px 2px 2px 2px;box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.075) inset, 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 2px rgba(0, 0, 0, 0.1);color: #5E5E5E;cursor: pointer;font-family: inherit;font-size: 14px;font-weight: bold;float: right;left: auto;margin: 0;overflow: visible;padding: 6px 10px;position: relative;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;}
109
 
110
- ul.products li.product .add_to_cart_button:hover{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
111
  background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
112
  background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
113
  background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
114
  background-image: -ms-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
115
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(1, #F7F6F7),color-stop(1, #D3CED3));}
116
  */
117
- ul.products li.product .product_footer{margin: 20px 0 0;overflow: hidden;}
118
- ul.products li.product .add_to_cart_button{background: #C45200; color: #FFFFFF;display: inline-block;font-size: 18px;font-weight: bold; line-height: 1.4em; margin: 0 20px; padding: 4px 15px;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6)}
119
- ul.products li.product .product_footer .product_demo_link{font-size: 16px;margin: 8px 20px; font-weight: bold}
120
 
121
- ul.products li.product .add_to_cart_button:hover{background: none repeat scroll 0 0 #D75A00;
122
- box-shadow: 0 1px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.4) inset;
123
- color: #FFFFFF;}
124
 
125
  /* Admin bar Menu */
126
  #wpadminbar .bp-media-settings-menu > .ab-item .ab-icon{background: url("../img/bpm-icon-16.png") no-repeat scroll -8px -7px transparent}
127
  #wpadminbar .bp-media-settings-menu:hover .ab-icon{background-position: -8px -41px}
128
 
129
-
 
 
 
 
130
  .bp-media-form li{margin-bottom: 10px}
131
- .bp-media-form .bp-media-label{ display: inline-block;margin-right: 10px;width: 150px;vertical-align: top}
132
  .bp-media-form .bp-media-input{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;line-height: 16px;padding: 5px;width: 220px;}
133
- .bp-media-form .bp-media-textarea{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;line-height: 16px;padding: 5px;width: 220px;}
 
 
 
 
 
 
 
 
 
 
134
  #normal-sortables .postbox .bp-media-form .submit{float: none; margin-left: 150px}
135
  .rt-success{background-color: #E1FFDF;border-color: #2ACF2A;}
136
  .rt-update{background-color: #FFEAA6;border-color:#E1CA82;}
137
- img.bp-media-donation-image{display:block;margin: 10px auto;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  li.media div.activity-content div.activity-inner p{display:none;}
18
  div.bp_media_title{margin-bottom:10px;}
19
  #bp-media-footer {color: #4D4D4D;text-align: center;text-shadow: #FAFAFA 1px 1px 0;}
20
+ #wpbody-content div.metabox-fixed{width: 280px;margin-right: -300px;float: right;}
21
  #wpbody-content div.wrap.bp-media-admin .columns-2{margin-right:300px;padding-top: 0;margin-top: 15px;width: 600px}
22
+ #wpbody-content .bp-media-settings-tabs{margin-bottom: 0; }
23
  #wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
24
  #wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
25
 
72
  #adminmenu li.toplevel_page_bp-media-settings:hover .wp-menu-image a,
73
  #adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
74
  #adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
75
+ #bp-media-settings-boxes{border:1px solid #CCC; overflow: hidden; padding: 10px; -webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px; float: left; width: 98%;}
76
  .nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
77
  .nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
78
+ .metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left top no-repeat; padding-left: 19px;}
79
  #branding #logo{text-align:center;padding: 10px 0;display:block;}
80
  ul#social{display:block;text-align:center;margin:0;}
81
  ul#social li{display:inline;}
89
  #bp-media-addons-list_metabox {background: #ffffff}
90
  .products ul:after, ul.products:after {clear: both;content: "";display: block;}
91
  .products ul, ul.products {clear: both;list-style: none outside none;margin: 0 0 14px;padding: 0;}
92
+ .bp-media-addon {margin: 0;}
93
+ .bp-media-addon.first { }
94
+ .bp-media-addon {margin: 20px 10px 30px;padding: 5px;position: relative;border: 1px solid #ccc;}
95
+ .bp-media-addon h4 {background: none repeat scroll 0 0 transparent;border: 0 none;color: #006999;cursor: pointer;font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size: 20px;font-weight: normal;line-height: 26px;margin: 0 0 10px;}
96
+ .bp-media-addon a {text-decoration: none;}
97
+ .bp-media-addon a img, div.product div.images img {box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);}
98
+ .bp-media-addon a img {display: block;height: auto;margin: 5px 15px 5px 5px;transition: all 0.2s ease-in-out 0s;float: left; width: 200px}
99
+
100
+ .bp-media-addon .price, .bp-media-addon .price .amount, .bp-media-addon .price ins {color: #85AD74;font-size: 25px;font-weight: bold;}
101
+ .bp-media-addon .price {line-height: 1.4em;color: #85AD74;display: block;font-weight: normal;margin-bottom: 0.5em;}
102
+ .coming-soon { background: url("../img/coming-soon.png"); z-index: 5; position:absolute;height:191px; opacity:0.9;}
103
+ .coming-soon.coming-soon-l { background-position: 0 0; width:250px; top:-12px; left:-18px;}
104
+ .coming-soon.coming-soon-r { background-position: 347px 0; width:174px; bottom:-14px; right:-12px;}
105
+ .coming-soon.coming-soon-r:hover{background-position: 175px 0;}
106
+ /*.bp-media-addon .add_to_cart_button{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
107
  background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
108
  background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
109
  background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
111
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #F7F6F7),color-stop(1, #DFDBDF));
112
  border: 1px solid #C7C0C7;border-radius: 2px 2px 2px 2px;box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.075) inset, 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 2px rgba(0, 0, 0, 0.1);color: #5E5E5E;cursor: pointer;font-family: inherit;font-size: 14px;font-weight: bold;float: right;left: auto;margin: 0;overflow: visible;padding: 6px 10px;position: relative;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;}
113
 
114
+ .bp-media-addon .add_to_cart_button:hover{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
115
  background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
116
  background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
117
  background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
118
  background-image: -ms-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
119
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(1, #F7F6F7),color-stop(1, #D3CED3));}
120
  */
121
+ .bp-media-addon .product_footer{margin: 20px 0 0;overflow: hidden;}
122
+ .bp-media-addon .add_to_cart_button{background: #C45200; color: #FFFFFF;display: inline-block;font-size: 18px;font-weight: bold; line-height: 1.4em; margin: 0 20px; padding: 4px 15px;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6)}
123
+ .bp-media-addon .product_footer .product_demo_link{font-size: 16px;margin: 8px 20px; font-weight: bold}
124
 
125
+ .bp-media-addon .add_to_cart_button:hover{background: none repeat scroll 0 0 #D75A00;
126
+ box-shadow: 0 1px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.4) inset;
127
+ color: #FFFFFF;}
128
 
129
  /* Admin bar Menu */
130
  #wpadminbar .bp-media-settings-menu > .ab-item .ab-icon{background: url("../img/bpm-icon-16.png") no-repeat scroll -8px -7px transparent}
131
  #wpadminbar .bp-media-settings-menu:hover .ab-icon{background-position: -8px -41px}
132
 
133
+ /* Buddypress media admin support form styling */
134
+ .bp-media-updated, .bp-media-error{border-radius: 3px; padding: 0 7px; margin: 5px 0 15px; border: 1px solid}
135
+ .bp-media-updated p, .bp-media-error p{margin: 0.5em 0;padding: 2px;}
136
+ .bp-media-updated{background-color: #FFFFE0;border-color: #E6DB55;}
137
+ .bp-media-error{background-color: #FFEBE8;border-color: #CC0000;}
138
  .bp-media-form li{margin-bottom: 10px}
139
+ .bp-media-form .bp-media-label{display: inline-block;margin-right: 10px;width: 150px;vertical-align: top; }
140
  .bp-media-form .bp-media-input{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;line-height: 16px;padding: 5px;width: 220px;}
141
+ .bp-media-form .bp-media-checkbox{margin-right: 10px; margin-left: 160px}
142
+ .bp-media-form .bp-media-textarea{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;height: 175px;line-height: 16px;padding: 5px;width: 400px;}
143
+ .bp-media-form .bp-media-select{margin: 0;max-width: 400px;}
144
+ .bp-media-support-attachment label{float: left}
145
+ .bp-media-support-attachment .more-attachment{margin-left: 160px; margin-top: 10px}
146
+ .bp-media-support-attachment .more-attachment:first-child{margin-top: 0px}
147
+ .bp-media-support-attachment .add-more-attachment-btn{clear: both;display: inline-block;margin-left: 160px;margin-top: 10px;}
148
+ .template_select_label{float: left}
149
+ .template_select_container{overflow-x:scroll; width:405px;float: left}
150
+ #bp_media_settings_form .support_form_laoder{height: 100px; width: 200px; background: url("../img/loader.gif") no-repeat }
151
+ /* Miscellinus */
152
  #normal-sortables .postbox .bp-media-form .submit{float: none; margin-left: 150px}
153
  .rt-success{background-color: #E1FFDF;border-color: #2ACF2A;}
154
  .rt-update{background-color: #FFEAA6;border-color:#E1CA82;}
155
+ img.bp-media-donation-image{display:block;margin: 10px auto;}
156
+
157
+ /* Buddypress Media Image Uploader album selection */
158
+ #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; }
159
+ #bp-media-album-new { z-index: 120000; }
160
+ .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; }
161
+ .bp-media-album-title span { background: none repeat scroll 0 0 transparent;display: block;font-size: 16px;padding: 10px; }
162
+ #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; }
163
+ #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; }
164
+ .bp-media-album-content { display: block;padding: 5px; }
165
+ .bp-media-album-content label { display: block;font-size: 14px;margin: 0 0 0 3px; }
166
+ #bp-media-album-prompt select { min-width: 140px; }
167
+ .select-btn-div { border-top: 1px solid #AAAAAA;margin: 15px 0 0;padding: 5px 5px 5px 30px;text-align: right; }
168
+ .select-btn-div .btn { float: right;font-size: 14px;margin: 5px;padding: 10px 25px; }
169
+ #bp-media-album-new > label { font-size: 14px; }
170
+ #bp-media-album-new input[type="text"] { width: 98%; }
171
+ #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; }
app/assets/img/Popup-title-bg.png ADDED
Binary file
{includes → app/assets}/img/audio_thumb.png RENAMED
File without changes
{includes → app/assets}/img/bp_media_social.png RENAMED
File without changes
{includes → app/assets}/img/bpm-icon-16.png RENAMED
File without changes
{includes → app/assets}/img/bpm-icon-32.png RENAMED
File without changes
app/assets/img/coming-soon.png ADDED
Binary file
{includes → app/assets}/img/donate.gif RENAMED
File without changes
{includes → app/assets}/img/donate.png RENAMED
File without changes
{includes → app/assets}/img/image_thumb.png RENAMED
File without changes
app/assets/img/loader.gif ADDED
Binary file
{includes → app/assets}/img/logo_medibp_32.png RENAMED
File without changes
{includes → app/assets}/img/rtCamp-bullet.png RENAMED
File without changes
{includes → app/assets}/img/rtcamp-logo.png RENAMED
File without changes
{includes → app/assets}/img/video_thumb.png RENAMED
File without changes
app/assets/js/admin.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function(){
2
+
3
+ /* Fetch Feed */
4
+ var bp_media_news_section = jQuery('#latest-news');
5
+ if(bp_media_news_section.length>0){
6
+ var data = {
7
+ action: 'bp_media_fetch_feed'
8
+ };
9
+ jQuery.post(bp_media_admin_ajax,data,function(response){
10
+ bp_media_news_section.find('.inside').html(response);
11
+ });
12
+ }
13
+
14
+ // /* Add more attachment link */
15
+ // jQuery( '.add-more-attachment-btn' ).live('click', function(event){
16
+ // event.preventDefault();
17
+ // jQuery(this).prev().after('<div class="more-attachment"><input class="bp-media-input" type="file" name="attachment[]" /></div>');
18
+ // });
19
+
20
+ /* Select Request */
21
+ jQuery('#bp-media-settings-boxes').on('change', '#select-request', function(){
22
+ if(jQuery(this).val()){
23
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
24
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html('<div class="support_form_laoder"></div>');
25
+ var data = {
26
+ action: 'bp_media_select_request',
27
+ form: jQuery(this).val()
28
+ };
29
+
30
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
31
+ jQuery.post(ajaxurl, data, function(response) {
32
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
33
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
34
+ });
35
+ }
36
+ });
37
+
38
+ /* Cancel Request */
39
+ jQuery('#bp-media-settings-boxes').on('click', '#cancel-request', function(){
40
+ if(jQuery(this).val()){
41
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
42
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html('<div class="support_form_laoder"></div>');
43
+ var data = {
44
+ action: 'bp_media_cancel_request'
45
+ };
46
+
47
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
48
+ jQuery.post(ajaxurl, data, function(response) {
49
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
50
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
51
+ });
52
+ }
53
+ });
54
+
55
+ /* Submit Request */
56
+ jQuery('.bp-media-support').on('submit', '#bp_media_settings_form', function(e){
57
+ e.preventDefault();
58
+ var data = {
59
+ action: 'bp_media_submit_request',
60
+ form_data: jQuery('form').serialize()
61
+ };
62
+
63
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
64
+ jQuery.post(ajaxurl, data, function(response) {
65
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
66
+ jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
67
+ });
68
+ });
69
+
70
+ });
app/assets/js/bp-media-uploader.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+ jQuery(document).ready(function(){
7
+ jQuery('body').append('<div id="custom-overlay"></div>');
8
+ jQuery('#custom-overlay').hide();
9
+ jQuery('#bp-media-close').click(function(){
10
+ jQuery('#bp-media-album-prompt').hide();
11
+ jQuery('#custom-overlay').hide();
12
+ jQuery('#bp-media-uploaded-files div').remove();
13
+ });
14
+ jQuery('#selected-btn').click(function() {
15
+ bp_media_album_selected = jQuery('#bp-media-selected-album').val();
16
+ jQuery('#bp-media-album-prompt').hide();
17
+ jQuery('#custom-overlay').hide();
18
+ bp_media_uploader.start();
19
+ });
20
+ jQuery('#create-btn').click(function() {
21
+ jQuery('#custom-overlay').css('z-index', 115000);
22
+ jQuery('#bp-media-album-new').show();
23
+ jQuery('#bp-media-album-new').css({
24
+ left: ((jQuery(window).width()-jQuery('#bp-media-album-new').width())/2),
25
+ top: ((jQuery(window).height()-jQuery('#bp-media-album-new').height())/2)
26
+ });
27
+ });
28
+ jQuery('#bp-media-create-album-close').click(function() {
29
+ jQuery('#bp-media-album-new').hide();
30
+ jQuery('#custom-overlay').css('z-index', 105000);
31
+ });
32
+ jQuery(window).resize(function(){
33
+ jQuery('#bp-media-album-prompt').css({
34
+ left: ((jQuery(window).width()-jQuery('#bp-media-album-prompt').width())/2),
35
+ top: ((jQuery(window).height()-jQuery('#bp-media-album-prompt').height())/2)
36
+ });
37
+ jQuery('#bp-media-album-new').css({
38
+ left: ((jQuery(window).width()-jQuery('#bp-media-album-new').width())/2),
39
+ top: ((jQuery(window).height()-jQuery('#bp-media-album-new').height())/2)
40
+ });
41
+ });
42
+ jQuery('#create-album').click(function() {
43
+ var album_name = jQuery('#bp_media_album_name').val();
44
+ if(album_name.length==0){
45
+ alert('You have not filled the album name');
46
+ return false;
47
+ }
48
+ var data = {
49
+ action: 'bp_media_add_album',
50
+ bp_media_album_name : album_name,
51
+ bp_media_group_id : bp_media_uploader_params.multipart_params.bp_media_group_id
52
+ };
53
+ jQuery.post(bp_media_vars.ajaxurl,data,function(response){
54
+ var album = parseInt(response);
55
+ if(album == 0){
56
+ alert('Sorry you cannot create albums in this group');
57
+ }
58
+ else{
59
+ jQuery('#bp-media-selected-album').append('<option value='+album+' selected="selected">'+jQuery('#bp_media_album_name').val()+'</option>')
60
+ jQuery('#bp-media-album-new').hide();
61
+ bp_media_album_selected = jQuery('#bp-media-selected-album').val();
62
+ jQuery('#bp-media-album-prompt').hide();
63
+ jQuery('#custom-overlay').hide();
64
+ bp_media_uploader.start();
65
+ }
66
+ });
67
+ });
68
+
69
+ var bp_media_is_multiple_upload = false;
70
+ if(jQuery('#'+bp_media_uploader_params.container).length==0)
71
+ return false;
72
+ var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
73
+ var bp_media_album_selected = false;
74
+ bp_media_uploader.init();
75
+ bp_media_uploader.bind('FilesAdded', function(up, files) {
76
+ //bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
77
+ bp_media_is_multiple_upload = files.length>1;
78
+ jQuery.each(files, function(i, file) {
79
+ jQuery('#bp-media-uploaded-files').append(
80
+ '<div id="bp-media-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' +
81
+ file.name + ' (' + plupload.formatSize(file.size) + ')(<b></b>)</div><div class="bp-media-progress-completed"></div></div>');
82
+ });
83
+ if(bp_media_album_selected == false){
84
+ jQuery('#bp-media-album-prompt').css({
85
+ left: ((jQuery(window).width()-jQuery('#bp-media-album-prompt').width())/2),
86
+ top: ((jQuery(window).height()-jQuery('#bp-media-album-prompt').height())/2)
87
+ });
88
+ jQuery('#custom-overlay').show();
89
+ jQuery('#bp-media-album-prompt').show();
90
+ } else {
91
+ bp_media_album_selected = jQuery('#bp-media-selected-album').val();
92
+ bp_media_uploader.start();
93
+ }
94
+ up.refresh(); // Reposition Flash/Silverlight
95
+ });
96
+ bp_media_uploader.bind('UploadProgress', function(up, file) {
97
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
98
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
99
+ });
100
+
101
+ bp_media_uploader.bind('Error', function(up, err) {
102
+ jQuery('#bp-media-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
103
+ ', Message: ' + err.message +
104
+ (err.file ? ', File: ' + err.file.name : '') +
105
+ '</p></div>'
106
+ );
107
+ up.refresh();
108
+ });
109
+
110
+ bp_media_uploader.bind('FileUploaded', function(up, file) {
111
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html("100%");
112
+ });
113
+ bp_media_uploader.bind('BeforeUpload',function(up){
114
+ up.settings.multipart_params.is_multiple_upload = bp_media_is_multiple_upload;
115
+ up.settings.multipart_params.bp_media_album_id = bp_media_album_selected;
116
+ });
117
+ bp_media_uploader.bind('UploadComplete',function(){
118
+ var new_location = window.location.href;
119
+ if(new_location.search('/media/')>0){
120
+ new_location = new_location.replace('/media/','/albums/');
121
+ if(bp_media_album_selected>0)
122
+ new_location = new_location.concat(bp_media_album_selected);
123
+ else
124
+ new_location = new_location.concat('0/');
125
+ window.location.replace(new_location);
126
+ }
127
+ });
128
+ });
app/assets/js/main.js ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * BuddyPress Media Default JS
3
+ */
4
+
5
+ function bp_media_create_element(id){
6
+ jQuery('#'+id).mediaelementplayer({
7
+ enableKeyboard: false,
8
+ startVolume: 1,
9
+ success: function(mediaElement,domElement){
10
+ var $thisMediaElement = (mediaElement.id) ? jQuery("#"+mediaElement.id) : jQuery(mediaElement);
11
+ $thisMediaElement.parents('.mejs-container').find(".mejs-volume-current").css("top","8px");
12
+ $thisMediaElement.parents('.mejs-container').find(".mejs-volume-handle").css("top","5px");
13
+ }
14
+ });
15
+ }
16
+
17
+ jQuery(document).ready(function(){
18
+
19
+ var bp_media_recent_tabs = jQuery('#recent-media-tabs');
20
+ if(bp_media_recent_tabs.length>0){
21
+ jQuery(bp_media_recent_tabs).tabs();
22
+ }
23
+
24
+ // var bp_media_popular_tabs = jQuery('#popular-media-tabs');
25
+ // if(bp_media_popular_tabs.length>0){
26
+ // jQuery( bp_media_popular_tabs ).tabs();
27
+ // }
28
+
29
+ var tallest = 0;
30
+ jQuery('#recent-media-tabs .bp-media-tab-panel').each(function() {
31
+
32
+ var thisHeight = jQuery(this).height();
33
+ if(thisHeight > tallest) {
34
+ tallest = thisHeight;
35
+ }
36
+ }).height(tallest);
37
+
38
+
39
+ jQuery('#bp-media-show-more').click(function(e){
40
+ e.preventDefault();
41
+ var data = {
42
+ action: 'bp_media_load_more',
43
+ page:++bp_media_vars.page,
44
+ current_action : bp_media_vars.current_action,
45
+ action_variables : bp_media_vars.action_variables,
46
+ displayed_user : bp_media_vars.displayed_user,
47
+ loggedin_user : bp_media_vars.loggedin_user,
48
+ current_group : bp_media_vars.current_group
49
+ };
50
+
51
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
52
+ jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
53
+ if(response.length==0)
54
+ jQuery('#bp-media-show-more').parent().remove();
55
+ else
56
+ jQuery('#bp-media-list').append(response);
57
+ });
58
+ });
59
+ setTimeout(function(){
60
+ jQuery('.media album_updated .delete-activity,.media_upload .delete-activity').unbind('click').click(function(e){
61
+ if(confirm('Are you sure you want to delete this activity and associated media?')){
62
+ return true;
63
+ }
64
+ else{
65
+ return false;
66
+ }
67
+ });
68
+
69
+ },1000);
70
+
71
+ /* Add Featured Image */
72
+
73
+ jQuery('.bp-media-featured').live('click',function(e){
74
+ e.preventDefault();
75
+ var post_id = jQuery(this).attr('data-post-id');
76
+ var post_date = new Date();
77
+ var date = post_date.getFullYear()+'-'+(post_date.getMonth() + 1) +'-'+post_date.getDate()+' '+ post_date.getHours()+':'+(post_date.getMinutes() + 1)+':'+(post_date.getSeconds()+1);
78
+ // var post_date = d.getTime();
79
+ var curr_obj = jQuery(this);
80
+ var remove_featured = 0;
81
+ if(jQuery(this).attr('data-remove-featured')){
82
+ remove_featured = jQuery(this).attr('data-remove-featured');
83
+ }
84
+ jQuery.ajax({
85
+ url:"/wp-admin/admin-ajax.php",
86
+ type:'POST',
87
+ data:'action=my_featured_action&post_id='+post_id+'&remove_featured='+remove_featured+'&post_date='+date,
88
+ success:function( results )
89
+ {
90
+ if(remove_featured == 1){
91
+ curr_obj.text('Featured');
92
+ curr_obj.attr('data-remove-featured','0');
93
+ } else {
94
+ curr_obj.text('Remove Featured');
95
+ curr_obj.attr('data-remove-featured','1');
96
+ }
97
+
98
+ }
99
+ });
100
+ });
101
+
102
+ });
app/helper/BPMediaAddon.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaAddon
5
+ *
6
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
7
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
8
+ */
9
+ if ( ! class_exists( 'BPMediaAddon' ) ) {
10
+
11
+ class BPMediaAddon {
12
+
13
+ public $enquiry_link = 'http://rtcamp.com/contact';
14
+
15
+ public function coming_soon_div(){
16
+ return
17
+ '<div class="coming-soon coming-soon-l"></div>
18
+ <a class="coming-soon coming-soon-r" href="'.$this->enquiry_link.'" target="_blank">'
19
+ //<a></a>
20
+ .'</a>';
21
+ }
22
+
23
+ public function get_addons() {
24
+ $addons = array(
25
+ array(
26
+ 'title' => __( 'BuddyPress-Media FFMPEG Add-on', BP_MEDIA_TXT_DOMAIN ),
27
+ 'img_src' => 'http://cdn.rtcamp.com/files/2012/09/ffmpeg-logo-240x184.png',
28
+ 'product_link' => 'http://rtcamp.com/store/buddypress-media-ffmpeg-converter/',
29
+ 'desc' => '<p>' . __( 'Add supports for more audio & video formats using open-source media-node.', BP_MEDIA_TXT_DOMAIN ) . '</p>
30
+ <p>' . __( 'Media node comes with automated setup script for Ubuntu/Debian.', BP_MEDIA_TXT_DOMAIN ) . '</p>',
31
+ 'price' => '$49',
32
+ 'demo_link' => 'http://demo.rtcamp.com/bpm-media',
33
+ 'buy_now' => 'http://rtcamp.com/store/?add-to-cart=13677'
34
+ ),
35
+ array(
36
+ 'title' => __( 'BuddyPress-Media Kaltura Add-on', BP_MEDIA_TXT_DOMAIN ),
37
+ 'img_src' => 'http://cdn.rtcamp.com/files/2012/10/new-buddypress-media-kaltura-logo-240x184.png',
38
+ 'product_link' => 'http://rtcamp.com/store/buddypress-media-kaltura/',
39
+ 'desc' => '<p>' . __( 'Add support for more video formats using Kaltura video solution.', BP_MEDIA_TXT_DOMAIN ) . '</p>
40
+ <p>' . __( 'Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.', BP_MEDIA_TXT_DOMAIN ) . '</p>',
41
+ 'price' => '$99',
42
+ 'demo_link' => 'http://demo.rtcamp.com/bpm-kaltura/',
43
+ 'buy_now' => 'http://rtcamp.com/store/?add-to-cart=15446',
44
+ 'coming_soon' => true
45
+ )
46
+ );
47
+ $addons = apply_filters('bp_media_addons',$addons);
48
+ foreach ( $addons as $addon ) {
49
+ $this->addon( $addon );
50
+ }
51
+ }
52
+
53
+ public function addon( $args ) {
54
+ global $bp_media;
55
+
56
+ $defaults = array(
57
+ 'title' => '',
58
+ 'img_src' => '',
59
+ 'product_link' => '',
60
+ 'desc' => '',
61
+ 'price' => '',
62
+ 'demo_link' => '',
63
+ 'buy_now' => '',
64
+ 'coming_soon' => false,
65
+ );
66
+ $args = wp_parse_args( $args, $defaults );
67
+ extract( $args );
68
+
69
+ $coming_soon ? ' coming-soon' : '';
70
+
71
+ $coming_soon_div = ($coming_soon) ? $this->coming_soon_div() : '';
72
+ $addon = '<div class="bp-media-addon">
73
+ <a href="' . $product_link . '" title="' . $title . '" target="_blank">
74
+ <img width="240" height="184" title="' . $title . '" alt="' . $title . '" src="' . $img_src . '">
75
+ </a>
76
+ <h4><a href="' . $product_link . '" title="' . $title . '" target="_blank">' . $title . '</a></h4>
77
+ <div class="product_desc">
78
+ ' . $desc . '
79
+ </div>
80
+ <div class="product_footer">
81
+ <span class="price alignleft"><span class="amount">' . $price . '</span></span>
82
+ <a class="add_to_cart_button alignright product_type_simple" href="' . $buy_now . '" target="_blank">' . __( 'Buy Now', BP_MEDIA_TXT_DOMAIN ) . '</a>
83
+ <a class="alignleft product_demo_link" href="' . $demo_link . '" title="' . $title . '" target="_blank">' . __( 'Live Demo', BP_MEDIA_TXT_DOMAIN ) . '</a>
84
+ </div>'
85
+ . $coming_soon_div .
86
+ '</div>';
87
+ echo $addon;
88
+ }
89
+
90
+ }
91
+
92
+ }
93
+ ?>
app/helper/BPMediaBranding.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaBranding
5
+ *
6
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
7
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
8
+ */
9
+ if (!class_exists('BPMediaBranding')) {
10
+
11
+ class BPMediaBranding {
12
+
13
+ public function __construct() {
14
+ ;
15
+ }
16
+
17
+ }
18
+
19
+ }
20
+ ?>
app/helper/BPMediaFeed.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaFeed
5
+ *
6
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
7
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
8
+ */
9
+ class BPMediaFeed {
10
+
11
+ public $feed_url = 'http://rtcamp.com/tag/buddypress/feed/';
12
+
13
+ public function __construct($feed_url = '') {
14
+ if ($feed_url)
15
+ $this->feed_url = $feed_url;
16
+ }
17
+
18
+ /**
19
+ * Get BuddyPress Media Feed from rtCamp.com
20
+ */
21
+ public function fetch_feed() {
22
+ global $bp_media;
23
+ // Get RSS Feed(s)
24
+ require_once( ABSPATH . WPINC . '/feed.php' );
25
+ $maxitems = 0;
26
+ // Get a SimplePie feed object from the specified feed source.
27
+ $rss = fetch_feed($this->feed_url);
28
+ if (!is_wp_error($rss)) { // Checks that the object is created correctly
29
+ // Figure out how many total items there are, but limit it to 5.
30
+ $maxitems = $rss->get_item_quantity(5);
31
+
32
+ // Build an array of all the items, starting with element 0 (first element).
33
+ $rss_items = $rss->get_items(0, $maxitems);
34
+ }
35
+ ?>
36
+ <ul><?php
37
+ if ($maxitems == 0) {
38
+ echo '<li>' . __('No items', BP_MEDIA_TXT_DOMAIN) . '.</li>';
39
+ } else {
40
+ // Loop through each feed item and display each item as a hyperlink.
41
+ foreach ($rss_items as $item) {
42
+ ?>
43
+ <li>
44
+ <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __('Posted ', BP_MEDIA_TXT_DOMAIN) . $item->get_date('j F Y | g:i a'); ?>'><?php echo $item->get_title(); ?></a>
45
+ </li><?php
46
+ }
47
+ }
48
+ ?>
49
+ </ul><?php
50
+ if (DOING_AJAX) {
51
+ die();
52
+ }
53
+ }
54
+
55
+ }
56
+ ?>
app/helper/BPMediaLog.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaLog
5
+ *
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaLog')) {
9
+
10
+ class BPMediaLog {
11
+
12
+ public function __construct() {
13
+ ;
14
+ }
15
+
16
+ }
17
+
18
+ }
19
+ ?>
app/helper/BPMediaSettings.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaSettings
4
+ *
5
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaSettings')) {
9
+
10
+ class BPMediaSettings {
11
+
12
+ public function __construct() {
13
+ add_action('admin_init', array($this, 'settings'));
14
+ }
15
+
16
+ /**
17
+ * Register Settings
18
+ *
19
+ * @global string BP_MEDIA_TXT_DOMAIN
20
+ */
21
+ public function settings() {
22
+ global $bp_media_addon;
23
+ add_settings_section('bpm-settings', __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
24
+ add_settings_field('bpm-video', __('Video', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
25
+ 'option' => 'videos_enabled',
26
+ 'desc' => __('Check to enable video upload functionality', BP_MEDIA_TXT_DOMAIN)
27
+ ));
28
+ add_settings_field('bpm-audio', __('Audio', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
29
+ 'option' => 'audio_enabled',
30
+ 'desc' => __('Check to enable audio upload functionality', BP_MEDIA_TXT_DOMAIN)
31
+ ));
32
+ add_settings_field('bpm-image', __('Images', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
33
+ 'option' => 'images_enabled',
34
+ 'desc' => __('Check to enable images upload functionality', BP_MEDIA_TXT_DOMAIN)
35
+ ));
36
+ add_settings_field('bpm-download', __('Download', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
37
+ 'option' => 'download_enabled',
38
+ 'desc' => __('Check to enable download functionality', BP_MEDIA_TXT_DOMAIN)
39
+ ));
40
+ add_settings_section('bpm-spread-the-word', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
41
+ add_settings_field('bpm-spread-the-word-settings', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), array($this, 'radio'), 'bp-media-settings', 'bpm-spread-the-word', array(
42
+ 'option' => 'remove_linkback',
43
+ 'radios' => array(
44
+ 2 => __('Yes, I support BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
45
+ 1 => __('No, I don\'t want to support BuddyPress Media', BP_MEDIA_TXT_DOMAIN)),
46
+ 'default' => 2)
47
+ );
48
+ add_settings_section('bpm-other', __('BuddyPress Media Other Options', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
49
+ add_settings_field('bpm-other-settings', __('Re-Count Media Entries', BP_MEDIA_TXT_DOMAIN), array($this, 'button'), 'bp-media-settings', 'bpm-other', array(
50
+ 'option' => 'refresh-count',
51
+ 'name' => 'Re-Count',
52
+ 'desc' => __('It will re-count all media entries of all users and correct any discrepancies.', BP_MEDIA_TXT_DOMAIN)
53
+ ));
54
+ $bp_media_addon = new BPMediaAddon();
55
+ add_settings_section('bpm-addons', __('BuddyPress Media Addons for Audio/Video Conversion', BP_MEDIA_TXT_DOMAIN), array($bp_media_addon, 'get_addons'), 'bp-media-addons');
56
+ add_settings_section('bpm-support', __('Submit a request form', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-support');
57
+ add_settings_field('bpm-request', __('Request Type', BP_MEDIA_TXT_DOMAIN), array($this, 'dropdown'), 'bp-media-support', 'bpm-support', array('option' => 'select-request', 'none' => false, 'values' => array(
58
+ '' => '--Select One--',
59
+ 'premium_support' => 'Premium Support',
60
+ 'new_feature' => 'Suggest a New Feature',
61
+ 'bug_report' => 'Submit a Bug Report')
62
+ ));
63
+ register_setting('bp_media', 'bp_media_options', array($this, 'sanitize'));
64
+ }
65
+
66
+ /**
67
+ * Sanitizes the settings
68
+ */
69
+ public function sanitize($input) {
70
+ global $bp_media_admin;
71
+ if (isset($_POST['refresh-count'])) {
72
+ if ($bp_media_admin->update_count())
73
+ add_settings_error('Recount Success', 'recount-success', __('Recounting of media files done successfully', BP_MEDIA_TXT_DOMAIN), 'updated');
74
+ else
75
+ add_settings_error('Recount Fail', 'recount-fail', __('Recounting Failed', BP_MEDIA_TXT_DOMAIN));
76
+ }
77
+ return $input;
78
+ }
79
+
80
+ /**
81
+ * Output a checkbox
82
+ *
83
+ * @global type $bp_media
84
+ * @param array $args
85
+ */
86
+ public function checkbox($args) {
87
+ global $bp_media;
88
+ $options = $bp_media->options;
89
+ $defaults = array(
90
+ 'option' => '',
91
+ 'desc' => '',
92
+ );
93
+ $args = wp_parse_args($args, $defaults);
94
+ extract($args);
95
+ if (empty($option)) {
96
+ trigger_error(__('Please provide "option" value ( required ) in the argument. Pass argument to add_settings_field in the following format array( \'option\' => \'option_name\' ) ', BP_MEDIA_TXT_DOMAIN));
97
+ return;
98
+ }
99
+ if (!isset($options[$option]))
100
+ $options[$option] = '';
101
+ ?>
102
+ <label for="<?php echo $option; ?>">
103
+ <input<?php checked($options[$option]); ?> name="bp_media_options[<?php echo $option; ?>]" id="<?php echo $option; ?>" value="1" type="checkbox" />
104
+ <?php echo $desc; ?>
105
+ </label><?php
106
+ }
107
+
108
+ /**
109
+ * Outputs Radio Buttons
110
+ *
111
+ * @global type $bp_media
112
+ * @param array $args
113
+ */
114
+ public function radio($args) {
115
+ global $bp_media;
116
+ $options = $bp_media->options;
117
+ $defaults = array(
118
+ 'option' => '',
119
+ 'radios' => array(),
120
+ 'default' => '',
121
+ );
122
+ $args = wp_parse_args($args, $defaults);
123
+ extract($args);
124
+ if (empty($option) || ( 2 > count($radios) )) {
125
+ if (empty($option))
126
+ trigger_error(__('Please provide "option" value ( required ) in the argument. Pass argument to add_settings_field in the following format array( \'option\' => \'option_name\' )', BP_MEDIA_TXT_DOMAIN));
127
+ if (2 > count($radios))
128
+ trigger_error(__('Need to specify atleast to radios else use a checkbox instead', BP_MEDIA_TXT_DOMAIN));
129
+ return;
130
+ }
131
+ if (empty($options[$option])) {
132
+ $options[$option] = $defaults;
133
+ }
134
+ foreach ($radios as $value => $desc) {
135
+ ?>
136
+ <label for="<?php echo sanitize_title($desc); ?>"><input<?php checked($options[$option], $value); ?> value='<?php echo $value; ?>' name='bp_media_options[<?php echo $option; ?>]' id="<?php echo sanitize_title($desc); ?>" type='radio' /><?php echo $desc; ?></label><br /><?php
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Outputs Dropdown
142
+ *
143
+ * @global type $bp_media
144
+ * @param array $args
145
+ */
146
+ public function dropdown($args) {
147
+ $defaults = array(
148
+ 'option' => '',
149
+ 'none' => true,
150
+ 'values' => ''
151
+ );
152
+ $args = wp_parse_args($args, $defaults);
153
+ extract($args);
154
+ if (empty($option) || empty($values)) {
155
+ if (empty($option))
156
+ trigger_error(__('Please provide "option" value ( required ) in the argument. Pass argument to add_settings_field in the following format array( \'option\' => \'option_name\' )', BP_MEDIA_TXT_DOMAIN));
157
+ if (empty($values))
158
+ trigger_error(__('Please provide some values to populate the dropdown. Format : array( \'value\' => \'option\' )', BP_MEDIA_TXT_DOMAIN));
159
+ return;
160
+ }
161
+ ?>
162
+ <select name="<?php echo $option; ?>" id="<?php echo $option; ?>"><?php if ($none) { ?>
163
+ <option><?php __e('None', BP_MEDIA_TXT_DOMAIN); ?></option><?php
164
+ }
165
+ foreach ($values as $value => $text) {
166
+ ?>
167
+ <option value="<?php echo $value; ?>"><?php echo $text; ?></option><?php }
168
+ ?>
169
+ </select><?php
170
+ }
171
+
172
+ /**
173
+ * Outputs a Button
174
+ *
175
+ * @global type $bp_media
176
+ * @param array $args
177
+ */
178
+ public function button($args) {
179
+ $defaults = array(
180
+ 'option' => '',
181
+ 'name' => 'Save Changes',
182
+ 'desc' => '',
183
+ );
184
+ $args = wp_parse_args($args, $defaults);
185
+ extract($args);
186
+ if (empty($option)) {
187
+ trigger_error('Please provide "option" value ( Required ) in the argument. Pass argument to add_settings_field in the following format array( \'option\' => \'option_name\', \'link\' => \'linkurl\' )');
188
+ return;
189
+ }
190
+ submit_button($name, '', $option, false);
191
+ if (!empty($desc)) {
192
+ ?>
193
+ <span class="description"><?php echo $desc; ?></a><?php
194
+ }
195
+ }
196
+
197
+ }
198
+
199
+ }
200
+ ?>
app/helper/BPMediaSupport.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaSupport
4
+ *
5
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaSupport')) {
9
+
10
+ class BPMediaSupport {
11
+
12
+ public function __construct() {
13
+ ;
14
+ }
15
+
16
+ public function get_form($form) {
17
+ if (empty($form))
18
+ $form = (isset($_POST['form'])) ? $_POST['form'] : '';
19
+
20
+ global $current_user;
21
+ switch ($form) {
22
+ case "bug_report":
23
+ $meta_title = __('Submit a Bug Report', BP_MEDIA_TXT_DOMAIN);
24
+ break;
25
+ case "new_feature":
26
+ $meta_title = __('Submit a New Feature Request', BP_MEDIA_TXT_DOMAIN);
27
+ break;
28
+ case "premium_support":
29
+ $meta_title = __('Submit a Premium Support Request', BP_MEDIA_TXT_DOMAIN);
30
+ break;
31
+ }
32
+ ?>
33
+ <h3><?php echo $meta_title; ?></h3>
34
+ <div id="support-form" class="bp-media-form">
35
+ <ul>
36
+ <li>
37
+ <label class="bp-media-label" for="name"><?php _e('Name', BP_MEDIA_TXT_DOMAIN); ?>:</label><input class="bp-media-input" id="name" type="text" name="name" value="<?php echo (isset($_REQUEST['name'])) ? esc_attr(stripslashes(trim($_REQUEST['name']))) : $current_user->display_name; ?>" required />
38
+ </li>
39
+ <li>
40
+ <label class="bp-media-label" for="email"><?php _e('Email', BP_MEDIA_TXT_DOMAIN); ?>:</label><input id="email" class="bp-media-input" type="text" name="email" value="<?php echo (isset($_REQUEST['email'])) ? esc_attr(stripslashes(trim($_REQUEST['email']))) : get_option('admin_email'); ?>" required />
41
+ </li>
42
+ <li>
43
+ <label class="bp-media-label" for="website"><?php _e('Website', BP_MEDIA_TXT_DOMAIN); ?>:</label><input id="website" class="bp-media-input" type="text" name="website" value="<?php echo (isset($_REQUEST['website'])) ? esc_attr(stripslashes(trim($_REQUEST['website']))) : get_bloginfo('url'); ?>" required />
44
+ </li>
45
+ <li>
46
+ <label class="bp-media-label" for="phone"><?php _e('Phone', BP_MEDIA_TXT_DOMAIN); ?>:</label><input class="bp-media-input" id="phone" type="text" name="phone" value="<?php echo (isset($_REQUEST['phone'])) ? esc_attr(stripslashes(trim($_REQUEST['phone']))) : ''; ?>"/>
47
+ </li>
48
+ <li>
49
+ <label class="bp-media-label" for="subject"><?php _e('Subject', BP_MEDIA_TXT_DOMAIN); ?>:</label><input id="subject" class="bp-media-input" type="text" name="subject" value="<?php echo (isset($_REQUEST['subject'])) ? esc_attr(stripslashes(trim($_REQUEST['subject']))) : ''; ?>" required />
50
+ </li>
51
+ <li>
52
+ <label class="bp-media-label" for="details"><?php _e('Details', BP_MEDIA_TXT_DOMAIN); ?>:</label><textarea id="details" class="bp-media-textarea" type="text" name="details" required/><?php echo (isset($_REQUEST['details'])) ? esc_textarea(stripslashes(trim($_REQUEST['details']))) : ''; ?></textarea>
53
+ </li>
54
+ <input type="hidden" name="request_type" value="<?php echo $form; ?>"/>
55
+ <input type="hidden" name="request_id" value="<?php echo wp_create_nonce(date('YmdHis')); ?>"/>
56
+ <input type="hidden" name="server_address" value="<?php echo $_SERVER['SERVER_ADDR']; ?>"/>
57
+ <input type="hidden" name="ip_address" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"/>
58
+ <input type="hidden" name="server_type" value="<?php echo $_SERVER['SERVER_SOFTWARE']; ?>"/>
59
+ <input type="hidden" name="user_agent" value="<?php echo $_SERVER['HTTP_USER_AGENT']; ?>"/>
60
+
61
+ </ul>
62
+ </div><!-- .submit-bug-box --><?php if ($form == 'bug_report') { ?>
63
+ <h3>Additional Information</h3>
64
+ <div id="support-form" class="bp-media-form">
65
+ <ul>
66
+
67
+ <li>
68
+ <label class="bp-media-label" for="wp_admin_username"><?php _e('Your WP Admin Login:', BP_MEDIA_TXT_DOMAIN); ?></label><input class="bp-media-input" id="wp_admin_username" type="text" name="wp_admin_username" value="<?php echo (isset($_REQUEST['wp_admin_username'])) ? esc_attr(stripslashes(trim($_REQUEST['wp_admin_username']))) : $current_user->user_login; ?>"/>
69
+ </li>
70
+ <li>
71
+ <label class="bp-media-label" for="wp_admin_pwd"><?php _e('Your WP Admin password:', BP_MEDIA_TXT_DOMAIN); ?></label><input class="bp-media-input" id="wp_admin_pwd" type="password" name="wp_admin_pwd" value="<?php echo (isset($_REQUEST['wp_admin_pwd'])) ? esc_attr(stripslashes(trim($_REQUEST['wp_admin_pwd']))) : ''; ?>"/>
72
+ </li>
73
+ <li>
74
+ <label class="bp-media-label" for="ssh_ftp_host"><?php _e('Your SSH / FTP host:', BP_MEDIA_TXT_DOMAIN); ?></label><input class="bp-media-input" id="ssh_ftp_host" type="text" name="ssh_ftp_host" value="<?php echo (isset($_REQUEST['ssh_ftp_host'])) ? esc_attr(stripslashes(trim($_REQUEST['ssh_ftp_host']))) : ''; ?>"/>
75
+ </li>
76
+ <li>
77
+ <label class="bp-media-label" for="ssh_ftp_username"><?php _e('Your SSH / FTP login:', BP_MEDIA_TXT_DOMAIN); ?></label><input class="bp-media-input" id="ssh_ftp_username" type="text" name="ssh_ftp_username" value="<?php echo (isset($_REQUEST['ssh_ftp_username'])) ? esc_attr(stripslashes(trim($_REQUEST['ssh_ftp_username']))) : ''; ?>"/>
78
+ </li>
79
+ <li>
80
+ <label class="bp-media-label" for="ssh_ftp_pwd"><?php _e('Your SSH / FTP password:', BP_MEDIA_TXT_DOMAIN); ?></label><input class="bp-media-input" id="ssh_ftp_pwd" type="password" name="ssh_ftp_pwd" value="<?php echo (isset($_REQUEST['ssh_ftp_pwd'])) ? esc_attr(stripslashes(trim($_REQUEST['ssh_ftp_pwd']))) : ''; ?>"/>
81
+ </li>
82
+ </ul>
83
+ </div><!-- .submit-bug-box --><?php } ?>
84
+
85
+ <?php submit_button('Submit', 'primary', 'submit-request', false); ?>
86
+ <?php submit_button('Cancel', 'secondary', 'cancel-request', false); ?>
87
+
88
+ <?php
89
+ if (DOING_AJAX) {
90
+ die();
91
+ }
92
+ }
93
+
94
+ public function submit_request() {
95
+ global $bp_media;
96
+ $form_data = wp_parse_args($_POST['form_data']);
97
+ if ($form_data['request_type'] == 'premium_support') {
98
+ $title = __('BuddyPress Media Premium Support Request from', BP_MEDIA_TXT_DOMAIN);
99
+ } elseif ($form_data['request_type'] == 'new_feature') {
100
+ $title = __('BuddyPress Media New Feature Request from', BP_MEDIA_TXT_DOMAIN);
101
+ } elseif ($form_data['request_type'] == 'bug_report') {
102
+ $title = __('BuddyPress Media Bug Report from', BP_MEDIA_TXT_DOMAIN);
103
+ } else {
104
+ $title = __('BuddyPress Media Contact from', BP_MEDIA_TXT_DOMAIN);
105
+ }
106
+ $message = '<html>
107
+ <head>
108
+ <title>' . $title . get_bloginfo('name') . '</title>
109
+ </head>
110
+ <body>
111
+ <table>
112
+ <tr>
113
+ <td>' . __("Name", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['name']) . '</td>
114
+ </tr>
115
+ <tr>
116
+ <td>' . __("Email", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['email']) . '</td>
117
+ </tr>
118
+ <tr>
119
+ <td>' . __("Website", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['website']) . '</td>
120
+ </tr>
121
+ <tr>
122
+ <td>' . __("Phone", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['phone']) . '</td>
123
+ </tr>
124
+ <tr>
125
+ <td>' . __("Subject", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['subject']) . '</td>
126
+ </tr>
127
+ <tr>
128
+ <td>' . __("Details", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['details']) . '</td>
129
+ </tr>
130
+ <tr>
131
+ <td>' . __("Request ID", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['request_id']) . '</td>
132
+ </tr>
133
+ <tr>
134
+ <td>' . __("Server Address", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['server_address']) . '</td>
135
+ </tr>
136
+ <tr>
137
+ <td>' . __("IP Address", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['ip_address']) . '</td>
138
+ </tr>
139
+ <tr>
140
+ <td>' . __("Server Type", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['server_type']) . '</td>
141
+ </tr>
142
+ <tr>
143
+ <td>' . __("User Agent", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['user_agent']) . '</td>
144
+ </tr>';
145
+ if ($form_data['request_type'] == 'bug_report') {
146
+ $message .= '<tr>
147
+ <td>' . __("WordPress Admin Username", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['wp_admin_username']) . '</td>
148
+ </tr>
149
+ <tr>
150
+ <td>' . __("WordPress Admin Password", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['wp_admin_pwd']) . '</td>
151
+ </tr>
152
+ <tr>
153
+ <td>' . __("SSH FTP Host", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['ssh_ftp_host']) . '</td>
154
+ </tr>
155
+ <tr>
156
+ <td>' . __("SSH FTP Username", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['ssh_ftp_username']) . '</td>
157
+ </tr>
158
+ <tr>
159
+ <td>' . __("SSH FTP Password", BP_MEDIA_TXT_DOMAIN) . '</td><td>' . strip_tags($form_data['ssh_ftp_pwd']) . '</td>
160
+ </tr>
161
+ ';
162
+ }
163
+ $message .= '</table>
164
+ </body>
165
+ </html>';
166
+ add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
167
+ $headers = 'From: ' . $form_data['name'] . ' <' . $form_data['email'] . '>' . "\r\n";
168
+ if (wp_mail($bp_media->support_email, '[buddypress-media] Bug Report | Premium Support from '.str_replace( array('http://', 'https://'), '', $form_data['website']), $message, $headers)) {
169
+ if ($form_data['request_type'] == 'new_feature') {
170
+ echo '<p>' . __('Thank you for your Feedback/Suggestion.', BP_MEDIA_TXT_DOMAIN) . '</p>';
171
+ } else {
172
+ echo '<p>' . __('Thank you for posting your support request.', BP_MEDIA_TXT_DOMAIN) . '</p>';
173
+ echo '<p>' . __('We will get back to you shortly.', BP_MEDIA_TXT_DOMAIN) . '</p>';
174
+ }
175
+ } else {
176
+ echo '<p>' . __('Your server failed to send an email.', BP_MEDIA_TXT_DOMAIN) . '</p>';
177
+ echo '<p>' . __('Kindly contact your server support to fix this.', BP_MEDIA_TXT_DOMAIN) . '</p>';
178
+ echo '<p>' . sprintf(__('You can alternatively create a support request <a href="%s">here</a>', BP_MEDIA_TXT_DOMAIN), $bp_media->support_url) . '</p>';
179
+ }
180
+ die();
181
+ }
182
+
183
+ }
184
+
185
+ }
186
+ ?>
app/helper/BPMediaUpgrade.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaUpgrade
4
+ *
5
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaUpgrade')) {
9
+
10
+ class BPMediaUpgrade {
11
+
12
+ public function __construct() {
13
+ if (is_admin()) {
14
+ if (version_compare(BP_MEDIA_DB_VERSION, get_site_option('bp_media_db_version', '1.0'), '>')) {
15
+ add_action('admin_notices', array($this, 'upgrade_db'));
16
+ }
17
+ add_action('wp_loaded', array($this, 'upgrade'));
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Displays admin notice to upgrade BuddyPress Media Database
23
+ *
24
+ * @global string BP_MEDIA_TXT_DOMAIN
25
+ */
26
+ public function upgrade_db() {
27
+ global $bp_media;
28
+ ?>
29
+ <div class="error"><p><?php
30
+ printf(__('Please click upgrade to upgrade the database of BuddyPress Media <a class="button" id="refresh_media_count" href ="%s" class="button" title="It will migrate your BuddyPress Media\'s earlier database to new database.">Upgrade</a>', BP_MEDIA_TXT_DOMAIN), bp_media_get_admin_url(add_query_arg(array('page' => 'bp-media-settings', 'bp_media_upgrade_db' => 1, 'wp_nonce' => wp_create_nonce('bp_media_upgrade_db')), 'admin.php')))
31
+ ?>
32
+ </p></div>
33
+ <?php
34
+ }
35
+
36
+ /**
37
+ * Upgrade Script
38
+ */
39
+ public function upgrade() {
40
+ if (isset($_GET['bp_media_upgrade_db']) && empty($_REQUEST['settings-updated'])) {
41
+ check_admin_referer('bp_media_upgrade_db', 'wp_nonce');
42
+ require_once('bp-media-upgrade-script.php');
43
+ $current_version = get_site_option('bp_media_db_version', '1.0');
44
+ if ($current_version == '2.0')
45
+ $this->upgrade_2_0_to_2_1();
46
+ else
47
+ $this->upgrade_1_0_to_2_1();
48
+ remove_action('admin_notices', 'upgrade_db');
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Upgrade from BuddyPress Media 1.0 to 2.1
54
+ * @global wpdb $wpdb
55
+ * @global string BP_MEDIA_TXT_DOMAIN
56
+ */
57
+ public function upgrade_1_0_to_2_1() {
58
+ global $wpdb, $bp_media;
59
+ remove_filter('bp_activity_get_user_join_filter', 'activity_query_filter', 10);
60
+ /* @var $wpdb wpdb */
61
+ $wall_posts_album_ids = array();
62
+ do {
63
+ $media_files = new WP_Query(array(
64
+ 'post_type' => 'bp_media',
65
+ 'posts_per_page' => 10
66
+ ));
67
+ $media_files = isset($media_files->posts) ? $media_files->posts : null;
68
+ if (is_array($media_files) && count($media_files)) {
69
+ foreach ($media_files as $media_file) {
70
+ $attachment_id = get_post_meta($media_file->ID, 'bp_media_child_attachment', true);
71
+ $child_activity = get_post_meta($media_file->ID, 'bp_media_child_activity', true);
72
+ update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
73
+ $attachment = get_post($attachment_id, ARRAY_A);
74
+ if (isset($wall_posts_album_ids[$media_file->post_author])) {
75
+ $wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
76
+ } else {
77
+ $wall_posts_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = 'Wall Posts' AND post_author = '" . $media_file->post_author . "' AND post_type='bp_media_album'");
78
+ if ($wall_posts_id == null) {
79
+ $album = new BPMediaAlbum();
80
+ $album->add_album('Wall Posts', $media_file->post_author);
81
+ $wall_posts_id = $album->get_id();
82
+ }
83
+ if (!$wall_posts_id) {
84
+ continue; //This condition should never be encountered
85
+ }
86
+ $wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
87
+ }
88
+ $attachment['post_parent'] = $wall_posts_id;
89
+ wp_update_post($attachment);
90
+ update_post_meta($attachment_id, 'bp-media-key', $media_file->post_author);
91
+ $activity = bp_activity_get(array('in' => intval($child_activity)));
92
+ if (isset($activity['activities'][0]->id))
93
+ $activity = $activity['activities'][0];
94
+ try {
95
+ $bp_media = new BPMediaHostWordpress($attachment_id);
96
+ } catch (exception $e) {
97
+ continue;
98
+ }
99
+ $args = array(
100
+ 'content' => $bp_media->get_media_activity_content(),
101
+ 'id' => $child_activity,
102
+ 'type' => 'media_upload',
103
+ 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media_file->post_author), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>')),
104
+ 'primary_link' => $bp_media->get_url(),
105
+ 'item_id' => $attachment_id,
106
+ 'recorded_time' => $activity->date_recorded,
107
+ 'user_id' => $bp_media->get_author()
108
+ );
109
+ $act_id = BPMediaFunction::record_activity($args);
110
+ bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
111
+ wp_delete_post($media_file->ID);
112
+ }
113
+ } else {
114
+ break;
115
+ }
116
+ } while (1);
117
+ update_site_option('bp_media_db_version', BP_MEDIA_DB_VERSION);
118
+ add_action('admin_notices', 'BPMediaUpgradeScript::database_updated_notice');
119
+ wp_cache_flush();
120
+ }
121
+
122
+ /**
123
+ * Upgrade from BuddyPress Media 2.0 to 2.1
124
+ *
125
+ * @global string BP_MEDIA_TXT_DOMAIN
126
+ */
127
+ public function upgrade_2_0_to_2_1() {
128
+ global $bp_media;
129
+ $page = 0;
130
+ while ($media_entries = BPMediaUpgradeScript::return_query_posts(array(
131
+ 'post_type' => 'attachment',
132
+ 'post_status' => 'any',
133
+ 'meta_key' => 'bp-media-key',
134
+ 'meta_value' => 0,
135
+ 'meta_compare' => '>',
136
+ 'paged' => ++$page,
137
+ 'postsperpage' => 10
138
+ ))) {
139
+ foreach ($media_entries as $media) {
140
+ try {
141
+ $bp_media = new BPMediaHostWordpress($media->ID);
142
+ } catch (exception $e) {
143
+ continue;
144
+ }
145
+ $child_activity = get_post_meta($media->ID, 'bp_media_child_activity', true);
146
+ if ($child_activity) {
147
+ $activity = bp_activity_get(array('in' => intval($child_activity)));
148
+ if (isset($activity['activities'][0]->id))
149
+ $activity = $activity['activities'][0];
150
+ else
151
+ continue;
152
+ $args = array(
153
+ 'content' => $bp_media->get_media_activity_content(),
154
+ 'id' => $child_activity,
155
+ 'type' => 'media_upload',
156
+ 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($bp_media->get_author()), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>')),
157
+ 'primary_link' => $bp_media->get_url(),
158
+ 'item_id' => $activity->item_id,
159
+ 'recorded_time' => $activity->date_recorded,
160
+ 'user_id' => $bp_media->get_author()
161
+ );
162
+ BPMediaFunction::record_activity($args);
163
+ }
164
+ }
165
+ }
166
+ update_site_option('bp_media_db_version', BP_MEDIA_DB_VERSION);
167
+ add_action('admin_notices', 'BPMediaUpgradeScript::database_updated_notice');
168
+ wp_cache_flush();
169
+ }
170
+
171
+ }
172
+
173
+ }
174
+ ?>
app/helper/BPMediaWidget.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaWidget
4
+ *
5
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ if (!class_exists('BPMediaWidget')) {
9
+
10
+ class BPMediaWidget {
11
+
12
+ public function __construct($id = NULL, $title = NULL, $content = NULL) {
13
+ global $bp_media;
14
+ if ($id) {
15
+ ?>
16
+ <div class="postbox" id="<?php echo $id; ?>"><?php if ($title) { ?>
17
+ <h3 class="hndle"><span><?php echo $title; ?></span></h3><?php }
18
+ ?>
19
+ <div class="inside"><?php echo $content; ?></div>
20
+ </div><?php
21
+ } else {
22
+ trigger_error(__('Argument missing. id is required.', BP_MEDIA_TXT_DOMAIN));
23
+ }
24
+ }
25
+
26
+ }
27
+
28
+ }
29
+ ?>
app/main/BPMediaLoader.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) )
4
+ exit;
5
+
6
+ /**
7
+ * Description of BPMediaLoader
8
+ *
9
+ * @author Saurabh Shukla <saurabh.shukla@rtcamp.com>
10
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
11
+ */
12
+ class BPMediaLoader {
13
+
14
+ public function __construct() {
15
+ add_action( 'bp_loaded', array( $this, 'load_component' ) );
16
+ add_action( 'bp_setup_nav', array( $this, 'custom_nav' ), 999 );
17
+ add_action( 'after_setup_theme', array( $this, 'thumbnail' ) );
18
+ }
19
+
20
+ public function load_component() {
21
+ global $bp;
22
+ $bp->{BP_MEDIA_SLUG} = new BPMediaComponent();
23
+ }
24
+
25
+ public function custom_nav() {
26
+ global $bp;
27
+ foreach ( $bp->bp_nav as $key => $nav_item ) {
28
+ switch ( $nav_item[ 'slug' ] ) {
29
+ case BP_MEDIA_IMAGES_SLUG:
30
+ case BP_MEDIA_VIDEOS_SLUG:
31
+ case BP_MEDIA_AUDIO_SLUG:
32
+ case BP_MEDIA_ALBUMS_SLUG:
33
+ $bp->bp_options_nav[ BP_MEDIA_SLUG ][ ] = array(
34
+ 'name' => $nav_item[ 'name' ],
35
+ 'link' => (isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : (isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '')) . $nav_item[ 'slug' ] . '/',
36
+ 'slug' => $nav_item[ 'slug' ],
37
+ 'css_id' => $nav_item[ 'css_id' ],
38
+ 'position' => $nav_item[ 'position' ],
39
+ 'screen_function' => $nav_item[ 'screen_function' ],
40
+ 'user_has_access' => true,
41
+ 'parent_url' => trailingslashit( bp_displayed_user_domain() )
42
+ );
43
+ unset( $bp->bp_nav[ $key ] );
44
+ }
45
+ switch ( $bp->current_component ) {
46
+ case BP_MEDIA_IMAGES_SLUG:
47
+ case BP_MEDIA_VIDEOS_SLUG:
48
+ case BP_MEDIA_AUDIO_SLUG:
49
+ case BP_MEDIA_ALBUMS_SLUG:
50
+ $count = count( $bp->action_variables );
51
+ for ( $i = $count; $i > 0; $i -- ) {
52
+ $bp->action_variables[ $i ] = $bp->action_variables[ $i - 1 ];
53
+ }
54
+ $bp->action_variables[ 0 ] = $bp->current_action;
55
+ $bp->current_action = $bp->current_component;
56
+ $bp->current_component = BP_MEDIA_SLUG;
57
+ }
58
+ }
59
+ }
60
+
61
+ public function thumbnail() {
62
+ global $bp_media;
63
+
64
+ $default_sizes = $bp_media->media_sizes();
65
+
66
+ add_image_size( 'bp_media_activity_image', $default_sizes[ 'activity_image' ][ 'width' ], $default_sizes[ 'activity_image' ][ 'height' ], true );
67
+ add_image_size( 'bp_media_single_image', $default_sizes[ 'single_image' ][ 'width' ], $default_sizes[ 'single_image' ][ 'height' ], true );
68
+ }
69
+
70
+ }
71
+
72
+ ?>
app/main/BuddyPressMedia.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMedia
4
+ *
5
+ * @author Saurabh Shukla <saurabh.shukla@rtcamp.com>
6
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
7
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) )
10
+ exit;
11
+
12
+ class BuddyPressMedia {
13
+
14
+ public $text_domain = 'buddypress-media';
15
+ public $options;
16
+ public $support_email = 'support@rtcamp.com';
17
+ public $support_url = 'http://rtcamp.com/support/forum/buddypress-media/';
18
+ public $query;
19
+ public $albums_query;
20
+ public $counter = 0;
21
+ public $count = null;
22
+ public $posts_per_page = 10;
23
+ public $activity_types = array(
24
+ 'media_upload',
25
+ 'album_updated',
26
+ 'album_created'
27
+ );
28
+ public $hidden_activity_cache = array( );
29
+ public $loader;
30
+ public $group_loader;
31
+
32
+ public function __construct() {
33
+ $this->constants();
34
+ $this->excerpt_lengths();
35
+ add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 );
36
+ }
37
+
38
+ public function get_option() {
39
+ $this->options = bp_get_option( 'bp_media_options' );
40
+ }
41
+
42
+ public function constants() {
43
+ /* Text domain */
44
+ if ( ! defined( 'BP_MEDIA_TXT_DOMAIN' ) )
45
+ define( 'BP_MEDIA_TXT_DOMAIN', $this->text_domain );
46
+
47
+ /* If the plugin is installed. */
48
+ if ( ! defined( 'BP_MEDIA_IS_INSTALLED' ) )
49
+ define( 'BP_MEDIA_IS_INSTALLED', 1 );
50
+
51
+ /* Current Version. */
52
+ if ( ! defined( 'BP_MEDIA_VERSION' ) )
53
+ define( 'BP_MEDIA_VERSION', '2.4' );
54
+
55
+ /* Required Version */
56
+ if ( ! defined( 'BP_MEDIA_REQUIRED_BP' ) )
57
+ define( 'BP_MEDIA_REQUIRED_BP', '1.6.2' );
58
+
59
+ /* Database Version */
60
+ if ( ! defined( 'BP_MEDIA_DB_VERSION' ) )
61
+ define( 'BP_MEDIA_DB_VERSION', '2.1' );
62
+
63
+ /**
64
+ /* A constant to Active Collab API Assignee ID
65
+ if ( ! defined( 'BP_MEDIA_AC_API_ASSIGNEE_ID' ) )
66
+ define( 'BP_MEDIA_AC_API_ASSIGNEE_ID', '5' );
67
+
68
+ /* A constant to Active Collab API Assignee ID
69
+ if ( ! defined( 'BP_MEDIA_AC_API_LABEL_ID' ) )
70
+ define( 'BP_MEDIA_AC_API_LABEL_ID', '1' );
71
+
72
+ /* A constant to Active Collab API priority
73
+ if ( ! defined( 'BP_MEDIA_AC_API_PRIORITY' ) )
74
+ define( 'BP_MEDIA_AC_API_PRIORITY', '2' );
75
+
76
+ /* A constant to Active Collab API priority
77
+ if ( ! defined( 'BP_MEDIA_AC_API_CATEGORY_ID' ) )
78
+ define( 'BP_MEDIA_AC_API_CATEGORY_ID', '224' );
79
+ */
80
+ /* Slug Constants */
81
+ if ( ! defined( 'BP_MEDIA_SLUG' ) )
82
+ define( 'BP_MEDIA_SLUG', 'media' );
83
+
84
+ if ( ! defined( 'BP_MEDIA_UPLOAD_SLUG' ) )
85
+ define( 'BP_MEDIA_UPLOAD_SLUG', 'upload' );
86
+
87
+ if ( ! defined( 'BP_MEDIA_DELETE_SLUG' ) )
88
+ define( 'BP_MEDIA_DELETE_SLUG', 'delete' );
89
+
90
+ if ( ! defined( 'BP_MEDIA_IMAGES_SLUG' ) )
91
+ define( 'BP_MEDIA_IMAGES_SLUG', 'photos' );
92
+
93
+ if ( ! defined( 'BP_MEDIA_IMAGES_ENTRY_SLUG' ) )
94
+ define( 'BP_MEDIA_IMAGES_ENTRY_SLUG', 'view' );
95
+
96
+ if ( ! defined( 'BP_MEDIA_IMAGES_EDIT_SLUG' ) )
97
+ define( 'BP_MEDIA_IMAGES_EDIT_SLUG', 'edit' );
98
+
99
+ if ( ! defined( 'BP_MEDIA_VIDEOS_SLUG' ) )
100
+ define( 'BP_MEDIA_VIDEOS_SLUG', 'videos' );
101
+
102
+ if ( ! defined( 'BP_MEDIA_VIDEOS_ENTRY_SLUG' ) )
103
+ define( 'BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch' );
104
+
105
+ if ( ! defined( 'BP_MEDIA_VIDEOS_EDIT_SLUG' ) )
106
+ define( 'BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit' );
107
+
108
+ if ( ! defined( 'BP_MEDIA_AUDIO_SLUG' ) )
109
+ define( 'BP_MEDIA_AUDIO_SLUG', 'music' );
110
+
111
+ if ( ! defined( 'BP_MEDIA_AUDIO_ENTRY_SLUG' ) )
112
+ define( 'BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen' );
113
+
114
+ if ( ! defined( 'BP_MEDIA_AUDIO_EDIT_SLUG' ) )
115
+ define( 'BP_MEDIA_AUDIO_EDIT_SLUG', 'edit' );
116
+
117
+ if ( ! defined( 'BP_MEDIA_ALBUMS_SLUG' ) )
118
+ define( 'BP_MEDIA_ALBUMS_SLUG', 'albums' );
119
+
120
+ if ( ! defined( 'BP_MEDIA_ALBUMS_ENTRY_SLUG' ) )
121
+ define( 'BP_MEDIA_ALBUMS_ENTRY_SLUG', 'list' );
122
+
123
+ if ( ! defined( 'BP_MEDIA_ALBUMS_EDIT_SLUG' ) )
124
+ define( 'BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit' );
125
+
126
+ /* Labels loaded via text domain, can be translated */
127
+ if ( ! defined( 'BP_MEDIA_LABEL' ) )
128
+ define( 'BP_MEDIA_LABEL', __( 'Media', $this->text_domain ) );
129
+
130
+ if ( ! defined( 'BP_MEDIA_LABEL_SINGULAR' ) )
131
+ define( 'BP_MEDIA_LABEL_SINGULAR', __( 'Media', $this->text_domain ) );
132
+
133
+ if ( ! defined( 'BP_MEDIA_IMAGES_LABEL' ) )
134
+ define( 'BP_MEDIA_IMAGES_LABEL', __( 'Photos', $this->text_domain ) );
135
+
136
+ if ( ! defined( 'BP_MEDIA_IMAGES_LABEL_SINGULAR' ) )
137
+ define( 'BP_MEDIA_IMAGES_LABEL_SINGULAR', __( 'Photo', $this->text_domain ) );
138
+
139
+ if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL' ) )
140
+ define( 'BP_MEDIA_VIDEOS_LABEL', __( 'Videos', $this->text_domain ) );
141
+
142
+ if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR' ) )
143
+ define( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR', __( 'Video', $this->text_domain ) );
144
+
145
+ if ( ! defined( 'BP_MEDIA_AUDIO_LABEL' ) )
146
+ define( 'BP_MEDIA_AUDIO_LABEL', __( 'Music', $this->text_domain ) );
147
+
148
+ if ( ! defined( 'BP_MEDIA_AUDIO_LABEL_SINGULAR' ) )
149
+ define( 'BP_MEDIA_AUDIO_LABEL_SINGULAR', __( 'Music', $this->text_domain ) );
150
+
151
+ if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL' ) )
152
+ define( 'BP_MEDIA_ALBUMS_LABEL', __( 'Albums', $this->text_domain ) );
153
+
154
+ if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR' ) )
155
+ define( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR', __( 'Album', $this->text_domain ) );
156
+
157
+ if ( ! defined( 'BP_MEDIAUPLOAD_LABEL' ) )
158
+ define( 'BP_MEDIA_UPLOAD_LABEL', __( 'Upload', $this->text_domain ) );
159
+
160
+ if ( ! defined( 'BP_MEDIA_TMP_DIR' ) )
161
+ define( 'BP_MEDIA_TMP_DIR', WP_CONTENT_DIR . '/bp-media-temp' );
162
+
163
+ if ( ! defined( 'BP_MEDIA_SUPPORT_EMAIL' ) )
164
+ define( 'BP_MEDIA_SUPPORT_EMAIL', $this->support_email );
165
+ }
166
+
167
+ function init() {
168
+ $this->get_option();
169
+
170
+ if ( defined( 'BP_VERSION' ) && version_compare( BP_VERSION, BP_MEDIA_REQUIRED_BP, '>=' ) ) {
171
+ add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
172
+ $this->loader = new BPMediaLoader();
173
+ $this->group_loader = new BPMediaGroup();
174
+ new BPMediaFilters();
175
+ new BPMediaActions();
176
+ new BPMediaFunction();
177
+ }
178
+
179
+ if ( file_exists( BP_MEDIA_PATH . '/languages/' . get_locale() . '.mo' ) )
180
+ load_textdomain( BP_MEDIA_TXT_DOMAIN, BP_MEDIA_PATH . '/languages/' . get_locale() . '.mo' );
181
+
182
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
183
+ global $bp_media_admin;
184
+ $bp_media_admin = new BPMediaAdmin();
185
+ }
186
+
187
+ function settings_link( $links, $file ) {
188
+ /* create link */
189
+ $plugin_name = plugin_basename( __FILE__ );
190
+ $admin_link = $this->get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) );
191
+ if ( $file == $plugin_name ) {
192
+ array_unshift(
193
+ $links, sprintf( '<a href="%s">%s</a>', $admin_link, __( 'Settings', $this->text_domain ) )
194
+ );
195
+ }
196
+ return $links;
197
+ }
198
+
199
+ function media_sizes() {
200
+ $def_sizes = array(
201
+ 'activity_image' => array(
202
+ 'width' => 320,
203
+ 'height' => 240
204
+ ),
205
+ 'activity_video' => array(
206
+ 'width' => 320,
207
+ 'height' => 240
208
+ ),
209
+ 'activity_audio' => array(
210
+ 'width' => 320,
211
+ ),
212
+ 'single_image' => array(
213
+ 'width' => 800,
214
+ 'height' => 0
215
+ ),
216
+ 'single_video' => array(
217
+ 'width' => 640,
218
+ 'height' => 480
219
+ ),
220
+ 'single_audio' => array(
221
+ 'width' => 640,
222
+ ),
223
+ );
224
+
225
+ return apply_filters( 'bpm_media_sizes', $def_sizes );
226
+ }
227
+
228
+ function excerpt_lengths() {
229
+ global $bp_media_default_excerpts;
230
+ $def_excerpt = array(
231
+ 'single_entry_title' => 100,
232
+ 'single_entry_description' => 500,
233
+ 'activity_entry_title' => 50,
234
+ 'activity_entry_description' => 500
235
+ );
236
+
237
+ $bp_media_default_excerpts = apply_filters( 'bpm_excerpt_lengths', $def_excerpt );
238
+ }
239
+
240
+ public function admin_notice() {
241
+ global $current_user;
242
+ $user_id = $current_user->ID;
243
+ if ( isset( $_GET[ 'bp_media_nag_ignore' ] ) && '0' == $_GET[ 'bp_media_nag_ignore' ] ) {
244
+ add_user_meta( $user_id, 'bp_media_ignore_notice', 'true', true );
245
+ }
246
+ /* Check that the user hasn't already clicked to ignore the message */
247
+ if ( ! get_user_meta( $user_id, 'bp_media_ignore_notice' ) ) {
248
+ if ( defined( 'BP_VERSION' ) ) {
249
+ if ( version_compare( BP_VERSION, BP_MEDIA_REQUIRED_BP, '<' ) ) {
250
+ echo '<div class="error"><p>';
251
+ printf( __( 'The BuddyPress version installed is an older version and is not supported, please update BuddyPress to use BuddyPress Media Plugin.<a class="alignright" href="%1$s">X</a>', $this->text_domain ), '?bp_media_nag_ignore=0' );
252
+ echo "</p></div>";
253
+ }
254
+ } else {
255
+ echo '<div class="error"><p>';
256
+ printf( __( 'You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin.<a class="alignright" href="%1$s">X</a>', $this->text_domain ), '?bp_media_nag_ignore=0' );
257
+ echo "</p></div>";
258
+ }
259
+ }
260
+ }
261
+
262
+ public function activate() {
263
+ $bpmquery = new WP_Query( array( 'post_type' => 'bp_media', 'posts_per_page' => 1 ) );
264
+ if ( $bpmquery->found_posts > 0 ) {
265
+ update_site_option( 'bp_media_db_version', '1.0' );
266
+ } else {
267
+ switch ( get_site_option( 'bp_media_db_version', false, false ) ) {
268
+ case '2.0':
269
+ break;
270
+ default:
271
+ update_site_option( 'bp_media_db_version', BP_MEDIA_DB_VERSION );
272
+ }
273
+ }
274
+ }
275
+
276
+ function get_admin_url( $path = '', $scheme = 'admin' ) {
277
+
278
+ // Links belong in network admin
279
+ if ( is_multisite() )
280
+ $url = network_admin_url( $path, $scheme );
281
+
282
+ // Links belong in site admin
283
+ else
284
+ $url = admin_url( $path, $scheme );
285
+
286
+ return $url;
287
+ }
288
+
289
+ function widgets_init() {
290
+ register_widget( 'BPMediaRecentMedia' );
291
+ register_widget( 'BPMediaPopularMedia' );
292
+ }
293
+
294
+ }
295
+
296
+ ?>
app/main/group/BPMediaGroup.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaGroup
5
+ *
6
+ * @author faishal
7
+ */
8
+ class BPMediaGroup {
9
+
10
+ function __construct($initFlag = true) {
11
+ if ($initFlag) {
12
+ if (class_exists('BPMediaGroupsExtension')) :
13
+ bp_register_group_extension('BPMediaGroupsExtension');
14
+ new BPMediaGroupImage ();
15
+ new BPMediaGroupAlbum();
16
+ new BPMediaGroupMusic();
17
+ new BPMediaGroupVideo();
18
+ endif;
19
+ add_action('bp_actions', array($this, 'custom_nav'), 999);
20
+ add_filter('bp_media_multipart_params_filter', array($this, 'multipart_params_handler'));
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Handles the custom navigation structure of the BuddyPress Group Extension Media
26
+ *
27
+ * @uses global $bp
28
+ *
29
+ * @since BuddyPress Media 2.3
30
+ */
31
+ function custom_nav() {
32
+ global $bp;
33
+ $current_group = isset($bp->groups->current_group->slug) ? $bp->groups->current_group->slug : null;
34
+ if (!$current_group)
35
+ return;
36
+ if (!(isset($bp->bp_options_nav[$current_group]) && is_array($bp->bp_options_nav[$current_group])))
37
+ return;
38
+
39
+ /** This line might break a thing or two in custom themes and widgets */
40
+ remove_filter('bp_activity_get_user_join_filter', 'activity_query_filter', 10);
41
+
42
+ foreach ($bp->bp_options_nav[$current_group] as $key => $nav_item) {
43
+ switch ($nav_item['slug']) {
44
+ case BP_MEDIA_IMAGES_SLUG:
45
+ case BP_MEDIA_VIDEOS_SLUG:
46
+ case BP_MEDIA_AUDIO_SLUG:
47
+ case BP_MEDIA_ALBUMS_SLUG:
48
+ unset($bp->bp_options_nav[$current_group][$key]);
49
+ }
50
+ switch ($bp->current_action) {
51
+ case BP_MEDIA_IMAGES_SLUG:
52
+ case BP_MEDIA_VIDEOS_SLUG:
53
+ case BP_MEDIA_AUDIO_SLUG:
54
+ case BP_MEDIA_ALBUMS_SLUG:
55
+ $count = count($bp->action_variables);
56
+ for ($i = $count; $i > 0; $i--) {
57
+ $bp->action_variables[$i] = $bp->action_variables[$i - 1];
58
+ }
59
+ $bp->action_variables[0] = $bp->current_action;
60
+ $bp->current_action = BP_MEDIA_SLUG;
61
+ }
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Adds the current group id as parameter for plupload
67
+ *
68
+ * @param Array $multipart_params Array of Multipart Parameters to be passed on to plupload script
69
+ *
70
+ * @since BuddyPress Media 2.3
71
+ */
72
+ function multipart_params_handler($multipart_params) {
73
+ if (is_array($multipart_params)) {
74
+ global $bp;
75
+ if (isset($bp->current_action) && $bp->current_action == BP_MEDIA_SLUG
76
+ && isset($bp->action_variables) && empty($bp->action_variables)
77
+ && isset($bp->current_component) && $bp->current_component == 'groups'
78
+ && isset($bp->groups->current_group->id)) {
79
+ $multipart_params['bp_media_group_id'] = $bp->groups->current_group->id;
80
+ }
81
+ }
82
+ return $multipart_params;
83
+ }
84
+
85
+ /**
86
+ * Displays the navigation available to the group media tab for the
87
+ * logged in user.
88
+ *
89
+ * @uses $bp Global Variable set by BuddyPress
90
+ *
91
+ * @since BuddyPress Media 2.3
92
+ */
93
+ static function navigation_menu() {
94
+ global $bp;
95
+ if (!isset($bp->current_action) || $bp->current_action != BP_MEDIA_SLUG)
96
+ return false;
97
+ $current_tab = BPMediaGroup::can_upload() ? BP_MEDIA_UPLOAD_SLUG : BP_MEDIA_IMAGES_SLUG;
98
+ if (isset($bp->action_variables[0])) {
99
+ $current_tab = $bp->action_variables[0];
100
+ }
101
+
102
+ if (BPMediaGroup::can_upload()) {
103
+ $bp_media_nav[BP_MEDIA_UPLOAD_SLUG] = array(
104
+ 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . BP_MEDIA_SLUG,
105
+ 'label' => BP_MEDIA_UPLOAD_LABEL,
106
+ );
107
+ } else {
108
+ $bp_media_nav = array();
109
+ }
110
+
111
+ foreach (array('IMAGES', 'VIDEOS', 'AUDIO', 'ALBUMS') as $type) {
112
+ $bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array(
113
+ 'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'),
114
+ 'label' => constant('BP_MEDIA_' . $type . '_LABEL'),
115
+ );
116
+ }
117
+
118
+ /** This variable will be used to display the tabs in group component */
119
+ $bp_media_group_tabs = apply_filters('bp_media_group_tabs', $bp_media_nav, $current_tab);
120
+ ?>
121
+ <div class="item-list-tabs no-ajax bp-media-group-navigation" id="subnav">
122
+ <ul>
123
+ <?php
124
+ foreach ($bp_media_group_tabs as $tab_slug => $tab_info) {
125
+ echo '<li id="' . $tab_slug . '-group-li" ' . ($current_tab == $tab_slug ? 'class="current selected"' : '') . '><a id="' . $tab_slug . '" href="' . $tab_info['url'] . '" title="' . __($tab_info['label'], BP_MEDIA_TXT_DOMAIN) . '">' . __($tab_info['label'], BP_MEDIA_TXT_DOMAIN) . '</a></li>';
126
+ }
127
+ ?>
128
+ </ul>
129
+ </div>
130
+ <?php
131
+ }
132
+
133
+ /**
134
+ * Checks whether the current logged in user has the ability to upload on
135
+ * the given group or not
136
+ *
137
+ * @since BuddyPress Media 2.3
138
+ */
139
+ static function can_upload() {
140
+ /** @todo Implementation Pending */
141
+ global $bp;
142
+ if (isset($bp->loggedin_user->id) && is_numeric($bp->loggedin_user->id)) {
143
+ return groups_is_user_member($bp->loggedin_user->id, bp_get_current_group_id());
144
+ } else {
145
+ return false;
146
+ }
147
+
148
+ return true;
149
+ }
150
+
151
+ /**
152
+ * Adds the Media Settings menu for groups in the admin bar
153
+ *
154
+ * @uses global $bp,$wp_admin_bar
155
+ *
156
+ * @since BuddyPress Media 2.3
157
+ */
158
+ function admin_bar() {
159
+ global $wp_admin_bar, $bp;
160
+ $wp_admin_bar->add_menu(array(
161
+ 'parent' => $bp->group_admin_menu_id,
162
+ 'id' => 'bp-media-group',
163
+ 'title' => __('Media Settings', BP_MEDIA_TXT_DOMAIN),
164
+ 'href' => bp_get_groups_action_link('admin/media')
165
+ ));
166
+ }
167
+
168
+ //add_action('admin_bar_menu','admin_bar',99);
169
+ /* This will need some handling for checking if its a single group page or not, also whether the person can
170
+ * edit media settings or not
171
+ */
172
+
173
+ /**
174
+ * Checks whether a user can create an album in the given group or not
175
+ *
176
+ * @param string $group_id The group id to check against
177
+ * @param string $user_id The user to be checked for permission
178
+ *
179
+ * @return boolean True if the user can create an album in the group, false if not
180
+ */
181
+ static function user_can_create_album($group_id, $user_id = 0) {
182
+ if ($user_id == 0)
183
+ $user_id = get_current_user_id();
184
+ $current_level = groups_get_groupmeta($group_id, 'bp_media_group_control_level');
185
+ switch ($current_level) {
186
+ case 'all':
187
+ return groups_is_user_member($user_id, $group_id) || groups_is_user_mod($user_id, $group_id) || groups_is_user_admin($user_id, $group_id);
188
+ break;
189
+ case 'moderators':
190
+ return groups_is_user_mod($user_id, $group_id) || groups_is_user_admin($user_id, $group_id);
191
+ break;
192
+ case 'admin':
193
+ return groups_is_user_admin($user_id, $group_id);
194
+ break;
195
+ default :
196
+ return groups_is_user_admin($user_id, $group_id);
197
+ }
198
+ return false;
199
+ }
200
+
201
+ static function bp_media_display_error($errorMessage) {
202
+ ?>
203
+ <div id="message" class="error">
204
+ <p>
205
+ <?php _e($errorMessage, BP_MEDIA_TXT_DOMAIN); ?>
206
+ </p>
207
+ </div>
208
+ <?php
209
+ }
210
+
211
+ }
app/main/group/BPMediaGroupAction.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaGroupLoader
5
+ *
6
+ * @author faishal
7
+ */
8
+ class BPMediaGroupAction {
9
+
10
+ /**
11
+ * Called on bp_init by screen functions
12
+ *
13
+ * @uses global $bp, $bp_media_query
14
+ *
15
+ * @since BuddyPress Media 2.0
16
+ */
17
+ static function bp_media_groups_set_query() {
18
+ global $bp, $bp_media_query, $bp_media_posts_per_page;
19
+ if (isset($bp->current_action) && $bp->current_action == BP_MEDIA_SLUG) {
20
+ if (bp_action_variable(0)) {
21
+ switch (bp_action_variable(0)) {
22
+ case BP_MEDIA_IMAGES_SLUG:
23
+ $type = 'image';
24
+ break;
25
+ case BP_MEDIA_AUDIO_SLUG:
26
+ $type = 'audio';
27
+ break;
28
+ case BP_MEDIA_VIDEOS_SLUG:
29
+ $type = 'video';
30
+ break;
31
+ default :
32
+ $type = null;
33
+ }
34
+ if (bp_action_variable(1) == 'page' && is_numeric(bp_action_variable(2))) {
35
+ $paged = bp_action_variable(2);
36
+ } else {
37
+ $paged = 1;
38
+ }
39
+ if ($type) {
40
+ $args = array(
41
+ 'post_type' => 'attachment',
42
+ 'post_status' => 'any',
43
+ 'post_mime_type' => $type,
44
+ 'meta_key' => 'bp-media-key',
45
+ 'meta_value' => -bp_get_current_group_id(),
46
+ 'meta_compare' => '=',
47
+ 'paged' => $paged,
48
+ 'posts_per_page' => $bp_media_posts_per_page
49
+ );
50
+ $bp_media_query = new WP_Query($args);
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Called on bp_init by screen functions
58
+ * Initializes the albums query for groups
59
+ *
60
+ * @uses global $bp, $bp_media_albums_query
61
+ *
62
+ * @since BuddyPress Media 2.2
63
+ */
64
+ static function bp_media_groups_albums_set_query() {
65
+ global $bp, $bp_media_albums_query;
66
+ if (isset($bp->action_variables) && isset($bp->action_variables[1]) && $bp->action_variables[1] == 'page' && isset($bp->action_variables[2]) && is_numeric($bp->action_variables[2])) {
67
+ $paged = $bp->action_variables[2];
68
+ } else {
69
+ $paged = 1;
70
+ }
71
+
72
+ if (isset($bp->action_variables[0]) && $bp->action_variables[0] == BP_MEDIA_ALBUMS_SLUG) {
73
+ $args = array(
74
+ 'post_type' => 'bp_media_album',
75
+ 'paged' => $paged,
76
+ 'meta_key' => 'bp-media-key',
77
+ 'meta_value' => -bp_get_current_group_id(),
78
+ 'meta_compare' => '='
79
+ );
80
+ $bp_media_albums_query = new WP_Query($args);
81
+
82
+ }
83
+ }
84
+
85
+ static function bp_media_groups_activity_create_after_add_media($media, $hidden = false) {
86
+ if (function_exists('bp_activity_add')) {
87
+ if (!is_object($media)) {
88
+ try {
89
+ $media = new BPMediaHostWordpress($media);
90
+ } catch (exception $e) {
91
+ return false;
92
+ }
93
+ }
94
+ $args = array(
95
+ 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media->get_author()), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>')),
96
+ 'content' => $media->get_media_activity_content(),
97
+ 'primary_link' => $media->get_url(),
98
+ 'item_id' => $media->get_id(),
99
+ 'type' => 'media_upload',
100
+ 'user_id' => $media->get_author()
101
+ );
102
+ $hidden = apply_filters('bp_media_force_hide_activity', $hidden);
103
+ if ($hidden) {
104
+ $args['secondary_item_id'] = -999;
105
+ //do_action('bp_media_album_updated',$media->get_album_id());
106
+ }
107
+ $activity_id = BPMediaFunction::record_activity($args);
108
+ add_post_meta($media->get_id(), 'bp_media_child_activity', $activity_id);
109
+ }
110
+ }
111
+
112
+ //add_action('bp_media_groups_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
113
+
114
+ static function bp_media_groups_redirection_handler() {
115
+ global $bp;
116
+ echo '<pre>';
117
+ var_dump($bp);
118
+ echo '</pre>';
119
+ die();
120
+ }
121
+
122
+ //add_action('bp_media_init','bp_media_groups_redirection_handler');
123
+
124
+ static function bp_media_groups_force_hide_activity() {
125
+ return true;
126
+ }
127
+
128
+ }
app/main/group/BPMediaGroupElementExtension.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupElementExtension
4
+ *
5
+ * @author faishal
6
+ */
7
+ if (class_exists('BP_Group_Extension')) :
8
+
9
+ class BPMediaGroupElementExtension extends BP_Group_Extension {
10
+
11
+ var $enable_edit_item = false;
12
+ var $enable_create_step = false;
13
+
14
+ function __construct($name, $slug) {
15
+ $this->name = $name;
16
+ $this->slug = $slug;
17
+ }
18
+
19
+ function display() {
20
+ global $bp;
21
+ BPMediaGroupAction::bp_media_groups_set_query();
22
+ if (bp_action_variable(0)) {
23
+ BPMediaGroup::navigation_menu();
24
+ $media_type = "";
25
+ $slug = "";
26
+ switch (bp_action_variable(0)) {
27
+ case BP_MEDIA_IMAGES_SLUG:
28
+ $media_type = "image";
29
+ $slug = BP_MEDIA_IMAGES_SLUG;
30
+ //BPMediaGroup::bp_media_groups_images_screen();
31
+ break;
32
+ case BP_MEDIA_VIDEOS_SLUG:
33
+ $media_type = "video";
34
+ $slug = BP_MEDIA_VIDEOS_SLUG;
35
+ break;
36
+ case BP_MEDIA_AUDIO_SLUG:
37
+ $media_type = "audio";
38
+ $slug = BP_MEDIA_AUDIO_SLUG;
39
+ break;
40
+ case BP_MEDIA_ALBUMS_SLUG:
41
+ $media_type = "album";
42
+ $slug = BP_MEDIA_ALBUMS_SLUG;
43
+ break;
44
+ default:
45
+ /** @todo Error is to be displayed for 404 */
46
+ }
47
+ if ($slug != "" && $media_type != "") {
48
+ if (isset($bp->action_variables[1])) {
49
+ switch ($bp->action_variables[1]) {
50
+ case 'edit':
51
+ //Edit screen for image
52
+ break;
53
+ case 'delete':
54
+ //Delete function for media file
55
+ break;
56
+ default:
57
+ if (intval(bp_action_variable(1)) > 0) {
58
+ global $bp_media_current_entry;
59
+ try {
60
+ $bp_media_current_entry = new BPMediaHostWordpress(bp_action_variable(1));
61
+ if ($bp_media_current_entry->get_group_id() != bp_get_current_group_id())
62
+ throw new Exception(__('Sorry, the requested media does not belong to the group', BP_MEDIA_TXT_DOMAIN));
63
+ } catch (Exception $e) {
64
+ /** Error Handling when media not present or not belong to the group */
65
+ bp_media_display_error($e->getMessage());
66
+ return;
67
+ }
68
+ if ($media_type == "album") {
69
+ $bp_media_content = new BPMediaAlbumScreen($media_type, BP_MEDIA_ALBUMS_ENTRY_SLUG);
70
+ $bp->action_variables[ 0 ]= BP_MEDIA_ALBUMS_ENTRY_SLUG;
71
+ $bp_media_content->entry_screen();
72
+ } else {
73
+ $bp_media_content = new BPMediaScreen($media_type, $slug);
74
+ }
75
+ $bp_media_content->entry_screen_content();
76
+
77
+ break;
78
+ } else {
79
+ /** @todo display 404 */
80
+ }
81
+ }
82
+ } else {
83
+ if ($media_type == "album") {
84
+ BPMediaGroupAction::bp_media_groups_albums_set_query();
85
+ $bp_media_content = new BPMediaAlbumScreen($media_type, $slug);
86
+ } else {
87
+ $bp_media_content = new BPMediaScreen($media_type, $slug);
88
+ }
89
+ $bp_media_content->screen_content();
90
+ }
91
+ }
92
+ } else {
93
+
94
+ if (BPMediaGroup::can_upload()) {
95
+ BPMediaGroup::navigation_menu();
96
+ $bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG);
97
+ $bp_media_upload->upload_screen_content();
98
+ } else {
99
+ $bp->action_variables[0] = BP_MEDIA_IMAGES_SLUG;
100
+ BPMediaGroupAction::bp_media_groups_set_query();
101
+ $this->display();
102
+ }
103
+ }
104
+ }
105
+
106
+ function widget_display() {
107
+
108
+ }
109
+
110
+ function bp_media_display_error($errorMessage) {
111
+ ?>
112
+ <div id="message" class="error">
113
+ <p>
114
+ <?php _e($errorMessage, BP_MEDIA_TXT_DOMAIN); ?>
115
+ </p>
116
+ </div>
117
+ <?php
118
+ }
119
+
120
+ }
121
+
122
+ endif;
123
+ //bp_register_group_extension("BP_Media_Group_Extension_' . constant('BP_MEDIA_' . $item . '_SLUG') . '" );
124
+ ?>
app/main/group/BPMediaGroupsExtension.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupLoader
4
+ *
5
+ * @author faishal
6
+ */
7
+ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems during upgrade or when Groups are disabled
8
+
9
+ class BPMediaGroupsExtension extends BPMediaGroupElementExtension {
10
+
11
+ /**
12
+ * Constructor for the BP_Group_Extension adding values to the variables defined
13
+ *
14
+ * @uses global $bp
15
+ *
16
+ * @since BuddyPress Media 2.3
17
+ */
18
+ function __construct() {
19
+ global $bp;
20
+ $this->name = BP_MEDIA_LABEL;
21
+ $this->slug = BP_MEDIA_SLUG;
22
+ $this->create_step_position = 21;
23
+ $this->nav_item_position = 31;
24
+ }
25
+
26
+ function create_screen() {
27
+ global $bp_media;
28
+ if (!bp_is_group_creation_step($this->slug))
29
+ return false;
30
+ ?>
31
+ <h4><?php _e("Album Creation Control", BP_MEDIA_TXT_DOMAIN); ?></h4>
32
+ <p><?php _e("Who can create Albums in this group?", BP_MEDIA_TXT_DOMAIN); ?></p>
33
+ <div class="radio">
34
+ <label>
35
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" checked="checked" value="all">
36
+ <strong><?php _e("All Group Members", BP_MEDIA_TXT_DOMAIN); ?></strong>
37
+ </label>
38
+ <label>
39
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators">
40
+ <strong><?php _e("Group Admins and Mods only", BP_MEDIA_TXT_DOMAIN); ?></strong>
41
+ </label>
42
+ <label>
43
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin">
44
+ <strong><?php _e("Group Admin only", BP_MEDIA_TXT_DOMAIN); ?></strong>
45
+ </label>
46
+ </div>
47
+
48
+ <?php
49
+ wp_nonce_field('groups_create_save_' . $this->slug);
50
+ }
51
+
52
+ function create_screen_save() {
53
+ global $bp;
54
+
55
+ check_admin_referer('groups_create_save_' . $this->slug);
56
+
57
+ /* Save any details submitted here */
58
+ if (isset($_POST['bp_album_creation_control']) && $_POST['bp_album_creation_control'] != '')
59
+ groups_update_groupmeta($bp->groups->new_group_id, 'bp_media_group_control_level', $_POST['bp_album_creation_control']);
60
+ }
61
+
62
+ function edit_screen() {
63
+ global $bp_media;
64
+ if (!bp_is_group_admin_screen($this->slug))
65
+ return false;
66
+ $current_level = groups_get_groupmeta(bp_get_current_group_id(), 'bp_media_group_control_level');
67
+ ?>
68
+
69
+ <h4><?php _e("Album Creation Control", BP_MEDIA_TXT_DOMAIN); ?></h4>
70
+ <p><?php _e("Who can create Albums in this group?", BP_MEDIA_TXT_DOMAIN); ?></p>
71
+ <div class="radio">
72
+ <label>
73
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="all"<?php checked($current_level, 'all', true) ?>>
74
+ <strong><?php _e("All Group Members", BP_MEDIA_TXT_DOMAIN); ?></strong>
75
+ </label>
76
+ <label>
77
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators" <?php checked($current_level, 'moderators', true) ?>>
78
+ <strong><?php _e("Group Admins and Mods only", BP_MEDIA_TXT_DOMAIN); ?></strong>
79
+ </label>
80
+ <label>
81
+ <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin" <?php checked($current_level, 'admin', true) ?>>
82
+ <strong><?php _e("Group Admin only", BP_MEDIA_TXT_DOMAIN); ?></strong>
83
+ </label>
84
+ </div>
85
+ <hr>
86
+ <input type="submit" name="save" value="<?php _e("Save Changes", BP_MEDIA_TXT_DOMAIN); ?> />
87
+ <?php
88
+ wp_nonce_field('groups_edit_save_' . $this->slug);
89
+ }
90
+
91
+ function edit_screen_save() {
92
+ global $bp, $bp_media;
93
+
94
+ if (!isset($_POST['save']))
95
+ return false;
96
+
97
+ check_admin_referer('groups_edit_save_' . $this->slug);
98
+
99
+ if (isset($_POST['bp_album_creation_control']) && $_POST['bp_album_creation_control'] != '')
100
+ $success = groups_update_groupmeta(bp_get_current_group_id(), 'bp_media_group_control_level', $_POST['bp_album_creation_control']);
101
+ else
102
+ $success = false;
103
+
104
+ /* To post an error/success message to the screen, use the following */
105
+ if (!$success)
106
+ bp_core_add_message(__('There was an error saving, please try again', BP_MEDIA_TXT_DOMAIN), 'error');
107
+ else
108
+ bp_core_add_message(__('Settings saved successfully', BP_MEDIA_TXT_DOMAIN));
109
+
110
+ bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . '/admin/' . $this->slug);
111
+ }
112
+
113
+ /**
114
+ * The display method for the extension
115
+ *
116
+ * @since BuddyPress Media 2.3
117
+ */
118
+ function widget_display() {
119
+ global $bp_media;
120
+ ?>
121
+ <div class="info-group" >
122
+ <h4><?php echo esc_attr($this->name) ?></h4>
123
+ <p>
124
+ <?php _e("You could display a small snippet of information from your group extension here. It will show on the group
125
+ home screen.", BP_MEDIA_TXT_DOMAIN); ?>
126
+ </p>
127
+ </div>
128
+ <?php
129
+ }
130
+
131
+
132
+
133
+ }
134
+
135
+
136
+ endif; // class_exists( 'BP_Group_Extension' )
app/main/group/dummy/BPMediaGroupAlbum.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupImage
4
+ *
5
+ * @author faishal
6
+ */
7
+ if ( class_exists( 'BP_Group_Extension' ) ) :
8
+ class BPMediaGroupAlbum extends BPMediaGroupElementExtension {
9
+
10
+ function __construct() {
11
+ parent::__construct(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_ALBUMS_SLUG);
12
+ bp_register_group_extension("BPMediaGroupAlbum");
13
+ }
14
+
15
+ }
16
+ endif;
17
+ ?>
app/main/group/dummy/BPMediaGroupImage.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupImage
4
+ *
5
+ * @author faishal
6
+ */
7
+ if ( class_exists( 'BP_Group_Extension' ) ) :
8
+ class BPMediaGroupImage extends BPMediaGroupElementExtension {
9
+
10
+ function __construct() {
11
+ parent::__construct(BP_MEDIA_IMAGES_LABEL, BP_MEDIA_IMAGES_SLUG);
12
+ bp_register_group_extension("BPMediaGroupImage");
13
+ }
14
+
15
+ }
16
+ endif;
17
+ ?>
app/main/group/dummy/BPMediaGroupMusic.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupImage
4
+ *
5
+ * @author faishal
6
+ */
7
+ if ( class_exists( 'BP_Group_Extension' ) ) :
8
+ class BPMediaGroupMusic extends BPMediaGroupElementExtension {
9
+
10
+ function __construct() {
11
+ parent::__construct(BP_MEDIA_AUDIO_LABEL, BP_MEDIA_AUDIO_SLUG);
12
+ bp_register_group_extension("BPMediaGroupMusic");
13
+ }
14
+
15
+ }
16
+ endif;
17
+ ?>
app/main/group/dummy/BPMediaGroupVideo.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaGroupImage
4
+ *
5
+ * @author faishal
6
+ */
7
+ if ( class_exists( 'BP_Group_Extension' ) ) :
8
+ class BPMediaGroupVideo extends BPMediaGroupElementExtension {
9
+
10
+ function __construct() {
11
+ parent::__construct(BP_MEDIA_VIDEOS_LABEL, BP_MEDIA_VIDEOS_SLUG);
12
+ bp_register_group_extension("BPMediaGroupVideo");
13
+ }
14
+
15
+ }
16
+ endif;
17
+ ?>
app/main/includes/BPMediaActions.php ADDED
@@ -0,0 +1,582 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Description of BPMediaActions
4
+ *
5
+ * @author faishal
6
+ */
7
+ class BPMediaActions {
8
+
9
+ function __construct() {
10
+ add_action('bp_media_before_content', 'BPMediaActions::show_messages');
11
+ add_action('wp_enqueue_scripts', array($this,'enqueue_scripts_styles'), 11);
12
+ add_action('bp_before_activity_delete', 'BPMediaActions::delete_activity_handler');
13
+ add_action('wp_enqueue_scripts', array($this,'upload_enqueue'));
14
+ add_action('init', 'BPMediaActions::init_count');
15
+ add_action('bp_activity_entry_meta', array($this,'action_buttons'));
16
+ add_action('bp_media_before_delete_media', 'BPMediaActions::delete_media_handler');
17
+ add_action('bp_media_after_add_album', array($this,'album_create_activity'));
18
+ add_action('bp_media_album_updated', array($this,'album_activity_update'));
19
+ add_action('bp_media_after_delete_media', array($this,'album_activity_sync'));
20
+ add_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 2);
21
+ add_action('wp_ajax_bp_media_load_more', array($this,'load_more'));
22
+ add_action('wp_ajax_nopriv_bp_media_load_more', array($this,'load_more'));
23
+ add_action('delete_attachment', array($this,'delete_attachment_handler'));
24
+ add_action('wp_ajax_bp_media_add_album', array($this,'add_album'));
25
+ add_action('wp_ajax_nopriv_bp_media_add_album', array($this,'add_album'));
26
+ global $bp_media_options;
27
+ if (isset($bp_media_options['remove_linkback']) && $bp_media_options['remove_linkback'] != '1')
28
+ add_action('bp_footer', array($this,'footer'));
29
+ }
30
+
31
+ /**
32
+ * Handles the uploads and creates respective posts for the upload
33
+ *
34
+ * @since BuddyPress Media 2.0
35
+ */
36
+ static function handle_uploads() {
37
+ global $bp, $bp_media_options;
38
+ $bp_media_options = get_site_option('bp_media_options', array(
39
+ 'videos_enabled' => true,
40
+ 'audio_enabled' => true,
41
+ 'images_enabled' => true,
42
+ ));
43
+ if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
44
+ /** This section can help in the group activity handling */
45
+ if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id'])) {
46
+ remove_action('bp_media_after_add_media','BPMediaActions::activity_create_after_add_media', 10, 2);
47
+ add_action('bp_media_after_add_media', 'BPMediaGroupAction::bp_media_groups_activity_create_after_add_media', 10, 2);
48
+ add_filter('bp_media_force_hide_activity', 'bp_media_groups_force_hide_activity');
49
+ }
50
+ /* @var $bp_media_entry BPMediaHostWordpress */
51
+ if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
52
+ if (!preg_match('/audio|video|image/i', $_FILES['bp_media_file']['type'], $result) || !isset($result[0])) {
53
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
54
+ return;
55
+ }
56
+ $type = $result[0];
57
+ switch ($result[0]) {
58
+ case 'image' :
59
+ if ($bp_media_options['images_enabled'] == false) {
60
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Image uploads are disabled');
61
+ return;
62
+ }
63
+ break;
64
+ case 'video' :
65
+ if ($bp_media_options['videos_enabled'] == false) {
66
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Video uploads are disabled');
67
+ return;
68
+ }
69
+ break;
70
+ case 'audio' :
71
+ if ($bp_media_options['audio_enabled'] == false) {
72
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Audio uploads are disabled');
73
+ return;
74
+ }
75
+ break;
76
+ default :
77
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
78
+ return;
79
+ }
80
+ $class_name = apply_filters('bp_media_transcoder', 'BPMediaHostWordpress', $type);
81
+ $bp_media_entry = new $class_name();
82
+ try {
83
+ $title = isset($_POST['bp_media_title']) ? ($_POST['bp_media_title'] != "") ? $_POST['bp_media_title'] : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME) : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME);
84
+ $album_id = isset($_POST['bp_media_album_id']) ? intval($_POST['bp_media_album_id']) : 0;
85
+ $is_multiple = isset($_POST['is_multiple_upload']) ? ($_POST['is_multiple_upload'] == 'true' ? true : false) : false;
86
+ $description = isset($_POST['bp_media_description']) ? $_POST['bp_media_description'] : '';
87
+ $group_id = isset($_POST['bp_media_group_id']) ? intval($_POST['bp_media_group_id']) : 0;
88
+ $entry = $bp_media_entry->add_media($title, $description, $album_id, $group_id, $is_multiple);
89
+ if (!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
90
+ $bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', BP_MEDIA_TXT_DOMAIN);
91
+ } catch (Exception $e) {
92
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
93
+ }
94
+ } else {
95
+ $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', BP_MEDIA_TXT_DOMAIN);
96
+ }
97
+ }
98
+ }
99
+
100
+ //add_action('bp_init', 'handle_uploads');
101
+
102
+ /**
103
+ * Displays the messages that other functions/methods creates according to the BuddyPress' formating
104
+ *
105
+ * @since BuddyPress Media 2.0
106
+ */
107
+ static function show_messages() {
108
+ global $bp;
109
+ if (is_array($bp->{BP_MEDIA_SLUG}->messages)) {
110
+ $types = array('error', 'updated', 'info');
111
+ foreach ($types as $type) {
112
+ if (count($bp->{BP_MEDIA_SLUG}->messages[$type]) > 0) {
113
+ BPMediaFunction::show_formatted_error_message($bp->{BP_MEDIA_SLUG}->messages[$type], $type);
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media.
121
+ *
122
+ * @since BuddyPress Media 2.0
123
+ */
124
+ function enqueue_scripts_styles() {
125
+
126
+ wp_enqueue_script('jquery-ui-tabs');
127
+ wp_enqueue_script('bp-media-mejs', BP_MEDIA_URL . 'lib/media-element/mediaelement-and-player.min.js');
128
+ wp_enqueue_script('bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js');
129
+ global $bp;
130
+ $cur_group_id = NULL;
131
+ if (bp_is_active("groups"))
132
+ $cur_group_id = bp_get_current_group_id();
133
+ $bp_media_vars = array(
134
+ 'ajaxurl' => admin_url('admin-ajax.php'),
135
+ 'page' => 1,
136
+ 'current_action' => $cur_group_id ? (empty($bp->action_variables) ? BP_MEDIA_IMAGES_SLUG : $bp->action_variables) : (isset($bp->current_action) ? $bp->current_action : false),
137
+ 'action_variables' => isset($bp->action_variables) ? (empty($bp->action_variables) ? array(BP_MEDIA_IMAGES_SLUG) : $bp->action_variables) : array(BP_MEDIA_IMAGES_SLUG),
138
+ 'displayed_user' => bp_displayed_user_id(),
139
+ 'loggedin_user' => bp_loggedin_user_id(),
140
+ 'current_group' => $cur_group_id
141
+ );
142
+
143
+ wp_localize_script('bp-media-default', 'bp_media_vars', $bp_media_vars);
144
+ wp_enqueue_style('bp-media-mecss', BP_MEDIA_URL . 'lib/media-element/mediaelementplayer.min.css');
145
+ wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
146
+ }
147
+
148
+ static function delete_activity_handler($args) {
149
+ remove_action('bp_media_before_delete_media', 'BPMediaActions::delete_media_handler');
150
+ global $bp_media_count, $wpdb;
151
+ if (!array_key_exists('id', $args))
152
+ return;
153
+
154
+ $activity_id = $args['id'];
155
+ if (intval($activity_id)) {
156
+ $query = "SELECT post_id from $wpdb->postmeta WHERE meta_key='bp_media_child_activity' AND meta_value={$activity_id}";
157
+ $result = $wpdb->get_results($query);
158
+ if (!(is_array($result) && count($result) == 1 ))
159
+ return;
160
+ $post_id = $result[0]->post_id;
161
+ try {
162
+ $post = get_post($post_id);
163
+ if (!isset($post->post_type))
164
+ return false;
165
+ switch ($post->post_type) {
166
+ case 'attachment':
167
+ $media = new BPMediaHostWordpress($post_id);
168
+ $media->delete_media();
169
+ break;
170
+ case 'bp_media_album':
171
+ $album = new BPMediaAlbum($post_id);
172
+ $album->delete_album();
173
+ break;
174
+ default:
175
+ wp_delete_post($post_id);
176
+ }
177
+ } catch (Exception $e) {
178
+ error_log('Media tried to delete was already deleted');
179
+ }
180
+ }
181
+ }
182
+
183
+ static function delete_media_handler($media_id) {
184
+ /* @var $media BPMediaHostWordpress */
185
+ remove_action('bp_before_activity_delete','BPMediaActions::delete_activity_handler');
186
+ $activity_id = get_post_meta($media_id, 'bp_media_child_activity', true);
187
+ if ($activity_id == NULL)
188
+ return false;
189
+ bp_activity_delete_by_activity_id($activity_id);
190
+ }
191
+
192
+ /**
193
+ * Called on bp_init by screen functions
194
+ *
195
+ * @uses global $bp, $bp_media_query
196
+ *
197
+ * @since BuddyPress Media 2.0
198
+ */
199
+ function set_query() {
200
+ global $bp, $bp_media_query, $bp_media_posts_per_page;
201
+ switch ($bp->current_action) {
202
+ case BP_MEDIA_IMAGES_SLUG:
203
+ $type = 'image';
204
+ break;
205
+ case BP_MEDIA_AUDIO_SLUG:
206
+ $type = 'audio';
207
+ break;
208
+ case BP_MEDIA_VIDEOS_SLUG:
209
+ $type = 'video';
210
+ break;
211
+ default :
212
+ $type = null;
213
+ }
214
+ if (isset($bp->action_variables) && is_array($bp->action_variables) && isset($bp->action_variables[0]) && $bp->action_variables[0] == 'page' && isset($bp->action_variables[1]) && is_numeric($bp->action_variables[1])) {
215
+ $paged = $bp->action_variables[1];
216
+ } else {
217
+ $paged = 1;
218
+ }
219
+ if ($type) {
220
+ $args = array(
221
+ 'post_type' => 'attachment',
222
+ 'post_status' => 'any',
223
+ 'post_mime_type' => $type,
224
+ 'author' => $bp->displayed_user->id,
225
+ 'meta_key' => 'bp-media-key',
226
+ 'meta_value' => $bp->displayed_user->id,
227
+ 'meta_compare' => '=',
228
+ 'paged' => $paged,
229
+ 'posts_per_page' => $bp_media_posts_per_page
230
+ );
231
+ $bp_media_query = new WP_Query($args);
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Adds a download button and edit button on single entry pages of media files.
237
+ *
238
+ * @uses $bp_media_options Global variable
239
+ *
240
+ * @since BuddyPress Media 2.0
241
+ */
242
+ function action_buttons() {
243
+ global $bp_media;
244
+ if (!in_array('bp_media_current_entry', $GLOBALS))
245
+ return false;
246
+ global $bp_media_current_entry, $bp_media_options;
247
+
248
+ if ($bp_media_current_entry != NULL) {
249
+ $featured_post = get_post_meta($bp_media_current_entry->get_id(), 'featured', true);
250
+
251
+ if (bp_displayed_user_id() == bp_loggedin_user_id())
252
+ echo '<a href="' . $bp_media_current_entry->get_edit_url()
253
+ . '" class="button item-button bp-secondary-action bp-media-edit" title="'
254
+ . __('Edit Media', BP_MEDIA_TXT_DOMAIN) . '">' . __('Edit', BP_MEDIA_TXT_DOMAIN) . '</a>';
255
+
256
+ if ($bp_media_options['download_enabled'] == true)
257
+ echo '<a href="' . $bp_media_current_entry->get_attachment_url()
258
+ . '" class="button item-button bp-secondary-action bp-media-download" title="'
259
+ . __('Download', BP_MEDIA_TXT_DOMAIN) . '">' . __('Download', BP_MEDIA_TXT_DOMAIN) . '</a>';
260
+
261
+ if (bp_displayed_user_id() == bp_loggedin_user_id() && $featured_post == '')
262
+ echo '<a href="' . $bp_media_current_entry->get_album_id()
263
+ . '" rel="" data-album-id="' . $bp_media_current_entry->get_album_id()
264
+ . '" data-post-id="' . $bp_media_current_entry->get_id()
265
+ . '" class="button item-button bp-secondary-action bp-media-featured" title="'
266
+ . __('Featured Media', BP_MEDIA_TXT_DOMAIN) . '">' . __('Featured', BP_MEDIA_TXT_DOMAIN) . '</a>';
267
+ else
268
+ echo '<a href="' . $bp_media_current_entry->get_album_id() . '" rel="" data-remove-featured="1" data-album-id="'
269
+ . $bp_media_current_entry->get_album_id() . '" data-post-id="' . $bp_media_current_entry->get_id()
270
+ . '" class="button item-button bp-secondary-action bp-media-featured" title="'
271
+ . __('Featured Media', BP_MEDIA_TXT_DOMAIN) . '">' . __('Remove Featured', BP_MEDIA_TXT_DOMAIN) . '</a>';
272
+ }
273
+ }
274
+
275
+ /* Should be used with Content Disposition Type for media files set to attachment */
276
+
277
+ /**
278
+ * Shows the media count of a user in the tabs
279
+ *
280
+ * @since BuddyPress Media 2.0
281
+ */
282
+ static function init_count($user = null) {
283
+ global $bp_media_count;
284
+ if (!$user)
285
+ $user = bp_displayed_user_id();
286
+ if ($user < 1) {
287
+ $bp_media_count = null;
288
+ return false;
289
+ }
290
+ $count = bp_get_user_meta($user, 'bp_media_count', true);
291
+ if (!$count) {
292
+ $bp_media_count = array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0);
293
+ bp_update_user_meta($user, 'bp_media_count', $bp_media_count);
294
+ } else {
295
+ $bp_media_count = $count;
296
+ }
297
+ add_filter('bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
298
+
299
+ if (bp_current_component() == BP_MEDIA_SLUG) {
300
+ add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
301
+ add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
302
+ add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
303
+ add_filter('bp_get_options_nav_' . BP_MEDIA_ALBUMS_SLUG, 'BPMediaFilters::items_count_filter', 10, 2);
304
+ }
305
+ return true;
306
+ }
307
+
308
+ /**
309
+ * Displays the footer of the BuddyPress Media Plugin if enabled through the dashboard options page
310
+ *
311
+ * @since BuddyPress Media 2.0
312
+ */
313
+ function footer() {
314
+ ?>
315
+ <div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
316
+ <?php
317
+ }
318
+
319
+ function upload_enqueue() {
320
+ $params = array(
321
+ 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
322
+ 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
323
+ 'browse_button' => 'bp-media-upload-browse-button',
324
+ 'container' => 'bp-media-upload-ui',
325
+ 'drop_element' => 'drag-drop-area',
326
+ 'filters' => apply_filters('bp_media_plupload_files_filter', array(array('title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3"))),
327
+ 'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
328
+ 'multipart' => true,
329
+ 'urlstream_upload' => true,
330
+ 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
331
+ 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
332
+ 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
333
+ 'multi_selection' => true,
334
+ 'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
335
+ );
336
+ 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'));
337
+ wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
338
+ wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
339
+ // wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
340
+ //wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
341
+ }
342
+
343
+ //This is used only on the uploads page so its added as action in the screens function of upload page.
344
+
345
+ /**
346
+ * Called on bp_init by screen functions
347
+ *
348
+ * @uses global $bp, $bp_media_albums_query
349
+ *
350
+ * @since BuddyPress Media 2.2
351
+ */
352
+ function albums_set_query() {
353
+ global $bp, $bp_media_albums_query;
354
+ if (isset($bp->action_variables) && is_array($bp->action_variables) && isset($bp->action_variables[0]) && $bp->action_variables[0] == 'page' && isset($bp->action_variables[1]) && is_numeric($bp->action_variables[1])) {
355
+ $paged = $bp->action_variables[1];
356
+ } else {
357
+ $paged = 1;
358
+ }
359
+ if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
360
+ $args = array(
361
+ 'post_type' => 'bp_media_album',
362
+ 'author' => $bp->displayed_user->id,
363
+ 'paged' => $paged,
364
+ 'meta_key' => 'bp-media-key',
365
+ 'meta_value' => $bp->displayed_user->id,
366
+ 'meta_compare' => '='
367
+ );
368
+ $bp_media_albums_query = new WP_Query($args);
369
+ }
370
+ }
371
+
372
+ /**
373
+ * Function to return the media for the ajax requests
374
+ */
375
+ function load_more() {
376
+ global $bp, $bp_media_query, $bp_media_posts_per_page;
377
+ $page = isset($_POST['page']) ? $_POST['page'] : die();
378
+ $current_action = isset($_POST['current_action']) ? $_POST['current_action'] : null;
379
+ $action_variables = isset($_POST['action_variables']) ? $_POST['action_variables'] : null;
380
+ $displayed_user = isset($_POST['displayed_user']) ? $_POST['displayed_user'] : null;
381
+ $loggedin_user = isset($_POST['loggedin_user']) ? $_POST['loggedin_user'] : null;
382
+ $current_group = isset($_POST['current_group']) ? $_POST['current_group'] : null;
383
+ if ((!$displayed_user || intval($displayed_user) == 0) && (!$current_group || intval($current_group) == 0)) {
384
+ die();
385
+ }
386
+ switch ($current_action) {
387
+ case BP_MEDIA_IMAGES_SLUG:
388
+ $args = array(
389
+ 'post_type' => 'attachment',
390
+ 'post_status' => 'any',
391
+ 'post_mime_type' => 'image',
392
+ 'meta_key' => 'bp-media-key',
393
+ 'meta_value' => $current_group > 0 ? -$current_group : $bp->displayed_user->id,
394
+ 'meta_compare' => '=',
395
+ 'paged' => $page,
396
+ 'posts_per_page' => $bp_media_posts_per_page
397
+ );
398
+ break;
399
+ case BP_MEDIA_AUDIO_SLUG:
400
+ $args = array(
401
+ 'post_type' => 'attachment',
402
+ 'post_status' => 'any',
403
+ 'post_mime_type' => 'audio',
404
+ 'author' => $bp->displayed_user->id,
405
+ 'meta_key' => 'bp-media-key',
406
+ 'meta_value' => $current_group > 0 ? -$current_group : $bp->displayed_user->id,
407
+ 'meta_compare' => '=',
408
+ 'paged' => $page,
409
+ 'posts_per_page' => $bp_media_posts_per_page
410
+ );
411
+ break;
412
+ case BP_MEDIA_VIDEOS_SLUG:
413
+ $args = array(
414
+ 'post_type' => 'attachment',
415
+ 'post_status' => 'any',
416
+ 'post_mime_type' => 'video',
417
+ 'author' => $bp->displayed_user->id,
418
+ 'meta_key' => 'bp-media-key',
419
+ 'meta_value' => $current_group > 0 ? -$current_group : $bp->displayed_user->id,
420
+ 'meta_compare' => '=',
421
+ 'paged' => $page,
422
+ 'posts_per_page' => $bp_media_posts_per_page
423
+ );
424
+ break;
425
+ case BP_MEDIA_ALBUMS_SLUG:
426
+ if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0]) && isset($action_variables[1])) {
427
+ $args = array(
428
+ 'post_type' => 'attachment',
429
+ 'post_status' => 'any',
430
+ 'author' => $displayed_user,
431
+ 'post_parent' => $action_variables[1],
432
+ 'paged' => $page,
433
+ 'posts_per_page' => $bp_media_posts_per_page
434
+ );
435
+ } else {
436
+ $args = array(
437
+ 'post_type' => 'bp_media_album',
438
+ 'author' => $displayed_user,
439
+ 'paged' => $page,
440
+ 'posts_per_page' => $bp_media_posts_per_page
441
+ );
442
+ }
443
+ break;
444
+ default:
445
+ die();
446
+ }
447
+ $bp_media_query = new WP_Query($args);
448
+ if (isset($bp_media_query->posts) && is_array($bp_media_query->posts) && count($bp_media_query->posts)) {
449
+ foreach ($bp_media_query->posts as $attachment) {
450
+ try {
451
+ $media = new BPMediaHostWordpress($attachment->ID);
452
+ echo $media->get_media_gallery_content();
453
+ } catch (exception $e) {
454
+ die();
455
+ }
456
+ }
457
+ }
458
+ die();
459
+ }
460
+
461
+ function delete_attachment_handler($attachment_id) {
462
+ if (get_post_meta($attachment_id, 'bp-media-key')) {
463
+ do_action('bp_media_before_delete_media', $attachment_id);
464
+ global $bp_media_count;
465
+ $attachment = get_post($attachment_id);
466
+ preg_match_all('/audio|video|image/i', $attachment->post_mime_type, $result);
467
+ if (isset($result[0][0]))
468
+ $type = $result[0][0];
469
+ else
470
+ return false;
471
+ BPMediaActions::init_count($attachment->post_author);
472
+ switch ($type) {
473
+ case 'image':
474
+ $images = intval($bp_media_count['images']) ? intval($bp_media_count['images']) : 0;
475
+ $bp_media_count['images'] = $images - 1;
476
+ break;
477
+ case 'audio':
478
+ $bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
479
+ break;
480
+ case 'video':
481
+ $bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
482
+ break;
483
+ default:
484
+ return false;
485
+ }
486
+ bp_update_user_meta($attachment->post_author, 'bp_media_count', $bp_media_count);
487
+ do_action('bp_media_after_delete_media', $attachment_id);
488
+ return true;
489
+ }
490
+ }
491
+
492
+ /**
493
+ * Function to create new album called via ajax request
494
+ */
495
+ function add_album() {
496
+ if (isset($_POST['bp_media_album_name']) && $_POST['bp_media_album_name'] != '') {
497
+ $album = new BPMediaAlbum();
498
+ if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id']) > 0) {
499
+ $group_id = intval($_POST['bp_media_group_id']);
500
+ if (BPMediaGroup::user_can_create_album($group_id, get_current_user_id())) {
501
+ try {
502
+ $album->add_album($_POST['bp_media_album_name'], 0, $group_id);
503
+ echo $album->get_id();
504
+ } catch (exception $e) {
505
+ echo '0';
506
+ }
507
+ } else {
508
+ echo '0';
509
+ }
510
+ } else {
511
+ try {
512
+ $album->add_album($_POST['bp_media_album_name']);
513
+ echo $album->get_id();
514
+ } catch (exception $e) {
515
+ echo '0';
516
+ }
517
+ }
518
+ } else {
519
+ echo '0';
520
+ }
521
+ die();
522
+ }
523
+
524
+ function add_new_from_activity() {
525
+ BPMediaTemplateFunctions::show_upload_form_multiple_activity();
526
+ }
527
+
528
+ //add_action('bp_after_activity_post_form','add_new_from_activity');
529
+
530
+
531
+ function album_create_activity($album) {
532
+ /* @var $album BP_Media_Album */
533
+ $args = array(
534
+ 'action' => apply_filters('bp_media_album_created', sprintf(__('%1$s created an album %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($album->get_owner()), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>')),
535
+ 'component' => BP_MEDIA_SLUG,
536
+ 'type' => 'album_created',
537
+ 'primary_link' => $album->get_url(),
538
+ 'user_id' => $album->get_owner(),
539
+ 'item_id' => $album->get_id()
540
+ );
541
+ $activity_id = BPMediaFunction::record_activity($args);
542
+ update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
543
+ }
544
+
545
+ function album_activity_update($album_id) {
546
+ BPMediaFunction::update_album_activity($album_id);
547
+ }
548
+
549
+ function album_activity_sync($media_id) {
550
+ $album_id = wp_get_post_parent_id($media_id);
551
+ BPMediaFunction::update_album_activity($album_id, false, $media_id);
552
+ }
553
+
554
+ static function activity_create_after_add_media($media, $hidden = false) {
555
+ if (function_exists('bp_activity_add')) {
556
+ if (!is_object($media)) {
557
+ try {
558
+ $media = new BPMediaHostWordpress($media);
559
+ } catch (exception $e) {
560
+ return false;
561
+ }
562
+ }
563
+ $args = array(
564
+ 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media->get_author()), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>')),
565
+ 'content' => $media->get_media_activity_content(),
566
+ 'primary_link' => $media->get_url(),
567
+ 'item_id' => $media->get_id(),
568
+ 'type' => 'media_upload',
569
+ 'user_id' => $media->get_author()
570
+ );
571
+ $hidden = apply_filters('bp_media_force_hide_activity', $hidden);
572
+ if ($hidden) {
573
+ $args['secondary_item_id'] = -999;
574
+ do_action('bp_media_album_updated', $media->get_album_id());
575
+ }
576
+ $activity_id = BPMediaFunction::record_activity($args);
577
+ add_post_meta($media->get_id(), 'bp_media_child_activity', $activity_id);
578
+ }
579
+ }
580
+
581
+ }
582
+ ?>
app/main/includes/BPMediaComponent.php ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 BPMediaComponent
10
+ *
11
+ * @author saurabh
12
+ */
13
+ class BPMediaComponent extends BP_Component {
14
+
15
+ /**
16
+ * Hold the messages generated during initialization process and will be shown on the screen functions
17
+ *
18
+ * @since BuddyPress Media 2.0
19
+ */
20
+ var $messages = array(
21
+ 'error' => array( ),
22
+ 'info' => array( ),
23
+ 'updated' => array( )
24
+ );
25
+
26
+ /**
27
+ * Constructor for the BuddyPress Media
28
+ *
29
+ * @since BuddyPress Media 2.0
30
+ */
31
+ function __construct() {
32
+ global $bp;
33
+ parent::start( BP_MEDIA_SLUG, BP_MEDIA_LABEL, BP_MEDIA_PATH );
34
+ $this->includes();
35
+ $bp->active_components[ $this->id ] = '1';
36
+ add_action( 'init', array( &$this, 'register_post_types' ),10);
37
+ }
38
+
39
+ /**
40
+ * Includes the files required for the BuddyPress Media and calls the parent class' includes function
41
+ *
42
+ * @since BuddyPress Media 2.0
43
+ */
44
+ function includes() {
45
+ $inc_path_prefix = 'app/main/includes/';
46
+ $includes = array(
47
+ $inc_path_prefix . 'bp-media-functions.php',
48
+ $inc_path_prefix . 'bp-media-template-functions.php',
49
+ $inc_path_prefix . 'bp-media-interface.php',
50
+ $inc_path_prefix . 'bp-media-shortcodes.php',
51
+ $inc_path_prefix . 'bp-media-widgets.php'
52
+ //$inc_path_prefix . 'BPMediaFilter.php',
53
+ );
54
+ parent::includes( $includes );
55
+ do_action( 'bp_media_init' );
56
+ }
57
+
58
+ /**
59
+ * Initializes the global variables of the BuddyPress Media and its parent class.
60
+ */
61
+ function setup_globals() {
62
+ global $bp;
63
+ $globals = array(
64
+ 'slug' => BP_MEDIA_SLUG,
65
+ 'root_slug' => isset( $bp->pages->{$this->id}->slug ) ? $bp->pages->{$this->id}->slug : BP_MEDIA_SLUG,
66
+ /* 'has_directory' => true, /* Set to false if not required */
67
+ 'search_string' => __( 'Search Media...', BP_MEDIA_TXT_DOMAIN ),
68
+ );
69
+ parent::setup_globals( $globals );
70
+ }
71
+
72
+ function setup_nav() {
73
+ /* Add 'Media' to the main navigation */
74
+ global $bp;
75
+ $bp_media_upload = new BPMediaUploadScreen( 'upload', BP_MEDIA_UPLOAD_SLUG );
76
+
77
+ $bp_media_image = new BPMediaScreen( 'image', BP_MEDIA_IMAGES_SLUG );
78
+ $bp_media_video = new BPMediaScreen( 'video', BP_MEDIA_VIDEOS_SLUG );
79
+ $bp_media_audio = new BPMediaScreen( 'audio', BP_MEDIA_AUDIO_SLUG );
80
+
81
+ $bp_media_album = new BPMediaAlbumScreen( 'album', BP_MEDIA_ALBUMS_SLUG );
82
+ switch ( $bp->current_component ) {
83
+ case BP_MEDIA_IMAGES_SLUG:
84
+ if ( is_numeric( $bp->current_action ) ) {
85
+ $bp->action_variables[ 0 ] = $bp->current_action;
86
+ $bp->current_action = BP_MEDIA_IMAGES_ENTRY_SLUG;
87
+ }
88
+ break;
89
+ case BP_MEDIA_AUDIO_SLUG:
90
+ if ( is_numeric( $bp->current_action ) ) {
91
+ $bp->action_variables[ 0 ] = $bp->current_action;
92
+ $bp->current_action = BP_MEDIA_AUDIO_ENTRY_SLUG;
93
+ }
94
+ break;
95
+ case BP_MEDIA_VIDEOS_SLUG:
96
+ if ( is_numeric( $bp->current_action ) ) {
97
+ $bp->action_variables[ 0 ] = $bp->current_action;
98
+ $bp->current_action = BP_MEDIA_VIDEOS_ENTRY_SLUG;
99
+ }
100
+ break;
101
+ case BP_MEDIA_ALBUMS_SLUG:
102
+ if ( is_numeric( $bp->current_action ) ) {
103
+ $bp->action_variables[ 0 ] = $bp->current_action;
104
+ $bp->current_action = BP_MEDIA_ALBUMS_ENTRY_SLUG;
105
+ }
106
+ break;
107
+ }
108
+
109
+ if ( bp_is_my_profile() ) {
110
+ $main_nav = array(
111
+ 'name' => BP_MEDIA_LABEL,
112
+ 'slug' => BP_MEDIA_SLUG,
113
+ 'position' => 80,
114
+ 'screen_function' => array( $bp_media_upload, 'upload_screen' ),
115
+ 'default_subnav_slug' => BP_MEDIA_UPLOAD_SLUG
116
+ );
117
+ } else {
118
+ $main_nav = array(
119
+ 'name' => BP_MEDIA_LABEL,
120
+ 'slug' => BP_MEDIA_SLUG,
121
+ 'position' => 80,
122
+ 'screen_function' => array( $bp_media_image, 'screen' ),
123
+ 'default_subnav_slug' => BP_MEDIA_IMAGES_SLUG
124
+ );
125
+ }
126
+ $sub_nav[ ] = array(
127
+ 'name' => BP_MEDIA_UPLOAD_LABEL,
128
+ 'slug' => BP_MEDIA_UPLOAD_SLUG,
129
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_SLUG ),
130
+ 'parent_slug' => BP_MEDIA_SLUG,
131
+ 'screen_function' => array( $bp_media_upload, 'upload_screen' ),
132
+ 'position' => 10,
133
+ 'user_has_access' => bp_is_my_profile()
134
+ );
135
+ parent::setup_nav( $main_nav, $sub_nav );
136
+
137
+ bp_core_new_nav_item( array(
138
+ 'name' => BP_MEDIA_IMAGES_LABEL,
139
+ 'slug' => BP_MEDIA_IMAGES_SLUG,
140
+ 'screen_function' => array( $bp_media_image, 'screen' ),
141
+ ) );
142
+
143
+ bp_core_new_subnav_item( array(
144
+ 'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
145
+ 'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
146
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
147
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG ), /* URL of the parent item */
148
+ 'position' => 90, /* Index of where this nav item should be positioned */
149
+ 'screen_function' => array( $bp_media_image, 'screen' ), /* The name of the function to run when clicked */
150
+ ) );
151
+
152
+ bp_core_new_subnav_item( array(
153
+ 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
154
+ 'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
155
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
156
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG ), /* URL of the parent item */
157
+ 'position' => 90, /* Index of where this nav item should be positioned */
158
+ 'screen_function' => array( $bp_media_image, 'edit_screen' ), /* The name of the function to run when clicked */
159
+ ) );
160
+
161
+ bp_core_new_subnav_item( array(
162
+ 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
163
+ 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
164
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
165
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG ), /* URL of the parent item */
166
+ 'position' => 90, /* Index of where this nav item should be positioned */
167
+ 'screen_function' => array( $bp_media_image, 'screen' ), /* The name of the function to run when clicked */
168
+ ) );
169
+
170
+ bp_core_new_subnav_item( array(
171
+ 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
172
+ 'slug' => 'page', /* URL slug for the nav item */
173
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
174
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG ), /* URL of the parent item */
175
+ 'position' => 90, /* Index of where this nav item should be positioned */
176
+ 'screen_function' => array( $bp_media_image, 'screen' ), /* The name of the function to run when clicked */
177
+ ) );
178
+
179
+
180
+ bp_core_new_nav_item( array(
181
+ 'name' => BP_MEDIA_VIDEOS_LABEL,
182
+ 'slug' => BP_MEDIA_VIDEOS_SLUG,
183
+ 'screen_function' => array( $bp_media_video, 'screen' )
184
+ ) );
185
+
186
+ bp_core_new_subnav_item( array(
187
+ 'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
188
+ 'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
189
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
190
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG ), /* URL of the parent item */
191
+ 'position' => 90, /* Index of where this nav item should be positioned */
192
+ 'screen_function' => array( $bp_media_video, 'screen' ), /* The name of the function to run when clicked */
193
+ ) );
194
+
195
+ bp_core_new_subnav_item( array(
196
+ 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
197
+ 'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
198
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
199
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG ), /* URL of the parent item */
200
+ 'position' => 90, /* Index of where this nav item should be positioned */
201
+ 'screen_function' => array( $bp_media_video, 'edit_screen' ), /* The name of the function to run when clicked */
202
+ ) );
203
+
204
+ bp_core_new_subnav_item( array(
205
+ 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
206
+ 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
207
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
208
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG ), /* URL of the parent item */
209
+ 'position' => 90, /* Index of where this nav item should be positioned */
210
+ 'screen_function' => array( $bp_media_video, 'screen' ), /* The name of the function to run when clicked */
211
+ ) );
212
+
213
+ bp_core_new_subnav_item( array(
214
+ 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
215
+ 'slug' => 'page', /* URL slug for the nav item */
216
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
217
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG ), /* URL of the parent item */
218
+ 'position' => 90, /* Index of where this nav item should be positioned */
219
+ 'screen_function' => array( $bp_media_video, 'screen' ), /* The name of the function to run when clicked */
220
+ ) );
221
+
222
+
223
+ bp_core_new_nav_item( array(
224
+ 'name' => BP_MEDIA_AUDIO_LABEL,
225
+ 'slug' => BP_MEDIA_AUDIO_SLUG,
226
+ 'screen_function' => array( $bp_media_audio, 'screen' )
227
+ ) );
228
+
229
+ bp_core_new_subnav_item( array(
230
+ 'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
231
+ 'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
232
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
233
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG ), /* URL of the parent item */
234
+ 'position' => 90, /* Index of where this nav item should be positioned */
235
+ 'screen_function' => array( $bp_media_audio, 'screen' ), /* The name of the function to run when clicked */
236
+ ) );
237
+
238
+ bp_core_new_subnav_item( array(
239
+ 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
240
+ 'slug' => BP_MEDIA_AUDIO_EDIT_SLUG, /* URL slug for the nav item */
241
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
242
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG ), /* URL of the parent item */
243
+ 'position' => 90, /* Index of where this nav item should be positioned */
244
+ 'screen_function' => array( $bp_media_audio, 'edit_screen' ), /* The name of the function to run when clicked */
245
+ ) );
246
+
247
+ bp_core_new_subnav_item( array(
248
+ 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
249
+ 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
250
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
251
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG ), /* URL of the parent item */
252
+ 'position' => 90, /* Index of where this nav item should be positioned */
253
+ 'screen_function' => array( $bp_media_audio, 'screen' ), /* The name of the function to run when clicked */
254
+ ) );
255
+
256
+ bp_core_new_subnav_item( array(
257
+ 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
258
+ 'slug' => 'page', /* URL slug for the nav item */
259
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
260
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG ), /* URL of the parent item */
261
+ 'position' => 90, /* Index of where this nav item should be positioned */
262
+ 'screen_function' => array( $bp_media_audio, 'screen' ), /* The name of the function to run when clicked */
263
+ ) );
264
+
265
+
266
+ bp_core_new_nav_item( array(
267
+ 'name' => BP_MEDIA_ALBUMS_LABEL,
268
+ 'slug' => BP_MEDIA_ALBUMS_SLUG,
269
+ 'screen_function' => array( $bp_media_album, 'screen' ),
270
+ ) );
271
+
272
+ bp_core_new_subnav_item( array(
273
+ 'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
274
+ 'slug' => BP_MEDIA_ALBUMS_ENTRY_SLUG, /* URL slug for the nav item */
275
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
276
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG ), /* URL of the parent item */
277
+ 'position' => 90, /* Index of where this nav item should be positioned */
278
+ 'screen_function' => array( $bp_media_album, 'screen' ), /* The name of the function to run when clicked */
279
+ ) );
280
+
281
+ bp_core_new_subnav_item( array(
282
+ 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
283
+ 'slug' => BP_MEDIA_ALBUMS_EDIT_SLUG, /* URL slug for the nav item */
284
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
285
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG ), /* URL of the parent item */
286
+ 'position' => 90, /* Index of where this nav item should be positioned */
287
+ 'screen_function' => array( $bp_media_album, 'edit_screen' ), /* The name of the function to run when clicked */
288
+ ) );
289
+
290
+ bp_core_new_subnav_item( array(
291
+ 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
292
+ 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
293
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
294
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG ), /* URL of the parent item */
295
+ 'position' => 90, /* Index of where this nav item should be positioned */
296
+ 'screen_function' => array( $bp_media_album, 'screen' ), /* The name of the function to run when clicked */
297
+ ) );
298
+
299
+ bp_core_new_subnav_item( array(
300
+ 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
301
+ 'slug' => 'page', /* URL slug for the nav item */
302
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
303
+ 'parent_url' => trailingslashit( bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG ), /* URL of the parent item */
304
+ 'position' => 90, /* Index of where this nav item should be positioned */
305
+ 'screen_function' => array( $bp_media_album, 'screen' ), /* The name of the function to run when clicked */
306
+ ) );
307
+ }
308
+
309
+ /**
310
+ * Creating a custom post type album for BuddyPress Media
311
+ */
312
+ function register_post_types() {
313
+ $labels = array(
314
+ 'name' => __( 'Albums', BP_MEDIA_TXT_DOMAIN ),
315
+ 'singular_name' => __( 'Album', BP_MEDIA_TXT_DOMAIN ),
316
+ 'add_new' => __( 'Create', BP_MEDIA_TXT_DOMAIN ),
317
+ 'add_new_item' => __( 'Create Album', BP_MEDIA_TXT_DOMAIN ),
318
+ 'edit_item' => __( 'Edit Album', BP_MEDIA_TXT_DOMAIN ),
319
+ 'new_item' => __( 'New Album', BP_MEDIA_TXT_DOMAIN ),
320
+ 'all_items' => __( 'All Albums', BP_MEDIA_TXT_DOMAIN ),
321
+ 'view_item' => __( 'View Album', BP_MEDIA_TXT_DOMAIN ),
322
+ 'search_items' => __( 'Search Albums', BP_MEDIA_TXT_DOMAIN ),
323
+ 'not_found' => __( 'No album found', BP_MEDIA_TXT_DOMAIN ),
324
+ 'not_found_in_trash' => __( 'No album found in Trash', BP_MEDIA_TXT_DOMAIN ),
325
+ 'parent_item_colon' => '',
326
+ 'menu_name' => __( 'Albums', BP_MEDIA_TXT_DOMAIN )
327
+ );
328
+
329
+ $args = array(
330
+ 'labels' => $labels,
331
+ 'public' => true,
332
+ 'publicly_queryable' => true,
333
+ 'show_ui' => false,
334
+ 'show_in_menu' => false,
335
+ 'query_var' => true,
336
+ 'capability_type' => 'post',
337
+ 'has_archive' => true,
338
+ 'hierarchical' => false,
339
+ 'menu_position' => null,
340
+ 'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'comments' )
341
+ );
342
+ register_post_type( 'bp_media_album', $args );
343
+ global $bp_media;
344
+ /* Set up labels for the post type */
345
+ $labels = array(
346
+ 'name' => __( 'Media', BP_MEDIA_TXT_DOMAIN),
347
+ 'singular' => __( 'Media', BP_MEDIA_TXT_DOMAIN ),
348
+ 'add_new' => __( 'Add New Media', BP_MEDIA_TXT_DOMAIN )
349
+ );
350
+
351
+ /* Set up the argument array for register_post_type() */
352
+ $args = array(
353
+ 'label' => __( 'Media', BP_MEDIA_TXT_DOMAIN ),
354
+ 'labels' => $labels,
355
+ 'description' => __('BuddyPress Media\'s Media Files',BP_MEDIA_TXT_DOMAIN),
356
+ 'public' => true,
357
+ 'show_ui' => false,
358
+ 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields' )
359
+ );
360
+ register_post_type( 'bp_media', $args );
361
+ parent::register_post_types();
362
+ }
363
+
364
+ }
365
+
366
+ ?>
app/main/includes/BPMediaFilters.php ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaFilters
5
+ *
6
+ * @author faishal
7
+ */
8
+ class BPMediaFilters {
9
+
10
+ function __construct() {
11
+ add_filter('bp_activity_get_permalink', array($this, 'activity_permalink_filter'), 10, 2);
12
+ add_filter('bp_get_activity_delete_link', array($this, 'delete_button_handler'));
13
+ add_filter('bp_activity_get_user_join_filter', array($this, 'activity_query_filter'), 10);
14
+ // and we hook our function via wp_before_admin_bar_render
15
+ add_action('admin_bar_menu', array($this, 'my_account_menu'), 1);
16
+ // and we hook our function via wp_before_admin_bar_render
17
+ add_action('wp_before_admin_bar_render', array($this, 'adminbar_settings_menu'));
18
+ global $bp_media_activity_types;
19
+ $bp_media_activity_types = array('media_upload', 'album_updated', 'album_created');
20
+ }
21
+
22
+ function activity_permalink_filter($link, $activity_obj = null) {
23
+ global $bp_media_activity_types;
24
+ if ($activity_obj != null && in_array($activity_obj->type, $bp_media_activity_types)) {
25
+ if ($activity_obj->primary_link != '') {
26
+ try {
27
+ return $activity_obj->primary_link;
28
+ } catch (Exception $e) {
29
+ return $link;
30
+ }
31
+ }
32
+ }
33
+ if ($activity_obj != null && 'activity_comment' == $activity_obj->type) {
34
+ global $activities_template;
35
+ remove_filter('bp_activity_get_user_join_filter', 'activity_query_filter', 10);
36
+ $parent = $activity_obj->item_id;
37
+ if ($parent) {
38
+ try {
39
+ if (isset($activities_template->activity_parents[$parent])) {
40
+ return $activities_template->activity_parents[$parent]->primary_link;
41
+ } else {
42
+ $activities = bp_activity_get(array('in' => $parent));
43
+ if (isset($activities['activities'][0])) {
44
+ $activities_template->activity_parents[$parent] = $activities['activities'][0];
45
+ return $activities['activities'][0]->primary_link;
46
+ }
47
+ }
48
+ } catch (Exception $e) {
49
+ return $link;
50
+ }
51
+ }
52
+ }
53
+ return $link;
54
+ }
55
+
56
+ function activity_parent_content_filter($activity_content) {
57
+ global $activities_template;
58
+ $defaults = array(
59
+ 'hide_user' => false
60
+ );
61
+ if (!$parent_id = $activities_template->activity->item_id)
62
+ return false;
63
+ if (!isset($bp_media_hidden_activity_cache[$parent_id])) {
64
+ $activities = bp_activity_get(array('in' => $parent_id));
65
+ if (isset($activities['activities'][0])) {
66
+ $bp_media_hidden_activity_cache[$parent_id] = $activities['activities'][0];
67
+ }
68
+ }
69
+ if (empty($bp_media_hidden_activity_cache[$parent_id]))
70
+ return false;
71
+
72
+ if (empty($bp_media_hidden_activity_cache[$parent_id]->content))
73
+ $content = $bp_media_hidden_activity_cache[$parent_id]->action;
74
+ else
75
+ $content = $bp_media_hidden_activity_cache[$parent_id]->action . ' ' . $bp_media_hidden_activity_cache[$parent_id]->content;
76
+
77
+ // Remove the time since content for backwards compatibility
78
+ $content = str_replace('<span class="time-since">%s</span>', '', $content);
79
+
80
+ // Remove images
81
+ $content = preg_replace('/<img[^>]*>/Ui', '', $content);
82
+
83
+ return $content;
84
+ return $activity_content;
85
+ }
86
+
87
+ //add_filter('bp_get_activity_parent_content', 'activity_parent_content_filter', 1);
88
+
89
+ function delete_button_handler($link) {
90
+ if (bp_current_component() == 'media')
91
+ $link = str_replace('delete-activity ', 'delete-activity-single ', $link);
92
+ return $link;
93
+ }
94
+
95
+ static function items_count_filter($title, $nav_item) {
96
+ global $bp_media_count;
97
+ $bp_media_count = wp_parse_args($bp_media_count, array(
98
+ 'images' => 0,
99
+ 'videos' => 0,
100
+ 'audio' => 0,
101
+ 'albums' => 0
102
+ ));
103
+ switch ($nav_item['slug']) {
104
+ case BP_MEDIA_SLUG :
105
+ $count = intval($bp_media_count['images']) + intval($bp_media_count['videos']) + intval($bp_media_count['audio']);
106
+ break;
107
+ case BP_MEDIA_IMAGES_SLUG:
108
+ $count = intval($bp_media_count['images']);
109
+ break;
110
+ case BP_MEDIA_VIDEOS_SLUG:
111
+ $count = intval($bp_media_count['videos']);
112
+ break;
113
+ case BP_MEDIA_AUDIO_SLUG:
114
+ $count = intval($bp_media_count['audio']);
115
+ break;
116
+ case BP_MEDIA_ALBUMS_SLUG:
117
+ $count = intval($bp_media_count['albums']);
118
+ break;
119
+ }
120
+ $count_html = ' <span>' . $count . '</span>';
121
+ return str_replace('</a>', $count_html . '</a>', $title);
122
+ }
123
+
124
+ /**
125
+ * To hide some activities of multiple uploads
126
+ */
127
+ function activity_query_filter($query) {
128
+ global $wpdb;
129
+ $query = preg_replace('/WHERE/i', 'WHERE a.secondary_item_id!=-999 AND ', $query);
130
+ return $query;
131
+ }
132
+
133
+ /**
134
+ * Added menu under buddypress menu 'my account' in admin bar
135
+ *
136
+ * @global type $wp_admin_bar
137
+ */
138
+ function my_account_menu() {
139
+ global $wp_admin_bar;
140
+
141
+ $bp_media_admin_nav = array();
142
+
143
+ // Added Main menu for BuddyPress Media
144
+ $bp_media_admin_nav[] = array(
145
+ 'parent' => 'my-account-buddypress',
146
+ 'id' => 'my-account-bpmedia',
147
+ 'title' => __('Media', BP_MEDIA_TXT_DOMAIN),
148
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
149
+ 'meta' => array(
150
+ 'class' => 'menupop')
151
+ );
152
+
153
+ // Uplaod Media
154
+ /* $bp_media_admin_nav[] = array(
155
+ 'parent' => 'my-account-bpmedia',
156
+ 'id' => 'my-account-upload-media',
157
+ 'title' => __('Upload Media',BP_MEDIA_TXT_DOMAIN),
158
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
159
+ ); */
160
+
161
+ // Photos
162
+ $bp_media_admin_nav[] = array(
163
+ 'parent' => 'my-account-bpmedia',
164
+ 'id' => 'my-account-photos',
165
+ 'title' => __('Photos', BP_MEDIA_TXT_DOMAIN),
166
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG)
167
+ );
168
+
169
+ // Video
170
+ $bp_media_admin_nav[] = array(
171
+ 'parent' => 'my-account-bpmedia',
172
+ 'id' => 'my-account-videos',
173
+ 'title' => __('Videos', BP_MEDIA_TXT_DOMAIN),
174
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG)
175
+ );
176
+
177
+ // Audio
178
+ $bp_media_admin_nav[] = array(
179
+ 'parent' => 'my-account-bpmedia',
180
+ 'id' => 'my-account-audio',
181
+ 'title' => __('Audio', BP_MEDIA_TXT_DOMAIN),
182
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG)
183
+ );
184
+
185
+ // Albums
186
+ $bp_media_admin_nav[] = array(
187
+ 'parent' => 'my-account-bpmedia',
188
+ 'id' => 'my-account-album',
189
+ 'title' => __('Albums', BP_MEDIA_TXT_DOMAIN),
190
+ 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG)
191
+ );
192
+
193
+ foreach ($bp_media_admin_nav as $admin_menu)
194
+ $wp_admin_bar->add_menu($admin_menu);
195
+ }
196
+
197
+ /**
198
+ * Added menu under buddypress menu 'my account' in admin bar
199
+ *
200
+ * @global type $wp_admin_bar
201
+ */
202
+ function adminbar_settings_menu() {
203
+ global $wp_admin_bar;
204
+
205
+ if (current_user_can('manage_options') && is_super_admin()) {
206
+
207
+ $bp_media_admin_nav = array();
208
+ $title = '<span class="ab-icon"></span><span class="ab-label">' . _x('BuddyPress Media', 'admin bar menu group label') . '</span>';
209
+
210
+ // Added Main menu for BuddyPress Media
211
+ $bp_media_admin_nav[] = array(
212
+ 'id' => 'bp-media-menu',
213
+ 'title' => $title,
214
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
215
+ 'meta' => array(
216
+ 'class' => 'menupop bp-media-settings-menu')
217
+ );
218
+
219
+ // Settings
220
+ $bp_media_admin_nav[] = array(
221
+ 'parent' => 'bp-media-menu',
222
+ 'id' => 'bp-media-settings',
223
+ 'title' => __('Settings', BP_MEDIA_TXT_DOMAIN),
224
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php'))
225
+ );
226
+
227
+ // Addons
228
+ $bp_media_admin_nav[] = array(
229
+ 'parent' => 'bp-media-menu',
230
+ 'id' => 'my-account-addons',
231
+ 'title' => __('Addons', BP_MEDIA_TXT_DOMAIN),
232
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php'))
233
+ );
234
+
235
+ // Support
236
+ $bp_media_admin_nav[] = array(
237
+ 'parent' => 'bp-media-menu',
238
+ 'id' => 'my-account-support',
239
+ 'title' => __('Support', BP_MEDIA_TXT_DOMAIN),
240
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php'))
241
+ );
242
+
243
+ foreach ($bp_media_admin_nav as $admin_menu)
244
+ $wp_admin_bar->add_menu($admin_menu);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Set BuddyPress Media dashboard widget
250
+ *
251
+ */
252
+ //add_action('wp_dashboard_setup','dashboard_widgets');
253
+
254
+ function dashboard_widgets() {
255
+ global $wp_meta_boxes;
256
+ // Buddypress Media
257
+ // if ( is_user_admin() )
258
+ wp_add_dashboard_widget('dashboard_media_widget', __('BuddyPress Media'), array($this,'dashboard_media'));
259
+
260
+ global $wp_meta_boxes;
261
+
262
+ // Get the regular dashboard widgets array
263
+ // (which has our new widget already but at the end)
264
+
265
+ $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
266
+
267
+ // Backup and delete our new dashbaord widget from the end of the array
268
+
269
+ $example_widget_backup = array('dashboard_media_widget' => $normal_dashboard['dashboard_media_widget']);
270
+ unset($normal_dashboard['dashboard_media_widget']);
271
+
272
+ // Merge the two arrays together so our widget is at the beginning
273
+
274
+ $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
275
+
276
+ // Save the sorted array back into the original metaboxes
277
+
278
+ $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
279
+ }
280
+
281
+ function dashboard_media() {
282
+
283
+ /* Single user media counts */
284
+ $photos_count = $this->admin_total_count('photo');
285
+ $videos_count = $this->admin_total_count('video');
286
+ $audio_count = $this->admin_total_count('audio');
287
+ $albums_count = $this->admin_total_count('album');
288
+
289
+ /* Group media counts */
290
+ $g_photos_count = $this->group_total_count('photo');
291
+ $g_videos_count = $this->group_total_count('video');
292
+ $g_audio_count = $this->group_total_count('audio');
293
+ $g_albums_count = $this->group_total_count('album');
294
+ ?>
295
+ <div class="bp-media-dashboard">
296
+ <h3 class="sub"><?php _e('Users', BP_MEDIA_TXT_DOMAIN); ?> </h3>
297
+ <div class="table table_user">
298
+ <div class=""><span class="media-cnt"><?php echo $photos_count; ?></span><span class="media-label"><?php _e('Total Photos', BP_MEDIA_TXT_DOMAIN); ?></span></div>
299
+ <div class=""><span class="media-cnt"><?php echo $videos_count; ?></span><span class="media-label"><?php _e('Total Videos', BP_MEDIA_TXT_DOMAIN); ?></span></div>
300
+ <div class=""><span class="media-cnt"><?php echo $audio_count; ?></span><span class="media-label"><?php _e('Total Audio', BP_MEDIA_TXT_DOMAIN); ?></span></div>
301
+ <div class=""><span class="media-cnt"><?php echo $albums_count; ?></span><span class="media-label"><?php _e('Total Albums', BP_MEDIA_TXT_DOMAIN); ?></span></div>
302
+ </div><!-- .table_user -->
303
+ <h3 class="sub"><?php _e('Groups', BP_MEDIA_TXT_DOMAIN); ?> </h3>
304
+ <div class="table table_group">
305
+
306
+ </div><!-- .table_group -->
307
+ </div><!-- .bp-media-dashboard-->
308
+
309
+ <?php
310
+ }
311
+
312
+ function admin_total_count($media_type) {
313
+
314
+ switch ($media_type) {
315
+ case 'photo':
316
+ return $this->total_count_media('image');
317
+
318
+ case 'video':
319
+ return $this->total_count_media('video');
320
+
321
+ case 'audio':
322
+ return $this->total_count_media('audio');
323
+
324
+ case 'album':
325
+ return $this->total_count_albums();
326
+ }
327
+ }
328
+
329
+ function group_total_count($media_type) {
330
+
331
+ switch ($media_type) {
332
+ case 'photo':
333
+ return $this->total_count_media('image');
334
+
335
+ case 'video':
336
+ return $this->total_count_media('video');
337
+
338
+ case 'audio':
339
+ return $this->total_count_media('audio');
340
+
341
+ case 'album':
342
+ return $this->total_count_albums();
343
+ }
344
+ }
345
+
346
+ function total_count_media($type) {
347
+ global $wpdb;
348
+
349
+ $query = "SELECT COUNT(*) AS total
350
+ FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
351
+ WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value > 0 AND ( wp_posts.post_mime_type LIKE '$type%')";
352
+
353
+ $result = $wpdb->get_var(( $query));
354
+
355
+ if (isset($result))
356
+ return $result;
357
+ else
358
+ return false;
359
+ }
360
+
361
+ function total_count_albums() {
362
+ global $wpdb;
363
+
364
+ $query = "SELECT COUNT(*) AS total
365
+ FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
366
+ WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value < 0 ";
367
+
368
+ $result = $wpdb->get_var(( $query));
369
+
370
+ if (isset($result))
371
+ return $result;
372
+ else
373
+ return false;
374
+ }
375
+
376
+ }
377
+ ?>
app/main/includes/BPMediaFunction.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BPMediaFunction {
4
+
5
+ function __construct() {
6
+ add_action('bp_init', array($this,'swap_filters'));
7
+ add_action('wp_ajax_my_featured_action', array($this,'implement_featured_ajax'));
8
+ add_action('wp_ajax_nopriv_my_featured_action', array($this,'implement_featured_ajax'));
9
+ }
10
+
11
+ static function record_activity($args = '') {
12
+ global $bp;
13
+ if (!function_exists('bp_activity_add'))
14
+ return false;
15
+ $defaults = array(
16
+ 'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
17
+ );
18
+ add_filter('bp_activity_allowed_tags', 'BPMediaFunction::override_allowed_tags');
19
+ $r = wp_parse_args($args, $defaults);
20
+ $activity_id = bp_activity_add($r);
21
+ return $activity_id;
22
+ }
23
+
24
+ static function override_allowed_tags($activity_allowedtags) {
25
+ $activity_allowedtags['video'] = array();
26
+ $activity_allowedtags['video']['id'] = array();
27
+ $activity_allowedtags['video']['class'] = array();
28
+ $activity_allowedtags['video']['src'] = array();
29
+ $activity_allowedtags['video']['height'] = array();
30
+ $activity_allowedtags['video']['width'] = array();
31
+ $activity_allowedtags['video']['controls'] = array();
32
+ $activity_allowedtags['video']['preload'] = array();
33
+ $activity_allowedtags['video']['alt'] = array();
34
+ $activity_allowedtags['video']['title'] = array();
35
+ $activity_allowedtags['audio'] = array();
36
+ $activity_allowedtags['audio']['id'] = array();
37
+ $activity_allowedtags['audio']['class'] = array();
38
+ $activity_allowedtags['audio']['src'] = array();
39
+ $activity_allowedtags['audio']['controls'] = array();
40
+ $activity_allowedtags['audio']['preload'] = array();
41
+ $activity_allowedtags['audio']['alt'] = array();
42
+ $activity_allowedtags['audio']['title'] = array();
43
+ $activity_allowedtags['script'] = array();
44
+ $activity_allowedtags['script']['type'] = array();
45
+ $activity_allowedtags['div'] = array();
46
+ $activity_allowedtags['div']['id'] = array();
47
+ $activity_allowedtags['div']['class'] = array();
48
+ $activity_allowedtags['a'] = array();
49
+ $activity_allowedtags['a']['title'] = array();
50
+ $activity_allowedtags['a']['href'] = array();
51
+ $activity_allowedtags['ul'] = array();
52
+ $activity_allowedtags['li'] = array();
53
+
54
+ return $activity_allowedtags;
55
+ }
56
+
57
+ static function show_formatted_error_message($messages, $type) {
58
+ echo '<div id="message" class="' . $type . '">';
59
+ if (is_array($messages)) {
60
+ foreach ($messages as $key => $message) {
61
+ if (is_string($message)) {
62
+ echo '<p>' . $message . '</p>';
63
+ }
64
+ }
65
+ } else {
66
+ if (is_string($messages)) {
67
+ echo '<p>' . $messages . '</p>';
68
+ }
69
+ }
70
+ echo '</div>';
71
+ }
72
+
73
+ static function conditional_override_allowed_tags($content, $activity = null) {
74
+ global $bp_media;
75
+ if ($activity != null && in_array($activity->type, $bp_media->activity_types)) {
76
+ add_filter('bp_activity_allowed_tags', 'BPMediaFunction::override_allowed_tags', 1);
77
+ }
78
+ return bp_activity_filter_kses($content);
79
+ }
80
+
81
+ function swap_filters() {
82
+ add_filter('bp_get_activity_content_body', 'BPMediaFunction::conditional_override_allowed_tags', 1, 2);
83
+ remove_filter('bp_get_activity_content_body', 'bp_activity_filter_kses', 1);
84
+ }
85
+
86
+ /**
87
+ * Updates the media count of all users.
88
+ */
89
+ static function update_count() {
90
+ global $wpdb;
91
+ $query =
92
+ "SELECT
93
+ post_author,
94
+ SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
95
+ SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
96
+ SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
97
+ SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums,
98
+ COUNT(*) as Total
99
+ FROM
100
+ $wpdb->posts RIGHT JOIN $wpdb->postmeta on wp_postmeta.post_id = wp_posts.id
101
+ WHERE
102
+ `meta_key` = 'bp-media-key' AND
103
+ `meta_value` > 0 AND
104
+ ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
105
+ GROUP BY post_author";
106
+ $result = $wpdb->get_results($query);
107
+ if (!is_array($result))
108
+ return false;
109
+
110
+ foreach ($result as $obj) {
111
+
112
+ $count = array(
113
+ 'images' => isset($obj->Images) ? $obj->Images : 0,
114
+ 'videos' => isset($obj->Videos) ? $obj->Videos : 0,
115
+ 'audio' => isset($obj->Audio) ? $obj->Audio : 0,
116
+ 'albums' => isset($obj->Albums) ? $obj->Albums : 0
117
+ );
118
+ bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
119
+ }
120
+ return true;
121
+ }
122
+
123
+ static function update_media() {
124
+ global $bp_media_current_entry;
125
+ if ($bp_media_current_entry->update_media(array('description' => esc_html($_POST['bp_media_description']), 'name' => esc_html($_POST['bp_media_title'])))) {
126
+ $bp_media_current_entry->update_media_activity();
127
+ @setcookie('bp-message', 'The media has been updated', time() + 60 * 60 * 24, COOKIEPATH);
128
+ @setcookie('bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH);
129
+ wp_redirect($bp_media_current_entry->get_url());
130
+ exit;
131
+ } else {
132
+ @setcookie('bp-message', 'The media update failed', time() + 60 * 60 * 24, COOKIEPATH);
133
+ @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
134
+ wp_redirect($bp_media_current_entry->get_edit_url());
135
+ exit;
136
+ }
137
+ }
138
+
139
+ static function check_user() {
140
+ if (bp_loggedin_user_id() != bp_displayed_user_id()) {
141
+ bp_core_no_access(array(
142
+ 'message' => __('You do not have access to this page.', BP_MEDIA_TXT_DOMAIN),
143
+ 'root' => bp_displayed_user_domain(),
144
+ 'redirect' => false
145
+ ));
146
+ exit;
147
+ }
148
+ }
149
+
150
+ function page_not_exist() {
151
+ @setcookie('bp-message', 'The requested url does not exist', time() + 60 * 60 * 24, COOKIEPATH);
152
+ @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
153
+ wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
154
+ exit;
155
+ }
156
+
157
+ static function update_album_activity($album, $current_time = true, $delete_media_id = null) {
158
+ if (!is_object($album)) {
159
+ $album = new BPMediaAlbum($album);
160
+ }
161
+ $args = array(
162
+ 'post_parent' => $album->get_id(),
163
+ 'numberposts' => 4,
164
+ 'post_type' => 'attachment',
165
+ );
166
+ if ($delete_media_id)
167
+ $args['exclude'] = $delete_media_id;
168
+ $attachments = get_posts($args);
169
+ if (is_array($attachments)) {
170
+ $content = '<ul>';
171
+ foreach ($attachments as $media) {
172
+ $bp_media = new BPMediaHostWordpress($media->ID);
173
+ $content .= $bp_media->get_album_activity_content();
174
+ }
175
+ $content .= '</ul>';
176
+ $activity_id = get_post_meta($album->get_id(), 'bp_media_child_activity');
177
+ if ($activity_id) {
178
+ $args = array(
179
+ 'in' => $activity_id,
180
+ );
181
+
182
+ $activity = @bp_activity_get($args);
183
+ if (isset($activity['activities'][0]->id)) {
184
+ $args = array(
185
+ 'content' => $content,
186
+ 'id' => $activity_id,
187
+ 'type' => 'album_updated',
188
+ 'user_id' => $activity['activities'][0]->user_id,
189
+ 'action' => apply_filters('bp_media_filter_album_updated', sprintf(__('%1$s added new media in album %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($activity['activities'][0]->user_id), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>')),
190
+ 'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
191
+ 'primary_link' => $activity['activities'][0]->primary_link,
192
+ 'item_id' => $activity['activities'][0]->item_id,
193
+ 'secondary_item_id' => $activity['activities'][0]->secondary_item_id,
194
+ 'recorded_time' => $current_time ? bp_core_current_time() : $activity['activities'][0]->date_recorded,
195
+ 'hide_sitewide' => $activity['activities'][0]->hide_sitewide
196
+ );
197
+ BPMediaFunction::record_activity($args);
198
+ }
199
+ }
200
+ }
201
+ }
202
+
203
+ static function wp_comment_form_mod() {
204
+ global $bp_media_current_entry;
205
+ echo '<input type="hidden" name="redirect_to" value="' . $bp_media_current_entry->get_url() . '">';
206
+ }
207
+
208
+ function implement_featured_ajax() {
209
+ if (isset($_POST['post_id'])) {
210
+ if (isset($_POST['post_date']) && $_POST['remove_featured'] == 0) {
211
+ update_post_meta($_POST['post_id'], 'featured', date('Y-m-d H:i:s', strtotime($_POST['post_date'])));
212
+ } else {
213
+ update_post_meta($_POST['post_id'], 'featured', FALSE);
214
+ }
215
+ die(1);
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Redirects the user to the location given in the parameter as well as set the message
221
+ * and context of redirect
222
+ *
223
+ * @param $location String The URL to redirect to
224
+ * @param $message String The message to show on the page where redirected
225
+ * @param $type String Type of message(updated, success, error, warning), works only if message is set
226
+ * @param $status String The HTTP status header for the redirection page.
227
+ */
228
+ function redirect($location, $message = '', $type = 'updated', $status = '302') {
229
+ if ($message != '')
230
+ bp_core_add_message($message, 'error');
231
+ bp_core_redirect($location, $status);
232
+ }
233
+
234
+ }
235
+
236
+ ?>
includes/bp-media-class-wordpress.php → app/main/includes/BPMediaHostWordpress.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- class BP_Media_Host_Wordpress {
3
 
4
  /**
5
  * Private variables not to be accessible outside this class' member functions
@@ -21,7 +21,7 @@ class BP_Media_Host_Wordpress {
21
  *
22
  * @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
23
  *
24
- * @since BP Media 2.0
25
  */
26
  function __construct($media_id = '') {
27
  if (!$media_id == '') {
@@ -34,7 +34,7 @@ class BP_Media_Host_Wordpress {
34
  *
35
  * @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
36
  *
37
- * @since BP Media 2.0
38
  */
39
  function init($media_id = '') {
40
  if (is_object($media_id)) {
@@ -43,7 +43,7 @@ class BP_Media_Host_Wordpress {
43
  $media = &get_post($media_id);
44
  }
45
  if (empty($media->ID))
46
- throw new Exception(__('Sorry, the requested media does not exist.', 'bp-media'));
47
  $this->id = $media->ID;
48
  $this->description = $media->post_content;
49
  $this->name = $media->post_title;
@@ -69,11 +69,11 @@ class BP_Media_Host_Wordpress {
69
  /**
70
  * Handles the uploaded media file and creates attachment post for the file.
71
  *
72
- * @since BP Media 2.0
73
  */
74
  function add_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false) {
75
  do_action('bp_media_before_add_media');
76
- global $bp, $wpdb, $bp_media_count;
77
  include_once(ABSPATH . 'wp-admin/includes/file.php');
78
  include_once(ABSPATH . 'wp-admin/includes/image.php');
79
 
@@ -81,7 +81,7 @@ class BP_Media_Host_Wordpress {
81
 
82
  $file = wp_handle_upload($_FILES['bp_media_file']);
83
  if (isset($file['error']) || $file === null) {
84
- throw new Exception(__('Error Uploading File', 'bp-media'));
85
  }
86
 
87
  $attachment = array();
@@ -97,65 +97,65 @@ class BP_Media_Host_Wordpress {
97
  'post_content' => $content,
98
  'post_parent' => $post_id,
99
  );
100
- bp_media_init_count(bp_loggedin_user_id());
101
  switch ($type) {
102
  case 'video/mp4' :
103
  case 'video/quicktime' :
104
  $type = 'video';
105
- include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/getid3/getid3.php');
106
  try {
107
  $getID3 = new getID3;
108
  $vid_info = $getID3->analyze($file);
109
  } catch (Exception $e) {
110
  unlink($file);
111
  $activity_content = false;
112
- throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
113
  }
114
  if (is_array($vid_info)) {
115
  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'])) {
116
  if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
117
  unlink($file);
118
  $activity_content = false;
119
- throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
120
  }
121
  } else {
122
  unlink($file);
123
  $activity_content = false;
124
- throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
125
  }
126
  } else {
127
  unlink($file);
128
  $activity_content = false;
129
- throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
130
  }
131
  $bp_media_count['videos'] = intval($bp_media_count['videos']) + 1;
132
  break;
133
  case 'audio/mpeg' :
134
- include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/getid3/getid3.php');
135
  try {
136
  $getID3 = new getID3;
137
  $file_info = $getID3->analyze($file);
138
  } catch (Exception $e) {
139
  unlink($file);
140
  $activity_content = false;
141
- throw new Exception(__('MP3 file you have uploaded is currupt.', 'bp-media'));
142
  }
143
  if (is_array($file_info)) {
144
  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'])) {
145
  if (!($file_info['fileformat']=='mp3'&&$file_info['audio']['dataformat']=='mp3')) {
146
  unlink($file);
147
  $activity_content = false;
148
- throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
149
  }
150
  } else {
151
  unlink($file);
152
  $activity_content = false;
153
- throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
154
  }
155
  } else {
156
  unlink($file);
157
  $activity_content = false;
158
- throw new Exception(__('The MP3 file you have uploaded is not an audio file.', 'bp-media'));
159
  }
160
  $type = 'audio';
161
  $bp_media_count['audio'] = intval($bp_media_count['audio']) + 1;
@@ -169,14 +169,14 @@ class BP_Media_Host_Wordpress {
169
  default :
170
  unlink($file);
171
  $activity_content = false;
172
- 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'));
173
  }
174
  $attachment_id = wp_insert_attachment($attachment, $file, $post_id);
175
  if (!is_wp_error($attachment_id)) {
176
  wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
177
  } else {
178
  unlink($file);
179
- throw new Exception(__('Error creating attachment for the media file, please try again', 'bp-media'));
180
  }
181
  $this->id = $attachment_id;
182
  $this->name = $name;
@@ -201,9 +201,9 @@ class BP_Media_Host_Wordpress {
201
  *
202
  */
203
  function get_media_activity_content() {
204
- global $bp_media_counter, $bp_media_default_excerpts;
205
  $attachment_id = $this->id;
206
- $activity_content = '<div class="bp_media_title"><a href="' . $this->url . '" title="' . $this->description . '">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['activity_entry_title']) . '</a></div>';
207
  $activity_content .='<div class="bp_media_content">';
208
  switch ($this->type) {
209
  case 'video' :
@@ -221,14 +221,14 @@ class BP_Media_Host_Wordpress {
221
  break;
222
  case 'image' :
223
  $image_array = image_downsize($attachment_id, 'bp_media_activity_image');
224
- $activity_content.='<a href="' . $this->url . '" title="' . $this->name . '"><img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '_' . $bp_media_counter++ . '" alt="' . $this->name . '" /></a>';
225
  $type = 'image';
226
  break;
227
  default :
228
  return false;
229
  }
230
  $activity_content .= '</div>';
231
- $activity_content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['activity_entry_description']) . '</div>';
232
  return $activity_content;
233
  }
234
 
@@ -246,9 +246,10 @@ class BP_Media_Host_Wordpress {
246
  * Returns the media activity's action text
247
  */
248
  function get_media_activity_action() {
249
- if (!bp_is_activity_component())
 
250
  return false;
251
- $activity_action = sprintf(__("%s uploaded a media."), bp_core_get_userlink($this->owner));
252
  return $activity_action;
253
  }
254
 
@@ -256,25 +257,27 @@ class BP_Media_Host_Wordpress {
256
  * Returns the HTML for content of the single entry page of the Media Entry
257
  */
258
  function get_media_single_content() {
259
- global $bp_media_default_sizes, $bp_media_default_excerpts;
 
 
260
  $content = '';
261
  if($this->group_id>0){
262
 
263
- $content .= '<div class="bp_media_author">Uploaded by '. bp_core_get_userlink($this->owner).'</div>';
264
  }
265
  $content .= '<div class="bp_media_content">';
266
  switch ($this->type) {
267
  case 'video' :
268
  if($this->thumbnail_id){
269
  $image_array = image_downsize($this->thumbnail_id, 'bp_media_single_image');
270
- $content.=apply_filters('bp_media_single_content_filter', '<video poster="'.$image_array[0].'" src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_video']['width'] . '" height="' . ($bp_media_default_sizes['single_video']['height'] == 0 ? 'auto' : $bp_media_default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>',$this);
271
  }
272
  else{
273
- $content.=apply_filters('bp_media_single_content_filter', '<video src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_video']['width'] . '" height="' . ($bp_media_default_sizes['single_video']['height'] == 0 ? 'auto' : $bp_media_default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>',$this);
274
  }
275
  break;
276
  case 'audio' :
277
- $content.=apply_filters('bp_media_single_content_filter', '<audio src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_audio']['width'] . '" type="audio/mp3" id="bp_media_audio_' . $this->id . '" controls="controls" preload="none" ></audio><script>bp_media_create_element("bp_media_audio_' . $this->id . '");</script>',$this);
278
  break;
279
  case 'image' :
280
  $image_array = image_downsize($this->id, 'bp_media_single_image');
@@ -284,7 +287,7 @@ class BP_Media_Host_Wordpress {
284
  return false;
285
  }
286
  $content .= '</div>';
287
- $content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['single_entry_description']) . '</div>';
288
  return $content;
289
  }
290
 
@@ -292,8 +295,8 @@ class BP_Media_Host_Wordpress {
292
  * Returns the HTML for title of the single entry page of the Media Entry
293
  */
294
  function get_media_single_title(){
295
- global $bp_media_default_excerpts;
296
- $content = '<div class="bp_media_title">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['single_entry_title']) . '</div>';
297
  return $content;
298
  }
299
 
@@ -301,7 +304,8 @@ class BP_Media_Host_Wordpress {
301
  * Returns the HTML for a media entry to be shown in the listing/gallery page
302
  */
303
  function get_media_gallery_content() {
304
- $attachment = $this->id;
 
305
  switch ($this->type) {
306
  case 'video' :
307
  if($this->thumbnail_id){
@@ -309,14 +313,14 @@ class BP_Media_Host_Wordpress {
309
  $thumb_url = $medium_array[0];
310
  }
311
  else{
312
- $thumb_url = plugins_url('img/video_thumb.png', __FILE__);
313
  }
314
  ?>
315
  <li>
316
- <a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
317
  <img src="<?php echo $thumb_url; ?>" />
318
  </a>
319
- <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
320
  </li>
321
  <?php
322
  break;
@@ -326,14 +330,14 @@ class BP_Media_Host_Wordpress {
326
  $thumb_url = $medium_array[0];
327
  }
328
  else{
329
- $thumb_url = plugins_url('img/audio_thumb.png', __FILE__);
330
  }
331
  ?>
332
  <li>
333
- <a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
334
  <img src="<?php echo $thumb_url ?>" />
335
  </a>
336
- <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
337
  </li>
338
  <?php
339
  break;
@@ -345,7 +349,7 @@ class BP_Media_Host_Wordpress {
345
  <a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
346
  <img src="<?php echo $medium_path ?>" />
347
  </a>
348
- <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
349
  </li>
350
  <?php
351
  break;
@@ -357,7 +361,7 @@ class BP_Media_Host_Wordpress {
357
  function show_comment_form_wordpress(){
358
  query_posts('attachment_id='.$this->id);
359
  while(have_posts()): the_post();
360
- add_action('comment_form','bp_media_wp_comment_form_mod');
361
  comments_template();
362
  endwhile;
363
  }
@@ -366,6 +370,7 @@ class BP_Media_Host_Wordpress {
366
  * Outputs the comments and comment form in the single media entry page
367
  */
368
  function show_comment_form() {
 
369
  $activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
370
  if(!$activity_id || !function_exists('bp_has_activities'))
371
  return false;
@@ -385,13 +390,13 @@ class BP_Media_Host_Wordpress {
385
  <?php if (is_user_logged_in()) : ?>
386
  <div class="activity-meta no-ajax">
387
  <?php if (bp_activity_can_comment()) : ?>
388
- <a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf(__('Comment <span>%s</span>', 'buddypress'), bp_activity_get_comment_count()); ?></a>
389
  <?php endif; ?>
390
  <?php if (bp_activity_can_favorite()) : ?>
391
  <?php if (!bp_get_activity_is_favorite()) : ?>
392
- <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', 'buddypress'); ?>"><?php _e('Favorite', 'buddypress') ?></a>
393
  <?php else : ?>
394
- <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', 'buddypress'); ?>"><?php _e('Remove Favorite', 'buddypress') ?></a>
395
  <?php endif; ?>
396
  <?php endif; ?>
397
  <?php if (bp_activity_user_can_delete()) bp_activity_delete_link(); ?>
@@ -410,7 +415,7 @@ class BP_Media_Host_Wordpress {
410
  <div class="ac-textarea">
411
  <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
412
  </div>
413
- <input type="submit" name="ac_form_submit" value="<?php _e('Post', 'buddypress'); ?>" /> &nbsp; <?php _e('or press esc to cancel.', 'buddypress'); ?>
414
  <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
415
  </div>
416
  <?php do_action('bp_activity_entry_comments'); ?>
@@ -433,7 +438,7 @@ class BP_Media_Host_Wordpress {
433
  <?php do_action('bp_activity_entry_content'); ?>
434
  <?php if (is_user_logged_in()) : ?>
435
  <div class="activity-meta no-ajax">
436
- <a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow">Delete</a>
437
  </div>
438
  <?php endif; ?>
439
  </div>
@@ -489,7 +494,7 @@ class BP_Media_Host_Wordpress {
489
  *
490
  */
491
  function update_media_activity(){
492
- global $wpdb, $bp, $current_user;
493
  $q = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id);
494
  $activities = $wpdb->get_results($q);
495
  if(isset($activities) && count($activities) > 0){
@@ -503,13 +508,13 @@ class BP_Media_Host_Wordpress {
503
  'content' => $this->get_media_activity_content(),
504
  'id' => $activity->id,
505
  'type' => 'media_upload',
506
- 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $this->get_author() ), '<a href="' . $this->get_url() . '">' . $this->get_media_activity_type() . '</a>' ) ),
507
  'primary_link' => $this->get_url(),
508
  'item_id' => $this->get_id(),
509
  'recorded_time' => $activity->date_recorded,
510
  'user_id' => $this->get_author()
511
  );
512
- $activity_id = bp_media_record_activity($args);
513
  }
514
  }
515
  }
@@ -520,7 +525,7 @@ class BP_Media_Host_Wordpress {
520
  function delete_media(){
521
  do_action('bp_media_before_delete_media',$this->id);
522
  global $bp_media_count;
523
- bp_media_init_count($this->owner);
524
  switch ($this->type) {
525
  case 'image':
526
  $bp_media_count['images'] = intval($bp_media_count['images']) - 1;
@@ -549,7 +554,7 @@ class BP_Media_Host_Wordpress {
549
  $thumb_url = $medium_array[0];
550
  }
551
  else{
552
- $thumb_url = plugins_url('img/video_thumb.png', __FILE__);
553
  }
554
  break;
555
  case 'audio' :
@@ -558,7 +563,7 @@ class BP_Media_Host_Wordpress {
558
  $thumb_url = $medium_array[0];
559
  }
560
  else{
561
- $thumb_url = plugins_url('img/audio_thumb.png', __FILE__);
562
  }
563
  break;
564
  case 'image' :
@@ -732,7 +737,7 @@ class BP_Media_Host_Wordpress {
732
  AND $wpdb->posts.post_title = 'Wall Posts'" );
733
  }
734
  if($post_id==null){
735
- $album = new BP_Media_Album();
736
  if($group == 0 )
737
  $album->add_album('Wall Posts', get_current_user_id(), $group);
738
  else{
1
  <?php
2
+ class BPMediaHostWordpress {
3
 
4
  /**
5
  * Private variables not to be accessible outside this class' member functions
21
  *
22
  * @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
23
  *
24
+ * @since BuddyPress Media 2.0
25
  */
26
  function __construct($media_id = '') {
27
  if (!$media_id == '') {
34
  *
35
  * @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
36
  *
37
+ * @since BuddyPress Media 2.0
38
  */
39
  function init($media_id = '') {
40
  if (is_object($media_id)) {
43
  $media = &get_post($media_id);
44
  }
45
  if (empty($media->ID))
46
+ throw new Exception(__('Sorry, the requested media does not exist.', BP_MEDIA_TXT_DOMAIN));
47
  $this->id = $media->ID;
48
  $this->description = $media->post_content;
49
  $this->name = $media->post_title;
69
  /**
70
  * Handles the uploaded media file and creates attachment post for the file.
71
  *
72
+ * @since BuddyPress Media 2.0
73
  */
74
  function add_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false) {
75
  do_action('bp_media_before_add_media');
76
+ global $bp, $wpdb, $bp_media_count,$bp_media;
77
  include_once(ABSPATH . 'wp-admin/includes/file.php');
78
  include_once(ABSPATH . 'wp-admin/includes/image.php');
79
 
81
 
82
  $file = wp_handle_upload($_FILES['bp_media_file']);
83
  if (isset($file['error']) || $file === null) {
84
+ throw new Exception(__('Error Uploading File', BP_MEDIA_TXT_DOMAIN));
85
  }
86
 
87
  $attachment = array();
97
  'post_content' => $content,
98
  'post_parent' => $post_id,
99
  );
100
+ BPMediaActions::init_count(bp_loggedin_user_id());
101
  switch ($type) {
102
  case 'video/mp4' :
103
  case 'video/quicktime' :
104
  $type = 'video';
105
+ include_once(trailingslashit(BP_MEDIA_PATH) . 'lib/getid3/getid3.php');
106
  try {
107
  $getID3 = new getID3;
108
  $vid_info = $getID3->analyze($file);
109
  } catch (Exception $e) {
110
  unlink($file);
111
  $activity_content = false;
112
+ throw new Exception(__('MP4 file you have uploaded is corrupt.', BP_MEDIA_TXT_DOMAIN));
113
  }
114
  if (is_array($vid_info)) {
115
  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'])) {
116
  if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
117
  unlink($file);
118
  $activity_content = false;
119
+ 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));
120
  }
121
  } else {
122
  unlink($file);
123
  $activity_content = false;
124
+ 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));
125
  }
126
  } else {
127
  unlink($file);
128
  $activity_content = false;
129
+ throw new Exception(__('The MP4 file you have uploaded is not a video file.', BP_MEDIA_TXT_DOMAIN));
130
  }
131
  $bp_media_count['videos'] = intval($bp_media_count['videos']) + 1;
132
  break;
133
  case 'audio/mpeg' :
134
+ include_once(trailingslashit(BP_MEDIA_PATH) . 'lib/getid3/getid3.php');
135
  try {
136
  $getID3 = new getID3;
137
  $file_info = $getID3->analyze($file);
138
  } catch (Exception $e) {
139
  unlink($file);
140
  $activity_content = false;
141
+ throw new Exception(__('MP3 file you have uploaded is currupt.', BP_MEDIA_TXT_DOMAIN));
142
  }
143
  if (is_array($file_info)) {
144
  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'])) {
145
  if (!($file_info['fileformat']=='mp3'&&$file_info['audio']['dataformat']=='mp3')) {
146
  unlink($file);
147
  $activity_content = false;
148
+ throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN));
149
  }
150
  } else {
151
  unlink($file);
152
  $activity_content = false;
153
+ throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN));
154
  }
155
  } else {
156
  unlink($file);
157
  $activity_content = false;
158
+ throw new Exception(__('The MP3 file you have uploaded is not an audio file.', BP_MEDIA_TXT_DOMAIN));
159
  }
160
  $type = 'audio';
161
  $bp_media_count['audio'] = intval($bp_media_count['audio']) + 1;
169
  default :
170
  unlink($file);
171
  $activity_content = false;
172
+ 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));
173
  }
174
  $attachment_id = wp_insert_attachment($attachment, $file, $post_id);
175
  if (!is_wp_error($attachment_id)) {
176
  wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
177
  } else {
178
  unlink($file);
179
+ throw new Exception(__('Error creating attachment for the media file, please try again', BP_MEDIA_TXT_DOMAIN));
180
  }
181
  $this->id = $attachment_id;
182
  $this->name = $name;
201
  *
202
  */
203
  function get_media_activity_content() {
204
+ global $bp_media_counter, $bp_media_default_excerpts,$bp_media;
205
  $attachment_id = $this->id;
206
+ $activity_content = '<div class="bp_media_title"><a href="' . $this->url . '" title="' . __($this->description,BP_MEDIA_TXT_DOMAIN) . '">' . __(wp_html_excerpt($this->name, $bp_media_default_excerpts['activity_entry_title']),BP_MEDIA_TXT_DOMAIN) . '</a></div>';
207
  $activity_content .='<div class="bp_media_content">';
208
  switch ($this->type) {
209
  case 'video' :
221
  break;
222
  case 'image' :
223
  $image_array = image_downsize($attachment_id, 'bp_media_activity_image');
224
+ $activity_content.='<a href="' . $this->url . '" title="' . __($this->name,BP_MEDIA_TXT_DOMAIN) . '"><img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '_' . $bp_media_counter++ . '" alt="' . __($this->name,BP_MEDIA_TXT_DOMAIN) . '" /></a>';
225
  $type = 'image';
226
  break;
227
  default :
228
  return false;
229
  }
230
  $activity_content .= '</div>';
231
+ $activity_content .= '<div class="bp_media_description">' . __(wp_html_excerpt($this->description, $bp_media_default_excerpts['activity_entry_description']),BP_MEDIA_TXT_DOMAIN) . '</div>';
232
  return $activity_content;
233
  }
234
 
246
  * Returns the media activity's action text
247
  */
248
  function get_media_activity_action() {
249
+ global $bp_media;
250
+ if (!bp_is_activity_component())
251
  return false;
252
+ $activity_action = sprintf(__("%s uploaded a media.",BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($this->owner));
253
  return $activity_action;
254
  }
255
 
257
  * Returns the HTML for content of the single entry page of the Media Entry
258
  */
259
  function get_media_single_content() {
260
+ global $bp_media_default_excerpts,$bp_media;
261
+
262
+ $default_sizes = $bp_media->media_sizes();
263
  $content = '';
264
  if($this->group_id>0){
265
 
266
+ $content .= '<div class="bp_media_author">' . __("Uploaded by ", BP_MEDIA_TXT_DOMAIN) . bp_core_get_userlink($this->owner).'</div>';
267
  }
268
  $content .= '<div class="bp_media_content">';
269
  switch ($this->type) {
270
  case 'video' :
271
  if($this->thumbnail_id){
272
  $image_array = image_downsize($this->thumbnail_id, 'bp_media_single_image');
273
+ $content.=apply_filters('bp_media_single_content_filter', '<video poster="'.$image_array[0].'" src="' . wp_get_attachment_url($this->id) . '" width="' . $default_sizes['single_video']['width'] . '" height="' . ($default_sizes['single_video']['height'] == 0 ? 'auto' : $default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>',$this);
274
  }
275
  else{
276
+ $content.=apply_filters('bp_media_single_content_filter', '<video src="' . wp_get_attachment_url($this->id) . '" width="' . $default_sizes['single_video']['width'] . '" height="' . ($default_sizes['single_video']['height'] == 0 ? 'auto' : $default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>',$this);
277
  }
278
  break;
279
  case 'audio' :
280
+ $content.=apply_filters('bp_media_single_content_filter', '<audio src="' . wp_get_attachment_url($this->id) . '" width="' . $default_sizes['single_audio']['width'] . '" type="audio/mp3" id="bp_media_audio_' . $this->id . '" controls="controls" preload="none" ></audio><script>bp_media_create_element("bp_media_audio_' . $this->id . '");</script>',$this);
281
  break;
282
  case 'image' :
283
  $image_array = image_downsize($this->id, 'bp_media_single_image');
287
  return false;
288
  }
289
  $content .= '</div>';
290
+ $content .= '<div class="bp_media_description">' . __(wp_html_excerpt($this->description, $bp_media_default_excerpts['single_entry_description']),BP_MEDIA_TXT_DOMAIN) . '</div>';
291
  return $content;
292
  }
293
 
295
  * Returns the HTML for title of the single entry page of the Media Entry
296
  */
297
  function get_media_single_title(){
298
+ global $bp_media_default_excerpts,$bp_media;
299
+ $content = '<div class="bp_media_title">' . __(wp_html_excerpt($this->name, $bp_media_default_excerpts['single_entry_title']),BP_MEDIA_TXT_DOMAIN) . '</div>';
300
  return $content;
301
  }
302
 
304
  * Returns the HTML for a media entry to be shown in the listing/gallery page
305
  */
306
  function get_media_gallery_content() {
307
+ global $bp_media;
308
+ $attachment = $this->id;
309
  switch ($this->type) {
310
  case 'video' :
311
  if($this->thumbnail_id){
313
  $thumb_url = $medium_array[0];
314
  }
315
  else{
316
+ $thumb_url = BP_MEDIA_URL.'app/assets/img/video_thumb.png';
317
  }
318
  ?>
319
  <li>
320
+ <a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>">
321
  <img src="<?php echo $thumb_url; ?>" />
322
  </a>
323
+ <h3 title="<?php echo $this->name; ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>"><?php echo $this->name; ?></a></h3>
324
  </li>
325
  <?php
326
  break;
330
  $thumb_url = $medium_array[0];
331
  }
332
  else{
333
+ $thumb_url = BP_MEDIA_URL.'app/assets/img/audio_thumb.png';
334
  }
335
  ?>
336
  <li>
337
+ <a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>">
338
  <img src="<?php echo $thumb_url ?>" />
339
  </a>
340
+ <h3 title="<?php echo $this->name; ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>"><?php echo $this->name ?></a></h3>
341
  </li>
342
  <?php
343
  break;
349
  <a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
350
  <img src="<?php echo $medium_path ?>" />
351
  </a>
352
+ <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>"><?php echo $this->name ?></a></h3>
353
  </li>
354
  <?php
355
  break;
361
  function show_comment_form_wordpress(){
362
  query_posts('attachment_id='.$this->id);
363
  while(have_posts()): the_post();
364
+ add_action('comment_form','BPMediaFunction::wp_comment_form_mod');
365
  comments_template();
366
  endwhile;
367
  }
370
  * Outputs the comments and comment form in the single media entry page
371
  */
372
  function show_comment_form() {
373
+ global $bp_media;
374
  $activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
375
  if(!$activity_id || !function_exists('bp_has_activities'))
376
  return false;
390
  <?php if (is_user_logged_in()) : ?>
391
  <div class="activity-meta no-ajax">
392
  <?php if (bp_activity_can_comment()) : ?>
393
+ <a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf(__('Comment <span>%s</span>', BP_MEDIA_TXT_DOMAIN), bp_activity_get_comment_count()); ?></a>
394
  <?php endif; ?>
395
  <?php if (bp_activity_can_favorite()) : ?>
396
  <?php if (!bp_get_activity_is_favorite()) : ?>
397
+ <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
398
  <?php else : ?>
399
+ <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Remove Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
400
  <?php endif; ?>
401
  <?php endif; ?>
402
  <?php if (bp_activity_user_can_delete()) bp_activity_delete_link(); ?>
415
  <div class="ac-textarea">
416
  <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
417
  </div>
418
+ <input type="submit" name="ac_form_submit" value="<?php _e('Post', BP_MEDIA_TXT_DOMAIN); ?>" /> &nbsp; <?php _e('or press esc to cancel.', BP_MEDIA_TXT_DOMAIN); ?>
419
  <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
420
  </div>
421
  <?php do_action('bp_activity_entry_comments'); ?>
438
  <?php do_action('bp_activity_entry_content'); ?>
439
  <?php if (is_user_logged_in()) : ?>
440
  <div class="activity-meta no-ajax">
441
+ <a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow"><?php _e("Delete",BP_MEDIA_TXT_DOMAIN); ?></a>
442
  </div>
443
  <?php endif; ?>
444
  </div>
494
  *
495
  */
496
  function update_media_activity(){
497
+ global $wpdb, $bp, $current_user,$bp_media;
498
  $q = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id);
499
  $activities = $wpdb->get_results($q);
500
  if(isset($activities) && count($activities) > 0){
508
  'content' => $this->get_media_activity_content(),
509
  'id' => $activity->id,
510
  'type' => 'media_upload',
511
+ 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink( $this->get_author() ), '<a href="' . $this->get_url() . '">' . $this->get_media_activity_type() . '</a>' ) ),
512
  'primary_link' => $this->get_url(),
513
  'item_id' => $this->get_id(),
514
  'recorded_time' => $activity->date_recorded,
515
  'user_id' => $this->get_author()
516
  );
517
+ $activity_id = BPMediaFunction::record_activity($args);
518
  }
519
  }
520
  }
525
  function delete_media(){
526
  do_action('bp_media_before_delete_media',$this->id);
527
  global $bp_media_count;
528
+ BPMediaActions::init_count($this->owner);
529
  switch ($this->type) {
530
  case 'image':
531
  $bp_media_count['images'] = intval($bp_media_count['images']) - 1;
554
  $thumb_url = $medium_array[0];
555
  }
556
  else{
557
+ $thumb_url = BP_MEDIA_URL.'app/assets/img/video_thumb.png';
558
  }
559
  break;
560
  case 'audio' :
563
  $thumb_url = $medium_array[0];
564
  }
565
  else{
566
+ $thumb_url = BP_MEDIA_URL.'app/assets/img/audio_thumb.png';
567
  }
568
  break;
569
  case 'image' :
737
  AND $wpdb->posts.post_title = 'Wall Posts'" );
738
  }
739
  if($post_id==null){
740
+ $album = new BPMediaAlbum();
741
  if($group == 0 )
742
  $album->add_album('Wall Posts', get_current_user_id(), $group);
743
  else{
app/main/includes/BPMediaTemplateFunctions.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BPMediaTemplateFunctions {
4
+
5
+ function show_upload_form() {
6
+ global $bp, $bp_media_default_excerpts, $bp_media_options;
7
+ $allowed = array(
8
+ 'type' => array(),
9
+ 'accept' => array()
10
+ );
11
+ if ($bp_media_options['images_enabled']) {
12
+ $allowed['type'][] = 'image';
13
+ $allowed['accept'][] = 'image/*';
14
+ }
15
+ if ($bp_media_options['audio_enabled']) {
16
+ $allowed['type'][] = 'audio';
17
+ $allowed['accept'][] = 'audio/mp3';
18
+ }
19
+ if ($bp_media_options['videos_enabled']) {
20
+ $allowed['type'][] = 'video';
21
+ $allowed['accept'][] = 'video/mp4';
22
+ $allowed['accept'][] = 'video/quicktime';
23
+ }
24
+ $allowed = apply_filters('bp_media_allowed_filter', $allowed);
25
+ $accept = implode(',', $allowed['accept']);
26
+ ?>
27
+ <form method="post" enctype="multipart/form-data" class="standard-form" id="bp-media-upload-form">
28
+ <label for="bp-media-upload-input-title"><?php _e('Media Title', BP_MEDIA_TXT_DOMAIN); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'], $bp_media_default_excerpts['activity_entry_title'])) ?>" />
29
+ <label for="bp-media-upload-input-description"><?php _e('Media Description', BP_MEDIA_TXT_DOMAIN); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'], $bp_media_default_excerpts['activity_entry_description'])) ?>" />
30
+ <label for="bp-media-upload-file"><?php _e('Select Media File', BP_MEDIA_TXT_DOMAIN) ?> (Max File Size:<?php echo min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))); ?> , Allowed types: <?php echo implode(', ', $allowed['type']) ?>)</label><input type="file" name="bp_media_file" id="bp-media-upload-file" accept="<?php echo $accept ?>" />
31
+ <input type="hidden" name="action" value="wp_handle_upload" />
32
+ <div class="submit"><input type="submit" class="auto" value="Upload" /></div>
33
+ </form>
34
+ <?php
35
+ }
36
+
37
+ function show_upload_form_multiple() {
38
+ global $bp, $bp_media;
39
+ ?>
40
+ <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
41
+ if (bp_is_current_component('groups')) {
42
+ $albums = new WP_Query(array(
43
+ 'post_type' => 'bp_media_album',
44
+ 'posts_per_page' => -1,
45
+ 'meta_key' => 'bp-media-key',
46
+ 'meta_value' => -bp_get_current_group_id(),
47
+ 'meta_compare' => '='
48
+ ));
49
+ } else {
50
+ $albums = new WP_Query(array(
51
+ 'post_type' => 'bp_media_album',
52
+ 'posts_per_page' => -1,
53
+ 'author' => get_current_user_id()
54
+ ));
55
+ }
56
+ if (isset($albums->posts) && is_array($albums->posts) && count($albums->posts) > 0) {
57
+ foreach ($albums->posts as $album) {
58
+ if ($album->post_title == 'Wall Posts')
59
+ echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
60
+ else
61
+ echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>';
62
+ };
63
+ }else {
64
+ $album = new BPMediaAlbum();
65
+ if (bp_is_current_component('groups')) {
66
+ $current_group = new BP_Groups_Group(bp_get_current_group_id());
67
+ $album->add_album('Wall Posts', $current_group->creator_id, bp_get_current_group_id());
68
+ } else {
69
+ $album->add_album('Wall Posts', bp_loggedin_user_id());
70
+ }
71
+ echo '<option value="' . $album->get_id() . '" selected="selected">' . $album->get_title() . '</option>';
72
+ }
73
+ ?></select></div>
74
+ <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
75
+ <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
76
+ <div id="drag-drop-area">
77
+ <div class="drag-drop-inside">
78
+ <p class="drag-drop-info">Drop files here</p>
79
+ <p>or</p>
80
+ <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Select Files" class="button" /></p>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ <div id="bp-media-uploaded-files"></div>
85
+ <?php
86
+ }
87
+
88
+ function show_pagination($type = 'top', $inner = false) {
89
+ global $bp, $bp_media_paginated_links, $bp_media_query, $bp_media_albums_query;
90
+ switch ($bp->current_action) {
91
+ case BP_MEDIA_IMAGES_SLUG :
92
+ $current = $bp_media_query->found_posts > 1 ? BP_MEDIA_IMAGES_LABEL : BP_MEDIA_IMAGES_LABEL_SINGULAR;
93
+ $current_single = BP_MEDIA_IMAGES_LABEL_SINGULAR;
94
+ break;
95
+ case BP_MEDIA_VIDEOS_SLUG :
96
+ $current = $bp_media_query->found_posts > 1 ? BP_MEDIA_VIDEOS_LABEL : BP_MEDIA_VIDEOS_LABEL_SINGULAR;
97
+ $current_single = BP_MEDIA_VIDEOS_LABEL_SINGULAR;
98
+ break;
99
+ case BP_MEDIA_AUDIO_SLUG :
100
+ $current = BP_MEDIA_AUDIO_LABEL;
101
+ $current_single = BP_MEDIA_AUDIO_LABEL_SINGULAR;
102
+ break;
103
+ case BP_MEDIA_ALBUMS_SLUG:
104
+ $current = BP_MEDIA_ALBUMS_LABEL;
105
+ $current_single = BP_MEDIA_ALBUMS_LABEL_SINGULAR;
106
+ break;
107
+ default :
108
+ $current = BP_MEDIA_LABEL;
109
+ $current_single = BP_MEDIA_LABEL_SINGULAR;
110
+ }
111
+
112
+ if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG && !$inner) {
113
+ $args = array(
114
+ 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
115
+ 'format' => 'page/%#%',
116
+ 'total' => $bp_media_albums_query->max_num_pages,
117
+ 'current' => $bp_media_albums_query->query_vars['paged'],
118
+ 'type' => 'array',
119
+ 'prev_text' => '&larr;',
120
+ 'next_text' => '&rarr;',
121
+ );
122
+ $start_num = intval($bp_media_albums_query->query_vars['posts_per_page'] * ($bp_media_albums_query->query_vars['paged'] - 1)) + 1;
123
+ $from_num = $start_num;
124
+ $to_num = $start_num + $bp_media_albums_query->post_count - 1;
125
+ $total = $bp_media_albums_query->found_posts;
126
+ $bp_media_paginated_links = paginate_links($args);
127
+ } else {
128
+ if ($inner) {
129
+ $current = BP_MEDIA_LABEL;
130
+ $current_single = BP_MEDIA_LABEL_SINGULAR;
131
+ $args = array(
132
+ 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/' . $bp->action_variables[1]) . '%_%',
133
+ 'format' => 'page/%#%',
134
+ 'total' => $bp_media_query->max_num_pages,
135
+ 'current' => $bp_media_query->query_vars['paged'],
136
+ 'type' => 'array',
137
+ 'prev_text' => '&larr;',
138
+ 'next_text' => '&rarr;',
139
+ );
140
+ } else {
141
+ $args = array(
142
+ 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
143
+ 'format' => 'page/%#%',
144
+ 'total' => $bp_media_query->max_num_pages,
145
+ 'current' => $bp_media_query->query_vars['paged'],
146
+ 'type' => 'array',
147
+ 'prev_text' => '&larr;',
148
+ 'next_text' => '&rarr;',
149
+ );
150
+ }
151
+ $start_num = intval($bp_media_query->query_vars['posts_per_page'] * ($bp_media_query->query_vars['paged'] - 1)) + 1;
152
+ $from_num = $start_num;
153
+ $to_num = $start_num + $bp_media_query->post_count - 1;
154
+ $total = $bp_media_query->found_posts;
155
+ $bp_media_paginated_links = paginate_links($args);
156
+ }
157
+ ?>
158
+ <div id="pag-<?php echo $type; ?>" class="pagination no-ajax">
159
+ <div class="pag-count">
160
+ Viewing <?php echo $current_single ?> <?php echo $from_num ?> to <?php echo $to_num ?> (of <?php echo $total; ?> <?php echo $current ?>)
161
+ </div>
162
+ <div class="pagination-links">
163
+ <?php if (is_array($bp_media_paginated_links)) : foreach ($bp_media_paginated_links as $link) : ?>
164
+ <?php echo $link; ?>
165
+ <?php endforeach;
166
+ endif; ?>
167
+ </div>
168
+ </div>
169
+ <?php
170
+ }
171
+
172
+ function get_permalink($id = 0) {
173
+ if (is_object($id))
174
+ $media = $id;
175
+ else
176
+ $media = &get_post($id);
177
+ if (empty($media->ID))
178
+ return false;
179
+ if (!$media->post_type == 'bp_media')
180
+ return false;
181
+ switch (get_post_meta($media->ID, 'bp_media_type', true)) {
182
+ case 'video' :
183
+ return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $media->ID);
184
+ break;
185
+ case 'audio' :
186
+ return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $media->ID);
187
+ break;
188
+ case 'image' :
189
+ return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $media->ID);
190
+ break;
191
+ default :
192
+ return false;
193
+ }
194
+ }
195
+
196
+ function the_permalink() {
197
+ echo apply_filters('the_permalink', $this->get_permalink());
198
+ }
199
+
200
+ function the_content($id = 0) {
201
+ if (is_object($id))
202
+ $media = $id;
203
+ else
204
+ $media = &get_post($id);
205
+ if (empty($media->ID))
206
+ return false;
207
+ if ($media->post_type != 'bp_media')
208
+ return false;
209
+ try {
210
+ $media = new BPMediaHostWordpress($media->ID);
211
+ echo $media->get_media_gallery_content();
212
+ } catch (Exception $e) {
213
+ echo '';
214
+ }
215
+ }
216
+
217
+ function album_the_content($id = 0) {
218
+ if (is_object($id))
219
+ $album = $id;
220
+ else
221
+ $album = &get_post($id);
222
+ if (empty($album->ID))
223
+ return false;
224
+ if (!$album->post_type == 'bp_media_album')
225
+ return false;
226
+ try {
227
+ $album = new BPMediaAlbum($album->ID);
228
+ echo $album->get_album_gallery_content();
229
+ } catch (Exception $e) {
230
+ echo '';
231
+ }
232
+ }
233
+
234
+ function display_show_more($type = 'media') {
235
+ $showmore = false;
236
+ switch ($type) {
237
+ case 'media':
238
+ global $bp_media_query;
239
+ //found_posts
240
+ if (isset($bp_media_query->found_posts) && $bp_media_query->found_posts > 10)
241
+ $showmore = true;
242
+ break;
243
+ case 'albums':
244
+ global $bp_media_albums_query;
245
+ if (isset($bp_media_query->found_posts) && $bp_media_query->found_posts > 10)
246
+ $showmore = true;
247
+ break;
248
+ }
249
+ if ($showmore) {
250
+ echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">Show More</a></div>';
251
+ }
252
+ }
253
+
254
+ static function show_upload_form_multiple_activity() {
255
+ global $bp, $bp_media_default_excerpts;
256
+ if ($bp->current_component != 'activity')
257
+ return;
258
+ ?>
259
+ <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
260
+ $albums = new WP_Query(array(
261
+ 'post_type' => 'bp_media_album',
262
+ 'posts_per_page' => -1,
263
+ 'author' => get_current_user_id()
264
+ ));
265
+ if (isset($albums->posts) && is_array($albums->posts) && count($albums->posts) > 0) {
266
+ foreach ($albums->posts as $album) {
267
+ if ($album->post_title == 'Wall Posts')
268
+ echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
269
+ else
270
+ echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>';
271
+ };
272
+ }
273
+ ?></select></div>
274
+ <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
275
+ <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop activity-component">
276
+ <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Add Media" class="button" /></p>
277
+ </div>
278
+ <div id="bp-media-uploaded-files"></div>
279
+ <?php
280
+ }
281
+
282
+ }
283
+ ?>
app/main/includes/BPMediaUpgradeScript.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BPMediaUpgradeScript{
3
+
4
+ static function upgrade_from_1_0_to_2_1(){
5
+ global $wpdb;
6
+ remove_filter('bp_activity_get_user_join_filter','activity_query_filter',10);
7
+ /* @var $wpdb wpdb */
8
+ $wall_posts_album_ids=array();
9
+ do{
10
+ $media_files = new WP_Query(array(
11
+ 'post_type' => 'bp_media',
12
+ 'posts_per_page' => 10
13
+ ));
14
+ $media_files = isset($media_files->posts)?$media_files->posts:null;
15
+ if(is_array($media_files)&&count($media_files)){
16
+ foreach($media_files as $media_file){
17
+ $attachment_id = get_post_meta($media_file->ID,'bp_media_child_attachment',true);
18
+ $child_activity = get_post_meta($media_file->ID,'bp_media_child_activity',true);
19
+ update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
20
+ $attachment = get_post($attachment_id , ARRAY_A);
21
+ if(isset($wall_posts_album_ids[$media_file->post_author])){
22
+ $wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
23
+ }
24
+ else{
25
+ $wall_posts_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title = 'Wall Posts' AND post_author = '". $media_file->post_author."' AND post_type='bp_media_album'");
26
+ if($wall_posts_id==null){
27
+ $album = new BPMediaAlbum();
28
+ $album->add_album('Wall Posts',$media_file->post_author);
29
+ $wall_posts_id = $album->get_id();
30
+ }
31
+ if(!$wall_posts_id){
32
+ continue; //This condition should never be encountered
33
+ }
34
+ $wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
35
+ }
36
+ $attachment['post_parent'] = $wall_posts_id;
37
+ wp_update_post($attachment);
38
+ update_post_meta($attachment_id,'bp-media-key',$media_file->post_author);
39
+ $activity = bp_activity_get(array('in'=>intval($child_activity)));
40
+ if(isset($activity['activities'][0]->id))
41
+ $activity = $activity['activities'][0];
42
+ try{
43
+ $bp_media = new BPMediaHostWordpress($attachment_id);
44
+ }
45
+ catch(exception $e){
46
+ continue;
47
+ }
48
+ $args = array(
49
+ 'content' => $bp_media->get_media_activity_content(),
50
+ 'id' => $child_activity,
51
+ 'type' => 'media_upload',
52
+ 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink( $media_file->post_author ), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>' ) ),
53
+ 'primary_link' => $bp_media->get_url(),
54
+ 'item_id' => $attachment_id,
55
+ 'recorded_time' => $activity->date_recorded,
56
+ 'user_id' => $bp_media->get_author()
57
+ );
58
+ $act_id = BPMediaFunction::record_activity($args);
59
+ bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
60
+ wp_delete_post($media_file->ID);
61
+ }
62
+ }
63
+ else{
64
+ break;
65
+ }
66
+ }while(1);
67
+ update_site_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
68
+ add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
69
+ wp_cache_flush();
70
+ }
71
+
72
+ static function database_updated_notice(){
73
+ echo '<div class="updated rt-success"><p>
74
+ <b>BuddyPress Media</b> Database upgraded successfully.
75
+ </p></div>';
76
+ }
77
+ static function upgrade_from_2_0_to_2_1(){
78
+ $page = 0;
79
+ while($media_entries = BPMediaUpgradeScript::return_query_posts(array(
80
+ 'post_type' => 'attachment',
81
+ 'post_status' => 'any',
82
+ 'meta_key' => 'bp-media-key',
83
+ 'meta_value' => 0,
84
+ 'meta_compare' => '>',
85
+ 'paged' => ++$page,
86
+ 'postsperpage' => 10
87
+ ))){
88
+ foreach($media_entries as $media){
89
+ try{
90
+ $bp_media = new BPMediaHostWordpress($media->ID);
91
+ } catch (exception $e){
92
+ continue;
93
+ }
94
+ $child_activity = get_post_meta($media->ID,'bp_media_child_activity',true);
95
+ if($child_activity){
96
+ $activity = bp_activity_get(array('in'=>intval($child_activity)));
97
+ if(isset($activity['activities'][0]->id))
98
+ $activity = $activity['activities'][0];
99
+ else
100
+ continue;
101
+ $args = array(
102
+ 'content' => $bp_media->get_media_activity_content(),
103
+ 'id' => $child_activity,
104
+ 'type' => 'media_upload',
105
+ 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink( $bp_media->get_author() ), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>' ) ),
106
+ 'primary_link' => $bp_media->get_url(),
107
+ 'item_id' => $activity->item_id,
108
+ 'recorded_time' => $activity->date_recorded,
109
+ 'user_id' => $bp_media->get_author()
110
+ );
111
+ BPMediaFunction::record_activity($args);
112
+ }
113
+ }
114
+ }
115
+ update_site_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
116
+ add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
117
+ wp_cache_flush();
118
+ }
119
+
120
+ static function return_query_posts($args){
121
+ $bp_media_query = new WP_Query($args);
122
+ return $bp_media_query->posts;
123
+ }
124
+ }
125
+ ?>
app/main/includes/BPMediaUtils.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BPMediaUtils {
4
+
5
+ function __construct() {
6
+ if (version_compare(BP_MEDIA_DB_VERSION, get_site_option('bp_media_db_version', '1.0'), '>')) {
7
+ add_action('admin_notices', array($this,'upgrade_db_notice'));
8
+ }
9
+ add_action('wp_loaded', array($this,'upgrade_script'));
10
+ add_action(bp_core_admin_hook(), array($this,'add_admin_menu'));
11
+ add_action('admin_init', array($this,'on_load_page'));
12
+ add_action('wp_ajax_bp_media_cancel_request', array($this,'cancel_request'));
13
+ add_action('wp_ajax_bp_media_request_type', array($this,'handle_request_type'));
14
+ add_action('admin_enqueue_scripts', array($this,'admin_enqueue'));
15
+ add_action('bp_admin_tabs', array($this,'admin_tab'));
16
+ }
17
+
18
+ function upgrade_script() {
19
+ if (isset($_GET['bp_media_upgrade_db']) && empty($_REQUEST['settings-updated'])) {
20
+ check_admin_referer('bp_media_upgrade_db', 'wp_nonce');
21
+ require_once('bp-media-upgrade-script.php');
22
+ $current_version = get_site_option('bp_media_db_version', '1.0');
23
+ if ($current_version == '2.0')
24
+ BPMediaUpgradeScript::upgrade_from_2_0_to_2_1();
25
+ else
26
+ BPMediaUpgradeScript::upgrade_from_1_0_to_2_1();
27
+ remove_action('admin_notices', array($this,'upgrade_db_notice'));
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Displays admin notice to upgrade BuddyPress Media Database
33
+ */
34
+ function upgrade_db_notice() {
35
+ ?>
36
+ <div class="error"><p>
37
+ Please click upgrade to upgrade the database of BuddyPress Media <a class="button" id="refresh_media_count" href ="<?php echo bp_media_get_admin_url(add_query_arg(array('page' => 'bp-media-settings', 'bp_media_upgrade_db' => 1, 'wp_nonce' => wp_create_nonce('bp_media_upgrade_db')), 'admin.php')) ?>" class="button" title="<?php printf(__('It will migrate your BuddyPress Media\'s earlier database to new database.')); ?>">Upgrade</a>
38
+ </p></div>
39
+ <?php
40
+ }
41
+
42
+ /**
43
+ * Add the BuddyPress Media's options menu in the BuddyPress' options subnavigation.
44
+ *
45
+ * @since BuddyPress Media 2.0
46
+ */
47
+ function add_admin_menu() {
48
+
49
+ global $bp, $bp_media_errors, $bp_media_messages;
50
+ if (!is_super_admin())
51
+ return false;
52
+ $bp_media_errors = array();
53
+ $bp_media_messages = array();
54
+ global $bp_media_options;
55
+ $bp_media_options = get_site_option('bp_media_options', array(
56
+ 'videos_enabled' => true,
57
+ 'audio_enabled' => true,
58
+ 'images_enabled' => true,
59
+ 'download_enabled' => true,
60
+ 'remove_linkback' => 1,
61
+ ));
62
+ if (isset($_POST['submit'])) {
63
+ if (isset($_POST['bp_media_options'])) {
64
+ foreach ($bp_media_options as $option => $value) {
65
+ if (isset($_POST['bp_media_options'][$option])) {
66
+ switch ($_POST['bp_media_options'][$option]) {
67
+ case 'true' :
68
+ $bp_media_options[$option] = true;
69
+ break;
70
+ case '1' :
71
+ $bp_media_options[$option] = 1;
72
+ break;
73
+ case '2' :
74
+ $bp_media_options[$option] = 2;
75
+ break;
76
+ default :
77
+ $bp_media_options[$option] = false;
78
+ }
79
+ } else {
80
+ $bp_media_options[$option] = false;
81
+ }
82
+ }
83
+ if (update_site_option('bp_media_options', $bp_media_options)) {
84
+ $bp_media_messages[0] = "<b>Settings saved.</b>";
85
+ }
86
+ }
87
+ do_action('bp_media_save_options');
88
+ $bp_media_messages = apply_filters('bp_media_settings_messages', $bp_media_messages);
89
+ $bp_media_errors = apply_filters('bp_media_settings_errors', $bp_media_errors);
90
+ } else if (isset($_GET['bp_media_refresh_count'])) {
91
+
92
+ check_admin_referer('bp_media_refresh_count', 'wp_nonce');
93
+ if (!BPMediaFunction::update_count())
94
+ $bp_media_errors[] = "<b>Recounting Failed</b>";
95
+ else
96
+ $bp_media_messages[] = "<b>Recounting of media files done successfully</b>";
97
+ }else if (isset($_REQUEST['submit-report'])) {
98
+
99
+ if (empty($_REQUEST['ur_name'])) {
100
+ $bp_media_errors[] = "<b>Please Enter Name</b>";
101
+ }
102
+ if (empty($_REQUEST['ur_email'])) {
103
+ $bp_media_errors[] = "<b>Please Enter Valid Email Address</b>";
104
+ }
105
+ if (!empty($_REQUEST['ur_email']) && !is_email(trim($_REQUEST['ur_email']))) {
106
+ $bp_media_errors[] = "<b>Please Enter Valid Email Address</b>";
107
+ }
108
+ if (empty($_REQUEST['ur_subject'])) {
109
+ $bp_media_errors[] = "<b>Please Enter Subject</b>";
110
+ }
111
+ if (empty($_REQUEST['ur_query'])) {
112
+ $bp_media_errors[] = "<b>Please Enter Details</b>";
113
+ }
114
+ if (isset($_REQUEST['request_type']) && $_REQUEST['request_type'] == 'bug_report') {
115
+ if (!file_exists(BP_MEDIA_TMP_DIR) && @!mkdir(BP_MEDIA_TMP_DIR, 0777))
116
+ $bp_media_errors[] = "The Buddypress Media Temporary directory does not exist and could not be created. Please check that directory have write permissions for the 'uploads' directory. ";
117
+ }
118
+ if (empty($bp_media_errors)) {
119
+
120
+ $attachments = array();
121
+ $str_to = BP_MEDIA_SUPPORT_EMAIL;
122
+ $str_subject = html_entity_decode(esc_attr(stripslashes($_REQUEST['ur_subject'])), ENT_QUOTES, 'UTF-8');
123
+
124
+ $request_type = $_REQUEST['request_type'];
125
+ $request_id = $_REQUEST['request_id'];
126
+ $server_address = $_REQUEST['server_address'];
127
+ $ip_address = $_REQUEST['ip_address'];
128
+ $server_type = $_REQUEST['server_type'];
129
+ $user_agent = $_REQUEST['user_agent'];
130
+ $str_message = '';
131
+ $str_title = ($request_type == 'bug_report') ? 'Bug Report' : 'New Feature Request';
132
+ switch ($request_type) {
133
+ case "bug_report":
134
+ $str_title = __('Bug Report', BP_MEDIA_TXT_DOMAIN);
135
+ break;
136
+ case "new_feature":
137
+ $str_title = __('New Feature Request', BP_MEDIA_TXT_DOMAIN);
138
+ break;
139
+ case "premium_support":
140
+ $str_title = __('Premium Support Request', BP_MEDIA_TXT_DOMAIN);
141
+ break;
142
+ }
143
+ $str_message .= "<h3><strong>$str_title</strong></h3>";
144
+
145
+ $str_message .= "<table>";
146
+ if (isset($_REQUEST['request_id']))
147
+ $str_message .= "<tr><td><strong>Request Id : </strong></td><td>" . $_REQUEST['request_id'] . "</td></tr>";
148
+ if (isset($_REQUEST['ip_address']))
149
+ $str_message .= "<tr><td><strong>Request IP Address : </strong></td><td>" . $_REQUEST['ip_address'] . "</td></tr>";
150
+ if (isset($_REQUEST['server_address']))
151
+ $str_message .= "<tr><td><strong>Request Server Address : </strong></td><td>" . $_REQUEST['server_address'] . "</td></tr>";
152
+ if (isset($_REQUEST['server_type']))
153
+ $str_message .= "<tr><td><strong>Request Server Type : </strong></td><td>" . $_REQUEST['server_type'] . "</td></tr>";
154
+ if (isset($_REQUEST['user_agent']))
155
+ $str_message .= "<tr><td><strong>Request User Agent : </strong></td><td>" . $_REQUEST['user_agent'] . "</td></tr>";
156
+ if (BP_MEDIA_VERSION)
157
+ $str_message .= "<tr><td><strong>Buddypress Media Version : </strong></td><td>" . BP_MEDIA_VERSION . "</td></tr>";
158
+ if (isset($_REQUEST['ur_name']))
159
+ $str_message .= "<tr><td><strong>Name : </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_name']))) . "</td></tr>";
160
+ if (isset($_REQUEST['ur_phone']))
161
+ $str_message .= "<tr><td><strong>Phone No. : </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_phone']))) . "</td></tr>";
162
+ $str_message .= "</table><br/><br/>";
163
+
164
+ if ($request_type == 'bug_report') {
165
+
166
+ $str_message .= "<h3><strong>Wordpress and Hosting Details</strong></h3>";
167
+ $str_message .= "<table>";
168
+
169
+ if (isset($_REQUEST['ur_wp_admin_login']))
170
+ $str_message .= "<tr><td><strong>WP Admin Login : </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_wp_admin_login']))) . "</td></tr>";
171
+ if (isset($_REQUEST['ur_wp_admin_pwd']))
172
+ $str_message .= "<tr><td><strong>WP Admin Password : </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_wp_admin_pwd']))) . "</td></tr>";
173
+ if (isset($_REQUEST['ur_ssh_ftp_host']))
174
+ $str_message .= "<tr><td><strong>SSH / FTP Host : </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_ssh_ftp_host']))) . "</td></tr>";
175
+ if (isset($_REQUEST['ur_ssh_ftp_login']))
176
+ $str_message .= "<tr><td><strong>SSH / FTP Login: </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_ssh_ftp_login']))) . "</td></tr>";
177
+ if (isset($_REQUEST['ur_ssh_ftp_pwd']))
178
+ $str_message .= "<tr><td><strong>SSH / FTP Password: </strong></td><td>" . esc_attr(stripslashes(trim($_REQUEST['ur_ssh_ftp_pwd']))) . "</td></tr>";
179
+ $str_message .= "</table><br/><br/>";
180
+
181
+
182
+ /* Create server info file */
183
+ $server_data = $this->get_server_info();
184
+ $server_info = '';
185
+ if (!empty($server_data)) {
186
+ $server_info .= '<table cellpadding="2px" >';
187
+ foreach ($server_data as $key => $val) {
188
+ $server_info .= '<tr><th><strong>' . $key . '</strong></th></th></tr>';
189
+ foreach ($val as $title => $content) {
190
+ $server_info .= '<tr>';
191
+ $server_info .= '<td valign = "top"><strong>' . $title . '</strong></td>';
192
+ if (is_array($content)) {
193
+ $server_info .= '<td valign = "top"><table>';
194
+ foreach ($content as $sub_title => $sub_content) {
195
+ $server_info .= '<tr>';
196
+ $server_info .= '<td valign = "top"><strong>' . $sub_title . '</strong></td>';
197
+ $server_info .= '<td valign = "top">' . print_r($sub_content, true) . '</td>';
198
+ $server_info .= '</tr>';
199
+ }
200
+ $server_info .= '</table></td>';
201
+ } else {
202
+ $server_info .= '<td>' . $content . '</td>';
203
+ }
204
+
205
+ $server_info .= '</tr>';
206
+ $server_info .= '<tr><td></td><td></td></tr>';
207
+ }
208
+ }
209
+ $server_info .= '</table>';
210
+ }
211
+
212
+ $server_info_path = BP_MEDIA_TMP_DIR . '/server_info.html';
213
+
214
+ if (@file_put_contents($server_info_path, $server_info)) {
215
+ $attachments[] = $server_info_path;
216
+ }
217
+
218
+ /* Create phpinfo file and attach to Email */
219
+ if (isset($_REQUEST['ur_send_phpinfo']) && $_REQUEST['ur_send_phpinfo'] == 'true') {
220
+ ob_start();
221
+ phpinfo();
222
+ $php_info = ob_get_contents();
223
+ ob_end_clean();
224
+
225
+ $php_info_path = BP_MEDIA_TMP_DIR . '/php_info.html';
226
+ if (@file_put_contents($php_info_path, $php_info)) {
227
+ $attachments[] = $php_info_path;
228
+ }
229
+ }
230
+ /* Attach other files */
231
+ if (!empty($_FILES['ur_attachment'])) {
232
+ $files = (array) $_FILES['ur_attachment'];
233
+ for ($i = 0, $l = count($files); $i < $l; $i++) {
234
+ if (isset($files['tmp_name'][$i]) && isset($files['name'][$i]) && isset($files['error'][$i]) && $files['error'][$i] == UPLOAD_ERR_OK) {
235
+ $path = BP_MEDIA_TMP_DIR . '/' . $files['name'][$i];
236
+ if (@move_uploaded_file($files['tmp_name'][$i], $path)) {
237
+ $attachments[] = $path;
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ /* if(isset($_REQUEST['ur_templates'])){
244
+ $templates = $_REQUEST['ur_templates'];
245
+ if(!empty($templates)){
246
+ foreach ($templates as $template) {
247
+ if (!empty($template)) {
248
+ $attachments[] = $template;
249
+ }
250
+ }
251
+ }
252
+ } */
253
+ }
254
+ $str_message .= nl2br(esc_attr(stripslashes($_REQUEST['ur_query'])));
255
+
256
+
257
+ /* Uniqid Session */
258
+ $strSid = md5(uniqid(time()));
259
+
260
+ /* Creating Header */
261
+ $str_header = "";
262
+ $str_header .= "From: " . $_REQUEST['ur_name'] . "<" . $_REQUEST['ur_email'] . ">";
263
+ $str_header .= "Reply-To: " . $_REQUEST['ur_name'] . "<" . $_REQUEST['ur_email'] . ">";
264
+
265
+ $str_header .= "MIME-Version: 1.0\n";
266
+ $str_header .= "Content-Type: multipart/mixed; boundary=\"" . $strSid . "\"\n\n";
267
+ $str_header .= "Content-type: text/html; charset=utf-8\n";
268
+ $str_header .= "Content-Transfer-Encoding: 7bit\n\n";
269
+
270
+ $flgSend = wp_mail($str_to, $str_subject, $str_message, $str_header, $attachments); // @ = No Show Error //
271
+
272
+ /* Delete temporary files */
273
+ if (!empty($attachments)) {
274
+ foreach ($attachments as $attachment) {
275
+ if (strstr($attachment, BP_MEDIA_TMP_DIR) !== false) {
276
+ @unlink($attachment);
277
+ }
278
+ }
279
+ }
280
+ if ($flgSend) {
281
+ switch ($request_type) {
282
+ case "bug_report":
283
+ $succ_msg = __('Thank you, Your bug report sent successfully.', BP_MEDIA_TXT_DOMAIN);
284
+ break;
285
+ case "new_feature":
286
+ $succ_msg = __('Thank you, Your new feature request sent successfully.', BP_MEDIA_TXT_DOMAIN);
287
+ break;
288
+ case "premium_support":
289
+ $succ_msg = __('Thank you, Your premium support request sent successfully, We will contact you soon.', BP_MEDIA_TXT_DOMAIN);
290
+ break;
291
+ }
292
+ $bp_media_messages[] = '<strong>' . $succ_msg . '</strong>';
293
+ } else {
294
+ $bp_media_errors[] = "<strong>Mail could not be sent</strong>";
295
+ }
296
+ }
297
+ }
298
+
299
+ if (isset($bp_media_errors) && count($bp_media_errors)) {
300
+ ?>
301
+ <div class="error"><p><?php foreach ($bp_media_errors as $error)
302
+ echo $error . '<br/>'; ?></p></div><?php } if (isset($bp_media_messages) && count($bp_media_messages)) {
303
+ ?>
304
+ <div class="updated"><p><?php foreach ($bp_media_messages as $message)
305
+ echo $message . '<br/>'; ?></p></div><?php
306
+ }
307
+
308
+ add_menu_page('Buddypress Media Component', 'BuddyPress Media', 'manage_options', 'bp-media-settings', array($this,'settings_page'));
309
+ 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"));
310
+ 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,"settings_page"));
311
+ 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,"settings_page"));
312
+
313
+ $tab = BPMediaAdmin::get_current_tab();
314
+ add_action('admin_print_styles-' . $tab, array($this,'admin_enqueue'));
315
+ }
316
+
317
+ /**
318
+ * Applies WordPress metabox funtionality to metaboxes
319
+ *
320
+ *
321
+ */
322
+ function on_load_page() {
323
+
324
+ /* Javascripts loaded to allow drag/drop, expand/collapse and hide/show of boxes. */
325
+ wp_enqueue_script('common');
326
+ wp_enqueue_script('wp-lists');
327
+ wp_enqueue_script('postbox');
328
+
329
+ // Check to see which tab we are on
330
+ $tab = BPMediaAdmin::get_current_tab();
331
+
332
+ switch ($tab) {
333
+ case 'bp-media-addons' :
334
+ // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
335
+ add_meta_box('addons_list_metabox', __('BuddyPress Media Addons for Audio/Video Conversion', BP_MEDIA_TXT_DOMAIN), array($this,'addons_list'), 'bp-media-settings', 'normal', 'core');
336
+ break;
337
+ case 'bp-media-support' :
338
+ // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
339
+ add_meta_box('bp_media_support_metabox', __('BuddyPress Media Support', 'rtPanel'), array($this,'bp_media_support'), 'bp-media-settings', 'normal', 'core');
340
+ add_meta_box('bp_media_form_report_metabox', __('Submit a request form', 'rtPanel'), array($this,'send_request'), 'bp-media-settings', 'normal', 'core');
341
+ break;
342
+ case $tab :
343
+ // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
344
+ add_meta_box('bp_media_settings_metabox', __('BuddyPress Media Settings', 'rtPanel'), 'bp_media_admin_menu', 'bp-media-settings', 'normal', 'core');
345
+ add_meta_box('bp_media_options_metabox', __('Spread the word', 'rtPanel'), array($this,'settings_options'), 'bp-media-settings', 'normal', 'core');
346
+ add_meta_box('bp_media_other_options_metabox', __('BuddyPress Media Other options', 'rtPanel'), array($this,'settings_other_options'), 'bp-media-settings', 'normal', 'core');
347
+ break;
348
+ }
349
+ }
350
+
351
+ function settings_page() {
352
+
353
+ $tab = BPMediaAdmin::get_current_tab();
354
+ ?>
355
+
356
+ <div class="wrap bp-media-admin">
357
+ <div id="icon-buddypress" class="icon32"><br></div>
358
+ <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs(__('Media', BP_MEDIA_TXT_DOMAIN)); ?></h2>
359
+ <div class="metabox-holder columns-2">
360
+ <div class="bp-media-settings-tabs"><?php
361
+ // Check to see which tab we are on
362
+ if (current_user_can('manage_options')) {
363
+ $tabs_html = '';
364
+ $idle_class = 'media-nav-tab';
365
+ $active_class = 'media-nav-tab media-nav-tab-active';
366
+ $tabs = array();
367
+
368
+ // Check to see which tab we are on
369
+ $tab = BPMediaAdmin::get_current_tab();
370
+ /* BuddyPress Media */
371
+ $tabs[] = array(
372
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
373
+ 'title' => __('Buddypress Media Settings', BP_MEDIA_TXT_DOMAIN),
374
+ 'name' => __('Settings', BP_MEDIA_TXT_DOMAIN),
375
+ 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
376
+ );
377
+
378
+ $tabs[] = array(
379
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
380
+ 'title' => __('Buddypress Media Addons', BP_MEDIA_TXT_DOMAIN),
381
+ 'name' => __('Addons', BP_MEDIA_TXT_DOMAIN),
382
+ 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
383
+ );
384
+
385
+ $tabs[] = array(
386
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
387
+ 'title' => __('Buddypress Media Support', BP_MEDIA_TXT_DOMAIN),
388
+ 'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
389
+ 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
390
+ );
391
+
392
+ $pipe = '|';
393
+ $i = '1';
394
+ foreach ($tabs as $tab) {
395
+ if ($i != 1)
396
+ $tabs_html.=$pipe;
397
+ $tabs_html.= '<a title=""' . $tab['title'] . '" " href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
398
+ $i++;
399
+ }
400
+ echo $tabs_html;
401
+ }
402
+ ?>
403
+ </div>
404
+
405
+ <div id="bp-media-settings-boxes">
406
+
407
+ <form id="bp_media_settings_form" name="bp_media_settings_form" action="" method="post" enctype="multipart/form-data"><?php
408
+ settings_fields('bp_media_options_settings');
409
+ do_settings_fields('bp_media_options_settings', '');
410
+ echo '<div class="bp-media-metabox-holder">';
411
+
412
+ if (isset($_REQUEST['request_type'])) {
413
+ BPMediaUtils::bp_media_bug_report_form($_REQUEST['request_type']);
414
+ } else {
415
+ do_meta_boxes('bp-media-settings', 'normal', '');
416
+ }
417
+
418
+ echo '</div>';
419
+ ?>
420
+
421
+ <script type="text/javascript">
422
+ //<![CDATA[
423
+ jQuery(document).ready( function($) {
424
+ // close postboxes that should be closed
425
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
426
+ // postboxes setup
427
+ postboxes.add_postbox_toggles('bp-media-settings');
428
+ });
429
+ //]]>
430
+ </script>
431
+
432
+ </form>
433
+ </div><!-- .bp-media-settings-boxes -->
434
+ <div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
435
+ <?php $this->default_admin_sidebar(); ?>
436
+ </div>
437
+ </div><!-- .metabox-holder -->
438
+ </div><!-- .bp-media-admin --><?php
439
+ }
440
+
441
+ /**
442
+ * Displays and updates the options menu of BuddyPress Media
443
+ *
444
+ * @since BuddyPress Media 2.0
445
+ */
446
+ function bp_media_admin_menu() {
447
+
448
+ $bp_media_errors = array();
449
+ $bp_media_messages = array();
450
+
451
+ global $bp_media_options;
452
+ $bp_media_options = get_site_option('bp_media_options', array(
453
+ 'videos_enabled' => true,
454
+ 'audio_enabled' => true,
455
+ 'images_enabled' => true,
456
+ 'download_enabled' => true,
457
+ 'remove_linkback' => 1,
458
+ ));
459
+ ?>
460
+
461
+ <?php if (count($bp_media_errors)) { ?>
462
+ <div class="error"><p><?php foreach ($bp_media_errors as $error)
463
+ echo $error . '<br/>'; ?></p></div>
464
+ <?php } if (count($bp_media_messages)) { ?>
465
+ <div class="updated"><p><?php foreach ($bp_media_messages as $message)
466
+ echo $message . '<br/>'; ?></p></div>
467
+ <?php } ?>
468
+ <table class="form-table ">
469
+ <tbody>
470
+ <tr valign="top">
471
+ <th scope="row"><label for="videos_enabled">Videos</label></th>
472
+ <td>
473
+ <fieldset>
474
+ <legend class="screen-reader-text"><span>Enable Videos</span></legend>
475
+ <label for="videos_enabled"><input name="bp_media_options[videos_enabled]" type="checkbox" id="videos_enabled" value="true" <?php global $bp_media_options;
476
+ checked($bp_media_options['videos_enabled'], true) ?>> (Check to enable video upload functionality)</label>
477
+ </fieldset>
478
+ </td>
479
+ </tr>
480
+ <tr valign="top">
481
+ <th scope="row"><label for="audio_enabled">Audio</label></th>
482
+ <td>
483
+ <fieldset>
484
+ <legend class="screen-reader-text"><span>Enable Audio</span></legend>
485
+ <label for="audio_enabled"><input name="bp_media_options[audio_enabled]" type="checkbox" id="audio_enabled" value="true" <?php checked($bp_media_options['audio_enabled'], true) ?>> (Check to enable audio upload functionality)</label>
486
+ </fieldset>
487
+ </td>
488
+ </tr>
489
+ <tr valign="top">
490
+ <th scope="row"><label for="images_enabled">Images</label></th>
491
+ <td>
492
+ <fieldset>
493
+ <legend class="screen-reader-text"><span>Enable Images</span></legend>
494
+ <label for="images_enabled"><input name="bp_media_options[images_enabled]" type="checkbox" id="images_enabled" value="true" <?php checked($bp_media_options['images_enabled'], true) ?>> (Check to enable images upload functionality)</label>
495
+ </fieldset>
496
+ </td>
497
+ </tr>
498
+ <tr valign="top">
499
+ <th scope="row"><label for="download_enabled">Download</label></th>
500
+ <td>
501
+ <fieldset>
502
+ <legend class="screen-reader-text"><span>Enable Download</span></legend>
503
+ <label for="download_enabled"><input name="bp_media_options[download_enabled]" type="checkbox" id="download_enabled" value="true" <?php checked($bp_media_options['download_enabled'], true) ?>> (Check to enable download functionality)</label>
504
+ </fieldset>
505
+ </td>
506
+ </tr>
507
+ </tbody>
508
+ </table>
509
+
510
+ <?php do_action('bp_media_extension_options'); ?>
511
+
512
+ <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary bp-media-submit" value="Save Changes"></p>
513
+ <div class="clear"></div><?php
514
+ }
515
+
516
+ function settings_other_options() {
517
+ ?>
518
+
519
+ <table class="form-table">
520
+ <tbody>
521
+ <tr valign="top">
522
+ <th scope="row"><label for="refresh_media_count">Re-Count Media Entries</label></th>
523
+ <td> <fieldset>
524
+ <a id="refresh_media_count" href ="?page=bp-media-settings&bp_media_refresh_count=1&wp_nonce=<?php echo wp_create_nonce('bp_media_refresh_count'); ?>" class="button" title="<?php printf(__('It will re-count all media entries of all users and correct any discrepancies.')); ?>">Re-Count</a>
525
+ </fieldset>
526
+ </td>
527
+ </tr>
528
+ </tbody>
529
+ </table>
530
+ <div class="clear"></div>
531
+
532
+ <?php
533
+ }
534
+
535
+ function settings_options() {
536
+ global $bp_media_options;
537
+ $bp_media_options = get_site_option('bp_media_options', array(
538
+ 'videos_enabled' => true,
539
+ 'audio_enabled' => true,
540
+ 'images_enabled' => true,
541
+ 'download_enabled' => true,
542
+ 'remove_linkback' => 1,
543
+ ));
544
+ ?>
545
+ <table class="form-table ">
546
+ <tbody>
547
+ <tr valign="top">
548
+ <th scope="row"><label for="remove_linkback">Spread the word</label></th>
549
+ <td>
550
+ <fieldset>
551
+ <legend class="screen-reader-text"><span>Yes, I want to support BuddyPress Media</span></legend>
552
+ <label for="remove_linkback_yes"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_yes" value="2" <?php checked($bp_media_options['remove_linkback'], '2'); ?>> Yes, I support BuddyPress Media</label>
553
+ <br/>
554
+ <legend class="screen-reader-text"><span>No, I don't want to support BuddyPress Media</span></legend>
555
+ <label for="remove_linkback_no"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_no" value="1" <?php checked($bp_media_options['remove_linkback'], '1'); ?>> No, I don't support BuddyPress Media</label>
556
+ </fieldset>
557
+ </td>
558
+ </tr>
559
+ </tbody>
560
+ </table>
561
+ <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary bp-media-submit" value="Save Changes"></p>
562
+ <div class="clear"></div>
563
+ <?php }
564
+
565
+ function addons_list() {
566
+ ?>
567
+
568
+ <div class="addon-list">
569
+ <ul class="products">
570
+
571
+ <li class="product first">
572
+ <a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">
573
+ <img width="240" height="184" title="BuddyPress - Media Kaltura Add-on" alt="BuddyPress - Media Kaltura Add-on" src="http://cdn.rtcamp.com/files/2012/10/new-buddypress-media-kaltura-logo-240x184.png">
574
+ </a>
575
+ <h4><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">BuddyPress-Media Kaltura Add-on</a></h4>
576
+ <div class="product_desc">
577
+ <p>Add support for more video formats using Kaltura video solution.</p>
578
+ <p>Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.</p>
579
+ </div>
580
+ <div class="product_footer">
581
+ <span class="price alignleft"><span class="amount">$99</span></span>
582
+ <a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=15446"><?php _e('Buy Now', BP_MEDIA_TXT_DOMAIN); ?></a>
583
+ <a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-kaltura/" title="BuddyPress Media Kaltura Add-on">Live Demo</a>
584
+ </div><!-- .product_footer -->
585
+ </li>
586
+ <li class="product last">
587
+ <a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >
588
+ <img width="240" height="184" title="BuddyPress-Media FFMPEG Converter Plugin" alt="BuddyPress-Media FFMPEG Converter Plugin" src="http://cdn.rtcamp.com/files/2012/09/ffmpeg-logo-240x184.png">
589
+ </a>
590
+ <h4><a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >BuddyPress-Media FFMPEG Add-on</a></h4>
591
+ <div class="product_desc">
592
+ <p>Add supports for more audio &amp; video formats using open-source <a href="https://github.com/rtCamp/media-node">media-node</a>.</p>
593
+ <p>Media node comes with automated setup script for Ubuntu/Debian.</p>
594
+ </div>
595
+ <div class="product_footer">
596
+ <span class="price alignleft"><span class="amount">$49</span></span>
597
+ <a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=13677"><?php _e('Buy Now', BP_MEDIA_TXT_DOMAIN); ?></a>
598
+ <a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-media" title="BuddyPress Media FFMPEG Add-on">Live Demo</a>
599
+ </div><!-- .product_footer -->
600
+ </li>
601
+
602
+ </ul><!-- .products -->
603
+ </div><!-- .addon-list -->
604
+
605
+ <?php }
606
+
607
+ function support() {
608
+ global $bp_media;
609
+ ?>
610
+
611
+ <div class="bp-media-support">
612
+ <h2><?php _e('Need Help/Support?', BP_MEDIA_TXT_DOMAIN); ?></h2>
613
+ <ul class="support_list">
614
+ <li><a href="http://rtcamp.com/buddypress-media/faq/" title="<?php _e('Read FAQ', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Read FAQ', BP_MEDIA_TXT_DOMAIN); ?></a> </li>
615
+ <li><a href="<?php $bp_media->support_url; ?>" title="<?php _e('Free Support Forum', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Free Support Forum', BP_MEDIA_TXT_DOMAIN); ?></a></li>
616
+ <li><a href="https://github.com/rtCamp/buddypress-media/issues/" title="<?php _e('Github Issue Tracker', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Github Issue Tracker', BP_MEDIA_TXT_DOMAIN); ?> </a> </li>
617
+ </ul>
618
+ <br/>
619
+
620
+ <h2><?php _e('Hire Us!', BP_MEDIA_TXT_DOMAIN); ?></h2>
621
+ <h4><a href="http://rtcamp.com/contact/?purpose=hire"><?php _e('We are available for customisation and premium support. Get on touch with us. :-)', BP_MEDIA_TXT_DOMAIN); ?></a></h4>
622
+ <br/>
623
+ </div>
624
+
625
+ <?php
626
+ }
627
+
628
+ function handle_request_type() {
629
+ $request_type = $_REQUEST['request_type'];
630
+ BPMediaUtils::bp_media_bug_report_form($request_type);
631
+ die();
632
+ }
633
+
634
+ function cancel_request() {
635
+ ?>
636
+ <div class="postbox ">
637
+ <div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span><?php _e('BuddyPress Media Support', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
638
+ <div class="inside"><?php $this->support(); ?></div>
639
+ </div>
640
+ <div class="postbox ">
641
+ <div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span><?php _e('Submit a request form', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
642
+ <div class="inside"><?php $this->send_request(); ?></div>
643
+ </div><?php
644
+ die();
645
+ }
646
+
647
+ function send_request() {
648
+ ?>
649
+ <div id="support-form" class="bp-media-form">
650
+ <ul>
651
+ <li>
652
+ <label class="bp-media-label" for="bp-media-request"><?php _e('Request type:', BP_MEDIA_TXT_DOMAIN); ?></label>
653
+ <select class="bp-media-select" id="request_type_select">
654
+ <option value=""><?php _e('-- Choose Type --', BP_MEDIA_TXT_DOMAIN); ?></option>
655
+ <option value="premium_support"><?php _e('Premium Support', BP_MEDIA_TXT_DOMAIN); ?></option>
656
+ <option value="new_feature"><?php _e('Suggest a New Feature', BP_MEDIA_TXT_DOMAIN); ?></option>
657
+ <option value="bug_report"><?php _e('Submit a Bug Report', BP_MEDIA_TXT_DOMAIN); ?></option>
658
+ </select>
659
+ </li>
660
+ </ul>
661
+ </div>
662
+ <?php
663
+ }
664
+
665
+ /**
666
+ * Default BuddyPress Media admin sidebar with metabox styling
667
+ *
668
+ * @since BuddyPress Media 2.0
669
+ */
670
+ function default_admin_sidebar() {
671
+ global $bp_media;
672
+ ?>
673
+
674
+ <div class="rtmetabox postbox" id="branding">
675
+ <div class="inside">
676
+ <a href="http://rtcamp.com" title="Empowering The Web With WordPress" id="logo"><img src="<?php echo plugins_url('/img/rtcamp-logo.png', __FILE__); ?>" alt="rtCamp" /></a>
677
+ <ul id="social">
678
+ <li><a href="<?php printf('%s', 'http://www.facebook.com/rtCamp.solutions/'); ?>" title="<?php _e('Become a fan on Facebook', BP_MEDIA_TXT_DOMAIN); ?>" class="bp-media-facebook bp-media-social"><?php _e('Facebook', BP_MEDIA_TXT_DOMAIN); ?></a></li>
679
+ <li><a href="<?php printf('%s', 'https://twitter.com/rtcamp/'); ?>" title="<?php _e('Follow us on Twitter', BP_MEDIA_TXT_DOMAIN); ?>" class="bp-media-twitter bp-media-social"><?php _e('Twitter', BP_MEDIA_TXT_DOMAIN); ?></a></li>
680
+ <li><a href="<?php printf('%s', 'http://feeds.feedburner.com/rtcamp/'); ?>" title="<?php _e('Subscribe to our feeds', BP_MEDIA_TXT_DOMAIN); ?>" class="bp-media-rss bp-media-social"><?php _e('RSS Feed', BP_MEDIA_TXT_DOMAIN); ?></a></li>
681
+ </ul>
682
+ </div>
683
+ </div>
684
+
685
+ <div class="rtmetabox postbox" id="support">
686
+
687
+ <h3 class="hndle"><span><?php _e('Need Help?', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
688
+ <div class="inside"><p><?php printf(__(' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
689
+ <a href="%s">Hire us!</a> To get professional customisation/setup service.', BP_MEDIA_TXT_DOMAIN), $bp_media->support_url, 'http://rtcamp.com/buddypress-media/hire/'); ?>.</p></div>
690
+ </div>
691
+
692
+ <div class="rtmetabox postbox" id="donate">
693
+
694
+ <h3 class="hndle"><span><?php _e('Donate', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
695
+ <span><a href="http://rtcamp.com/donate/" title="Help the development keep going."><img class="bp-media-donation-image" src ="<?php echo plugins_url('/img/donate.gif', __FILE__); ?>" /></a></span>
696
+ <div class="inside"><p><?php printf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', BP_MEDIA_TXT_DOMAIN)); ?>.</p></div>
697
+ </div>
698
+
699
+ <div class="rtmetabox postbox" id="bp-media-premium-addons">
700
+
701
+ <h3 class="hndle"><span><?php _e('Premium Addons', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
702
+ <div class="inside">
703
+ <ul>
704
+ <li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress Media Kaltura">BPM-Kaltura</a> - add support for Kaltura.com/Kaltura-CE based video conversion support</li>
705
+ <li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="BuddyPress Media FFMPEG">BPM-FFMPEG</a> - add FFMEG-based audio/video conversion support</li>
706
+ </ul>
707
+ <h4><?php printf(__('Are you a developer?', BP_MEDIA_TXT_DOMAIN)) ?></h4>
708
+ <p><?php printf(__('If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href="%s">More info!</a>', BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/contact/') ?></p></h4>
709
+ </div>
710
+ </div>
711
+
712
+ <div class="rtmetabox postbox" id="bp_media_latest_news">
713
+
714
+ <h3 class="hndle"><span><?php _e('Latest News', BP_MEDIA_TXT_DOMAIN); ?></span></h3>
715
+ <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
716
+ </div><?php
717
+ }
718
+
719
+ /**
720
+ * Enqueues the scripts and stylesheets needed for the BuddyPress Media's options page
721
+ */
722
+ function admin_enqueue() {
723
+ $current_screen = get_current_screen();
724
+ $admin_js = trailingslashit(site_url()) . '?bp_media_get_feeds=1';
725
+ wp_enqueue_script('bp-media-js', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
726
+ wp_localize_script('bp-media-js', 'bp_media_news_url', $admin_js);
727
+ wp_enqueue_style('bp-media-admin-style', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
728
+ }
729
+
730
+ /**
731
+ * Adds a tab for Media settings in the BuddyPress settings page
732
+ */
733
+ function admin_tab() {
734
+
735
+ if (current_user_can('manage_options')) {
736
+ $tabs_html = '';
737
+ $idle_class = 'nav-tab';
738
+ $active_class = 'nav-tab nav-tab-active';
739
+ $tabs = array();
740
+
741
+ // Check to see which tab we are on
742
+ $tab = BPMediaAdmin::get_current_tab();
743
+ /* BuddyPress Media */
744
+ $tabs[] = array(
745
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
746
+ 'title' => __('Buddypress Media', BP_MEDIA_TXT_DOMAIN),
747
+ 'name' => __('Buddypress Media', BP_MEDIA_TXT_DOMAIN),
748
+ 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
749
+ );
750
+
751
+ foreach ($tabs as $tab) {
752
+ $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
753
+ }
754
+ echo $tabs_html;
755
+ }
756
+ }
757
+
758
+ function get_server_info() {
759
+ global $wp_version, $wp_db_version, $wpdb;
760
+
761
+ $wordpress_plugins = get_plugins();
762
+ $wordpress_plugins_active = array();
763
+
764
+ foreach ($wordpress_plugins as $wordpress_plugin_file => $wordpress_plugin) {
765
+
766
+ if (is_plugin_active($wordpress_plugin_file)) {
767
+
768
+ $plugin_info['plugin_name'] = $wordpress_plugin['Name'];
769
+ $plugin_info['PluginURI'] = $wordpress_plugin['PluginURI'];
770
+ $plugin_info['Version'] = $wordpress_plugin['Version'];
771
+ $plugin_info['AuthorURI'] = $wordpress_plugin['AuthorURI'];
772
+ $wordpress_plugins_active[$wordpress_plugin_file] = $plugin_info;
773
+ }
774
+ }
775
+ $theme_info = wp_get_theme();
776
+ $theme_data = array();
777
+ $theme_data['Name'] = $theme_info->Name;
778
+ $theme_data['ThemeURI'] = $theme_info->ThemeURI;
779
+ $theme_data['Description'] = $theme_info->Description;
780
+ $theme_data['AuthorURI'] = $theme_info->AuthorURI;
781
+ $theme_data['Version'] = $theme_info->Version;
782
+
783
+ $mysql_version = $wpdb->get_var('SELECT VERSION()');
784
+
785
+ $server_info = array(
786
+ 'Wordpress' => array(
787
+ 'version' => $wp_version,
788
+ 'db_version' => $wp_db_version,
789
+ 'abspath' => ABSPATH,
790
+ 'home' => get_option('home'),
791
+ 'siteurl' => get_option('siteurl'),
792
+ 'email' => get_option('admin_email'),
793
+ 'upload_info' => @wp_upload_dir(),
794
+ ),
795
+ 'Theme' => $theme_data,
796
+ 'Plugins' => $wordpress_plugins_active,
797
+ 'Mysql' => array(
798
+ 'version' => $mysql_version
799
+ )
800
+ );
801
+
802
+ return $server_info;
803
+ }
804
+
805
+ }
806
+ ?>
includes/lib/bootstrap.php → app/main/includes/bp-media-upload-handler.php RENAMED
@@ -1,24 +1,18 @@
1
  <?php
2
- /**
3
- * Bootstrap file for getting the ABSPATH constant to wp-load.php
4
- * This is requried when a plugin requires access not via the admin screen.
5
- *
6
- * If the wp-load.php file is not found, then an error will be displayed
7
- *
8
- * @package PDF Converter
9
- * @since Version 0.0
10
- */
11
-
12
  /** Define the server path to the file wp-config here, if you placed WP-CONTENT outside the classic file structure */
13
 
14
- $path = ''; // It should be end with a trailing slash
15
 
16
  /** That's all, stop editing from here **/
17
 
18
  if ( !defined('WP_LOAD_PATH') ) {
19
 
20
  /** classic root path if wp-content and plugins is below wp-config.php */
21
- $classic_root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/' ;
 
 
22
  if (file_exists( $classic_root . 'wp-load.php') )
23
  define( 'WP_LOAD_PATH', $classic_root);
24
  else
@@ -32,4 +26,11 @@ if ( !defined('WP_LOAD_PATH') ) {
32
  require_once( WP_LOAD_PATH . 'wp-load.php');
33
 
34
  //require_once( WP_LOAD_PATH . 'wp-admin/admin.php');
 
 
 
 
 
 
 
35
  ?>
1
  <?php
2
+ ignore_user_abort(true);
3
+
 
 
 
 
 
 
 
 
4
  /** Define the server path to the file wp-config here, if you placed WP-CONTENT outside the classic file structure */
5
 
6
+ $path = '/'; // It should be end with a trailing slash
7
 
8
  /** That's all, stop editing from here **/
9
 
10
  if ( !defined('WP_LOAD_PATH') ) {
11
 
12
  /** classic root path if wp-content and plugins is below wp-config.php */
13
+ $classic_root = dirname(dirname(dirname(dirname(dirname(dirname(dirname( __FILE__ ))))))).'/';
14
+ echo $classic_root;
15
+ //$classic_root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/' ;
16
  if (file_exists( $classic_root . 'wp-load.php') )
17
  define( 'WP_LOAD_PATH', $classic_root);
18
  else
26
  require_once( WP_LOAD_PATH . 'wp-load.php');
27
 
28
  //require_once( WP_LOAD_PATH . 'wp-admin/admin.php');
29
+
30
+ // Check for rights
31
+ if ( !is_user_logged_in() )
32
+ wp_die(__("You are not allowed to be here"));
33
+
34
+ BPMediaActions::handle_uploads();
35
+
36
  ?>
includes/bp-media-class-album.php → app/main/profile/BPMediaAlbum.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class BP_Media_Album{
4
  private $id,
5
  $name,
6
  $description,
@@ -17,7 +17,7 @@ class BP_Media_Album{
17
  *
18
  * @param mixed $album_id optional Album ID of the element to be initialized if not defined, returns an empty element.
19
  *
20
- * @since BP Media 2.2
21
  */
22
  function __construct($album_id = '') {
23
  if (!$album_id == '') {
@@ -30,7 +30,7 @@ class BP_Media_Album{
30
  *
31
  * @param mixed $album_id Album ID of the element to be initialized. Can be the ID or the object of the Album
32
  *
33
- * @since BP Media 2.2
34
  */
35
  function init($album_id){
36
  if (is_object($album_id)) {
@@ -39,7 +39,7 @@ class BP_Media_Album{
39
  $album = &get_post($album_id);
40
  }
41
  if (empty($album->ID))
42
- throw new Exception(__('Sorry, the requested album does not exist.', 'bp-media'));
43
  $this->id = $album->ID;
44
  $this->description = $album->post_content;
45
  $this->name = $album->post_title;
@@ -89,7 +89,7 @@ class BP_Media_Album{
89
  $this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
90
  }
91
  }else{
92
- $this->thumbnail = '<img src = '.plugins_url('img/image_thumb.png', __FILE__) .' />';
93
  }
94
  $this->media_entries = get_children(array(
95
  'post_parent' => $this->id,
@@ -104,7 +104,7 @@ class BP_Media_Album{
104
  * @param string $author_id Optional The author id, defaults to zero in which case takes the logged in user id.
105
  * @param string $group_id Optional The group id to which the album belongs, defaults to 0 meaning its not attached with a group.
106
  *
107
- * @since BP Media 2.2
108
  */
109
  function add_album($title,$author_id = 0, $group_id = 0){
110
  do_action('bp_media_before_add_album');
@@ -116,7 +116,7 @@ class BP_Media_Album{
116
  'post_type' => 'bp_media_album',
117
  'post_author'=> $author_id
118
  );
119
- bp_media_init_count($author_id);
120
  global $bp_media_count;
121
  $album_id = wp_insert_post($post_vars);
122
  if($group_id){
@@ -135,18 +135,18 @@ class BP_Media_Album{
135
  /**
136
  * Deletes the album and all associated attachments
137
  *
138
- * @since BP Media 2.2
139
  */
140
  function delete_album(){
141
  do_action('bp_media_before_delete_album', $this);
142
  foreach($this->media_entries as $entry){
143
- bp_media_delete_media_handler($entry->ID);
144
  //do_action('bp_media_before_delete_media',$entry->ID); //Not working for some reason so called the required function directly
145
  wp_delete_attachment($entry->ID,true);
146
  do_action('bp_media_after_delete_media',$entry->ID);
147
  }
148
  $author_id = $this->owner;
149
- bp_media_init_count($author_id);
150
  wp_delete_post($this->id,true);
151
  global $bp_media_count;
152
  $bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) - 1;
@@ -177,18 +177,19 @@ class BP_Media_Album{
177
  }
178
 
179
  function get_album_gallery_content(){
 
180
  ?><li>
181
- <a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
182
  <?php echo $this->thumbnail; ?>
183
  </a>
184
- <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name;?></a><?php echo ' ('.count($this->media_entries).')'; ?></h3>
185
  </li><?php
186
  }
187
 
188
  /**
189
  * Returns the attachments linked with the albume
190
  *
191
- * @since BP Media 2.2
192
  */
193
  function get_entries(){
194
  return $this->media_entries;
@@ -197,7 +198,7 @@ class BP_Media_Album{
197
  /**
198
  * Returns the title of the album
199
  *
200
- * @since BP Media 2.2
201
  */
202
  function get_title(){
203
  return $this->name;
@@ -206,7 +207,7 @@ class BP_Media_Album{
206
  /**
207
  * Echoes the title of the album
208
  *
209
- * @since BP Media 2.2
210
  */
211
  function the_title(){
212
  echo $this->name;
@@ -215,7 +216,7 @@ class BP_Media_Album{
215
  /**
216
  * Returns the id of the album
217
  *
218
- * @since BP Media 2.2
219
  */
220
  function get_id(){
221
  return $this->id;
@@ -224,7 +225,7 @@ class BP_Media_Album{
224
  /**
225
  * Returns the url of the album
226
  *
227
- * @since BP Media 2.2
228
  */
229
  function get_url(){
230
  return $this->url;
@@ -233,7 +234,7 @@ class BP_Media_Album{
233
  /**
234
  * Returns the owner's id
235
  *
236
- * @since BP Media 2.2
237
  */
238
  function get_owner(){
239
  return $this->owner;
1
  <?php
2
 
3
+ class BPMediaAlbum{
4
  private $id,
5
  $name,
6
  $description,
17
  *
18
  * @param mixed $album_id optional Album ID of the element to be initialized if not defined, returns an empty element.
19
  *
20
+ * @since BuddyPress Media 2.2
21
  */
22
  function __construct($album_id = '') {
23
  if (!$album_id == '') {
30
  *
31
  * @param mixed $album_id Album ID of the element to be initialized. Can be the ID or the object of the Album
32
  *
33
+ * @since BuddyPress Media 2.2
34
  */
35
  function init($album_id){
36
  if (is_object($album_id)) {
39
  $album = &get_post($album_id);
40
  }
41
  if (empty($album->ID))
42
+ throw new Exception(__('Sorry, the requested album does not exist.', BP_MEDIA_TXT_DOMAIN));
43
  $this->id = $album->ID;
44
  $this->description = $album->post_content;
45
  $this->name = $album->post_title;
89
  $this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
90
  }
91
  }else{
92
+ $this->thumbnail = '<img src ="'.BP_MEDIA_URL.'app/assets/img/image_thumb.png">';
93
  }
94
  $this->media_entries = get_children(array(
95
  'post_parent' => $this->id,
104
  * @param string $author_id Optional The author id, defaults to zero in which case takes the logged in user id.
105
  * @param string $group_id Optional The group id to which the album belongs, defaults to 0 meaning its not attached with a group.
106
  *
107
+ * @since BuddyPress Media 2.2
108
  */
109
  function add_album($title,$author_id = 0, $group_id = 0){
110
  do_action('bp_media_before_add_album');
116
  'post_type' => 'bp_media_album',
117
  'post_author'=> $author_id
118
  );
119
+ BPMediaActions::init_count($author_id);
120
  global $bp_media_count;
121
  $album_id = wp_insert_post($post_vars);
122
  if($group_id){
135
  /**
136
  * Deletes the album and all associated attachments
137
  *
138
+ * @since BuddyPress Media 2.2
139
  */
140
  function delete_album(){
141
  do_action('bp_media_before_delete_album', $this);
142
  foreach($this->media_entries as $entry){
143
+ BPMediaActions::delete_media_handler($entry->ID);
144
  //do_action('bp_media_before_delete_media',$entry->ID); //Not working for some reason so called the required function directly
145
  wp_delete_attachment($entry->ID,true);
146
  do_action('bp_media_after_delete_media',$entry->ID);
147
  }
148
  $author_id = $this->owner;
149
+ BPMediaActions::init_count($author_id);
150
  wp_delete_post($this->id,true);
151
  global $bp_media_count;
152
  $bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) - 1;
177
  }
178
 
179
  function get_album_gallery_content(){
180
+ global $bp_media
181
  ?><li>
182
+ <a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>">
183
  <?php echo $this->thumbnail; ?>
184
  </a>
185
+ <h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>"><?php echo $this->name;?></a><?php echo ' ('.count($this->media_entries).')'; ?></h3>
186
  </li><?php
187
  }
188
 
189
  /**
190
  * Returns the attachments linked with the albume
191
  *
192
+ * @since BuddyPress Media 2.2
193
  */
194
  function get_entries(){
195
  return $this->media_entries;
198
  /**
199
  * Returns the title of the album
200
  *
201
+ * @since BuddyPress Media 2.2
202
  */
203
  function get_title(){
204
  return $this->name;
207
  /**
208
  * Echoes the title of the album
209
  *
210
+ * @since BuddyPress Media 2.2
211
  */
212
  function the_title(){
213
  echo $this->name;
216
  /**
217
  * Returns the id of the album
218
  *
219
+ * @since BuddyPress Media 2.2
220
  */
221
  function get_id(){
222
  return $this->id;
225
  /**
226
  * Returns the url of the album
227
  *
228
+ * @since BuddyPress Media 2.2
229
  */
230
  function get_url(){
231
  return $this->url;
234
  /**
235
  * Returns the owner's id
236
  *
237
+ * @since BuddyPress Media 2.2
238
  */
239
  function get_owner(){
240
  return $this->owner;
app/main/profile/BPMediaAlbumScreen.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 BPMediaAlbumScreen
10
+ *
11
+ * @author saurabh
12
+ */
13
+ class BPMediaAlbumScreen extends BPMediaScreen {
14
+
15
+ public function __construct( $media_type, $slug ) {
16
+ parent::__construct( $media_type, $slug );
17
+ }
18
+
19
+ function screen() {
20
+ global $bp;
21
+ if ( isset( $bp->action_variables[ 0 ] ) ) {
22
+ switch ( $bp->action_variables[ 0 ] ) {
23
+ case BP_MEDIA_ALBUMS_EDIT_SLUG :
24
+ $this->edit_screen();
25
+ break;
26
+ case BP_MEDIA_ALBUMS_ENTRY_SLUG:
27
+ $this->entry_screen();
28
+ $this->template_actions( 'entry_screen' );
29
+ break;
30
+ case BP_MEDIA_DELETE_SLUG :
31
+ if ( ! isset( $bp->action_variables[ 1 ] ) ) {
32
+ $this->page_not_exist();
33
+ }
34
+ $this->entry_delete();
35
+ break;
36
+ default:
37
+ $this->set_query();
38
+ $this->template_actions( 'screen' );
39
+ }
40
+ } else {
41
+ $this->set_query();
42
+ $this->template_actions( 'screen' );
43
+ }
44
+ $this->template->loader();
45
+ }
46
+
47
+ function screen_content() {
48
+ global $bp_media_albums_query;
49
+
50
+ $this->hook_before();
51
+ if ( $bp_media_albums_query && $bp_media_albums_query->have_posts() ):
52
+ echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
53
+ while ( $bp_media_albums_query->have_posts() ) : $bp_media_albums_query->the_post();
54
+ $this->template->the_album_content();
55
+ endwhile;
56
+ echo '</ul>';
57
+ $this->template->show_more();
58
+ else:
59
+ BPMediaFunction::show_formatted_error_message( sprintf( __( 'Sorry, no %s were found.', BP_MEDIA_TXT_DOMAIN ), $this->slug ), 'info' );
60
+ endif;
61
+ $this->hook_after();
62
+ }
63
+
64
+ function entry_screen() {
65
+ global $bp, $bp_media_current_album;
66
+ if ( ! $bp->action_variables[ 0 ] == BP_MEDIA_ALBUMS_ENTRY_SLUG )
67
+ return false;
68
+ try {
69
+ $bp_media_current_album = new BPMediaAlbum( $bp->action_variables[ 1 ] );
70
+ } catch ( Exception $e ) {
71
+ /* Send the values to the cookie for page reload display */
72
+ @setcookie( 'bp-message', $_COOKIE[ 'bp-message' ], time() + 60 * 60 * 24, COOKIEPATH );
73
+ @setcookie( 'bp-message-type', $_COOKIE[ 'bp-message-type' ], time() + 60 * 60 * 24, COOKIEPATH );
74
+ $this->template->redirect($this->media_const);
75
+ exit;
76
+ }
77
+ }
78
+
79
+ function entry_screen_content() {
80
+ global $bp, $bp_media_current_album, $bp_media_query;
81
+ if ( ! $bp->action_variables[ 0 ] == BP_MEDIA_ALBUMS_ENTRY_SLUG )
82
+ return false;
83
+ echo '<div class="bp_media_title">' . $bp_media_current_album->get_title() . '</div>';
84
+ $this->inner_query( $bp_media_current_album->get_id() );
85
+ $this->hook_before();
86
+ if ( $bp_media_current_album && $bp_media_query->have_posts() ):
87
+ echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
88
+ while ( $bp_media_query->have_posts() ) : $bp_media_query->the_post();
89
+ $this->template->the_content();
90
+ endwhile;
91
+ echo '</ul>';
92
+ $this->template->show_more();
93
+ else:
94
+ BPMediaFunction::show_formatted_error_message( __( 'Sorry, no media items were found in this album.', BP_MEDIA_TXT_DOMAIN ), 'info' );
95
+ endif;
96
+ $this->hook_after();
97
+ }
98
+
99
+ function set_query() {
100
+ global $bp, $bp_media_albums_query;
101
+ if ( isset( $bp->action_variables ) && is_array( $bp->action_variables ) && isset( $bp->action_variables[ 0 ] ) && $bp->action_variables[ 0 ] == 'page' && isset( $bp->action_variables[ 1 ] ) && is_numeric( $bp->action_variables[ 1 ] ) ) {
102
+ $paged = $bp->action_variables[ 1 ];
103
+ } else {
104
+ $paged = 1;
105
+ }
106
+ if ( $bp->current_action == BP_MEDIA_ALBUMS_SLUG ) {
107
+ $args = array(
108
+ 'post_type' => 'bp_media_album',
109
+ 'author' => $bp->displayed_user->id,
110
+ 'paged' => $paged,
111
+ 'meta_key' => 'bp-media-key',
112
+ 'meta_value' => $bp->displayed_user->id,
113
+ 'meta_compare' => '='
114
+ );
115
+ $bp_media_albums_query = new WP_Query( $args );
116
+ }
117
+ }
118
+
119
+
120
+ function template_actions( $action ) {
121
+ add_action( 'bp_template_content', array( $this, $action . '_content' ) );
122
+ }
123
+
124
+ function inner_query( $album_id = 0 ) {
125
+ global $bp, $bp_media_query;
126
+ $paged = 0;
127
+ $action_variables = isset( $bp->canonical_stack[ 'action_variables' ] ) ? $bp->canonical_stack[ 'action_variables' ] : null;
128
+ if ( isset( $action_variables ) && is_array( $action_variables ) && isset( $action_variables[ 0 ] ) ) {
129
+ if ( $action_variables[ 0 ] == 'page' && isset( $action_variables[ 1 ] ) && is_numeric( $action_variables[ 1 ] ) )
130
+ $paged = $action_variables[ 1 ];
131
+ else if ( isset( $action_variables[ 1 ] ) && $action_variables[ 1 ] == 'page' && isset( $action_variables[ 2 ] ) && is_numeric( $action_variables[ 2 ] ) )
132
+ $paged = $action_variables[ 2 ];
133
+ }
134
+ if ( ! $paged )
135
+ $paged = 1;
136
+ $args = array(
137
+ 'post_type' => 'attachment',
138
+ 'post_status' => 'any',
139
+ 'post_parent' => $album_id,
140
+ 'paged' => $paged
141
+ );
142
+ $bp_media_query = new WP_Query( $args );
143
+ }
144
+
145
+ }
146
+
147
+ ?>
app/main/profile/BPMediaScreen.php ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This protects from direct access
4
+ */
5
+ if ( ! defined( 'ABSPATH' ) )
6
+ exit;
7
+
8
+ /**
9
+ * Base class for creating BuddyPress Media Tabs on the user profile
10
+ *
11
+ * @author Saurabh Shukla <saurabh.sahukla@rtcamp.com>
12
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
13
+ */
14
+ if ( ! class_exists( 'BPMediaScreen' ) ) {
15
+
16
+ class BPMediaScreen {
17
+
18
+ /**
19
+ *
20
+ * @var string Slug to be used for the media type/screen
21
+ */
22
+ public $slug = NULL;
23
+
24
+ /**
25
+ *
26
+ * @var string Media type for use in the class
27
+ */
28
+ public $media_type = '';
29
+
30
+ /**
31
+ *
32
+ * @var string Media type string used to build constants
33
+ */
34
+ public $media_const = '';
35
+
36
+ /**
37
+ *
38
+ * @var string Plural media type string
39
+ */
40
+ public $medias_type = '';
41
+
42
+ public $template='';
43
+
44
+ /**
45
+ * Populates all the variables of the class, $media_type, $media_const, $medias_type
46
+ *
47
+ * @param string $media_type The media type for which the screen is going to be created
48
+ * @param string $slug The slug to use for the media type
49
+ */
50
+ public function __construct( $media_type, $slug ) {
51
+ $this->slug = $slug;
52
+ $this->media_constant( $media_type );
53
+ $this->template = new BPMediaTemplate();
54
+ }
55
+
56
+ /**
57
+ * Populates variable $media_type
58
+ * @param string $media_type
59
+ */
60
+ private function media( $media_type ) {
61
+ $this->media_type = $media_type;
62
+ }
63
+
64
+ /**
65
+ * Creates plural
66
+ * @param type $media_type
67
+ */
68
+ private function medias( $media_type ) {
69
+ $this->media( $media_type );
70
+ $media = strtolower( $this->media_type );
71
+ if ( $media != 'audio' ) {
72
+ $media .= 's';
73
+ }
74
+ $this->medias_type = $media;
75
+ }
76
+
77
+ /**
78
+ *
79
+ * @param type $media_type
80
+ */
81
+ private function media_constant( $media_type ) {
82
+ $this->medias( $media_type );
83
+ $this->media_const = strtoupper( $this->medias_type );
84
+ }
85
+
86
+ /**
87
+ *
88
+ */
89
+ public function hook_before() {
90
+ do_action( 'bp_media_before_content' );
91
+ do_action( 'bp_media_before_' . $this->slug );
92
+ }
93
+
94
+ /**
95
+ *
96
+ */
97
+ public function hook_after() {
98
+ do_action( 'bp_media_after_' . $this->slug );
99
+ do_action( 'bp_media_after_content' );
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @global type $bp_media
105
+ */
106
+ private function page_not_exist() {
107
+ @setcookie( 'bp-message', __( 'The requested url does not exist', BP_MEDIA_TXT_DOMAIN ), time() + 60 * 60 * 24, COOKIEPATH );
108
+ @setcookie( 'bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH );
109
+ $this->template->redirect($this->media_const);
110
+ exit;
111
+ }
112
+
113
+ /**
114
+ *
115
+ * @global type $bp_media
116
+ */
117
+ private function screen_title() {
118
+ printf( __( '%s List Page', BP_MEDIA_TXT_DOMAIN ), $this->slug );
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @global type $bp
124
+ */
125
+ public function screen() {
126
+ $editslug = 'BP_MEDIA_' . $this->media_const . '_EDIT_SLUG';
127
+ $entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
128
+
129
+ global $bp;
130
+
131
+ remove_filter( 'bp_activity_get_user_join_filter', 'activity_query_filter', 10 );
132
+ if ( isset( $bp->action_variables[ 0 ] ) ) {
133
+ switch ( $bp->action_variables[ 0 ] ) {
134
+ case constant( $editslug ) :
135
+ $this->edit_screen();
136
+ break;
137
+ case constant( $entryslug ) :
138
+ $this->entry_screen();
139
+ break;
140
+ case BP_MEDIA_DELETE_SLUG :
141
+ if ( ! isset( $bp->action_variables[ 1 ] ) ) {
142
+ $this->page_not_exist();
143
+ }
144
+ $this->entry_delete();
145
+ break;
146
+ default:
147
+ $this->set_query();
148
+ add_action( 'bp_template_content', array( $this, 'screen_content' ) );
149
+ }
150
+ } else {
151
+ $this->set_query();
152
+ add_action( 'bp_template_content', array( $this, 'screen_content' ) );
153
+ }
154
+ $this->template->loader();
155
+ }
156
+
157
+ /**
158
+ *
159
+ * @global type $bp_media
160
+ * @global type $bp_media_query
161
+ * @global type $bp_media_albums_query
162
+ */
163
+ function screen_content() {
164
+ global $bp_media_query, $bp_media_albums_query;
165
+ $this->set_query();
166
+
167
+ $this->hook_before();
168
+ if ( $bp_media_query && $bp_media_query->have_posts() ):
169
+ echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
170
+ while ( $bp_media_query->have_posts() ) : $bp_media_query->the_post();
171
+ $this->template->the_content();
172
+ endwhile;
173
+ echo '</ul>';
174
+ $this->template->show_more();
175
+ else:
176
+ BPMediaFunction::show_formatted_error_message( sprintf( __( 'Sorry, no %s were found.', BP_MEDIA_TXT_DOMAIN ), $this->slug ), 'info' );
177
+ endif;
178
+ $this->hook_after();
179
+ }
180
+
181
+ /**
182
+ *
183
+ * @global type $bp
184
+ * @global BPMediaHostWordpress $bp_media_current_entry
185
+ * @return boolean
186
+ */
187
+ function entry_screen() {
188
+
189
+ global $bp, $bp_media_current_entry;
190
+ $entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
191
+ if ( ! $bp->action_variables[ 0 ] == constant( $entryslug ) )
192
+ return false;
193
+ try {
194
+
195
+ $bp_media_current_entry = new BPMediaHostWordpress( $bp->action_variables[ 1 ] );
196
+ } catch ( Exception $e ) {
197
+ /* Send the values to the cookie for page reload display */
198
+ @setcookie( 'bp-message', $_COOKIE[ 'bp-message' ], time() + 60 * 60 * 24, COOKIEPATH );
199
+ @setcookie( 'bp-message-type', $_COOKIE[ 'bp-message-type' ], time() + 60 * 60 * 24, COOKIEPATH );
200
+ $this->template->redirect($this->media_const);
201
+ exit;
202
+ }
203
+
204
+ $this->template_actions( 'entry_screen' );
205
+ $this->template->loader();
206
+ }
207
+
208
+ /**
209
+ *
210
+ * @global BPMediaHostWordpress $bp_media_current_entry
211
+ */
212
+ function entry_screen_title() {
213
+
214
+ global $bp_media_current_entry;
215
+ /** @var $bp_media_current_entry BPMediaHostWordpress */
216
+ if ( is_object( $bp_media_current_entry ) )
217
+ echo $bp_media_current_entry->get_media_single_title();
218
+ }
219
+
220
+ /**
221
+ *
222
+ * @global type $bp
223
+ * @global BPMediaHostWordpress $bp_media_current_entry
224
+ * @return boolean
225
+ */
226
+ function entry_screen_content() {
227
+ global $bp, $bp_media_current_entry;
228
+ $entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
229
+ $this->hook_before();
230
+ if ( ! $bp->action_variables[ 0 ] == constant( $entryslug ) )
231
+ return false;
232
+ echo '<div class="bp-media-single bp-media-image">';
233
+ echo $bp_media_current_entry->get_media_single_content();
234
+ echo $bp_media_current_entry->show_comment_form();
235
+ echo '</div>';
236
+ $this->hook_after();
237
+ }
238
+
239
+ /**
240
+ *
241
+ * @global BPMediaHostWordpress $bp_media_current_entry
242
+ * @global type $bp
243
+ */
244
+ function edit_screen() {
245
+ global $bp_media_current_entry, $bp;
246
+ if ( ! isset( $bp->action_variables[ 1 ] ) ) {
247
+ $this->page_not_exist();
248
+ }
249
+ //Creating global bp_media_current_entry for later use
250
+ try {
251
+ $bp_media_current_entry = new BPMediaHostWordpress( $bp->action_variables[ 1 ] );
252
+ } catch ( Exception $e ) {
253
+ /* Send the values to the cookie for page reload display */
254
+ @setcookie( 'bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH );
255
+ @setcookie( 'bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH );
256
+ $this->template->redirect($this->media_const);
257
+ exit;
258
+ }
259
+ BPMediaFunction::check_user();
260
+
261
+ //For saving the data if the form is submitted
262
+ if ( array_key_exists( 'bp_media_title', $_POST ) ) {
263
+ BPMediaFunction::update_media();
264
+ }
265
+ $this->template_actions( 'edit_screen' );
266
+ $this->template->loader();
267
+ }
268
+
269
+ /**
270
+ *
271
+ * @global type $bp_media
272
+ */
273
+ function edit_screen_title() {
274
+ printf( __( 'Edit %s', BP_MEDIA_TXT_DOMAIN ), $this->slug );
275
+ }
276
+
277
+ /**
278
+ *
279
+ * @global type $bp
280
+ * @global BPMediaHostWordpress $bp_media_current_entry
281
+ * @global type $bp_media_default_excerpts
282
+ * @global type $bp_media
283
+ */
284
+ function edit_screen_content() {
285
+ global $bp_media_current_entry, $bp_media_default_excerpts;
286
+ ?>
287
+ <form method="post" class="standard-form" id="bp-media-upload-form">
288
+ <label for="bp-media-upload-input-title">
289
+ <?php printf( __( '%s Title', BP_MEDIA_TXT_DOMAIN ), ucfirst( $this->media_type ) ); ?>
290
+ </label>
291
+ <input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input"
292
+ maxlength="<?php echo max( array( $bp_media_default_excerpts[ 'single_entry_title' ], $bp_media_default_excerpts[ 'activity_entry_title' ] ) ) ?>"
293
+ value="<?php echo $bp_media_current_entry->get_title(); ?>" />
294
+ <label for="bp-media-upload-input-description">
295
+ <?php printf( __( '%s Description', BP_MEDIA_TXT_DOMAIN ), ucfirst( $this->media_type ) ); ?>
296
+ </label>
297
+ <input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input"
298
+ maxlength="<?php echo max( array( $bp_media_default_excerpts[ 'single_entry_description' ], $bp_media_default_excerpts[ 'activity_entry_description' ] ) ) ?>"
299
+ value="<?php echo $bp_media_current_entry->get_content(); ?>" />
300
+ <div class="submit">
301
+ <input type="submit" class="auto" value="<?php _e( 'Update', BP_MEDIA_TXT_DOMAIN ); ?>" />
302
+ <a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="<?php _e( 'Back to Media File', BP_MEDIA_TXT_DOMAIN ); ?>">
303
+ <?php _e( 'Back to Media', BP_MEDIA_TXT_DOMAIN ); ?>
304
+ </a>
305
+ </div>
306
+ </form>
307
+ <?php
308
+ }
309
+
310
+ /**
311
+ *
312
+ * @global type $bp
313
+ * @global type $bp_media
314
+ * @global BPMediaHostWordpress $bp_media_current_entry
315
+ */
316
+ function entry_delete() {
317
+ global $bp;
318
+ if ( bp_loggedin_user_id() != bp_displayed_user_id() ) {
319
+ bp_core_no_access( array(
320
+ 'message' => __( 'You do not have access to this page.', BP_MEDIA_TXT_DOMAIN ),
321
+ 'root' => bp_displayed_user_domain(),
322
+ 'redirect' => false
323
+ ) );
324
+ exit;
325
+ }
326
+ if ( ! isset( $bp->action_variables[ 1 ] ) ) {
327
+ @setcookie( 'bp-message', __( 'The requested url does not exist', BP_MEDIA_TXT_DOMAIN ), time() + 60 * 60 * 24, COOKIEPATH );
328
+ @setcookie( 'bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH );
329
+ $this->template->redirect($this->media_const);
330
+ exit;
331
+ }
332
+ global $bp_media_current_entry;
333
+ try {
334
+ $bp_media_current_entry = new BPMediaHostWordpress( $bp->action_variables[ 1 ] );
335
+ } catch ( Exception $e ) {
336
+ /* Send the values to the cookie for page reload display */
337
+ @setcookie( 'bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH );
338
+ @setcookie( 'bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH );
339
+ $this->template->redirect($this->media_const);
340
+ exit;
341
+ }
342
+ $post_id = $bp_media_current_entry->get_id();
343
+ $activity_id = get_post_meta( $post_id, 'bp_media_child_activity', true );
344
+
345
+ bp_activity_delete_by_activity_id( $activity_id );
346
+ $bp_media_current_entry->delete_media();
347
+
348
+ @setcookie( 'bp-message', __( 'Media deleted successfully', BP_MEDIA_TXT_DOMAIN ), time() + 60 * 60 * 24, COOKIEPATH );
349
+ @setcookie( 'bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH );
350
+ $this->template->redirect($this->media_const);
351
+ exit;
352
+ }
353
+
354
+ /**
355
+ *
356
+ * @param type $action
357
+ */
358
+ function template_actions( $action ) {
359
+ add_action( 'bp_template_title', array( $this, $action . '_title' ) );
360
+ add_action( 'bp_template_content', array( $this, $action . '_content' ) );
361
+ }
362
+
363
+
364
+
365
+ /**
366
+ *
367
+ * @global type $bp
368
+ * @global type $bp_media_posts_per_page
369
+ * @global type $bp_media_query
370
+ */
371
+ public function set_query() {
372
+ global $bp, $bp_media_posts_per_page, $bp_media_query;
373
+ switch ( $bp->current_action ) {
374
+ case BP_MEDIA_IMAGES_SLUG:
375
+ $type = 'image';
376
+ break;
377
+ case BP_MEDIA_AUDIO_SLUG:
378
+ $type = 'audio';
379
+ break;
380
+ case BP_MEDIA_VIDEOS_SLUG:
381
+ $type = 'video';
382
+ break;
383
+ default :
384
+ $type = null;
385
+ }
386
+ if ( isset( $bp->action_variables ) && is_array( $bp->action_variables ) && isset( $bp->action_variables[ 0 ] ) && $bp->action_variables[ 0 ] == 'page' && isset( $bp->action_variables[ 1 ] ) && is_numeric( $bp->action_variables[ 1 ] ) ) {
387
+ $paged = $bp->action_variables[ 1 ];
388
+ } else {
389
+ $paged = 1;
390
+ }
391
+ if ( $type ) {
392
+ $args = array(
393
+ 'post_type' => 'attachment',
394
+ 'post_status' => 'any',
395
+ 'post_mime_type' => $type,
396
+ 'author' => $bp->displayed_user->id,
397
+ 'meta_key' => 'bp-media-key',
398
+ 'meta_value' => $bp->displayed_user->id,
399
+ 'meta_compare' => '=',
400
+ 'paged' => $paged,
401
+ 'posts_per_page' => $bp_media_posts_per_page
402
+ );
403
+
404
+ $bp_media_query = new WP_Query( $args );
405
+ }
406
+ }
407
+
408
+ }
409
+
410
+ }
411
+ ?>
app/main/profile/BPMediaTemplate.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+
7
+ /**
8
+ * Description of BPMediaTemplate
9
+ *
10
+ * @author saurabh
11
+ */
12
+ class BPMediaTemplate {
13
+
14
+ function upload_form_multiple() {
15
+ ?>
16
+ <div id="bp-media-album-prompt" title="Select Album">
17
+ <div class="bp-media-album-title">
18
+ <span><?php _e( 'Select Album', BP_MEDIA_TXT_DOMAIN ); ?></span>
19
+ <span id="bp-media-close"><?php _e( 'x', BP_MEDIA_TXT_DOMAIN ); ?></span>
20
+ </div>
21
+ <div class="bp-media-album-content">
22
+ <select id="bp-media-selected-album"><?php
23
+ if ( bp_is_current_component( 'groups' ) ) {
24
+ $albums = new WP_Query( array(
25
+ 'post_type' => 'bp_media_album',
26
+ 'posts_per_page' => -1,
27
+ 'meta_key' => 'bp-media-key',
28
+ 'meta_value' => -bp_get_current_group_id(),
29
+ 'meta_compare' => '='
30
+ ) );
31
+ } else {
32
+ $albums = new WP_Query( array(
33
+ 'post_type' => 'bp_media_album',
34
+ 'posts_per_page' => -1,
35
+ 'author' => get_current_user_id()
36
+ ) );
37
+ }
38
+ if ( isset( $albums->posts ) && is_array( $albums->posts ) && count( $albums->posts ) > 0 ) {
39
+ foreach ( $albums->posts as $album ) {
40
+ if ( $album->post_title == 'Wall Posts' )
41
+ echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
42
+ else
43
+ echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>';
44
+ };
45
+ }else {
46
+ $album = new BPMediaAlbum();
47
+ if ( bp_is_current_component( 'groups' ) ) {
48
+ $current_group = new BP_Groups_Group( bp_get_current_group_id() );
49
+ $album->add_album( 'Wall Posts', $current_group->creator_id, bp_get_current_group_id() );
50
+ } else {
51
+ $album->add_album( 'Wall Posts', bp_loggedin_user_id() );
52
+ }
53
+ echo '<option value="' . $album->get_id() . '" selected="selected">' . $album->get_title() . '</option>';
54
+ }
55
+ ?></select>
56
+ </div>
57
+ <div class="select-btn-div">
58
+ <input id="selected-btn" type="button" class="btn" value="Select" />
59
+ <input id="create-btn" type="button" class="btn" value="Create Album" />
60
+ <div style="clear: both;"></div>
61
+ </div>
62
+ </div>
63
+ <div id="bp-media-album-new" title="Create New Album">
64
+ <div class="bp-media-album-title">
65
+ <span><?php _e( 'Create Album', BP_MEDIA_TXT_DOMAIN ); ?></span>
66
+ <span id="bp-media-create-album-close"><?php _e( 'x', BP_MEDIA_TXT_DOMAIN ); ?></span>
67
+ </div>
68
+ <div class="bp-media-album-content">
69
+ <label for="bp_media_album_name"><?php _e( 'Album Name', BP_MEDIA_TXT_DOMAIN ); ?></label>
70
+ <input id="bp_media_album_name" type="text" name="bp_media_album_name" />
71
+ </div>
72
+ <div class="select-btn-div">
73
+ <input id="create-album" type="button" class="btn" value="Create" />
74
+ </div>
75
+ </div>
76
+ <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
77
+ <div id="drag-drop-area">
78
+ <div class="drag-drop-inside">
79
+ <p class="drag-drop-info"><?php _e( 'Drop files here', BP_MEDIA_TXT_DOMAIN ); ?></p>
80
+ <p><?php _e( ' or ', BP_MEDIA_TXT_DOMAIN ); ?></p>
81
+ <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="<?php _e( 'Select Files', BP_MEDIA_TXT_DOMAIN ); ?>" class="button" /></p>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <div id="bp-media-uploaded-files"></div>
86
+ <?php
87
+ }
88
+
89
+ function get_permalink( $id = 0 ) {
90
+ if ( is_object( $id ) )
91
+ $media = $id;
92
+ else
93
+ $media = &get_post( $id );
94
+ if ( empty( $media->ID ) )
95
+ return false;
96
+ if ( ! $media->post_type == 'bp_media' )
97
+ return false;
98
+ switch ( get_post_meta( $media->ID, 'bp_media_type', true ) ) {
99
+ case 'video' :
100
+ return trailingslashit( bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $media->ID );
101
+ break;
102
+ case 'audio' :
103
+ return trailingslashit( bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $media->ID );
104
+ break;
105
+ case 'image' :
106
+ return trailingslashit( bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $media->ID );
107
+ break;
108
+ default :
109
+ return false;
110
+ }
111
+ }
112
+
113
+ function the_permalink() {
114
+ echo apply_filters( 'the_permalink', array( $this, 'get_permalink' ) );
115
+ }
116
+
117
+ function the_content( $id = 0 ) {
118
+ if ( is_object( $id ) )
119
+ $media = $id;
120
+ else
121
+ $media = &get_post( $id );
122
+ if ( empty( $media->ID ) )
123
+ return false;
124
+ if ( $media->post_type != 'attachment' )
125
+ return false;
126
+ try {
127
+ $media = new BPMediaHostWordpress( $media->ID );
128
+ echo $media->get_media_gallery_content();
129
+ } catch ( Exception $e ) {
130
+ echo '';
131
+ }
132
+ }
133
+
134
+ function the_album_content( $id = 0 ) {
135
+ if ( is_object( $id ) )
136
+ $album = $id;
137
+ else
138
+ $album = &get_post( $id );
139
+ if ( empty( $album->ID ) )
140
+ return false;
141
+ if ( ! $album->post_type == 'bp_media_album' )
142
+ return false;
143
+ try {
144
+ $album = new BPMediaAlbum( $album->ID );
145
+ echo $album->get_album_gallery_content();
146
+ } catch ( Exception $e ) {
147
+ echo '';
148
+ }
149
+ }
150
+
151
+ function show_more( $type = 'media' ) {
152
+ $showmore = false;
153
+ switch ( $type ) {
154
+ case 'media':
155
+ global $bp_media_query;
156
+ //found_posts
157
+ if ( isset( $bp_media_query->found_posts ) && $bp_media_query->found_posts > 10 )
158
+ $showmore = true;
159
+ break;
160
+ case 'albums':
161
+ global $bp_media_albums_query;
162
+ if ( isset( $bp_media_query->found_posts ) && $bp_media_query->found_posts > 10 )
163
+ $showmore = true;
164
+ break;
165
+ }
166
+ if ( $showmore ) {
167
+ echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">Show More</a></div>';
168
+ }
169
+ }
170
+
171
+ /**
172
+ *
173
+ */
174
+ function redirect( $mediaconst ) {
175
+ bp_core_redirect( trailingslashit( bp_displayed_user_domain() . constant( 'BP_MEDIA_' . $mediaconst . '_SLUG' ) ) );
176
+ }
177
+
178
+ /**
179
+ *
180
+ */
181
+ function loader() {
182
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
183
+ }
184
+
185
+ function upload_form_multiple_activity() {
186
+ global $bp, $bp_media_default_excerpts;
187
+ if ( $bp->current_component != 'activity' )
188
+ return;
189
+ ?>
190
+ <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
191
+ $albums = new WP_Query( array(
192
+ 'post_type' => 'bp_media_album',
193
+ 'posts_per_page' => -1,
194
+ 'author' => get_current_user_id()
195
+ ) );
196
+ if ( isset( $albums->posts ) && is_array( $albums->posts ) && count( $albums->posts ) > 0 ) {
197
+ foreach ( $albums->posts as $album ) {
198
+ if ( $album->post_title == 'Wall Posts' )
199
+ echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
200
+ else
201
+ echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>';
202
+ };
203
+ }
204
+ ?></select></div>
205
+ <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
206
+ <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop activity-component">
207
+ <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Add Media" class="button" /></p>
208
+ </div>
209
+ <div id="bp-media-uploaded-files"></div>
210
+ <?php
211
+ }
212
+
213
+ }
214
+ ?>
app/main/profile/BPMediaUploadScreen.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 BPMediaUploadScreen
10
+ *
11
+ * @author saurabh
12
+ */
13
+ class BPMediaUploadScreen extends BPMediaScreen {
14
+
15
+ public function __construct( $media_type, $slug ) {
16
+ parent::__construct( $media_type, $slug );
17
+ }
18
+
19
+ function upload_screen() {
20
+ add_action( 'wp_enqueue_scripts', array( $this, 'upload_enqueue' ) );
21
+ add_action( 'bp_template_title', array( $this, 'upload_screen_title' ) );
22
+ add_action( 'bp_template_content', array( $this, 'upload_screen_content' ) );
23
+ $this->template->loader();
24
+ }
25
+
26
+ function upload_screen_title() {
27
+ _e( 'Upload Media', BP_MEDIA_TXT_DOMAIN );
28
+ }
29
+
30
+ function upload_screen_content() {
31
+ $this->hook_before();
32
+
33
+ $this->template->upload_form_multiple();
34
+
35
+ $this->hook_after();
36
+ }
37
+
38
+ function upload_enqueue() {
39
+ $params = array(
40
+ 'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
41
+ 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
42
+ 'browse_button' => 'bp-media-upload-browse-button',
43
+ 'container' => 'bp-media-upload-ui',
44
+ 'drop_element' => 'drag-drop-area',
45
+ 'filters' => apply_filters( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3" ) ) ),
46
+ 'max_file_size' => min( array( ini_get( 'upload_max_filesize' ), ini_get( 'post_max_size' ) ) ),
47
+ 'multipart' => true,
48
+ 'urlstream_upload' => true,
49
+ 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
50
+ 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
51
+ 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
52
+ 'multi_selection' => true,
53
+ 'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
54
+ );
55
+ 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' ) );
56
+ wp_localize_script( 'bp-media-uploader', 'bp_media_uploader_params', $params );
57
+ wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/bp-media-style.css' );
58
+ //wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
59
+ //wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
60
+ }
61
+
62
+ function upload_handler() {
63
+ ignore_user_abort( true );
64
+
65
+ require_once(BP_MEDIA_PATH . 'lib/bootstrap.php');
66
+
67
+ // Check for rights
68
+ if ( ! is_user_logged_in() )
69
+ wp_die( __( "You are not allowed to be here", BP_MEDIA_TXT_DOMAIN ) );
70
+ }
71
+
72
+ function upload_media() {
73
+ global $bp, $bp_media_options;
74
+ $bp_media_options = get_site_option( 'bp_media_options',
75
+ array(
76
+ 'videos_enabled' => true,
77
+ 'audio_enabled' => true,
78
+ 'images_enabled' => true,
79
+ )
80
+ );
81
+ if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'wp_handle_upload' ) {
82
+ /** This section can help in the group activity handling */
83
+ if ( isset( $_POST[ 'bp_media_group_id' ] ) && intval( $_POST[ 'bp_media_group_id' ] ) ) {
84
+ remove_action( 'bp_media_after_add_media', 'BPMediaActions::p_media_activity_create_after_add_media', 10, 2 );
85
+ add_action( 'bp_media_after_add_media', 'BPMediaGroupAction::bp_media_groups_activity_create_after_add_media', 10, 2 );
86
+ add_filter( 'bp_media_force_hide_activity', 'bp_media_groups_force_hide_activity' );
87
+ }
88
+ /* @var $bp_media_entry BPMediaHostWordpress */
89
+ if ( isset( $_FILES ) && is_array( $_FILES ) && array_key_exists( 'bp_media_file', $_FILES ) && $_FILES[ 'bp_media_file' ][ 'name' ] != '' ) {
90
+ if ( ! preg_match( '/audio|video|image/i', $_FILES[ 'bp_media_file' ][ 'type' ], $result ) || ! isset( $result[ 0 ] ) ) {
91
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'File uploaded is not supported' );
92
+ return;
93
+ }
94
+ $type = $result[ 0 ];
95
+ switch ( $result[ 0 ] ) {
96
+ case 'image' :
97
+ if ( $bp_media_options[ 'images_enabled' ] == false ) {
98
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Image uploads are disabled', BP_MEDIA_TXT_DOMAIN );
99
+ return;
100
+ }
101
+ break;
102
+ case 'video' :
103
+ if ( $bp_media_options[ 'videos_enabled' ] == false ) {
104
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Video uploads are disabled', BP_MEDIA_TXT_DOMAIN );
105
+ return;
106
+ }
107
+ break;
108
+ case 'audio' :
109
+ if ( $bp_media_options[ 'audio_enabled' ] == false ) {
110
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'Audio uploads are disabled', BP_MEDIA_TXT_DOMAIN );
111
+ return;
112
+ }
113
+ break;
114
+ default :
115
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'File uploaded is not supported', BP_MEDIA_TXT_DOMAIN );
116
+ return;
117
+ }
118
+ $class_name = apply_filters( 'bp_media_transcoder', 'BPMediaHostWordpress', $type );
119
+ $bp_media_entry = new $class_name();
120
+ try {
121
+ $title = isset( $_POST[ 'bp_media_title' ] ) ? ($_POST[ 'bp_media_title' ] != "") ? $_POST[ 'bp_media_title' ] : pathinfo( $_FILES[ 'bp_media_file' ][ 'name' ], PATHINFO_FILENAME ) : pathinfo( $_FILES[ 'bp_media_file' ][ 'name' ], PATHINFO_FILENAME );
122
+ $album_id = isset( $_POST[ 'bp_media_album_id' ] ) ? intval( $_POST[ 'bp_media_album_id' ] ) : 0;
123
+ $is_multiple = isset( $_POST[ 'is_multiple_upload' ] ) ? ($_POST[ 'is_multiple_upload' ] == 'true' ? true : false) : false;
124
+ $description = isset( $_POST[ 'bp_media_description' ] ) ? $_POST[ 'bp_media_description' ] : '';
125
+ $group_id = isset( $_POST[ 'bp_media_group_id' ] ) ? intval( $_POST[ 'bp_media_group_id' ] ) : 0;
126
+ $entry = $bp_media_entry->add_media( $title, $description, $album_id, $group_id, $is_multiple );
127
+ if ( ! isset( $bp->{BP_MEDIA_SLUG}->messages[ 'updated' ][ 0 ] ) )
128
+ $bp->{BP_MEDIA_SLUG}->messages[ 'updated' ][ 0 ] = __( 'Upload Successful', BP_MEDIA_TXT_DOMAIN );
129
+ } catch ( Exception $e ) {
130
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = $e->getMessage();
131
+ }
132
+ } else {
133
+ $bp->{BP_MEDIA_SLUG}->messages[ 'error' ][ ] = __( 'You did not specified a file to upload', BP_MEDIA_TXT_DOMAIN );
134
+ }
135
+ }
136
+ }
137
+
138
+ }
139
+
140
+ ?>
app/main/widgets/BPMediaPopularMedia.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+
7
+ /**
8
+ * Description of BPMediaPopularMediaWidget
9
+ *
10
+ * @author saurabh
11
+ */
12
+ class BPMediaPopularMedia extends WP_Widget {
13
+
14
+ function __construct() {
15
+ $widget_ops = array( 'classname' => 'BPMediaPopularMedia', 'description' => __( "The most popular media on your site", BP_MEDIA_TXT_DOMAIN ) );
16
+ parent::__construct( 'popular-media', __( 'Popular Media', BP_MEDIA_TXT_DOMAIN ), $widget_ops );
17
+ }
18
+
19
+ function widget( $args, $instance ) {
20
+ extract( $args );
21
+
22
+ $title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? __( 'Popular Media', BP_MEDIA_TXT_DOMAIN ) : $instance[ 'title' ], $instance, $this->id_base );
23
+
24
+ if ( empty( $instance[ 'number' ] ) || ! $number = absint( $instance[ 'number' ] ) )
25
+ $number = 10;
26
+
27
+ echo $before_widget;
28
+ echo $before_title . $title . $after_title;
29
+ ?>
30
+ <div id="popular-media-tabs" class="media-tabs-container">
31
+ <!-- <ul>
32
+ <li><a href="#popular-media-tabs-comments"><?php _e( 'comments', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
33
+ <li><a href="#popular-media-tabs-views"><?php _e( 'Views', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
34
+ </ul>-->
35
+ <div id="popular-media-tabs-comments" class="bp-media-tab-panel">
36
+ <?php
37
+ $args = array( 'post_type' => 'attachment',
38
+ 'post_status' => 'any',
39
+ 'posts_per_page' => $number,
40
+ 'meta_key' => 'bp-media-key',
41
+ 'meta_value' => 0,
42
+ 'meta_compare' => '>',
43
+ 'orderby' => 'comment_count' );
44
+
45
+ $bp_media_widget_query = new WP_Query( $args );
46
+
47
+ if ( $bp_media_widget_query->have_posts() ) {
48
+ ?>
49
+
50
+ <ul class="widget-item-listing"><?php
51
+ while ( $bp_media_widget_query->have_posts() ) {
52
+ $bp_media_widget_query->the_post();
53
+
54
+ $entry = new BPMediaHostWordpress( get_the_ID() );
55
+ ?>
56
+
57
+ <?php echo $entry->get_media_gallery_content(); ?><?php }
58
+ ?>
59
+
60
+ </ul><!-- .widget-item-listing --><?php
61
+ }else
62
+ _e( 'No popular media found', BP_MEDIA_TXT_DOMAIN );
63
+
64
+ wp_reset_query();
65
+ ?>
66
+
67
+ </div><!-- #popular-media-tabs-comments -->
68
+ </div>
69
+ <?php
70
+ echo $after_widget;
71
+ }
72
+
73
+ function update( $new_instance, $old_instance ) {
74
+ $instance = $old_instance;
75
+ $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
76
+ $instance[ 'number' ] = (int) $new_instance[ 'number' ];
77
+ return $instance;
78
+ }
79
+
80
+ function form( $instance ) {
81
+ $title = isset( $instance[ 'title' ] ) ? esc_attr( $instance[ 'title' ] ) : '';
82
+ $number = isset( $instance[ 'number' ] ) ? absint( $instance[ 'number' ] ) : 10;
83
+ ?>
84
+ <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', BP_MEDIA_TXT_DOMAIN ); ?></label>
85
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
86
+
87
+ <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:', BP_MEDIA_TXT_DOMAIN ); ?></label>
88
+ <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
89
+ <?php
90
+ }
91
+
92
+ }
93
+ ?>
app/main/widgets/BPMediaRecentMedia.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+
7
+ /**
8
+ * Description of BPMediaRecentMediaWidget
9
+ *
10
+ * @author saurabh
11
+ */
12
+ class BPMediaRecentMedia extends WP_Widget {
13
+
14
+ function __construct() {
15
+ $widget_ops = array( 'classname' => 'widget_recent_media', 'description' => __( "The most recent media uploaded on your site", BP_MEDIA_TXT_DOMAIN ) );
16
+ parent::__construct( 'recent-media', __( 'Recent Media', BP_MEDIA_TXT_DOMAIN ), $widget_ops );
17
+ }
18
+
19
+ function widget( $args, $instance ) {
20
+ extract( $args );
21
+
22
+ $title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? __( 'Recent Media', BP_MEDIA_TXT_DOMAIN ) : $instance[ 'title' ], $instance, $this->id_base );
23
+
24
+ if ( empty( $instance[ 'number' ] ) || ! $number = absint( $instance[ 'number' ] ) )
25
+ $number = 10;
26
+
27
+ echo $before_widget;
28
+ echo $before_title . $title . $after_title;
29
+ ?>
30
+ <div id="recent-media-tabs" class="media-tabs-container">
31
+ <ul>
32
+ <li><a href="#recent-media-tabs-all"><?php _e( 'All', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
33
+ <li><a href="#recent-media-tabs-photos"><?php _e( 'Photos', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
34
+ <li><a href="#recent-media-tabs-music"><?php _e( 'Music', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
35
+ <li><a href="#recent-media-tabs-videos"><?php _e( 'Videos', BP_MEDIA_TXT_DOMAIN ); ?></a></li>
36
+ </ul>
37
+ <div id="recent-media-tabs-all" class="bp-media-tab-panel">
38
+ <?php
39
+ // All Media
40
+ $args = array( 'post_type' => 'attachment',
41
+ 'post_status' => 'any',
42
+ 'posts_per_page' => $number,
43
+ 'meta_key' => 'bp-media-key',
44
+ 'meta_value' => 0,
45
+ 'meta_compare' => '>' );
46
+
47
+ $bp_media_widget_query = new WP_Query( $args );
48
+
49
+ if ( $bp_media_widget_query->have_posts() ) {
50
+ ?>
51
+
52
+ <ul class="widget-item-listing"><?php
53
+ while ( $bp_media_widget_query->have_posts() ) {
54
+ $bp_media_widget_query->the_post();
55
+
56
+ $entry = new BPMediaHostWordpress( get_the_ID() );
57
+ ?>
58
+
59
+ <?php echo $entry->get_media_gallery_content(); ?><?php }
60
+ ?>
61
+
62
+ </ul><!-- .widget-item-listing --><?php
63
+ }else
64
+ _e( 'No recent media found', BP_MEDIA_TXT_DOMAIN );
65
+
66
+ wp_reset_query();
67
+ ?>
68
+
69
+ </div><!-- #recent-media-tabs-all -->
70
+
71
+ <div id="recent-media-tabs-photos" class="bp-media-tab-panel">
72
+ <?php
73
+ // Recent photos
74
+ $args = array( 'post_type' => 'attachment',
75
+ 'post_status' => 'any',
76
+ 'post_mime_type' => 'image',
77
+ 'posts_per_page' => $number,
78
+ 'meta_key' => 'bp-media-key',
79
+ 'meta_value' => 0,
80
+ 'meta_compare' => '>' );
81
+
82
+
83
+ $bp_media_widget_query = new WP_Query( $args );
84
+
85
+ if ( $bp_media_widget_query->have_posts() ) {
86
+ ?>
87
+
88
+ <ul class="widget-item-listing"><?php
89
+ while ( $bp_media_widget_query->have_posts() ) {
90
+ $bp_media_widget_query->the_post();
91
+
92
+ $entry = new BPMediaHostWordpress( get_the_ID() );
93
+ ?>
94
+
95
+ <?php echo $entry->get_media_gallery_content(); ?><?php }
96
+ ?>
97
+
98
+ </ul><!-- .widget-item-listing --><?php
99
+ }else
100
+ _e( 'No recent photo found', BP_MEDIA_TXT_DOMAIN );
101
+
102
+ wp_reset_query();
103
+ ?>
104
+
105
+ </div><!-- #media-tabs-photos -->
106
+
107
+ <div id="recent-media-tabs-music" class="bp-media-tab-panel">
108
+ <?php
109
+ // Recent Audio
110
+ $args = array( 'post_type' => 'attachment',
111
+ 'post_status' => 'any',
112
+ 'post_mime_type' => 'audio',
113
+ 'posts_per_page' => $number,
114
+ 'meta_key' => 'bp-media-key',
115
+ 'meta_value' => 0,
116
+ 'meta_compare' => '>' );
117
+
118
+ $bp_media_widget_query = new WP_Query( $args );
119
+
120
+ if ( $bp_media_widget_query->have_posts() ) {
121
+ ?>
122
+
123
+ <ul class="widget-item-listing">
124
+ <?php
125
+ while ( $bp_media_widget_query->have_posts() ) {
126
+ $bp_media_widget_query->the_post();
127
+
128
+ $entry = new BPMediaHostWordpress( get_the_ID() );
129
+ echo $entry->get_media_gallery_content();
130
+ }
131
+ ?>
132
+
133
+ </ul><!-- .widget-item-listing --><?php
134
+ }else
135
+ _e( 'No recent audio found', BP_MEDIA_TXT_DOMAIN );
136
+
137
+ wp_reset_query();
138
+ ?>
139
+
140
+ </div><!-- #recent-media-tabs-music -->
141
+
142
+ <div id="recent-media-tabs-videos" class="bp-media-tab-panel">
143
+ <?php
144
+ // Recent Video
145
+ $args = array( 'post_type' => 'attachment',
146
+ 'post_status' => 'any',
147
+ 'post_mime_type' => 'video',
148
+ 'posts_per_page' => $number,
149
+ 'meta_key' => 'bp-media-key',
150
+ 'meta_value' => 0,
151
+ 'meta_compare' => '>' );
152
+
153
+ $bp_media_widget_query = new WP_Query( $args );
154
+
155
+ if ( $bp_media_widget_query->have_posts() ) {
156
+ ?>
157
+
158
+ <ul class="widget-item-listing"><?php
159
+ while ( $bp_media_widget_query->have_posts() ) {
160
+ $bp_media_widget_query->the_post();
161
+
162
+ $entry = new BPMediaHostWordpress( get_the_ID() );
163
+ ?>
164
+
165
+ <?php echo $entry->get_media_gallery_content(); ?><?php }
166
+ ?>
167
+
168
+ </ul><!-- .widget-item-listing --><?php
169
+ }else
170
+ _e( 'No recent video found', BP_MEDIA_TXT_DOMAIN );
171
+
172
+ wp_reset_query();
173
+ ?>
174
+
175
+ </div><!-- #media-tabs-videos -->
176
+
177
+ </div>
178
+ <?php
179
+ echo $after_widget;
180
+ }
181
+
182
+ function update( $new_instance, $old_instance ) {
183
+ $instance = $old_instance;
184
+ $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
185
+ $instance[ 'number' ] = (int) $new_instance[ 'number' ];
186
+ return $instance;
187
+ }
188
+
189
+ function form( $instance ) {
190
+ $title = isset( $instance[ 'title' ] ) ? esc_attr( $instance[ 'title' ] ) : '';
191
+ $number = isset( $instance[ 'number' ] ) ? absint( $instance[ 'number' ] ) : 10;
192
+ ?>
193
+ <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', BP_MEDIA_TXT_DOMAIN ); ?></label>
194
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
195
+
196
+ <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:', BP_MEDIA_TXT_DOMAIN ); ?></label>
197
+ <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
198
+ <?php
199
+ }
200
+
201
+ }
202
+ ?>
config/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To fake it is to stand guard over emptiness.
4
+ * Arthur Herzog
5
+ */
6
+ ?>
includes/bp-media-actions.php DELETED
@@ -1,589 +0,0 @@
1
- <?php
2
- /**
3
- * Handles the uploads and creates respective posts for the upload
4
- *
5
- * @since BP Media 2.0
6
- */
7
- function bp_media_handle_uploads() {
8
- global $bp,$bp_media_options;
9
- $bp_media_options = get_site_option('bp_media_options',array(
10
- 'videos_enabled' => true,
11
- 'audio_enabled' => true,
12
- 'images_enabled' => true,
13
- ));
14
- if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
15
- /** This section can help in the group activity handling */
16
- if(isset($_POST['bp_media_group_id'])&&intval($_POST['bp_media_group_id'])){
17
- remove_action('bp_media_after_add_media','bp_media_activity_create_after_add_media',10,2);
18
- add_action('bp_media_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
19
- add_filter('bp_media_force_hide_activity','bp_media_groups_force_hide_activity');
20
- }
21
- /* @var $bp_media_entry BP_Media_Host_Wordpress */
22
- if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
23
- if(!preg_match('/audio|video|image/i',$_FILES['bp_media_file']['type'],$result)||!isset($result[0])){
24
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
25
- return;
26
- }
27
- $type = $result[0];
28
- switch($result[0]){
29
- case 'image' :
30
- if($bp_media_options['images_enabled']==false){
31
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Image uploads are disabled');
32
- return;
33
- }
34
- break;
35
- case 'video' :
36
- if($bp_media_options['videos_enabled']==false){
37
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Video uploads are disabled');
38
- return;
39
- }
40
- break;
41
- case 'audio' :
42
- if($bp_media_options['audio_enabled']==false){
43
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Audio uploads are disabled');
44
- return;
45
- }
46
- break;
47
- default :
48
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
49
- return;
50
- }
51
- $class_name = apply_filters('bp_media_transcoder','BP_Media_Host_Wordpress',$type);
52
- $bp_media_entry = new $class_name();
53
- try {
54
- $title = isset($_POST['bp_media_title']) ? ($_POST['bp_media_title'] != "") ? $_POST['bp_media_title'] : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME) : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME);
55
- $album_id = isset($_POST['bp_media_album_id']) ? intval($_POST['bp_media_album_id']) : 0;
56
- $is_multiple = isset($_POST['is_multiple_upload'])?($_POST['is_multiple_upload']=='true'?true:false):false;
57
- $description = isset($_POST['bp_media_description'])? $_POST['bp_media_description'] : '';
58
- $group_id = isset($_POST['bp_media_group_id']) ? intval($_POST['bp_media_group_id']) : 0;
59
- $entry = $bp_media_entry->add_media($title, $description,$album_id,$group_id,$is_multiple);
60
- if(!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
61
- $bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', 'bp-media');
62
- } catch (Exception $e) {
63
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
64
- }
65
- } else {
66
- $bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', 'bp-media');
67
- }
68
- }
69
- }
70
- //add_action('bp_init', 'bp_media_handle_uploads');
71
-
72
- /**
73
- * Displays the messages that other functions/methods creates according to the BuddyPress' formating
74
- *
75
- * @since BP Media 2.0
76
- */
77
- function bp_media_show_messages() {
78
- global $bp;
79
- if (is_array($bp->{BP_MEDIA_SLUG}->messages)) {
80
- $types = array('error', 'updated', 'info');
81
- foreach ($types as $type) {
82
- if (count($bp->{BP_MEDIA_SLUG}->messages[$type]) > 0) {
83
- bp_media_show_formatted_error_message($bp->{BP_MEDIA_SLUG}->messages[$type], $type);
84
- }
85
- }
86
- }
87
- }
88
- add_action('bp_media_before_content', 'bp_media_show_messages');
89
-
90
- /**
91
- * Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media.
92
- *
93
- * @since BP Media 2.0
94
- */
95
- function bp_media_enqueue_scripts_styles() {
96
-
97
- wp_enqueue_script('jquery-ui-tabs');
98
- wp_enqueue_script('bp-media-mejs', plugins_url('includes/media-element/mediaelement-and-player.min.js', dirname(__FILE__)));
99
- wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
100
- global $bp;
101
- $bp_media_vars = array(
102
- 'ajaxurl' => admin_url( 'admin-ajax.php'),
103
- 'page' => 1,
104
- 'current_action' => bp_get_current_group_id()?(empty($bp->action_variables)?BP_MEDIA_IMAGES_SLUG:$bp->action_variables):(isset($bp->current_action)?$bp->current_action:false),
105
- 'action_variables' => isset($bp->action_variables)?(empty($bp->action_variables)?array(BP_MEDIA_IMAGES_SLUG):$bp->action_variables):array(BP_MEDIA_IMAGES_SLUG),
106
- 'displayed_user' => bp_displayed_user_id(),
107
- 'loggedin_user' => bp_loggedin_user_id(),
108
- 'current_group' => bp_get_current_group_id()
109
- );
110
- wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
111
- wp_enqueue_style('bp-media-mecss', plugins_url('includes/media-element/mediaelementplayer.min.css', dirname(__FILE__)));
112
- wp_enqueue_style('bp-media-default', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
113
-
114
- }
115
- add_action('wp_enqueue_scripts', 'bp_media_enqueue_scripts_styles', 11);
116
-
117
- function bp_media_delete_activity_handler($args){
118
- remove_action('bp_media_before_delete_media','bp_media_delete_media_handler');
119
- global $bp_media_count,$wpdb;
120
- if(!array_key_exists('id', $args))
121
- return;
122
-
123
- $activity_id=$args['id'];
124
- if(intval($activity_id)){
125
- $query="SELECT post_id from $wpdb->postmeta WHERE meta_key='bp_media_child_activity' AND meta_value={$activity_id}";
126
- $result=$wpdb->get_results($query);
127
- if(!(is_array($result)&& count($result)==1 ))
128
- return;
129
- $post_id=$result[0]->post_id;
130
- try{
131
- $post = get_post($post_id);
132
- if(!isset($post->post_type))
133
- return false;
134
- switch($post->post_type){
135
- case 'attachment':
136
- $media = new BP_Media_Host_Wordpress($post_id);
137
- $media->delete_media();
138
- break;
139
- case 'bp_media_album':
140
- $album = new BP_Media_Album($post_id);
141
- $album->delete_album();
142
- break;
143
- default:
144
- wp_delete_post($post_id);
145
- }
146
- }
147
- catch(Exception $e){
148
- error_log('Media tried to delete was already deleted');
149
- }
150
- }
151
- }
152
- add_action('bp_before_activity_delete', 'bp_media_delete_activity_handler');
153
-
154
- function bp_media_delete_media_handler($media_id){
155
- /* @var $media BP_Media_Host_Wordpress */
156
- remove_action('bp_before_activity_delete', 'bp_media_delete_activity_handler');
157
- $activity_id = get_post_meta($media_id,'bp_media_child_activity',true);
158
- if($activity_id==NULL)
159
- return false;
160
- bp_activity_delete_by_activity_id($activity_id);
161
- }
162
- add_action('bp_media_before_delete_media','bp_media_delete_media_handler');
163
-
164
- /**
165
- * Called on bp_init by screen functions
166
- *
167
- * @uses global $bp, $bp_media_query
168
- *
169
- * @since BP Media 2.0
170
- */
171
- function bp_media_set_query() {
172
- global $bp, $bp_media_query,$bp_media_posts_per_page;
173
- switch ($bp->current_action) {
174
- case BP_MEDIA_IMAGES_SLUG:
175
- $type = 'image';
176
- break;
177
- case BP_MEDIA_AUDIO_SLUG:
178
- $type = 'audio';
179
- break;
180
- case BP_MEDIA_VIDEOS_SLUG:
181
- $type = 'video';
182
- break;
183
- default :
184
- $type = null;
185
- }
186
- if (isset($bp->action_variables) && is_array($bp->action_variables) && isset($bp->action_variables[0]) && $bp->action_variables[0] == 'page' && isset($bp->action_variables[1]) && is_numeric($bp->action_variables[1])) {
187
- $paged = $bp->action_variables[1];
188
- } else {
189
- $paged = 1;
190
- }
191
- if ($type) {
192
- $args = array(
193
- 'post_type' => 'attachment',
194
- 'post_status' => 'any',
195
- 'post_mime_type' => $type,
196
- 'author' => $bp->displayed_user->id,
197
- 'meta_key' => 'bp-media-key',
198
- 'meta_value' => $bp->displayed_user->id,
199
- 'meta_compare' => '=',
200
- 'paged' => $paged,
201
- 'posts_per_page' => $bp_media_posts_per_page
202
- );
203
- $bp_media_query = new WP_Query($args);
204
- }
205
- }
206
-
207
- /**
208
- * Adds a download button and edit button on single entry pages of media files.
209
- *
210
- * @uses $bp_media_options Global variable
211
- *
212
- * @since BP Media 2.0
213
- */
214
- function bp_media_action_buttons() {
215
- if(!in_array('bp_media_current_entry', $GLOBALS))
216
- return false;
217
- global $bp_media_current_entry,$bp_media_options;
218
-
219
- if($bp_media_current_entry!=NULL){
220
- $featured_post = get_post_meta($bp_media_current_entry->get_id(),'featured',true);
221
-
222
- if(bp_displayed_user_id()== bp_loggedin_user_id())
223
- echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action bp-media-edit" title="Edit Media">Edit</a>';
224
-
225
- if($bp_media_options['download_enabled']==true)
226
- echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action bp-media-download" title="Download">Download</a>';
227
-
228
- if(bp_displayed_user_id()== bp_loggedin_user_id() && $featured_post == '')
229
- echo '<a href="'.$bp_media_current_entry->get_album_id().'" rel="" data-album-id="'.$bp_media_current_entry->get_album_id().'" data-post-id="'.$bp_media_current_entry->get_id().'" class="button item-button bp-secondary-action bp-media-featured" title="Featured Media">Featured</a>';
230
- else
231
- echo '<a href="'.$bp_media_current_entry->get_album_id().'" rel="" data-remove-featured="1" data-album-id="'.$bp_media_current_entry->get_album_id().'" data-post-id="'.$bp_media_current_entry->get_id().'" class="button item-button bp-secondary-action bp-media-featured" title="Featured Media">Remove Featured</a>';
232
- }
233
- }
234
- add_action('bp_activity_entry_meta', 'bp_media_action_buttons');
235
-
236
- /* Should be used with Content Disposition Type for media files set to attachment */
237
-
238
- /**
239
- * Shows the media count of a user in the tabs
240
- *
241
- * @since BP Media 2.0
242
- */
243
- function bp_media_init_count($user = null) {
244
- global $bp_media_count;
245
- if (!$user)
246
- $user = bp_displayed_user_id();
247
- if ($user < 1) {
248
- $bp_media_count = null;
249
- return false;
250
- }
251
- $count = bp_get_user_meta($user, 'bp_media_count', true);
252
- if (!$count) {
253
- $bp_media_count = array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0);
254
- bp_update_user_meta($user, 'bp_media_count', $bp_media_count);
255
- } else {
256
- $bp_media_count = $count;
257
- }
258
- add_filter('bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'bp_media_items_count_filter', 10, 2);
259
-
260
- if (bp_current_component() == BP_MEDIA_SLUG) {
261
- add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'bp_media_items_count_filter', 10, 2);
262
- add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'bp_media_items_count_filter', 10, 2);
263
- add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'bp_media_items_count_filter', 10, 2);
264
- add_filter('bp_get_options_nav_' . BP_MEDIA_ALBUMS_SLUG, 'bp_media_items_count_filter', 10, 2);
265
- }
266
- return true;
267
- }
268
- add_action('init', 'bp_media_init_count');
269
-
270
- /**
271
- * Displays the footer of the BP Media Plugin if enabled through the dashboard options page
272
- *
273
- * @since BP Media 2.0
274
- */
275
- function bp_media_footer() { ?>
276
- <div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
277
- <?php
278
- }
279
-
280
- global $bp_media_options;
281
- if(isset($bp_media_options['remove_linkback'])&&$bp_media_options['remove_linkback']!='1')
282
- add_action('bp_footer','bp_media_footer');
283
-
284
- function bp_media_upload_enqueue(){
285
- $params=array(
286
- 'url'=>plugins_url('bp-media-upload-handler.php',__FILE__),
287
- 'runtimes' => 'gears,html5,flash,silverlight,browserplus',
288
- 'browse_button' => 'bp-media-upload-browse-button',
289
- 'container' => 'bp-media-upload-ui',
290
- 'drop_element' => 'drag-drop-area',
291
- 'filters' => apply_filters('bp_media_plupload_files_filter',array(array('title' => "Media Files",'extensions'=> "mp4,jpg,png,jpeg,gif,mp3"))),
292
- 'max_file_size' => min(array(ini_get('upload_max_filesize'),ini_get('post_max_size'))),
293
- 'multipart' => true,
294
- 'urlstream_upload' => true,
295
- 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
296
- 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
297
- 'file_data_name' => 'bp_media_file', // key passed to $_FILE.
298
- 'multi_selection' => true,
299
- 'multipart_params' => apply_filters('bp_media_multipart_params_filter',array('action'=>'wp_handle_upload'))
300
- );
301
- wp_enqueue_script('bp-media-uploader',plugins_url('js/bp-media-uploader.js',__FILE__),array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4','plupload-handlers','jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-dialog'));
302
- wp_localize_script('bp-media-uploader','bp_media_uploader_params',$params);
303
- wp_enqueue_style('bp-media-default',plugins_url('css/bp-media-style.css',__FILE__));
304
- // wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
305
- wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
306
- }
307
- add_action('wp_enqueue_scripts','bp_media_upload_enqueue');
308
- //This is used only on the uploads page so its added as action in the screens function of upload page.
309
-
310
-
311
- /**
312
- * Called on bp_init by screen functions
313
- *
314
- * @uses global $bp, $bp_media_albums_query
315
- *
316
- * @since BP Media 2.2
317
- */
318
- function bp_media_albums_set_query() {
319
- global $bp, $bp_media_albums_query;
320
- if (isset($bp->action_variables) && is_array($bp->action_variables) && isset($bp->action_variables[0]) && $bp->action_variables[0] == 'page' && isset($bp->action_variables[1]) && is_numeric($bp->action_variables[1])) {
321
- $paged = $bp->action_variables[1];
322
- } else {
323
- $paged = 1;
324
- }
325
- if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
326
- $args = array(
327
- 'post_type' => 'bp_media_album',
328
- 'author' => $bp->displayed_user->id,
329
- 'paged' => $paged,
330
- 'meta_key' => 'bp-media-key',
331
- 'meta_value' => $bp->displayed_user->id,
332
- 'meta_compare' => '='
333
- );
334
- $bp_media_albums_query = new WP_Query($args);
335
- }
336
- }
337
-
338
- /**
339
- * Called on bp_init by screen functions
340
- *
341
- * @uses global $bp, $bp_media_query
342
- *
343
- * @since BP Media 2.2
344
- */
345
- function bp_media_albums_set_inner_query($album_id=0) {
346
- global $bp, $bp_media_query;
347
- $paged = 0;
348
- $action_variables = isset($bp->canonical_stack['action_variables'])?$bp->canonical_stack['action_variables']:null;
349
- if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0])) {
350
- if($action_variables[0] == 'page' && isset($action_variables[1]) && is_numeric($action_variables[1]))
351
- $paged = $action_variables[1];
352
- else if(isset($action_variables[1]) && $action_variables[1] == 'page' && isset($action_variables[2]) && is_numeric($action_variables[2]))
353
- $paged = $action_variables[2];
354
- }
355
- if(!$paged)
356
- $paged = 1;
357
- $args = array(
358
- 'post_type' => 'attachment',
359
- 'post_status' => 'any',
360
- 'post_parent'=>$album_id,
361
- 'paged' => $paged
362
- );
363
- $bp_media_query = new WP_Query($args);
364
- }
365
-
366
- /**
367
- * Function to return the media for the ajax requests
368
- */
369
- function bp_media_load_more() {
370
- global $bp,$bp_media_query,$bp_media_posts_per_page;
371
- $page = isset($_POST['page'])?$_POST['page']:die();
372
- $current_action = isset($_POST['current_action'])?$_POST['current_action']:null;
373
- $action_variables = isset($_POST['action_variables'])?$_POST['action_variables']:null;
374
- $displayed_user = isset($_POST['displayed_user'])?$_POST['displayed_user']:null;
375
- $loggedin_user = isset($_POST['loggedin_user'])?$_POST['loggedin_user']:null;
376
- $current_group = isset($_POST['current_group'])?$_POST['current_group']:null;
377
- if((!$displayed_user||intval($displayed_user)==0)&&(!$current_group||intval($current_group)==0)){
378
- die();
379
- }
380
- switch($current_action){
381
- case BP_MEDIA_IMAGES_SLUG:
382
- $args = array(
383
- 'post_type' => 'attachment',
384
- 'post_status' => 'any',
385
- 'post_mime_type' => 'image',
386
- 'meta_key' => 'bp-media-key',
387
- 'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
388
- 'meta_compare' => '=',
389
- 'paged' => $page,
390
- 'posts_per_page' => $bp_media_posts_per_page
391
- );
392
- break;
393
- case BP_MEDIA_AUDIO_SLUG:
394
- $args = array(
395
- 'post_type' => 'attachment',
396
- 'post_status' => 'any',
397
- 'post_mime_type' => 'audio',
398
- 'author' => $bp->displayed_user->id,
399
- 'meta_key' => 'bp-media-key',
400
- 'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
401
- 'meta_compare' => '=',
402
- 'paged' => $page,
403
- 'posts_per_page' => $bp_media_posts_per_page
404
- );
405
- break;
406
- case BP_MEDIA_VIDEOS_SLUG:
407
- $args = array(
408
- 'post_type' => 'attachment',
409
- 'post_status' => 'any',
410
- 'post_mime_type' => 'video',
411
- 'author' => $bp->displayed_user->id,
412
- 'meta_key' => 'bp-media-key',
413
- 'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
414
- 'meta_compare' => '=',
415
- 'paged' => $page,
416
- 'posts_per_page' => $bp_media_posts_per_page
417
- );
418
- break;
419
- case BP_MEDIA_ALBUMS_SLUG:
420
- if(isset($action_variables)&& is_array($action_variables)&&isset($action_variables[0])&&isset($action_variables[1])){
421
- $args = array(
422
- 'post_type' => 'attachment',
423
- 'post_status' => 'any',
424
- 'author' => $displayed_user,
425
- 'post_parent'=>$action_variables[1],
426
- 'paged' => $page,
427
- 'posts_per_page' => $bp_media_posts_per_page
428
- );
429
- }
430
- else{
431
- $args = array(
432
- 'post_type' => 'bp_media_album',
433
- 'author' => $displayed_user,
434
- 'paged' => $page,
435
- 'posts_per_page' => $bp_media_posts_per_page
436
- );
437
- }
438
- break;
439
- default:
440
- die();
441
- }
442
- $bp_media_query = new WP_Query($args);
443
- if(isset($bp_media_query->posts)&&is_array($bp_media_query->posts)&&count($bp_media_query->posts)){
444
- foreach($bp_media_query->posts as $attachment){
445
- try{
446
- $media = new BP_Media_Host_Wordpress($attachment->ID);
447
- echo $media->get_media_gallery_content();
448
- }
449
- catch(exception $e){
450
- die();
451
- }
452
- }
453
- }
454
- die();
455
- }
456
- add_action('wp_ajax_bp_media_load_more', 'bp_media_load_more');
457
- add_action( 'wp_ajax_nopriv_bp_media_load_more', 'bp_media_load_more' );
458
-
459
-
460
- function bp_media_delete_attachment_handler($attachment_id){
461
- if(get_post_meta($attachment_id,'bp-media-key')){
462
- do_action('bp_media_before_delete_media',$attachment_id);
463
- global $bp_media_count;
464
- $attachment = get_post($attachment_id);
465
- preg_match_all('/audio|video|image/i', $attachment->post_mime_type, $result);
466
- if(isset($result[0][0]))
467
- $type = $result[0][0];
468
- else
469
- return false;
470
- bp_media_init_count($attachment->post_author);
471
- switch($type){
472
- case 'image':
473
- $images = intval($bp_media_count['images'])?intval($bp_media_count['images']):0;
474
- $bp_media_count['images'] = $images - 1;
475
- break;
476
- case 'audio':
477
- $bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
478
- break;
479
- case 'video':
480
- $bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
481
- break;
482
- default:
483
- return false;
484
- }
485
- bp_update_user_meta($attachment->post_author, 'bp_media_count', $bp_media_count);
486
- do_action('bp_media_after_delete_media',$attachment_id);
487
- return true;
488
- }
489
- }
490
- add_action('delete_attachment','bp_media_delete_attachment_handler');
491
-
492
- /**
493
- * Function to create new album called via ajax request
494
- */
495
- function bp_media_add_album() {
496
- if(isset($_POST['bp_media_album_name'])&&$_POST['bp_media_album_name']!=''){
497
- $album = new BP_Media_Album();
498
- if(isset($_POST['bp_media_group_id'])&&intval($_POST['bp_media_group_id'])>0){
499
- $group_id = intval($_POST['bp_media_group_id']);
500
- if(bp_media_groups_user_can_create_album($group_id, get_current_user_id())){
501
- try{
502
- $album -> add_album($_POST['bp_media_album_name'], 0 ,$group_id);
503
- echo $album->get_id();
504
- }
505
- catch(exception $e){
506
- echo '0';
507
- }
508
- }
509
- else{
510
- echo '0';
511
- }
512
- }
513
- else{
514
- try{
515
- $album -> add_album($_POST['bp_media_album_name']);
516
- echo $album->get_id();
517
- }
518
- catch(exception $e){
519
- echo '0';
520
- }
521
- }
522
- }
523
- else{
524
- echo '0';
525
- }
526
- die();
527
- }
528
- add_action('wp_ajax_bp_media_add_album', 'bp_media_add_album');
529
-
530
- function bp_media_add_new_from_activity(){
531
- bp_media_show_upload_form_multiple_activity();
532
- }
533
- //add_action('bp_after_activity_post_form','bp_media_add_new_from_activity');
534
-
535
-
536
- function bp_media_album_create_activity($album){
537
- /* @var $album BP_Media_Album */
538
- $args = array(
539
- 'action' => apply_filters( 'bp_media_album_created', sprintf( __( '%1$s created an album %2$s', 'bp-media'), bp_core_get_userlink( $album->get_owner() ), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>' ) ),
540
- 'component' => BP_MEDIA_SLUG,
541
- 'type' => 'album_created',
542
- 'primary_link' => $album->get_url(),
543
- 'user_id' => $album->get_owner(),
544
- 'item_id' => $album->get_id()
545
- );
546
- $activity_id = bp_media_record_activity($args);
547
- update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
548
- }
549
- add_action('bp_media_after_add_album','bp_media_album_create_activity');
550
-
551
- function bp_media_album_activity_update($album_id){
552
- bp_media_update_album_activity($album_id);
553
- }
554
- add_action('bp_media_album_updated','bp_media_album_activity_update');
555
-
556
- function bp_media_album_activity_sync($media_id){
557
- $album_id = wp_get_post_parent_id($media_id);
558
- bp_media_update_album_activity($album_id,false,$media_id);
559
- }
560
- add_action('bp_media_after_delete_media','bp_media_album_activity_sync');
561
-
562
- function bp_media_activity_create_after_add_media($media,$hidden=false){
563
- if(function_exists('bp_activity_add')){
564
- if(!is_object($media)){
565
- try{
566
- $media = new BP_Media_Host_Wordpress($media);
567
- }catch(exception $e){
568
- return false;
569
- }
570
- }
571
- $args = array(
572
- 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $media->get_author() ), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>' ) ),
573
- 'content' => $media->get_media_activity_content(),
574
- 'primary_link' => $media->get_url(),
575
- 'item_id' => $media->get_id(),
576
- 'type' => 'media_upload',
577
- 'user_id' => $media->get_author()
578
- );
579
- $hidden = apply_filters('bp_media_force_hide_activity',$hidden);
580
- if($hidden){
581
- $args['secondary_item_id'] = -999;
582
- do_action('bp_media_album_updated',$media->get_album_id());
583
- }
584
- $activity_id = bp_media_record_activity($args);
585
- add_post_meta($media->get_id(),'bp_media_child_activity',$activity_id);
586
- }
587
- }
588
- add_action('bp_media_after_add_media','bp_media_activity_create_after_add_media',10,2);
589
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-admin.php DELETED
@@ -1,530 +0,0 @@
1
- <?php
2
- if(version_compare(BP_MEDIA_DB_VERSION,get_site_option('bp_media_db_version','1.0'),'>')){
3
- add_action('admin_notices', 'bp_media_upgrade_db_notice');
4
- }
5
-
6
- add_action('wp_loaded','bp_media_upgrade_script');
7
- function bp_media_upgrade_script(){
8
- if(isset($_GET['bp_media_upgrade_db']) && empty($_REQUEST['settings-updated'])){
9
- check_admin_referer('bp_media_upgrade_db','wp_nonce');
10
- require_once('bp-media-upgrade-script.php');
11
- $current_version = get_site_option('bp_media_db_version','1.0');
12
- if($current_version == '2.0')
13
- bp_media_upgrade_from_2_0_to_2_1();
14
- else
15
- bp_media_upgrade_from_1_0_to_2_1();
16
- remove_action('admin_notices', 'bp_media_upgrade_db_notice');
17
- }
18
- }
19
-
20
-
21
- /**
22
- * Displays admin notice to upgrade BuddyPress Media Database
23
- */
24
- function bp_media_upgrade_db_notice() {
25
- ?>
26
- <div class="error"><p>
27
- Please click upgrade to upgrade the database of BuddyPress Media <a class="button" id="refresh_media_count" href ="<?php echo bp_media_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings', 'bp_media_upgrade_db' => 1 ,'wp_nonce' => wp_create_nonce( 'bp_media_upgrade_db' ) ), 'admin.php' ) ) ?>" class="button" title="<?php printf(__('It will migrate your BuddyPress Media\'s earlier database to new database.')); ?>">Upgrade</a>
28
- </p></div>
29
- <?php
30
- }
31
-
32
- /**
33
- * Add the BuddyPress Media's options menu in the BuddyPress' options subnavigation.
34
- *
35
- * @since BP Media 2.0
36
- */
37
- function bp_media_add_admin_menu() {
38
-
39
- global $bp,$bp_media_errors,$bp_media_messages;
40
- if (!is_super_admin())
41
- return false;
42
- $bp_media_errors=array();
43
- $bp_media_messages=array();
44
- global $bp_media_options;
45
- $bp_media_options = get_site_option('bp_media_options',array(
46
- 'videos_enabled' => true,
47
- 'audio_enabled' => true,
48
- 'images_enabled' => true,
49
- 'download_enabled' => true,
50
- 'remove_linkback' => 1,
51
- ));
52
- if(isset($_POST['submit'])){
53
- if(isset($_POST['bp_media_options'])){
54
- foreach($bp_media_options as $option=>$value){
55
- if(isset($_POST['bp_media_options'][$option])){
56
- switch($_POST['bp_media_options'][$option]){
57
- case 'true' :
58
- $bp_media_options[$option] = true;
59
- break;
60
- case '1' :
61
- $bp_media_options[$option] = 1;
62
- break;
63
- case '2' :
64
- $bp_media_options[$option] = 2;
65
- break;
66
- default :
67
- $bp_media_options[$option] = false;
68
- }
69
- }
70
- else{
71
- $bp_media_options[$option] = false;
72
- }
73
- }
74
- if(update_site_option('bp_media_options', $bp_media_options)){
75
- $bp_media_messages[0]="<b>Settings saved.</b>";
76
- }
77
- }
78
- do_action('bp_media_save_options');
79
- $bp_media_messages = apply_filters('bp_media_settings_messages',$bp_media_messages);
80
- $bp_media_errors = apply_filters('bp_media_settings_errors',$bp_media_errors);
81
- }
82
- else if(isset($_GET['bp_media_refresh_count'])){
83
- check_admin_referer('bp_media_refresh_count','wp_nonce');
84
- if(!bp_media_update_count())
85
- $bp_media_errors[]="<b>Recounting Failed</b>";
86
- else
87
- $bp_media_messages[]="<b>Recounting of media files done successfully</b>";
88
- }
89
-
90
- if(isset($bp_media_errors) && count($bp_media_errors)) { ?>
91
- <div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div><?php
92
- } if(isset($bp_media_messages) && count($bp_media_messages)){ ?>
93
- <div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div><?php
94
- }
95
-
96
- add_menu_page( 'BP Media Component', 'BP Media', 'manage_options', 'bp-media-settings', 'bp_media_settings_page' );
97
- add_submenu_page( 'bp-media-settings', __( 'BP-Media Settings', 'bp-media' ), __( 'Settings', 'bp-media' ), 'manage_options', 'bp-media-settings', "bp_media_settings_page" );
98
- add_submenu_page( 'bp-media-settings', __( 'BP-Media Addons', 'bp-media' ), __( 'Addons', 'bp-media' ), 'manage_options', 'bp-media-addons', "bp_media_settings_page" );
99
- add_submenu_page( 'bp-media-settings', __( 'BP-Media Support', 'bp-media' ), __( 'Support ', 'bp-media' ), 'manage_options', 'bp-media-support', "bp_media_settings_page" );
100
-
101
- $tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
102
- add_action('admin_print_styles-' . $tab, 'bp_media_admin_enqueue');
103
- }
104
-
105
- add_action(bp_core_admin_hook(), 'bp_media_add_admin_menu');
106
-
107
- add_action('admin_init','bp_media_on_load_page');
108
-
109
- /**
110
- * Applies WordPress metabox funtionality to metaboxes
111
- *
112
- *
113
- */
114
- function bp_media_on_load_page() {
115
-
116
- /* Javascripts loaded to allow drag/drop, expand/collapse and hide/show of boxes. */
117
- wp_enqueue_script( 'common' );
118
- wp_enqueue_script( 'wp-lists' );
119
- wp_enqueue_script( 'postbox' );
120
-
121
- // Check to see which tab we are on
122
- $tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
123
-
124
- switch ( $tab ) {
125
- case 'bp-media-addons' :
126
- // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
127
- add_meta_box('bp-media-addons-list_metabox',__('BuddyPress Media Addons for Audio/Video Conversion','bp-media'),'bp_media_addons_list','bp-media-settings', 'normal', 'core' );
128
- break;
129
- case 'bp-media-support' :
130
- // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
131
- add_meta_box( 'post_summaries_options_metabox', __('BuddyPress Media Support', 'rtPanel'), 'bp_media_support', 'bp-media-settings', 'normal', 'core' );
132
- break;
133
- case $tab :
134
- // All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
135
- add_meta_box( 'bp_media_settings_metabox', __('BuddyPress Media Settings', 'rtPanel'), 'bp_media_admin_menu', 'bp-media-settings', 'normal', 'core' );
136
- add_meta_box( 'bp_media_options_metabox', __('Spread the word', 'rtPanel'), 'bp_media_settings_options', 'bp-media-settings', 'normal', 'core' );
137
- add_meta_box( 'bp_media_other_options_metabox', __('BuddyPress Media Other options', 'rtPanel'), 'bp_media_settings_other_options', 'bp-media-settings', 'normal', 'core' );
138
- break;
139
- }
140
- }
141
-
142
-
143
- function bp_media_settings_page(){
144
- global $bp_media_errors,$bp_media_messages;
145
- $tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
146
-
147
- ?>
148
- <div class="wrap bp-media-admin">
149
- <?php //screen_icon( 'buddypress' ); ?>
150
- <div id="icon-buddypress" class="icon32"><br></div>
151
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Media', 'bp-media' ) ); ?></h2>
152
- <div class="metabox-holder columns-2">
153
- <div class="bp-media-settings-tabs"><?php
154
- // Check to see which tab we are on
155
- if(current_user_can('manage_options')){
156
- $tabs_html = '';
157
- $idle_class = 'media-nav-tab';
158
- $active_class = 'media-nav-tab media-nav-tab-active';
159
- $tabs = array();
160
-
161
- // Check to see which tab we are on
162
- $tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
163
- /* BP Media */
164
- $tabs[] = array(
165
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
166
- 'title' => __( 'BP Media Settings', 'bp-media' ),
167
- 'name' => __( 'Settings', 'bp-media' ),
168
- 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class. ' first_tab'
169
- );
170
-
171
- $tabs[] = array(
172
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-addons' ), 'admin.php' ) ),
173
- 'title' => __( 'BP Media Addons', 'bp-media' ),
174
- 'name' => __( 'Addons', 'bp-media' ),
175
- 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
176
- );
177
-
178
- $tabs[] = array(
179
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-support' ), 'admin.php' ) ),
180
- 'title' => __( 'BP Media Support', 'bp-media' ),
181
- 'name' => __( 'Support', 'bp-media' ),
182
- 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class. ' last_tab'
183
- );
184
-
185
- $pipe = '|' ;
186
- $i = '1';
187
- foreach($tabs as $tab){
188
- if($i!=1) $tabs_html.=$pipe;
189
- $tabs_html.= '<a title=""' . $tab['title'] . '" " href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
190
- $i++;
191
- }
192
- echo $tabs_html;
193
- }?>
194
- </div>
195
-
196
- <div id="bp-media-settings-boxes">
197
-
198
- <form id="bp_media_settings_form" name="bp_media_settings_form" action="" method="post" enctype="multipart/form-data">
199
- <?php
200
-
201
- settings_fields( 'bp_media_options_settings');
202
- do_settings_fields( 'bp_media_options_settings','' );
203
- do_meta_boxes( 'bp-media-settings', 'normal', '' ); ?>
204
-
205
- <script type="text/javascript">
206
- //<![CDATA[
207
- jQuery(document).ready( function($) {
208
- // close postboxes that should be closed
209
- $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
210
- // postboxes setup
211
- postboxes.add_postbox_toggles('bp-media-settings');
212
- });
213
- //]]>
214
- </script>
215
- </form>
216
- </div><!-- .bp-media-settings-boxes -->
217
- <div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
218
- <?php bp_media_default_admin_sidebar(); ?>
219
- </div>
220
- </div><!-- .metabox-holder -->
221
- </div><!-- .bp-media-admin --><?php
222
- }
223
-
224
-
225
- /**
226
- * Displays and updates the options menu of BuddyPress Media
227
- *
228
- * @since BP Media 2.0
229
- */
230
- function bp_media_admin_menu() {
231
-
232
- $bp_media_errors=array();
233
- $bp_media_messages=array();
234
-
235
- global $bp_media_options;
236
- $bp_media_options = get_site_option('bp_media_options',array(
237
- 'videos_enabled' => true,
238
- 'audio_enabled' => true,
239
- 'images_enabled' => true,
240
- 'download_enabled' => true,
241
- 'remove_linkback' => 1,
242
- ));
243
- ?>
244
-
245
- <?php if(count($bp_media_errors)) { ?>
246
- <div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div>
247
- <?php } if(count($bp_media_messages)){ ?>
248
- <div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div>
249
- <?php } ?>
250
- <table class="form-table ">
251
- <tbody>
252
- <tr valign="top">
253
- <th scope="row"><label for="videos_enabled">Videos</label></th>
254
- <td>
255
- <fieldset>
256
- <legend class="screen-reader-text"><span>Enable Videos</span></legend>
257
- <label for="videos_enabled"><input name="bp_media_options[videos_enabled]" type="checkbox" id="videos_enabled" value="true" <?php global $bp_media_options;checked($bp_media_options['videos_enabled'],true) ?>> (Check to enable video upload functionality)</label>
258
- </fieldset>
259
- </td>
260
- </tr>
261
- <tr valign="top">
262
- <th scope="row"><label for="audio_enabled">Audio</label></th>
263
- <td>
264
- <fieldset>
265
- <legend class="screen-reader-text"><span>Enable Audio</span></legend>
266
- <label for="audio_enabled"><input name="bp_media_options[audio_enabled]" type="checkbox" id="audio_enabled" value="true" <?php checked($bp_media_options['audio_enabled'],true) ?>> (Check to enable audio upload functionality)</label>
267
- </fieldset>
268
- </td>
269
- </tr>
270
- <tr valign="top">
271
- <th scope="row"><label for="images_enabled">Images</label></th>
272
- <td>
273
- <fieldset>
274
- <legend class="screen-reader-text"><span>Enable Images</span></legend>
275
- <label for="images_enabled"><input name="bp_media_options[images_enabled]" type="checkbox" id="images_enabled" value="true" <?php checked($bp_media_options['images_enabled'],true) ?>> (Check to enable images upload functionality)</label>
276
- </fieldset>
277
- </td>
278
- </tr>
279
- <tr valign="top">
280
- <th scope="row"><label for="download_enabled">Download</label></th>
281
- <td>
282
- <fieldset>
283
- <legend class="screen-reader-text"><span>Enable Download</span></legend>
284
- <label for="download_enabled"><input name="bp_media_options[download_enabled]" type="checkbox" id="download_enabled" value="true" <?php checked($bp_media_options['download_enabled'],true) ?>> (Check to enable download functionality)</label>
285
- </fieldset>
286
- </td>
287
- </tr>
288
- </tbody>
289
- </table>
290
-
291
- <?php do_action('bp_media_extension_options'); ?>
292
-
293
- <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p>
294
- <div class="clear"></div><?php
295
- }
296
-
297
- function bp_media_settings_other_options(){ ?>
298
-
299
- <table class="form-table">
300
- <tbody>
301
- <tr valign="top">
302
- <th scope="row"><label for="refresh_media_count">Re-Count Media Entries</label></th>
303
- <td> <fieldset>
304
- <a id="refresh_media_count" href ="?page=bp-media-settings&bp_media_refresh_count=1&wp_nonce=<?php echo wp_create_nonce( 'bp_media_refresh_count' ); ?>" class="button" title="<?php printf(__('It will re-count all media entries of all users and correct any discrepancies.')); ?>">Re-Count</a>
305
- </fieldset>
306
- </td>
307
- </tr>
308
- </tbody>
309
- </table>
310
- <div class="clear"></div>
311
-
312
- <?php }
313
-
314
- function bp_media_settings_options(){
315
- global $bp_media_options;
316
- $bp_media_options = get_site_option('bp_media_options',array(
317
- 'videos_enabled' => true,
318
- 'audio_enabled' => true,
319
- 'images_enabled' => true,
320
- 'download_enabled' => true,
321
- 'remove_linkback' => 1,
322
- ));
323
- ?>
324
- <table class="form-table ">
325
- <tbody>
326
- <tr valign="top">
327
- <th scope="row"><label for="remove_linkback">Spread the word</label></th>
328
- <td>
329
- <fieldset>
330
- <legend class="screen-reader-text"><span>Yes, I want to support BuddyPress Media</span></legend>
331
- <label for="remove_linkback_yes"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_yes" value="2" <?php checked($bp_media_options['remove_linkback'], '2' ); ?>> Yes, I support BuddyPress Media</label>
332
- <br/>
333
- <legend class="screen-reader-text"><span>No, I don't want to support BuddyPress Media</span></legend>
334
- <label for="remove_linkback_no"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_no" value="1" <?php checked($bp_media_options['remove_linkback'], '1' ); ?>> No, I don't support BuddyPress Media</label>
335
- </fieldset>
336
- </td>
337
- </tr>
338
- </tbody>
339
- </table>
340
- <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p>
341
- <div class="clear"></div>
342
- <?php }
343
-
344
-
345
-
346
-
347
- function bp_media_addons_list(){ ?>
348
-
349
- <div class="addon-list">
350
- <ul class="products">
351
-
352
- <li class="product first">
353
- <a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">
354
- <img width="240" height="184" title="BuddyPress - Media Kaltura Add-on" alt="BuddyPress - Media Kaltura Add-on" src="http://cdn.rtcamp.com/files/2012/10/new-buddypress-media-kaltura-logo-240x184.png">
355
- </a>
356
- <h4><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">BuddyPress-Media Kaltura Add-on</a></h4>
357
- <div class="product_desc">
358
- <p>Add support for more video formats using Kaltura video solution.</p>
359
- <p>Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.</p>
360
- </div>
361
- <div class="product_footer">
362
- <span class="price alignleft"><span class="amount">$99</span></span>
363
- <a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=15446"><?php _e('Buy Now', 'bp-media'); ?></a>
364
- <a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-kaltura/" title="BuddyPress Media Kaltura Add-on">Live Demo</a>
365
- </div><!-- .product_footer -->
366
- </li>
367
- <li class="product last">
368
- <a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >
369
- <img width="240" height="184" title="BuddyPress-Media FFMPEG Converter Plugin" alt="BuddyPress-Media FFMPEG Converter Plugin" src="http://cdn.rtcamp.com/files/2012/09/ffmpeg-logo-240x184.png">
370
- </a>
371
- <h4><a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >BuddyPress-Media FFMPEG Add-on</a></h4>
372
- <div class="product_desc">
373
- <p>Add supports for more audio &amp; video formats using open-source <a href="https://github.com/rtCamp/media-node">media-node</a>.</p>
374
- <p>Media node comes with automated setup script for Ubuntu/Debian.</p>
375
- </div>
376
- <div class="product_footer">
377
- <span class="price alignleft"><span class="amount">$49</span></span>
378
- <a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=13677"><?php _e('Buy Now', 'bp-media'); ?></a>
379
- <a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-media" title="BuddyPress Media FFMPEG Add-on">Live Demo</a>
380
- </div><!-- .product_footer -->
381
- </li>
382
-
383
- </ul><!-- .products -->
384
- </div><!-- .addon-list -->
385
-
386
- <?php }
387
-
388
-
389
- function bp_media_support(){ global $current_user; ?>
390
-
391
- <div class="bp-media-support">
392
- <h2><?php _e('Need Help/Support?', 'bp-media');?></h2>
393
- <ul class="support_list">
394
- <li><a href="http://rtcamp.com/buddypress-media/faq/" title="<?php _e('Read FAQ', 'bp-media');?>"><?php _e('Read FAQ', 'bp-media');?></a> </li>
395
- <li><a href="http://rtcamp.com/support/forum/buddypress-media/" title="<?php _e('Free Support Forum', 'bp-media');?>"><?php _e('Free Support Forum', 'bp-media');?></a></li>
396
- <li><a href="https://github.com/rtCamp/buddypress-media/issues/" title="<?php _e('Github Issue Tracker', 'bp-media');?>"><?php _e('Github Issue Tracker', 'bp-media');?> </a> </li>
397
- </ul>
398
- <br/>
399
-
400
- <h2><?php _e('Hire Us!', 'bp-media');?></h2>
401
-
402
- <h4><a href="http://rtcamp.com/contact/?purpose=hire"><?php _e('We are available for customisation and premium support. Get on touch with us. :-)', 'bp-media');?></a></h4>
403
- <!--
404
- <div class="bp-media-form" id="premium-support-form" >
405
- <h4><?php _e('Please fill the form for premium support'); ?></h4>
406
- <ul>
407
- <li>
408
- <label class="bp-media-label" for="ur_name"><?php _e('Your Name:','bp-media');?></label><input class="bp-media-input" id="ur_name" type="text" name="premium_support[ur_name]" value="<?php echo (isset($_REQUEST['premium_support']['ur_name']))? $_REQUEST['premium_support']['ur_name'] : $current_user->user_login; ?>"/>
409
- </li>
410
- <li>
411
- <label class="bp-media-label" for="ur_email"><?php _e('Your Email-Id:','bp-media');?></label><input id="ur_email" class="bp-media-input" type="text" name="premium_support[ur_email]" value="<?php echo (isset($_REQUEST['premium_support']['ur_name']))? $_REQUEST['premium_support']['ur_name'] : get_option('admin_email'); ?>"/>
412
- </li>
413
- <li>
414
- <label class="bp-media-label" for="ur_query"><?php _e('Details:','bp-media');?></label><textarea id="ur_query" class="bp-media-textarea" type="text" name="premium_support[ur_query]"/><?php echo (isset($_REQUEST['premium_support']['ur_query']))? $_REQUEST['premium_support']['ur_query'] : ''; ?></textarea>
415
- </li>
416
- <li>
417
- <label class="bp-media-label" for="ur_budget"><?php _e('Your Budget:','bp-media');?></label><input id="ur_budget" class="bp-media-input" type="text" name="premium_support[ur_budget]" value="<?php echo (isset($_REQUEST['premium_support']['ur_budget']))? $_REQUEST['premium_support']['ur_budget'] : ''; ?>"/>
418
- </li>
419
- <li>
420
- <label class="bp-media-label" for="ur_delivery_date"><?php _e('Expected Delivery Date:','bp-media');?></label><input id="ur_delivery_date" class="bp-media-input" type="text" name="premium_support[ur_delivery_date]" value="<?php echo (isset($_REQUEST['premium_support']['ur_delivery_date']))? $_REQUEST['premium_support']['ur_delivery_date'] : ''; ?>"/>
421
- </li>
422
- </ul>
423
- <p class="submit"><input type="submit" name="premium_form_submit" id="submit" class="button-primary" value="Submit"></p>
424
- </div><!-- .premium-support-form-->
425
- <br/>
426
- </div>
427
-
428
- <?php }
429
-
430
-
431
- /**
432
- * Default BuddyPress Media admin sidebar with metabox styling
433
- *
434
- * @since BP Media 2.0
435
- */
436
- function bp_media_default_admin_sidebar() { ?>
437
-
438
- <div class="rtmetabox postbox" id="branding">
439
- <div class="inside">
440
- <a href="http://rtcamp.com" title="Empowering The Web With WordPress" id="logo"><img src="<?php echo plugins_url( '/img/rtcamp-logo.png', __FILE__ ); ?>" alt="rtCamp" /></a>
441
- <ul id="social">
442
- <li><a href="<?php printf('%s', 'http://www.facebook.com/rtCamp.solutions/'); ?>" title="<?php _e('Become a fan on Facebook', 'bp-media'); ?>" class="bp-media-facebook bp-media-social"><?php _e('Facebook', 'bp-media'); ?></a></li>
443
- <li><a href="<?php printf('%s', 'https://twitter.com/rtcamp/'); ?>" title="<?php _e('Follow us on Twitter', 'bp-media'); ?>" class="bp-media-twitter bp-media-social"><?php _e('Twitter', 'bp-media'); ?></a></li>
444
- <li><a href="<?php printf('%s', 'http://feeds.feedburner.com/rtcamp/'); ?>" title="<?php _e('Subscribe to our feeds', 'bp-media'); ?>" class="bp-media-rss bp-media-social"><?php _e('RSS Feed', 'bp-media'); ?></a></li>
445
- </ul>
446
- </div>
447
- </div>
448
-
449
- <div class="rtmetabox postbox" id="support">
450
-
451
- <h3 class="hndle"><span><?php _e('Need Help?', 'bp-media'); ?></span></h3>
452
- <div class="inside"><p><?php printf(__(' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
453
- <a href="%s">Hire us!</a> To get professional customisation/setup service.', 'bp-media'), 'http://rtcamp.com/support/forum/buddypress-media/','http://rtcamp.com/buddypress-media/hire/'); ?>.</p></div>
454
- </div>
455
-
456
- <div class="rtmetabox postbox" id="donate">
457
-
458
- <h3 class="hndle"><span><?php _e('Donate', 'bp-media'); ?></span></h3>
459
- <span><a href="http://rtcamp.com/donate/" title="Help the development keep going."><img class="bp-media-donation-image" src ="<?php echo plugins_url( '/img/donate.gif', __FILE__ ); ?>" /></a></span>
460
- <div class="inside"><p><?php printf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', 'bp-media')); ?>.</p></div>
461
- </div>
462
-
463
- <div class="rtmetabox postbox" id="bp-media-premium-addons">
464
-
465
- <h3 class="hndle"><span><?php _e('Premium Addons', 'bp-media'); ?></span></h3>
466
- <div class="inside">
467
- <ul>
468
- <li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress Media Kaltura">BPM-Kaltura</a> - add support for Kaltura.com/Kaltura-CE based video conversion support</li>
469
- <li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="BuddyPress Media FFMPEG">BPM-FFMPEG</a> - add FFMEG-based audio/video conversion support</li>
470
- </ul>
471
- <h4><?php printf(__('Are you a developer?','bp-media')) ?></h4>
472
- <p><?php printf(__('If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href="%s">More info!</a>','bp-media'),'http://rtcamp.com/contact/') ?></p></h4>
473
- </div>
474
- </div>
475
-
476
- <div class="rtmetabox postbox" id="bp_media_latest_news">
477
-
478
- <h3 class="hndle"><span><?php _e('Latest News', 'bp-media'); ?></span></h3>
479
- <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
480
- </div><?php
481
- }
482
-
483
-
484
-
485
- /**
486
- * Enqueues the scripts and stylesheets needed for the BuddyPress Media's options page
487
- */
488
- function bp_media_admin_enqueue() {
489
- $current_screen = get_current_screen();
490
- $admin_js = trailingslashit(site_url()).'?bp_media_get_feeds=1';
491
- wp_enqueue_script('bp-media-js',plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
492
- wp_localize_script('bp-media-js','bp_media_news_url',$admin_js);
493
- wp_enqueue_style('bp-media-admin-style', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
494
-
495
- }
496
- add_action('admin_enqueue_scripts', 'bp_media_admin_enqueue');
497
-
498
-
499
-
500
- /**
501
- * Adds a tab for Media settings in the BuddyPress settings page
502
- */
503
- function bp_media_admin_tab() {
504
-
505
- if(current_user_can('manage_options')){
506
- $tabs_html = '';
507
- $idle_class = 'nav-tab';
508
- $active_class = 'nav-tab nav-tab-active';
509
- $tabs = array();
510
-
511
- // Check to see which tab we are on
512
- $tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
513
- /* BP Media */
514
- $tabs[] = array(
515
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
516
- 'title' => __( 'BP Media', 'bp-media' ),
517
- 'name' => __( 'BP Media', 'bp-media' ),
518
- 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
519
- );
520
-
521
- foreach($tabs as $tab){
522
- $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
523
- }
524
- echo $tabs_html;
525
- }
526
- }
527
-
528
- add_action('bp_admin_tabs','bp_media_admin_tab');
529
-
530
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-filters.php DELETED
@@ -1,369 +0,0 @@
1
- <?php
2
- function bp_media_activity_permalink_filter($link, $activity_obj = null) {
3
- global $bp_media_activity_types;
4
- if ($activity_obj != null && in_array($activity_obj->type,$bp_media_activity_types)) {
5
- if($activity_obj->primary_link!=''){
6
- try{
7
- return $activity_obj->primary_link;
8
- }
9
- catch(Exception $e){
10
- return $link;
11
- }
12
- }
13
- }
14
- if ($activity_obj != null && 'activity_comment' == $activity_obj->type) {
15
- global $activities_template;
16
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
17
- $parent = $activity_obj->item_id;
18
- if ($parent) {
19
- try{
20
- if(isset($activities_template->activity_parents[$parent])){
21
- return $activities_template->activity_parents[$parent]->primary_link;
22
- }
23
- else{
24
- $activities = bp_activity_get(array('in' => $parent));
25
- if(isset($activities['activities'][0])){
26
- $activities_template->activity_parents[$parent] = $activities['activities'][0];
27
- return $activities['activities'][0]->primary_link;
28
- }
29
- }
30
- }
31
- catch(Exception $e){
32
- return $link;
33
- }
34
- }
35
- }
36
- return $link;
37
- }
38
- add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
39
-
40
- function bp_media_activity_parent_content_filter($activity_content) {
41
- global $activities_template;
42
- $defaults = array(
43
- 'hide_user' => false
44
- );
45
- if ( !$parent_id = $activities_template->activity->item_id )
46
- return false;
47
- if(!isset($bp_media_hidden_activity_cache[$parent_id])){
48
- $activities = bp_activity_get(array('in' => $parent_id));
49
- if(isset($activities['activities'][0])){
50
- $bp_media_hidden_activity_cache[$parent_id] = $activities['activities'][0];
51
- }
52
- }
53
- if ( empty( $bp_media_hidden_activity_cache[$parent_id] ) )
54
- return false;
55
-
56
- if ( empty( $bp_media_hidden_activity_cache[$parent_id]->content ) )
57
- $content = $bp_media_hidden_activity_cache[$parent_id]->action;
58
- else
59
- $content = $bp_media_hidden_activity_cache[$parent_id]->action . ' ' . $bp_media_hidden_activity_cache[$parent_id]->content;
60
-
61
- // Remove the time since content for backwards compatibility
62
- $content = str_replace( '<span class="time-since">%s</span>', '', $content );
63
-
64
- // Remove images
65
- $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
66
-
67
- return $content;
68
- return $activity_content;
69
- }
70
- //add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter', 1);
71
-
72
- function bp_media_delete_button_handler($link) {
73
- if(bp_current_component()=='media')
74
- $link=str_replace('delete-activity ', 'delete-activity-single ', $link);
75
- return $link;
76
- }
77
- add_filter('bp_get_activity_delete_link','bp_media_delete_button_handler');
78
-
79
- function bp_media_items_count_filter ($title,$nav_item) {
80
- global $bp_media_count;
81
- $bp_media_count = wp_parse_args($bp_media_count,array(
82
- 'images' => 0,
83
- 'videos' => 0,
84
- 'audio' => 0,
85
- 'albums' => 0
86
- ));
87
- switch($nav_item['slug']){
88
- case BP_MEDIA_SLUG :
89
- $count= intval($bp_media_count['images'])+intval($bp_media_count['videos'])+intval($bp_media_count['audio']);
90
- break;
91
- case BP_MEDIA_IMAGES_SLUG:
92
- $count= intval($bp_media_count['images']);
93
- break;
94
- case BP_MEDIA_VIDEOS_SLUG:
95
- $count= intval($bp_media_count['videos']);
96
- break;
97
- case BP_MEDIA_AUDIO_SLUG:
98
- $count= intval($bp_media_count['audio']);
99
- break;
100
- case BP_MEDIA_ALBUMS_SLUG:
101
- $count= intval($bp_media_count['albums']);
102
- break;
103
- }
104
- $count_html=' <span>'. $count.'</span>';
105
- return str_replace('</a>', $count_html.'</a>', $title);
106
- }
107
-
108
- /**
109
- * To hide some activities of multiple uploads
110
- */
111
- function bp_media_activity_query_filter($query){
112
- global $wpdb;
113
- $query = preg_replace('/WHERE/i', 'WHERE a.secondary_item_id!=-999 AND ',$query);
114
- return $query;
115
- }
116
- add_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
117
-
118
- /**
119
- * Added menu under buddypress menu 'my account' in admin bar
120
- *
121
- * @global type $wp_admin_bar
122
- */
123
- function bp_media_my_account_menu() {
124
- global $wp_admin_bar;
125
-
126
- $bp_media_admin_nav = array();
127
-
128
- // Added Main menu for BP Media
129
- $bp_media_admin_nav[] = array(
130
- 'parent' => 'my-account-buddypress',
131
- 'id' => 'my-account-bpmedia',
132
- 'title' => __('Media', 'bp-media'),
133
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
134
- 'meta' => array(
135
- 'class' => 'menupop')
136
- );
137
-
138
- // Uplaod Media
139
- /*$bp_media_admin_nav[] = array(
140
- 'parent' => 'my-account-bpmedia',
141
- 'id' => 'my-account-upload-media',
142
- 'title' => __('Upload Media','bp-media'),
143
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
144
- );*/
145
-
146
- // Photos
147
- $bp_media_admin_nav[] = array(
148
- 'parent' => 'my-account-bpmedia',
149
- 'id' => 'my-account-photos',
150
- 'title' => __('Photos','bp-media'),
151
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG)
152
- );
153
-
154
- // Video
155
- $bp_media_admin_nav[] = array(
156
- 'parent' => 'my-account-bpmedia',
157
- 'id' => 'my-account-videos',
158
- 'title' => __('Videos','bp-media'),
159
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG)
160
- );
161
-
162
- // Audio
163
- $bp_media_admin_nav[] = array(
164
- 'parent' => 'my-account-bpmedia',
165
- 'id' => 'my-account-audio',
166
- 'title' => __('Audio','bp-media'),
167
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG)
168
- );
169
-
170
- // Albums
171
- $bp_media_admin_nav[] = array(
172
- 'parent' => 'my-account-bpmedia',
173
- 'id' => 'my-account-album',
174
- 'title' => __('Albums','bp-media'),
175
- 'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG)
176
- );
177
-
178
- foreach( $bp_media_admin_nav as $admin_menu )
179
- $wp_admin_bar->add_menu( $admin_menu );
180
-
181
- }
182
-
183
- // and we hook our function via wp_before_admin_bar_render
184
- add_action( 'admin_bar_menu', 'bp_media_my_account_menu', 1 );
185
-
186
- /**
187
- * Added menu under buddypress menu 'my account' in admin bar
188
- *
189
- * @global type $wp_admin_bar
190
- */
191
- function bp_media_adminbar_settings_menu() {
192
- global $wp_admin_bar;
193
-
194
- if( current_user_can('manage_options') && is_super_admin() ){
195
-
196
- $bp_media_admin_nav = array();
197
- $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'BP Media', 'admin bar menu group label' ) . '</span>';
198
-
199
- // Added Main menu for BP Media
200
- $bp_media_admin_nav[] = array(
201
- 'id' => 'bp-media-menu',
202
- 'title' => $title,
203
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
204
- 'meta' => array(
205
- 'class' => 'menupop bp-media-settings-menu')
206
- );
207
-
208
- // Settings
209
- $bp_media_admin_nav[] = array(
210
- 'parent' => 'bp-media-menu',
211
- 'id' => 'bp-media-settings',
212
- 'title' => __('Settings','bp-media'),
213
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) )
214
- );
215
-
216
- // Addons
217
- $bp_media_admin_nav[] = array(
218
- 'parent' => 'bp-media-menu',
219
- 'id' => 'my-account-addons',
220
- 'title' => __('Addons','bp-media'),
221
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-addons' ), 'admin.php' ) )
222
- );
223
-
224
- // Support
225
- $bp_media_admin_nav[] = array(
226
- 'parent' => 'bp-media-menu',
227
- 'id' => 'my-account-support',
228
- 'title' => __('Support','bp-media'),
229
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-support' ), 'admin.php' ) )
230
- );
231
-
232
- foreach( $bp_media_admin_nav as $admin_menu )
233
- $wp_admin_bar->add_menu( $admin_menu );
234
- }
235
- }
236
-
237
- // and we hook our function via wp_before_admin_bar_render
238
- add_action( 'wp_before_admin_bar_render', 'bp_media_adminbar_settings_menu' );
239
-
240
-
241
- /**
242
- * Set BP Media dashboard widget
243
- *
244
- */
245
- //add_action('wp_dashboard_setup','bp_media_dashboard_widgets');
246
-
247
- function bp_media_dashboard_widgets(){
248
- global $wp_meta_boxes;
249
- // Buddypress Media
250
- // if ( is_user_admin() )
251
- wp_add_dashboard_widget( 'dashboard_media_widget', __( 'BuddPress Media' ), 'bp_media_dashboard_media' );
252
-
253
- global $wp_meta_boxes;
254
-
255
- // Get the regular dashboard widgets array
256
- // (which has our new widget already but at the end)
257
-
258
- $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
259
-
260
- // Backup and delete our new dashbaord widget from the end of the array
261
-
262
- $example_widget_backup = array('dashboard_media_widget' => $normal_dashboard['dashboard_media_widget']);
263
- unset($normal_dashboard['dashboard_media_widget']);
264
-
265
- // Merge the two arrays together so our widget is at the beginning
266
-
267
- $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
268
-
269
- // Save the sorted array back into the original metaboxes
270
-
271
- $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
272
-
273
- }
274
-
275
- function bp_media_dashboard_media(){
276
-
277
- /* Single user media counts */
278
- $photos_count = bp_media_admin_total_count('photo');
279
- $videos_count = bp_media_admin_total_count('video');
280
- $audio_count = bp_media_admin_total_count('audio');
281
- $albums_count = bp_media_admin_total_count('album');
282
-
283
- /* Group media counts */
284
- $g_photos_count = bp_media_admin_group_total_count('photo');
285
- $g_videos_count = bp_media_admin_group_total_count('video');
286
- $g_audio_count = bp_media_admin_group_total_count('audio');
287
- $g_albums_count = bp_media_admin_group_total_count('album');
288
-
289
- ?>
290
- <div class="bp-media-dashboard">
291
- <h3 class="sub"><?php _e('Users','bp-media');?> </h3>
292
- <div class="table table_user">
293
- <div class=""><span class="media-cnt"><?php echo $photos_count; ?></span><span class="media-label"><?php _e('Total Photos','bp-media'); ?></span></div>
294
- <div class=""><span class="media-cnt"><?php echo $videos_count; ?></span><span class="media-label"><?php _e('Total Videos','bp-media'); ?></span></div>
295
- <div class=""><span class="media-cnt"><?php echo $audio_count; ?></span><span class="media-label"><?php _e('Total Audio','bp-media'); ?></span></div>
296
- <div class=""><span class="media-cnt"><?php echo $albums_count; ?></span><span class="media-label"><?php _e('Total Albums','bp-media'); ?></span></div>
297
- </div><!-- .table_user -->
298
- <h3 class="sub"><?php _e('Groups','bp-media');?> </h3>
299
- <div class="table table_group">
300
-
301
- </div><!-- .table_group -->
302
- </div><!-- .bp-media-dashboard-->
303
-
304
- <?php
305
- }
306
-
307
- function bp_media_admin_total_count($media_type){
308
-
309
- switch($media_type){
310
- case 'photo':
311
- return bp_media_total_count_media('image');
312
-
313
- case 'video':
314
- return bp_media_total_count_media('video');
315
-
316
- case 'audio':
317
- return bp_media_total_count_media('audio');
318
-
319
- case 'album':
320
- return bp_media_total_count_albums();
321
- }
322
- }
323
-
324
- function bp_media_admin_group_total_count($media_type){
325
-
326
- switch($media_type){
327
- case 'photo':
328
- return bp_media_total_count_media('image');
329
-
330
- case 'video':
331
- return bp_media_total_count_media('video');
332
-
333
- case 'audio':
334
- return bp_media_total_count_media('audio');
335
-
336
- case 'album':
337
- return bp_media_total_count_albums();
338
- }
339
- }
340
-
341
-
342
- function bp_media_total_count_media($type){
343
- global $wpdb;
344
-
345
- $query = "SELECT COUNT(*) AS total
346
- FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
347
- WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value > 0 AND ( wp_posts.post_mime_type LIKE '$type%')";
348
-
349
- $result = $wpdb->get_var( ( $query ) );
350
-
351
- if(isset($result )) return $result;
352
- else return false;
353
- }
354
-
355
-
356
- function bp_media_total_count_albums(){
357
- global $wpdb;
358
-
359
- $query = "SELECT COUNT(*) AS total
360
- FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
361
- WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value < 0 ";
362
-
363
- $result = $wpdb->get_var( ( $query ) );
364
-
365
- if(isset($result )) return $result;
366
- else return false;
367
-
368
- }
369
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-functions.php DELETED
@@ -1,265 +0,0 @@
1
- <?php
2
- function bp_media_record_activity($args = '') {
3
- global $bp;
4
- if (!function_exists('bp_activity_add'))
5
- return false;
6
- $defaults = array(
7
- 'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
8
- );
9
- add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags');
10
- $r = wp_parse_args($args, $defaults);
11
- $activity_id = bp_activity_add($r);
12
- return $activity_id;
13
- }
14
-
15
- function bp_media_override_allowed_tags($activity_allowedtags) {
16
- $activity_allowedtags['video'] = array();
17
- $activity_allowedtags['video']['id'] = array();
18
- $activity_allowedtags['video']['class'] = array();
19
- $activity_allowedtags['video']['src'] = array();
20
- $activity_allowedtags['video']['height'] = array();
21
- $activity_allowedtags['video']['width'] = array();
22
- $activity_allowedtags['video']['controls'] = array();
23
- $activity_allowedtags['video']['preload'] = array();
24
- $activity_allowedtags['video']['alt'] = array();
25
- $activity_allowedtags['video']['title'] = array();
26
- $activity_allowedtags['audio'] = array();
27
- $activity_allowedtags['audio']['id'] = array();
28
- $activity_allowedtags['audio']['class'] = array();
29
- $activity_allowedtags['audio']['src'] = array();
30
- $activity_allowedtags['audio']['controls'] = array();
31
- $activity_allowedtags['audio']['preload'] = array();
32
- $activity_allowedtags['audio']['alt'] = array();
33
- $activity_allowedtags['audio']['title'] = array();
34
- $activity_allowedtags['script'] = array();
35
- $activity_allowedtags['script']['type'] = array();
36
- $activity_allowedtags['div'] = array();
37
- $activity_allowedtags['div']['id'] = array();
38
- $activity_allowedtags['div']['class'] = array();
39
- $activity_allowedtags['a'] = array();
40
- $activity_allowedtags['a']['title'] = array();
41
- $activity_allowedtags['a']['href'] = array();
42
- $activity_allowedtags['ul'] = array();
43
- $activity_allowedtags['li'] = array();
44
-
45
- return $activity_allowedtags;
46
- }
47
-
48
- function bp_media_show_formatted_error_message($messages, $type) {
49
- echo '<div id="message" class="' . $type . '">';
50
- if (is_array($messages)) {
51
- foreach ($messages as $key => $message) {
52
- if (is_string($message)) {
53
- echo '<p>' . $message . '</p>';
54
- }
55
- }
56
- } else {
57
- if (is_string($messages)) {
58
- echo '<p>' . $messages . '</p>';
59
- }
60
- }
61
- echo '</div>';
62
- }
63
-
64
- function bp_media_conditional_override_allowed_tags($content, $activity=null) {
65
- global $bp_media_activity_types;
66
- if ($activity != null && in_array($activity->type,$bp_media_activity_types)) {
67
- add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
68
- }
69
- return bp_activity_filter_kses($content);
70
- }
71
-
72
- function bp_media_swap_filters() {
73
- add_filter('bp_get_activity_content_body', 'bp_media_conditional_override_allowed_tags', 1, 2);
74
- remove_filter('bp_get_activity_content_body', 'bp_activity_filter_kses', 1);
75
- }
76
- add_action('bp_init', 'bp_media_swap_filters');
77
-
78
- /**
79
- * Updates the media count of all users.
80
- */
81
- function bp_media_update_count() {
82
- global $wpdb;
83
- $query =
84
- "SELECT
85
- post_author,
86
- SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
87
- SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
88
- SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
89
- SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums,
90
- COUNT(*) as Total
91
- FROM
92
- $wpdb->posts RIGHT JOIN $wpdb->postmeta on wp_postmeta.post_id = wp_posts.id
93
- WHERE
94
- `meta_key` = 'bp-media-key' AND
95
- `meta_value` > 0 AND
96
- ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
97
- GROUP BY post_author";
98
- $result = $wpdb->get_results($query);
99
- if(!is_array($result))
100
- return false;
101
-
102
- foreach ($result as $obj) {
103
-
104
- $count = array(
105
- 'images' => isset($obj->Images)?$obj->Images:0,
106
- 'videos' => isset($obj->Videos)?$obj->Videos:0,
107
- 'audio' => isset($obj->Audio)?$obj->Audio:0,
108
- 'albums'=> isset($obj->Albums)?$obj->Albums:0
109
- );
110
- bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
111
- }
112
- return true;
113
- }
114
-
115
- function bp_media_update_media(){
116
- global $bp_media_current_entry;
117
- if($bp_media_current_entry->update_media(array('description'=> esc_html($_POST['bp_media_description']),'name'=>esc_html($_POST['bp_media_title'])))){
118
- $bp_media_current_entry->update_media_activity();
119
- @setcookie('bp-message', 'The media has been updated' , time() + 60 * 60 * 24, COOKIEPATH);
120
- @setcookie('bp-message-type', 'success' , time() + 60 * 60 * 24, COOKIEPATH);
121
- wp_redirect($bp_media_current_entry->get_url());
122
- exit;
123
- }
124
- else{
125
- @setcookie('bp-message', 'The media update failed' , time() + 60 * 60 * 24, COOKIEPATH);
126
- @setcookie('bp-message-type', 'error' , time() + 60 * 60 * 24, COOKIEPATH);
127
- wp_redirect($bp_media_current_entry->get_edit_url());
128
- exit;
129
- }
130
- }
131
-
132
- function bp_media_check_user() {
133
- if (bp_loggedin_user_id() != bp_displayed_user_id()) {
134
- bp_core_no_access(array(
135
- 'message' => __('You do not have access to this page.', 'buddypress'),
136
- 'root' => bp_displayed_user_domain(),
137
- 'redirect' => false
138
- ));
139
- exit;
140
- }
141
- }
142
-
143
- function bp_media_page_not_exist() {
144
- @setcookie('bp-message', 'The requested url does not exist' , time() + 60 * 60 * 24, COOKIEPATH);
145
- @setcookie('bp-message-type', 'error' , time() + 60 * 60 * 24, COOKIEPATH);
146
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
147
- exit;
148
- }
149
-
150
- /**
151
- * Display feeds from a specified Feed URL
152
- *
153
- * @param string $feed_url The Feed URL.
154
- *
155
- * @since BP Media 2.0
156
- */
157
- function bp_media_get_feeds($feed_url = 'http://rtcamp.com/tag/buddypress/feed/') {
158
- // Get RSS Feed(s)
159
- require_once( ABSPATH . WPINC . '/feed.php' );
160
- $maxitems = 0;
161
- // Get a SimplePie feed object from the specified feed source.
162
- $rss = fetch_feed($feed_url);
163
- if (!is_wp_error($rss)) { // Checks that the object is created correctly
164
- // Figure out how many total items there are, but limit it to 5.
165
- $maxitems = $rss->get_item_quantity(5);
166
-
167
- // Build an array of all the items, starting with element 0 (first element).
168
- $rss_items = $rss->get_items(0, $maxitems);
169
- }
170
- ?>
171
- <ul><?php
172
- if ($maxitems == 0) {
173
- echo '<li>' . __('No items', 'bp-media') . '.</li>';
174
- } else {
175
- // Loop through each feed item and display each item as a hyperlink.
176
- foreach ($rss_items as $item) {
177
- ?>
178
- <li>
179
- <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __('Posted ', 'bp-media') . $item->get_date('j F Y | g:i a'); ?>'><?php echo $item->get_title(); ?></a>
180
- </li><?php
181
- }
182
- }
183
- ?>
184
- </ul><?php
185
- }
186
-
187
- function bp_media_update_album_activity($album,$current_time = true,$delete_media_id = null){
188
- if(!is_object($album)){
189
- $album = new BP_Media_Album($album);
190
- }
191
- $args = array(
192
- 'post_parent' => $album->get_id(),
193
- 'numberposts' => 4,
194
- 'post_type' => 'attachment',
195
- );
196
- if($delete_media_id)
197
- $args['exclude'] = $delete_media_id;
198
- $attachments = get_posts($args);
199
- if(is_array($attachments)){
200
- $content = '<ul>';
201
- foreach($attachments as $media){
202
- $bp_media = new BP_Media_Host_Wordpress($media->ID);
203
- $content .= $bp_media->get_album_activity_content();
204
- }
205
- $content .= '</ul>';
206
- $activity_id = get_post_meta($album->get_id(), 'bp_media_child_activity');
207
- if($activity_id){
208
- $args = array(
209
- 'in' => $activity_id,
210
- );
211
-
212
- $activity = @bp_activity_get($args);
213
- if(isset($activity['activities'][0]->id)){
214
- $args = array(
215
- 'content' => $content,
216
- 'id' => $activity_id,
217
- 'type' => 'album_updated',
218
- 'user_id' => $activity['activities'][0]->user_id,
219
- 'action' => apply_filters( 'bp_media_filter_album_updated', sprintf( __( '%1$s added new media in album %2$s', 'bp-media'), bp_core_get_userlink( $activity['activities'][0]->user_id ), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>' ) ),
220
- 'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
221
- 'primary_link' => $activity['activities'][0]->primary_link,
222
- 'item_id' => $activity['activities'][0]->item_id,
223
- 'secondary_item_id' => $activity['activities'][0]->secondary_item_id,
224
- 'recorded_time' => $current_time? bp_core_current_time(): $activity['activities'][0]->date_recorded,
225
- 'hide_sitewide' => $activity['activities'][0]->hide_sitewide
226
- );
227
- bp_media_record_activity($args);
228
- }
229
- }
230
- }
231
- }
232
-
233
- function bp_media_wp_comment_form_mod() {
234
- global $bp_media_current_entry;
235
- echo '<input type="hidden" name="redirect_to" value="'.$bp_media_current_entry->get_url().'">' ;
236
- }
237
-
238
- function implement_featured_ajax() {
239
- if(isset($_POST['post_id'])) {
240
- if(isset($_POST['post_date']) && $_POST['remove_featured'] == 0){
241
- update_post_meta($_POST['post_id'], 'featured', date('Y-m-d H:i:s', strtotime($_POST['post_date'])) );
242
- } else {
243
- update_post_meta($_POST['post_id'], 'featured', FALSE);
244
- }
245
- die(1);
246
- }
247
- }
248
- add_action('wp_ajax_my_featured_action', 'implement_featured_ajax');
249
- add_action('wp_ajax_nopriv_my_featured_action', 'implement_featured_ajax');
250
-
251
- /**
252
- * Redirects the user to the location given in the parameter as well as set the message
253
- * and context of redirect
254
- *
255
- * @param $location String The URL to redirect to
256
- * @param $message String The message to show on the page where redirected
257
- * @param $type String Type of message(updated, success, error, warning), works only if message is set
258
- * @param $status String The HTTP status header for the redirection page.
259
- */
260
- function bp_media_redirect($location,$message = '',$type='updated',$status='302'){
261
- if($message!='')
262
- bp_core_add_message( $message, 'error' );
263
- bp_core_redirect($location, $status);
264
- }
265
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-groups-actions.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Called on bp_init by screen functions
5
- *
6
- * @uses global $bp, $bp_media_query
7
- *
8
- * @since BP Media 2.0
9
- */
10
- function bp_media_groups_set_query() {
11
- global $bp, $bp_media_query,$bp_media_posts_per_page;
12
- if(isset($bp->current_action)&&$bp->current_action==BP_MEDIA_SLUG){
13
- if(bp_action_variable(0)){
14
- switch (bp_action_variable(0)) {
15
- case BP_MEDIA_IMAGES_SLUG:
16
- $type = 'image';
17
- break;
18
- case BP_MEDIA_AUDIO_SLUG:
19
- $type = 'audio';
20
- break;
21
- case BP_MEDIA_VIDEOS_SLUG:
22
- $type = 'video';
23
- break;
24
- default :
25
- $type = null;
26
- }
27
- if (bp_action_variable(1)=='page'&& is_numeric(bp_action_variable(2))) {
28
- $paged = bp_action_variable(2);
29
- } else {
30
- $paged = 1;
31
- }
32
- if ($type) {
33
- $args = array(
34
- 'post_type' => 'attachment',
35
- 'post_status' => 'any',
36
- 'post_mime_type' => $type,
37
- 'meta_key' => 'bp-media-key',
38
- 'meta_value' => -bp_get_current_group_id(),
39
- 'meta_compare' => '=',
40
- 'paged' => $paged,
41
- 'posts_per_page' => $bp_media_posts_per_page
42
- );
43
- $bp_media_query = new WP_Query($args);
44
- }
45
- }
46
- }
47
- }
48
-
49
-
50
- /**
51
- * Called on bp_init by screen functions
52
- * Initializes the albums query for groups
53
- *
54
- * @uses global $bp, $bp_media_albums_query
55
- *
56
- * @since BP Media 2.2
57
- */
58
- function bp_media_groups_albums_set_query() {
59
- global $bp, $bp_media_albums_query;
60
- if (isset($bp->action_variables) && isset($bp->action_variables[1]) && $bp->action_variables[1] == 'page' && isset($bp->action_variables[2]) && is_numeric($bp->action_variables[2])) {
61
- $paged = $bp->action_variables[2];
62
- } else {
63
- $paged = 1;
64
- }
65
-
66
- if (isset($bp->action_variables[0])&&$bp->action_variables[0] == BP_MEDIA_ALBUMS_SLUG) {
67
- $args = array(
68
- 'post_type' => 'bp_media_album',
69
- 'paged' => $paged,
70
- 'meta_key' => 'bp-media-key',
71
- 'meta_value' => -bp_get_current_group_id(),
72
- 'meta_compare' => '='
73
- );
74
- $bp_media_albums_query = new WP_Query($args);
75
- }
76
- }
77
-
78
- function bp_media_groups_activity_create_after_add_media($media,$hidden=false){
79
- if(function_exists('bp_activity_add')){
80
- if(!is_object($media)){
81
- try{
82
- $media = new BP_Media_Host_Wordpress($media);
83
- }catch(exception $e){
84
- return false;
85
- }
86
- }
87
- $args = array(
88
- 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $media->get_author() ), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>' ) ),
89
- 'content' => $media->get_media_activity_content(),
90
- 'primary_link' => $media->get_url(),
91
- 'item_id' => $media->get_id(),
92
- 'type' => 'media_upload',
93
- 'user_id' => $media->get_author()
94
- );
95
- $hidden = apply_filters('bp_media_force_hide_activity',$hidden);
96
- if($hidden){
97
- $args['secondary_item_id'] = -999;
98
- //do_action('bp_media_album_updated',$media->get_album_id());
99
- }
100
- $activity_id = bp_media_record_activity($args);
101
- add_post_meta($media->get_id(),'bp_media_child_activity',$activity_id);
102
- }
103
- }
104
- //add_action('bp_media_groups_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
105
-
106
- function bp_media_groups_redirection_handler(){
107
- global $bp;
108
- echo '<pre>';
109
- var_dump($bp);
110
- echo '</pre>';
111
- die();
112
- }
113
- //add_action('bp_media_init','bp_media_groups_redirection_handler');
114
-
115
- function bp_media_groups_force_hide_activity(){
116
- return true;
117
- }
118
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-groups-loader.php DELETED
@@ -1,333 +0,0 @@
1
- <?php
2
-
3
- global $bp_media_group_sub_nav;
4
- $bp_media_group_sub_nav = array();
5
- class BP_Media_Groups_Extension extends BP_Group_Extension {
6
-
7
- /**
8
- * Constructor for the BP_Group_Extension adding values to the variables defined
9
- *
10
- * @uses global $bp
11
- *
12
- * @since BP Media 2.3
13
- */
14
- function __construct() {
15
- global $bp;
16
- $this->name = BP_MEDIA_LABEL;
17
- $this->slug = BP_MEDIA_SLUG;
18
- $this->create_step_position = 21;
19
- $this->nav_item_position = 31;
20
- }
21
-
22
- function create_screen() {
23
- if ( !bp_is_group_creation_step( $this->slug ) )
24
- return false;
25
- ?>
26
- <h4>Album Creation Control</h4>
27
- <p>Who can create Albums in this group?</p>
28
- <div class="radio">
29
- <label>
30
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" checked="checked" value="all">
31
- <strong>All Group Members</strong>
32
- </label>
33
- <label>
34
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators">
35
- <strong>Group Admins and Mods only</strong>
36
- </label>
37
- <label>
38
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin">
39
- <strong>Group Admin only</strong>
40
- </label>
41
- </div>
42
-
43
- <?php
44
- wp_nonce_field( 'groups_create_save_' . $this->slug );
45
- }
46
-
47
- function create_screen_save() {
48
- global $bp;
49
-
50
- check_admin_referer( 'groups_create_save_' . $this->slug );
51
-
52
- /* Save any details submitted here */
53
- if(isset($_POST['bp_album_creation_control'])&&$_POST['bp_album_creation_control']!='')
54
- groups_update_groupmeta( $bp->groups->new_group_id, 'bp_media_group_control_level', $_POST['bp_album_creation_control'] );
55
- }
56
-
57
- function edit_screen() {
58
- if ( !bp_is_group_admin_screen( $this->slug ) )
59
- return false;
60
- $current_level = groups_get_groupmeta(bp_get_current_group_id(),'bp_media_group_control_level');
61
- ?>
62
-
63
- <h4>Album Creation Control</h4>
64
- <p>Who can create Albums in this group?</p>
65
- <div class="radio">
66
- <label>
67
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="all"<?php checked($current_level, 'all', true) ?>>
68
- <strong>All Group Members</strong>
69
- </label>
70
- <label>
71
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators" <?php checked($current_level, 'moderators', true) ?>>
72
- <strong>Group Admins and Mods only</strong>
73
- </label>
74
- <label>
75
- <input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin" <?php checked($current_level, 'admin', true) ?>>
76
- <strong>Group Admin only</strong>
77
- </label>
78
- </div>
79
- <hr>
80
- <input type="submit" name="save" value="Save Changes" />
81
- <?php
82
- wp_nonce_field( 'groups_edit_save_' . $this->slug );
83
- }
84
-
85
- function edit_screen_save() {
86
- global $bp;
87
-
88
- if ( !isset( $_POST['save'] ) )
89
- return false;
90
-
91
- check_admin_referer( 'groups_edit_save_' . $this->slug );
92
-
93
- if(isset($_POST['bp_album_creation_control'])&&$_POST['bp_album_creation_control']!='')
94
- $success = groups_update_groupmeta(bp_get_current_group_id(), 'bp_media_group_control_level', $_POST['bp_album_creation_control'] );
95
- else
96
- $success = false;
97
-
98
- /* To post an error/success message to the screen, use the following */
99
- if ( !$success )
100
- bp_core_add_message( __( 'There was an error saving, please try again', 'buddypress' ), 'error' );
101
- else
102
- bp_core_add_message( __( 'Settings saved successfully', 'buddypress' ) );
103
-
104
- bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/' . $this->slug );
105
- }
106
-
107
- /**
108
- * The display method for the extension
109
- *
110
- * @since BP Media 2.3
111
- */
112
- function display() {
113
- bp_media_groups_display_screen();
114
- }
115
-
116
-
117
- function widget_display() { ?>
118
- <div class="info-group">
119
- <h4><?php echo esc_attr( $this->name ) ?></h4>
120
- <p>
121
- You could display a small snippet of information from your group extension here. It will show on the group
122
- home screen.
123
- </p>
124
- </div>
125
- <?php
126
- }
127
- }
128
- bp_register_group_extension( 'BP_Media_Groups_Extension' );
129
-
130
- /**
131
- * Handles the custom navigation structure of the BuddyPress Group Extension Media
132
- *
133
- * @uses global $bp
134
- *
135
- * @since BP Media 2.3
136
- */
137
- function bp_media_groups_custom_nav(){
138
- global $bp;
139
- $current_group = isset($bp->groups->current_group->slug)?$bp->groups->current_group->slug:null;
140
- if(!$current_group)
141
- return;
142
- if(!(isset($bp->bp_options_nav[$current_group])&& is_array($bp->bp_options_nav[$current_group])))
143
- return;
144
-
145
- /** This line might break a thing or two in custom themes and widgets */
146
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
147
-
148
- foreach ($bp->bp_options_nav[$current_group] as $key => $nav_item) {
149
- switch($nav_item['slug']){
150
- case BP_MEDIA_IMAGES_SLUG:
151
- case BP_MEDIA_VIDEOS_SLUG:
152
- case BP_MEDIA_AUDIO_SLUG:
153
- case BP_MEDIA_ALBUMS_SLUG:
154
- unset($bp->bp_options_nav[$current_group][$key]);
155
-
156
- }
157
- switch($bp->current_action){
158
- case BP_MEDIA_IMAGES_SLUG:
159
- case BP_MEDIA_VIDEOS_SLUG:
160
- case BP_MEDIA_AUDIO_SLUG:
161
- case BP_MEDIA_ALBUMS_SLUG:
162
- $count = count($bp->action_variables);
163
- for ($i = $count; $i > 0; $i--) {
164
- $bp->action_variables[$i] = $bp->action_variables[$i - 1];
165
- }
166
- $bp->action_variables[0] = $bp->current_action;
167
- $bp->current_action = BP_MEDIA_SLUG;
168
- }
169
- }
170
- }
171
- add_action('bp_actions','bp_media_groups_custom_nav',999);
172
-
173
- /**
174
- * This loop creates dummy classes for images, videos, audio and albums so that the url structuring
175
- * can be uniform as it is in the members section.
176
- */
177
- foreach(array('IMAGES','VIDEOS','AUDIO','ALBUMS') as $item){
178
- eval('
179
- class BP_Media_Group_Extension_'.constant('BP_MEDIA_'.$item.'_SLUG').' extends BP_Group_Extension{
180
- var $enable_edit_item = false;
181
- var $enable_create_step = false;
182
- function __construct(){
183
- $this->name = BP_MEDIA_'.$item.'_LABEL;
184
- $this->slug = BP_MEDIA_'.$item.'_SLUG;
185
- $enable_create_step = false;
186
- $enable_edit_item = false;
187
- }
188
- function display(){bp_media_groups_display_screen();}
189
- function widget_display(){}
190
- }
191
- bp_register_group_extension("BP_Media_Group_Extension_'.constant('BP_MEDIA_'.$item.'_SLUG').'" );
192
- ');
193
- }
194
-
195
- /**
196
- * Adds the current group id as parameter for plupload
197
- *
198
- * @param Array $multipart_params Array of Multipart Parameters to be passed on to plupload script
199
- *
200
- * @since BP Media 2.3
201
- */
202
- function bp_media_groups_multipart_params_handler($multipart_params){
203
- if(is_array($multipart_params)){
204
- global $bp;
205
- if(isset($bp->current_action)&&$bp->current_action==BP_MEDIA_SLUG
206
- &&isset($bp->action_variables)&&empty($bp->action_variables)
207
- &&isset($bp->current_component)&&$bp->current_component=='groups'
208
- &&isset($bp->groups->current_group->id)){
209
- $multipart_params['bp_media_group_id']=$bp->groups->current_group->id;
210
- }
211
- }
212
- return $multipart_params;
213
- }
214
- add_filter('bp_media_multipart_params_filter','bp_media_groups_multipart_params_handler');
215
-
216
- /**
217
- * Displays the navigation available to the group media tab for the
218
- * logged in user.
219
- *
220
- * @uses $bp Global Variable set by BuddyPress
221
- *
222
- * @since BP Media 2.3
223
- */
224
- function bp_media_groups_display_navigation_menu(){
225
- global $bp;
226
-
227
- if(!isset($bp->current_action)||$bp->current_action!=BP_MEDIA_SLUG)
228
- return false;
229
- $current_tab = bp_media_groups_can_upload()?BP_MEDIA_UPLOAD_SLUG:BP_MEDIA_IMAGES_SLUG;
230
- if(isset($bp->action_variables[0])){
231
- $current_tab = $bp->action_variables[0];
232
- }
233
-
234
- if(bp_media_groups_can_upload()){
235
- $bp_media_nav[BP_MEDIA_UPLOAD_SLUG] = array(
236
- 'url' => trailingslashit(bp_get_group_permalink( $bp->groups->current_group )).BP_MEDIA_SLUG,
237
- 'label' => BP_MEDIA_UPLOAD_LABEL,
238
- );
239
- }
240
- else{
241
- $bp_media_nav = array();
242
- }
243
-
244
- foreach(array('IMAGES','VIDEOS','AUDIO','ALBUMS') as $type){
245
- $bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array(
246
- 'url' => trailingslashit(bp_get_group_permalink( $bp->groups->current_group )).constant('BP_MEDIA_' . $type . '_SLUG'),
247
- 'label' => constant('BP_MEDIA_' . $type . '_LABEL'),
248
- );
249
- }
250
-
251
- /** This variable will be used to display the tabs in group component */
252
- $bp_media_group_tabs = apply_filters('bp_media_group_tabs', $bp_media_nav,$current_tab);
253
- ?>
254
- <div class="item-list-tabs no-ajax bp-media-group-navigation" id="subnav">
255
- <ul>
256
- <?php
257
- foreach($bp_media_group_tabs as $tab_slug=>$tab_info){
258
- echo '<li id="'.$tab_slug.'-group-li" '.($current_tab==$tab_slug?'class="current selected"':'').'><a id="'.$tab_slug.'" href="'.$tab_info['url'].'" title="'.$tab_info['label'].'">'.$tab_info['label'].'</a></li>';
259
- }
260
- ?>
261
- </ul>
262
- </div>
263
- <?php
264
- }
265
-
266
- /**
267
- * Checks whether the current logged in user has the ability to upload on
268
- * the given group or not
269
- *
270
- * @since BP Media 2.3
271
- */
272
- function bp_media_groups_can_upload(){
273
- /** @todo Implementation Pending */
274
- global $bp;
275
- if(isset($bp->loggedin_user->id)&&is_numeric($bp->loggedin_user->id)){
276
- return groups_is_user_member($bp->loggedin_user->id, bp_get_current_group_id());
277
- }
278
- else{
279
- return false;
280
- }
281
-
282
- return true;
283
- }
284
-
285
- /**
286
- * Adds the Media Settings menu for groups in the admin bar
287
- *
288
- * @uses global $bp,$wp_admin_bar
289
- *
290
- * @since BP Media 2.3
291
- */
292
- function bp_media_groups_adminbar(){
293
- global $wp_admin_bar, $bp;
294
- $wp_admin_bar->add_menu( array(
295
- 'parent' => $bp->group_admin_menu_id,
296
- 'id' => 'bp-media-group',
297
- 'title' => __( 'Media Settings', 'buddypress' ),
298
- 'href' => bp_get_groups_action_link( 'admin/media' )
299
- ) );
300
- }
301
- //add_action('admin_bar_menu','bp_media_groups_adminbar',99);
302
- /* This will need some handling for checking if its a single group page or not, also whether the person can
303
- * edit media settings or not
304
- */
305
-
306
- /**
307
- * Checks whether a user can create an album in the given group or not
308
- *
309
- * @param string $group_id The group id to check against
310
- * @param string $user_id The user to be checked for permission
311
- *
312
- * @return boolean True if the user can create an album in the group, false if not
313
- */
314
- function bp_media_groups_user_can_create_album($group_id, $user_id = 0){
315
- if($user_id == 0)
316
- $user_id = get_current_user_id ();
317
- $current_level = groups_get_groupmeta($group_id,'bp_media_group_control_level');
318
- switch($current_level){
319
- case 'all':
320
- return groups_is_user_member($user_id, $group_id)||groups_is_user_mod($user_id, $group_id)||groups_is_user_admin($user_id, $group_id);
321
- break;
322
- case 'moderators':
323
- return groups_is_user_mod($user_id, $group_id)||groups_is_user_admin($user_id, $group_id);
324
- break;
325
- case 'admin':
326
- return groups_is_user_admin($user_id, $group_id);
327
- break;
328
- default :
329
- return groups_is_user_admin($user_id, $group_id);
330
- }
331
- return false;
332
- }
333
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-groups-screens.php DELETED
@@ -1,172 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Displays the Video, Audio, Image, Album and Upload screens
5
- *
6
- * @uses global $bp_media_group_sub_nav, $bp
7
- *
8
- * @since BP Media 2.3
9
- */
10
- function bp_media_groups_display_screen(){
11
- global $bp_media_group_sub_nav,$bp;
12
- bp_media_groups_set_query();
13
- bp_media_groups_display_navigation_menu();
14
- if(bp_action_variable(0)){
15
- switch(bp_action_variable(0)){
16
- case BP_MEDIA_IMAGES_SLUG:
17
- bp_media_groups_images_screen();
18
- break;
19
- case BP_MEDIA_VIDEOS_SLUG:
20
- if(isset($bp->action_variables[1])){
21
- switch($bp->action_variables[1]){
22
- case BP_MEDIA_VIDEOS_EDIT_SLUG:
23
- //Edit screen for image
24
- break;
25
- case BP_MEDIA_DELETE_SLUG:
26
- //Delete function for media file
27
- break;
28
- default:
29
- if(intval(bp_action_variable(1))>0){
30
- global $bp_media_current_entry;
31
- try {
32
- $bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
33
- if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
34
- throw new Exception(__('Sorry, the requested media does not belong to the group'));
35
- } catch (Exception $e) {
36
- /** Error Handling when media not present or not belong to the group */
37
- echo '<div id="message" class="error">';
38
- echo '<p>'.$e->getMessage().'</p>';
39
- echo '</div>';
40
- return;
41
- }
42
- bp_media_videos_entry_screen_content();
43
- break;
44
- }
45
- else{
46
- /** @todo display 404 */
47
- }
48
- }
49
- }else{
50
- bp_media_videos_screen_content();
51
- }
52
- break;
53
- case BP_MEDIA_AUDIO_SLUG:
54
- if(isset($bp->action_variables[1])){
55
- switch($bp->action_variables[1]){
56
- case BP_MEDIA_AUDIO_EDIT_SLUG:
57
- //Edit screen for image
58
- break;
59
- case BP_MEDIA_DELETE_SLUG:
60
- //Delete function for media file
61
- break;
62
- default:
63
- if(intval(bp_action_variable(1))>0){
64
- global $bp_media_current_entry;
65
- try {
66
- $bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
67
- if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
68
- throw new Exception(__('Sorry, the requested media does not belong to the group'));
69
- } catch (Exception $e) {
70
- /** Error Handling when media not present or not belong to the group */
71
- echo '<div id="message" class="error">';
72
- echo '<p>'.$e->getMessage().'</p>';
73
- echo '</div>';
74
- return;
75
- }
76
- bp_media_audio_entry_screen_content();
77
- break;
78
- }
79
- else{
80
- /** @todo display 404 */
81
- }
82
- }
83
- }else{
84
- bp_media_audio_screen_content();
85
- }
86
- break;
87
- case BP_MEDIA_ALBUMS_SLUG:
88
- if(isset($bp->action_variables[1])){
89
- switch($bp->action_variables[1]){
90
- case BP_MEDIA_ALBUMS_EDIT_SLUG:
91
- //Edit screen for image
92
- break;
93
- case BP_MEDIA_DELETE_SLUG:
94
- //Delete function for media file
95
- break;
96
- default:
97
- if(intval(bp_action_variable(1))>0){
98
- global $bp_media_current_album;
99
- try {
100
- $bp_media_current_album = new BP_Media_Host_Wordpress(bp_action_variable(1));
101
- if($bp_media_current_album->get_group_id()!= bp_get_current_group_id())
102
- throw new Exception(__('Sorry, the requested album does not belong to the group'));
103
- } catch (Exception $e) {
104
- /** Error Handling when media not present or not belong to the group */
105
- echo '<div id="message" class="error">';
106
- echo '<p>'.$e->getMessage().'</p>';
107
- echo '</div>';
108
- return;
109
- }
110
- bp_media_albums_entry_screen_content();
111
- break;
112
- }
113
- else{
114
- /** @todo display 404 */
115
- }
116
- }
117
- }else{
118
- bp_media_groups_albums_set_query();
119
- bp_media_albums_screen_content();
120
- }
121
- break;
122
- default:
123
- /** @todo Error is to be displayed for 404 */
124
- }
125
- }
126
- else{
127
- if(bp_media_groups_can_upload())
128
- bp_media_upload_screen_content();
129
- else{
130
- $bp->action_variables[0] = BP_MEDIA_IMAGES_SLUG;
131
- bp_media_groups_set_query();
132
- bp_media_groups_images_screen();
133
- }
134
- }
135
- }
136
-
137
- function bp_media_groups_images_screen(){
138
- global $bp_media_current_entry;
139
- if(bp_action_variable(1)){
140
- switch(bp_action_variable(1)){
141
- case BP_MEDIA_IMAGES_EDIT_SLUG:
142
- //Edit screen for image
143
- break;
144
- case BP_MEDIA_DELETE_SLUG:
145
- //Delete function for media file
146
- break;
147
- default:
148
- if(intval(bp_action_variable(1))>0){
149
- global $bp_media_current_entry;
150
- try {
151
- $bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
152
- if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
153
- throw new Exception(__('Sorry, the requested media does not belong to the group'));
154
- } catch (Exception $e) {
155
- /** Error Handling when media not present or not belong to the group */
156
- echo '<div id="message" class="error">';
157
- echo '<p>'.$e->getMessage().'</p>';
158
- echo '</div>';
159
- return;
160
- }
161
- bp_media_images_entry_screen_content();
162
- break;
163
- }
164
- else{
165
- /** @todo display 404 */
166
- }
167
- }
168
- }else{
169
- bp_media_images_screen_content();
170
- }
171
- }
172
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-loader.php DELETED
@@ -1,537 +0,0 @@
1
- <?php
2
- /**
3
- * The Main loader file of BuddyPress Media Plugin
4
- */
5
- /* Exit if accessed directlly. */
6
-
7
- if (!defined('ABSPATH'))
8
- exit;
9
-
10
- /* Slug Constants */
11
- define('BP_MEDIA_SLUG', 'media');
12
- define('BP_MEDIA_UPLOAD_SLUG', 'upload');
13
- define('BP_MEDIA_DELETE_SLUG', 'delete');
14
-
15
- define('BP_MEDIA_IMAGES_SLUG', 'photos');
16
- define('BP_MEDIA_IMAGES_ENTRY_SLUG', 'view');
17
- define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit');
18
-
19
- define('BP_MEDIA_VIDEOS_SLUG', 'videos');
20
- define('BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch');
21
- define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit');
22
-
23
- define('BP_MEDIA_AUDIO_SLUG', 'music');
24
- define('BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen');
25
- define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit');
26
-
27
- define('BP_MEDIA_ALBUMS_SLUG', 'albums');
28
- define('BP_MEDIA_ALBUMS_ENTRY_SLUG', 'list');
29
- define('BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit');
30
-
31
- /* Label Constants(need to be translatable) */
32
- define('BP_MEDIA_LABEL', __('Media', 'bp-media'));
33
- define('BP_MEDIA_LABEL_SINGULAR', __('Media', 'bp-media'));
34
- define('BP_MEDIA_IMAGES_LABEL', __('Photos', 'bp-media'));
35
- define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('Photo', 'bp-media'));
36
- define('BP_MEDIA_VIDEOS_LABEL', __('Videos', 'bp-media'));
37
- define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', 'bp-media'));
38
- define('BP_MEDIA_AUDIO_LABEL', __('Music', 'bp-media'));
39
- define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('Music', 'bp-media'));
40
- define('BP_MEDIA_ALBUMS_LABEL', __('Albums', 'bp-media'));
41
- define('BP_MEDIA_ALBUMS_LABEL_SINGULAR', __('Album', 'bp-media'));
42
- define('BP_MEDIA_UPLOAD_LABEL', __('Upload', 'bp-media'));
43
-
44
- /* Global variable to store the query */
45
- global $bp_media_query;
46
-
47
- /* Global variable to store the albums query */
48
- global $bp_media_albums_query;
49
-
50
- /* Global variable for making distinct ids for different media objects in activity stream */
51
- global $bp_media_counter;
52
- $bp_media_counter = 0;
53
-
54
- /* Global variable storing the count of the media files displayed user has */
55
- global $bp_media_count;
56
- $bp_media_count=null;
57
-
58
- /* Global variable for various display sizes */
59
- global $bp_media_default_sizes;
60
- $bp_media_default_sizes = array(
61
- 'activity_image' => array(
62
- 'width' => 320,
63
- 'height' => 240
64
- ),
65
- 'activity_video' => array(
66
- 'width' => 320,
67
- 'height' => 240
68
- ),
69
- 'activity_audio' => array(
70
- 'width' => 320,
71
- ),
72
- 'single_image' => array(
73
- 'width' => 800,
74
- 'height' => 0
75
- ),
76
- 'single_video' => array(
77
- 'width' => 640,
78
- 'height' => 480
79
- ),
80
- 'single_audio' => array(
81
- 'width' => 640,
82
- ),
83
- );
84
-
85
- /* Global variable to store various excerpt sizes */
86
- global $bp_media_default_excerpts;
87
- $bp_media_default_excerpts=array(
88
- 'single_entry_title' => 100,
89
- 'single_entry_description' => 500,
90
- 'activity_entry_title' => 50,
91
- 'activity_entry_description'=> 500
92
- );
93
-
94
- global $bp_media_options;
95
- $bp_media_options = get_site_option('bp_media_options',array(
96
- 'videos_enabled' => true,
97
- 'audio_enabled' => true,
98
- 'images_enabled' => true,
99
- 'download_enabled' => true
100
- ));
101
-
102
- global $bp_media_posts_per_page;
103
- $bp_media_posts_per_page = 10;
104
-
105
- global $bp_media_activity_types;
106
- $bp_media_activity_types = array('media_upload','album_updated','album_created');
107
-
108
- global $bp_media_hidden_activity_cache;
109
- $bp_media_hidden_activity_cache = array();
110
-
111
- /* To set the language according to the locale selected and availability of the language file. */
112
- if (file_exists(BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo'))
113
- load_textdomain('bp-media', BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo');
114
-
115
- /**
116
- * BP Media Class, extends BP_Component
117
- *
118
- * @see BP_Component
119
- *
120
- * @since BP Media 2.0
121
- */
122
- class BP_Media_Component extends BP_Component {
123
-
124
- /**
125
- * Hold the messages generated during initialization process and will be shown on the screen functions
126
- *
127
- * @since BP Media 2.0
128
- */
129
- var $messages = array(
130
- 'error' => array(),
131
- 'info' => array(),
132
- 'updated' => array()
133
- );
134
-
135
-
136
- /**
137
- * Constructor for the BuddyPress Media
138
- *
139
- * @since BP Media 2.0
140
- */
141
- function __construct() {
142
- global $bp;
143
- parent::start(BP_MEDIA_SLUG, BP_MEDIA_LABEL, BP_MEDIA_PLUGIN_DIR);
144
- $this->includes();
145
- $bp->active_components[$this->id] = '1';
146
- add_action('init', array(&$this, 'register_post_types'));
147
- }
148
-
149
- /**
150
- * Includes the files required for the BuddyPress Media and calls the parent class' includes function
151
- *
152
- * @since BP Media 2.0
153
- */
154
- function includes() {
155
- $includes = array(
156
- 'includes/bp-media-screens.php',
157
- 'includes/bp-media-functions.php',
158
- 'includes/bp-media-filters.php',
159
- 'includes/bp-media-template-functions.php',
160
- 'includes/bp-media-actions.php',
161
- 'includes/bp-media-interface.php',
162
- 'includes/bp-media-class-wordpress.php',
163
- 'includes/bp-media-shortcodes.php',
164
- 'includes/bp-media-widgets.php',
165
- 'includes/bp-media-class-album.php',
166
- 'includes/bp-media-groups-loader.php',
167
- 'includes/bp-media-groups-actions.php',
168
- 'includes/bp-media-groups-screens.php'
169
- );
170
- if (is_admin() || is_network_admin()) {
171
- $includes[] = 'includes/bp-media-admin.php';
172
- }
173
- parent::includes($includes);
174
- do_action('bp_media_init');
175
- }
176
-
177
- /**
178
- * Initializes the global variables of the BuddyPress Media and its parent class.
179
- */
180
- function setup_globals() {
181
- global $bp;
182
- $globals = array(
183
- 'slug' => BP_MEDIA_SLUG,
184
- 'root_slug' => isset($bp->pages->{$this->id}->slug) ? $bp->pages->{$this->id}->slug : BP_MEDIA_SLUG,
185
- /*'has_directory' => true, /* Set to false if not required */
186
- 'search_string' => __('Search Media...', 'bp-media'),
187
- );
188
- parent::setup_globals($globals);
189
- }
190
-
191
- function setup_nav() {
192
- /* Add 'Media' to the main navigation */
193
- global $bp;
194
- switch($bp->current_component){
195
- case BP_MEDIA_IMAGES_SLUG:
196
- if(is_numeric($bp->current_action)){
197
- $bp->action_variables[0]=$bp->current_action;
198
- $bp->current_action=BP_MEDIA_IMAGES_ENTRY_SLUG;
199
- }
200
- break;
201
- case BP_MEDIA_AUDIO_SLUG:
202
- if(is_numeric($bp->current_action)){
203
- $bp->action_variables[0]=$bp->current_action;
204
- $bp->current_action=BP_MEDIA_AUDIO_ENTRY_SLUG;
205
- }
206
- break;
207
- case BP_MEDIA_VIDEOS_SLUG:
208
- if(is_numeric($bp->current_action)){
209
- $bp->action_variables[0]=$bp->current_action;
210
- $bp->current_action=BP_MEDIA_VIDEOS_ENTRY_SLUG;
211
- }
212
- break;
213
- case BP_MEDIA_ALBUMS_SLUG:
214
- if(is_numeric($bp->current_action)){
215
- $bp->action_variables[0]=$bp->current_action;
216
- $bp->current_action=BP_MEDIA_ALBUMS_ENTRY_SLUG;
217
- }
218
- break;
219
- }
220
-
221
- if (bp_is_my_profile()) {
222
- $main_nav = array(
223
- 'name' => BP_MEDIA_LABEL,
224
- 'slug' => BP_MEDIA_SLUG,
225
- 'position' => 80,
226
- 'screen_function' => 'bp_media_upload_screen',
227
- 'default_subnav_slug' => BP_MEDIA_UPLOAD_SLUG
228
- );
229
- } else {
230
- $main_nav = array(
231
- 'name' => BP_MEDIA_LABEL,
232
- 'slug' => BP_MEDIA_SLUG,
233
- 'position' => 80,
234
- 'screen_function' => 'bp_media_images_screen',
235
- 'default_subnav_slug' => BP_MEDIA_IMAGES_SLUG
236
- );
237
- }
238
- $sub_nav[] = array(
239
- 'name' => BP_MEDIA_UPLOAD_LABEL,
240
- 'slug' => BP_MEDIA_UPLOAD_SLUG,
241
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
242
- 'parent_slug' => BP_MEDIA_SLUG,
243
- 'screen_function' => 'bp_media_upload_screen',
244
- 'position' => 10,
245
- 'user_has_access' => bp_is_my_profile()
246
- );
247
- parent::setup_nav($main_nav, $sub_nav);
248
-
249
- bp_core_new_nav_item(array(
250
- 'name' => BP_MEDIA_IMAGES_LABEL,
251
- 'slug' => BP_MEDIA_IMAGES_SLUG,
252
- 'screen_function' => 'bp_media_images_screen'
253
- ));
254
-
255
- bp_core_new_subnav_item(array(
256
- 'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
257
- 'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
258
- 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
259
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
260
- 'position' => 90, /* Index of where this nav item should be positioned */
261
- 'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
262
- ));
263
-
264
- bp_core_new_subnav_item(array(
265
- 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
266
- 'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
267
- 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
268
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
269
- 'position' => 90, /* Index of where this nav item should be positioned */
270
- 'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
271
- ));
272
-
273
- bp_core_new_subnav_item(array(
274
- 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
275
- 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
276
- 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
277
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
278
- 'position' => 90, /* Index of where this nav item should be positioned */
279
- 'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
280
- ));
281
-
282
- bp_core_new_subnav_item(array(
283
- 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
284
- 'slug' => 'page', /* URL slug for the nav item */
285
- 'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
286
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
287
- 'position' => 90, /* Index of where this nav item should be positioned */
288
- 'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
289
- ));
290
-
291
-
292
- bp_core_new_nav_item(array(
293
- 'name' => BP_MEDIA_VIDEOS_LABEL,
294
- 'slug' => BP_MEDIA_VIDEOS_SLUG,
295
- 'screen_function' => 'bp_media_videos_screen'
296
- ));
297
-
298
- bp_core_new_subnav_item(array(
299
- 'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
300
- 'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
301
- 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
302
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
303
- 'position' => 90, /* Index of where this nav item should be positioned */
304
- 'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
305
- ));
306
-
307
- bp_core_new_subnav_item(array(
308
- 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
309
- 'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
310
- 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
311
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
312
- 'position' => 90, /* Index of where this nav item should be positioned */
313
- 'screen_function' => 'bp_media_videos_edit_screen', /* The name of the function to run when clicked */
314
- ));
315
-
316
- bp_core_new_subnav_item(array(
317
- 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
318
- 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
319
- 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
320
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
321
- 'position' => 90, /* Index of where this nav item should be positioned */
322
- 'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
323
- ));
324
-
325
- bp_core_new_subnav_item(array(
326
- 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
327
- 'slug' => 'page', /* URL slug for the nav item */
328
- 'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
329
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
330
- 'position' => 90, /* Index of where this nav item should be positioned */
331
- 'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
332
- ));
333
-
334
-
335
- bp_core_new_nav_item(array(
336
- 'name' => BP_MEDIA_AUDIO_LABEL,
337
- 'slug' => BP_MEDIA_AUDIO_SLUG,
338
- 'screen_function' => 'bp_media_audio_screen'
339
- ));
340
-
341
- bp_core_new_subnav_item(array(
342
- 'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
343
- 'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
344
- 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
345
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
346
- 'position' => 90, /* Index of where this nav item should be positioned */
347
- 'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
348
- ));
349
-
350
- bp_core_new_subnav_item(array(
351
- 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
352
- 'slug' => BP_MEDIA_AUDIO_EDIT_SLUG, /* URL slug for the nav item */
353
- 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
354
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
355
- 'position' => 90, /* Index of where this nav item should be positioned */
356
- 'screen_function' => 'bp_media_audio_edit_screen', /* The name of the function to run when clicked */
357
- ));
358
-
359
- bp_core_new_subnav_item(array(
360
- 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
361
- 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
362
- 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
363
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
364
- 'position' => 90, /* Index of where this nav item should be positioned */
365
- 'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
366
- ));
367
-
368
- bp_core_new_subnav_item(array(
369
- 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
370
- 'slug' => 'page', /* URL slug for the nav item */
371
- 'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
372
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
373
- 'position' => 90, /* Index of where this nav item should be positioned */
374
- 'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
375
- ));
376
-
377
-
378
- bp_core_new_nav_item(array(
379
- 'name' => BP_MEDIA_ALBUMS_LABEL,
380
- 'slug' => BP_MEDIA_ALBUMS_SLUG,
381
- 'screen_function' => 'bp_media_albums_screen'
382
- ));
383
-
384
- bp_core_new_subnav_item(array(
385
- 'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
386
- 'slug' => BP_MEDIA_ALBUMS_ENTRY_SLUG, /* URL slug for the nav item */
387
- 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
388
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
389
- 'position' => 90, /* Index of where this nav item should be positioned */
390
- 'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
391
- ));
392
-
393
- bp_core_new_subnav_item(array(
394
- 'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
395
- 'slug' => BP_MEDIA_ALBUMS_EDIT_SLUG, /* URL slug for the nav item */
396
- 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
397
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
398
- 'position' => 90, /* Index of where this nav item should be positioned */
399
- 'screen_function' => 'bp_media_albums_edit_screen', /* The name of the function to run when clicked */
400
- ));
401
-
402
- bp_core_new_subnav_item(array(
403
- 'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
404
- 'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
405
- 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
406
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
407
- 'position' => 90, /* Index of where this nav item should be positioned */
408
- 'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
409
- ));
410
-
411
- bp_core_new_subnav_item(array(
412
- 'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
413
- 'slug' => 'page', /* URL slug for the nav item */
414
- 'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
415
- 'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
416
- 'position' => 90, /* Index of where this nav item should be positioned */
417
- 'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
418
- ));
419
- }
420
-
421
- /**
422
- * Creating a custom post type album for BuddyPress Media
423
- */
424
- function register_post_types() {
425
- $labels = array(
426
- 'name' => __('Albums', 'bp-media'),
427
- 'singular_name' => __('Album', 'bp-media'),
428
- 'add_new' => __('Create', 'bp-media'),
429
- 'add_new_item' => __('Create Album', 'bp-media'),
430
- 'edit_item' => __('Edit Album', 'bp-media'),
431
- 'new_item' => __('New Album', 'bp-media'),
432
- 'all_items' => __('All Albums', 'bp-media'),
433
- 'view_item' => __('View Album', 'bp-media'),
434
- 'search_items' => __('Search Albums', 'bp-media'),
435
- 'not_found' => __('No album found', 'bp-media'),
436
- 'not_found_in_trash' => __('No album found in Trash', 'bp-media'),
437
- 'parent_item_colon' => '',
438
- 'menu_name' => __('Albums', 'bp-media')
439
- );
440
-
441
- $args = array(
442
- 'labels' => $labels,
443
- 'public' => true,
444
- 'publicly_queryable' => true,
445
- 'show_ui' => false,
446
- 'show_in_menu' => false,
447
- 'query_var' => true,
448
- 'capability_type' => 'post',
449
- 'has_archive' => true,
450
- 'hierarchical' => false,
451
- 'menu_position' => null,
452
- 'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'comments' )
453
- );
454
- register_post_type('bp_media_album', $args);
455
-
456
- /* Set up labels for the post type */
457
- $labels = array(
458
- 'name' => __('Media', 'bp-media'),
459
- 'singular' => __('Media', 'bp-media'),
460
- 'add_new' => __('Add New Media', 'bp-media')
461
- );
462
-
463
- /* Set up the argument array for register_post_type() */
464
- $args = array(
465
- 'label' => __('Media', 'bp-media'),
466
- 'labels' => $labels,
467
- 'description' => 'BuddyPress Media\'s Media Files',
468
- 'public' => true,
469
- 'show_ui' => false,
470
- 'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields')
471
- );
472
- register_post_type('bp_media', $args);
473
- parent::register_post_types();
474
- }
475
- }
476
-
477
- function bp_media_load_core_component() {
478
- global $bp;
479
- $bp->{BP_MEDIA_SLUG} = new BP_Media_Component();
480
- }
481
- add_action('bp_loaded', 'bp_media_load_core_component');
482
-
483
- /**
484
- * Function to set the custom navigation system in effect.
485
- */
486
- function bp_media_custom_nav() {
487
- global $bp;
488
- foreach ($bp->bp_nav as $key => $nav_item) {
489
- switch($nav_item['slug']){
490
- case BP_MEDIA_IMAGES_SLUG:
491
- case BP_MEDIA_VIDEOS_SLUG:
492
- case BP_MEDIA_AUDIO_SLUG:
493
- case BP_MEDIA_ALBUMS_SLUG:
494
- $bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
495
- 'name' => $nav_item['name'],
496
- 'link' => (isset($bp->displayed_user->domain) ? $bp->displayed_user->domain : (isset($bp->loggedin_user->domain) ? $bp->loggedin_user->domain : '')) . $nav_item['slug'] . '/',
497
- 'slug' => $nav_item['slug'],
498
- 'css_id' => $nav_item['css_id'],
499
- 'position' => $nav_item['position'],
500
- 'screen_function' => $nav_item['screen_function'],
501
- 'user_has_access' => true,
502
- 'parent_url' => trailingslashit(bp_displayed_user_domain())
503
- );
504
- unset($bp->bp_nav[$key]);
505
- }
506
- switch($bp->current_component){
507
- case BP_MEDIA_IMAGES_SLUG:
508
- case BP_MEDIA_VIDEOS_SLUG:
509
- case BP_MEDIA_AUDIO_SLUG:
510
- case BP_MEDIA_ALBUMS_SLUG:
511
- $count = count($bp->action_variables);
512
- for ($i = $count; $i > 0; $i--) {
513
- $bp->action_variables[$i] = $bp->action_variables[$i - 1];
514
- }
515
- $bp->action_variables[0] = $bp->current_action;
516
- $bp->current_action = $bp->current_component;
517
- $bp->current_component = BP_MEDIA_SLUG;
518
- }
519
- }
520
- }
521
- add_action('bp_setup_nav', 'bp_media_custom_nav', 999);
522
-
523
- function bp_media_thumbnail() {
524
- global $bp_media_default_sizes;
525
- add_image_size('bp_media_activity_image', $bp_media_default_sizes['activity_image']['width'], $bp_media_default_sizes['activity_image']['height'], true);
526
- add_image_size('bp_media_single_image', $bp_media_default_sizes['single_image']['width'], $bp_media_default_sizes['single_image']['height'], true);
527
- }
528
- add_action('after_setup_theme', 'bp_media_thumbnail');
529
-
530
- function bp_media_fetch_feeds() {
531
- if(isset($_GET['bp_media_get_feeds'])&&$_GET['bp_media_get_feeds']=='1'){
532
- bp_media_get_feeds();
533
- die();
534
- }
535
- }
536
- add_action('init','bp_media_fetch_feeds');
537
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-screens.php DELETED
@@ -1,627 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Screens for all the slugs defined in the BuddyPress Media
5
- */
6
-
7
- /* Exit if accessed directlly. */
8
- if (!defined('ABSPATH'))
9
- exit;
10
-
11
- /**
12
- * Screen function for Upload page
13
- */
14
- function bp_media_upload_screen() {
15
- add_action('wp_enqueue_scripts','bp_media_upload_enqueue');
16
- add_action('bp_template_title', 'bp_media_upload_screen_title');
17
- add_action('bp_template_content', 'bp_media_upload_screen_content');
18
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
19
- }
20
-
21
- /**
22
- * Screen function to display upload screen title
23
- */
24
- function bp_media_upload_screen_title() {
25
- _e('Upload Media');
26
- }
27
-
28
- /**
29
- * Screen function to display upload screen content
30
- */
31
- function bp_media_upload_screen_content() {
32
- do_action('bp_media_before_content');
33
- bp_media_show_upload_form_multiple();
34
- do_action('bp_media_after_content');
35
- }
36
-
37
- /**
38
- * Screen function for Images listing page (Default)
39
- */
40
- function bp_media_images_screen() {
41
- global $bp;
42
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
43
- if (isset($bp->action_variables[0])) {
44
- switch ($bp->action_variables[0]) {
45
- case BP_MEDIA_IMAGES_EDIT_SLUG :
46
- bp_media_images_edit_screen();
47
- break;
48
- case BP_MEDIA_IMAGES_ENTRY_SLUG:
49
- global $bp_media_current_entry;
50
- if(!isset($bp->action_variables[1])){
51
- bp_media_page_not_exist();
52
- }
53
- try {
54
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
55
- if($bp_media_current_entry->get_author()!= bp_displayed_user_id())
56
- throw new Exception(__('Sorry, the requested media does not belong to the user'));
57
- } catch (Exception $e) {
58
- /* Send the values to the cookie for page reload display */
59
- if(isset($_COOKIE['bp-message'])&&$_COOKIE['bp-message']!=''){
60
- @setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
61
- @setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
62
- }
63
- else{
64
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
65
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
66
- }
67
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
68
- exit;
69
- }
70
- add_action('bp_template_title', 'bp_media_entry_screen_title');
71
- add_action('bp_template_content', 'bp_media_images_entry_screen_content');
72
- break;
73
- case BP_MEDIA_DELETE_SLUG :
74
- if(!isset($bp->action_variables[1])){
75
- bp_media_page_not_exist();
76
- }
77
- bp_media_entry_delete();
78
- break;
79
- default:
80
- bp_media_set_query();
81
- add_action('bp_template_content', 'bp_media_images_screen_content');
82
- }
83
- } else {
84
- bp_media_set_query();
85
- add_action('bp_template_content', 'bp_media_images_screen_content');
86
- }
87
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
88
- }
89
-
90
- /**
91
- * Screen function to display images screen title
92
- */
93
- function bp_media_images_screen_title() {
94
- _e('Images List Page');
95
- }
96
-
97
- /**
98
- * Screen function to display images screen content
99
- */
100
- function bp_media_images_screen_content() {
101
- global $bp_media_query;
102
- if ($bp_media_query && $bp_media_query->have_posts()):
103
- do_action('bp_media_before_content');
104
- echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
105
- while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
106
- bp_media_the_content();
107
- endwhile;
108
- echo '</ul>';
109
- bp_media_display_show_more();
110
- do_action('bp_media_after_content');
111
- else:
112
- bp_media_show_formatted_error_message(__('Sorry, no images were found.', 'bp-media'), 'info');
113
- endif;
114
- }
115
-
116
- /**
117
- * Screen function for Images Edit page
118
- */
119
- function bp_media_images_edit_screen() {
120
- global $bp_media_current_entry,$bp;
121
- if(!isset($bp->action_variables[1])){
122
- bp_media_page_not_exist();
123
- }
124
- //Creating global bp_media_current_entry for later use
125
- try {
126
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
127
-
128
- } catch (Exception $e) {
129
- /* Send the values to the cookie for page reload display */
130
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
131
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
132
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
133
- exit;
134
- }
135
- bp_media_check_user();
136
-
137
- //For saving the data if the form is submitted
138
- if(array_key_exists('bp_media_title', $_POST)){
139
- bp_media_update_media();
140
- }
141
- add_action('bp_template_title', 'bp_media_images_edit_screen_title');
142
- add_action('bp_template_content', 'bp_media_images_edit_screen_content');
143
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
144
- }
145
-
146
- /**
147
- * Screen function to dipslay edit images screen title
148
- */
149
- function bp_media_images_edit_screen_title() {
150
- _e('Edit Image','bp-media');
151
- }
152
-
153
- /**
154
- * Screen function to display edit image screen content
155
- */
156
- function bp_media_images_edit_screen_content() {
157
- global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
158
- ?>
159
- <form method="post" class="standard-form" id="bp-media-upload-form">
160
- <label for="bp-media-upload-input-title"><?php _e('Image Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" value="<?php echo $bp_media_current_entry->get_title(); ?>" />
161
- <label for="bp-media-upload-input-description"><?php _e('Image Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" value="<?php echo $bp_media_current_entry->get_content(); ?>" />
162
- <div class="submit"><input type="submit" class="auto" value="Update" /><a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="Back to Media File">Back to Media</a></div>
163
- </form>
164
- <?php
165
- }
166
-
167
- /**
168
- * Screen function for Images Entry page
169
- */
170
- function bp_media_images_entry_screen() {
171
- add_action('bp_template_title', 'bp_media_entry_screen_title');
172
- add_action('bp_template_content', 'bp_media_images_entry_screen_content');
173
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
174
- }
175
-
176
- function bp_media_entry_screen_title() {
177
- global $bp_media_current_entry;
178
- /** @var $bp_media_current_entry BP_Media_Host_Wordpress */
179
- if(is_object($bp_media_current_entry))
180
- echo $bp_media_current_entry->get_media_single_title();
181
- }
182
-
183
- function bp_media_images_entry_screen_content() {
184
- global $bp, $bp_media_current_entry,$bp_media_options;
185
- if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
186
- return false;
187
- do_action('bp_media_before_content');
188
- echo '<div class="bp-media-single bp-media-image">';
189
- echo $bp_media_current_entry->get_media_single_content();
190
- echo $bp_media_current_entry->show_comment_form();
191
- echo '</div>';
192
- do_action('bp_media_after_content');
193
- }
194
-
195
- /**
196
- * Screen function for Videos listing page (Default)
197
- */
198
- function bp_media_videos_screen() {
199
- global $bp;
200
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
201
- if (isset($bp->action_variables[0])) {
202
- switch ($bp->action_variables[0]) {
203
- case BP_MEDIA_VIDEOS_EDIT_SLUG :
204
- bp_media_video_edit_screen();
205
- break;
206
- case BP_MEDIA_VIDEOS_ENTRY_SLUG:
207
- global $bp_media_current_entry;
208
- if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
209
- return false;
210
- try {
211
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
212
- } catch (Exception $e) {
213
- /* Send the values to the cookie for page reload display */
214
- @setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
215
- @setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
216
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG));
217
- exit;
218
- }
219
- add_action('bp_template_title', 'bp_media_entry_screen_title');
220
- add_action('bp_template_content', 'bp_media_videos_entry_screen_content');
221
- break;
222
- case BP_MEDIA_DELETE_SLUG :
223
- if(!isset($bp->action_variables[1])){
224
- bp_media_page_not_exist();
225
- }
226
- bp_media_entry_delete();
227
- break;
228
- default:
229
- bp_media_set_query();
230
- add_action('bp_template_content', 'bp_media_videos_screen_content');
231
- }
232
- } else {
233
- bp_media_set_query();
234
- add_action('bp_template_content', 'bp_media_videos_screen_content');
235
- }
236
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
237
- }
238
-
239
- function bp_media_videos_screen_title() {
240
- _e('Videos List Page');
241
- }
242
-
243
- function bp_media_videos_screen_content() {
244
- global $bp_media_query;
245
- if ($bp_media_query && $bp_media_query->have_posts()):
246
- do_action('bp_media_before_content');
247
- echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
248
- while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
249
- bp_media_the_content();
250
- endwhile;
251
- echo '</ul>';
252
- bp_media_display_show_more();
253
- do_action('bp_media_after_content');
254
- else:
255
- bp_media_show_formatted_error_message(__('Sorry, no videos were found.', 'bp-media'), 'info');
256
- endif;
257
- }
258
-
259
- /**
260
- * Screen function for Videos Edit page
261
- */
262
- function bp_media_videos_edit_screen() {
263
- global $bp_media_current_entry,$bp;
264
- if(!isset($bp->action_variables[1])){
265
- bp_media_page_not_exist();
266
- }
267
- //Creating global bp_media_current_entry for later use
268
- try {
269
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
270
- } catch (Exception $e) {
271
- /* Send the values to the cookie for page reload display */
272
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
273
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
274
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
275
- exit;
276
- }
277
- bp_media_check_user();
278
-
279
- //For saving the data if the form is submitted
280
- if(array_key_exists('bp_media_title', $_POST)){
281
- bp_media_update_media();
282
- }
283
- add_action('bp_template_title', 'bp_media_videos_edit_screen_title');
284
- add_action('bp_template_content', 'bp_media_videos_edit_screen_content');
285
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
286
- }
287
-
288
- function bp_media_videos_edit_screen_title() {
289
- _e('Edit Video');
290
- }
291
-
292
- function bp_media_videos_edit_screen_content() {
293
- global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
294
- ?>
295
- <form method="post" class="standard-form" id="bp-media-upload-form">
296
- <label for="bp-media-upload-input-title"><?php _e('Video Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" value="<?php echo $bp_media_current_entry->get_title(); ?>" />
297
- <label for="bp-media-upload-input-description"><?php _e('Video Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" value="<?php echo $bp_media_current_entry->get_content(); ?>" />
298
- <div class="submit"><input type="submit" class="auto" value="Update" /><a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="Back to Media File">Back to Media</a></div>
299
- </form>
300
- <?php
301
- }
302
-
303
- /**
304
- * Screen function for Videos Entry page
305
- */
306
- function bp_media_videos_entry_screen() {
307
- add_action('bp_template_title', 'bp_media_entry_screen_title');
308
- add_action('bp_template_content', 'bp_media_videos_entry_screen_content');
309
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
310
- }
311
-
312
- function bp_media_videos_entry_screen_content() {
313
- global $bp, $bp_media_current_entry, $bp_media_options;
314
- if (!$bp->action_variables[0] == BP_MEDIA_VIDEOS_ENTRY_SLUG)
315
- return false;
316
- do_action('bp_media_before_content');
317
- echo '<div class="bp-media-single bp-media-video">';
318
- echo $bp_media_current_entry->get_media_single_content();
319
- echo $bp_media_current_entry->show_comment_form();
320
- echo '</div>';
321
- do_action('bp_media_after_content');
322
- }
323
-
324
- /**
325
- * Screen function for Audio listing page (Default)
326
- */
327
- function bp_media_audio_screen() {
328
- global $bp;
329
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
330
- if (isset($bp->action_variables[0])) {
331
- switch ($bp->action_variables[0]) {
332
- case BP_MEDIA_AUDIO_EDIT_SLUG :
333
- bp_media_audio_edit_screen();
334
- break;
335
- case BP_MEDIA_AUDIO_ENTRY_SLUG:
336
- global $bp_media_current_entry;
337
- if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
338
- return false;
339
- try {
340
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
341
- } catch (Exception $e) {
342
- /* Send the values to the cookie for page reload display */
343
- @setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
344
- @setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
345
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG));
346
- exit;
347
- }
348
- add_action('bp_template_title', 'bp_media_entry_screen_title');
349
- add_action('bp_template_content', 'bp_media_audio_entry_screen_content');
350
- break;
351
- case BP_MEDIA_DELETE_SLUG :
352
- if(!isset($bp->action_variables[1])){
353
- bp_media_page_not_exist();
354
- }
355
- bp_media_entry_delete();
356
- break;
357
- default:
358
- bp_media_set_query();
359
- add_action('bp_template_content', 'bp_media_audio_screen_content');
360
- }
361
- } else {
362
- bp_media_set_query();
363
- add_action('bp_template_content', 'bp_media_audio_screen_content');
364
- }
365
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
366
- }
367
-
368
- /**
369
- * Screen function to dipslay edit audio screen title
370
- */
371
- function bp_media_audio_screen_title() {
372
- _e('Audio List Page');
373
- }
374
-
375
- /**
376
- * Screen function to dipslay edit audio screen content
377
- */
378
- function bp_media_audio_screen_content() {
379
- global $bp_media_query;
380
- if ($bp_media_query && $bp_media_query->have_posts()):
381
- do_action('bp_media_before_content');
382
- echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
383
- while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
384
- bp_media_the_content();
385
- endwhile;
386
- echo '</ul>';
387
- bp_media_display_show_more();
388
- do_action('bp_media_after_content');
389
- else:
390
- bp_media_show_formatted_error_message(__('Sorry, no audio files were found.', 'bp-media'), 'info');
391
- endif;
392
- }
393
-
394
- /**
395
- * Screen function for Audio Edit page
396
- */
397
- function bp_media_audio_edit_screen() {
398
- global $bp_media_current_entry,$bp;
399
- if(!isset($bp->action_variables[1])){
400
- bp_media_page_not_exist();
401
- }
402
- //Creating global bp_media_current_entry for later use
403
- try {
404
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
405
-
406
- } catch (Exception $e) {
407
- /* Send the values to the cookie for page reload display */
408
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
409
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
410
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
411
- exit;
412
- }
413
- bp_media_check_user();
414
-
415
- //For saving the data if the form is submitted
416
- if(array_key_exists('bp_media_title', $_POST)){
417
- bp_media_update_media();
418
- }
419
- add_action('bp_template_title', 'bp_media_audio_edit_screen_title');
420
- add_action('bp_template_content', 'bp_media_audio_edit_screen_content');
421
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
422
- }
423
-
424
- function bp_media_audio_edit_screen_title() {
425
- _e('Edit Audio');
426
- }
427
-
428
- function bp_media_audio_edit_screen_content() {
429
- global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
430
- ?>
431
- <form method="post" class="standard-form" id="bp-media-upload-form">
432
- <label for="bp-media-upload-input-title"><?php _e('Audio Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" value="<?php echo $bp_media_current_entry->get_title(); ?>" />
433
- <label for="bp-media-upload-input-description"><?php _e('Audio Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" value="<?php echo $bp_media_current_entry->get_content(); ?>" />
434
- <div class="submit"><input type="submit" class="auto" value="Update" /><a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="Back to Media File">Back to Media</a></div>
435
- </form>
436
- <?php
437
- }
438
-
439
- /**
440
- * Screen function for Audio Entry page
441
- */
442
- function bp_media_audio_entry_screen() {
443
- add_action('bp_template_title', 'bp_media_entry_screen_title');
444
- add_action('bp_template_content', 'bp_media_audio_entry_screen_content');
445
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
446
- }
447
-
448
- function bp_media_audio_entry_screen_content() {
449
- global $bp, $bp_media_current_entry, $bp_media_options;
450
- if($bp_media_current_entry==null){
451
- echo 'Entry not found';
452
- }
453
-
454
- if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
455
- return false;
456
- do_action('bp_media_before_content');
457
- echo '<div class="bp-media-single bp-media-audio">';
458
- echo $bp_media_current_entry->get_media_single_content();
459
- echo $bp_media_current_entry->show_comment_form();
460
- echo '</div>';
461
- do_action('bp_media_after_content');
462
- }
463
-
464
- function bp_media_entry_delete() {
465
- global $bp;
466
- if (bp_loggedin_user_id() != bp_displayed_user_id()) {
467
- bp_core_no_access(array(
468
- 'message' => __('You do not have access to this page.', 'buddypress'),
469
- 'root' => bp_displayed_user_domain(),
470
- 'redirect' => false
471
- ));
472
- exit;
473
- }
474
- if(!isset($bp->action_variables[1])){
475
- @setcookie('bp-message', 'The requested url does not exist' , time() + 60 * 60 * 24, COOKIEPATH);
476
- @setcookie('bp-message-type', 'error' , time() + 60 * 60 * 24, COOKIEPATH);
477
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
478
- exit;
479
- }
480
- global $bp_media_current_entry;
481
- try {
482
- $bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
483
- } catch (Exception $e) {
484
- /* Send the values to the cookie for page reload display */
485
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
486
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
487
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
488
- exit;
489
- }
490
- $post_id = $bp_media_current_entry->get_id();
491
- $activity_id=get_post_meta($post_id,'bp_media_child_activity',true);
492
-
493
- bp_activity_delete_by_activity_id($activity_id);
494
- $bp_media_current_entry->delete_media();
495
-
496
- @setcookie('bp-message', __('Media deleted successfully','bp-media'), time() + 60 * 60 * 24, COOKIEPATH);
497
- @setcookie('bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH);
498
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
499
- exit;
500
- }
501
-
502
- /**
503
- * Screen function for Albums listing page (Default)
504
- */
505
- function bp_media_albums_screen() {
506
- global $bp;
507
- if (isset($bp->action_variables[0])) {
508
- switch ($bp->action_variables[0]) {
509
- case BP_MEDIA_ALBUMS_EDIT_SLUG :
510
- bp_media_album_edit_screen();
511
- break;
512
- case BP_MEDIA_ALBUMS_ENTRY_SLUG:
513
- global $bp_media_current_album;
514
- if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
515
- return false;
516
- try {
517
- $bp_media_current_album = new BP_Media_Album($bp->action_variables[1]);
518
- } catch (Exception $e) {
519
- /* Send the values to the cookie for page reload display */
520
- @setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
521
- @setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
522
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_ALBUMS_SLUG));
523
- exit;
524
- }
525
- add_action('bp_template_content', 'bp_media_albums_entry_screen_content');
526
- break;
527
- case BP_MEDIA_DELETE_SLUG :
528
- if(!isset($bp->action_variables[1])){
529
- bp_media_page_not_exist();
530
- }
531
- bp_media_entry_delete();
532
- break;
533
- default:
534
- bp_media_albums_set_query();
535
- add_action('bp_template_content', 'bp_media_albums_screen_content');
536
- }
537
- } else {
538
- bp_media_albums_set_query();
539
- add_action('bp_template_content', 'bp_media_albums_screen_content');
540
- }
541
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
542
- }
543
-
544
- function bp_media_albums_screen_title() {
545
- _e('Albums List Page');
546
- }
547
-
548
- function bp_media_albums_screen_content() {
549
- global $bp_media_albums_query;
550
- if ($bp_media_albums_query && $bp_media_albums_query->have_posts()):
551
- do_action('bp_media_before_content');
552
- echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
553
- while ($bp_media_albums_query->have_posts()) : $bp_media_albums_query->the_post();
554
- bp_media_album_the_content();
555
- endwhile;
556
- echo '</ul>';
557
- bp_media_display_show_more('albums');
558
- do_action('bp_media_after_content');
559
- else:
560
- bp_media_show_formatted_error_message(__('Sorry, no albums were found.', 'bp-media'), 'info');
561
- endif;
562
- }
563
-
564
- /**
565
- * Screen function for Albums Edit page
566
- */
567
- function bp_media_albums_edit_screen() {
568
- global $bp_media_current_album,$bp;
569
- if(!isset($bp->action_variables[1])){
570
- bp_media_page_not_exist();
571
- }
572
- //Creating global bp_media_current_entry for later use
573
- try {
574
- $bp_media_current_album = new BP_Media_Album($bp->action_variables[1]);
575
- } catch (Exception $e) {
576
- /* Send the values to the cookie for page reload display */
577
- @setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
578
- @setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
579
- wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
580
- exit;
581
- }
582
- bp_media_check_user();
583
-
584
- //For saving the data if the form is submitted
585
- if(array_key_exists('bp_media_title', $_POST)){
586
- bp_media_update_media();
587
- }
588
- add_action('bp_template_title', 'bp_media_albums_edit_screen_title');
589
- add_action('bp_template_content', 'bp_media_albums_edit_screen_content');
590
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
591
- }
592
-
593
- function bp_media_albums_edit_screen_title() {
594
- _e('Edit Album');
595
- }
596
-
597
- function bp_media_albums_edit_screen_content() {
598
- global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
599
- ?>
600
- <form method="post" class="standard-form" id="bp-media-upload-form">
601
- <label for="bp-media-upload-input-title"><?php _e('Album Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" value="<?php echo $bp_media_current_entry->get_title(); ?>" />
602
- <label for="bp-media-upload-input-description"><?php _e('Album Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" value="<?php echo $bp_media_current_entry->get_content(); ?>" />
603
- <div class="submit"><input type="submit" class="auto" value="Update" /><a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="Back to Media File">Back to Media</a></div>
604
- </form>
605
- <?php
606
- }
607
-
608
- function bp_media_albums_entry_screen_content() {
609
- global $bp, $bp_media_current_album,$bp_media_query;
610
- if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
611
- return false;
612
- echo '<div class="bp_media_title">'.$bp_media_current_album->get_title().'</div>';
613
- bp_media_albums_set_inner_query($bp_media_current_album->get_id());
614
- if ($bp_media_query && $bp_media_query->have_posts()):
615
- do_action('bp_media_before_content');
616
- echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
617
- while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
618
- bp_media_the_content();
619
- endwhile;
620
- echo '</ul>';
621
- bp_media_display_show_more();
622
- do_action('bp_media_after_content');
623
- else:
624
- bp_media_show_formatted_error_message(__('Sorry, no media items were found in this album.', 'bp-media'), 'info');
625
- endif;
626
- }
627
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-shortcodes.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Shortcode for generating the action of the activity
5
- */
6
- function bp_media_shortcode_action($atts) {
7
- extract(shortcode_atts(array(
8
- 'id' => '0'
9
- ), $atts)
10
- );
11
- try{
12
- $media=new BP_Media_Host_Wordpress($id);
13
- return $media->get_media_activity_action();
14
- }
15
- catch(Exception $e){
16
- return 'Media not present';
17
- }
18
- }
19
- //add_shortcode('bp_media_action', 'bp_media_shortcode_action');
20
-
21
- /**
22
- * Shortcode for generationg the content of the activity
23
- */
24
- function bp_media_shortcode_content($atts) {
25
- extract(shortcode_atts(array(
26
- 'id' => '0'
27
- ), $atts)
28
- );
29
- try{
30
- $media=new BP_Media_Host_Wordpress($id);
31
- return $media->get_media_activity_content();
32
- }
33
- catch(Exception $e){
34
- return 'Media not present';
35
- }
36
- }
37
- //add_shortcode('bp_media_content', 'bp_media_shortcode_content');
38
-
39
- function bp_media_shortcode_url($atts) {
40
- extract(shortcode_atts(array(
41
- 'id' => '0'
42
- ), $atts)
43
- );
44
- try{
45
- $media=new BP_Media_Host_Wordpress($id);
46
- return $media->get_media_activity_url();
47
- }
48
- catch(Exception $e){
49
- return home_url();
50
- }
51
- }
52
- //add_shortcode('bp_media_url','bp_media_shortcode_url');
53
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-template-functions.php DELETED
@@ -1,282 +0,0 @@
1
- <?php
2
- function bp_media_show_upload_form() {
3
- global $bp,$bp_media_default_excerpts,$bp_media_options;
4
- $allowed=array(
5
- 'type'=>array(),
6
- 'accept'=>array()
7
- );
8
- if($bp_media_options['images_enabled']){
9
- $allowed['type'][] = 'image';
10
- $allowed['accept'][] = 'image/*';
11
- }
12
- if($bp_media_options['audio_enabled']){
13
- $allowed['type'][] = 'audio';
14
- $allowed['accept'][] = 'audio/mp3';
15
- }
16
- if($bp_media_options['videos_enabled']){
17
- $allowed['type'][] = 'video';
18
- $allowed['accept'][] = 'video/mp4';
19
- $allowed['accept'][] = 'video/quicktime';
20
- }
21
- $allowed = apply_filters('bp_media_allowed_filter',$allowed);
22
- $accept = implode(',',$allowed['accept']);
23
-
24
- ?>
25
- <form method="post" enctype="multipart/form-data" class="standard-form" id="bp-media-upload-form">
26
- <label for="bp-media-upload-input-title"><?php _e('Media Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" />
27
- <label for="bp-media-upload-input-description"><?php _e('Media Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" />
28
- <label for="bp-media-upload-file"><?php _e('Select Media File', 'bp-media') ?> (Max File Size:<?php echo min(array(ini_get('upload_max_filesize'),ini_get('post_max_size'))); ?> , Allowed types: <?php echo implode(', ',$allowed['type']) ?>)</label><input type="file" name="bp_media_file" id="bp-media-upload-file" accept="<?php echo $accept ?>" />
29
- <input type="hidden" name="action" value="wp_handle_upload" />
30
- <div class="submit"><input type="submit" class="auto" value="Upload" /></div>
31
- </form>
32
- <?php
33
- }
34
-
35
- function bp_media_show_upload_form_multiple() {
36
- global $bp,$bp_media_default_excerpts;
37
- ?>
38
- <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
39
- if(bp_is_current_component('groups')){
40
- $albums = new WP_Query(array(
41
- 'post_type' => 'bp_media_album',
42
- 'posts_per_page'=> -1,
43
- 'meta_key' => 'bp-media-key',
44
- 'meta_value' => -bp_get_current_group_id(),
45
- 'meta_compare' => '='
46
- ));
47
- }
48
- else{
49
- $albums = new WP_Query(array(
50
- 'post_type' => 'bp_media_album',
51
- 'posts_per_page'=> -1,
52
- 'author'=> get_current_user_id()
53
- ));
54
- }
55
- if(isset($albums->posts)&& is_array($albums->posts)&& count($albums->posts)>0){
56
- foreach ($albums->posts as $album){
57
- if($album->post_title == 'Wall Posts')
58
- echo '<option value="'.$album->ID.'" selected="selected">'.$album->post_title.'</option>' ;
59
- else
60
- echo '<option value="'.$album->ID.'">'.$album->post_title.'</option>' ;
61
- };
62
- }else{
63
- $album = new BP_Media_Album();
64
- if(bp_is_current_component('groups')){
65
- $current_group = new BP_Groups_Group(bp_get_current_group_id());
66
- $album->add_album('Wall Posts',$current_group->creator_id , bp_get_current_group_id());
67
- }
68
- else{
69
- $album->add_album('Wall Posts', bp_loggedin_user_id());
70
- }
71
- echo '<option value="'.$album->get_id().'" selected="selected">'.$album->get_title().'</option>' ;
72
- }
73
- ?></select></div>
74
- <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
75
- <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
76
- <div id="drag-drop-area">
77
- <div class="drag-drop-inside">
78
- <p class="drag-drop-info">Drop files here</p>
79
- <p>or</p>
80
- <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Select Files" class="button" /></p>
81
- </div>
82
- </div>
83
- </div>
84
- <div id="bp-media-uploaded-files"></div>
85
- <?php
86
- }
87
-
88
- function bp_media_show_pagination($type = 'top' , $inner = false) {
89
- global $bp, $bp_media_paginated_links, $bp_media_query, $bp_media_albums_query;
90
- switch ($bp->current_action) {
91
- case BP_MEDIA_IMAGES_SLUG :
92
- $current = $bp_media_query->found_posts > 1 ? BP_MEDIA_IMAGES_LABEL : BP_MEDIA_IMAGES_LABEL_SINGULAR;
93
- $current_single = BP_MEDIA_IMAGES_LABEL_SINGULAR;
94
- break;
95
- case BP_MEDIA_VIDEOS_SLUG :
96
- $current = $bp_media_query->found_posts > 1 ? BP_MEDIA_VIDEOS_LABEL : BP_MEDIA_VIDEOS_LABEL_SINGULAR;
97
- $current_single = BP_MEDIA_VIDEOS_LABEL_SINGULAR;
98
- break;
99
- case BP_MEDIA_AUDIO_SLUG :
100
- $current = BP_MEDIA_AUDIO_LABEL;
101
- $current_single = BP_MEDIA_AUDIO_LABEL_SINGULAR;
102
- break;
103
- case BP_MEDIA_ALBUMS_SLUG:
104
- $current = BP_MEDIA_ALBUMS_LABEL;
105
- $current_single = BP_MEDIA_ALBUMS_LABEL_SINGULAR;
106
- break;
107
- default :
108
- $current = BP_MEDIA_LABEL;
109
- $current_single = BP_MEDIA_LABEL_SINGULAR;
110
- }
111
-
112
- if($bp->current_action == BP_MEDIA_ALBUMS_SLUG && !$inner){
113
- $args = array(
114
- 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
115
- 'format' => 'page/%#%',
116
- 'total' => $bp_media_albums_query->max_num_pages,
117
- 'current' => $bp_media_albums_query->query_vars['paged'],
118
- 'type' => 'array',
119
- 'prev_text' => '&larr;',
120
- 'next_text' => '&rarr;',
121
- );
122
- $start_num = intval($bp_media_albums_query->query_vars['posts_per_page'] * ($bp_media_albums_query->query_vars['paged'] - 1)) + 1;
123
- $from_num = $start_num;
124
- $to_num = $start_num + $bp_media_albums_query->post_count - 1;
125
- $total = $bp_media_albums_query->found_posts;
126
- $bp_media_paginated_links = paginate_links($args);
127
- }
128
- else{
129
- if($inner){
130
- $current = BP_MEDIA_LABEL;
131
- $current_single = BP_MEDIA_LABEL_SINGULAR;
132
- $args = array(
133
- 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/'.$bp->action_variables[1]) . '%_%',
134
- 'format' => 'page/%#%',
135
- 'total' => $bp_media_query->max_num_pages,
136
- 'current' => $bp_media_query->query_vars['paged'],
137
- 'type' => 'array',
138
- 'prev_text' => '&larr;',
139
- 'next_text' => '&rarr;',
140
- );
141
- }
142
- else{
143
- $args = array(
144
- 'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
145
- 'format' => 'page/%#%',
146
- 'total' => $bp_media_query->max_num_pages,
147
- 'current' => $bp_media_query->query_vars['paged'],
148
- 'type' => 'array',
149
- 'prev_text' => '&larr;',
150
- 'next_text' => '&rarr;',
151
- );
152
- }
153
- $start_num = intval($bp_media_query->query_vars['posts_per_page'] * ($bp_media_query->query_vars['paged'] - 1)) + 1;
154
- $from_num = $start_num;
155
- $to_num = $start_num + $bp_media_query->post_count - 1;
156
- $total = $bp_media_query->found_posts;
157
- $bp_media_paginated_links = paginate_links($args);
158
- }
159
- ?>
160
- <div id="pag-<?php echo $type; ?>" class="pagination no-ajax">
161
- <div class="pag-count">
162
- Viewing <?php echo $current_single ?> <?php echo $from_num ?> to <?php echo $to_num ?> (of <?php echo $total; ?> <?php echo $current ?>)
163
- </div>
164
- <div class="pagination-links">
165
- <?php if(is_array($bp_media_paginated_links)) : foreach ($bp_media_paginated_links as $link) : ?>
166
- <?php echo $link; ?>
167
- <?php endforeach; endif; ?>
168
- </div>
169
- </div>
170
- <?php
171
- }
172
-
173
- function bp_media_get_permalink($id = 0) {
174
- if (is_object($id))
175
- $media = $id;
176
- else
177
- $media = &get_post($id);
178
- if (empty($media->ID))
179
- return false;
180
- if (!$media->post_type == 'bp_media')
181
- return false;
182
- switch (get_post_meta($media->ID, 'bp_media_type', true)) {
183
- case 'video' :
184
- return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $media->ID);
185
- break;
186
- case 'audio' :
187
- return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $media->ID);
188
- break;
189
- case 'image' :
190
- return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $media->ID);
191
- break;
192
- default :
193
- return false;
194
- }
195
- }
196
-
197
- function bp_media_the_permalink() {
198
- echo apply_filters('bp_media_the_permalink', bp_media_get_permalink());
199
- }
200
-
201
- function bp_media_the_content($id = 0) {
202
- if (is_object($id))
203
- $media = $id;
204
- else
205
- $media = &get_post($id);
206
- if (empty($media->ID))
207
- return false;
208
- if (!$media->post_type == 'bp_media')
209
- return false;
210
- try{
211
- $media = new BP_Media_Host_Wordpress($media->ID);
212
- echo $media->get_media_gallery_content();
213
- }
214
- catch(Exception $e){
215
- echo '';
216
- }
217
- }
218
- function bp_media_album_the_content($id = 0) {
219
- if (is_object($id))
220
- $album = $id;
221
- else
222
- $album = &get_post($id);
223
- if (empty($album->ID))
224
- return false;
225
- if (!$album->post_type == 'bp_media_album')
226
- return false;
227
- try{
228
- $album = new BP_Media_Album($album->ID);
229
- echo $album->get_album_gallery_content();
230
- }
231
- catch(Exception $e){
232
- echo '';
233
- }
234
- }
235
- function bp_media_display_show_more($type='media'){
236
- $showmore = false;
237
- switch($type){
238
- case 'media':
239
- global $bp_media_query;
240
- //found_posts
241
- if(isset($bp_media_query->found_posts)&&$bp_media_query->found_posts>10)
242
- $showmore = true;
243
- break;
244
- case 'albums':
245
- global $bp_media_albums_query;
246
- if(isset($bp_media_query->found_posts)&&$bp_media_query->found_posts>10)
247
- $showmore = true;
248
- break;
249
- }
250
- if($showmore){
251
- echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">Show More</a></div>';
252
- }
253
- }
254
-
255
- function bp_media_show_upload_form_multiple_activity() {
256
- global $bp,$bp_media_default_excerpts;
257
- if($bp->current_component!='activity')
258
- return;
259
- ?>
260
- <div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
261
- $albums = new WP_Query(array(
262
- 'post_type' => 'bp_media_album',
263
- 'posts_per_page'=> -1,
264
- 'author'=> get_current_user_id()
265
- ));
266
- if(isset($albums->posts)&& is_array($albums->posts)&& count($albums->posts)>0){
267
- foreach ($albums->posts as $album){
268
- if($album->post_title == 'Wall Posts')
269
- echo '<option value="'.$album->ID.'" selected="selected">'.$album->post_title.'</option>' ;
270
- else
271
- echo '<option value="'.$album->ID.'">'.$album->post_title.'</option>' ;
272
- };
273
- }?></select></div>
274
- <div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
275
- <div id="bp-media-upload-ui" class="hide-if-no-js drag-drop activity-component">
276
- <p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Add Media" class="button" /></p>
277
- </div>
278
- <div id="bp-media-uploaded-files"></div>
279
- <?php
280
- }
281
-
282
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-upgrade-script.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
-
3
- function bp_media_upgrade_from_1_0_to_2_1(){
4
- global $wpdb;
5
- remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
6
- /* @var $wpdb wpdb */
7
- $wall_posts_album_ids=array();
8
- do{
9
- $media_files = new WP_Query(array(
10
- 'post_type' => 'bp_media',
11
- 'posts_per_page' => 10
12
- ));
13
- $media_files = isset($media_files->posts)?$media_files->posts:null;
14
- if(is_array($media_files)&&count($media_files)){
15
- foreach($media_files as $media_file){
16
- $attachment_id = get_post_meta($media_file->ID,'bp_media_child_attachment',true);
17
- $child_activity = get_post_meta($media_file->ID,'bp_media_child_activity',true);
18
- update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
19
- $attachment = get_post($attachment_id , ARRAY_A);
20
- if(isset($wall_posts_album_ids[$media_file->post_author])){
21
- $wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
22
- }
23
- else{
24
- $wall_posts_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title = 'Wall Posts' AND post_author = '". $media_file->post_author."' AND post_type='bp_media_album'");
25
- if($wall_posts_id==null){
26
- $album = new BP_Media_Album();
27
- $album->add_album('Wall Posts',$media_file->post_author);
28
- $wall_posts_id = $album->get_id();
29
- }
30
- if(!$wall_posts_id){
31
- continue; //This condition should never be encountered
32
- }
33
- $wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
34
- }
35
- $attachment['post_parent'] = $wall_posts_id;
36
- wp_update_post($attachment);
37
- update_post_meta($attachment_id,'bp-media-key',$media_file->post_author);
38
- $activity = bp_activity_get(array('in'=>intval($child_activity)));
39
- if(isset($activity['activities'][0]->id))
40
- $activity = $activity['activities'][0];
41
- try{
42
- $bp_media = new BP_Media_Host_Wordpress($attachment_id);
43
- }
44
- catch(exception $e){
45
- continue;
46
- }
47
- $args = array(
48
- 'content' => $bp_media->get_media_activity_content(),
49
- 'id' => $child_activity,
50
- 'type' => 'media_upload',
51
- 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $media_file->post_author ), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>' ) ),
52
- 'primary_link' => $bp_media->get_url(),
53
- 'item_id' => $attachment_id,
54
- 'recorded_time' => $activity->date_recorded,
55
- 'user_id' => $bp_media->get_author()
56
- );
57
- $act_id = bp_media_record_activity($args);
58
- bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
59
- wp_delete_post($media_file->ID);
60
- }
61
- }
62
- else{
63
- break;
64
- }
65
- }while(1);
66
- update_site_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
67
- add_action('admin_notices','bp_media_database_updated_notice');
68
- wp_cache_flush();
69
- }
70
- function bp_media_database_updated_notice(){echo '<div class="updated rt-success"><p>
71
- <b>BuddyPress Media</b> Database upgraded successfully.
72
- </p></div>';}
73
- function bp_media_upgrade_from_2_0_to_2_1(){
74
- $page = 0;
75
- while($media_entries = bp_media_return_query_posts(array(
76
- 'post_type' => 'attachment',
77
- 'post_status' => 'any',
78
- 'meta_key' => 'bp-media-key',
79
- 'meta_value' => 0,
80
- 'meta_compare' => '>',
81
- 'paged' => ++$page,
82
- 'postsperpage' => 10
83
- ))){
84
- foreach($media_entries as $media){
85
- try{
86
- $bp_media = new BP_Media_Host_Wordpress($media->ID);
87
- } catch (exception $e){
88
- continue;
89
- }
90
- $child_activity = get_post_meta($media->ID,'bp_media_child_activity',true);
91
- if($child_activity){
92
- $activity = bp_activity_get(array('in'=>intval($child_activity)));
93
- if(isset($activity['activities'][0]->id))
94
- $activity = $activity['activities'][0];
95
- else
96
- continue;
97
- $args = array(
98
- 'content' => $bp_media->get_media_activity_content(),
99
- 'id' => $child_activity,
100
- 'type' => 'media_upload',
101
- 'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $bp_media->get_author() ), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>' ) ),
102
- 'primary_link' => $bp_media->get_url(),
103
- 'item_id' => $activity->item_id,
104
- 'recorded_time' => $activity->date_recorded,
105
- 'user_id' => $bp_media->get_author()
106
- );
107
- bp_media_record_activity($args);
108
- }
109
- }
110
- }
111
- update_site_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
112
- add_action('admin_notices','bp_media_database_updated_notice');
113
- wp_cache_flush();
114
- }
115
-
116
- function bp_media_return_query_posts($args){
117
- $bp_media_query = new WP_Query($args);
118
- return $bp_media_query->posts;
119
- }
120
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-upload-handler.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- ignore_user_abort(true);
3
-
4
- require_once('lib/bootstrap.php');
5
-
6
- // Check for rights
7
- if ( !is_user_logged_in() )
8
- wp_die(__("You are not allowed to be here"));
9
-
10
- bp_media_handle_uploads();
11
-
12
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
includes/bp-media-widgets.php DELETED
@@ -1,293 +0,0 @@
1
- <?php
2
- /**
3
- * Recent_media widget class
4
- *
5
- * @since 2.8.0
6
- */
7
-
8
- class BP_Media_Recent_Media extends WP_Widget {
9
-
10
- function __construct() {
11
- $widget_ops = array('classname' => 'widget_recent_media', 'description' => __( "The most recent media uploaded on your site", 'bp-media') );
12
- parent::__construct('recent-media', __('Recent Media', 'bp-media'), $widget_ops);
13
- }
14
-
15
- function widget($args, $instance) {
16
- extract( $args );
17
-
18
- $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
19
-
20
- if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
21
- $number = 10;
22
-
23
- echo $before_widget;
24
- echo $before_title . $title . $after_title;
25
- ?>
26
- <div id="recent-media-tabs" class="media-tabs-container">
27
- <ul>
28
- <li><a href="#recent-media-tabs-all"><?php _e('All','bp-media'); ?></a></li>
29
- <li><a href="#recent-media-tabs-photos"><?php _e('Photos','bp-media'); ?></a></li>
30
- <li><a href="#recent-media-tabs-music"><?php _e('Music','bp-media'); ?></a></li>
31
- <li><a href="#recent-media-tabs-videos"><?php _e('Videos','bp-media'); ?></a></li>
32
- </ul>
33
- <div id="recent-media-tabs-all" class="bp-media-tab-panel">
34
- <?php
35
- // All Media
36
- $args = array( 'post_type' => 'attachment',
37
- 'post_status' => 'any',
38
- 'posts_per_page' => $number,
39
- 'meta_key' => 'bp-media-key',
40
- 'meta_value' => 0,
41
- 'meta_compare' => '>' );
42
-
43
- $bp_media_widget_query = new WP_Query($args);
44
-
45
- if($bp_media_widget_query->have_posts()){ ?>
46
-
47
- <ul class="widget-item-listing"><?php
48
- while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
49
-
50
- $entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
51
-
52
- <?php echo $entry -> get_media_gallery_content();?><?php
53
-
54
- } ?>
55
-
56
- </ul><!-- .widget-item-listing --><?php
57
-
58
- }else
59
- _e('No rescent media found', 'bp-media');
60
-
61
- wp_reset_query(); ?>
62
-
63
- </div><!-- #recent-media-tabs-all -->
64
-
65
- <div id="recent-media-tabs-photos" class="bp-media-tab-panel">
66
- <?php
67
- // Rescent photos
68
- $args = array( 'post_type' => 'attachment',
69
- 'post_status' => 'any',
70
- 'post_mime_type' => 'image',
71
- 'posts_per_page' => $number,
72
- 'meta_key' => 'bp-media-key',
73
- 'meta_value' => 0,
74
- 'meta_compare' => '>' );
75
-
76
-
77
- $bp_media_widget_query = new WP_Query($args);
78
-
79
- if($bp_media_widget_query->have_posts()){ ?>
80
-
81
- <ul class="widget-item-listing"><?php
82
- while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
83
-
84
- $entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
85
-
86
- <?php echo $entry -> get_media_gallery_content();?><?php
87
-
88
- } ?>
89
-
90
- </ul><!-- .widget-item-listing --><?php
91
-
92
- }else
93
- _e('No rescent photo found', 'bp-media');
94
-
95
- wp_reset_query(); ?>
96
-
97
- </div><!-- #media-tabs-photos -->
98
-
99
- <div id="recent-media-tabs-music" class="bp-media-tab-panel">
100
- <?php
101
- // Rescent Audio
102
- $args = array( 'post_type' => 'attachment',
103
- 'post_status' => 'any',
104
- 'post_mime_type' => 'audio',
105
- 'posts_per_page' => $number,
106
- 'meta_key' => 'bp-media-key',
107
- 'meta_value' => 0,
108
- 'meta_compare' => '>' );
109
-
110
- $bp_media_widget_query = new WP_Query($args);
111
-
112
- if($bp_media_widget_query->have_posts()){ ?>
113
-
114
- <ul class="widget-item-listing"><?php
115
- while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
116
-
117
- $entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
118
-
119
- <?php echo $entry -> get_media_gallery_content();?><?php
120
-
121
- } ?>
122
-
123
- </ul><!-- .widget-item-listing --><?php
124
-
125
- }else
126
- _e('No rescent audio found', 'bp-media');
127
-
128
- wp_reset_query(); ?>
129
-
130
- </div><!-- #recent-media-tabs-music -->
131
-
132
- <div id="recent-media-tabs-videos" class="bp-media-tab-panel">
133
- <?php
134
- // Rescent Video
135
- $args = array( 'post_type' => 'attachment',
136
- 'post_status' => 'any',
137
- 'post_mime_type' => 'video',
138
- 'posts_per_page' => $number,
139
- 'meta_key' => 'bp-media-key',
140
- 'meta_value' => 0,
141
- 'meta_compare' => '>' );
142
-
143
- $bp_media_widget_query = new WP_Query($args);
144
-
145
- if($bp_media_widget_query->have_posts()){ ?>
146
-
147
- <ul class="widget-item-listing"><?php
148
- while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
149
-
150
- $entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
151
-
152
- <?php echo $entry -> get_media_gallery_content();?><?php
153
-
154
- } ?>
155
-
156
- </ul><!-- .widget-item-listing --><?php
157
-
158
- }else
159
- _e('No rescent video found', 'bp-media');
160
-
161
- wp_reset_query(); ?>
162
-
163
- </div><!-- #media-tabs-videos -->
164
-
165
- </div>
166
- <?php
167
- echo $after_widget;
168
-
169
-
170
- }
171
-
172
- function update( $new_instance, $old_instance ) {
173
- $instance = $old_instance;
174
- $instance['title'] = strip_tags($new_instance['title']);
175
- $instance['number'] = (int) $new_instance['number'];
176
- return $instance;
177
- }
178
-
179
- function form( $instance ) {
180
- $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
181
- $number = isset($instance['number']) ? absint($instance['number']) : 10;
182
- ?>
183
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'bp-media'); ?></label>
184
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
185
-
186
- <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
187
- <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
188
- <?php
189
-
190
- }
191
-
192
- }
193
-
194
-
195
-
196
-
197
- /**
198
- * Popular_media widget class
199
- *
200
- * @since 2.8.0
201
- */
202
-
203
- class BP_Media_Popular_Media extends WP_Widget {
204
-
205
- function __construct() {
206
- $widget_ops = array('classname' => 'BP_Media_Popular_Media', 'description' => __( "The most popular media on your site", 'bp-media') );
207
- parent::__construct('popular-media', __('Popular Media', 'bp-media'), $widget_ops);
208
- }
209
-
210
- function widget($args, $instance) {
211
- extract( $args );
212
-
213
- $title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
214
-
215
- if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
216
- $number = 10;
217
-
218
- echo $before_widget;
219
- echo $before_title . $title . $after_title;
220
- ?>
221
- <div id="popular-media-tabs" class="media-tabs-container">
222
- <!-- <ul>
223
- <li><a href="#popular-media-tabs-comments"><?php _e('comments', 'bp-media'); ?></a></li>
224
- <li><a href="#popular-media-tabs-views"><?php _e('Views', 'bp-media'); ?></a></li>
225
- </ul>-->
226
- <div id="popular-media-tabs-comments" class="bp-media-tab-panel">
227
- <?php
228
- $args = array( 'post_type' => 'attachment',
229
- 'post_status' => 'any',
230
- 'posts_per_page' => $number,
231
- 'meta_key' => 'bp-media-key',
232
- 'meta_value' => 0,
233
- 'meta_compare' => '>',
234
- 'orderby' => 'comment_count');
235
-
236
- $bp_media_widget_query = new WP_Query($args);
237
-
238
- if($bp_media_widget_query->have_posts()){ ?>
239
-
240
- <ul class="widget-item-listing"><?php
241
- while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
242
-
243
- $entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
244
-
245
- <?php echo $entry -> get_media_gallery_content();?><?php
246
-
247
- } ?>
248
-
249
- </ul><!-- .widget-item-listing --><?php
250
-
251
- }else
252
- _e('No popular media found', 'bp-media');
253
-
254
- wp_reset_query(); ?>
255
-
256
- </div><!-- #popular-media-tabs-comments -->
257
- </div>
258
- <?php
259
- echo $after_widget;
260
- }
261
-
262
- function update( $new_instance, $old_instance ) {
263
- $instance = $old_instance;
264
- $instance['title'] = strip_tags($new_instance['title']);
265
- $instance['number'] = (int) $new_instance['number'];
266
- return $instance;
267
- }
268
-
269
- function form( $instance ) {
270
- $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
271
- $number = isset($instance['number']) ? absint($instance['number']) : 10;
272
- ?>
273
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'bp-media'); ?></label>
274
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
275
-
276
- <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
277
- <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
278
- <?php
279
-
280
- }
281
-
282
- }
283
-
284
-
285
- function bp_media_widgets_init(){
286
- register_widget('BP_Media_Recent_Media');
287
- register_widget('BP_Media_Popular_Media');
288
- }
289
-
290
- /* Initialize widgets */
291
- add_action('widgets_init', 'bp_media_widgets_init', 1);
292
-
293
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/css/bp-media-admin.css DELETED
@@ -1,39 +0,0 @@
1
- /* Used on backend */
2
- #wpbody-content div.metabox-fixed{
3
- width: 22%;
4
- margin-right: 10px;
5
- clear: both;
6
- }
7
- #wpbody-content div.wrap.bp-media-admin{
8
- overflow: hidden;
9
- width: 76%;
10
- }
11
- #icon-bp-media{
12
- background:url('../img/logo_medibp_32.png') no-repeat scroll 0 0 transparent;
13
- }.bp-media-social{
14
- background: url('../img/bp_media_social.png');
15
- height: 35px;
16
- width: 35px;
17
- display: inline-block;
18
- font-size: 0px;
19
- margin-right:5px;
20
- }
21
- .bp-media-facebook{
22
- background-position: 0px 0px;
23
- }
24
- .bp-media-facebook:hover{
25
- background-position: 0px 36px;
26
- }
27
- .bp-media-twitter{
28
- background-position: 80px 0px;
29
- }
30
- .bp-media-twitter:hover{
31
- background-position: 80px 36px;
32
- }
33
- .bp-media-rss{
34
- background-position: 35px 0px;
35
- }
36
- .bp-media-rss:hover{
37
- background-position: 35px 36px;
38
- }
39
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/css/bp-media-uploader.css DELETED
@@ -1,98 +0,0 @@
1
- /*
2
- Document : bp-media-uploader
3
- Created on : Aug 21, 2012, 1:24:31 PM
4
- Author : Gagan
5
- Description:
6
- Purpose of the stylesheet follows.
7
- */
8
- #bp-media-upload-ui{position: relative;}
9
- #bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 200px;}
10
- #bp-media-upload-ui .drag-drop-inside{margin: 70px auto 0;width: 250px;}
11
- #bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 5px 0;}
12
- #bp-media-upload-ui .drag-drop-info{font-size: 20px;}
13
- #bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;
14
- color: #464646;
15
- text-decoration: none;
16
- font-size: 12px!important;
17
- line-height: 13px;
18
- padding: 3px 8px;
19
- cursor: pointer;
20
- border-width: 1px;
21
- border-style: solid;
22
- -webkit-border-radius: 11px;
23
- border-radius: 11px;
24
- -moz-box-sizing: content-box;
25
- -webkit-box-sizing: content-box;
26
- box-sizing: content-box;}
27
- .bp-media-progressbar{height: 28px;
28
- margin: 6px 10px 0 0;
29
- line-height: 2em;
30
- padding: 0;
31
- overflow: hidden;
32
- margin-bottom: 2px;
33
- border: 1px solid
34
- #D1D1D1;
35
- background:
36
- white;
37
- background-image: linear-gradient(bottom,
38
- white 0,
39
- #F7F7F7 100%);
40
- background-image: -o-linear-gradient(bottom,
41
- white 0,
42
- #F7F7F7 100%);
43
- background-image: -moz-linear-gradient(bottom,
44
- white 0,
45
- #F7F7F7 100%);
46
- background-image: -webkit-linear-gradient(bottom,
47
- white 0,
48
- #F7F7F7 100%);
49
- background-image: -ms-linear-gradient(bottom,
50
- white 0,
51
- #F7F7F7 100%);
52
- -webkit-border-radius: 3px;
53
- border-radius: 3px;
54
- -webkit-box-shadow: inset 0 0 3px
55
- rgba(0, 0, 0, 0.1);
56
- box-shadow: inset 0 0 3px
57
- rgba(0, 0, 0, 0.1)}
58
-
59
- .bp-media-progress-text{z-index: 10;
60
- position: relative;
61
- width: 100%;
62
- padding: 0 8px;
63
- text-shadow: 0 1px 0
64
- rgba(255, 255, 255, 0.4);
65
- color:
66
- rgba(0, 0, 0, 0.6);
67
- font-size:16px;
68
- line-height: 28px;
69
- }
70
-
71
- .bp-media-progress-completed{z-index: 9;
72
- width: 0;
73
- height: 35px;
74
- margin-top: -35px;
75
- background-color:
76
- #83B4D8;
77
- background-image: linear-gradient(bottom,
78
- #72A7CF 0,
79
- #90C5EE 100%);
80
- background-image: -o-linear-gradient(bottom,
81
- #72A7CF 0,
82
- #90C5EE 100%);
83
- background-image: -moz-linear-gradient(bottom,
84
- #72A7CF 0,
85
- #90C5EE 100%);
86
- background-image: -webkit-linear-gradient(bottom,
87
- #72A7CF 0,
88
- #90C5EE 100%);
89
- background-image: -ms-linear-gradient(bottom,
90
- #72A7CF 0,
91
- #90C5EE 100%);
92
- -webkit-border-radius: 3px;
93
- border-radius: 3px;
94
- -webkit-box-shadow: 0 0 3px
95
- rgba(0, 0, 0, 0.3);
96
- box-shadow: 0 0 3px
97
- rgba(0, 0, 0, 0.3);
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/js/bp-media-uploader.js DELETED
@@ -1,113 +0,0 @@
1
- /*
2
- * To change this template, choose Tools | Templates
3
- * and open the template in the editor.
4
- */
5
-
6
- jQuery(document).ready(function(){
7
- var bp_media_is_multiple_upload = false;
8
- if(jQuery('#'+bp_media_uploader_params.container).length==0)
9
- return false;
10
- var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
11
- var bp_media_album_selected = false;
12
- bp_media_uploader.init();
13
- bp_media_uploader.bind('FilesAdded', function(up, files) {
14
- //bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
15
- bp_media_is_multiple_upload = files.length>1;
16
- jQuery.each(files, function(i, file) {
17
- jQuery('#bp-media-uploaded-files').append(
18
- '<div id="bp-media-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' +
19
- file.name + ' (' + plupload.formatSize(file.size) + ')(<b></b>)</div><div class="bp-media-progress-completed"></div></div>');
20
- });
21
- if(bp_media_album_selected == false){
22
- bp_media_album_select.dialog('option','buttons',{
23
- 'Select': function() {
24
- bp_media_album_selected = jQuery('#bp-media-selected-album').val();
25
- bp_media_uploader.start();
26
- jQuery(this).dialog("close");
27
- },
28
- 'Create New': function(){
29
- bp_media_new_album.dialog('option','buttons',{
30
- 'Create' : function(){
31
- var album_name = jQuery('#bp_media_album_name').val();
32
- if(album_name.length==0){
33
- alert('You have not filled the album name');
34
- return false;
35
- }
36
- var data = {
37
- action: 'bp_media_add_album',
38
- bp_media_album_name : album_name,
39
- bp_media_group_id : bp_media_uploader_params.multipart_params.bp_media_group_id
40
- };
41
- jQuery.post(bp_media_vars.ajaxurl,data,function(response){
42
- var album = parseInt(response);
43
- if(album == 0){
44
- alert('Sorry you cannot create albums in this group');
45
- }
46
- else{
47
- jQuery('#bp-media-selected-album').append('<option value='+album+' selected="selected">'+jQuery('#bp_media_album_name').val()+'</option>')
48
- bp_media_new_album.dialog('close');
49
- bp_media_album_selected = jQuery('#bp-media-selected-album').val();
50
- bp_media_album_select.dialog('close');
51
- bp_media_uploader.start();
52
- }
53
- });
54
- }
55
- });
56
- bp_media_new_album.dialog('open');
57
- }
58
- });
59
- bp_media_album_select.dialog('open');
60
- }
61
- else{
62
- bp_media_album_selected = jQuery('#bp-media-selected-album').val();
63
- bp_media_uploader.start();
64
- }
65
- up.refresh(); // Reposition Flash/Silverlight
66
- });
67
- bp_media_uploader.bind('UploadProgress', function(up, file) {
68
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
69
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
70
- });
71
-
72
- bp_media_uploader.bind('Error', function(up, err) {
73
- jQuery('#bp-media-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
74
- ', Message: ' + err.message +
75
- (err.file ? ', File: ' + err.file.name : '') +
76
- '</p></div>'
77
- );
78
- up.refresh();
79
- });
80
-
81
- bp_media_uploader.bind('FileUploaded', function(up, file) {
82
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html("100%");
83
- });
84
- bp_media_uploader.bind('BeforeUpload',function(up){
85
- up.settings.multipart_params.is_multiple_upload = bp_media_is_multiple_upload;
86
- up.settings.multipart_params.bp_media_album_id = bp_media_album_selected;
87
- });
88
- var bp_media_album_select =jQuery('#bp-media-album-prompt').dialog({
89
- autoOpen:false,
90
- draggable:false,
91
- modal:true,
92
- resizable:false,
93
- closeOnEscape:false
94
- });
95
- var bp_media_new_album = jQuery('#bp-media-album-new').dialog({
96
- autoOpen:false,
97
- draggable:false,
98
- modal:true,
99
- resizable:false,
100
- closeOnEscape:false
101
- });
102
- bp_media_uploader.bind('UploadComplete',function(){
103
- var new_location = window.location.href;
104
- if(new_location.search('/media/')>0){
105
- new_location = new_location.replace('/media/','/albums/');
106
- if(bp_media_album_selected>0)
107
- new_location = new_location.concat(bp_media_album_selected);
108
- else
109
- new_location = new_location.concat('0/');
110
- window.location.replace(new_location);
111
- }
112
- });
113
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/js/bp-media.js DELETED
@@ -1,109 +0,0 @@
1
- /*
2
- * BuddyPress Media Default JS
3
- */
4
-
5
- function bp_media_create_element(id){
6
- jQuery('#'+id).mediaelementplayer({
7
- enableKeyboard: false,
8
- startVolume: 1,
9
- success: function(mediaElement,domElement){
10
- var $thisMediaElement = (mediaElement.id) ? jQuery("#"+mediaElement.id) : jQuery(mediaElement);
11
- $thisMediaElement.parents('.mejs-container').find(".mejs-volume-current").css("top","8px");
12
- $thisMediaElement.parents('.mejs-container').find(".mejs-volume-handle").css("top","5px");
13
- }
14
- });
15
- }
16
-
17
- jQuery(document).ready(function(){
18
- var bp_media_news_section = jQuery('#bp_media_latest_news');
19
- if(bp_media_news_section.length>0){
20
- jQuery.get(bp_media_news_url,function(data){
21
- bp_media_news_section.find('.inside').html(data);
22
- });
23
- }
24
- var bp_media_recent_tabs = jQuery('#recent-media-tabs');
25
- if(bp_media_recent_tabs.length>0){
26
- jQuery(bp_media_recent_tabs).tabs();
27
- }
28
-
29
- // var bp_media_popular_tabs = jQuery('#popular-media-tabs');
30
- // if(bp_media_popular_tabs.length>0){
31
- // jQuery( bp_media_popular_tabs ).tabs();
32
- // }
33
-
34
- var tallest = 0;
35
- jQuery('#recent-media-tabs .bp-media-tab-panel').each(function() {
36
-
37
- var thisHeight = jQuery(this).height();
38
- console.log(thisHeight);
39
- if(thisHeight > tallest) {
40
- tallest = thisHeight;
41
- }
42
- }).height(tallest);
43
-
44
-
45
- jQuery('#bp-media-show-more').click(function(e){
46
- e.preventDefault();
47
- var data = {
48
- action: 'bp_media_load_more',
49
- page:++bp_media_vars.page,
50
- current_action : bp_media_vars.current_action,
51
- action_variables : bp_media_vars.action_variables,
52
- displayed_user : bp_media_vars.displayed_user,
53
- loggedin_user : bp_media_vars.loggedin_user,
54
- current_group : bp_media_vars.current_group
55
- };
56
-
57
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
58
- jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
59
- if(response.length==0)
60
- jQuery('#bp-media-show-more').parent().remove();
61
- else
62
- jQuery('#bp-media-list').append(response);
63
- });
64
- });
65
- setTimeout(function(){
66
- jQuery('.media album_updated .delete-activity,.media_upload .delete-activity').unbind('click').click(function(e){
67
- if(confirm('Are you sure you want to delete this activity and associated media?')){
68
- return true;
69
- }
70
- else{
71
- return false;
72
- }
73
- });
74
-
75
- },1000);
76
-
77
- /* Add Featured Image */
78
-
79
- jQuery('.bp-media-featured').live('click',function(e){
80
- e.preventDefault();
81
- var post_id = jQuery(this).attr('data-post-id');
82
- var post_date = new Date();
83
- var date = post_date.getFullYear()+'-'+(post_date.getMonth() + 1) +'-'+post_date.getDate()+' '+ post_date.getHours()+':'+(post_date.getMinutes() + 1)+':'+(post_date.getSeconds()+1);
84
- // var post_date = d.getTime();
85
- var curr_obj = jQuery(this);
86
- var remove_featured = 0;
87
- if(jQuery(this).attr('data-remove-featured')){
88
- remove_featured = jQuery(this).attr('data-remove-featured');
89
- }
90
- jQuery.ajax({
91
- url:"/wp-admin/admin-ajax.php",
92
- type:'POST',
93
- data:'action=my_featured_action&post_id='+post_id+'&remove_featured='+remove_featured+'&post_date='+date,
94
- success:function( results )
95
- {
96
- if(remove_featured == 1){
97
- curr_obj.text('Featured');
98
- curr_obj.attr('data-remove-featured','0');
99
- } else {
100
- curr_obj.text('Remove Featured');
101
- curr_obj.attr('data-remove-featured','1');
102
- }
103
-
104
- }
105
- });
106
- });
107
-
108
-
109
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
index.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: BuddyPress Media
4
+ Plugin URI: http://rtcamp.com/buddypress-media/
5
+ Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
6
+ Version: 2.4
7
+ Author: rtCamp
8
+ Text Domain: buddypress-media
9
+ Author URI: http://rtcamp.com
10
+ Text domain: buddypress-media
11
+ */
12
+
13
+ /*
14
+ * Base constants that provide the plugin's path and directory
15
+ */
16
+ if ( ! defined( 'BP_MEDIA_PATH' ) )
17
+ define( 'BP_MEDIA_PATH', plugin_dir_path( __FILE__ ) );
18
+
19
+ if ( ! defined( 'BP_MEDIA_URL' ) )
20
+ define( 'BP_MEDIA_URL', plugin_dir_url( __FILE__ ) );
21
+
22
+ /*
23
+ * Autoloads classes on instantiation.
24
+ */
25
+ function buddypress_media_autoloader( $class_name ) {
26
+ $rtlibpath = array(
27
+ 'app/helper/' . $class_name . '.php',
28
+ 'app/admin/' . $class_name . '.php',
29
+ 'app/main/' . $class_name . '.php',
30
+ 'app/main/profile/' . $class_name . '.php',
31
+ 'app/main/group/' . $class_name . '.php',
32
+ 'app/main/group/dummy/' . $class_name . '.php',
33
+ 'app/main/includes/' . $class_name . '.php',
34
+ 'app/main/widgets/' . $class_name . '.php',
35
+ );
36
+ foreach ( $rtlibpath as $i => $path ) {
37
+ $path = BP_MEDIA_PATH . $path;
38
+ if ( file_exists( $path ) ) {
39
+ include $path;
40
+ break;
41
+ }
42
+ }
43
+ }
44
+
45
+ /*
46
+ * Register the autoloader function into spl_autoload
47
+ */
48
+ spl_autoload_register( 'buddypress_media_autoloader' );
49
+
50
+ /*
51
+ * Instantiate the BuddyPressMedia class.
52
+ */
53
+ global $bp_media;
54
+ $bp_media = new BuddyPressMedia();
55
+
56
+ /*
57
+ * Activating the plugin!
58
+ */
59
+ register_activation_hook( __FILE__, array( $bp_media, 'activate' ) );
60
+
61
+ /*
62
+ * And hooking it to BuddyPress
63
+ */
64
+ add_action( 'bp_include', array($bp_media, 'init') );
65
+
66
+ /*
67
+ * Look Ma! Very few includes!
68
+ */
69
+ ?>
lang/buddypress-media.po ADDED
@@ -0,0 +1,872 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Buddypress Media\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-12-31 17:50+0530\n"
6
+ "PO-Revision-Date: 2012-12-31 17:52+0530\n"
7
+ "Last-Translator: Saurabh Shukla <saurabh.shukla@rtcamp.com>\n"
8
+ "Language-Team: rtCamp <info@rtcamp.com>\n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SearchPath-0: .\n"
16
+
17
+ #: app/helper/BPMediaWidget.php:22
18
+ #, fuzzy
19
+ msgid "Argument missing. id is required."
20
+ msgstr ""
21
+
22
+ #: app/helper/BPMediaFeed.php:38
23
+ msgid "No items"
24
+ msgstr ""
25
+
26
+ #: app/helper/BPMediaFeed.php:44
27
+ msgid "Posted "
28
+ msgstr ""
29
+
30
+ #: app/helper/BPMediaSettings.php:23
31
+ msgid "BuddyPress Media Settings"
32
+ msgstr ""
33
+
34
+ #: app/helper/BPMediaSettings.php:24
35
+ msgid "Video"
36
+ msgstr ""
37
+
38
+ #: app/helper/BPMediaSettings.php:24
39
+ msgid "Check to enable video upload functionality"
40
+ msgstr ""
41
+
42
+ #: app/helper/BPMediaSettings.php:25
43
+ msgid "Audio"
44
+ msgstr ""
45
+
46
+ #: app/helper/BPMediaSettings.php:25
47
+ msgid "Check to enable audio upload functionality"
48
+ msgstr ""
49
+
50
+ #: app/helper/BPMediaSettings.php:26
51
+ msgid "Images"
52
+ msgstr ""
53
+
54
+ #: app/helper/BPMediaSettings.php:26
55
+ msgid "Check to enable images upload functionality"
56
+ msgstr ""
57
+
58
+ #: app/helper/BPMediaSettings.php:27
59
+ msgid "Download"
60
+ msgstr ""
61
+
62
+ #: app/helper/BPMediaSettings.php:27
63
+ msgid "Check to enable download functionality"
64
+ msgstr ""
65
+
66
+ #: app/helper/BPMediaSettings.php:28
67
+ #: app/helper/BPMediaSettings.php:29
68
+ msgid "Spread the Word"
69
+ msgstr ""
70
+
71
+ #: app/helper/BPMediaSettings.php:29
72
+ msgid "Yes, I support BuddyPress Media"
73
+ msgstr ""
74
+
75
+ #: app/helper/BPMediaSettings.php:29
76
+ msgid "No, I don't want to support BuddyPress Media"
77
+ msgstr ""
78
+
79
+ #: app/helper/BPMediaSettings.php:30
80
+ msgid "BuddyPress Media Other Options"
81
+ msgstr ""
82
+
83
+ #: app/helper/BPMediaSettings.php:31
84
+ msgid "Re-Count Media Entries"
85
+ msgstr ""
86
+
87
+ #: app/helper/BPMediaSettings.php:31
88
+ msgid "It will re-count all media entries of all users and correct any discrepancies."
89
+ msgstr ""
90
+
91
+ #: app/helper/BPMediaSettings.php:33
92
+ msgid "BuddyPress Media Addons for Audio/Video Conversion"
93
+ msgstr ""
94
+
95
+ #: app/helper/BPMediaSettings.php:34
96
+ msgid "Submit a request form"
97
+ msgstr ""
98
+
99
+ #: app/helper/BPMediaSettings.php:35
100
+ msgid "Request Type"
101
+ msgstr ""
102
+
103
+ #: app/helper/BPMediaSettings.php:46
104
+ msgid "Recounting of media files done successfully"
105
+ msgstr ""
106
+
107
+ #: app/helper/BPMediaSettings.php:48
108
+ msgid "Recounting Failed"
109
+ msgstr ""
110
+
111
+ #: app/helper/BPMediaSettings.php:69
112
+ msgid "Please provide \"option\" value ( required ) in the argument. Pass argument to add_settings_field in the following format array( 'option' => 'option_name' ) "
113
+ msgstr ""
114
+
115
+ #: app/helper/BPMediaSettings.php:99
116
+ #: app/helper/BPMediaSettings.php:132
117
+ msgid "Please provide \"option\" value ( required ) in the argument. Pass argument to add_settings_field in the following format array( 'option' => 'option_name' )"
118
+ msgstr ""
119
+
120
+ #: app/helper/BPMediaSettings.php:101
121
+ msgid "Need to specify atleast to radios else use a checkbox instead"
122
+ msgstr ""
123
+
124
+ #: app/helper/BPMediaSettings.php:134
125
+ msgid "Please provide some values to populate the dropdown. Format : array( 'value' => 'option' )"
126
+ msgstr ""
127
+
128
+ #: app/helper/BPMediaAddon.php:65
129
+ msgid "Buy Now"
130
+ msgstr ""
131
+
132
+ #: app/helper/BPMediaAddon.php:66
133
+ msgid "Live Demo"
134
+ msgstr ""
135
+
136
+ #: app/helper/BPMediaUpgrade.php:30
137
+ #, php-format
138
+ msgid "Please click upgrade to upgrade the database of BuddyPress Media <a class=\"button\" id=\"refresh_media_count\" href =\"%s\" class=\"button\" title=\"It will migrate your BuddyPress Media's earlier database to new database.\">Upgrade</a>"
139
+ msgstr ""
140
+
141
+ #: app/helper/BPMediaUpgrade.php:103
142
+ #: app/helper/BPMediaUpgrade.php:156
143
+ #: app/main/group/BPMediaGroupAction.php:94
144
+ #, php-format
145
+ msgid "%1$s added a %2$s"
146
+ msgstr ""
147
+
148
+ #: app/admin/BPMediaAdmin.php:50
149
+ msgid "Buddypress Media Component"
150
+ msgstr ""
151
+
152
+ #: app/admin/BPMediaAdmin.php:50
153
+ msgid "BuddyPress Media"
154
+ msgstr ""
155
+
156
+ #: app/admin/BPMediaAdmin.php:51
157
+ #: app/admin/BPMediaAdmin.php:169
158
+ msgid "Buddypress Media Settings"
159
+ msgstr ""
160
+
161
+ #: app/admin/BPMediaAdmin.php:51
162
+ #: app/admin/BPMediaAdmin.php:170
163
+ #: app/main/BuddyPressMedia.php:192
164
+ msgid "Settings"
165
+ msgstr ""
166
+
167
+ #: app/admin/BPMediaAdmin.php:52
168
+ #: app/admin/BPMediaAdmin.php:176
169
+ msgid "Buddypress Media Addons"
170
+ msgstr ""
171
+
172
+ #: app/admin/BPMediaAdmin.php:52
173
+ #: app/admin/BPMediaAdmin.php:177
174
+ msgid "Addons"
175
+ msgstr ""
176
+
177
+ #: app/admin/BPMediaAdmin.php:53
178
+ #: app/admin/BPMediaAdmin.php:183
179
+ msgid "Buddypress Media Support"
180
+ msgstr ""
181
+
182
+ #: app/admin/BPMediaAdmin.php:53
183
+ msgid "Support "
184
+ msgstr ""
185
+
186
+ #: app/admin/BPMediaAdmin.php:87
187
+ #: app/main/BuddyPressMedia.php:129
188
+ #: app/main/BuddyPressMedia.php:132
189
+ msgid "Media"
190
+ msgstr ""
191
+
192
+ #: app/admin/BPMediaAdmin.php:142
193
+ #: app/admin/BPMediaAdmin.php:143
194
+ msgid "Buddypress Media"
195
+ msgstr ""
196
+
197
+ #: app/admin/BPMediaAdmin.php:184
198
+ msgid "Support"
199
+ msgstr ""
200
+
201
+ #: app/admin/BPMediaAdmin.php:238
202
+ msgid "Empowering The Web With WordPress"
203
+ msgstr ""
204
+
205
+ #: app/admin/BPMediaAdmin.php:238
206
+ msgid "rtCamp"
207
+ msgstr ""
208
+
209
+ #: app/admin/BPMediaAdmin.php:240
210
+ msgid "Become a fan on Facebook"
211
+ msgstr ""
212
+
213
+ #: app/admin/BPMediaAdmin.php:240
214
+ msgid "Facebook"
215
+ msgstr ""
216
+
217
+ #: app/admin/BPMediaAdmin.php:241
218
+ msgid "Follow us on Twitter"
219
+ msgstr ""
220
+
221
+ #: app/admin/BPMediaAdmin.php:241
222
+ msgid "Twitter"
223
+ msgstr ""
224
+
225
+ #: app/admin/BPMediaAdmin.php:242
226
+ msgid "Subscribe to our feeds"
227
+ msgstr ""
228
+
229
+ #: app/admin/BPMediaAdmin.php:242
230
+ msgid "RSS Feed"
231
+ msgstr ""
232
+
233
+ #: app/admin/BPMediaAdmin.php:247
234
+ #, php-format
235
+ msgid "<a href=\"%s\">Read FAQ</a>"
236
+ msgstr ""
237
+
238
+ #: app/admin/BPMediaAdmin.php:248
239
+ #, php-format
240
+ msgid "<a href=\"%s\">Free Support Forum</a>"
241
+ msgstr ""
242
+
243
+ #: app/admin/BPMediaAdmin.php:249
244
+ #, php-format
245
+ msgid "<a href=\"%s\">Github Issue Tracker</a>"
246
+ msgstr ""
247
+
248
+ #: app/admin/BPMediaAdmin.php:250
249
+ #, php-format
250
+ msgid "<a href=\"%s\">Hire us!</a> To get professional customisation/setup service."
251
+ msgstr ""
252
+
253
+ #: app/admin/BPMediaAdmin.php:252
254
+ msgid "Need Help?"
255
+ msgstr ""
256
+
257
+ #: app/admin/BPMediaAdmin.php:254
258
+ msgid "Help the development keep going."
259
+ msgstr ""
260
+
261
+ #: app/admin/BPMediaAdmin.php:255
262
+ msgid "Help us release more amazing features faster. Consider making a donation to our consistent efforts."
263
+ msgstr ""
264
+
265
+ #: app/admin/BPMediaAdmin.php:256
266
+ msgid "Donate"
267
+ msgstr ""
268
+
269
+ #: app/admin/BPMediaAdmin.php:259
270
+ msgid "BuddyPress Media Kaltura"
271
+ msgstr ""
272
+
273
+ #: app/admin/BPMediaAdmin.php:259
274
+ msgid "BPM-Kaltura"
275
+ msgstr ""
276
+
277
+ #: app/admin/BPMediaAdmin.php:259
278
+ msgid "Add support for Kaltura.com/Kaltura-CE based video conversion support"
279
+ msgstr ""
280
+
281
+ #: app/admin/BPMediaAdmin.php:260
282
+ msgid "BuddyPress Media FFMPEG"
283
+ msgstr ""
284
+
285
+ #: app/admin/BPMediaAdmin.php:260
286
+ msgid "BPM-FFMPEG"
287
+ msgstr ""
288
+
289
+ #: app/admin/BPMediaAdmin.php:260
290
+ msgid "Add FFMEG-based audio/video conversion support"
291
+ msgstr ""
292
+
293
+ #: app/admin/BPMediaAdmin.php:262
294
+ msgid "Are you a developer?"
295
+ msgstr ""
296
+
297
+ #: app/admin/BPMediaAdmin.php:263
298
+ #, php-format
299
+ msgid "If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href=\"%s\">More info!</a>"
300
+ msgstr ""
301
+
302
+ #: app/admin/BPMediaAdmin.php:264
303
+ msgid "Premium Addons"
304
+ msgstr ""
305
+
306
+ #: app/admin/BPMediaAdmin.php:267
307
+ msgid "Latest News"
308
+ msgstr ""
309
+
310
+ #: app/main/BuddyPressMedia.php:135
311
+ msgid "Photos"
312
+ msgstr ""
313
+
314
+ #: app/main/BuddyPressMedia.php:138
315
+ msgid "Photo"
316
+ msgstr ""
317
+
318
+ #: app/main/BuddyPressMedia.php:141
319
+ msgid "Videos"
320
+ msgstr ""
321
+
322
+ #: app/main/BuddyPressMedia.php:147
323
+ #: app/main/BuddyPressMedia.php:150
324
+ msgid "Music"
325
+ msgstr ""
326
+
327
+ #: app/main/BuddyPressMedia.php:153
328
+ msgid "Albums"
329
+ msgstr ""
330
+
331
+ #: app/main/BuddyPressMedia.php:156
332
+ msgid "Album"
333
+ msgstr ""
334
+
335
+ #: app/main/BuddyPressMedia.php:159
336
+ msgid "Upload"
337
+ msgstr ""
338
+
339
+ #: app/main/BuddyPressMedia.php:250
340
+ #, php-format
341
+ msgid "The BuddyPress version installed is an older version and is not supported, please update BuddyPress to use BuddyPress Media Plugin.<a class=\"alignright\" href=\"%1$s\">X</a>"
342
+ msgstr ""
343
+
344
+ #: app/main/BuddyPressMedia.php:255
345
+ #, php-format
346
+ msgid "You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin.<a class=\"alignright\" href=\"%1$s\">X</a>"
347
+ msgstr ""
348
+
349
+ #: app/main/profile/BPMediaTemplate.php:54
350
+ msgid "Drop files here"
351
+ msgstr ""
352
+
353
+ #: app/main/profile/BPMediaTemplate.php:55
354
+ msgid " or "
355
+ msgstr ""
356
+
357
+ #: app/main/profile/BPMediaTemplate.php:56
358
+ msgid "Select Files"
359
+ msgstr ""
360
+
361
+ #: app/main/profile/BPMediaScreen.php:107
362
+ #: app/main/profile/BPMediaScreen.php:327
363
+ msgid "The requested url does not exist"
364
+ msgstr ""
365
+
366
+ #: app/main/profile/BPMediaScreen.php:118
367
+ #, php-format
368
+ msgid "%s List Page"
369
+ msgstr ""
370
+
371
+ #: app/main/profile/BPMediaScreen.php:176
372
+ #: app/main/profile/BPMediaAlbumScreen.php:59
373
+ #, php-format
374
+ msgid "Sorry, no %s were found."
375
+ msgstr ""
376
+
377
+ #: app/main/profile/BPMediaScreen.php:274
378
+ #, php-format
379
+ msgid "Edit %s"
380
+ msgstr ""
381
+
382
+ #: app/main/profile/BPMediaScreen.php:289
383
+ #, php-format
384
+ msgid "%s Title"
385
+ msgstr ""
386
+
387
+ #: app/main/profile/BPMediaScreen.php:295
388
+ #, php-format
389
+ msgid "%s Description"
390
+ msgstr ""
391
+
392
+ #: app/main/profile/BPMediaScreen.php:301
393
+ msgid "Update"
394
+ msgstr ""
395
+
396
+ #: app/main/profile/BPMediaScreen.php:302
397
+ msgid "Back to Media File"
398
+ msgstr ""
399
+
400
+ #: app/main/profile/BPMediaScreen.php:303
401
+ msgid "Back to Media"
402
+ msgstr ""
403
+
404
+ #: app/main/profile/BPMediaScreen.php:320
405
+ msgid "You do not have access to this page."
406
+ msgstr ""
407
+
408
+ #: app/main/profile/BPMediaScreen.php:348
409
+ msgid "Media deleted successfully"
410
+ msgstr ""
411
+
412
+ #: app/main/profile/BPMediaUploadScreen.php:27
413
+ msgid "Upload Media"
414
+ msgstr ""
415
+
416
+ #: app/main/profile/BPMediaUploadScreen.php:69
417
+ msgid "You are not allowed to be here"
418
+ msgstr ""
419
+
420
+ #: app/main/profile/BPMediaUploadScreen.php:91
421
+ #: app/main/profile/BPMediaUploadScreen.php:115
422
+ msgid "File uploaded is not supported"
423
+ msgstr ""
424
+
425
+ #: app/main/profile/BPMediaUploadScreen.php:98
426
+ msgid "Image uploads are disabled"
427
+ msgstr ""
428
+
429
+ #: app/main/profile/BPMediaUploadScreen.php:104
430
+ msgid "Video uploads are disabled"
431
+ msgstr ""
432
+
433
+ #: app/main/profile/BPMediaUploadScreen.php:110
434
+ msgid "Audio uploads are disabled"
435
+ msgstr ""
436
+
437
+ #: app/main/profile/BPMediaUploadScreen.php:128
438
+ msgid "Upload Successful"
439
+ msgstr ""
440
+
441
+ #: app/main/profile/BPMediaUploadScreen.php:133
442
+ msgid "You did not specified a file to upload"
443
+ msgstr ""
444
+
445
+ #: app/main/profile/BPMediaAlbumScreen.php:94
446
+ msgid "Sorry, no media items were found in this album."
447
+ msgstr ""
448
+
449
+ #: app/main/profile/BPMediaAlbum.php:42
450
+ msgid "Sorry, the requested album does not exist."
451
+ msgstr ""
452
+
453
+ #: app/main/group/BPMediaGroup.php:179
454
+ msgid "Media Settings"
455
+ msgstr ""
456
+
457
+ #: app/main/group/BPMediaGroup.php:239
458
+ #: app/main/group/BPMediaGroup.php:272
459
+ #: app/main/group/BPMediaGroup.php:354
460
+ msgid "Sorry, the requested media does not belong to the group"
461
+ msgstr ""
462
+
463
+ #: app/main/group/BPMediaGroup.php:305
464
+ msgid "Sorry, the requested album does not belong to the group"
465
+ msgstr ""
466
+
467
+ #: app/main/group/BPMediaGroupsExtension.php:103
468
+ msgid "There was an error saving, please try again"
469
+ msgstr ""
470
+
471
+ #: app/main/group/BPMediaGroupsExtension.php:105
472
+ msgid "Settings saved successfully"
473
+ msgstr ""
474
+
475
+ #: app/main/widgets/BPMediaPopularMedia.php:15
476
+ msgid "The most popular media on your site"
477
+ msgstr ""
478
+
479
+ #: app/main/widgets/BPMediaPopularMedia.php:16
480
+ #: app/main/widgets/BPMediaPopularMedia.php:22
481
+ msgid "Popular Media"
482
+ msgstr ""
483
+
484
+ #: app/main/widgets/BPMediaPopularMedia.php:32
485
+ msgid "comments"
486
+ msgstr ""
487
+
488
+ #: app/main/widgets/BPMediaPopularMedia.php:33
489
+ msgid "Views"
490
+ msgstr ""
491
+
492
+ #: app/main/widgets/BPMediaPopularMedia.php:62
493
+ msgid "No popular media found"
494
+ msgstr ""
495
+
496
+ #: app/main/widgets/BPMediaPopularMedia.php:84
497
+ msgid "Title:"
498
+ msgstr ""
499
+
500
+ #: app/main/widgets/BPMediaPopularMedia.php:87
501
+ msgid "Number of posts to show:"
502
+ msgstr ""
503
+
504
+ #: app/main/widgets/BPMediaRecentMedia.php:15
505
+ msgid "The most recent media uploaded on your site"
506
+ msgstr ""
507
+
508
+ #: app/main/widgets/BPMediaRecentMedia.php:16
509
+ #: app/main/widgets/BPMediaRecentMedia.php:22
510
+ msgid "Recent Media"
511
+ msgstr ""
512
+
513
+ #: app/main/widgets/BPMediaRecentMedia.php:32
514
+ msgid "All"
515
+ msgstr ""
516
+
517
+ #: app/main/widgets/BPMediaRecentMedia.php:64
518
+ msgid "No rescent media found"
519
+ msgstr ""
520
+
521
+ #: app/main/widgets/BPMediaRecentMedia.php:100
522
+ msgid "No rescent photo found"
523
+ msgstr ""
524
+
525
+ #: app/main/widgets/BPMediaRecentMedia.php:135
526
+ msgid "No rescent audio found"
527
+ msgstr ""
528
+
529
+ #: app/main/widgets/BPMediaRecentMedia.php:170
530
+ msgid "No rescent video found"
531
+ msgstr ""
532
+
533
+ #: app/main/includes/BPMediaHostWordpress.php:46
534
+ msgid "Sorry, the requested media does not exist."
535
+ msgstr ""
536
+
537
+ #: app/main/includes/BPMediaHostWordpress.php:84
538
+ msgid "Error Uploading File"
539
+ msgstr ""
540
+
541
+ #: app/main/includes/BPMediaHostWordpress.php:112
542
+ msgid "MP4 file you have uploaded is currupt."
543
+ msgstr ""
544
+
545
+ #: app/main/includes/BPMediaHostWordpress.php:119
546
+ #: app/main/includes/BPMediaHostWordpress.php:124
547
+ msgid "The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264."
548
+ msgstr ""
549
+
550
+ #: app/main/includes/BPMediaHostWordpress.php:129
551
+ msgid "The MP4 file you have uploaded is not a video file."
552
+ msgstr ""
553
+
554
+ #: app/main/includes/BPMediaHostWordpress.php:141
555
+ msgid "MP3 file you have uploaded is currupt."
556
+ msgstr ""
557
+
558
+ #: app/main/includes/BPMediaHostWordpress.php:148
559
+ #: app/main/includes/BPMediaHostWordpress.php:153
560
+ msgid "The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3."
561
+ msgstr ""
562
+
563
+ #: app/main/includes/BPMediaHostWordpress.php:158
564
+ msgid "The MP3 file you have uploaded is not an audio file."
565
+ msgstr ""
566
+
567
+ #: app/main/includes/BPMediaHostWordpress.php:172
568
+ msgid "Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4."
569
+ msgstr ""
570
+
571
+ #: app/main/includes/BPMediaHostWordpress.php:179
572
+ msgid "Error creating attachment for the media file, please try again"
573
+ msgstr ""
574
+
575
+ #: app/main/includes/BPMediaHostWordpress.php:251
576
+ #, php-format
577
+ msgid "%s uploaded a media."
578
+ msgstr ""
579
+
580
+ #: app/main/includes/BPMediaHostWordpress.php:388
581
+ #, php-format
582
+ msgid "Comment <span>%s</span>"
583
+ msgstr ""
584
+
585
+ #: app/main/includes/BPMediaHostWordpress.php:392
586
+ msgid "Favorite"
587
+ msgstr ""
588
+
589
+ #: app/main/includes/BPMediaHostWordpress.php:394
590
+ msgid "Remove Favorite"
591
+ msgstr ""
592
+
593
+ #: app/main/includes/BPMediaHostWordpress.php:413
594
+ msgid "Post"
595
+ msgstr ""
596
+
597
+ #: app/main/includes/BPMediaHostWordpress.php:413
598
+ msgid "or press esc to cancel."
599
+ msgstr ""
600
+
601
+ #: app/main/includes/bp-media-actions.php:226
602
+ msgid "Edit Media"
603
+ msgstr ""
604
+
605
+ #: app/main/includes/bp-media-actions.php:226
606
+ msgid "Edit"
607
+ msgstr ""
608
+
609
+ #: app/main/includes/bp-media-actions.php:238
610
+ #: app/main/includes/bp-media-actions.php:243
611
+ msgid "Featured Media"
612
+ msgstr ""
613
+
614
+ #: app/main/includes/bp-media-actions.php:238
615
+ msgid "Featured"
616
+ msgstr ""
617
+
618
+ #: app/main/includes/bp-media-actions.php:243
619
+ msgid "Remove Featured"
620
+ msgstr ""
621
+
622
+ #: app/main/includes/bp-media-actions.php:523
623
+ #, php-format
624
+ msgid "%1$s created an album %2$s"
625
+ msgstr ""
626
+
627
+ #: app/main/includes/bp-media-template-functions.php:26
628
+ msgid "Media Title"
629
+ msgstr ""
630
+
631
+ #: app/main/includes/bp-media-template-functions.php:27
632
+ msgid "Media Description"
633
+ msgstr ""
634
+
635
+ #: app/main/includes/bp-media-template-functions.php:28
636
+ msgid "Select Media File"
637
+ msgstr ""
638
+
639
+ #: app/main/includes/bp-media-admin.php:27
640
+ msgid "It will migrate your BuddyPress Media's earlier database to new database."
641
+ msgstr ""
642
+
643
+ #: app/main/includes/bp-media-admin.php:127
644
+ msgid "Bug Report"
645
+ msgstr ""
646
+
647
+ #: app/main/includes/bp-media-admin.php:130
648
+ msgid "New Feature Request"
649
+ msgstr ""
650
+
651
+ #: app/main/includes/bp-media-admin.php:133
652
+ msgid "Premium Support Request"
653
+ msgstr ""
654
+
655
+ #: app/main/includes/bp-media-admin.php:275
656
+ msgid "Thank you, Your bug report sent successfully."
657
+ msgstr ""
658
+
659
+ #: app/main/includes/bp-media-admin.php:278
660
+ msgid "Thank you, Your new feature request sent successfully."
661
+ msgstr ""
662
+
663
+ #: app/main/includes/bp-media-admin.php:281
664
+ msgid "Thank you, Your premium support request sent successfully, We will contact you soon."
665
+ msgstr ""
666
+
667
+ #: app/main/includes/bp-media-admin.php:333
668
+ #: app/main/includes/bp-media-admin.php:627
669
+ msgid "BuddyPress Media Support"
670
+ msgstr ""
671
+
672
+ #: app/main/includes/bp-media-admin.php:339
673
+ msgid "Spread the word"
674
+ msgstr ""
675
+
676
+ #: app/main/includes/bp-media-admin.php:340
677
+ msgid "BuddyPress Media Other options"
678
+ msgstr ""
679
+
680
+ #: app/main/includes/bp-media-admin.php:602
681
+ msgid "Need Help/Support?"
682
+ msgstr ""
683
+
684
+ #: app/main/includes/bp-media-admin.php:604
685
+ msgid "Read FAQ"
686
+ msgstr ""
687
+
688
+ #: app/main/includes/bp-media-admin.php:605
689
+ msgid "Free Support Forum"
690
+ msgstr ""
691
+
692
+ #: app/main/includes/bp-media-admin.php:606
693
+ msgid "Github Issue Tracker"
694
+ msgstr ""
695
+
696
+ #: app/main/includes/bp-media-admin.php:610
697
+ msgid "Hire Us!"
698
+ msgstr ""
699
+
700
+ #: app/main/includes/bp-media-admin.php:611
701
+ msgid "We are available for customisation and premium support. Get on touch with us. :-)"
702
+ msgstr ""
703
+
704
+ #: app/main/includes/bp-media-admin.php:641
705
+ msgid "Request type:"
706
+ msgstr ""
707
+
708
+ #: app/main/includes/bp-media-admin.php:643
709
+ msgid "-- Choose Type --"
710
+ msgstr ""
711
+
712
+ #: app/main/includes/bp-media-admin.php:644
713
+ msgid "Premium Support"
714
+ msgstr ""
715
+
716
+ #: app/main/includes/bp-media-admin.php:645
717
+ msgid "Suggest a New Feature"
718
+ msgstr ""
719
+
720
+ #: app/main/includes/bp-media-admin.php:646
721
+ #: app/main/includes/bp-media-admin.php:658
722
+ msgid "Submit a Bug Report"
723
+ msgstr ""
724
+
725
+ #: app/main/includes/bp-media-admin.php:661
726
+ msgid "Submit a New Feature Request"
727
+ msgstr ""
728
+
729
+ #: app/main/includes/bp-media-admin.php:664
730
+ msgid "Submit a Premium Support Request"
731
+ msgstr ""
732
+
733
+ #: app/main/includes/bp-media-admin.php:672
734
+ msgid "Your Name:"
735
+ msgstr ""
736
+
737
+ #: app/main/includes/bp-media-admin.php:675
738
+ msgid "Your Email-Id:"
739
+ msgstr ""
740
+
741
+ #: app/main/includes/bp-media-admin.php:678
742
+ msgid "Your Site Url:"
743
+ msgstr ""
744
+
745
+ #: app/main/includes/bp-media-admin.php:681
746
+ msgid "Your Phone:"
747
+ msgstr ""
748
+
749
+ #: app/main/includes/bp-media-admin.php:684
750
+ msgid "Subject:"
751
+ msgstr ""
752
+
753
+ #: app/main/includes/bp-media-admin.php:687
754
+ msgid "Details:"
755
+ msgstr ""
756
+
757
+ #: app/main/includes/bp-media-admin.php:706
758
+ msgid "Attachment:"
759
+ msgstr ""
760
+
761
+ #: app/main/includes/bp-media-admin.php:708
762
+ msgid "Add more attachment"
763
+ msgstr ""
764
+
765
+ #: app/main/includes/bp-media-admin.php:731
766
+ msgid "Your WP Admin Login:"
767
+ msgstr ""
768
+
769
+ #: app/main/includes/bp-media-admin.php:734
770
+ msgid "Your WP Admin password:"
771
+ msgstr ""
772
+
773
+ #: app/main/includes/bp-media-admin.php:737
774
+ msgid "Your SSH / FTP host:"
775
+ msgstr ""
776
+
777
+ #: app/main/includes/bp-media-admin.php:740
778
+ msgid "Your SSH / FTP login:"
779
+ msgstr ""
780
+
781
+ #: app/main/includes/bp-media-admin.php:743
782
+ msgid "Your SSH / FTP password:"
783
+ msgstr ""
784
+
785
+ #: app/main/includes/bp-media-admin.php:746
786
+ msgid "Send PHP Info"
787
+ msgstr ""
788
+
789
+ #: app/main/includes/bp-media-admin.php:780
790
+ #, php-format
791
+ msgid ""
792
+ " Please use our <a href=\"%s\">free support forum</a>.<br/><span class=\"bpm-aligncenter\">OR</span><br/>\n"
793
+ "\t\t<a href=\"%s\">Hire us!</a> To get professional customisation/setup service."
794
+ msgstr ""
795
+
796
+ #: app/main/includes/BPMediaComponent.php:71
797
+ msgid "Search Media..."
798
+ msgstr ""
799
+
800
+ #: app/main/includes/BPMediaComponent.php:320
801
+ msgid "Create"
802
+ msgstr ""
803
+
804
+ #: app/main/includes/BPMediaComponent.php:321
805
+ msgid "Create Album"
806
+ msgstr ""
807
+
808
+ #: app/main/includes/BPMediaComponent.php:322
809
+ msgid "Edit Album"
810
+ msgstr ""
811
+
812
+ #: app/main/includes/BPMediaComponent.php:323
813
+ msgid "New Album"
814
+ msgstr ""
815
+
816
+ #: app/main/includes/BPMediaComponent.php:324
817
+ msgid "All Albums"
818
+ msgstr ""
819
+
820
+ #: app/main/includes/BPMediaComponent.php:325
821
+ msgid "View Album"
822
+ msgstr ""
823
+
824
+ #: app/main/includes/BPMediaComponent.php:326
825
+ msgid "Search Albums"
826
+ msgstr ""
827
+
828
+ #: app/main/includes/BPMediaComponent.php:327
829
+ msgid "No album found"
830
+ msgstr ""
831
+
832
+ #: app/main/includes/BPMediaComponent.php:328
833
+ msgid "No album found in Trash"
834
+ msgstr ""
835
+
836
+ #: app/main/includes/BPMediaComponent.php:352
837
+ msgid "Add New Media"
838
+ msgstr ""
839
+
840
+ #: app/main/includes/bp-media-functions.php:182
841
+ #, php-format
842
+ msgid "%1$s added new media in album %2$s"
843
+ msgstr ""
844
+
845
+ #: app/main/includes/bp-media-filters.php:251
846
+ msgid "BuddPress Media"
847
+ msgstr ""
848
+
849
+ #: app/main/includes/bp-media-filters.php:291
850
+ msgid "Users"
851
+ msgstr ""
852
+
853
+ #: app/main/includes/bp-media-filters.php:293
854
+ msgid "Total Photos"
855
+ msgstr ""
856
+
857
+ #: app/main/includes/bp-media-filters.php:294
858
+ msgid "Total Videos"
859
+ msgstr ""
860
+
861
+ #: app/main/includes/bp-media-filters.php:295
862
+ msgid "Total Audio"
863
+ msgstr ""
864
+
865
+ #: app/main/includes/bp-media-filters.php:296
866
+ msgid "Total Albums"
867
+ msgstr ""
868
+
869
+ #: app/main/includes/bp-media-filters.php:298
870
+ msgid "Groups"
871
+ msgstr ""
872
+
{includes/lib → lib}/getid3/extension.cache.dbm.php RENAMED
File without changes
{includes/lib → lib}/getid3/extension.cache.mysql.php RENAMED
File without changes
{includes/lib → lib}/getid3/getid3.lib.php RENAMED
File without changes
{includes/lib → lib}/getid3/getid3.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.archive.gzip.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.archive.rar.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.archive.szip.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.archive.tar.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.archive.zip.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.asf.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.bink.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.flv.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.matroska.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.mpeg.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.nsv.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.quicktime.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.real.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.riff.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio-video.swf.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.aa.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.aac.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.ac3.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.au.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.avr.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.bonk.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.dss.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.dts.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.flac.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.la.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.lpac.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.midi.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.mod.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.monkey.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.mp3.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.mpc.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.ogg.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.optimfrog.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.rkau.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.shorten.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.tta.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.voc.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.vqf.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.audio.wavpack.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.bmp.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.efax.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.gif.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.jpg.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.pcd.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.png.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.svg.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.graphic.tiff.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.cue.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.exe.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.iso.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.msoffice.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.par2.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.misc.pdf.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.tag.apetag.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.tag.id3v1.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.tag.id3v2.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.tag.lyrics3.php RENAMED
File without changes
{includes/lib → lib}/getid3/module.tag.xmp.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.apetag.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.id3v1.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.id3v2.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.lyrics3.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.metaflac.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.real.php RENAMED
File without changes
{includes/lib → lib}/getid3/write.vorbiscomment.php RENAMED
File without changes
lib/index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * It was a place without a single feature of the space-time matrix that he
4
+ * knew. It was a place where nothing yet had happened - an utter emptiness.
5
+ * There was neither light nor dark: there was nothing here but emptiness.
6
+ * Clifford D. Simak
7
+ */
8
+ ?>
{includes → lib}/media-element/background.png RENAMED
File without changes
{includes → lib}/media-element/bigplay.png RENAMED
File without changes
{includes → lib}/media-element/controls-ted.png RENAMED
File without changes
{includes → lib}/media-element/controls-wmp-bg.png RENAMED
File without changes
{includes → lib}/media-element/controls-wmp.png RENAMED
File without changes
{includes → lib}/media-element/controls.png RENAMED
File without changes
{includes → lib}/media-element/flashmediaelement.swf RENAMED
File without changes
{includes → lib}/media-element/jquery.js RENAMED
File without changes
{includes → lib}/media-element/loading.gif RENAMED
File without changes
{includes → lib}/media-element/mediaelement-and-player.js RENAMED
File without changes
{includes → lib}/media-element/mediaelement-and-player.min.js RENAMED
File without changes
{includes → lib}/media-element/mediaelement.js RENAMED
File without changes
{includes → lib}/media-element/mediaelement.min.js RENAMED
File without changes
{includes → lib}/media-element/mediaelementplayer.css RENAMED
File without changes
{includes → lib}/media-element/mediaelementplayer.js RENAMED
File without changes
{includes → lib}/media-element/mediaelementplayer.min.css RENAMED
File without changes
{includes → lib}/media-element/mediaelementplayer.min.js RENAMED
File without changes
{includes → lib}/media-element/mejs-skins.css RENAMED
File without changes
{includes → lib}/media-element/silverlightmediaelement.xap RENAMED
File without changes
loader.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: BuddyPress Media
4
- Plugin URI: http://rtcamp.com/buddypress-media/
5
- Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
6
- Version: 2.3.2
7
- Author: rtCamp
8
- Author URI: http://rtcamp.com
9
- */
10
-
11
- /* A constant that can be checked to see if the BP Media is installed or not. */
12
- define('BP_MEDIA_IS_INSTALLED', 1);
13
-
14
- /* Constant to store the current version of the BP Media Plugin. */
15
- define('BP_MEDIA_VERSION', '2.3.2');
16
-
17
- /* A constant to be used as base for other URLs throughout the plugin */
18
- define('BP_MEDIA_PLUGIN_DIR', dirname(__FILE__));
19
-
20
- /* A constant to store the required */
21
- define('BP_MEDIA_REQUIRED_BP','1.6');
22
-
23
- /* A constatnt to store database version */
24
- define('BP_MEDIA_DB_VERSION','2.1');
25
-
26
- /* A constant to Active Collab API Assignee ID */
27
- define('BP_MEDIA_AC_API_ASSIGNEE_ID','5');
28
-
29
- /* A constant to Active Collab API Assignee ID */
30
- define('BP_MEDIA_AC_API_LABEL_ID','1');
31
-
32
- /* A constant to Active Collab API priority */
33
- define('BP_MEDIA_AC_API_PRIORITY','2');
34
-
35
- /* A constant to Active Collab API priority */
36
- define('BP_MEDIA_AC_API_CATEGORY_ID','224');
37
-
38
- /**
39
- * Function to initialize the BP Media Plugin
40
- *
41
- * It checks for the version minimum required version of buddypress before initializing.
42
- *
43
- * @uses BP_VERSION to check if the plugin supports the BuddyPress version.
44
- *
45
- * @since BP Media 2.0
46
- */
47
- function bp_media_init() {
48
- if (defined('BP_VERSION')&&version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '>')) {
49
- add_filter( 'plugin_action_links', 'bp_media_settings_link', 10, 2 );
50
- require( BP_MEDIA_PLUGIN_DIR . '/includes/bp-media-loader.php' );
51
- //require( BP_MEDIA_PLUGIN_DIR . '/includes/bp-media-groups-loader.php');
52
- }
53
- }
54
- add_action('bp_include', 'bp_media_init');
55
-
56
- /**
57
- * Function to do the tasks required to be done while activating the plugin
58
- */
59
- function bp_media_activate() {
60
- $bp_media_options = get_site_option('bp_media_options',array(
61
- 'videos_enabled' => true,
62
- 'audio_enabled' => true,
63
- 'images_enabled' => true,
64
- 'remove_linkback' => '1',
65
- 'download_enabled' => true,
66
- ));
67
- $previous_linkback_status = get_site_option('bp_media_remove_linkback');
68
- if($previous_linkback_status===false)
69
- $bp_media_options['remove_linkback'] = '1';
70
- else{
71
- $bp_media_options['remove_linkback'] = $previous_linkback_status;
72
- delete_option('bp_media_remove_linkback');
73
- }
74
- update_site_option('bp_media_options',$bp_media_options);
75
-
76
-
77
- $bpmquery = new WP_Query(array('post_type'=>'bp_media','posts_per_page'=>1));
78
- if($bpmquery->found_posts > 0){
79
- update_site_option('bp_media_db_version', '1.0');
80
- }else{
81
- switch(get_site_option('bp_media_db_version',false,false)){
82
- case '2.0':
83
- break;
84
- default:
85
- update_site_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
86
- }
87
- }
88
- }
89
-
90
- register_activation_hook(__FILE__, 'bp_media_activate');
91
-
92
- /**
93
- * Function to do the tasks during deactivation.
94
- *
95
- * Will Make this function to do the db deletion and other things that might have been created with the plugin.
96
- */
97
- function bp_media_deactivate() {
98
- //todo
99
- }
100
- register_deactivation_hook(__FILE__, 'bp_media_deactivate');
101
-
102
- function bp_media_admin_notice() {
103
- global $current_user ;
104
- $user_id = $current_user->ID;
105
- if ( isset($_GET['bp_media_nag_ignore']) && '0' == $_GET['bp_media_nag_ignore'] ) {
106
- add_user_meta($user_id, 'bp_media_ignore_notice', 'true', true);
107
- }
108
- /* Check that the user hasn't already clicked to ignore the message */
109
- if ( ! get_user_meta($user_id, 'bp_media_ignore_notice') ) {
110
- if(defined('BP_VERSION')){
111
- if (version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '<')) {
112
- echo '<div class="error"><p>';
113
- printf(__('The BuddyPress version installed is an older version and is not supported, please update BuddyPress to use BuddyPress Media Plugin.<a class="alignright" href="%1$s">X</a>'), '?bp_media_nag_ignore=0');
114
- echo "</p></div>";
115
- }
116
- }
117
- else {
118
- echo '<div class="error"><p>';
119
- printf(__('You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin.<a class="alignright" href="%1$s">X</a>'), '?bp_media_nag_ignore=0');
120
- echo "</p></div>";
121
- }
122
- }
123
- }
124
- add_action('admin_notices', 'bp_media_admin_notice');
125
-
126
- /**
127
- * Shows the settings link adjacent to the plugin in the plugins list
128
- * @since BP Media 2.0.4
129
- */
130
- function bp_media_settings_link($links, $file) {
131
- /* create link */
132
- $plugin_name = plugin_basename( __FILE__ );
133
- $admin_link = bp_media_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) );
134
- if ( $file == $plugin_name ) {
135
- array_unshift(
136
- $links,
137
- sprintf( '<a href="%s">%s</a>', $admin_link, __('Settings') )
138
- );
139
- }
140
- return $links;
141
- }
142
-
143
- function bp_media_get_admin_url( $path = '', $scheme = 'admin' ) {
144
-
145
- // Links belong in network admin
146
- if (is_multisite() )
147
- $url = network_admin_url( $path, $scheme );
148
-
149
- // Links belong in site admin
150
- else
151
- $url = admin_url( $path, $scheme );
152
-
153
- return $url;
154
- }
155
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
log/index.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * I think about that "empty" space a lot. That emptiness is what allows for
4
+ * something to actually evolve in a natural way. I've had to learn that over
5
+ * the years - because one of the traps of being an artist is to always want to
6
+ * be creating, always wanting to produce.
7
+ * Meredith Monk
8
+ */
9
+ ?>
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === BuddyPress Media ===
2
- Contributors: rtcamp, rahul286, gagan0123, umesh.nevase, suhasgirgaonkar, neerukoul
3
  Donate link: http://rtcamp.com/donate
4
  Tags: BuddyPress, media, multimedia, album, audio, songs, music, video, photo, image, upload, share, MediaElement.js, ffmpeg, kaltura, media-node
5
  License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: 3.3.2
8
  Tested up to: 3.4.2
9
- Stable tag: 2.3.2
10
 
11
  Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
12
 
@@ -18,6 +18,7 @@ BuddyPress Media adds Photos, Music, Videos & Albums to your BuddyPress. Support
18
 
19
  * Images, Music, Videos Upload
20
  * User-Albums Support
 
21
  * Multiple files upload with Drag-n-Drop
22
  * Uploading Photos/Videos via mobile (Tested on iPhone running iOS6)
23
  * HTML5 player (with fall back to flash/silverlight player support)
@@ -25,7 +26,6 @@ BuddyPress Media adds Photos, Music, Videos & Albums to your BuddyPress. Support
25
 
26
  = Roadmap =
27
 
28
- * Group Albums
29
  * Activity-update form media upload
30
  * Paid membership plans, i.e. "Upload Quota" for buddypress members (in planning stage).
31
 
@@ -73,6 +73,11 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
73
 
74
  Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
75
 
 
 
 
 
 
76
  = 2.3.2 =
77
  * Album creation on a single file upload. Thanks to [Josh Levinson](http://profiles.wordpress.org/joshlevinson/) for providing the fix.
78
  * Fixed Version number constant.
@@ -163,5 +168,5 @@ Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-medi
163
  * HTML5 Video Tag Support (with fallback)
164
 
165
  == Upgrade Notice ==
166
- Added album support for user-profile. Important update with plenty of new features.
167
-
1
  === BuddyPress Media ===
2
+ Contributors: rtcamp, rahul286, gagan0123, umesh.nevase, suhasgirgaonkar, neerukoul, saurabhshukla, JoshuaAbenazer, faishal, hrishiv90
3
  Donate link: http://rtcamp.com/donate
4
  Tags: BuddyPress, media, multimedia, album, audio, songs, music, video, photo, image, upload, share, MediaElement.js, ffmpeg, kaltura, media-node
5
  License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: 3.3.2
8
  Tested up to: 3.4.2
9
+ Stable tag: 2.4
10
 
11
  Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
12
 
18
 
19
  * Images, Music, Videos Upload
20
  * User-Albums Support
21
+ * Group Media Support
22
  * Multiple files upload with Drag-n-Drop
23
  * Uploading Photos/Videos via mobile (Tested on iPhone running iOS6)
24
  * HTML5 player (with fall back to flash/silverlight player support)
26
 
27
  = Roadmap =
28
 
 
29
  * Activity-update form media upload
30
  * Paid membership plans, i.e. "Upload Quota" for buddypress members (in planning stage).
31
 
73
 
74
  Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
75
 
76
+ = 2.4 =
77
+ * Total code overhaul. Fixed a lot of bugs and optimised a lot of other code.
78
+ * Added proper translation support!
79
+ * Removed extra jQuery UI scripts and styles, for speed and optimisation
80
+
81
  = 2.3.2 =
82
  * Album creation on a single file upload. Thanks to [Josh Levinson](http://profiles.wordpress.org/joshlevinson/) for providing the fix.
83
  * Fixed Version number constant.
168
  * HTML5 Video Tag Support (with fallback)
169
 
170
  == Upgrade Notice ==
171
+ =2.4=
172
+ Total code refactor. Translation ready! Faster and more optimised.