Version Description
- Fixes image rotation for PHP < 5.3 that caused upload failure
Download this release
Release Info
Developer | saurabhshukla |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.7.5 |
Comparing to | |
See all releases |
Code changes from version 2.7.4 to 2.7.5
- app/main/includes/BPMediaHostWordpress.php +1002 -1002
- index.php +1 -1
- readme.txt +6 -3
app/main/includes/BPMediaHostWordpress.php
CHANGED
@@ -2,1018 +2,1018 @@
|
|
2 |
|
3 |
class BPMediaHostWordpress {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
// $this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail', true);
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
FROM $wpdb->posts
|
987 |
WHERE
|
988 |
post_title = $post_wall
|
989 |
AND post_author = '" . get_current_user_id() . "'
|
990 |
AND post_type='bp_media_album'"
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
FROM $wpdb->posts
|
996 |
INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
997 |
AND $wpdb->postmeta.meta_key = 'bp-media-key'
|
998 |
AND $wpdb->postmeta.meta_value = -$group
|
999 |
-
AND $wpdb->posts.post_title = '$current_user->display_name\'s Album'");
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
|
1018 |
}
|
1019 |
?>
|
2 |
|
3 |
class BPMediaHostWordpress {
|
4 |
|
5 |
+
/**
|
6 |
+
* Private variables not to be accessible outside this class' member functions
|
7 |
+
*/
|
8 |
+
protected $id, //id of the entry
|
9 |
+
$name, //Name of the entry
|
10 |
+
$description, //Description of the entry
|
11 |
+
$url, //URL of the entry
|
12 |
+
$type, //Type of the entry (Video, Image or Audio)
|
13 |
+
$owner, //Owner of the entry
|
14 |
+
$delete_url, //The delete url for the media
|
15 |
+
$thumbnail_id, //The thumbnail's id
|
16 |
+
$album_id, //The album id to which the media belongs
|
17 |
+
$edit_url, //The edit page's url for the media
|
18 |
+
$group_id; //The group id of the current media file if it belongs to a group
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructs a new BP_Media_Host_Wordpress element
|
22 |
+
*
|
23 |
+
* @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
|
24 |
+
*
|
25 |
+
* @since BuddyPress Media 2.0
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @param type $media_id
|
31 |
+
*/
|
32 |
+
function __construct( $media_id = '' ) {
|
33 |
+
if ( $media_id != '' ) {
|
34 |
+
$this->init( $media_id );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initializes the object with the variables from the post
|
40 |
+
*
|
41 |
+
* @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
|
42 |
+
*
|
43 |
+
* @since BuddyPress Media 2.0
|
44 |
+
*/
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @param type $media_id
|
49 |
+
* @return boolean
|
50 |
+
* @throws Exception
|
51 |
+
*/
|
52 |
+
function init( $media_id = '' ) {
|
53 |
+
if ( is_object( $media_id ) ) {
|
54 |
+
$media = $media_id;
|
55 |
+
} else {
|
56 |
+
$media = &get_post( $media_id );
|
57 |
+
}
|
58 |
+
if ( empty( $media->ID ) )
|
59 |
+
throw new Exception( __( 'Sorry, the requested media does not exist.', BP_MEDIA_TXT_DOMAIN ) );
|
60 |
+
if ( ! 'bp_media_album' == $media->post_type || ! empty( $media->post_mime_type ) )
|
61 |
+
preg_match_all( '/audio|video|image/i', $media->post_mime_type, $result );
|
62 |
+
else
|
63 |
+
$result[ 0 ][ 0 ] = 'album';
|
64 |
+
if ( isset( $result[ 0 ][ 0 ] ) )
|
65 |
+
$this->type = $result[ 0 ][ 0 ];
|
66 |
+
else
|
67 |
+
return false;
|
68 |
+
|
69 |
+
|
70 |
+
global $bp;
|
71 |
+
$this->id = $media->ID;
|
72 |
+
$meta_key = get_post_meta( $this->id, 'bp-media-key', true );
|
73 |
+
|
74 |
+
/**
|
75 |
+
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
76 |
+
* if the value is less than 0 it means it the group id to which the media belongs
|
77 |
+
* and if its greater than 0 then it means its the author id of the uploader
|
78 |
+
* But for use in the class, we use group_id as positive integer even though
|
79 |
+
* we use it as negative value in the bp-media-key meta key
|
80 |
+
*/
|
81 |
+
$this->group_id = $meta_key < 0 ? -$meta_key : 0;
|
82 |
+
|
83 |
+
$this->description = $media->post_content;
|
84 |
+
$this->name = $media->post_title;
|
85 |
+
$this->owner = $media->post_author;
|
86 |
+
$this->album_id = $media->post_parent;
|
87 |
+
$this->mime_type = $media->post_mime_type;
|
88 |
+
|
89 |
+
|
90 |
+
$this->set_permalinks();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Handles the uploaded media file and creates attachment post for the file.
|
95 |
+
*
|
96 |
+
* @since BuddyPress Media 2.0
|
97 |
+
*/
|
98 |
+
|
99 |
+
/**
|
100 |
+
*
|
101 |
+
* @global type $bp
|
102 |
+
* @global type $wpdb
|
103 |
+
* @global type $bp_media_count
|
104 |
+
* @global type $bp_media
|
105 |
+
* @param type $name
|
106 |
+
* @param type $description
|
107 |
+
* @param type $album_id
|
108 |
+
* @param type $group
|
109 |
+
* @param type $is_multiple
|
110 |
+
* @throws Exception
|
111 |
+
* @uses global var $_FILES
|
112 |
+
*/
|
113 |
+
function add_media( $name, $description, $album_id = 0, $group = 0, $is_multiple = false, $is_activity = false, $files = false ) {
|
114 |
+
do_action( 'bp_media_before_add_media' );
|
115 |
+
|
116 |
+
global $bp, $wpdb, $bp_media;
|
117 |
+
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
118 |
+
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
119 |
+
|
120 |
+
$post_id = $this->check_and_create_album( $album_id, $group );
|
121 |
+
|
122 |
+
if ( ! $files ) {
|
123 |
+
$files = $_FILES[ 'bp_media_file' ];
|
124 |
+
$file = wp_handle_upload( $files );
|
125 |
+
} else {
|
126 |
+
$file = wp_handle_sideload( $files );
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( isset( $file[ 'error' ] ) || $file === null ) {
|
130 |
+
throw new Exception( __( 'Error Uploading File', BP_MEDIA_TXT_DOMAIN ) );
|
131 |
+
}
|
132 |
+
|
133 |
+
$type = $file[ 'type' ];
|
134 |
+
if ( in_array( $type, array( 'image/gif', 'image/jpeg', 'image/png' ) ) ) {
|
135 |
+
$file = $this->exif( $file );
|
136 |
+
}
|
137 |
+
|
138 |
+
$attachment = array( );
|
139 |
+
$url = $file[ 'url' ];
|
140 |
+
$file = $file[ 'file' ];
|
141 |
+
$title = $name;
|
142 |
+
$content = $description;
|
143 |
+
$attachment = array(
|
144 |
+
'post_mime_type' => $type,
|
145 |
+
'guid' => $url,
|
146 |
+
'post_title' => $title,
|
147 |
+
'post_content' => $content,
|
148 |
+
'post_parent' => $post_id,
|
149 |
+
);
|
150 |
+
switch ( $type ) {
|
151 |
+
case 'video/mp4' :
|
152 |
+
case 'video/quicktime' :
|
153 |
+
$type = 'video';
|
154 |
+
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
155 |
+
try {
|
156 |
+
$getID3 = new getID3;
|
157 |
+
$vid_info = $getID3->analyze( $file );
|
158 |
+
} catch ( Exception $e ) {
|
159 |
+
unlink( $file );
|
160 |
+
$activity_content = false;
|
161 |
+
throw new Exception( __( 'MP4 file you have uploaded is corrupt.', BP_MEDIA_TXT_DOMAIN ) );
|
162 |
+
}
|
163 |
+
if ( is_array( $vid_info ) ) {
|
164 |
+
if ( ! array_key_exists( 'error', $vid_info ) && array_key_exists( 'fileformat', $vid_info ) && array_key_exists( 'video', $vid_info ) && array_key_exists( 'fourcc', $vid_info[ 'video' ] ) ) {
|
165 |
+
if ( ! ($vid_info[ 'fileformat' ] == 'mp4' && $vid_info[ 'video' ][ 'fourcc' ] == 'avc1') ) {
|
166 |
+
unlink( $file );
|
167 |
+
$activity_content = false;
|
168 |
+
throw new Exception( __( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', BP_MEDIA_TXT_DOMAIN ) );
|
169 |
+
}
|
170 |
+
} else {
|
171 |
+
unlink( $file );
|
172 |
+
$activity_content = false;
|
173 |
+
throw new Exception( __( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', BP_MEDIA_TXT_DOMAIN ) );
|
174 |
+
}
|
175 |
+
} else {
|
176 |
+
unlink( $file );
|
177 |
+
$activity_content = false;
|
178 |
+
throw new Exception( __( 'The MP4 file you have uploaded is not a video file.', BP_MEDIA_TXT_DOMAIN ) );
|
179 |
+
}
|
180 |
+
break;
|
181 |
+
case 'audio/mpeg' :
|
182 |
+
include_once(trailingslashit( BP_MEDIA_PATH ) . 'lib/getid3/getid3.php');
|
183 |
+
try {
|
184 |
+
$getID3 = new getID3;
|
185 |
+
$file_info = $getID3->analyze( $file );
|
186 |
+
} catch ( Exception $e ) {
|
187 |
+
unlink( $file );
|
188 |
+
$activity_content = false;
|
189 |
+
throw new Exception( __( 'MP3 file you have uploaded is currupt.', BP_MEDIA_TXT_DOMAIN ) );
|
190 |
+
}
|
191 |
+
if ( is_array( $file_info ) ) {
|
192 |
+
if ( ! array_key_exists( 'error', $file_info ) && array_key_exists( 'fileformat', $file_info ) && array_key_exists( 'audio', $file_info ) && array_key_exists( 'dataformat', $file_info[ 'audio' ] ) ) {
|
193 |
+
if ( ! ($file_info[ 'fileformat' ] == 'mp3' && $file_info[ 'audio' ][ 'dataformat' ] == 'mp3') ) {
|
194 |
+
unlink( $file );
|
195 |
+
$activity_content = false;
|
196 |
+
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
unlink( $file );
|
200 |
+
$activity_content = false;
|
201 |
+
throw new Exception( __( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', BP_MEDIA_TXT_DOMAIN ) );
|
202 |
+
}
|
203 |
+
} else {
|
204 |
+
unlink( $file );
|
205 |
+
$activity_content = false;
|
206 |
+
throw new Exception( __( 'The MP3 file you have uploaded is not an audio file.', BP_MEDIA_TXT_DOMAIN ) );
|
207 |
+
}
|
208 |
+
$type = 'audio';
|
209 |
+
break;
|
210 |
+
case 'image/gif' :
|
211 |
+
case 'image/jpeg' :
|
212 |
+
case 'image/png' :
|
213 |
+
$type = 'image';
|
214 |
+
break;
|
215 |
+
default :
|
216 |
+
unlink( $file );
|
217 |
+
$activity_content = false;
|
218 |
+
throw new Exception( __( 'Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', BP_MEDIA_TXT_DOMAIN ) );
|
219 |
+
}
|
220 |
+
echo $attachment_id = wp_insert_attachment( $attachment, $file, $post_id );
|
221 |
+
if ( ! is_wp_error( $attachment_id ) ) {
|
222 |
+
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
|
223 |
+
} else {
|
224 |
+
unlink( $file );
|
225 |
+
throw new Exception( __( 'Error creating attachment for the media file, please try again', BP_MEDIA_TXT_DOMAIN ) );
|
226 |
+
}
|
227 |
+
$this->id = $attachment_id;
|
228 |
+
$this->name = $name;
|
229 |
+
$this->description = $description;
|
230 |
+
$this->type = $type;
|
231 |
+
$this->owner = get_current_user_id();
|
232 |
+
$this->album_id = $post_id;
|
233 |
+
$this->group_id = $group;
|
234 |
+
$this->set_permalinks();
|
235 |
+
if ( $group == 0 ) {
|
236 |
+
update_post_meta( $attachment_id, 'bp-media-key', get_current_user_id() );
|
237 |
+
} else {
|
238 |
+
update_post_meta( $attachment_id, 'bp-media-key', (-$group ) );
|
239 |
+
}
|
240 |
+
do_action( 'bp_media_after_add_media', $this, $is_multiple, $is_activity, $group );
|
241 |
+
return $attachment_id;
|
242 |
+
}
|
243 |
+
|
244 |
+
function get_media_thumbnail( $size = 'thumbnail' ) {
|
245 |
+
$thumb = '';
|
246 |
+
if ( in_array( $this->type, array( 'image', 'video', 'audio' ) ) ) {
|
247 |
+
if ( $this->thumbnail_id ) {
|
248 |
+
$medium_array = image_downsize( $this->thumbnail_id, $size );
|
249 |
+
$thumb_url = $medium_array[ 0 ];
|
250 |
+
} else {
|
251 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/' . $this->type . '_thumb.png';
|
252 |
+
}
|
253 |
+
$thumb = apply_filters( 'bp_media_video_thumb', $thumb_url, $this->thumbnail_id, $this->type );
|
254 |
+
return $thumb;
|
255 |
+
}
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Fetches the content of the activity of media upload based on its type
|
261 |
+
*
|
262 |
+
*/
|
263 |
+
|
264 |
+
/**
|
265 |
+
*
|
266 |
+
* @global type $bp_media_counter
|
267 |
+
* @global type $bp_media_default_excerpts
|
268 |
+
* @global type $bp_media
|
269 |
+
* @return boolean|string
|
270 |
+
*/
|
271 |
+
function get_media_activity_content() {
|
272 |
+
global $bp_media_counter, $bp_media_default_excerpts, $bp_media;
|
273 |
+
$attachment_id = $this->id;
|
274 |
+
$activity_content = apply_filters( 'bp_media_single_activity_title', '<div class="bp_media_title"><a href="' . $this->url . '" title="' . __( $this->description, BP_MEDIA_TXT_DOMAIN ) . '">' . __( wp_html_excerpt( $this->name, $bp_media_default_excerpts[ 'activity_entry_title' ] ), BP_MEDIA_TXT_DOMAIN ) . '</a></div>' );
|
275 |
+
$activity_content .='<div class="bp_media_content">';
|
276 |
+
switch ( $this->type ) {
|
277 |
+
case 'video' :
|
278 |
+
if ( $this->thumbnail_id ) {
|
279 |
+
$image_array = image_downsize( $this->thumbnail_id, 'bp_media_activity_image' );
|
280 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<video poster="' . $image_array[ 0 ] . '" src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" height="240" type="video/mp4" id="bp_media_video_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none"></video></span>', $this, true );
|
281 |
+
} else {
|
282 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<video src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" height="240" type="video/mp4" id="bp_media_video_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none"></video></span>', $this, true );
|
283 |
+
}
|
284 |
+
break;
|
285 |
+
case 'audio' :
|
286 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<audio src="' . wp_get_attachment_url( $attachment_id ) . '" width="320" type="audio/mp3" id="bp_media_audio_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none" ></audio></span>', $this, true );
|
287 |
+
$type = 'audio';
|
288 |
+
break;
|
289 |
+
case 'image' :
|
290 |
+
$image_array = image_downsize( $attachment_id, 'bp_media_activity_image' );
|
291 |
+
$activity_content.=apply_filters( 'bp_media_single_activity_filter', '<a href="' . $this->url . '" title="' . __( $this->name, BP_MEDIA_TXT_DOMAIN ) . '"><img src="' . $image_array[ 0 ] . '" id="bp_media_image_' . $this->id . '_' . $bp_media_counter ++ . '" alt="' . __( $this->name, BP_MEDIA_TXT_DOMAIN ) . '" /></a>', $this, true );
|
292 |
+
$type = 'image';
|
293 |
+
break;
|
294 |
+
default :
|
295 |
+
return false;
|
296 |
+
}
|
297 |
+
$activity_content .= '</div>';
|
298 |
+
$activity_content .= apply_filters( 'bp_media_single_activity_description', '<div class="bp_media_description">' . wp_html_excerpt( $this->description, $bp_media_default_excerpts[ 'activity_entry_description' ] ) . '</div>' );
|
299 |
+
return $activity_content;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Returns the single media entry's URL
|
304 |
+
*/
|
305 |
+
|
306 |
+
/**
|
307 |
+
*
|
308 |
+
* @return boolean
|
309 |
+
*/
|
310 |
+
function get_media_activity_url() {
|
311 |
+
if ( ! bp_is_activity_component() )
|
312 |
+
return false;
|
313 |
+
$activity_url = $this->url;
|
314 |
+
return $activity_url;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Returns the media activity's action text
|
319 |
+
*/
|
320 |
+
|
321 |
+
/**
|
322 |
+
*
|
323 |
+
* @global type $bp_media
|
324 |
+
* @return boolean
|
325 |
+
*/
|
326 |
+
function get_media_activity_action() {
|
327 |
+
global $bp_media;
|
328 |
+
if ( ! bp_is_activity_component() )
|
329 |
+
return false;
|
330 |
+
$activity_action = sprintf( __( "%s uploaded a media.", BP_MEDIA_TXT_DOMAIN ), bp_core_get_userlink( $this->owner ) );
|
331 |
+
return $activity_action;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Returns the HTML for content of the single entry page of the Media Entry
|
336 |
+
*/
|
337 |
+
|
338 |
+
/**
|
339 |
+
*
|
340 |
+
* @global type $bp_media_default_excerpts
|
341 |
+
* @global type $bp_media
|
342 |
+
* @return boolean|string
|
343 |
+
*/
|
344 |
+
function get_media_single_content() {
|
345 |
+
global $bp_media_default_excerpts, $bp_media;
|
346 |
+
|
347 |
+
$default_sizes = $bp_media->media_sizes();
|
348 |
+
$content = '';
|
349 |
+
if ( $this->group_id > 0 ) {
|
350 |
+
|
351 |
+
$content .= '<div class="bp_media_author">' . __( "Uploaded by ", BP_MEDIA_TXT_DOMAIN ) . bp_core_get_userlink( $this->owner ) . '</div>';
|
352 |
+
}
|
353 |
+
$content .= '<div class="bp_media_content">';
|
354 |
+
switch ( $this->type ) {
|
355 |
+
case 'video' :
|
356 |
+
if ( $this->thumbnail_id ) {
|
357 |
+
$image_array = image_downsize( $this->thumbnail_id, 'bp_media_single_image' );
|
358 |
+
$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 );
|
359 |
+
} else {
|
360 |
+
$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 );
|
361 |
+
}
|
362 |
+
break;
|
363 |
+
case 'audio' :
|
364 |
+
$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 );
|
365 |
+
break;
|
366 |
+
case 'image' :
|
367 |
+
$image_array = image_downsize( $this->id, 'bp_media_single_image' );
|
368 |
+
$content.=apply_filters( 'bp_media_single_content_filter', '<img src="' . $image_array[ 0 ] . '" id="bp_media_image_' . $this->id . '" />', $this );
|
369 |
+
break;
|
370 |
+
default :
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
$content .= '</div>';
|
374 |
+
$content .= '<div class="bp_media_description">' . nl2br( $this->description ) . '</div>';
|
375 |
+
return $content;
|
376 |
+
}
|
377 |
+
|
378 |
+
public function exif( $file ) {
|
379 |
+
$exif = read_exif_data( $file[ 'file' ] );
|
380 |
+
$exif_orient = isset( $exif[ 'Orientation' ] ) ? $exif[ 'Orientation' ] : 0;
|
381 |
+
$rotateImage = 0;
|
382 |
+
|
383 |
+
if ( 6 == $exif_orient ) {
|
384 |
+
$rotateImage = 90;
|
385 |
+
$imageOrientation = 1;
|
386 |
+
} elseif ( 3 == $exif_orient ) {
|
387 |
+
$rotateImage = 180;
|
388 |
+
$imageOrientation = 1;
|
389 |
+
} elseif ( 8 == $exif_orient ) {
|
390 |
+
$rotateImage = 270;
|
391 |
+
$imageOrientation = 1;
|
392 |
+
}
|
393 |
+
|
394 |
+
if ( $rotateImage > 0 ) {
|
395 |
+
if ( class_exists( 'Imagick' ) ) {
|
396 |
+
$imagick = new Imagick();
|
397 |
+
$imagick->readImage( $file[ 'file' ] );
|
398 |
+
$imagick->rotateImage( new ImagickPixel(), $rotateImage );
|
399 |
+
$imagick->setImageOrientation( $imageOrientation );
|
400 |
+
$imagick->writeImage( $file[ 'file' ] );
|
401 |
+
$imagick->clear();
|
402 |
+
$imagick->destroy();
|
403 |
+
} else {
|
404 |
+
$rotateImage = -$rotateImage;
|
405 |
+
|
406 |
+
switch ( $file[ 'type' ] ) {
|
407 |
+
case 'image/jpeg':
|
408 |
+
$source = imagecreatefromjpeg( $file[ 'file' ] );
|
409 |
+
$rotate = imagerotate( $source, $rotateImage, 0 );
|
410 |
+
imagejpeg( $rotate, $file[ 'file' ] );
|
411 |
+
break;
|
412 |
+
case 'image/png':
|
413 |
+
$source = imagecreatefrompng( $file[ 'file' ] );
|
414 |
+
$rotate = imagerotate( $source, $rotateImage, 0 );
|
415 |
+
imagepng( $rotate, $file[ 'file' ] );
|
416 |
+
break;
|
417 |
+
case 'image/gif':
|
418 |
+
$source = imagecreatefromgif( $file[ 'file' ] );
|
419 |
+
$rotate = imagerotate( $source, $rotateImage, 0 );
|
420 |
+
imagegif( $rotate, $file[ 'file' ] );
|
421 |
+
break;
|
422 |
+
default:
|
423 |
+
break;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
}
|
427 |
+
return $file;
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Returns the HTML for title of the single entry page of the Media Entry
|
432 |
+
*/
|
433 |
+
|
434 |
+
/**
|
435 |
+
*
|
436 |
+
* @global type $bp_media_default_excerpts
|
437 |
+
* @global type $bp_media
|
438 |
+
* @return string
|
439 |
+
*/
|
440 |
+
function get_media_single_title() {
|
441 |
+
global $bp_media_default_excerpts, $bp_media;
|
442 |
+
$content = wp_html_excerpt( $this->name, $bp_media_default_excerpts[ 'single_entry_title' ] );
|
443 |
+
return $content;
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
448 |
+
*/
|
449 |
+
|
450 |
+
/**
|
451 |
+
*
|
452 |
+
* @global type $bp_media
|
453 |
+
* @return boolean
|
454 |
+
*/
|
455 |
+
function get_media_gallery_content() {
|
456 |
+
$attachment = $this->id;
|
457 |
+
switch ( $this->type ) {
|
458 |
+
case 'video' :
|
459 |
+
if ( $this->thumbnail_id ) {
|
460 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
461 |
+
$thumb_url = $medium_array[ 0 ];
|
462 |
+
} else {
|
463 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/video_thumb.png';
|
464 |
+
}
|
465 |
+
?>
|
466 |
+
<li id="bp-media-item-<?php echo $this->id ?>">
|
467 |
+
<a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>">
|
468 |
+
<img src="<?php echo apply_filters( 'bp_media_video_thumb', $thumb_url, $attachment, $this->type ); ?>" />
|
469 |
+
</a>
|
470 |
+
<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>
|
471 |
+
</li>
|
472 |
+
<?php
|
473 |
+
break;
|
474 |
+
case 'audio' :
|
475 |
+
if ( $this->thumbnail_id ) {
|
476 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
477 |
+
$thumb_url = $medium_array[ 0 ];
|
478 |
+
} else {
|
479 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/audio_thumb.png';
|
480 |
+
}
|
481 |
+
?>
|
482 |
+
<li id="bp-media-item-<?php echo $this->id ?>">
|
483 |
+
<a href="<?php echo $this->url ?>" title="<?php _e( $this->description, BP_MEDIA_TXT_DOMAIN ); ?>">
|
484 |
+
<img src="<?php echo $thumb_url ?>" />
|
485 |
+
</a>
|
486 |
+
<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>
|
487 |
+
<div class="bp-media-ajax-preloader"></div>
|
488 |
+
</li>
|
489 |
+
<?php
|
490 |
+
break;
|
491 |
+
case 'image' :
|
492 |
+
$medium_array = image_downsize( $attachment, 'thumbnail' );
|
493 |
+
$medium_path = $medium_array[ 0 ];
|
494 |
+
?>
|
495 |
+
<li id="bp-media-item-<?php echo $this->id ?>">
|
496 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
497 |
+
<img src="<?php echo $medium_path ?>" />
|
498 |
+
</a>
|
499 |
+
<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>
|
500 |
+
<div class="bp-media-ajax-preloader"></div>
|
501 |
+
</li>
|
502 |
+
<?php
|
503 |
+
break;
|
504 |
+
default :
|
505 |
+
return false;
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
function show_comment_form_wordpress() {
|
510 |
+
query_posts( 'attachment_id=' . $this->id );
|
511 |
+
while ( have_posts() ): the_post();
|
512 |
+
add_action( 'comment_form', 'BPMediaFunction::wp_comment_form_mod' );
|
513 |
+
comments_template();
|
514 |
+
endwhile;
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Outputs the comments and comment form in the single media entry page
|
519 |
+
*/
|
520 |
+
|
521 |
+
/**
|
522 |
+
*
|
523 |
+
* @global type $bp_media
|
524 |
+
* @return boolean
|
525 |
+
*/
|
526 |
+
function show_comment_form() {
|
527 |
+
global $bp_media;
|
528 |
+
$activity_id = get_post_meta( $this->id, 'bp_media_child_activity', true );
|
529 |
+
if ( ! $activity_id || ! function_exists( 'bp_has_activities' ) )
|
530 |
+
return false;
|
531 |
+
if ( bp_has_activities( array(
|
532 |
+
'display_comments' => 'stream',
|
533 |
+
'include' => $activity_id,
|
534 |
+
'max' => 1
|
535 |
+
) ) ) {
|
536 |
+
while ( bp_activities() ) {
|
537 |
+
bp_the_activity();
|
538 |
+
do_action( 'bp_before_activity_entry' );
|
539 |
+
?>
|
540 |
+
<div class="activity">
|
541 |
+
<ul id="activity-stream" class="activity-list item-list">
|
542 |
+
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
543 |
+
<div class="activity-content">
|
544 |
+
<?php do_action( 'bp_activity_entry_content' ); ?>
|
545 |
+
<?php if ( is_user_logged_in() ) : ?>
|
546 |
+
<div class="activity-meta no-ajax">
|
547 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
548 |
+
<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>
|
549 |
+
<?php endif; ?>
|
550 |
+
<?php if ( bp_activity_can_favorite() ) : ?>
|
551 |
+
<?php if ( ! bp_get_activity_is_favorite() ) : ?>
|
552 |
+
<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>
|
553 |
+
<?php else : ?>
|
554 |
+
<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>
|
555 |
+
<?php endif; ?>
|
556 |
+
<?php endif; ?>
|
557 |
+
<?php do_action( 'bp_activity_entry_meta' ); ?>
|
558 |
+
<?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?>
|
559 |
+
</div>
|
560 |
+
<?php endif; ?>
|
561 |
+
</div>
|
562 |
+
<?php do_action( 'bp_before_activity_entry_comments' ); ?>
|
563 |
+
<?php if ( ( is_user_logged_in() && bp_activity_can_comment() ) || bp_activity_get_comment_count() ) : ?>
|
564 |
+
<div class="activity-comments">
|
565 |
+
<?php bp_activity_comments(); ?>
|
566 |
+
<?php if ( is_user_logged_in() ) : ?>
|
567 |
+
<form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>>
|
568 |
+
<div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?></div>
|
569 |
+
<div class="ac-reply-content">
|
570 |
+
<div class="ac-textarea">
|
571 |
+
<textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
|
572 |
+
</div>
|
573 |
+
<input type="submit" name="ac_form_submit" value="<?php _e( 'Post', BP_MEDIA_TXT_DOMAIN ); ?>" /> <?php _e( 'or press esc to cancel.', BP_MEDIA_TXT_DOMAIN ); ?>
|
574 |
+
<input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
|
575 |
+
</div>
|
576 |
+
<?php do_action( 'bp_activity_entry_comments' ); ?>
|
577 |
+
<?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ); ?>
|
578 |
+
</form>
|
579 |
+
<?php endif; ?>
|
580 |
+
</div>
|
581 |
+
<?php endif; ?>
|
582 |
+
<?php do_action( 'bp_after_activity_entry_comments' ); ?>
|
583 |
+
</li>
|
584 |
+
</ul>
|
585 |
+
</div>
|
586 |
+
<?php
|
587 |
+
}
|
588 |
+
}
|
589 |
+
else {
|
590 |
+
?>
|
591 |
+
<div class="activity">
|
592 |
+
<ul id="activity-stream" class="activity-list item-list">
|
593 |
+
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
594 |
+
<div class="activity-content">
|
595 |
+
<?php do_action( 'bp_activity_entry_content' ); ?>
|
596 |
+
<?php if ( is_user_logged_in() ) : ?>
|
597 |
+
<div class="activity-meta no-ajax">
|
598 |
+
<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>
|
599 |
+
</div>
|
600 |
+
<?php endif; ?>
|
601 |
+
</div>
|
602 |
+
</li>
|
603 |
+
</ul>
|
604 |
+
</div>
|
605 |
+
<?php
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Returns the URL of the single media entry page
|
611 |
+
*/
|
612 |
+
|
613 |
+
/**
|
614 |
+
*
|
615 |
+
* @return type
|
616 |
+
*/
|
617 |
+
function get_url() {
|
618 |
+
return $this->url;
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* Returns the URL of the attached media file
|
623 |
+
*/
|
624 |
+
|
625 |
+
/**
|
626 |
+
*
|
627 |
+
* @return type
|
628 |
+
*/
|
629 |
+
function get_attachment_url() {
|
630 |
+
return wp_get_attachment_url( $this->id );
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Updates the media entry
|
635 |
+
*
|
636 |
+
* @param array $args Array with the following keys:<br/>
|
637 |
+
* 'name' <br/>
|
638 |
+
* 'description'<br/>
|
639 |
+
* 'owner'
|
640 |
+
*
|
641 |
+
* @return bool True when the update is successful, False when the update fails
|
642 |
+
*/
|
643 |
+
|
644 |
+
/**
|
645 |
+
*
|
646 |
+
* @param type $args
|
647 |
+
* @return type
|
648 |
+
*/
|
649 |
+
function update_media( $args = array( ) ) {
|
650 |
+
$defaults = array(
|
651 |
+
'name' => $this->name,
|
652 |
+
'description' => $this->description,
|
653 |
+
'owner' => $this->owner
|
654 |
+
);
|
655 |
+
$args = wp_parse_args( $args, $defaults );
|
656 |
+
$post = get_post( $this->id, ARRAY_A );
|
657 |
+
$post[ 'post_title' ] = esc_html( $args[ 'name' ] );
|
658 |
+
$post[ 'post_content' ] = esc_html( $args[ 'description' ] );
|
659 |
+
$post[ 'post_author' ] = $args[ 'owner' ];
|
660 |
+
$result = wp_update_post( $post );
|
661 |
+
$this->init( $this->id );
|
662 |
+
do_action( 'bp_media_after_update_media', $this );
|
663 |
+
return $result;
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Updates activity content's title and description sync with the editing of Media
|
668 |
+
*
|
669 |
+
*/
|
670 |
+
|
671 |
+
/**
|
672 |
+
*
|
673 |
+
* @global type $wpdb
|
674 |
+
* @global type $bp
|
675 |
+
* @global type $current_user
|
676 |
+
* @global type $bp_media
|
677 |
+
*/
|
678 |
+
function update_media_activity() {
|
679 |
+
global $wpdb, $bp, $current_user, $bp_media;
|
680 |
+
$q = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id );
|
681 |
+
$activities = $wpdb->get_results( $q );
|
682 |
+
if ( isset( $activities ) && count( $activities ) > 0 ) {
|
683 |
+
$activities_template = new BP_Activity_Template( array(
|
684 |
+
'max' => TRUE,
|
685 |
+
'user_id' => $current_user,
|
686 |
+
'in' => $activities[ 0 ]->id
|
687 |
+
) );
|
688 |
+
foreach ( $activities_template->activities as $activity ) {
|
689 |
+
if ( isset( $_POST[ 'bp_media_group_id' ] ) ) {
|
690 |
+
$component = $bp->groups->id;
|
691 |
+
$item_id = $_POST[ 'bp_media_group_id' ];
|
692 |
+
} else {
|
693 |
+
$component = $bp->activity->id;
|
694 |
+
$item_id = $this->get_id();
|
695 |
+
}
|
696 |
+
$args = array(
|
697 |
+
'content' => $this->get_media_activity_content(),
|
698 |
+
'id' => $activity->id,
|
699 |
+
'type' => $component,
|
700 |
+
'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>' ) ),
|
701 |
+
'primary_link' => $this->get_url(),
|
702 |
+
'item_id' => $item_id,
|
703 |
+
'recorded_time' => $activity->date_recorded,
|
704 |
+
'user_id' => $this->get_author()
|
705 |
+
);
|
706 |
+
$activity_id = BPMediaFunction::record_activity( $args );
|
707 |
+
}
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
/**
|
712 |
+
* Deletes the Media Entry
|
713 |
+
*/
|
714 |
+
|
715 |
+
/**
|
716 |
+
*
|
717 |
+
* @global type $bp_media_count
|
718 |
+
*/
|
719 |
+
function delete_media() {
|
720 |
+
do_action( 'bp_media_before_delete_media', $this->id );
|
721 |
+
wp_delete_attachment( $this->id, true );
|
722 |
+
do_action( 'bp_media_after_delete_media', $this->id );
|
723 |
+
}
|
724 |
+
|
725 |
+
/**
|
726 |
+
* Function to return the content to be placed in the activity of album
|
727 |
+
*/
|
728 |
+
|
729 |
+
/**
|
730 |
+
*
|
731 |
+
* @return boolean|string
|
732 |
+
*/
|
733 |
+
function get_album_activity_content() {
|
734 |
+
$attachment = $this->id;
|
735 |
+
switch ( $this->type ) {
|
736 |
+
case 'video' :
|
737 |
+
if ( $this->thumbnail_id ) {
|
738 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
739 |
+
$thumb_url = $medium_array[ 0 ];
|
740 |
+
} else {
|
741 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/video_thumb.png';
|
742 |
+
}
|
743 |
+
break;
|
744 |
+
case 'audio' :
|
745 |
+
if ( $this->thumbnail_id ) {
|
746 |
+
$medium_array = image_downsize( $this->thumbnail_id, 'thumbnail' );
|
747 |
+
$thumb_url = $medium_array[ 0 ];
|
748 |
+
} else {
|
749 |
+
$thumb_url = BP_MEDIA_URL . 'app/assets/img/audio_thumb.png';
|
750 |
+
}
|
751 |
+
break;
|
752 |
+
case 'image' :
|
753 |
+
$medium_array = image_downsize( $attachment, 'thumbnail' );
|
754 |
+
$thumb_url = $medium_array[ 0 ];
|
755 |
+
break;
|
756 |
+
default :
|
757 |
+
return false;
|
758 |
+
}
|
759 |
+
$content = '<li>';
|
760 |
+
$content .= '<a href="' . $this->url . '" title="' . $this->name . '">';
|
761 |
+
$content .= '<img src="' . $thumb_url . '" />';
|
762 |
+
$content .= '</a>';
|
763 |
+
$content .= '</li>';
|
764 |
+
return $content;
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* Returns the description of the Media Entry
|
769 |
+
*/
|
770 |
+
|
771 |
+
/**
|
772 |
+
*
|
773 |
+
* @return type
|
774 |
+
*/
|
775 |
+
function get_content() {
|
776 |
+
return $this->description;
|
777 |
+
}
|
778 |
+
|
779 |
+
/**
|
780 |
+
* Returns the owner id of the Media Entry
|
781 |
+
*/
|
782 |
+
|
783 |
+
/**
|
784 |
+
*
|
785 |
+
* @return type
|
786 |
+
*/
|
787 |
+
function get_author() {
|
788 |
+
return $this->owner;
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Returns the id of the Media Entry
|
793 |
+
*/
|
794 |
+
|
795 |
+
/**
|
796 |
+
*
|
797 |
+
* @return type
|
798 |
+
*/
|
799 |
+
function get_id() {
|
800 |
+
return $this->id;
|
801 |
+
}
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Returns the edit url of the Media Entry
|
805 |
+
*/
|
806 |
+
|
807 |
+
/**
|
808 |
+
*
|
809 |
+
* @return type
|
810 |
+
*/
|
811 |
+
function get_edit_url() {
|
812 |
+
return $this->edit_url;
|
813 |
+
}
|
814 |
+
|
815 |
+
/**
|
816 |
+
* Returns the delete url of the Media Entry
|
817 |
+
*/
|
818 |
+
|
819 |
+
/**
|
820 |
+
*
|
821 |
+
* @return type
|
822 |
+
*/
|
823 |
+
function get_delete_url() {
|
824 |
+
return $this->delete_url;
|
825 |
+
}
|
826 |
+
|
827 |
+
/**
|
828 |
+
* Returns the type of activity
|
829 |
+
*/
|
830 |
+
|
831 |
+
/**
|
832 |
+
*
|
833 |
+
* @return string
|
834 |
+
*/
|
835 |
+
function get_media_activity_type() {
|
836 |
+
switch ( $this->type ) {
|
837 |
+
case 'image':
|
838 |
+
return BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
839 |
+
case 'video':
|
840 |
+
return BP_MEDIA_VIDEOS_LABEL_SINGULAR;
|
841 |
+
case 'audio':
|
842 |
+
return BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
843 |
+
default:
|
844 |
+
return 'Media';
|
845 |
+
}
|
846 |
+
}
|
847 |
+
|
848 |
+
/**
|
849 |
+
* Returns the album id
|
850 |
+
*/
|
851 |
+
|
852 |
+
/**
|
853 |
+
*
|
854 |
+
* @return type
|
855 |
+
*/
|
856 |
+
function get_album_id() {
|
857 |
+
return $this->album_id;
|
858 |
+
}
|
859 |
+
|
860 |
+
/**
|
861 |
+
* Returns the title of the media
|
862 |
+
*/
|
863 |
+
|
864 |
+
/**
|
865 |
+
*
|
866 |
+
* @return type
|
867 |
+
*/
|
868 |
+
function get_title() {
|
869 |
+
return $this->name;
|
870 |
+
}
|
871 |
+
|
872 |
+
/**
|
873 |
+
* Returns the type of media
|
874 |
+
*/
|
875 |
+
|
876 |
+
/**
|
877 |
+
*
|
878 |
+
* @return type
|
879 |
+
*/
|
880 |
+
function get_type() {
|
881 |
+
return $this->type;
|
882 |
+
}
|
883 |
+
|
884 |
+
/**
|
885 |
+
* Returns the thumbnail id
|
886 |
+
*/
|
887 |
+
function get_thumbnail_id() {
|
888 |
+
return $this->thumbnail_id;
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Returns the group id of the media, 0 if it does not belong to a group
|
893 |
+
*/
|
894 |
+
|
895 |
+
/**
|
896 |
+
*
|
897 |
+
* @return type
|
898 |
+
*/
|
899 |
+
function get_group_id() {
|
900 |
+
return $this->group_id;
|
901 |
+
}
|
902 |
+
|
903 |
+
/**
|
904 |
+
* Sets the permalinks of the media depending upon whether its in member directory
|
905 |
+
* or group and acording to the media type
|
906 |
+
*/
|
907 |
+
|
908 |
+
/**
|
909 |
+
*
|
910 |
+
* @return boolean
|
911 |
+
*/
|
912 |
+
protected function set_permalinks() {
|
913 |
+
|
914 |
+
if ( bp_is_active( 'groups' ) && class_exists( 'BP_Group_Extension' ) ) {
|
915 |
+
if ( $this->group_id > 0 ) {
|
916 |
+
$current_group = new BP_Groups_Group( $this->group_id );
|
917 |
+
$pre_url = bp_get_group_permalink( $current_group );
|
918 |
+
} else {
|
919 |
+
$pre_url = bp_core_get_user_domain( $this->owner );
|
920 |
+
}
|
921 |
+
} else {
|
922 |
+
$pre_url = bp_core_get_user_domain( $this->owner );
|
923 |
+
}
|
924 |
+
switch ( $this->type ) {
|
925 |
+
case 'video' :
|
926 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . $this->id );
|
927 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id );
|
928 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
929 |
+
$this->thumbnail_id = get_post_meta( $this->id, 'bp_media_thumbnail', true );
|
930 |
+
break;
|
931 |
+
case 'audio' :
|
932 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . $this->id );
|
933 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id );
|
934 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
935 |
+
$this->thumbnail_id = get_post_meta( $this->id, 'bp_media_thumbnail', true );
|
936 |
+
break;
|
937 |
+
case 'image' :
|
938 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . $this->id );
|
939 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id );
|
940 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
941 |
+
$image_array = image_downsize( $this->id, 'bp_media_single_image' );
|
942 |
+
$this->thumbnail_id = $this->id;
|
943 |
+
break;
|
944 |
+
case 'album' :
|
945 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id );
|
946 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id );
|
947 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id );
|
948 |
// $this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail', true);
|
949 |
+
break;
|
950 |
+
default :
|
951 |
+
return false;
|
952 |
+
}
|
953 |
+
return true;
|
954 |
+
}
|
955 |
+
|
956 |
+
/**
|
957 |
+
* Checks if the album given exists if not, creates a new one according to context
|
958 |
+
*/
|
959 |
+
|
960 |
+
/**
|
961 |
+
*
|
962 |
+
* @global type $wpdb
|
963 |
+
* @param type $album_id
|
964 |
+
* @param type $group
|
965 |
+
* @return type
|
966 |
+
*/
|
967 |
+
function check_and_create_album( $album_id, $group ) {
|
968 |
+
global $wpdb;
|
969 |
+
$post_wall = __( 'Wall Posts', BP_MEDIA_TXT_DOMAIN );
|
970 |
+
$create_new_album_flag = false;
|
971 |
+
if ( $album_id != 0 ) {
|
972 |
+
$album = get_post( $album_id );
|
973 |
+
if ( $album->post_author != get_current_user_id() && $group == 0 ) {
|
974 |
+
$create_new_album_flag = true;
|
975 |
+
} else {
|
976 |
+
$post_id = $album->ID;
|
977 |
+
}
|
978 |
+
} else {
|
979 |
+
$create_new_album_flag = true;
|
980 |
+
}
|
981 |
+
$current_user = wp_get_current_user();
|
982 |
+
if ( $create_new_album_flag ) {
|
983 |
+
if ( $group == 0 ) {
|
984 |
+
$post_id = $wpdb->get_var(
|
985 |
+
"SELECT ID
|
986 |
FROM $wpdb->posts
|
987 |
WHERE
|
988 |
post_title = $post_wall
|
989 |
AND post_author = '" . get_current_user_id() . "'
|
990 |
AND post_type='bp_media_album'"
|
991 |
+
);
|
992 |
+
} else {
|
993 |
+
$post_id = $wpdb->get_var(
|
994 |
+
"SELECT wp_posts.ID
|
995 |
FROM $wpdb->posts
|
996 |
INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
997 |
AND $wpdb->postmeta.meta_key = 'bp-media-key'
|
998 |
AND $wpdb->postmeta.meta_value = -$group
|
999 |
+
AND $wpdb->posts.post_title = '$current_user->display_name\'s Album'" );
|
1000 |
+
}
|
1001 |
+
if ( $post_id == null ) {
|
1002 |
+
$album = new BPMediaAlbum();
|
1003 |
+
if ( $group == 0 )
|
1004 |
+
$album->add_album( $post_wall, get_current_user_id(), $group );
|
1005 |
+
else {
|
1006 |
+
$album->add_album( $current_user->display_name . '\'s Album', get_current_user_id(), $group );
|
1007 |
+
}
|
1008 |
+
$post_id = $album->get_id();
|
1009 |
+
}
|
1010 |
+
}
|
1011 |
+
return $post_id;
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
function get_description() {
|
1015 |
+
return $this->description;
|
1016 |
+
}
|
1017 |
|
1018 |
}
|
1019 |
?>
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
-
Version: 2.7.
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
+
Version: 2.7.5
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
|
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: WordPress 3.5 + BuddyPress 1.6
|
8 |
Tested up to: WordPress 3.5 + BuddyPress 1.6
|
9 |
-
Stable tag: 2.7.
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
@@ -122,6 +122,9 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
122 |
|
123 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit BuddyPress Media's Features page") to get some details about future releases.
|
124 |
|
|
|
|
|
|
|
125 |
= 2.7.4 =
|
126 |
* Added french translation
|
127 |
* Fixed Widget privacy
|
@@ -339,5 +342,5 @@ Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-medi
|
|
339 |
* HTML5 Video Tag Support (with fallback)
|
340 |
|
341 |
== Upgrade Notice ==
|
342 |
-
= 2.7.
|
343 |
-
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: WordPress 3.5 + BuddyPress 1.6
|
8 |
Tested up to: WordPress 3.5 + BuddyPress 1.6
|
9 |
+
Stable tag: 2.7.5
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
122 |
|
123 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit BuddyPress Media's Features page") to get some details about future releases.
|
124 |
|
125 |
+
= 2.7.5 =
|
126 |
+
* Fixes image rotation for PHP < 5.3 that caused upload failure
|
127 |
+
|
128 |
= 2.7.4 =
|
129 |
* Added french translation
|
130 |
* Fixed Widget privacy
|
342 |
* HTML5 Video Tag Support (with fallback)
|
343 |
|
344 |
== Upgrade Notice ==
|
345 |
+
= 2.7.5 =
|
346 |
+
Bug fix for PHP < 5.3 fixes image uploads
|