Version Description
- Add Media Count
- Fixed Setting for Upload media
- Fixed Feature image issue
- Other minor bug fixes
Download this release
Release Info
Developer | faishal |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 3.0.9 |
Comparing to | |
See all releases |
Code changes from version 3.0.7 to 3.0.9
- app/assets/css/main.css +1 -1
- app/assets/js/rtMedia.backbone.js +6 -2
- app/assets/js/rtMedia.js +11 -3
- app/assets/sass/main.scss +1 -0
- app/helper/RTMediaModel.php +234 -196
- app/helper/db/RTDBUpdate.php +1 -0
- app/helper/rtForm.php +79 -14
- app/importers/RTMediaMigration.php +455 -460
- app/main/RTMedia.php +774 -734
- app/main/contexts/RTMediaContext.php +28 -25
- app/main/controllers/activity/RTMediaBuddyPressActivity.php +102 -104
- app/main/controllers/media/RTMediaAlbum.php +482 -488
- app/main/controllers/media/RTMediaFeatured.php +95 -89
- app/main/controllers/media/RTMediaMedia.php +170 -165
- app/main/controllers/media/RTMediaUserInteraction.php +1 -1
- app/main/controllers/privacy/RTMediaFriends.php +2 -2
- app/main/controllers/privacy/RTMediaPrivacy.php +38 -20
- app/main/controllers/shortcodes/RTMediaGalleryShortcode.php +100 -89
- app/main/controllers/shortcodes/RTMediaUploadShortcode.php +26 -15
- app/main/controllers/template/RTMediaAJAX.php +2 -2
- app/main/controllers/template/RTMediaNav.php +316 -286
- app/main/controllers/template/RTMediaTemplate.php +21 -6
- app/main/controllers/template/RTMediaUploadTemplate.php +23 -23
- app/main/controllers/template/rt-template-functions.php +402 -366
- app/main/controllers/upload/RTMediaUploadEndpoint.php +63 -56
- app/main/controllers/upload/RTMediaUploadModel.php +53 -54
- app/main/controllers/upload/RTMediaUploadView.php +79 -77
- app/main/controllers/upload/processors/RTMediaUploadFile.php +134 -131
- app/main/interactions/RTMediaInteraction.php +149 -160
- app/main/routers/RTMediaRouter.php +119 -130
- app/main/routers/query/RTMediaQuery.php +704 -704
- app/services/RTMediaEncoding.php +322 -320
- index.php +61 -63
- readme.txt +15 -4
- templates/media/album-gallery-item.php +5 -5
- templates/media/album-gallery.php +37 -37
- templates/media/media-gallery.php +29 -29
- templates/upload/uploader.php +43 -44
app/assets/css/main.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.rtmedia-container,.rtmedia-activity-container,#buddypress div.rtmedia-activity-container{padding:5px;margin:0;clear:left}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html,.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body,.rtmedia-container div,.rtmedia-activity-container div,#buddypress div.rtmedia-activity-container div,.rtmedia-container span,.rtmedia-activity-container span,#buddypress div.rtmedia-activity-container span,.rtmedia-container applet,.rtmedia-activity-container applet,#buddypress div.rtmedia-activity-container applet,.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container iframe,.rtmedia-activity-container iframe,#buddypress div.rtmedia-activity-container iframe,.rtmedia-container h1,.rtmedia-activity-container h1,#buddypress div.rtmedia-activity-container h1,.rtmedia-container h2,.rtmedia-activity-container h2,#buddypress div.rtmedia-activity-container h2,.rtmedia-container h3,.rtmedia-activity-container h3,#buddypress div.rtmedia-activity-container h3,.rtmedia-container h4,.rtmedia-activity-container h4,#buddypress div.rtmedia-activity-container h4,.rtmedia-container h5,.rtmedia-activity-container h5,#buddypress div.rtmedia-activity-container h5,.rtmedia-container h6,.rtmedia-activity-container h6,#buddypress div.rtmedia-activity-container h6,.rtmedia-container p,.rtmedia-activity-container p,#buddypress div.rtmedia-activity-container p,.rtmedia-container blockquote,.rtmedia-activity-container blockquote,#buddypress div.rtmedia-activity-container blockquote,.rtmedia-container pre,.rtmedia-activity-container pre,#buddypress div.rtmedia-activity-container pre,.rtmedia-container a,.rtmedia-activity-container a,#buddypress div.rtmedia-activity-container a,.rtmedia-container abbr,.rtmedia-activity-container abbr,#buddypress div.rtmedia-activity-container abbr,.rtmedia-container acronym,.rtmedia-activity-container acronym,#buddypress div.rtmedia-activity-container acronym,.rtmedia-container address,.rtmedia-activity-container address,#buddypress div.rtmedia-activity-container address,.rtmedia-container big,.rtmedia-activity-container big,#buddypress div.rtmedia-activity-container big,.rtmedia-container cite,.rtmedia-activity-container cite,#buddypress div.rtmedia-activity-container cite,.rtmedia-container code,.rtmedia-activity-container code,#buddypress div.rtmedia-activity-container code,.rtmedia-container del,.rtmedia-activity-container del,#buddypress div.rtmedia-activity-container del,.rtmedia-container dfn,.rtmedia-activity-container dfn,#buddypress div.rtmedia-activity-container dfn,.rtmedia-container em,.rtmedia-activity-container em,#buddypress div.rtmedia-activity-container em,.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img,.rtmedia-container ins,.rtmedia-activity-container ins,#buddypress div.rtmedia-activity-container ins,.rtmedia-container kbd,.rtmedia-activity-container kbd,#buddypress div.rtmedia-activity-container kbd,.rtmedia-container q,.rtmedia-activity-container q,#buddypress div.rtmedia-activity-container q,.rtmedia-container s,.rtmedia-activity-container s,#buddypress div.rtmedia-activity-container s,.rtmedia-container samp,.rtmedia-activity-container samp,#buddypress div.rtmedia-activity-container samp,.rtmedia-container small,.rtmedia-activity-container small,#buddypress div.rtmedia-activity-container small,.rtmedia-container strike,.rtmedia-activity-container strike,#buddypress div.rtmedia-activity-container strike,.rtmedia-container strong,.rtmedia-activity-container strong,#buddypress div.rtmedia-activity-container strong,.rtmedia-container sub,.rtmedia-activity-container sub,#buddypress div.rtmedia-activity-container sub,.rtmedia-container sup,.rtmedia-activity-container sup,#buddypress div.rtmedia-activity-container sup,.rtmedia-container tt,.rtmedia-activity-container tt,#buddypress div.rtmedia-activity-container tt,.rtmedia-container var,.rtmedia-activity-container var,#buddypress div.rtmedia-activity-container var,.rtmedia-container b,.rtmedia-activity-container b,#buddypress div.rtmedia-activity-container b,.rtmedia-container u,.rtmedia-activity-container u,#buddypress div.rtmedia-activity-container u,.rtmedia-container i,.rtmedia-activity-container i,#buddypress div.rtmedia-activity-container i,.rtmedia-container center,.rtmedia-activity-container center,#buddypress div.rtmedia-activity-container center,.rtmedia-container dl,.rtmedia-activity-container dl,#buddypress div.rtmedia-activity-container dl,.rtmedia-container dt,.rtmedia-activity-container dt,#buddypress div.rtmedia-activity-container dt,.rtmedia-container dd,.rtmedia-activity-container dd,#buddypress div.rtmedia-activity-container dd,.rtmedia-container ol,.rtmedia-activity-container ol,#buddypress div.rtmedia-activity-container ol,.rtmedia-container ul,.rtmedia-activity-container ul,#buddypress div.rtmedia-activity-container ul,.rtmedia-container li,.rtmedia-activity-container li,#buddypress div.rtmedia-activity-container li,.rtmedia-container fieldset,.rtmedia-activity-container fieldset,#buddypress div.rtmedia-activity-container fieldset,.rtmedia-container form,.rtmedia-activity-container form,#buddypress div.rtmedia-activity-container form,.rtmedia-container label,.rtmedia-activity-container label,#buddypress div.rtmedia-activity-container label,.rtmedia-container legend,.rtmedia-activity-container legend,#buddypress div.rtmedia-activity-container legend,.rtmedia-container table,.rtmedia-activity-container table,#buddypress div.rtmedia-activity-container table,.rtmedia-container caption,.rtmedia-activity-container caption,#buddypress div.rtmedia-activity-container caption,.rtmedia-container tbody,.rtmedia-activity-container tbody,#buddypress div.rtmedia-activity-container tbody,.rtmedia-container tfoot,.rtmedia-activity-container tfoot,#buddypress div.rtmedia-activity-container tfoot,.rtmedia-container thead,.rtmedia-activity-container thead,#buddypress div.rtmedia-activity-container thead,.rtmedia-container tr,.rtmedia-activity-container tr,#buddypress div.rtmedia-activity-container tr,.rtmedia-container th,.rtmedia-activity-container th,#buddypress div.rtmedia-activity-container th,.rtmedia-container td,.rtmedia-activity-container td,#buddypress div.rtmedia-activity-container td,.rtmedia-container article,.rtmedia-activity-container article,#buddypress div.rtmedia-activity-container article,.rtmedia-container aside,.rtmedia-activity-container aside,#buddypress div.rtmedia-activity-container aside,.rtmedia-container canvas,.rtmedia-activity-container canvas,#buddypress div.rtmedia-activity-container canvas,.rtmedia-container details,.rtmedia-activity-container details,#buddypress div.rtmedia-activity-container details,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed,.rtmedia-container figure,.rtmedia-activity-container figure,#buddypress div.rtmedia-activity-container figure,.rtmedia-container figcaption,.rtmedia-activity-container figcaption,#buddypress div.rtmedia-activity-container figcaption,.rtmedia-container footer,.rtmedia-activity-container footer,#buddypress div.rtmedia-activity-container footer,.rtmedia-container header,.rtmedia-activity-container header,#buddypress div.rtmedia-activity-container header,.rtmedia-container hgroup,.rtmedia-activity-container hgroup,#buddypress div.rtmedia-activity-container hgroup,.rtmedia-container menu,.rtmedia-activity-container menu,#buddypress div.rtmedia-activity-container menu,.rtmedia-container nav,.rtmedia-activity-container nav,#buddypress div.rtmedia-activity-container nav,.rtmedia-container output,.rtmedia-activity-container output,#buddypress div.rtmedia-activity-container output,.rtmedia-container ruby,.rtmedia-activity-container ruby,#buddypress div.rtmedia-activity-container ruby,.rtmedia-container section,.rtmedia-activity-container section,#buddypress div.rtmedia-activity-container section,.rtmedia-container summary,.rtmedia-activity-container summary,#buddypress div.rtmedia-activity-container summary,.rtmedia-container time,.rtmedia-activity-container time,#buddypress div.rtmedia-activity-container time,.rtmedia-container mark,.rtmedia-activity-container mark,#buddypress div.rtmedia-activity-container mark,.rtmedia-container audio,.rtmedia-activity-container audio,#buddypress div.rtmedia-activity-container audio,.rtmedia-container video,.rtmedia-activity-container video,#buddypress div.rtmedia-activity-container video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html{line-height:1}.rtmedia-container ol,.rtmedia-activity-container ol,#buddypress div.rtmedia-activity-container ol,.rtmedia-container ul,.rtmedia-activity-container ul,#buddypress div.rtmedia-activity-container ul{list-style:none}.rtmedia-container table,.rtmedia-activity-container table,#buddypress div.rtmedia-activity-container table{border-collapse:collapse;border-spacing:0}.rtmedia-container caption,.rtmedia-activity-container caption,#buddypress div.rtmedia-activity-container caption,.rtmedia-container th,.rtmedia-activity-container th,#buddypress div.rtmedia-activity-container th,.rtmedia-container td,.rtmedia-activity-container td,#buddypress div.rtmedia-activity-container td{text-align:left;font-weight:normal;vertical-align:middle}.rtmedia-container q,.rtmedia-activity-container q,#buddypress div.rtmedia-activity-container q,.rtmedia-container blockquote,.rtmedia-activity-container blockquote,#buddypress div.rtmedia-activity-container blockquote{quotes:none}.rtmedia-container q:before,.rtmedia-activity-container q:before,#buddypress div.rtmedia-activity-container q:before,.rtmedia-container q:after,.rtmedia-activity-container q:after,#buddypress div.rtmedia-activity-container q:after,.rtmedia-container blockquote:before,.rtmedia-activity-container blockquote:before,#buddypress div.rtmedia-activity-container blockquote:before,.rtmedia-container blockquote:after,.rtmedia-activity-container blockquote:after,#buddypress div.rtmedia-activity-container blockquote:after{content:"";content:none}.rtmedia-container a img,.rtmedia-activity-container a img,#buddypress div.rtmedia-activity-container a img{border:none}.rtmedia-container article,.rtmedia-activity-container article,#buddypress div.rtmedia-activity-container article,.rtmedia-container aside,.rtmedia-activity-container aside,#buddypress div.rtmedia-activity-container aside,.rtmedia-container details,.rtmedia-activity-container details,#buddypress div.rtmedia-activity-container details,.rtmedia-container figcaption,.rtmedia-activity-container figcaption,#buddypress div.rtmedia-activity-container figcaption,.rtmedia-container figure,.rtmedia-activity-container figure,#buddypress div.rtmedia-activity-container figure,.rtmedia-container footer,.rtmedia-activity-container footer,#buddypress div.rtmedia-activity-container footer,.rtmedia-container header,.rtmedia-activity-container header,#buddypress div.rtmedia-activity-container header,.rtmedia-container hgroup,.rtmedia-activity-container hgroup,#buddypress div.rtmedia-activity-container hgroup,.rtmedia-container menu,.rtmedia-activity-container menu,#buddypress div.rtmedia-activity-container menu,.rtmedia-container nav,.rtmedia-activity-container nav,#buddypress div.rtmedia-activity-container nav,.rtmedia-container section,.rtmedia-activity-container section,#buddypress div.rtmedia-activity-container section,.rtmedia-container summary,.rtmedia-activity-container summary,#buddypress div.rtmedia-activity-container summary{display:block}.rtmedia-container *,.rtmedia-activity-container *,#buddypress div.rtmedia-activity-container *,.rtmedia-container *:before,.rtmedia-activity-container *:before,#buddypress div.rtmedia-activity-container *:before,.rtmedia-container *:after,.rtmedia-activity-container *:after,#buddypress div.rtmedia-activity-container *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html,.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body{font-size:100%}.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative;cursor:default}.rtmedia-container a:hover,.rtmedia-activity-container a:hover,#buddypress div.rtmedia-activity-container a:hover{cursor:pointer}.rtmedia-container a:focus,.rtmedia-activity-container a:focus,#buddypress div.rtmedia-activity-container a:focus{outline:none}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img,.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed{max-width:100%;height:auto}.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed{height:100%}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img{-ms-interpolation-mode:bicubic}.rtmedia-container #map_canvas img,.rtmedia-activity-container #map_canvas img,.rtmedia-container #map_canvas embed,.rtmedia-activity-container #map_canvas embed,.rtmedia-container #map_canvas object,.rtmedia-activity-container #map_canvas object,.rtmedia-container .map_canvas img,.rtmedia-activity-container .map_canvas img,#buddypress div.rtmedia-activity-container .map_canvas img,.rtmedia-container .map_canvas embed,.rtmedia-activity-container .map_canvas embed,#buddypress div.rtmedia-activity-container .map_canvas embed,.rtmedia-container .map_canvas object,.rtmedia-activity-container .map_canvas object,#buddypress div.rtmedia-activity-container .map_canvas object{max-width:none !important}.rtmedia-container .left,.rtmedia-activity-container .left,#buddypress div.rtmedia-activity-container .left{float:left !important}.rtmedia-container .right,.rtmedia-activity-container .right,#buddypress div.rtmedia-activity-container .right{float:right !important}.rtmedia-container .text-left,.rtmedia-activity-container .text-left,#buddypress div.rtmedia-activity-container .text-left{text-align:left !important}.rtmedia-container .text-right,.rtmedia-activity-container .text-right,#buddypress div.rtmedia-activity-container .text-right{text-align:right !important}.rtmedia-container .text-center,.rtmedia-activity-container .text-center,#buddypress div.rtmedia-activity-container .text-center{text-align:center !important}.rtmedia-container .text-justify,.rtmedia-activity-container .text-justify,#buddypress div.rtmedia-activity-container .text-justify{text-align:justify !important}.rtmedia-container .hide,.rtmedia-activity-container .hide,#buddypress div.rtmedia-activity-container .hide{display:none}.rtmedia-container .antialiased,.rtmedia-activity-container .antialiased,#buddypress div.rtmedia-activity-container .antialiased{-webkit-font-smoothing:antialiased}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img{display:inline-block;vertical-align:middle}.rtmedia-container textarea,.rtmedia-activity-container textarea,#buddypress div.rtmedia-activity-container textarea{height:auto;min-height:50px}.rtmedia-container select,.rtmedia-activity-container select,#buddypress div.rtmedia-activity-container select{width:100%}.rtmedia-container .row,.rtmedia-activity-container .row,#buddypress div.rtmedia-activity-container .row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1}.rtmedia-container .row:before,.rtmedia-activity-container .row:before,#buddypress div.rtmedia-activity-container .row:before,.rtmedia-container .row:after,.rtmedia-activity-container .row:after,#buddypress div.rtmedia-activity-container .row:after{content:" ";display:table}.rtmedia-container .row:after,.rtmedia-activity-container .row:after,#buddypress div.rtmedia-activity-container .row:after{clear:both}.rtmedia-container .row.collapse .column,.rtmedia-activity-container .row.collapse .column,#buddypress div.rtmedia-activity-container .row.collapse .column,.rtmedia-container .row.collapse .columns,.rtmedia-activity-container .row.collapse .columns,#buddypress div.rtmedia-activity-container .row.collapse .columns{position:relative;padding-left:0;padding-right:0;float:left}.rtmedia-container .row .row,.rtmedia-activity-container .row .row,#buddypress div.rtmedia-activity-container .row .row{width:auto;margin-left:-0.9375em;margin-right:-0.9375em;margin-top:0;margin-bottom:0;max-width:none;*zoom:1}.rtmedia-container .row .row:before,.rtmedia-activity-container .row .row:before,#buddypress div.rtmedia-activity-container .row .row:before,.rtmedia-container .row .row:after,.rtmedia-activity-container .row .row:after,#buddypress div.rtmedia-activity-container .row .row:after{content:" ";display:table}.rtmedia-container .row .row:after,.rtmedia-activity-container .row .row:after,#buddypress div.rtmedia-activity-container .row .row:after{clear:both}.rtmedia-container .row .row.collapse,.rtmedia-activity-container .row .row.collapse,#buddypress div.rtmedia-activity-container .row .row.collapse{width:auto;margin:0;max-width:none;*zoom:1}.rtmedia-container .row .row.collapse:before,.rtmedia-activity-container .row .row.collapse:before,#buddypress div.rtmedia-activity-container .row .row.collapse:before,.rtmedia-container .row .row.collapse:after,.rtmedia-activity-container .row .row.collapse:after,#buddypress div.rtmedia-activity-container .row .row.collapse:after{content:" ";display:table}.rtmedia-container .row .row.collapse:after,.rtmedia-activity-container .row .row.collapse:after,#buddypress div.rtmedia-activity-container .row .row.collapse:after{clear:both}.rtmedia-container .column,.rtmedia-activity-container .column,#buddypress div.rtmedia-activity-container .column,.rtmedia-container .columns,.rtmedia-activity-container .columns,#buddypress div.rtmedia-activity-container .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;width:100%;float:left}@media only screen{.rtmedia-container .column,.rtmedia-activity-container .column,#buddypress div.rtmedia-activity-container .column,.rtmedia-container .columns,.rtmedia-activity-container .columns,#buddypress div.rtmedia-activity-container .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;float:left}.rtmedia-container .small-1,.rtmedia-activity-container .small-1,#buddypress div.rtmedia-activity-container .small-1{position:relative;width:8.33333%}.rtmedia-container .small-2,.rtmedia-activity-container .small-2,#buddypress div.rtmedia-activity-container .small-2{position:relative;width:16.66667%}.rtmedia-container .small-3,.rtmedia-activity-container .small-3,#buddypress div.rtmedia-activity-container .small-3{position:relative;width:25%}.rtmedia-container .small-4,.rtmedia-activity-container .small-4,#buddypress div.rtmedia-activity-container .small-4{position:relative;width:33.33333%}.rtmedia-container .small-5,.rtmedia-activity-container .small-5,#buddypress div.rtmedia-activity-container .small-5{position:relative;width:41.66667%}.rtmedia-container .small-6,.rtmedia-activity-container .small-6,#buddypress div.rtmedia-activity-container .small-6{position:relative;width:50%}.rtmedia-container .small-7,.rtmedia-activity-container .small-7,#buddypress div.rtmedia-activity-container .small-7{position:relative;width:58.33333%}.rtmedia-container .small-8,.rtmedia-activity-container .small-8,#buddypress div.rtmedia-activity-container .small-8{position:relative;width:66.66667%}.rtmedia-container .small-9,.rtmedia-activity-container .small-9,#buddypress div.rtmedia-activity-container .small-9{position:relative;width:75%}.rtmedia-container .small-10,.rtmedia-activity-container .small-10,#buddypress div.rtmedia-activity-container .small-10{position:relative;width:83.33333%}.rtmedia-container .small-11,.rtmedia-activity-container .small-11,#buddypress div.rtmedia-activity-container .small-11{position:relative;width:91.66667%}.rtmedia-container .small-12,.rtmedia-activity-container .small-12,#buddypress div.rtmedia-activity-container .small-12{position:relative;width:100%}.rtmedia-container .small-offset-0,.rtmedia-activity-container .small-offset-0,#buddypress div.rtmedia-activity-container .small-offset-0{position:relative;margin-left:0%}.rtmedia-container .small-offset-1,.rtmedia-activity-container .small-offset-1,#buddypress div.rtmedia-activity-container .small-offset-1{position:relative;margin-left:8.33333%}.rtmedia-container .small-offset-2,.rtmedia-activity-container .small-offset-2,#buddypress div.rtmedia-activity-container .small-offset-2{position:relative;margin-left:16.66667%}.rtmedia-container .small-offset-3,.rtmedia-activity-container .small-offset-3,#buddypress div.rtmedia-activity-container .small-offset-3{position:relative;margin-left:25%}.rtmedia-container .small-offset-4,.rtmedia-activity-container .small-offset-4,#buddypress div.rtmedia-activity-container .small-offset-4{position:relative;margin-left:33.33333%}.rtmedia-container .small-offset-5,.rtmedia-activity-container .small-offset-5,#buddypress div.rtmedia-activity-container .small-offset-5{position:relative;margin-left:41.66667%}.rtmedia-container .small-offset-6,.rtmedia-activity-container .small-offset-6,#buddypress div.rtmedia-activity-container .small-offset-6{position:relative;margin-left:50%}.rtmedia-container .small-offset-7,.rtmedia-activity-container .small-offset-7,#buddypress div.rtmedia-activity-container .small-offset-7{position:relative;margin-left:58.33333%}.rtmedia-container .small-offset-8,.rtmedia-activity-container .small-offset-8,#buddypress div.rtmedia-activity-container .small-offset-8{position:relative;margin-left:66.66667%}.rtmedia-container .small-offset-9,.rtmedia-activity-container .small-offset-9,#buddypress div.rtmedia-activity-container .small-offset-9{position:relative;margin-left:75%}.rtmedia-container .small-offset-10,.rtmedia-activity-container .small-offset-10,#buddypress div.rtmedia-activity-container .small-offset-10{position:relative;margin-left:83.33333%}.rtmedia-container [class*="column"]+[class*="column"]:last-child,.rtmedia-activity-container [class*="column"]+[class*="column"]:last-child,#buddypress div.rtmedia-activity-container [class*="column"]+[class*="column"]:last-child{float:right}.rtmedia-container [class*="column"]+[class*="column"].end,.rtmedia-activity-container [class*="column"]+[class*="column"].end,#buddypress div.rtmedia-activity-container [class*="column"]+[class*="column"].end{float:left}.rtmedia-container .column.small-centered,.rtmedia-activity-container .column.small-centered,#buddypress div.rtmedia-activity-container .column.small-centered,.rtmedia-container .columns.small-centered,.rtmedia-activity-container .columns.small-centered,#buddypress div.rtmedia-activity-container .columns.small-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}}@media only screen and (min-width: 768px){.rtmedia-container .large-1,.rtmedia-activity-container .large-1,#buddypress div.rtmedia-activity-container .large-1{position:relative;width:8.33333%}.rtmedia-container .large-2,.rtmedia-activity-container .large-2,#buddypress div.rtmedia-activity-container .large-2{position:relative;width:16.66667%}.rtmedia-container .large-3,.rtmedia-activity-container .large-3,#buddypress div.rtmedia-activity-container .large-3{position:relative;width:25%}.rtmedia-container .large-4,.rtmedia-activity-container .large-4,#buddypress div.rtmedia-activity-container .large-4{position:relative;width:33.33333%}.rtmedia-container .large-5,.rtmedia-activity-container .large-5,#buddypress div.rtmedia-activity-container .large-5{position:relative;width:41.66667%}.rtmedia-container .large-6,.rtmedia-activity-container .large-6,#buddypress div.rtmedia-activity-container .large-6{position:relative;width:50%}.rtmedia-container .large-7,.rtmedia-activity-container .large-7,#buddypress div.rtmedia-activity-container .large-7{position:relative;width:58.33333%}.rtmedia-container .large-8,.rtmedia-activity-container .large-8,#buddypress div.rtmedia-activity-container .large-8{position:relative;width:66.66667%}.rtmedia-container .large-9,.rtmedia-activity-container .large-9,#buddypress div.rtmedia-activity-container .large-9{position:relative;width:75%}.rtmedia-container .large-10,.rtmedia-activity-container .large-10,#buddypress div.rtmedia-activity-container .large-10{position:relative;width:83.33333%}.rtmedia-container .large-11,.rtmedia-activity-container .large-11,#buddypress div.rtmedia-activity-container .large-11{position:relative;width:91.66667%}.rtmedia-container .large-12,.rtmedia-activity-container .large-12,#buddypress div.rtmedia-activity-container .large-12{position:relative;width:100%}.rtmedia-container .row .large-offset-0,.rtmedia-activity-container .row .large-offset-0,#buddypress div.rtmedia-activity-container .row .large-offset-0{position:relative;margin-left:0%}.rtmedia-container .row .large-offset-1,.rtmedia-activity-container .row .large-offset-1,#buddypress div.rtmedia-activity-container .row .large-offset-1{position:relative;margin-left:8.33333%}.rtmedia-container .row .large-offset-2,.rtmedia-activity-container .row .large-offset-2,#buddypress div.rtmedia-activity-container .row .large-offset-2{position:relative;margin-left:16.66667%}.rtmedia-container .row .large-offset-3,.rtmedia-activity-container .row .large-offset-3,#buddypress div.rtmedia-activity-container .row .large-offset-3{position:relative;margin-left:25%}.rtmedia-container .row .large-offset-4,.rtmedia-activity-container .row .large-offset-4,#buddypress div.rtmedia-activity-container .row .large-offset-4{position:relative;margin-left:33.33333%}.rtmedia-container .row .large-offset-5,.rtmedia-activity-container .row .large-offset-5,#buddypress div.rtmedia-activity-container .row .large-offset-5{position:relative;margin-left:41.66667%}.rtmedia-container .row .large-offset-6,.rtmedia-activity-container .row .large-offset-6,#buddypress div.rtmedia-activity-container .row .large-offset-6{position:relative;margin-left:50%}.rtmedia-container .row .large-offset-7,.rtmedia-activity-container .row .large-offset-7,#buddypress div.rtmedia-activity-container .row .large-offset-7{position:relative;margin-left:58.33333%}.rtmedia-container .row .large-offset-8,.rtmedia-activity-container .row .large-offset-8,#buddypress div.rtmedia-activity-container .row .large-offset-8{position:relative;margin-left:66.66667%}.rtmedia-container .row .large-offset-9,.rtmedia-activity-container .row .large-offset-9,#buddypress div.rtmedia-activity-container .row .large-offset-9{position:relative;margin-left:75%}.rtmedia-container .row .large-offset-10,.rtmedia-activity-container .row .large-offset-10,#buddypress div.rtmedia-activity-container .row .large-offset-10{position:relative;margin-left:83.33333%}.rtmedia-container .row .large-offset-11,.rtmedia-activity-container .row .large-offset-11,#buddypress div.rtmedia-activity-container .row .large-offset-11{position:relative;margin-left:91.66667%}.rtmedia-container .push-1,.rtmedia-activity-container .push-1,#buddypress div.rtmedia-activity-container .push-1{position:relative;left:8.33333%;right:auto}.rtmedia-container .pull-1,.rtmedia-activity-container .pull-1,#buddypress div.rtmedia-activity-container .pull-1{position:relative;right:8.33333%;left:auto}.rtmedia-container .push-2,.rtmedia-activity-container .push-2,#buddypress div.rtmedia-activity-container .push-2{position:relative;left:16.66667%;right:auto}.rtmedia-container .pull-2,.rtmedia-activity-container .pull-2,#buddypress div.rtmedia-activity-container .pull-2{position:relative;right:16.66667%;left:auto}.rtmedia-container .push-3,.rtmedia-activity-container .push-3,#buddypress div.rtmedia-activity-container .push-3{position:relative;left:25%;right:auto}.rtmedia-container .pull-3,.rtmedia-activity-container .pull-3,#buddypress div.rtmedia-activity-container .pull-3{position:relative;right:25%;left:auto}.rtmedia-container .push-4,.rtmedia-activity-container .push-4,#buddypress div.rtmedia-activity-container .push-4{position:relative;left:33.33333%;right:auto}.rtmedia-container .pull-4,.rtmedia-activity-container .pull-4,#buddypress div.rtmedia-activity-container .pull-4{position:relative;right:33.33333%;left:auto}.rtmedia-container .push-5,.rtmedia-activity-container .push-5,#buddypress div.rtmedia-activity-container .push-5{position:relative;left:41.66667%;right:auto}.rtmedia-container .pull-5,.rtmedia-activity-container .pull-5,#buddypress div.rtmedia-activity-container .pull-5{position:relative;right:41.66667%;left:auto}.rtmedia-container .push-6,.rtmedia-activity-container .push-6,#buddypress div.rtmedia-activity-container .push-6{position:relative;left:50%;right:auto}.rtmedia-container .pull-6,.rtmedia-activity-container .pull-6,#buddypress div.rtmedia-activity-container .pull-6{position:relative;right:50%;left:auto}.rtmedia-container .push-7,.rtmedia-activity-container .push-7,#buddypress div.rtmedia-activity-container .push-7{position:relative;left:58.33333%;right:auto}.rtmedia-container .pull-7,.rtmedia-activity-container .pull-7,#buddypress div.rtmedia-activity-container .pull-7{position:relative;right:58.33333%;left:auto}.rtmedia-container .push-8,.rtmedia-activity-container .push-8,#buddypress div.rtmedia-activity-container .push-8{position:relative;left:66.66667%;right:auto}.rtmedia-container .pull-8,.rtmedia-activity-container .pull-8,#buddypress div.rtmedia-activity-container .pull-8{position:relative;right:66.66667%;left:auto}.rtmedia-container .push-9,.rtmedia-activity-container .push-9,#buddypress div.rtmedia-activity-container .push-9{position:relative;left:75%;right:auto}.rtmedia-container .pull-9,.rtmedia-activity-container .pull-9,#buddypress div.rtmedia-activity-container .pull-9{position:relative;right:75%;left:auto}.rtmedia-container .push-10,.rtmedia-activity-container .push-10,#buddypress div.rtmedia-activity-container .push-10{position:relative;left:83.33333%;right:auto}.rtmedia-container .pull-10,.rtmedia-activity-container .pull-10,#buddypress div.rtmedia-activity-container .pull-10{position:relative;right:83.33333%;left:auto}.rtmedia-container .push-11,.rtmedia-activity-container .push-11,#buddypress div.rtmedia-activity-container .push-11{position:relative;left:91.66667%;right:auto}.rtmedia-container .pull-11,.rtmedia-activity-container .pull-11,#buddypress div.rtmedia-activity-container .pull-11{position:relative;right:91.66667%;left:auto}.rtmedia-container .column.large-centered,.rtmedia-activity-container .column.large-centered,#buddypress div.rtmedia-activity-container .column.large-centered,.rtmedia-container .columns.large-centered,.rtmedia-activity-container .columns.large-centered,#buddypress div.rtmedia-activity-container .columns.large-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}.rtmedia-container .column.large-uncentered,.rtmedia-activity-container .column.large-uncentered,#buddypress div.rtmedia-activity-container .column.large-uncentered,.rtmedia-container .columns.large-uncentered,.rtmedia-activity-container .columns.large-uncentered,#buddypress div.rtmedia-activity-container .columns.large-uncentered{margin-left:0;margin-right:0;float:left !important}.rtmedia-container .column.large-uncentered.opposite,.rtmedia-activity-container .column.large-uncentered.opposite,#buddypress div.rtmedia-activity-container .column.large-uncentered.opposite,.rtmedia-container .columns.large-uncentered.opposite,.rtmedia-activity-container .columns.large-uncentered.opposite,#buddypress div.rtmedia-activity-container .columns.large-uncentered.opposite{float:right !important}}.rtmedia-container .show-for-small,.rtmedia-activity-container .show-for-small,#buddypress div.rtmedia-activity-container .show-for-small,.rtmedia-container .show-for-medium-down,.rtmedia-activity-container .show-for-medium-down,#buddypress div.rtmedia-activity-container .show-for-medium-down,.rtmedia-container .show-for-large-down,.rtmedia-activity-container .show-for-large-down,#buddypress div.rtmedia-activity-container .show-for-large-down{display:inherit !important}.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-up,.rtmedia-activity-container .show-for-medium-up,#buddypress div.rtmedia-activity-container .show-for-medium-up,.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-up,.rtmedia-activity-container .show-for-large-up,#buddypress div.rtmedia-activity-container .show-for-large-up,.rtmedia-container .show-for-xlarge,.rtmedia-activity-container .show-for-xlarge,#buddypress div.rtmedia-activity-container .show-for-xlarge{display:none !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-up,.rtmedia-activity-container .hide-for-medium-up,#buddypress div.rtmedia-activity-container .hide-for-medium-up,.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-up,.rtmedia-activity-container .hide-for-large-up,#buddypress div.rtmedia-activity-container .hide-for-large-up,.rtmedia-container .hide-for-xlarge,.rtmedia-activity-container .hide-for-xlarge,#buddypress div.rtmedia-activity-container .hide-for-xlarge{display:inherit !important}.rtmedia-container .hide-for-small,.rtmedia-activity-container .hide-for-small,#buddypress div.rtmedia-activity-container .hide-for-small,.rtmedia-container .hide-for-medium-down,.rtmedia-activity-container .hide-for-medium-down,#buddypress div.rtmedia-activity-container .hide-for-medium-down,.rtmedia-container .hide-for-large-down,.rtmedia-activity-container .hide-for-large-down,#buddypress div.rtmedia-activity-container .hide-for-large-down{display:none !important}.rtmedia-container table.show-for-small,.rtmedia-activity-container table.show-for-small,#buddypress div.rtmedia-activity-container table.show-for-small,.rtmedia-container table.show-for-medium-down,.rtmedia-activity-container table.show-for-medium-down,#buddypress div.rtmedia-activity-container table.show-for-medium-down,.rtmedia-container table.show-for-large-down,.rtmedia-activity-container table.show-for-large-down,#buddypress div.rtmedia-activity-container table.show-for-large-down,.rtmedia-container table.hide-for-medium,.rtmedia-activity-container table.hide-for-medium,#buddypress div.rtmedia-activity-container table.hide-for-medium,.rtmedia-container table.hide-for-medium-up,.rtmedia-activity-container table.hide-for-medium-up,#buddypress div.rtmedia-activity-container table.hide-for-medium-up,.rtmedia-container table.hide-for-large,.rtmedia-activity-container table.hide-for-large,#buddypress div.rtmedia-activity-container table.hide-for-large,.rtmedia-container table.hide-for-large-up,.rtmedia-activity-container table.hide-for-large-up,#buddypress div.rtmedia-activity-container table.hide-for-large-up,.rtmedia-container table.hide-for-xlarge,.rtmedia-activity-container table.hide-for-xlarge,#buddypress div.rtmedia-activity-container table.hide-for-xlarge{display:table}.rtmedia-container thead.show-for-small,.rtmedia-activity-container thead.show-for-small,#buddypress div.rtmedia-activity-container thead.show-for-small,.rtmedia-container thead.show-for-medium-down,.rtmedia-activity-container thead.show-for-medium-down,#buddypress div.rtmedia-activity-container thead.show-for-medium-down,.rtmedia-container thead.show-for-large-down,.rtmedia-activity-container thead.show-for-large-down,#buddypress div.rtmedia-activity-container thead.show-for-large-down,.rtmedia-container thead.hide-for-medium,.rtmedia-activity-container thead.hide-for-medium,#buddypress div.rtmedia-activity-container thead.hide-for-medium,.rtmedia-container thead.hide-for-medium-up,.rtmedia-activity-container thead.hide-for-medium-up,#buddypress div.rtmedia-activity-container thead.hide-for-medium-up,.rtmedia-container thead.hide-for-large,.rtmedia-activity-container thead.hide-for-large,#buddypress div.rtmedia-activity-container thead.hide-for-large,.rtmedia-container thead.hide-for-large-up,.rtmedia-activity-container thead.hide-for-large-up,#buddypress div.rtmedia-activity-container thead.hide-for-large-up,.rtmedia-container thead.hide-for-xlarge,.rtmedia-activity-container thead.hide-for-xlarge,#buddypress div.rtmedia-activity-container thead.hide-for-xlarge{display:table-header-group !important}.rtmedia-container tbody.show-for-small,.rtmedia-activity-container tbody.show-for-small,#buddypress div.rtmedia-activity-container tbody.show-for-small,.rtmedia-container tbody.show-for-medium-down,.rtmedia-activity-container tbody.show-for-medium-down,#buddypress div.rtmedia-activity-container tbody.show-for-medium-down,.rtmedia-container tbody.show-for-large-down,.rtmedia-activity-container tbody.show-for-large-down,#buddypress div.rtmedia-activity-container tbody.show-for-large-down,.rtmedia-container tbody.hide-for-medium,.rtmedia-activity-container tbody.hide-for-medium,#buddypress div.rtmedia-activity-container tbody.hide-for-medium,.rtmedia-container tbody.hide-for-medium-up,.rtmedia-activity-container tbody.hide-for-medium-up,#buddypress div.rtmedia-activity-container tbody.hide-for-medium-up,.rtmedia-container tbody.hide-for-large,.rtmedia-activity-container tbody.hide-for-large,#buddypress div.rtmedia-activity-container tbody.hide-for-large,.rtmedia-container tbody.hide-for-large-up,.rtmedia-activity-container tbody.hide-for-large-up,#buddypress div.rtmedia-activity-container tbody.hide-for-large-up,.rtmedia-container tbody.hide-for-xlarge,.rtmedia-activity-container tbody.hide-for-xlarge,#buddypress div.rtmedia-activity-container tbody.hide-for-xlarge{display:table-row-group !important}.rtmedia-container tr.show-for-small,.rtmedia-activity-container tr.show-for-small,#buddypress div.rtmedia-activity-container tr.show-for-small,.rtmedia-container tr.show-for-medium-down,.rtmedia-activity-container tr.show-for-medium-down,#buddypress div.rtmedia-activity-container tr.show-for-medium-down,.rtmedia-container tr.show-for-large-down,.rtmedia-activity-container tr.show-for-large-down,#buddypress div.rtmedia-activity-container tr.show-for-large-down,.rtmedia-container tr.hide-for-medium,.rtmedia-activity-container tr.hide-for-medium,#buddypress div.rtmedia-activity-container tr.hide-for-medium,.rtmedia-container tr.hide-for-medium-up,.rtmedia-activity-container tr.hide-for-medium-up,#buddypress div.rtmedia-activity-container tr.hide-for-medium-up,.rtmedia-container tr.hide-for-large,.rtmedia-activity-container tr.hide-for-large,#buddypress div.rtmedia-activity-container tr.hide-for-large,.rtmedia-container tr.hide-for-large-up,.rtmedia-activity-container tr.hide-for-large-up,#buddypress div.rtmedia-activity-container tr.hide-for-large-up,.rtmedia-container tr.hide-for-xlarge,.rtmedia-activity-container tr.hide-for-xlarge,#buddypress div.rtmedia-activity-container tr.hide-for-xlarge{display:table-row !important}.rtmedia-container td.show-for-small,.rtmedia-activity-container td.show-for-small,#buddypress div.rtmedia-activity-container td.show-for-small,.rtmedia-container td.show-for-medium-down,.rtmedia-activity-container td.show-for-medium-down,#buddypress div.rtmedia-activity-container td.show-for-medium-down,.rtmedia-container td.show-for-large-down,.rtmedia-activity-container td.show-for-large-down,#buddypress div.rtmedia-activity-container td.show-for-large-down,.rtmedia-container td.hide-for-medium,.rtmedia-activity-container td.hide-for-medium,#buddypress div.rtmedia-activity-container td.hide-for-medium,.rtmedia-container td.hide-for-medium-up,.rtmedia-activity-container td.hide-for-medium-up,#buddypress div.rtmedia-activity-container td.hide-for-medium-up,.rtmedia-container td.hide-for-large,.rtmedia-activity-container td.hide-for-large,#buddypress div.rtmedia-activity-container td.hide-for-large,.rtmedia-container td.hide-for-large-up,.rtmedia-activity-container td.hide-for-large-up,#buddypress div.rtmedia-activity-container td.hide-for-large-up,.rtmedia-container td.hide-for-xlarge,.rtmedia-activity-container td.hide-for-xlarge,#buddypress div.rtmedia-activity-container td.hide-for-xlarge,.rtmedia-container th.show-for-small,.rtmedia-activity-container th.show-for-small,#buddypress div.rtmedia-activity-container th.show-for-small,.rtmedia-container th.show-for-medium-down,.rtmedia-activity-container th.show-for-medium-down,#buddypress div.rtmedia-activity-container th.show-for-medium-down,.rtmedia-container th.show-for-large-down,.rtmedia-activity-container th.show-for-large-down,#buddypress div.rtmedia-activity-container th.show-for-large-down,.rtmedia-container th.hide-for-medium,.rtmedia-activity-container th.hide-for-medium,#buddypress div.rtmedia-activity-container th.hide-for-medium,.rtmedia-container th.hide-for-medium-up,.rtmedia-activity-container th.hide-for-medium-up,#buddypress div.rtmedia-activity-container th.hide-for-medium-up,.rtmedia-container th.hide-for-large,.rtmedia-activity-container th.hide-for-large,#buddypress div.rtmedia-activity-container th.hide-for-large,.rtmedia-container th.hide-for-large-up,.rtmedia-activity-container th.hide-for-large-up,#buddypress div.rtmedia-activity-container th.hide-for-large-up,.rtmedia-container th.hide-for-xlarge,.rtmedia-activity-container th.hide-for-xlarge,#buddypress div.rtmedia-activity-container th.hide-for-xlarge{display:table-cell !important}@media only screen and (min-width: 768px){.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-up,.rtmedia-activity-container .show-for-medium-up,#buddypress div.rtmedia-activity-container .show-for-medium-up{display:inherit !important}.rtmedia-container .show-for-small,.rtmedia-activity-container .show-for-small,#buddypress div.rtmedia-activity-container .show-for-small{display:none !important}.rtmedia-container .hide-for-small,.rtmedia-activity-container .hide-for-small,#buddypress div.rtmedia-activity-container .hide-for-small{display:inherit !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-up,.rtmedia-activity-container .hide-for-medium-up,#buddypress div.rtmedia-activity-container .hide-for-medium-up{display:none !important}.rtmedia-container table.show-for-medium,.rtmedia-activity-container table.show-for-medium,#buddypress div.rtmedia-activity-container table.show-for-medium,.rtmedia-container table.show-for-medium-up,.rtmedia-activity-container table.show-for-medium-up,#buddypress div.rtmedia-activity-container table.show-for-medium-up,.rtmedia-container table.hide-for-small,.rtmedia-activity-container table.hide-for-small,#buddypress div.rtmedia-activity-container table.hide-for-small{display:table}.rtmedia-container thead.show-for-medium,.rtmedia-activity-container thead.show-for-medium,#buddypress div.rtmedia-activity-container thead.show-for-medium,.rtmedia-container thead.show-for-medium-up,.rtmedia-activity-container thead.show-for-medium-up,#buddypress div.rtmedia-activity-container thead.show-for-medium-up,.rtmedia-container thead.hide-for-small,.rtmedia-activity-container thead.hide-for-small,#buddypress div.rtmedia-activity-container thead.hide-for-small{display:table-header-group !important}.rtmedia-container tbody.show-for-medium,.rtmedia-activity-container tbody.show-for-medium,#buddypress div.rtmedia-activity-container tbody.show-for-medium,.rtmedia-container tbody.show-for-medium-up,.rtmedia-activity-container tbody.show-for-medium-up,#buddypress div.rtmedia-activity-container tbody.show-for-medium-up,.rtmedia-container tbody.hide-for-small,.rtmedia-activity-container tbody.hide-for-small,#buddypress div.rtmedia-activity-container tbody.hide-for-small{display:table-row-group !important}.rtmedia-container tr.show-for-medium,.rtmedia-activity-container tr.show-for-medium,#buddypress div.rtmedia-activity-container tr.show-for-medium,.rtmedia-container tr.show-for-medium-up,.rtmedia-activity-container tr.show-for-medium-up,#buddypress div.rtmedia-activity-container tr.show-for-medium-up,.rtmedia-container tr.hide-for-small,.rtmedia-activity-container tr.hide-for-small,#buddypress div.rtmedia-activity-container tr.hide-for-small{display:table-row !important}.rtmedia-container td.show-for-medium,.rtmedia-activity-container td.show-for-medium,#buddypress div.rtmedia-activity-container td.show-for-medium,.rtmedia-container td.show-for-medium-up,.rtmedia-activity-container td.show-for-medium-up,#buddypress div.rtmedia-activity-container td.show-for-medium-up,.rtmedia-container td.hide-for-small,.rtmedia-activity-container td.hide-for-small,#buddypress div.rtmedia-activity-container td.hide-for-small,.rtmedia-container th.show-for-medium,.rtmedia-activity-container th.show-for-medium,#buddypress div.rtmedia-activity-container th.show-for-medium,.rtmedia-container th.show-for-medium-up,.rtmedia-activity-container th.show-for-medium-up,#buddypress div.rtmedia-activity-container th.show-for-medium-up,.rtmedia-container th.hide-for-small,.rtmedia-activity-container th.hide-for-small,#buddypress div.rtmedia-activity-container th.hide-for-small{display:table-cell !important}}@media only screen and (min-width: 1280px){.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-up,.rtmedia-activity-container .show-for-large-up,#buddypress div.rtmedia-activity-container .show-for-large-up{display:inherit !important}.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-down,.rtmedia-activity-container .show-for-medium-down,#buddypress div.rtmedia-activity-container .show-for-medium-down{display:none !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-down,.rtmedia-activity-container .hide-for-medium-down,#buddypress div.rtmedia-activity-container .hide-for-medium-down{display:inherit !important}.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-up,.rtmedia-activity-container .hide-for-large-up,#buddypress div.rtmedia-activity-container .hide-for-large-up{display:none !important}.rtmedia-container table.show-for-large,.rtmedia-activity-container table.show-for-large,#buddypress div.rtmedia-activity-container table.show-for-large,.rtmedia-container table.show-for-large-up,.rtmedia-activity-container table.show-for-large-up,#buddypress div.rtmedia-activity-container table.show-for-large-up,.rtmedia-container table.hide-for-medium,.rtmedia-activity-container table.hide-for-medium,#buddypress div.rtmedia-activity-container table.hide-for-medium,.rtmedia-container table.hide-for-medium-down,.rtmedia-activity-container table.hide-for-medium-down,#buddypress div.rtmedia-activity-container table.hide-for-medium-down{display:table}.rtmedia-container thead.show-for-large,.rtmedia-activity-container thead.show-for-large,#buddypress div.rtmedia-activity-container thead.show-for-large,.rtmedia-container thead.show-for-large-up,.rtmedia-activity-container thead.show-for-large-up,#buddypress div.rtmedia-activity-container thead.show-for-large-up,.rtmedia-container thead.hide-for-medium,.rtmedia-activity-container thead.hide-for-medium,#buddypress div.rtmedia-activity-container thead.hide-for-medium,.rtmedia-container thead.hide-for-medium-down,.rtmedia-activity-container thead.hide-for-medium-down,#buddypress div.rtmedia-activity-container thead.hide-for-medium-down{display:table-header-group !important}.rtmedia-container tbody.show-for-large,.rtmedia-activity-container tbody.show-for-large,#buddypress div.rtmedia-activity-container tbody.show-for-large,.rtmedia-container tbody.show-for-large-up,.rtmedia-activity-container tbody.show-for-large-up,#buddypress div.rtmedia-activity-container tbody.show-for-large-up,.rtmedia-container tbody.hide-for-medium,.rtmedia-activity-container tbody.hide-for-medium,#buddypress div.rtmedia-activity-container tbody.hide-for-medium,.rtmedia-container tbody.hide-for-medium-down,.rtmedia-activity-container tbody.hide-for-medium-down,#buddypress div.rtmedia-activity-container tbody.hide-for-medium-down{display:table-row-group !important}.rtmedia-container tr.show-for-large,.rtmedia-activity-container tr.show-for-large,#buddypress div.rtmedia-activity-container tr.show-for-large,.rtmedia-container tr.show-for-large-up,.rtmedia-activity-container tr.show-for-large-up,#buddypress div.rtmedia-activity-container tr.show-for-large-up,.rtmedia-container tr.hide-for-medium,.rtmedia-activity-container tr.hide-for-medium,#buddypress div.rtmedia-activity-container tr.hide-for-medium,.rtmedia-container tr.hide-for-medium-down,.rtmedia-activity-container tr.hide-for-medium-down,#buddypress div.rtmedia-activity-container tr.hide-for-medium-down{display:table-row !important}.rtmedia-container td.show-for-large,.rtmedia-activity-container td.show-for-large,#buddypress div.rtmedia-activity-container td.show-for-large,.rtmedia-container td.show-for-large-up,.rtmedia-activity-container td.show-for-large-up,#buddypress div.rtmedia-activity-container td.show-for-large-up,.rtmedia-container td.hide-for-medium,.rtmedia-activity-container td.hide-for-medium,#buddypress div.rtmedia-activity-container td.hide-for-medium,.rtmedia-container td.hide-for-medium-down,.rtmedia-activity-container td.hide-for-medium-down,#buddypress div.rtmedia-activity-container td.hide-for-medium-down,.rtmedia-container th.show-for-large,.rtmedia-activity-container th.show-for-large,#buddypress div.rtmedia-activity-container th.show-for-large,.rtmedia-container th.show-for-large-up,.rtmedia-activity-container th.show-for-large-up,#buddypress div.rtmedia-activity-container th.show-for-large-up,.rtmedia-container th.hide-for-medium,.rtmedia-activity-container th.hide-for-medium,#buddypress div.rtmedia-activity-container th.hide-for-medium,.rtmedia-container th.hide-for-medium-down,.rtmedia-activity-container th.hide-for-medium-down,#buddypress div.rtmedia-activity-container th.hide-for-medium-down{display:table-cell !important}}@media only screen and (min-width: 1440px){.rtmedia-container .show-for-xlarge,.rtmedia-activity-container .show-for-xlarge,#buddypress div.rtmedia-activity-container .show-for-xlarge{display:inherit !important}.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-down,.rtmedia-activity-container .show-for-large-down,#buddypress div.rtmedia-activity-container .show-for-large-down{display:none !important}.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-down,.rtmedia-activity-container .hide-for-large-down,#buddypress div.rtmedia-activity-container .hide-for-large-down{display:inherit !important}.rtmedia-container .hide-for-xlarge,.rtmedia-activity-container .hide-for-xlarge,#buddypress div.rtmedia-activity-container .hide-for-xlarge{display:none !important}.rtmedia-container table.show-for-xlarge,.rtmedia-activity-container table.show-for-xlarge,#buddypress div.rtmedia-activity-container table.show-for-xlarge,.rtmedia-container table.hide-for-large,.rtmedia-activity-container table.hide-for-large,#buddypress div.rtmedia-activity-container table.hide-for-large,.rtmedia-container table.hide-for-large-down,.rtmedia-activity-container table.hide-for-large-down,#buddypress div.rtmedia-activity-container table.hide-for-large-down{display:table}.rtmedia-container thead.show-for-xlarge,.rtmedia-activity-container thead.show-for-xlarge,#buddypress div.rtmedia-activity-container thead.show-for-xlarge,.rtmedia-container thead.hide-for-large,.rtmedia-activity-container thead.hide-for-large,#buddypress div.rtmedia-activity-container thead.hide-for-large,.rtmedia-container thead.hide-for-large-down,.rtmedia-activity-container thead.hide-for-large-down,#buddypress div.rtmedia-activity-container thead.hide-for-large-down{display:table-header-group !important}.rtmedia-container tbody.show-for-xlarge,.rtmedia-activity-container tbody.show-for-xlarge,#buddypress div.rtmedia-activity-container tbody.show-for-xlarge,.rtmedia-container tbody.hide-for-large,.rtmedia-activity-container tbody.hide-for-large,#buddypress div.rtmedia-activity-container tbody.hide-for-large,.rtmedia-container tbody.hide-for-large-down,.rtmedia-activity-container tbody.hide-for-large-down,#buddypress div.rtmedia-activity-container tbody.hide-for-large-down{display:table-row-group !important}.rtmedia-container tr.show-for-xlarge,.rtmedia-activity-container tr.show-for-xlarge,#buddypress div.rtmedia-activity-container tr.show-for-xlarge,.rtmedia-container tr.hide-for-large,.rtmedia-activity-container tr.hide-for-large,#buddypress div.rtmedia-activity-container tr.hide-for-large,.rtmedia-container tr.hide-for-large-down,.rtmedia-activity-container tr.hide-for-large-down,#buddypress div.rtmedia-activity-container tr.hide-for-large-down{display:table-row !important}.rtmedia-container td.show-for-xlarge,.rtmedia-activity-container td.show-for-xlarge,#buddypress div.rtmedia-activity-container td.show-for-xlarge,.rtmedia-container td.hide-for-large,.rtmedia-activity-container td.hide-for-large,#buddypress div.rtmedia-activity-container td.hide-for-large,.rtmedia-container td.hide-for-large-down,.rtmedia-activity-container td.hide-for-large-down,#buddypress div.rtmedia-activity-container td.hide-for-large-down,.rtmedia-container th.show-for-xlarge,.rtmedia-activity-container th.show-for-xlarge,#buddypress div.rtmedia-activity-container th.show-for-xlarge,.rtmedia-container th.hide-for-large,.rtmedia-activity-container th.hide-for-large,#buddypress div.rtmedia-activity-container th.hide-for-large,.rtmedia-container th.hide-for-large-down,.rtmedia-activity-container th.hide-for-large-down,#buddypress div.rtmedia-activity-container th.hide-for-large-down{display:table-cell !important}}.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape,.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait{display:inherit !important}.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape,.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait{display:none !important}.rtmedia-container table.hide-for-landscape,.rtmedia-activity-container table.hide-for-landscape,#buddypress div.rtmedia-activity-container table.hide-for-landscape,.rtmedia-container table.show-for-portrait,.rtmedia-activity-container table.show-for-portrait,#buddypress div.rtmedia-activity-container table.show-for-portrait{display:table}.rtmedia-container thead.hide-for-landscape,.rtmedia-activity-container thead.hide-for-landscape,#buddypress div.rtmedia-activity-container thead.hide-for-landscape,.rtmedia-container thead.show-for-portrait,.rtmedia-activity-container thead.show-for-portrait,#buddypress div.rtmedia-activity-container thead.show-for-portrait{display:table-header-group !important}.rtmedia-container tbody.hide-for-landscape,.rtmedia-activity-container tbody.hide-for-landscape,#buddypress div.rtmedia-activity-container tbody.hide-for-landscape,.rtmedia-container tbody.show-for-portrait,.rtmedia-activity-container tbody.show-for-portrait,#buddypress div.rtmedia-activity-container tbody.show-for-portrait{display:table-row-group !important}.rtmedia-container tr.hide-for-landscape,.rtmedia-activity-container tr.hide-for-landscape,#buddypress div.rtmedia-activity-container tr.hide-for-landscape,.rtmedia-container tr.show-for-portrait,.rtmedia-activity-container tr.show-for-portrait,#buddypress div.rtmedia-activity-container tr.show-for-portrait{display:table-row !important}.rtmedia-container td.hide-for-landscape,.rtmedia-activity-container td.hide-for-landscape,#buddypress div.rtmedia-activity-container td.hide-for-landscape,.rtmedia-container td.show-for-portrait,.rtmedia-activity-container td.show-for-portrait,#buddypress div.rtmedia-activity-container td.show-for-portrait,.rtmedia-container th.hide-for-landscape,.rtmedia-activity-container th.hide-for-landscape,#buddypress div.rtmedia-activity-container th.hide-for-landscape,.rtmedia-container th.show-for-portrait,.rtmedia-activity-container th.show-for-portrait,#buddypress div.rtmedia-activity-container th.show-for-portrait{display:table-cell !important}@media only screen and (orientation: landscape){.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape,.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait{display:inherit !important}.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape,.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait{display:none !important}.rtmedia-container table.show-for-landscape,.rtmedia-activity-container table.show-for-landscape,#buddypress div.rtmedia-activity-container table.show-for-landscape,.rtmedia-container table.hide-for-portrait,.rtmedia-activity-container table.hide-for-portrait,#buddypress div.rtmedia-activity-container table.hide-for-portrait{display:table}.rtmedia-container thead.show-for-landscape,.rtmedia-activity-container thead.show-for-landscape,#buddypress div.rtmedia-activity-container thead.show-for-landscape,.rtmedia-container thead.hide-for-portrait,.rtmedia-activity-container thead.hide-for-portrait,#buddypress div.rtmedia-activity-container thead.hide-for-portrait{display:table-header-group !important}.rtmedia-container tbody.show-for-landscape,.rtmedia-activity-container tbody.show-for-landscape,#buddypress div.rtmedia-activity-container tbody.show-for-landscape,.rtmedia-container tbody.hide-for-portrait,.rtmedia-activity-container tbody.hide-for-portrait,#buddypress div.rtmedia-activity-container tbody.hide-for-portrait{display:table-row-group !important}.rtmedia-container tr.show-for-landscape,.rtmedia-activity-container tr.show-for-landscape,#buddypress div.rtmedia-activity-container tr.show-for-landscape,.rtmedia-container tr.hide-for-portrait,.rtmedia-activity-container tr.hide-for-portrait,#buddypress div.rtmedia-activity-container tr.hide-for-portrait{display:table-row !important}.rtmedia-container td.show-for-landscape,.rtmedia-activity-container td.show-for-landscape,#buddypress div.rtmedia-activity-container td.show-for-landscape,.rtmedia-container td.hide-for-portrait,.rtmedia-activity-container td.hide-for-portrait,#buddypress div.rtmedia-activity-container td.hide-for-portrait,.rtmedia-container th.show-for-landscape,.rtmedia-activity-container th.show-for-landscape,#buddypress div.rtmedia-activity-container th.show-for-landscape,.rtmedia-container th.hide-for-portrait,.rtmedia-activity-container th.hide-for-portrait,#buddypress div.rtmedia-activity-container th.hide-for-portrait{display:table-cell !important}}@media only screen and (orientation: portrait){.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait,.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape{display:inherit !important}.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait,.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape{display:none !important}.rtmedia-container table.show-for-portrait,.rtmedia-activity-container table.show-for-portrait,#buddypress div.rtmedia-activity-container table.show-for-portrait,.rtmedia-container table.hide-for-landscape,.rtmedia-activity-container table.hide-for-landscape,#buddypress div.rtmedia-activity-container table.hide-for-landscape{display:table}.rtmedia-container thead.show-for-portrait,.rtmedia-activity-container thead.show-for-portrait,#buddypress div.rtmedia-activity-container thead.show-for-portrait,.rtmedia-container thead.hide-for-landscape,.rtmedia-activity-container thead.hide-for-landscape,#buddypress div.rtmedia-activity-container thead.hide-for-landscape{display:table-header-group !important}.rtmedia-container tbody.show-for-portrait,.rtmedia-activity-container tbody.show-for-portrait,#buddypress div.rtmedia-activity-container tbody.show-for-portrait,.rtmedia-container tbody.hide-for-landscape,.rtmedia-activity-container tbody.hide-for-landscape,#buddypress div.rtmedia-activity-container tbody.hide-for-landscape{display:table-row-group !important}.rtmedia-container tr.show-for-portrait,.rtmedia-activity-container tr.show-for-portrait,#buddypress div.rtmedia-activity-container tr.show-for-portrait,.rtmedia-container tr.hide-for-landscape,.rtmedia-activity-container tr.hide-for-landscape,#buddypress div.rtmedia-activity-container tr.hide-for-landscape{display:table-row !important}.rtmedia-container td.show-for-portrait,.rtmedia-activity-container td.show-for-portrait,#buddypress div.rtmedia-activity-container td.show-for-portrait,.rtmedia-container td.hide-for-landscape,.rtmedia-activity-container td.hide-for-landscape,#buddypress div.rtmedia-activity-container td.hide-for-landscape,.rtmedia-container th.show-for-portrait,.rtmedia-activity-container th.show-for-portrait,#buddypress div.rtmedia-activity-container th.show-for-portrait,.rtmedia-container th.hide-for-landscape,.rtmedia-activity-container th.hide-for-landscape,#buddypress div.rtmedia-activity-container th.hide-for-landscape{display:table-cell !important}}.rtmedia-container .show-for-touch,.rtmedia-activity-container .show-for-touch,#buddypress div.rtmedia-activity-container .show-for-touch{display:none !important}.rtmedia-container .hide-for-touch,.rtmedia-activity-container .hide-for-touch,#buddypress div.rtmedia-activity-container .hide-for-touch{display:inherit !important}.rtmedia-container .touch .show-for-touch,.rtmedia-activity-container .touch .show-for-touch,#buddypress div.rtmedia-activity-container .touch .show-for-touch{display:inherit !important}.rtmedia-container .touch .hide-for-touch,.rtmedia-activity-container .touch .hide-for-touch,#buddypress div.rtmedia-activity-container .touch .hide-for-touch{display:none !important}.rtmedia-container table.hide-for-touch,.rtmedia-activity-container table.hide-for-touch,#buddypress div.rtmedia-activity-container table.hide-for-touch{display:table}.rtmedia-container .touch table.show-for-touch,.rtmedia-activity-container .touch table.show-for-touch,#buddypress div.rtmedia-activity-container .touch table.show-for-touch{display:table}.rtmedia-container thead.hide-for-touch,.rtmedia-activity-container thead.hide-for-touch,#buddypress div.rtmedia-activity-container thead.hide-for-touch{display:table-header-group !important}.rtmedia-container .touch thead.show-for-touch,.rtmedia-activity-container .touch thead.show-for-touch,#buddypress div.rtmedia-activity-container .touch thead.show-for-touch{display:table-header-group !important}.rtmedia-container tbody.hide-for-touch,.rtmedia-activity-container tbody.hide-for-touch,#buddypress div.rtmedia-activity-container tbody.hide-for-touch{display:table-row-group !important}.rtmedia-container .touch tbody.show-for-touch,.rtmedia-activity-container .touch tbody.show-for-touch,#buddypress div.rtmedia-activity-container .touch tbody.show-for-touch{display:table-row-group !important}.rtmedia-container tr.hide-for-touch,.rtmedia-activity-container tr.hide-for-touch,#buddypress div.rtmedia-activity-container tr.hide-for-touch{display:table-row !important}.rtmedia-container .touch tr.show-for-touch,.rtmedia-activity-container .touch tr.show-for-touch,#buddypress div.rtmedia-activity-container .touch tr.show-for-touch{display:table-row !important}.rtmedia-container td.hide-for-touch,.rtmedia-activity-container td.hide-for-touch,#buddypress div.rtmedia-activity-container td.hide-for-touch{display:table-cell !important}.rtmedia-container .touch td.show-for-touch,.rtmedia-activity-container .touch td.show-for-touch,#buddypress div.rtmedia-activity-container .touch td.show-for-touch{display:table-cell !important}.rtmedia-container th.hide-for-touch,.rtmedia-activity-container th.hide-for-touch,#buddypress div.rtmedia-activity-container th.hide-for-touch{display:table-cell !important}.rtmedia-container .touch th.show-for-touch,.rtmedia-activity-container .touch th.show-for-touch,#buddypress div.rtmedia-activity-container .touch th.show-for-touch{display:table-cell !important}.rtmedia-container .flex-video,.rtmedia-activity-container .flex-video,#buddypress div.rtmedia-activity-container .flex-video{position:relative;padding-top:1.5625em;padding-bottom:67.5%;height:0;margin-bottom:1em;overflow:hidden}.rtmedia-container .flex-video.widescreen,.rtmedia-activity-container .flex-video.widescreen,#buddypress div.rtmedia-activity-container .flex-video.widescreen{padding-bottom:57.25%}.rtmedia-container .flex-video.vimeo,.rtmedia-activity-container .flex-video.vimeo,#buddypress div.rtmedia-activity-container .flex-video.vimeo{padding-top:0}.rtmedia-container .flex-video iframe,.rtmedia-activity-container .flex-video iframe,#buddypress div.rtmedia-activity-container .flex-video iframe,.rtmedia-container .flex-video object,.rtmedia-activity-container .flex-video object,#buddypress div.rtmedia-activity-container .flex-video object,.rtmedia-container .flex-video embed,.rtmedia-activity-container .flex-video embed,#buddypress div.rtmedia-activity-container .flex-video embed,.rtmedia-container .flex-video video,.rtmedia-activity-container .flex-video video,#buddypress div.rtmedia-activity-container .flex-video video{position:absolute;top:0;left:0;width:100%;height:100%}.rtmedia-container .row,.rtmedia-activity-container .row,#buddypress div.rtmedia-activity-container .row{max-width:95%}.rtmedia-container .rtmedia-item-title,.rtmedia-activity-container .rtmedia-item-title,#buddypress div.rtmedia-activity-container .rtmedia-item-title{text-align:center}.rtmedia-container .rtmedia-item-title h4,.rtmedia-activity-container .rtmedia-item-title h4,#buddypress div.rtmedia-activity-container .rtmedia-item-title h4{text-overflow:ellipsis;white-space:nowrap;width:100%;overflow:hidden;font-size:1.1em;text-align:center}.rtmedia-container .rtmedia-success,.rtmedia-activity-container .rtmedia-success,#buddypress div.rtmedia-activity-container .rtmedia-success{display:block;padding:10px;border:1px solid #008000;background-color:#90EE90;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.rtmedia-container h2,.rtmedia-activity-container h2,#buddypress div.rtmedia-activity-container h2{font-size:1.4em;font-weight:bold;line-height:2.4em}.rtmedia-container .drag-drop,.rtmedia-activity-container .drag-drop,#buddypress div.rtmedia-activity-container .drag-drop{border:4px dashed #DDD;text-align:center;background:#fafafa;overflow:hidden;padding:15px 0}.rtmedia-container .drag-drop.dragover,.rtmedia-activity-container .drag-drop.dragover,#buddypress div.rtmedia-activity-container .drag-drop.dragover{border-color:#83b4d8}.rtmedia-container .rtmedia-action-update,.rtmedia-activity-container .rtmedia-action-update,#buddypress div.rtmedia-activity-container .rtmedia-action-update{float:left;margin-top:12px;margin-right:10px}.rtmedia-container .rtmedia-list,.rtmedia-activity-container .rtmedia-list,#buddypress div.rtmedia-activity-container .rtmedia-list{list-style:none}.rtmedia-container .rtmedia-list .rtmedia-list-item,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item{word-wrap:break-word;padding:20px;float:left}.rtmedia-container .rtmedia-list .rtmedia-list-item a,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a{text-decoration:none}.rtmedia-container .rtmedia-list .rtmedia-list-item a h4,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a h4,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a h4{line-height:1.4em;font-size:1.2em;padding-top:10px}.rtmedia-container .rtmedia-media img,.rtmedia-activity-container .rtmedia-media img,#buddypress div.rtmedia-activity-container .rtmedia-media img{max-width:100%}.rtmedia-container .rtmedia-item-thumbnail,.rtmedia-activity-container .rtmedia-item-thumbnail,#buddypress div.rtmedia-activity-container .rtmedia-item-thumbnail{text-align:center}.rtmedia-container .rtmedia-item-thumbnail img,.rtmedia-activity-container .rtmedia-item-thumbnail img,#buddypress div.rtmedia-activity-container .rtmedia-item-thumbnail img{vertical-align:middle}.rtmedia-container .rtmedia_next_prev,.rtmedia-activity-container .rtmedia_next_prev,#buddypress div.rtmedia-activity-container .rtmedia_next_prev{float:left}.rtmedia-container .rtmedia-item-comments-container,.rtmedia-activity-container .rtmedia-item-comments-container,#buddypress div.rtmedia-activity-container .rtmedia-item-comments-container{margin:3% 3%}.rtmedia-container .rtmedia-comment,.rtmedia-activity-container .rtmedia-comment,#buddypress div.rtmedia-activity-container .rtmedia-comment{list-style:none;background:#f6f6f6;border:1px solid #ddd;-moz-border-radius:3px;border-radius:3px;margin:5px 0;padding:1px 5px 25px;width:391px}.rtmedia-container .rtmedia-comment .rtmedia-comment-author,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-author,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-author{display:block}.rtmedia-container .rtmedia-comment .rtmedia-comment-content,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-content,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-content{display:block}.rtmedia-container .rtmedia-comment .rtmedia-comment-date,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-date,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-date{display:block;float:right}.rtmedia-container .rtmedia-bp-header,.rtmedia-activity-container .rtmedia-bp-header,#buddypress div.rtmedia-activity-container .rtmedia-bp-header{width:460px;margin:auto}.rtmedia-container #div-attache-rtmedia,.rtmedia-activity-container #div-attache-rtmedia,#buddypress div.rtmedia-activity-container #div-attache-rtmedia{display:none}.rtmedia-container #rtMedia-update-queue-list p span,.rtmedia-activity-container #rtMedia-update-queue-list p span{margin-right:20px}.rtmedia-container .rtmedia-move-container,.rtmedia-activity-container .rtmedia-move-container,#buddypress div.rtmedia-activity-container .rtmedia-move-container{display:none}.rtmedia-container #rtmedia-add-media-button-post-update,.rtmedia-activity-container #rtmedia-add-media-button-post-update,#buddypress div.rtmedia-activity-container #rtmedia-add-media-button-post-update{float:left;margin-top:10px;margin-right:20px}.rtmedia-container #whats-new-post-in-box,.rtmedia-activity-container #whats-new-post-in-box,#buddypress div.rtmedia-activity-container #whats-new-post-in-box{float:left}.rtmedia-container .rtmedia-activity-text,.rtmedia-activity-container .rtmedia-activity-text,#buddypress div.rtmedia-activity-container .rtmedia-activity-text{display:block;padding-bottom:10px}.rtmedia-container .rtmedia-merge-container,.rtmedia-activity-container .rtmedia-merge-container,#buddypress div.rtmedia-activity-container .rtmedia-merge-container{display:none}.rtmedia-container .rtmedia-create-new-album-container,.rtmedia-activity-container .rtmedia-create-new-album-container,#buddypress div.rtmedia-activity-container .rtmedia-create-new-album-container{display:none}.rtmedia-container select,.rtmedia-activity-container select,#buddypress div.rtmedia-activity-container select{width:auto}.rtmedia-container.rtmedia-single-container .row,.rtmedia-single-container.rtmedia-activity-container .row,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row{background-color:#FFF}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container{padding-top:10px;padding-bottom:10px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-overlay-button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-overlay-button{margin:-50px 0 0 -50px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-button button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:rgba(0,0,0,0) url("../../../lib/media-element/controls.png") no-repeat}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-mute button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-mute button{background-position:-16px -16px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-fullscreen-button button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-fullscreen-button button{background-position:-32px 0}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta{padding:10px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta button,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta button,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta button{color:#5E5E5E;background-color:#EBEBEB;background-repeat:repeat-x;background-image:-moz-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-ms-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-webkit-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-o-linear-gradient(top, #f9f9f9, #ebebeb);background-image:linear-gradient(to bottom, #f9f9f9,#ebebeb)}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta>a,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta>a,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta>a{float:left;margin:10px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions>a,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>a,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>a{display:inline-block;float:left}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions>form,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>form,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>form{float:left;margin-right:5px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span{background:#EEE;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;border:1px solid #CCC;color:#999;display:inline;font-size:70%;margin-left:2px;margin-right:2px;padding:3px 6px;text-align:center;vertical-align:middle}.rtmedia-container.rtmedia-single-container .row .rtmedia-item-comments,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments{background-color:transparent}.rtmedia-container.rtmedia-single-container .row .rtmedia-item-comments div,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments div,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments div{background-color:transparent}.rtmedia-container #wp-description-editor-tools a.wp-switch-editor,.rtmedia-activity-container #wp-description-editor-tools a.wp-switch-editor{margin:5px 5px 0 0;padding:4px 5px 2px;float:right;cursor:pointer;border:1px solid;border-color:#DFDFDF #DFDFDF #CCC;font:13px/18px Arial,Helvetica,sans-serif normal;height:auto}.rtmedia-container #description_toolbargroup .mceToolbar td,.rtmedia-activity-container #description_toolbargroup .mceToolbar td{padding:0px}.rtmedia-container #wp-description-editor-container,.rtmedia-activity-container #wp-description-editor-container,#buddypress div.rtmedia-activity-container #wp-description-editor-container{border-width:1px;border-style:solid;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;border-color:#CCC #CCC #DFDFDF}#buddypress div.rtmedia-activity-container ul.rtmedia-list li{float:left;padding:10px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video{float:none}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail{margin:0 auto}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-overlay-button{margin:-50px 0 0 -50px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:rgba(0,0,0,0) url("../../../lib/media-element/controls.png") no-repeat}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-mute button{background-position:-16px -16px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-fullscreen-button button{background-position:-32px 0}#rtmedia-action-update{float:left;padding-right:10px}#header{z-index:1 !important}.bp_media_content video{background-color:black}.rtmedia-success{display:block;padding:10px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;background-color:#2ECC71;color:white}.rtmedia-error{color:white;display:block;padding:10px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;background-color:#E74C3C}
|
1 |
+
.rtmedia-container,.rtmedia-activity-container,#buddypress div.rtmedia-activity-container{padding:5px;margin:0;clear:left}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html,.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body,.rtmedia-container div,.rtmedia-activity-container div,#buddypress div.rtmedia-activity-container div,.rtmedia-container span,.rtmedia-activity-container span,#buddypress div.rtmedia-activity-container span,.rtmedia-container applet,.rtmedia-activity-container applet,#buddypress div.rtmedia-activity-container applet,.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container iframe,.rtmedia-activity-container iframe,#buddypress div.rtmedia-activity-container iframe,.rtmedia-container h1,.rtmedia-activity-container h1,#buddypress div.rtmedia-activity-container h1,.rtmedia-container h2,.rtmedia-activity-container h2,#buddypress div.rtmedia-activity-container h2,.rtmedia-container h3,.rtmedia-activity-container h3,#buddypress div.rtmedia-activity-container h3,.rtmedia-container h4,.rtmedia-activity-container h4,#buddypress div.rtmedia-activity-container h4,.rtmedia-container h5,.rtmedia-activity-container h5,#buddypress div.rtmedia-activity-container h5,.rtmedia-container h6,.rtmedia-activity-container h6,#buddypress div.rtmedia-activity-container h6,.rtmedia-container p,.rtmedia-activity-container p,#buddypress div.rtmedia-activity-container p,.rtmedia-container blockquote,.rtmedia-activity-container blockquote,#buddypress div.rtmedia-activity-container blockquote,.rtmedia-container pre,.rtmedia-activity-container pre,#buddypress div.rtmedia-activity-container pre,.rtmedia-container a,.rtmedia-activity-container a,#buddypress div.rtmedia-activity-container a,.rtmedia-container abbr,.rtmedia-activity-container abbr,#buddypress div.rtmedia-activity-container abbr,.rtmedia-container acronym,.rtmedia-activity-container acronym,#buddypress div.rtmedia-activity-container acronym,.rtmedia-container address,.rtmedia-activity-container address,#buddypress div.rtmedia-activity-container address,.rtmedia-container big,.rtmedia-activity-container big,#buddypress div.rtmedia-activity-container big,.rtmedia-container cite,.rtmedia-activity-container cite,#buddypress div.rtmedia-activity-container cite,.rtmedia-container code,.rtmedia-activity-container code,#buddypress div.rtmedia-activity-container code,.rtmedia-container del,.rtmedia-activity-container del,#buddypress div.rtmedia-activity-container del,.rtmedia-container dfn,.rtmedia-activity-container dfn,#buddypress div.rtmedia-activity-container dfn,.rtmedia-container em,.rtmedia-activity-container em,#buddypress div.rtmedia-activity-container em,.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img,.rtmedia-container ins,.rtmedia-activity-container ins,#buddypress div.rtmedia-activity-container ins,.rtmedia-container kbd,.rtmedia-activity-container kbd,#buddypress div.rtmedia-activity-container kbd,.rtmedia-container q,.rtmedia-activity-container q,#buddypress div.rtmedia-activity-container q,.rtmedia-container s,.rtmedia-activity-container s,#buddypress div.rtmedia-activity-container s,.rtmedia-container samp,.rtmedia-activity-container samp,#buddypress div.rtmedia-activity-container samp,.rtmedia-container small,.rtmedia-activity-container small,#buddypress div.rtmedia-activity-container small,.rtmedia-container strike,.rtmedia-activity-container strike,#buddypress div.rtmedia-activity-container strike,.rtmedia-container strong,.rtmedia-activity-container strong,#buddypress div.rtmedia-activity-container strong,.rtmedia-container sub,.rtmedia-activity-container sub,#buddypress div.rtmedia-activity-container sub,.rtmedia-container sup,.rtmedia-activity-container sup,#buddypress div.rtmedia-activity-container sup,.rtmedia-container tt,.rtmedia-activity-container tt,#buddypress div.rtmedia-activity-container tt,.rtmedia-container var,.rtmedia-activity-container var,#buddypress div.rtmedia-activity-container var,.rtmedia-container b,.rtmedia-activity-container b,#buddypress div.rtmedia-activity-container b,.rtmedia-container u,.rtmedia-activity-container u,#buddypress div.rtmedia-activity-container u,.rtmedia-container i,.rtmedia-activity-container i,#buddypress div.rtmedia-activity-container i,.rtmedia-container center,.rtmedia-activity-container center,#buddypress div.rtmedia-activity-container center,.rtmedia-container dl,.rtmedia-activity-container dl,#buddypress div.rtmedia-activity-container dl,.rtmedia-container dt,.rtmedia-activity-container dt,#buddypress div.rtmedia-activity-container dt,.rtmedia-container dd,.rtmedia-activity-container dd,#buddypress div.rtmedia-activity-container dd,.rtmedia-container ol,.rtmedia-activity-container ol,#buddypress div.rtmedia-activity-container ol,.rtmedia-container ul,.rtmedia-activity-container ul,#buddypress div.rtmedia-activity-container ul,.rtmedia-container li,.rtmedia-activity-container li,#buddypress div.rtmedia-activity-container li,.rtmedia-container fieldset,.rtmedia-activity-container fieldset,#buddypress div.rtmedia-activity-container fieldset,.rtmedia-container form,.rtmedia-activity-container form,#buddypress div.rtmedia-activity-container form,.rtmedia-container label,.rtmedia-activity-container label,#buddypress div.rtmedia-activity-container label,.rtmedia-container legend,.rtmedia-activity-container legend,#buddypress div.rtmedia-activity-container legend,.rtmedia-container table,.rtmedia-activity-container table,#buddypress div.rtmedia-activity-container table,.rtmedia-container caption,.rtmedia-activity-container caption,#buddypress div.rtmedia-activity-container caption,.rtmedia-container tbody,.rtmedia-activity-container tbody,#buddypress div.rtmedia-activity-container tbody,.rtmedia-container tfoot,.rtmedia-activity-container tfoot,#buddypress div.rtmedia-activity-container tfoot,.rtmedia-container thead,.rtmedia-activity-container thead,#buddypress div.rtmedia-activity-container thead,.rtmedia-container tr,.rtmedia-activity-container tr,#buddypress div.rtmedia-activity-container tr,.rtmedia-container th,.rtmedia-activity-container th,#buddypress div.rtmedia-activity-container th,.rtmedia-container td,.rtmedia-activity-container td,#buddypress div.rtmedia-activity-container td,.rtmedia-container article,.rtmedia-activity-container article,#buddypress div.rtmedia-activity-container article,.rtmedia-container aside,.rtmedia-activity-container aside,#buddypress div.rtmedia-activity-container aside,.rtmedia-container canvas,.rtmedia-activity-container canvas,#buddypress div.rtmedia-activity-container canvas,.rtmedia-container details,.rtmedia-activity-container details,#buddypress div.rtmedia-activity-container details,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed,.rtmedia-container figure,.rtmedia-activity-container figure,#buddypress div.rtmedia-activity-container figure,.rtmedia-container figcaption,.rtmedia-activity-container figcaption,#buddypress div.rtmedia-activity-container figcaption,.rtmedia-container footer,.rtmedia-activity-container footer,#buddypress div.rtmedia-activity-container footer,.rtmedia-container header,.rtmedia-activity-container header,#buddypress div.rtmedia-activity-container header,.rtmedia-container hgroup,.rtmedia-activity-container hgroup,#buddypress div.rtmedia-activity-container hgroup,.rtmedia-container menu,.rtmedia-activity-container menu,#buddypress div.rtmedia-activity-container menu,.rtmedia-container nav,.rtmedia-activity-container nav,#buddypress div.rtmedia-activity-container nav,.rtmedia-container output,.rtmedia-activity-container output,#buddypress div.rtmedia-activity-container output,.rtmedia-container ruby,.rtmedia-activity-container ruby,#buddypress div.rtmedia-activity-container ruby,.rtmedia-container section,.rtmedia-activity-container section,#buddypress div.rtmedia-activity-container section,.rtmedia-container summary,.rtmedia-activity-container summary,#buddypress div.rtmedia-activity-container summary,.rtmedia-container time,.rtmedia-activity-container time,#buddypress div.rtmedia-activity-container time,.rtmedia-container mark,.rtmedia-activity-container mark,#buddypress div.rtmedia-activity-container mark,.rtmedia-container audio,.rtmedia-activity-container audio,#buddypress div.rtmedia-activity-container audio,.rtmedia-container video,.rtmedia-activity-container video,#buddypress div.rtmedia-activity-container video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html{line-height:1}.rtmedia-container ol,.rtmedia-activity-container ol,#buddypress div.rtmedia-activity-container ol,.rtmedia-container ul,.rtmedia-activity-container ul,#buddypress div.rtmedia-activity-container ul{list-style:none}.rtmedia-container table,.rtmedia-activity-container table,#buddypress div.rtmedia-activity-container table{border-collapse:collapse;border-spacing:0}.rtmedia-container caption,.rtmedia-activity-container caption,#buddypress div.rtmedia-activity-container caption,.rtmedia-container th,.rtmedia-activity-container th,#buddypress div.rtmedia-activity-container th,.rtmedia-container td,.rtmedia-activity-container td,#buddypress div.rtmedia-activity-container td{text-align:left;font-weight:normal;vertical-align:middle}.rtmedia-container q,.rtmedia-activity-container q,#buddypress div.rtmedia-activity-container q,.rtmedia-container blockquote,.rtmedia-activity-container blockquote,#buddypress div.rtmedia-activity-container blockquote{quotes:none}.rtmedia-container q:before,.rtmedia-activity-container q:before,#buddypress div.rtmedia-activity-container q:before,.rtmedia-container q:after,.rtmedia-activity-container q:after,#buddypress div.rtmedia-activity-container q:after,.rtmedia-container blockquote:before,.rtmedia-activity-container blockquote:before,#buddypress div.rtmedia-activity-container blockquote:before,.rtmedia-container blockquote:after,.rtmedia-activity-container blockquote:after,#buddypress div.rtmedia-activity-container blockquote:after{content:"";content:none}.rtmedia-container a img,.rtmedia-activity-container a img,#buddypress div.rtmedia-activity-container a img{border:none}.rtmedia-container article,.rtmedia-activity-container article,#buddypress div.rtmedia-activity-container article,.rtmedia-container aside,.rtmedia-activity-container aside,#buddypress div.rtmedia-activity-container aside,.rtmedia-container details,.rtmedia-activity-container details,#buddypress div.rtmedia-activity-container details,.rtmedia-container figcaption,.rtmedia-activity-container figcaption,#buddypress div.rtmedia-activity-container figcaption,.rtmedia-container figure,.rtmedia-activity-container figure,#buddypress div.rtmedia-activity-container figure,.rtmedia-container footer,.rtmedia-activity-container footer,#buddypress div.rtmedia-activity-container footer,.rtmedia-container header,.rtmedia-activity-container header,#buddypress div.rtmedia-activity-container header,.rtmedia-container hgroup,.rtmedia-activity-container hgroup,#buddypress div.rtmedia-activity-container hgroup,.rtmedia-container menu,.rtmedia-activity-container menu,#buddypress div.rtmedia-activity-container menu,.rtmedia-container nav,.rtmedia-activity-container nav,#buddypress div.rtmedia-activity-container nav,.rtmedia-container section,.rtmedia-activity-container section,#buddypress div.rtmedia-activity-container section,.rtmedia-container summary,.rtmedia-activity-container summary,#buddypress div.rtmedia-activity-container summary{display:block}.rtmedia-container *,.rtmedia-activity-container *,#buddypress div.rtmedia-activity-container *,.rtmedia-container *:before,.rtmedia-activity-container *:before,#buddypress div.rtmedia-activity-container *:before,.rtmedia-container *:after,.rtmedia-activity-container *:after,#buddypress div.rtmedia-activity-container *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.rtmedia-container html,.rtmedia-activity-container html,#buddypress div.rtmedia-activity-container html,.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body{font-size:100%}.rtmedia-container body,.rtmedia-activity-container body,#buddypress div.rtmedia-activity-container body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative;cursor:default}.rtmedia-container a:hover,.rtmedia-activity-container a:hover,#buddypress div.rtmedia-activity-container a:hover{cursor:pointer}.rtmedia-container a:focus,.rtmedia-activity-container a:focus,#buddypress div.rtmedia-activity-container a:focus{outline:none}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img,.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed{max-width:100%;height:auto}.rtmedia-container object,.rtmedia-activity-container object,#buddypress div.rtmedia-activity-container object,.rtmedia-container embed,.rtmedia-activity-container embed,#buddypress div.rtmedia-activity-container embed{height:100%}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img{-ms-interpolation-mode:bicubic}.rtmedia-container #map_canvas img,.rtmedia-activity-container #map_canvas img,.rtmedia-container #map_canvas embed,.rtmedia-activity-container #map_canvas embed,.rtmedia-container #map_canvas object,.rtmedia-activity-container #map_canvas object,.rtmedia-container .map_canvas img,.rtmedia-activity-container .map_canvas img,#buddypress div.rtmedia-activity-container .map_canvas img,.rtmedia-container .map_canvas embed,.rtmedia-activity-container .map_canvas embed,#buddypress div.rtmedia-activity-container .map_canvas embed,.rtmedia-container .map_canvas object,.rtmedia-activity-container .map_canvas object,#buddypress div.rtmedia-activity-container .map_canvas object{max-width:none !important}.rtmedia-container .left,.rtmedia-activity-container .left,#buddypress div.rtmedia-activity-container .left{float:left !important}.rtmedia-container .right,.rtmedia-activity-container .right,#buddypress div.rtmedia-activity-container .right{float:right !important}.rtmedia-container .text-left,.rtmedia-activity-container .text-left,#buddypress div.rtmedia-activity-container .text-left{text-align:left !important}.rtmedia-container .text-right,.rtmedia-activity-container .text-right,#buddypress div.rtmedia-activity-container .text-right{text-align:right !important}.rtmedia-container .text-center,.rtmedia-activity-container .text-center,#buddypress div.rtmedia-activity-container .text-center{text-align:center !important}.rtmedia-container .text-justify,.rtmedia-activity-container .text-justify,#buddypress div.rtmedia-activity-container .text-justify{text-align:justify !important}.rtmedia-container .hide,.rtmedia-activity-container .hide,#buddypress div.rtmedia-activity-container .hide{display:none}.rtmedia-container .antialiased,.rtmedia-activity-container .antialiased,#buddypress div.rtmedia-activity-container .antialiased{-webkit-font-smoothing:antialiased}.rtmedia-container img,.rtmedia-activity-container img,#buddypress div.rtmedia-activity-container img{display:inline-block;vertical-align:middle}.rtmedia-container textarea,.rtmedia-activity-container textarea,#buddypress div.rtmedia-activity-container textarea{height:auto;min-height:50px}.rtmedia-container select,.rtmedia-activity-container select,#buddypress div.rtmedia-activity-container select{width:100%}.rtmedia-container .row,.rtmedia-activity-container .row,#buddypress div.rtmedia-activity-container .row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1}.rtmedia-container .row:before,.rtmedia-activity-container .row:before,#buddypress div.rtmedia-activity-container .row:before,.rtmedia-container .row:after,.rtmedia-activity-container .row:after,#buddypress div.rtmedia-activity-container .row:after{content:" ";display:table}.rtmedia-container .row:after,.rtmedia-activity-container .row:after,#buddypress div.rtmedia-activity-container .row:after{clear:both}.rtmedia-container .row.collapse .column,.rtmedia-activity-container .row.collapse .column,#buddypress div.rtmedia-activity-container .row.collapse .column,.rtmedia-container .row.collapse .columns,.rtmedia-activity-container .row.collapse .columns,#buddypress div.rtmedia-activity-container .row.collapse .columns{position:relative;padding-left:0;padding-right:0;float:left}.rtmedia-container .row .row,.rtmedia-activity-container .row .row,#buddypress div.rtmedia-activity-container .row .row{width:auto;margin-left:-0.9375em;margin-right:-0.9375em;margin-top:0;margin-bottom:0;max-width:none;*zoom:1}.rtmedia-container .row .row:before,.rtmedia-activity-container .row .row:before,#buddypress div.rtmedia-activity-container .row .row:before,.rtmedia-container .row .row:after,.rtmedia-activity-container .row .row:after,#buddypress div.rtmedia-activity-container .row .row:after{content:" ";display:table}.rtmedia-container .row .row:after,.rtmedia-activity-container .row .row:after,#buddypress div.rtmedia-activity-container .row .row:after{clear:both}.rtmedia-container .row .row.collapse,.rtmedia-activity-container .row .row.collapse,#buddypress div.rtmedia-activity-container .row .row.collapse{width:auto;margin:0;max-width:none;*zoom:1}.rtmedia-container .row .row.collapse:before,.rtmedia-activity-container .row .row.collapse:before,#buddypress div.rtmedia-activity-container .row .row.collapse:before,.rtmedia-container .row .row.collapse:after,.rtmedia-activity-container .row .row.collapse:after,#buddypress div.rtmedia-activity-container .row .row.collapse:after{content:" ";display:table}.rtmedia-container .row .row.collapse:after,.rtmedia-activity-container .row .row.collapse:after,#buddypress div.rtmedia-activity-container .row .row.collapse:after{clear:both}.rtmedia-container .column,.rtmedia-activity-container .column,#buddypress div.rtmedia-activity-container .column,.rtmedia-container .columns,.rtmedia-activity-container .columns,#buddypress div.rtmedia-activity-container .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;width:100%;float:left}@media only screen{.rtmedia-container .column,.rtmedia-activity-container .column,#buddypress div.rtmedia-activity-container .column,.rtmedia-container .columns,.rtmedia-activity-container .columns,#buddypress div.rtmedia-activity-container .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;float:left}.rtmedia-container .small-1,.rtmedia-activity-container .small-1,#buddypress div.rtmedia-activity-container .small-1{position:relative;width:8.33333%}.rtmedia-container .small-2,.rtmedia-activity-container .small-2,#buddypress div.rtmedia-activity-container .small-2{position:relative;width:16.66667%}.rtmedia-container .small-3,.rtmedia-activity-container .small-3,#buddypress div.rtmedia-activity-container .small-3{position:relative;width:25%}.rtmedia-container .small-4,.rtmedia-activity-container .small-4,#buddypress div.rtmedia-activity-container .small-4{position:relative;width:33.33333%}.rtmedia-container .small-5,.rtmedia-activity-container .small-5,#buddypress div.rtmedia-activity-container .small-5{position:relative;width:41.66667%}.rtmedia-container .small-6,.rtmedia-activity-container .small-6,#buddypress div.rtmedia-activity-container .small-6{position:relative;width:50%}.rtmedia-container .small-7,.rtmedia-activity-container .small-7,#buddypress div.rtmedia-activity-container .small-7{position:relative;width:58.33333%}.rtmedia-container .small-8,.rtmedia-activity-container .small-8,#buddypress div.rtmedia-activity-container .small-8{position:relative;width:66.66667%}.rtmedia-container .small-9,.rtmedia-activity-container .small-9,#buddypress div.rtmedia-activity-container .small-9{position:relative;width:75%}.rtmedia-container .small-10,.rtmedia-activity-container .small-10,#buddypress div.rtmedia-activity-container .small-10{position:relative;width:83.33333%}.rtmedia-container .small-11,.rtmedia-activity-container .small-11,#buddypress div.rtmedia-activity-container .small-11{position:relative;width:91.66667%}.rtmedia-container .small-12,.rtmedia-activity-container .small-12,#buddypress div.rtmedia-activity-container .small-12{position:relative;width:100%}.rtmedia-container .small-offset-0,.rtmedia-activity-container .small-offset-0,#buddypress div.rtmedia-activity-container .small-offset-0{position:relative;margin-left:0%}.rtmedia-container .small-offset-1,.rtmedia-activity-container .small-offset-1,#buddypress div.rtmedia-activity-container .small-offset-1{position:relative;margin-left:8.33333%}.rtmedia-container .small-offset-2,.rtmedia-activity-container .small-offset-2,#buddypress div.rtmedia-activity-container .small-offset-2{position:relative;margin-left:16.66667%}.rtmedia-container .small-offset-3,.rtmedia-activity-container .small-offset-3,#buddypress div.rtmedia-activity-container .small-offset-3{position:relative;margin-left:25%}.rtmedia-container .small-offset-4,.rtmedia-activity-container .small-offset-4,#buddypress div.rtmedia-activity-container .small-offset-4{position:relative;margin-left:33.33333%}.rtmedia-container .small-offset-5,.rtmedia-activity-container .small-offset-5,#buddypress div.rtmedia-activity-container .small-offset-5{position:relative;margin-left:41.66667%}.rtmedia-container .small-offset-6,.rtmedia-activity-container .small-offset-6,#buddypress div.rtmedia-activity-container .small-offset-6{position:relative;margin-left:50%}.rtmedia-container .small-offset-7,.rtmedia-activity-container .small-offset-7,#buddypress div.rtmedia-activity-container .small-offset-7{position:relative;margin-left:58.33333%}.rtmedia-container .small-offset-8,.rtmedia-activity-container .small-offset-8,#buddypress div.rtmedia-activity-container .small-offset-8{position:relative;margin-left:66.66667%}.rtmedia-container .small-offset-9,.rtmedia-activity-container .small-offset-9,#buddypress div.rtmedia-activity-container .small-offset-9{position:relative;margin-left:75%}.rtmedia-container .small-offset-10,.rtmedia-activity-container .small-offset-10,#buddypress div.rtmedia-activity-container .small-offset-10{position:relative;margin-left:83.33333%}.rtmedia-container [class*="column"]+[class*="column"]:last-child,.rtmedia-activity-container [class*="column"]+[class*="column"]:last-child,#buddypress div.rtmedia-activity-container [class*="column"]+[class*="column"]:last-child{float:right}.rtmedia-container [class*="column"]+[class*="column"].end,.rtmedia-activity-container [class*="column"]+[class*="column"].end,#buddypress div.rtmedia-activity-container [class*="column"]+[class*="column"].end{float:left}.rtmedia-container .column.small-centered,.rtmedia-activity-container .column.small-centered,#buddypress div.rtmedia-activity-container .column.small-centered,.rtmedia-container .columns.small-centered,.rtmedia-activity-container .columns.small-centered,#buddypress div.rtmedia-activity-container .columns.small-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}}@media only screen and (min-width: 768px){.rtmedia-container .large-1,.rtmedia-activity-container .large-1,#buddypress div.rtmedia-activity-container .large-1{position:relative;width:8.33333%}.rtmedia-container .large-2,.rtmedia-activity-container .large-2,#buddypress div.rtmedia-activity-container .large-2{position:relative;width:16.66667%}.rtmedia-container .large-3,.rtmedia-activity-container .large-3,#buddypress div.rtmedia-activity-container .large-3{position:relative;width:25%}.rtmedia-container .large-4,.rtmedia-activity-container .large-4,#buddypress div.rtmedia-activity-container .large-4{position:relative;width:33.33333%}.rtmedia-container .large-5,.rtmedia-activity-container .large-5,#buddypress div.rtmedia-activity-container .large-5{position:relative;width:41.66667%}.rtmedia-container .large-6,.rtmedia-activity-container .large-6,#buddypress div.rtmedia-activity-container .large-6{position:relative;width:50%}.rtmedia-container .large-7,.rtmedia-activity-container .large-7,#buddypress div.rtmedia-activity-container .large-7{position:relative;width:58.33333%}.rtmedia-container .large-8,.rtmedia-activity-container .large-8,#buddypress div.rtmedia-activity-container .large-8{position:relative;width:66.66667%}.rtmedia-container .large-9,.rtmedia-activity-container .large-9,#buddypress div.rtmedia-activity-container .large-9{position:relative;width:75%}.rtmedia-container .large-10,.rtmedia-activity-container .large-10,#buddypress div.rtmedia-activity-container .large-10{position:relative;width:83.33333%}.rtmedia-container .large-11,.rtmedia-activity-container .large-11,#buddypress div.rtmedia-activity-container .large-11{position:relative;width:91.66667%}.rtmedia-container .large-12,.rtmedia-activity-container .large-12,#buddypress div.rtmedia-activity-container .large-12{position:relative;width:100%}.rtmedia-container .row .large-offset-0,.rtmedia-activity-container .row .large-offset-0,#buddypress div.rtmedia-activity-container .row .large-offset-0{position:relative;margin-left:0%}.rtmedia-container .row .large-offset-1,.rtmedia-activity-container .row .large-offset-1,#buddypress div.rtmedia-activity-container .row .large-offset-1{position:relative;margin-left:8.33333%}.rtmedia-container .row .large-offset-2,.rtmedia-activity-container .row .large-offset-2,#buddypress div.rtmedia-activity-container .row .large-offset-2{position:relative;margin-left:16.66667%}.rtmedia-container .row .large-offset-3,.rtmedia-activity-container .row .large-offset-3,#buddypress div.rtmedia-activity-container .row .large-offset-3{position:relative;margin-left:25%}.rtmedia-container .row .large-offset-4,.rtmedia-activity-container .row .large-offset-4,#buddypress div.rtmedia-activity-container .row .large-offset-4{position:relative;margin-left:33.33333%}.rtmedia-container .row .large-offset-5,.rtmedia-activity-container .row .large-offset-5,#buddypress div.rtmedia-activity-container .row .large-offset-5{position:relative;margin-left:41.66667%}.rtmedia-container .row .large-offset-6,.rtmedia-activity-container .row .large-offset-6,#buddypress div.rtmedia-activity-container .row .large-offset-6{position:relative;margin-left:50%}.rtmedia-container .row .large-offset-7,.rtmedia-activity-container .row .large-offset-7,#buddypress div.rtmedia-activity-container .row .large-offset-7{position:relative;margin-left:58.33333%}.rtmedia-container .row .large-offset-8,.rtmedia-activity-container .row .large-offset-8,#buddypress div.rtmedia-activity-container .row .large-offset-8{position:relative;margin-left:66.66667%}.rtmedia-container .row .large-offset-9,.rtmedia-activity-container .row .large-offset-9,#buddypress div.rtmedia-activity-container .row .large-offset-9{position:relative;margin-left:75%}.rtmedia-container .row .large-offset-10,.rtmedia-activity-container .row .large-offset-10,#buddypress div.rtmedia-activity-container .row .large-offset-10{position:relative;margin-left:83.33333%}.rtmedia-container .row .large-offset-11,.rtmedia-activity-container .row .large-offset-11,#buddypress div.rtmedia-activity-container .row .large-offset-11{position:relative;margin-left:91.66667%}.rtmedia-container .push-1,.rtmedia-activity-container .push-1,#buddypress div.rtmedia-activity-container .push-1{position:relative;left:8.33333%;right:auto}.rtmedia-container .pull-1,.rtmedia-activity-container .pull-1,#buddypress div.rtmedia-activity-container .pull-1{position:relative;right:8.33333%;left:auto}.rtmedia-container .push-2,.rtmedia-activity-container .push-2,#buddypress div.rtmedia-activity-container .push-2{position:relative;left:16.66667%;right:auto}.rtmedia-container .pull-2,.rtmedia-activity-container .pull-2,#buddypress div.rtmedia-activity-container .pull-2{position:relative;right:16.66667%;left:auto}.rtmedia-container .push-3,.rtmedia-activity-container .push-3,#buddypress div.rtmedia-activity-container .push-3{position:relative;left:25%;right:auto}.rtmedia-container .pull-3,.rtmedia-activity-container .pull-3,#buddypress div.rtmedia-activity-container .pull-3{position:relative;right:25%;left:auto}.rtmedia-container .push-4,.rtmedia-activity-container .push-4,#buddypress div.rtmedia-activity-container .push-4{position:relative;left:33.33333%;right:auto}.rtmedia-container .pull-4,.rtmedia-activity-container .pull-4,#buddypress div.rtmedia-activity-container .pull-4{position:relative;right:33.33333%;left:auto}.rtmedia-container .push-5,.rtmedia-activity-container .push-5,#buddypress div.rtmedia-activity-container .push-5{position:relative;left:41.66667%;right:auto}.rtmedia-container .pull-5,.rtmedia-activity-container .pull-5,#buddypress div.rtmedia-activity-container .pull-5{position:relative;right:41.66667%;left:auto}.rtmedia-container .push-6,.rtmedia-activity-container .push-6,#buddypress div.rtmedia-activity-container .push-6{position:relative;left:50%;right:auto}.rtmedia-container .pull-6,.rtmedia-activity-container .pull-6,#buddypress div.rtmedia-activity-container .pull-6{position:relative;right:50%;left:auto}.rtmedia-container .push-7,.rtmedia-activity-container .push-7,#buddypress div.rtmedia-activity-container .push-7{position:relative;left:58.33333%;right:auto}.rtmedia-container .pull-7,.rtmedia-activity-container .pull-7,#buddypress div.rtmedia-activity-container .pull-7{position:relative;right:58.33333%;left:auto}.rtmedia-container .push-8,.rtmedia-activity-container .push-8,#buddypress div.rtmedia-activity-container .push-8{position:relative;left:66.66667%;right:auto}.rtmedia-container .pull-8,.rtmedia-activity-container .pull-8,#buddypress div.rtmedia-activity-container .pull-8{position:relative;right:66.66667%;left:auto}.rtmedia-container .push-9,.rtmedia-activity-container .push-9,#buddypress div.rtmedia-activity-container .push-9{position:relative;left:75%;right:auto}.rtmedia-container .pull-9,.rtmedia-activity-container .pull-9,#buddypress div.rtmedia-activity-container .pull-9{position:relative;right:75%;left:auto}.rtmedia-container .push-10,.rtmedia-activity-container .push-10,#buddypress div.rtmedia-activity-container .push-10{position:relative;left:83.33333%;right:auto}.rtmedia-container .pull-10,.rtmedia-activity-container .pull-10,#buddypress div.rtmedia-activity-container .pull-10{position:relative;right:83.33333%;left:auto}.rtmedia-container .push-11,.rtmedia-activity-container .push-11,#buddypress div.rtmedia-activity-container .push-11{position:relative;left:91.66667%;right:auto}.rtmedia-container .pull-11,.rtmedia-activity-container .pull-11,#buddypress div.rtmedia-activity-container .pull-11{position:relative;right:91.66667%;left:auto}.rtmedia-container .column.large-centered,.rtmedia-activity-container .column.large-centered,#buddypress div.rtmedia-activity-container .column.large-centered,.rtmedia-container .columns.large-centered,.rtmedia-activity-container .columns.large-centered,#buddypress div.rtmedia-activity-container .columns.large-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}.rtmedia-container .column.large-uncentered,.rtmedia-activity-container .column.large-uncentered,#buddypress div.rtmedia-activity-container .column.large-uncentered,.rtmedia-container .columns.large-uncentered,.rtmedia-activity-container .columns.large-uncentered,#buddypress div.rtmedia-activity-container .columns.large-uncentered{margin-left:0;margin-right:0;float:left !important}.rtmedia-container .column.large-uncentered.opposite,.rtmedia-activity-container .column.large-uncentered.opposite,#buddypress div.rtmedia-activity-container .column.large-uncentered.opposite,.rtmedia-container .columns.large-uncentered.opposite,.rtmedia-activity-container .columns.large-uncentered.opposite,#buddypress div.rtmedia-activity-container .columns.large-uncentered.opposite{float:right !important}}.rtmedia-container .show-for-small,.rtmedia-activity-container .show-for-small,#buddypress div.rtmedia-activity-container .show-for-small,.rtmedia-container .show-for-medium-down,.rtmedia-activity-container .show-for-medium-down,#buddypress div.rtmedia-activity-container .show-for-medium-down,.rtmedia-container .show-for-large-down,.rtmedia-activity-container .show-for-large-down,#buddypress div.rtmedia-activity-container .show-for-large-down{display:inherit !important}.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-up,.rtmedia-activity-container .show-for-medium-up,#buddypress div.rtmedia-activity-container .show-for-medium-up,.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-up,.rtmedia-activity-container .show-for-large-up,#buddypress div.rtmedia-activity-container .show-for-large-up,.rtmedia-container .show-for-xlarge,.rtmedia-activity-container .show-for-xlarge,#buddypress div.rtmedia-activity-container .show-for-xlarge{display:none !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-up,.rtmedia-activity-container .hide-for-medium-up,#buddypress div.rtmedia-activity-container .hide-for-medium-up,.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-up,.rtmedia-activity-container .hide-for-large-up,#buddypress div.rtmedia-activity-container .hide-for-large-up,.rtmedia-container .hide-for-xlarge,.rtmedia-activity-container .hide-for-xlarge,#buddypress div.rtmedia-activity-container .hide-for-xlarge{display:inherit !important}.rtmedia-container .hide-for-small,.rtmedia-activity-container .hide-for-small,#buddypress div.rtmedia-activity-container .hide-for-small,.rtmedia-container .hide-for-medium-down,.rtmedia-activity-container .hide-for-medium-down,#buddypress div.rtmedia-activity-container .hide-for-medium-down,.rtmedia-container .hide-for-large-down,.rtmedia-activity-container .hide-for-large-down,#buddypress div.rtmedia-activity-container .hide-for-large-down{display:none !important}.rtmedia-container table.show-for-small,.rtmedia-activity-container table.show-for-small,#buddypress div.rtmedia-activity-container table.show-for-small,.rtmedia-container table.show-for-medium-down,.rtmedia-activity-container table.show-for-medium-down,#buddypress div.rtmedia-activity-container table.show-for-medium-down,.rtmedia-container table.show-for-large-down,.rtmedia-activity-container table.show-for-large-down,#buddypress div.rtmedia-activity-container table.show-for-large-down,.rtmedia-container table.hide-for-medium,.rtmedia-activity-container table.hide-for-medium,#buddypress div.rtmedia-activity-container table.hide-for-medium,.rtmedia-container table.hide-for-medium-up,.rtmedia-activity-container table.hide-for-medium-up,#buddypress div.rtmedia-activity-container table.hide-for-medium-up,.rtmedia-container table.hide-for-large,.rtmedia-activity-container table.hide-for-large,#buddypress div.rtmedia-activity-container table.hide-for-large,.rtmedia-container table.hide-for-large-up,.rtmedia-activity-container table.hide-for-large-up,#buddypress div.rtmedia-activity-container table.hide-for-large-up,.rtmedia-container table.hide-for-xlarge,.rtmedia-activity-container table.hide-for-xlarge,#buddypress div.rtmedia-activity-container table.hide-for-xlarge{display:table}.rtmedia-container thead.show-for-small,.rtmedia-activity-container thead.show-for-small,#buddypress div.rtmedia-activity-container thead.show-for-small,.rtmedia-container thead.show-for-medium-down,.rtmedia-activity-container thead.show-for-medium-down,#buddypress div.rtmedia-activity-container thead.show-for-medium-down,.rtmedia-container thead.show-for-large-down,.rtmedia-activity-container thead.show-for-large-down,#buddypress div.rtmedia-activity-container thead.show-for-large-down,.rtmedia-container thead.hide-for-medium,.rtmedia-activity-container thead.hide-for-medium,#buddypress div.rtmedia-activity-container thead.hide-for-medium,.rtmedia-container thead.hide-for-medium-up,.rtmedia-activity-container thead.hide-for-medium-up,#buddypress div.rtmedia-activity-container thead.hide-for-medium-up,.rtmedia-container thead.hide-for-large,.rtmedia-activity-container thead.hide-for-large,#buddypress div.rtmedia-activity-container thead.hide-for-large,.rtmedia-container thead.hide-for-large-up,.rtmedia-activity-container thead.hide-for-large-up,#buddypress div.rtmedia-activity-container thead.hide-for-large-up,.rtmedia-container thead.hide-for-xlarge,.rtmedia-activity-container thead.hide-for-xlarge,#buddypress div.rtmedia-activity-container thead.hide-for-xlarge{display:table-header-group !important}.rtmedia-container tbody.show-for-small,.rtmedia-activity-container tbody.show-for-small,#buddypress div.rtmedia-activity-container tbody.show-for-small,.rtmedia-container tbody.show-for-medium-down,.rtmedia-activity-container tbody.show-for-medium-down,#buddypress div.rtmedia-activity-container tbody.show-for-medium-down,.rtmedia-container tbody.show-for-large-down,.rtmedia-activity-container tbody.show-for-large-down,#buddypress div.rtmedia-activity-container tbody.show-for-large-down,.rtmedia-container tbody.hide-for-medium,.rtmedia-activity-container tbody.hide-for-medium,#buddypress div.rtmedia-activity-container tbody.hide-for-medium,.rtmedia-container tbody.hide-for-medium-up,.rtmedia-activity-container tbody.hide-for-medium-up,#buddypress div.rtmedia-activity-container tbody.hide-for-medium-up,.rtmedia-container tbody.hide-for-large,.rtmedia-activity-container tbody.hide-for-large,#buddypress div.rtmedia-activity-container tbody.hide-for-large,.rtmedia-container tbody.hide-for-large-up,.rtmedia-activity-container tbody.hide-for-large-up,#buddypress div.rtmedia-activity-container tbody.hide-for-large-up,.rtmedia-container tbody.hide-for-xlarge,.rtmedia-activity-container tbody.hide-for-xlarge,#buddypress div.rtmedia-activity-container tbody.hide-for-xlarge{display:table-row-group !important}.rtmedia-container tr.show-for-small,.rtmedia-activity-container tr.show-for-small,#buddypress div.rtmedia-activity-container tr.show-for-small,.rtmedia-container tr.show-for-medium-down,.rtmedia-activity-container tr.show-for-medium-down,#buddypress div.rtmedia-activity-container tr.show-for-medium-down,.rtmedia-container tr.show-for-large-down,.rtmedia-activity-container tr.show-for-large-down,#buddypress div.rtmedia-activity-container tr.show-for-large-down,.rtmedia-container tr.hide-for-medium,.rtmedia-activity-container tr.hide-for-medium,#buddypress div.rtmedia-activity-container tr.hide-for-medium,.rtmedia-container tr.hide-for-medium-up,.rtmedia-activity-container tr.hide-for-medium-up,#buddypress div.rtmedia-activity-container tr.hide-for-medium-up,.rtmedia-container tr.hide-for-large,.rtmedia-activity-container tr.hide-for-large,#buddypress div.rtmedia-activity-container tr.hide-for-large,.rtmedia-container tr.hide-for-large-up,.rtmedia-activity-container tr.hide-for-large-up,#buddypress div.rtmedia-activity-container tr.hide-for-large-up,.rtmedia-container tr.hide-for-xlarge,.rtmedia-activity-container tr.hide-for-xlarge,#buddypress div.rtmedia-activity-container tr.hide-for-xlarge{display:table-row !important}.rtmedia-container td.show-for-small,.rtmedia-activity-container td.show-for-small,#buddypress div.rtmedia-activity-container td.show-for-small,.rtmedia-container td.show-for-medium-down,.rtmedia-activity-container td.show-for-medium-down,#buddypress div.rtmedia-activity-container td.show-for-medium-down,.rtmedia-container td.show-for-large-down,.rtmedia-activity-container td.show-for-large-down,#buddypress div.rtmedia-activity-container td.show-for-large-down,.rtmedia-container td.hide-for-medium,.rtmedia-activity-container td.hide-for-medium,#buddypress div.rtmedia-activity-container td.hide-for-medium,.rtmedia-container td.hide-for-medium-up,.rtmedia-activity-container td.hide-for-medium-up,#buddypress div.rtmedia-activity-container td.hide-for-medium-up,.rtmedia-container td.hide-for-large,.rtmedia-activity-container td.hide-for-large,#buddypress div.rtmedia-activity-container td.hide-for-large,.rtmedia-container td.hide-for-large-up,.rtmedia-activity-container td.hide-for-large-up,#buddypress div.rtmedia-activity-container td.hide-for-large-up,.rtmedia-container td.hide-for-xlarge,.rtmedia-activity-container td.hide-for-xlarge,#buddypress div.rtmedia-activity-container td.hide-for-xlarge,.rtmedia-container th.show-for-small,.rtmedia-activity-container th.show-for-small,#buddypress div.rtmedia-activity-container th.show-for-small,.rtmedia-container th.show-for-medium-down,.rtmedia-activity-container th.show-for-medium-down,#buddypress div.rtmedia-activity-container th.show-for-medium-down,.rtmedia-container th.show-for-large-down,.rtmedia-activity-container th.show-for-large-down,#buddypress div.rtmedia-activity-container th.show-for-large-down,.rtmedia-container th.hide-for-medium,.rtmedia-activity-container th.hide-for-medium,#buddypress div.rtmedia-activity-container th.hide-for-medium,.rtmedia-container th.hide-for-medium-up,.rtmedia-activity-container th.hide-for-medium-up,#buddypress div.rtmedia-activity-container th.hide-for-medium-up,.rtmedia-container th.hide-for-large,.rtmedia-activity-container th.hide-for-large,#buddypress div.rtmedia-activity-container th.hide-for-large,.rtmedia-container th.hide-for-large-up,.rtmedia-activity-container th.hide-for-large-up,#buddypress div.rtmedia-activity-container th.hide-for-large-up,.rtmedia-container th.hide-for-xlarge,.rtmedia-activity-container th.hide-for-xlarge,#buddypress div.rtmedia-activity-container th.hide-for-xlarge{display:table-cell !important}@media only screen and (min-width: 768px){.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-up,.rtmedia-activity-container .show-for-medium-up,#buddypress div.rtmedia-activity-container .show-for-medium-up{display:inherit !important}.rtmedia-container .show-for-small,.rtmedia-activity-container .show-for-small,#buddypress div.rtmedia-activity-container .show-for-small{display:none !important}.rtmedia-container .hide-for-small,.rtmedia-activity-container .hide-for-small,#buddypress div.rtmedia-activity-container .hide-for-small{display:inherit !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-up,.rtmedia-activity-container .hide-for-medium-up,#buddypress div.rtmedia-activity-container .hide-for-medium-up{display:none !important}.rtmedia-container table.show-for-medium,.rtmedia-activity-container table.show-for-medium,#buddypress div.rtmedia-activity-container table.show-for-medium,.rtmedia-container table.show-for-medium-up,.rtmedia-activity-container table.show-for-medium-up,#buddypress div.rtmedia-activity-container table.show-for-medium-up,.rtmedia-container table.hide-for-small,.rtmedia-activity-container table.hide-for-small,#buddypress div.rtmedia-activity-container table.hide-for-small{display:table}.rtmedia-container thead.show-for-medium,.rtmedia-activity-container thead.show-for-medium,#buddypress div.rtmedia-activity-container thead.show-for-medium,.rtmedia-container thead.show-for-medium-up,.rtmedia-activity-container thead.show-for-medium-up,#buddypress div.rtmedia-activity-container thead.show-for-medium-up,.rtmedia-container thead.hide-for-small,.rtmedia-activity-container thead.hide-for-small,#buddypress div.rtmedia-activity-container thead.hide-for-small{display:table-header-group !important}.rtmedia-container tbody.show-for-medium,.rtmedia-activity-container tbody.show-for-medium,#buddypress div.rtmedia-activity-container tbody.show-for-medium,.rtmedia-container tbody.show-for-medium-up,.rtmedia-activity-container tbody.show-for-medium-up,#buddypress div.rtmedia-activity-container tbody.show-for-medium-up,.rtmedia-container tbody.hide-for-small,.rtmedia-activity-container tbody.hide-for-small,#buddypress div.rtmedia-activity-container tbody.hide-for-small{display:table-row-group !important}.rtmedia-container tr.show-for-medium,.rtmedia-activity-container tr.show-for-medium,#buddypress div.rtmedia-activity-container tr.show-for-medium,.rtmedia-container tr.show-for-medium-up,.rtmedia-activity-container tr.show-for-medium-up,#buddypress div.rtmedia-activity-container tr.show-for-medium-up,.rtmedia-container tr.hide-for-small,.rtmedia-activity-container tr.hide-for-small,#buddypress div.rtmedia-activity-container tr.hide-for-small{display:table-row !important}.rtmedia-container td.show-for-medium,.rtmedia-activity-container td.show-for-medium,#buddypress div.rtmedia-activity-container td.show-for-medium,.rtmedia-container td.show-for-medium-up,.rtmedia-activity-container td.show-for-medium-up,#buddypress div.rtmedia-activity-container td.show-for-medium-up,.rtmedia-container td.hide-for-small,.rtmedia-activity-container td.hide-for-small,#buddypress div.rtmedia-activity-container td.hide-for-small,.rtmedia-container th.show-for-medium,.rtmedia-activity-container th.show-for-medium,#buddypress div.rtmedia-activity-container th.show-for-medium,.rtmedia-container th.show-for-medium-up,.rtmedia-activity-container th.show-for-medium-up,#buddypress div.rtmedia-activity-container th.show-for-medium-up,.rtmedia-container th.hide-for-small,.rtmedia-activity-container th.hide-for-small,#buddypress div.rtmedia-activity-container th.hide-for-small{display:table-cell !important}}@media only screen and (min-width: 1280px){.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-up,.rtmedia-activity-container .show-for-large-up,#buddypress div.rtmedia-activity-container .show-for-large-up{display:inherit !important}.rtmedia-container .show-for-medium,.rtmedia-activity-container .show-for-medium,#buddypress div.rtmedia-activity-container .show-for-medium,.rtmedia-container .show-for-medium-down,.rtmedia-activity-container .show-for-medium-down,#buddypress div.rtmedia-activity-container .show-for-medium-down{display:none !important}.rtmedia-container .hide-for-medium,.rtmedia-activity-container .hide-for-medium,#buddypress div.rtmedia-activity-container .hide-for-medium,.rtmedia-container .hide-for-medium-down,.rtmedia-activity-container .hide-for-medium-down,#buddypress div.rtmedia-activity-container .hide-for-medium-down{display:inherit !important}.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-up,.rtmedia-activity-container .hide-for-large-up,#buddypress div.rtmedia-activity-container .hide-for-large-up{display:none !important}.rtmedia-container table.show-for-large,.rtmedia-activity-container table.show-for-large,#buddypress div.rtmedia-activity-container table.show-for-large,.rtmedia-container table.show-for-large-up,.rtmedia-activity-container table.show-for-large-up,#buddypress div.rtmedia-activity-container table.show-for-large-up,.rtmedia-container table.hide-for-medium,.rtmedia-activity-container table.hide-for-medium,#buddypress div.rtmedia-activity-container table.hide-for-medium,.rtmedia-container table.hide-for-medium-down,.rtmedia-activity-container table.hide-for-medium-down,#buddypress div.rtmedia-activity-container table.hide-for-medium-down{display:table}.rtmedia-container thead.show-for-large,.rtmedia-activity-container thead.show-for-large,#buddypress div.rtmedia-activity-container thead.show-for-large,.rtmedia-container thead.show-for-large-up,.rtmedia-activity-container thead.show-for-large-up,#buddypress div.rtmedia-activity-container thead.show-for-large-up,.rtmedia-container thead.hide-for-medium,.rtmedia-activity-container thead.hide-for-medium,#buddypress div.rtmedia-activity-container thead.hide-for-medium,.rtmedia-container thead.hide-for-medium-down,.rtmedia-activity-container thead.hide-for-medium-down,#buddypress div.rtmedia-activity-container thead.hide-for-medium-down{display:table-header-group !important}.rtmedia-container tbody.show-for-large,.rtmedia-activity-container tbody.show-for-large,#buddypress div.rtmedia-activity-container tbody.show-for-large,.rtmedia-container tbody.show-for-large-up,.rtmedia-activity-container tbody.show-for-large-up,#buddypress div.rtmedia-activity-container tbody.show-for-large-up,.rtmedia-container tbody.hide-for-medium,.rtmedia-activity-container tbody.hide-for-medium,#buddypress div.rtmedia-activity-container tbody.hide-for-medium,.rtmedia-container tbody.hide-for-medium-down,.rtmedia-activity-container tbody.hide-for-medium-down,#buddypress div.rtmedia-activity-container tbody.hide-for-medium-down{display:table-row-group !important}.rtmedia-container tr.show-for-large,.rtmedia-activity-container tr.show-for-large,#buddypress div.rtmedia-activity-container tr.show-for-large,.rtmedia-container tr.show-for-large-up,.rtmedia-activity-container tr.show-for-large-up,#buddypress div.rtmedia-activity-container tr.show-for-large-up,.rtmedia-container tr.hide-for-medium,.rtmedia-activity-container tr.hide-for-medium,#buddypress div.rtmedia-activity-container tr.hide-for-medium,.rtmedia-container tr.hide-for-medium-down,.rtmedia-activity-container tr.hide-for-medium-down,#buddypress div.rtmedia-activity-container tr.hide-for-medium-down{display:table-row !important}.rtmedia-container td.show-for-large,.rtmedia-activity-container td.show-for-large,#buddypress div.rtmedia-activity-container td.show-for-large,.rtmedia-container td.show-for-large-up,.rtmedia-activity-container td.show-for-large-up,#buddypress div.rtmedia-activity-container td.show-for-large-up,.rtmedia-container td.hide-for-medium,.rtmedia-activity-container td.hide-for-medium,#buddypress div.rtmedia-activity-container td.hide-for-medium,.rtmedia-container td.hide-for-medium-down,.rtmedia-activity-container td.hide-for-medium-down,#buddypress div.rtmedia-activity-container td.hide-for-medium-down,.rtmedia-container th.show-for-large,.rtmedia-activity-container th.show-for-large,#buddypress div.rtmedia-activity-container th.show-for-large,.rtmedia-container th.show-for-large-up,.rtmedia-activity-container th.show-for-large-up,#buddypress div.rtmedia-activity-container th.show-for-large-up,.rtmedia-container th.hide-for-medium,.rtmedia-activity-container th.hide-for-medium,#buddypress div.rtmedia-activity-container th.hide-for-medium,.rtmedia-container th.hide-for-medium-down,.rtmedia-activity-container th.hide-for-medium-down,#buddypress div.rtmedia-activity-container th.hide-for-medium-down{display:table-cell !important}}@media only screen and (min-width: 1440px){.rtmedia-container .show-for-xlarge,.rtmedia-activity-container .show-for-xlarge,#buddypress div.rtmedia-activity-container .show-for-xlarge{display:inherit !important}.rtmedia-container .show-for-large,.rtmedia-activity-container .show-for-large,#buddypress div.rtmedia-activity-container .show-for-large,.rtmedia-container .show-for-large-down,.rtmedia-activity-container .show-for-large-down,#buddypress div.rtmedia-activity-container .show-for-large-down{display:none !important}.rtmedia-container .hide-for-large,.rtmedia-activity-container .hide-for-large,#buddypress div.rtmedia-activity-container .hide-for-large,.rtmedia-container .hide-for-large-down,.rtmedia-activity-container .hide-for-large-down,#buddypress div.rtmedia-activity-container .hide-for-large-down{display:inherit !important}.rtmedia-container .hide-for-xlarge,.rtmedia-activity-container .hide-for-xlarge,#buddypress div.rtmedia-activity-container .hide-for-xlarge{display:none !important}.rtmedia-container table.show-for-xlarge,.rtmedia-activity-container table.show-for-xlarge,#buddypress div.rtmedia-activity-container table.show-for-xlarge,.rtmedia-container table.hide-for-large,.rtmedia-activity-container table.hide-for-large,#buddypress div.rtmedia-activity-container table.hide-for-large,.rtmedia-container table.hide-for-large-down,.rtmedia-activity-container table.hide-for-large-down,#buddypress div.rtmedia-activity-container table.hide-for-large-down{display:table}.rtmedia-container thead.show-for-xlarge,.rtmedia-activity-container thead.show-for-xlarge,#buddypress div.rtmedia-activity-container thead.show-for-xlarge,.rtmedia-container thead.hide-for-large,.rtmedia-activity-container thead.hide-for-large,#buddypress div.rtmedia-activity-container thead.hide-for-large,.rtmedia-container thead.hide-for-large-down,.rtmedia-activity-container thead.hide-for-large-down,#buddypress div.rtmedia-activity-container thead.hide-for-large-down{display:table-header-group !important}.rtmedia-container tbody.show-for-xlarge,.rtmedia-activity-container tbody.show-for-xlarge,#buddypress div.rtmedia-activity-container tbody.show-for-xlarge,.rtmedia-container tbody.hide-for-large,.rtmedia-activity-container tbody.hide-for-large,#buddypress div.rtmedia-activity-container tbody.hide-for-large,.rtmedia-container tbody.hide-for-large-down,.rtmedia-activity-container tbody.hide-for-large-down,#buddypress div.rtmedia-activity-container tbody.hide-for-large-down{display:table-row-group !important}.rtmedia-container tr.show-for-xlarge,.rtmedia-activity-container tr.show-for-xlarge,#buddypress div.rtmedia-activity-container tr.show-for-xlarge,.rtmedia-container tr.hide-for-large,.rtmedia-activity-container tr.hide-for-large,#buddypress div.rtmedia-activity-container tr.hide-for-large,.rtmedia-container tr.hide-for-large-down,.rtmedia-activity-container tr.hide-for-large-down,#buddypress div.rtmedia-activity-container tr.hide-for-large-down{display:table-row !important}.rtmedia-container td.show-for-xlarge,.rtmedia-activity-container td.show-for-xlarge,#buddypress div.rtmedia-activity-container td.show-for-xlarge,.rtmedia-container td.hide-for-large,.rtmedia-activity-container td.hide-for-large,#buddypress div.rtmedia-activity-container td.hide-for-large,.rtmedia-container td.hide-for-large-down,.rtmedia-activity-container td.hide-for-large-down,#buddypress div.rtmedia-activity-container td.hide-for-large-down,.rtmedia-container th.show-for-xlarge,.rtmedia-activity-container th.show-for-xlarge,#buddypress div.rtmedia-activity-container th.show-for-xlarge,.rtmedia-container th.hide-for-large,.rtmedia-activity-container th.hide-for-large,#buddypress div.rtmedia-activity-container th.hide-for-large,.rtmedia-container th.hide-for-large-down,.rtmedia-activity-container th.hide-for-large-down,#buddypress div.rtmedia-activity-container th.hide-for-large-down{display:table-cell !important}}.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape,.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait{display:inherit !important}.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape,.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait{display:none !important}.rtmedia-container table.hide-for-landscape,.rtmedia-activity-container table.hide-for-landscape,#buddypress div.rtmedia-activity-container table.hide-for-landscape,.rtmedia-container table.show-for-portrait,.rtmedia-activity-container table.show-for-portrait,#buddypress div.rtmedia-activity-container table.show-for-portrait{display:table}.rtmedia-container thead.hide-for-landscape,.rtmedia-activity-container thead.hide-for-landscape,#buddypress div.rtmedia-activity-container thead.hide-for-landscape,.rtmedia-container thead.show-for-portrait,.rtmedia-activity-container thead.show-for-portrait,#buddypress div.rtmedia-activity-container thead.show-for-portrait{display:table-header-group !important}.rtmedia-container tbody.hide-for-landscape,.rtmedia-activity-container tbody.hide-for-landscape,#buddypress div.rtmedia-activity-container tbody.hide-for-landscape,.rtmedia-container tbody.show-for-portrait,.rtmedia-activity-container tbody.show-for-portrait,#buddypress div.rtmedia-activity-container tbody.show-for-portrait{display:table-row-group !important}.rtmedia-container tr.hide-for-landscape,.rtmedia-activity-container tr.hide-for-landscape,#buddypress div.rtmedia-activity-container tr.hide-for-landscape,.rtmedia-container tr.show-for-portrait,.rtmedia-activity-container tr.show-for-portrait,#buddypress div.rtmedia-activity-container tr.show-for-portrait{display:table-row !important}.rtmedia-container td.hide-for-landscape,.rtmedia-activity-container td.hide-for-landscape,#buddypress div.rtmedia-activity-container td.hide-for-landscape,.rtmedia-container td.show-for-portrait,.rtmedia-activity-container td.show-for-portrait,#buddypress div.rtmedia-activity-container td.show-for-portrait,.rtmedia-container th.hide-for-landscape,.rtmedia-activity-container th.hide-for-landscape,#buddypress div.rtmedia-activity-container th.hide-for-landscape,.rtmedia-container th.show-for-portrait,.rtmedia-activity-container th.show-for-portrait,#buddypress div.rtmedia-activity-container th.show-for-portrait{display:table-cell !important}@media only screen and (orientation: landscape){.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape,.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait{display:inherit !important}.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape,.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait{display:none !important}.rtmedia-container table.show-for-landscape,.rtmedia-activity-container table.show-for-landscape,#buddypress div.rtmedia-activity-container table.show-for-landscape,.rtmedia-container table.hide-for-portrait,.rtmedia-activity-container table.hide-for-portrait,#buddypress div.rtmedia-activity-container table.hide-for-portrait{display:table}.rtmedia-container thead.show-for-landscape,.rtmedia-activity-container thead.show-for-landscape,#buddypress div.rtmedia-activity-container thead.show-for-landscape,.rtmedia-container thead.hide-for-portrait,.rtmedia-activity-container thead.hide-for-portrait,#buddypress div.rtmedia-activity-container thead.hide-for-portrait{display:table-header-group !important}.rtmedia-container tbody.show-for-landscape,.rtmedia-activity-container tbody.show-for-landscape,#buddypress div.rtmedia-activity-container tbody.show-for-landscape,.rtmedia-container tbody.hide-for-portrait,.rtmedia-activity-container tbody.hide-for-portrait,#buddypress div.rtmedia-activity-container tbody.hide-for-portrait{display:table-row-group !important}.rtmedia-container tr.show-for-landscape,.rtmedia-activity-container tr.show-for-landscape,#buddypress div.rtmedia-activity-container tr.show-for-landscape,.rtmedia-container tr.hide-for-portrait,.rtmedia-activity-container tr.hide-for-portrait,#buddypress div.rtmedia-activity-container tr.hide-for-portrait{display:table-row !important}.rtmedia-container td.show-for-landscape,.rtmedia-activity-container td.show-for-landscape,#buddypress div.rtmedia-activity-container td.show-for-landscape,.rtmedia-container td.hide-for-portrait,.rtmedia-activity-container td.hide-for-portrait,#buddypress div.rtmedia-activity-container td.hide-for-portrait,.rtmedia-container th.show-for-landscape,.rtmedia-activity-container th.show-for-landscape,#buddypress div.rtmedia-activity-container th.show-for-landscape,.rtmedia-container th.hide-for-portrait,.rtmedia-activity-container th.hide-for-portrait,#buddypress div.rtmedia-activity-container th.hide-for-portrait{display:table-cell !important}}@media only screen and (orientation: portrait){.rtmedia-container .show-for-portrait,.rtmedia-activity-container .show-for-portrait,#buddypress div.rtmedia-activity-container .show-for-portrait,.rtmedia-container .hide-for-landscape,.rtmedia-activity-container .hide-for-landscape,#buddypress div.rtmedia-activity-container .hide-for-landscape{display:inherit !important}.rtmedia-container .hide-for-portrait,.rtmedia-activity-container .hide-for-portrait,#buddypress div.rtmedia-activity-container .hide-for-portrait,.rtmedia-container .show-for-landscape,.rtmedia-activity-container .show-for-landscape,#buddypress div.rtmedia-activity-container .show-for-landscape{display:none !important}.rtmedia-container table.show-for-portrait,.rtmedia-activity-container table.show-for-portrait,#buddypress div.rtmedia-activity-container table.show-for-portrait,.rtmedia-container table.hide-for-landscape,.rtmedia-activity-container table.hide-for-landscape,#buddypress div.rtmedia-activity-container table.hide-for-landscape{display:table}.rtmedia-container thead.show-for-portrait,.rtmedia-activity-container thead.show-for-portrait,#buddypress div.rtmedia-activity-container thead.show-for-portrait,.rtmedia-container thead.hide-for-landscape,.rtmedia-activity-container thead.hide-for-landscape,#buddypress div.rtmedia-activity-container thead.hide-for-landscape{display:table-header-group !important}.rtmedia-container tbody.show-for-portrait,.rtmedia-activity-container tbody.show-for-portrait,#buddypress div.rtmedia-activity-container tbody.show-for-portrait,.rtmedia-container tbody.hide-for-landscape,.rtmedia-activity-container tbody.hide-for-landscape,#buddypress div.rtmedia-activity-container tbody.hide-for-landscape{display:table-row-group !important}.rtmedia-container tr.show-for-portrait,.rtmedia-activity-container tr.show-for-portrait,#buddypress div.rtmedia-activity-container tr.show-for-portrait,.rtmedia-container tr.hide-for-landscape,.rtmedia-activity-container tr.hide-for-landscape,#buddypress div.rtmedia-activity-container tr.hide-for-landscape{display:table-row !important}.rtmedia-container td.show-for-portrait,.rtmedia-activity-container td.show-for-portrait,#buddypress div.rtmedia-activity-container td.show-for-portrait,.rtmedia-container td.hide-for-landscape,.rtmedia-activity-container td.hide-for-landscape,#buddypress div.rtmedia-activity-container td.hide-for-landscape,.rtmedia-container th.show-for-portrait,.rtmedia-activity-container th.show-for-portrait,#buddypress div.rtmedia-activity-container th.show-for-portrait,.rtmedia-container th.hide-for-landscape,.rtmedia-activity-container th.hide-for-landscape,#buddypress div.rtmedia-activity-container th.hide-for-landscape{display:table-cell !important}}.rtmedia-container .show-for-touch,.rtmedia-activity-container .show-for-touch,#buddypress div.rtmedia-activity-container .show-for-touch{display:none !important}.rtmedia-container .hide-for-touch,.rtmedia-activity-container .hide-for-touch,#buddypress div.rtmedia-activity-container .hide-for-touch{display:inherit !important}.rtmedia-container .touch .show-for-touch,.rtmedia-activity-container .touch .show-for-touch,#buddypress div.rtmedia-activity-container .touch .show-for-touch{display:inherit !important}.rtmedia-container .touch .hide-for-touch,.rtmedia-activity-container .touch .hide-for-touch,#buddypress div.rtmedia-activity-container .touch .hide-for-touch{display:none !important}.rtmedia-container table.hide-for-touch,.rtmedia-activity-container table.hide-for-touch,#buddypress div.rtmedia-activity-container table.hide-for-touch{display:table}.rtmedia-container .touch table.show-for-touch,.rtmedia-activity-container .touch table.show-for-touch,#buddypress div.rtmedia-activity-container .touch table.show-for-touch{display:table}.rtmedia-container thead.hide-for-touch,.rtmedia-activity-container thead.hide-for-touch,#buddypress div.rtmedia-activity-container thead.hide-for-touch{display:table-header-group !important}.rtmedia-container .touch thead.show-for-touch,.rtmedia-activity-container .touch thead.show-for-touch,#buddypress div.rtmedia-activity-container .touch thead.show-for-touch{display:table-header-group !important}.rtmedia-container tbody.hide-for-touch,.rtmedia-activity-container tbody.hide-for-touch,#buddypress div.rtmedia-activity-container tbody.hide-for-touch{display:table-row-group !important}.rtmedia-container .touch tbody.show-for-touch,.rtmedia-activity-container .touch tbody.show-for-touch,#buddypress div.rtmedia-activity-container .touch tbody.show-for-touch{display:table-row-group !important}.rtmedia-container tr.hide-for-touch,.rtmedia-activity-container tr.hide-for-touch,#buddypress div.rtmedia-activity-container tr.hide-for-touch{display:table-row !important}.rtmedia-container .touch tr.show-for-touch,.rtmedia-activity-container .touch tr.show-for-touch,#buddypress div.rtmedia-activity-container .touch tr.show-for-touch{display:table-row !important}.rtmedia-container td.hide-for-touch,.rtmedia-activity-container td.hide-for-touch,#buddypress div.rtmedia-activity-container td.hide-for-touch{display:table-cell !important}.rtmedia-container .touch td.show-for-touch,.rtmedia-activity-container .touch td.show-for-touch,#buddypress div.rtmedia-activity-container .touch td.show-for-touch{display:table-cell !important}.rtmedia-container th.hide-for-touch,.rtmedia-activity-container th.hide-for-touch,#buddypress div.rtmedia-activity-container th.hide-for-touch{display:table-cell !important}.rtmedia-container .touch th.show-for-touch,.rtmedia-activity-container .touch th.show-for-touch,#buddypress div.rtmedia-activity-container .touch th.show-for-touch{display:table-cell !important}.rtmedia-container .flex-video,.rtmedia-activity-container .flex-video,#buddypress div.rtmedia-activity-container .flex-video{position:relative;padding-top:1.5625em;padding-bottom:67.5%;height:0;margin-bottom:1em;overflow:hidden}.rtmedia-container .flex-video.widescreen,.rtmedia-activity-container .flex-video.widescreen,#buddypress div.rtmedia-activity-container .flex-video.widescreen{padding-bottom:57.25%}.rtmedia-container .flex-video.vimeo,.rtmedia-activity-container .flex-video.vimeo,#buddypress div.rtmedia-activity-container .flex-video.vimeo{padding-top:0}.rtmedia-container .flex-video iframe,.rtmedia-activity-container .flex-video iframe,#buddypress div.rtmedia-activity-container .flex-video iframe,.rtmedia-container .flex-video object,.rtmedia-activity-container .flex-video object,#buddypress div.rtmedia-activity-container .flex-video object,.rtmedia-container .flex-video embed,.rtmedia-activity-container .flex-video embed,#buddypress div.rtmedia-activity-container .flex-video embed,.rtmedia-container .flex-video video,.rtmedia-activity-container .flex-video video,#buddypress div.rtmedia-activity-container .flex-video video{position:absolute;top:0;left:0;width:100%;height:100%}.rtmedia-container .row,.rtmedia-activity-container .row,#buddypress div.rtmedia-activity-container .row{max-width:95%}.rtmedia-container .rtmedia-item-title,.rtmedia-activity-container .rtmedia-item-title,#buddypress div.rtmedia-activity-container .rtmedia-item-title{text-align:center}.rtmedia-container .rtmedia-item-title h4,.rtmedia-activity-container .rtmedia-item-title h4,#buddypress div.rtmedia-activity-container .rtmedia-item-title h4{text-overflow:ellipsis;white-space:nowrap;width:100%;overflow:hidden;font-size:1.1em;text-align:center}.rtmedia-container .rtmedia-success,.rtmedia-activity-container .rtmedia-success,#buddypress div.rtmedia-activity-container .rtmedia-success{display:block;padding:10px;border:1px solid #008000;background-color:#90EE90;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.rtmedia-container h2,.rtmedia-activity-container h2,#buddypress div.rtmedia-activity-container h2{font-size:1.4em;font-weight:bold;line-height:2.4em}.rtmedia-container .drag-drop,.rtmedia-activity-container .drag-drop,#buddypress div.rtmedia-activity-container .drag-drop{border:4px dashed #DDD;text-align:center;background:#fafafa;overflow:hidden;padding:15px 0}.rtmedia-container .drag-drop.dragover,.rtmedia-activity-container .drag-drop.dragover,#buddypress div.rtmedia-activity-container .drag-drop.dragover{border-color:#83b4d8}.rtmedia-container .rtmedia-action-update,.rtmedia-activity-container .rtmedia-action-update,#buddypress div.rtmedia-activity-container .rtmedia-action-update{float:left;margin-top:12px;margin-right:10px}.rtmedia-container .rtmedia-list,.rtmedia-activity-container .rtmedia-list,#buddypress div.rtmedia-activity-container .rtmedia-list{list-style:none}.rtmedia-container .rtmedia-list .rtmedia-list-item,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item{word-wrap:break-word;padding:20px;float:left}.rtmedia-container .rtmedia-list .rtmedia-list-item a,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a{text-decoration:none}.rtmedia-container .rtmedia-list .rtmedia-list-item a h4,.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a h4,#buddypress div.rtmedia-activity-container .rtmedia-list .rtmedia-list-item a h4{line-height:1.4em;font-size:1.2em;padding-top:10px}.rtmedia-container .rtmedia-media img,.rtmedia-activity-container .rtmedia-media img,#buddypress div.rtmedia-activity-container .rtmedia-media img{max-width:100%}.rtmedia-container .rtmedia-item-thumbnail,.rtmedia-activity-container .rtmedia-item-thumbnail,#buddypress div.rtmedia-activity-container .rtmedia-item-thumbnail{text-align:center}.rtmedia-container .rtmedia-item-thumbnail img,.rtmedia-activity-container .rtmedia-item-thumbnail img,#buddypress div.rtmedia-activity-container .rtmedia-item-thumbnail img{vertical-align:middle}.rtmedia-container .rtmedia_next_prev,.rtmedia-activity-container .rtmedia_next_prev,#buddypress div.rtmedia-activity-container .rtmedia_next_prev{float:left}.rtmedia-container .rtmedia-item-comments-container,.rtmedia-activity-container .rtmedia-item-comments-container,#buddypress div.rtmedia-activity-container .rtmedia-item-comments-container{margin:3% 3%}.rtmedia-container .rtmedia-comment,.rtmedia-activity-container .rtmedia-comment,#buddypress div.rtmedia-activity-container .rtmedia-comment{list-style:none;background:#f6f6f6;border:1px solid #ddd;-moz-border-radius:3px;border-radius:3px;margin:5px 0;padding:1px 5px 25px;width:391px;max-width:100%}.rtmedia-container .rtmedia-comment .rtmedia-comment-author,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-author,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-author{display:block}.rtmedia-container .rtmedia-comment .rtmedia-comment-content,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-content,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-content{display:block}.rtmedia-container .rtmedia-comment .rtmedia-comment-date,.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-date,#buddypress div.rtmedia-activity-container .rtmedia-comment .rtmedia-comment-date{display:block;float:right}.rtmedia-container .rtmedia-bp-header,.rtmedia-activity-container .rtmedia-bp-header,#buddypress div.rtmedia-activity-container .rtmedia-bp-header{width:460px;margin:auto}.rtmedia-container #div-attache-rtmedia,.rtmedia-activity-container #div-attache-rtmedia,#buddypress div.rtmedia-activity-container #div-attache-rtmedia{display:none}.rtmedia-container #rtMedia-update-queue-list p span,.rtmedia-activity-container #rtMedia-update-queue-list p span{margin-right:20px}.rtmedia-container .rtmedia-move-container,.rtmedia-activity-container .rtmedia-move-container,#buddypress div.rtmedia-activity-container .rtmedia-move-container{display:none}.rtmedia-container #rtmedia-add-media-button-post-update,.rtmedia-activity-container #rtmedia-add-media-button-post-update,#buddypress div.rtmedia-activity-container #rtmedia-add-media-button-post-update{float:left;margin-top:10px;margin-right:20px}.rtmedia-container #whats-new-post-in-box,.rtmedia-activity-container #whats-new-post-in-box,#buddypress div.rtmedia-activity-container #whats-new-post-in-box{float:left}.rtmedia-container .rtmedia-activity-text,.rtmedia-activity-container .rtmedia-activity-text,#buddypress div.rtmedia-activity-container .rtmedia-activity-text{display:block;padding-bottom:10px}.rtmedia-container .rtmedia-merge-container,.rtmedia-activity-container .rtmedia-merge-container,#buddypress div.rtmedia-activity-container .rtmedia-merge-container{display:none}.rtmedia-container .rtmedia-create-new-album-container,.rtmedia-activity-container .rtmedia-create-new-album-container,#buddypress div.rtmedia-activity-container .rtmedia-create-new-album-container{display:none}.rtmedia-container select,.rtmedia-activity-container select,#buddypress div.rtmedia-activity-container select{width:auto}.rtmedia-container.rtmedia-single-container .row,.rtmedia-single-container.rtmedia-activity-container .row,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row{background-color:#FFF}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container{padding-top:10px;padding-bottom:10px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-overlay-button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-overlay-button{margin:-50px 0 0 -50px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-button button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:rgba(0,0,0,0) url("../../../lib/media-element/controls.png") no-repeat}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-mute button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-mute button{background-position:-16px -16px}.rtmedia-container.rtmedia-single-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-fullscreen-button button,.rtmedia-single-container.rtmedia-activity-container .row #rtmedia-single-media-container .rtmedia-media .mejs-controls .mejs-fullscreen-button button{background-position:-32px 0}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta{padding:10px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta button,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta button,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta button{color:#5E5E5E;background-color:#EBEBEB;background-repeat:repeat-x;background-image:-moz-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-ms-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-webkit-linear-gradient(top, #f9f9f9, #ebebeb);background-image:-o-linear-gradient(top, #f9f9f9, #ebebeb);background-image:linear-gradient(to bottom, #f9f9f9,#ebebeb)}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta>a,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta>a,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta>a{float:left;margin:10px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions>a,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>a,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>a{display:inline-block;float:left}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions>form,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>form,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions>form{float:left;margin-right:5px}.rtmedia-container.rtmedia-single-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-single-meta .rtmedia-item-actions .rtmedia-action-buttons span{background:#EEE;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;border:1px solid #CCC;color:#999;display:inline;font-size:70%;margin-left:2px;margin-right:2px;padding:3px 6px;text-align:center;vertical-align:middle}.rtmedia-container.rtmedia-single-container .row .rtmedia-item-comments,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments{background-color:transparent}.rtmedia-container.rtmedia-single-container .row .rtmedia-item-comments div,.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments div,#buddypress div.rtmedia-single-container.rtmedia-activity-container .row .rtmedia-item-comments div{background-color:transparent}.rtmedia-container #wp-description-editor-tools a.wp-switch-editor,.rtmedia-activity-container #wp-description-editor-tools a.wp-switch-editor{margin:5px 5px 0 0;padding:4px 5px 2px;float:right;cursor:pointer;border:1px solid;border-color:#DFDFDF #DFDFDF #CCC;font:13px/18px Arial,Helvetica,sans-serif normal;height:auto}.rtmedia-container #description_toolbargroup .mceToolbar td,.rtmedia-activity-container #description_toolbargroup .mceToolbar td{padding:0px}.rtmedia-container #wp-description-editor-container,.rtmedia-activity-container #wp-description-editor-container,#buddypress div.rtmedia-activity-container #wp-description-editor-container{border-width:1px;border-style:solid;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;border-color:#CCC #CCC #DFDFDF}#buddypress div.rtmedia-activity-container ul.rtmedia-list li{float:left;padding:10px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video{float:none}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail{margin:0 auto}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-overlay-button{margin:-50px 0 0 -50px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:rgba(0,0,0,0) url("../../../lib/media-element/controls.png") no-repeat}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-mute button{background-position:-16px -16px}#buddypress div.rtmedia-activity-container ul.rtmedia-list li.media-type-video .rtmedia-item-thumbnail .mejs-controls .mejs-fullscreen-button button{background-position:-32px 0}#rtmedia-action-update{float:left;padding-right:10px}#header{z-index:1 !important}.bp_media_content video{background-color:black}.rtmedia-success{display:block;padding:10px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;background-color:#2ECC71;color:white}.rtmedia-error{color:white;display:block;padding:10px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;background-color:#E74C3C}
|
app/assets/js/rtMedia.backbone.js
CHANGED
@@ -2,6 +2,7 @@ var galleryObj;
|
|
2 |
var nextpage = 2;
|
3 |
var upload_sync = false;
|
4 |
var activity_id = -1;
|
|
|
5 |
|
6 |
jQuery(function($) {
|
7 |
|
@@ -227,7 +228,7 @@ jQuery(function($) {
|
|
227 |
|
228 |
|
229 |
if ($("#rtMedia-upload-button").length > 0) {
|
230 |
-
|
231 |
|
232 |
uploaderObj.initUploader();
|
233 |
|
@@ -295,6 +296,9 @@ jQuery(function($) {
|
|
295 |
});
|
296 |
uploaderObj.uploader.bind('BeforeUpload', function(up, file) {
|
297 |
up.settings.multipart_params.privacy = $("#rtm-file_upload-ui select#privacy").val();
|
|
|
|
|
|
|
298 |
up.settings.multipart_params.activity_id = activity_id;
|
299 |
if ($('.rtmedia-user-album-list').length > 0)
|
300 |
up.settings.multipart_params.album_id = $('.rtmedia-user-album-list').find(":selected").val();
|
@@ -312,7 +316,7 @@ jQuery(function($) {
|
|
312 |
uploaderObj.uploader.settings.multipart_params.activity_id = rtnObj.activity_id;
|
313 |
activity_id= rtnObj.activity_id;
|
314 |
} catch (e) {
|
315 |
-
|
316 |
}
|
317 |
});
|
318 |
|
2 |
var nextpage = 2;
|
3 |
var upload_sync = false;
|
4 |
var activity_id = -1;
|
5 |
+
var uploaderObj;
|
6 |
|
7 |
jQuery(function($) {
|
8 |
|
228 |
|
229 |
|
230 |
if ($("#rtMedia-upload-button").length > 0) {
|
231 |
+
uploaderObj = new UploadView(rtMedia_plupload_config);
|
232 |
|
233 |
uploaderObj.initUploader();
|
234 |
|
296 |
});
|
297 |
uploaderObj.uploader.bind('BeforeUpload', function(up, file) {
|
298 |
up.settings.multipart_params.privacy = $("#rtm-file_upload-ui select#privacy").val();
|
299 |
+
jQuery("#rtmedia-uploader-form input[type=hidden]").each(function(){
|
300 |
+
up.settings.multipart_params[$(this).attr("name")] = $(this).val();
|
301 |
+
});
|
302 |
up.settings.multipart_params.activity_id = activity_id;
|
303 |
if ($('.rtmedia-user-album-list').length > 0)
|
304 |
up.settings.multipart_params.album_id = $('.rtmedia-user-album-list').find(":selected").val();
|
316 |
uploaderObj.uploader.settings.multipart_params.activity_id = rtnObj.activity_id;
|
317 |
activity_id= rtnObj.activity_id;
|
318 |
} catch (e) {
|
319 |
+
// console.log('Invalid Activity ID');
|
320 |
}
|
321 |
});
|
322 |
|
app/assets/js/rtMedia.js
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
jQuery('document').ready(function($) {
|
2 |
|
3 |
$("#rt_media_comment_form").submit(function(e) {
|
@@ -12,10 +13,14 @@ jQuery('document').ready(function($) {
|
|
12 |
|
13 |
if (jQuery('.wp-audio-shortcode, .wp-video-shortcode').length > 0)
|
14 |
jQuery('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer();
|
15 |
-
//
|
|
|
|
|
|
|
|
|
16 |
if(typeof(rtmedia_lightbox_enabled) != 'undefined' && rtmedia_lightbox_enabled =="1"){
|
17 |
-
jQuery('.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content').magnificPopup({
|
18 |
-
delegate: 'a',
|
19 |
type: 'ajax',
|
20 |
tLoading: 'Loading image #%curr%...',
|
21 |
mainClass: 'mfp-img-mobile',
|
@@ -54,6 +59,9 @@ if(typeof(rtmedia_lightbox_enabled) != 'undefined' && rtmedia_lightbox_enabled
|
|
54 |
},
|
55 |
close: function(e) {
|
56 |
console.log(e);
|
|
|
|
|
|
|
57 |
}
|
58 |
}
|
59 |
});
|
1 |
+
var rtMagnificPopup;
|
2 |
jQuery('document').ready(function($) {
|
3 |
|
4 |
$("#rt_media_comment_form").submit(function(e) {
|
13 |
|
14 |
if (jQuery('.wp-audio-shortcode, .wp-video-shortcode').length > 0)
|
15 |
jQuery('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer();
|
16 |
+
//Remove title from popup duplication
|
17 |
+
$("li.rtmedia-list-item p a").each(function(e){
|
18 |
+
$(this).addClass("no-popup");
|
19 |
+
})
|
20 |
+
//rtmedia_lightbox_enabled from setting
|
21 |
if(typeof(rtmedia_lightbox_enabled) != 'undefined' && rtmedia_lightbox_enabled =="1"){
|
22 |
+
rtMagnificPopup = jQuery('.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content').magnificPopup({
|
23 |
+
delegate: 'a:not(".no-popup")',
|
24 |
type: 'ajax',
|
25 |
tLoading: 'Loading image #%curr%...',
|
26 |
mainClass: 'mfp-img-mobile',
|
59 |
},
|
60 |
close: function(e) {
|
61 |
console.log(e);
|
62 |
+
},
|
63 |
+
BeforeChange : function(e){
|
64 |
+
console.log(e);
|
65 |
}
|
66 |
}
|
67 |
});
|
app/assets/sass/main.scss
CHANGED
@@ -96,6 +96,7 @@
|
|
96 |
margin: 5px 0;
|
97 |
padding: 1px 5px 25px;
|
98 |
width: 391px;
|
|
|
99 |
|
100 |
.rtmedia-comment-author {
|
101 |
display: block;
|
96 |
margin: 5px 0;
|
97 |
padding: 1px 5px 25px;
|
98 |
width: 391px;
|
99 |
+
max-width:100%;
|
100 |
|
101 |
.rtmedia-comment-author {
|
102 |
display: block;
|
app/helper/RTMediaModel.php
CHANGED
@@ -7,204 +7,242 @@
|
|
7 |
*/
|
8 |
class RTMediaModel extends RTDBModel {
|
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 |
FROM
|
180 |
{$this->table_name} WHERE 2=2 ";
|
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 |
|
7 |
*/
|
8 |
class RTMediaModel extends RTDBModel {
|
9 |
|
10 |
+
function __construct () {
|
11 |
+
parent::__construct ( 'rtm_media' );
|
12 |
+
$this->meta_table_name = "rt_rtm_media_meta";
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @param type $name
|
18 |
+
* @param type $arguments
|
19 |
+
* @return type
|
20 |
+
*/
|
21 |
+
function __call ( $name, $arguments ) {
|
22 |
+
$result = parent::__call ( $name, $arguments );
|
23 |
+
if ( ! $result[ 'result' ] ) {
|
24 |
+
$result[ 'result' ] = $this->populate_results_fallback ( $name, $arguments );
|
25 |
+
}
|
26 |
+
return $result;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
*
|
31 |
+
* @global type $wpdb
|
32 |
+
* @param type $columns
|
33 |
+
* @param type $offset
|
34 |
+
* @param type $per_page
|
35 |
+
* @param type $order_by
|
36 |
+
* @return type
|
37 |
+
*/
|
38 |
+
function get ( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc' ) {
|
39 |
+
global $wpdb;
|
40 |
+
$select = "SELECT * FROM {$this->table_name}";
|
41 |
+
$join = "";
|
42 |
+
$where = " where 2=2 ";
|
43 |
+
$temp = 65;
|
44 |
+
foreach ( $columns as $colname => $colvalue ) {
|
45 |
+
if ( strtolower ( $colname ) == "meta_query" ) {
|
46 |
+
foreach ( $colvalue as $meta_query ) {
|
47 |
+
if ( ! isset ( $meta_query[ "compare" ] ) ) {
|
48 |
+
$meta_query[ "compare" ] = "=";
|
49 |
+
}
|
50 |
+
$tbl_alias = chr ( $temp ++ );
|
51 |
+
$join .= " LEFT JOIN {$wpdb->prefix}{$this->meta_table_name} {$tbl_alias} ON {$this->table_name}.id = {$tbl_alias}.media_id ";
|
52 |
+
if ( isset ( $meta_query[ "value" ] ) )
|
53 |
+
$where .= " AND ({$tbl_alias}.meta_key = '{$meta_query[ "key" ]}' and {$tbl_alias}.meta_value {$meta_query[ "compare" ]} '{$meta_query[ "value" ]}' ) ";
|
54 |
+
else
|
55 |
+
$where .= " AND {$tbl_alias}.meta_key = '{$meta_query[ "key" ]}' ";
|
56 |
+
}
|
57 |
+
} else {
|
58 |
+
if ( is_array ( $colvalue ) ) {
|
59 |
+
if ( ! isset ( $colvalue[ 'compare' ] ) )
|
60 |
+
$compare = 'IN';
|
61 |
+
else
|
62 |
+
$compare = $colvalue[ 'compare' ];
|
63 |
+
if ( ! isset ( $colvalue[ 'value' ] ) ) {
|
64 |
+
$colvalue[ 'value' ] = $colvalue;
|
65 |
+
}
|
66 |
+
$col_val_comapare = ($colvalue[ 'value' ]) ? '(\'' . implode ( "','", $colvalue[ 'value' ] ) . '\')' : '';
|
67 |
+
$where .= " AND {$this->table_name}.{$colname} {$compare} {$col_val_comapare}";
|
68 |
+
}
|
69 |
+
else
|
70 |
+
$where .= " AND {$this->table_name}.{$colname} = '{$colvalue}'";
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
$where = apply_filters ( 'rtmedia-model-where-query', $where, $this->table_name );
|
75 |
+
$sql = $select . $join . $where;
|
76 |
+
|
77 |
+
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
78 |
+
|
79 |
+
if ( is_integer ( $offset ) && is_integer ( $per_page ) ) {
|
80 |
+
$sql .= ' LIMIT ' . $offset . ',' . $per_page;
|
81 |
+
}
|
82 |
+
|
83 |
+
return $wpdb->get_results ( $sql );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
*
|
88 |
+
* @param type $name
|
89 |
+
* @param type $arguments
|
90 |
+
* @return type
|
91 |
+
*/
|
92 |
+
function populate_results_fallback ( $name, $arguments ) {
|
93 |
+
$result[ 'result' ] = false;
|
94 |
+
if ( 'get_by_media_id' == $name && isset ( $arguments[ 0 ] ) && $arguments[ 0 ] ) {
|
95 |
+
|
96 |
+
$result[ 'result' ][ 0 ]->media_id = $arguments[ 0 ];
|
97 |
+
|
98 |
+
$post_type = get_post_field ( 'post_type', $arguments[ 0 ] );
|
99 |
+
if ( 'attachment' == $post_type ) {
|
100 |
+
$post_mime_type = explode ( '/', get_post_field ( 'post_mime_type', $arguments[ 0 ] ) );
|
101 |
+
$result[ 'result' ][ 0 ]->media_type = $post_mime_type[ 0 ];
|
102 |
+
} elseif ( 'bp_media_album' == $post_type ) {
|
103 |
+
$result[ 'result' ][ 0 ]->media_type = 'bp_media_album';
|
104 |
+
} else {
|
105 |
+
$result[ 'result' ][ 0 ]->media_type = false;
|
106 |
+
}
|
107 |
+
|
108 |
+
$result[ 'result' ][ 0 ]->context_id = intval ( get_post_meta ( $arguments[ 0 ], 'bp-media-key', true ) );
|
109 |
+
if ( $result[ 'result' ][ 0 ]->context_id > 0 )
|
110 |
+
$result[ 'result' ][ 0 ]->context = 'profile';
|
111 |
+
else
|
112 |
+
$result[ 'result' ][ 0 ]->context = 'group';
|
113 |
+
|
114 |
+
$result[ 'result' ][ 0 ]->activity_id = get_post_meta ( $arguments[ 0 ], 'bp_media_child_activity', true );
|
115 |
+
|
116 |
+
$result[ 'result' ][ 0 ]->privacy = get_post_meta ( $arguments[ 0 ], 'bp_media_privacy', true );
|
117 |
+
}
|
118 |
+
return $result[ 'result' ];
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
*
|
123 |
+
* @param type $columns
|
124 |
+
* @param type $offset
|
125 |
+
* @param type $per_page
|
126 |
+
* @param type $order_by
|
127 |
+
* @return type
|
128 |
+
*/
|
129 |
+
function get_media ( $columns, $offset = false, $per_page = false, $order_by = 'media_id desc' ) {
|
130 |
+
if ( is_multisite () ) {
|
131 |
+
$results = $this->get ( $columns, $offset, $per_page, "blog_id ," . $order_by );
|
132 |
+
} else {
|
133 |
+
$results = $this->get ( $columns, $offset, $per_page, $order_by );
|
134 |
+
}
|
135 |
+
return $results;
|
136 |
+
}
|
137 |
+
|
138 |
+
function get_user_albums ( $author_id, $offset, $per_page, $order_by = 'media_id desc' ) {
|
139 |
+
global $wpdb;
|
140 |
+
if ( is_multisite () )
|
141 |
+
$order_by = "blog_id ," . $order_by;
|
142 |
+
|
143 |
+
$sql = "SELECT * FROM {$this->table_name} WHERE (id IN(SELECT DISTINCT (album_id)
|
144 |
+
FROM {$this->table_name}
|
145 |
+
WHERE media_author = $author_id
|
146 |
+
AND album_id IS NOT NULL
|
147 |
+
AND media_type <> 'album' AND context <> 'group') OR (media_author = $author_id ))
|
148 |
+
AND media_type = 'album'
|
149 |
+
AND (context <> 'group' or context is NULL) ";
|
150 |
+
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
151 |
+
|
152 |
+
if ( is_integer ( $offset ) && is_integer ( $per_page ) ) {
|
153 |
+
$sql .= ' LIMIT ' . $offset . ',' . $per_page;
|
154 |
+
}
|
155 |
+
|
156 |
+
$results = $wpdb->get_results ( $sql );
|
157 |
+
return $results;
|
158 |
+
}
|
159 |
+
|
160 |
+
function get_group_albums ( $group_id, $offset, $per_page, $order_by = 'media_id desc' ) {
|
161 |
+
global $wpdb;
|
162 |
+
if ( is_multisite () )
|
163 |
+
$order_by = "blog_id ," . $order_by;
|
164 |
+
$sql = "SELECT * FROM {$this->table_name} WHERE id IN(SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id = $group_id AND album_id IS NOT NULL AND media_type != 'album' AND context = 'group') OR (media_type = 'album' AND context_id = $group_id AND context = 'group')";
|
165 |
+
$sql .= " ORDER BY {$this->table_name}.$order_by";
|
166 |
+
|
167 |
+
if ( is_integer ( $offset ) && is_integer ( $per_page ) ) {
|
168 |
+
$sql .= ' LIMIT ' . $offset . ',' . $per_page;
|
169 |
+
}
|
170 |
+
$results = $wpdb->get_results ( $sql );
|
171 |
+
return $results;
|
172 |
+
}
|
173 |
+
|
174 |
+
function get_counts ( $user_id = false, $where_query = false ) {
|
175 |
+
|
176 |
+
if ( ! $user_id && ! $where_query )
|
177 |
+
return false;
|
178 |
+
global $wpdb, $rtmedia;
|
179 |
+
|
180 |
+
$query =
|
181 |
+
"SELECT {$this->table_name}.privacy, ";
|
182 |
+
foreach ( $rtmedia->allowed_types as $type ) {
|
183 |
+
$query .= "SUM(CASE WHEN {$this->table_name}.media_type LIKE '{$type[ 'name' ]}' THEN 1 ELSE 0 END) as {$type[ 'name' ]}, ";
|
184 |
+
}
|
185 |
+
$query .= "SUM(CASE WHEN {$this->table_name}.media_type LIKE 'album' THEN 1 ELSE 0 END) as album
|
186 |
FROM
|
187 |
{$this->table_name} WHERE 2=2 ";
|
188 |
+
|
189 |
+
if ( $where_query ) {
|
190 |
+
foreach ( $where_query as $colname => $colvalue ) {
|
191 |
+
if ( strtolower ( $colname ) != "meta_query" ) {
|
192 |
+
if ( is_array ( $colvalue ) ) {
|
193 |
+
if ( ! isset ( $colvalue[ 'compare' ] ) )
|
194 |
+
$compare = 'IN';
|
195 |
+
else
|
196 |
+
$compare = $colvalue[ 'compare' ];
|
197 |
+
if ( ! isset ( $colvalue[ 'value' ] ) ) {
|
198 |
+
$colvalue[ 'value' ] = $colvalue;
|
199 |
+
}
|
200 |
+
|
201 |
+
$query .= " AND {$this->table_name}.{$colname} {$compare} ('" . implode ( "','", $colvalue[ 'value' ] ) . "')";
|
202 |
+
} else {
|
203 |
+
|
204 |
+
if ( $colname == "context" && $colvalue == "profile" ) {
|
205 |
+
$query .= " AND {$this->table_name}.{$colname} <> 'group'";
|
206 |
+
} else {
|
207 |
+
$query .= " AND {$this->table_name}.{$colname} = '{$colvalue}'";
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
213 |
+
$query .= "GROUP BY privacy";
|
214 |
+
|
215 |
+
$result = $wpdb->get_results ( $query );
|
216 |
+
if ( ! is_array ( $result ) )
|
217 |
+
return false;
|
218 |
+
return $result;
|
219 |
+
}
|
220 |
+
|
221 |
+
function get_other_album_count ( $profile_id, $context = "profile" ) {
|
222 |
+
$global = RTMediaAlbum::get_globals ();
|
223 |
+
$sql = "select distinct album_id from {$this->table_name} where 2=2 AND context = '{$context}' ";
|
224 |
+
if ( is_array ( $global ) && count ( $global ) > 0 ) {
|
225 |
+
$sql .= " and album_id in (";
|
226 |
+
$sep = "";
|
227 |
+
foreach ( $global as $id ) {
|
228 |
+
$sql .= $sep . $id;
|
229 |
+
$sep = ",";
|
230 |
+
}
|
231 |
+
$sql .= ")";
|
232 |
+
}
|
233 |
+
if ( $context == "profile" ) {
|
234 |
+
$sql .= " AND media_author=$profile_id ";
|
235 |
+
} else if ( $context == "group" ) {
|
236 |
+
$sql .= " AND context_id=$profile_id ";
|
237 |
+
}
|
238 |
+
global $wpdb;
|
239 |
+
$result = $wpdb->get_results ( $sql );
|
240 |
+
if ( isset ( $result ) ) {
|
241 |
+
return count ( $result );
|
242 |
+
} else {
|
243 |
+
return 0;
|
244 |
+
}
|
245 |
+
}
|
246 |
|
247 |
}
|
248 |
|
app/helper/db/RTDBUpdate.php
CHANGED
@@ -50,6 +50,7 @@ class RTDBUpdate {
|
|
50 |
|
51 |
public function do_upgrade() {
|
52 |
if (version_compare($this->db_version, $this->install_db_version, '>')) {
|
|
|
53 |
$path = realpath(dirname(__FILE__) . $this->schema_path);
|
54 |
if ($handle = opendir($path)) {
|
55 |
while (false !== ($entry = readdir($handle))) {
|
50 |
|
51 |
public function do_upgrade() {
|
52 |
if (version_compare($this->db_version, $this->install_db_version, '>')) {
|
53 |
+
do_action("rt_db_upgrade");
|
54 |
$path = realpath(dirname(__FILE__) . $this->schema_path);
|
55 |
if ($handle = opendir($path)) {
|
56 |
while (false !== ($entry = readdir($handle))) {
|
app/helper/rtForm.php
CHANGED
@@ -24,6 +24,7 @@ if(!class_exists("rtForm")) {
|
|
24 |
private static $id_counts = array(
|
25 |
"rtText" => 0,
|
26 |
"rtNumber" => 0,
|
|
|
27 |
"rtRadio" => 0,
|
28 |
"rtCheckbox" => 0,
|
29 |
"rtSelect" => 0,
|
@@ -35,6 +36,7 @@ if(!class_exists("rtForm")) {
|
|
35 |
private static $default_classes = array(
|
36 |
"rtText" => "rt-form-text",
|
37 |
"rtNumber" => "rt-form-number",
|
|
|
38 |
"rtRadio" => "rt-form-radio",
|
39 |
"rtCheckbox" => "rt-form-checkbox",
|
40 |
"rtSelect" => "rt-form-select",
|
@@ -146,8 +148,18 @@ if(!class_exists("rtForm")) {
|
|
146 |
}
|
147 |
|
148 |
private function embedd_misc_attributes($misc) {
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
$html = '';
|
150 |
|
|
|
|
|
|
|
|
|
151 |
return $html;
|
152 |
}
|
153 |
|
@@ -176,8 +188,8 @@ if(!class_exists("rtForm")) {
|
|
176 |
$html .= $this->embedd_class($element);
|
177 |
}
|
178 |
|
179 |
-
if(isset($attributes['misc'])
|
180 |
-
$html.= $this->embedd_misc_attributes($attributes['misc']);
|
181 |
|
182 |
$html .= $this->generate_element_value($element, $attributes);
|
183 |
|
@@ -286,9 +298,13 @@ if(!class_exists("rtForm")) {
|
|
286 |
throw new rtFormInvalidArgumentsException( "attributes" );
|
287 |
}
|
288 |
|
289 |
-
protected function enclose_label($element, $html, $label) {
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
$data = '<label for="' . $this->element_id . '">';
|
292 |
|
293 |
if( $element == "rtRadio" || $element == "rtCheckbox" )
|
294 |
$data .= $html . ' ' . $label;
|
@@ -315,8 +331,12 @@ if(!class_exists("rtForm")) {
|
|
315 |
/* ending the tag */
|
316 |
$html .= ' />';
|
317 |
|
318 |
-
if( isset($attributes['label']) )
|
319 |
-
|
|
|
|
|
|
|
|
|
320 |
|
321 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
322 |
$html .= $this->generate_element_desc($attributes);
|
@@ -346,8 +366,12 @@ if(!class_exists("rtForm")) {
|
|
346 |
/* ending the tag */
|
347 |
$html .= ' />';
|
348 |
|
349 |
-
if( isset($attributes['label']) )
|
350 |
-
|
|
|
|
|
|
|
|
|
351 |
|
352 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
353 |
$html .= $this->generate_element_desc($attributes);
|
@@ -362,6 +386,35 @@ if(!class_exists("rtForm")) {
|
|
362 |
return $this->generate_number($attributes);
|
363 |
}
|
364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
protected function generate_hidden($attributes) {
|
367 |
|
@@ -377,8 +430,12 @@ if(!class_exists("rtForm")) {
|
|
377 |
/* ending the tag */
|
378 |
$html .= ' />';
|
379 |
|
380 |
-
if( isset($attributes['label']) )
|
381 |
-
|
|
|
|
|
|
|
|
|
382 |
|
383 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
384 |
$html .= $this->generate_element_desc($attributes);
|
@@ -407,8 +464,12 @@ if(!class_exists("rtForm")) {
|
|
407 |
|
408 |
$html .= '</textarea>';
|
409 |
|
410 |
-
if( isset($attributes['label']) )
|
411 |
-
|
|
|
|
|
|
|
|
|
412 |
|
413 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
414 |
$html .= $this->generate_element_desc($attributes);
|
@@ -567,8 +628,12 @@ if(!class_exists("rtForm")) {
|
|
567 |
|
568 |
$html .= '</select>';
|
569 |
|
570 |
-
if( isset($attributes['label']) )
|
571 |
-
|
|
|
|
|
|
|
|
|
572 |
|
573 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
574 |
$html .= $this->generate_element_desc($attributes);
|
24 |
private static $id_counts = array(
|
25 |
"rtText" => 0,
|
26 |
"rtNumber" => 0,
|
27 |
+
"rtDate" => 0,
|
28 |
"rtRadio" => 0,
|
29 |
"rtCheckbox" => 0,
|
30 |
"rtSelect" => 0,
|
36 |
private static $default_classes = array(
|
37 |
"rtText" => "rt-form-text",
|
38 |
"rtNumber" => "rt-form-number",
|
39 |
+
"rtDate" => "rt-form-date",
|
40 |
"rtRadio" => "rt-form-radio",
|
41 |
"rtCheckbox" => "rt-form-checkbox",
|
42 |
"rtSelect" => "rt-form-select",
|
148 |
}
|
149 |
|
150 |
private function embedd_misc_attributes($misc) {
|
151 |
+
|
152 |
+
if(!is_array($misc)) {
|
153 |
+
throw new rtFormInvalidArgumentsException("attributes : misc");
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
$html = '';
|
158 |
|
159 |
+
foreach ($misc as $key => $value) {
|
160 |
+
$html .= $key . '="' . $value . '" ';
|
161 |
+
}
|
162 |
+
|
163 |
return $html;
|
164 |
}
|
165 |
|
188 |
$html .= $this->embedd_class($element);
|
189 |
}
|
190 |
|
191 |
+
if(isset($attributes['misc']))
|
192 |
+
$html.= ' ' . $this->embedd_misc_attributes($attributes['misc']);
|
193 |
|
194 |
$html .= $this->generate_element_value($element, $attributes);
|
195 |
|
298 |
throw new rtFormInvalidArgumentsException( "attributes" );
|
299 |
}
|
300 |
|
301 |
+
protected function enclose_label($element, $html, $label, $class=false) {
|
302 |
+
|
303 |
+
$labelClass = '';
|
304 |
+
if(!empty($class) && is_array($class))
|
305 |
+
$labelClass = 'class="'.implode(' ', $class).'"';
|
306 |
|
307 |
+
$data = '<label for="' . $this->element_id . '" '.$labelClass.'>';
|
308 |
|
309 |
if( $element == "rtRadio" || $element == "rtCheckbox" )
|
310 |
$data .= $html . ' ' . $label;
|
331 |
/* ending the tag */
|
332 |
$html .= ' />';
|
333 |
|
334 |
+
if( isset($attributes['label']) ) {
|
335 |
+
if( isset($attributes['labelClass']) )
|
336 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
337 |
+
else
|
338 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
339 |
+
}
|
340 |
|
341 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
342 |
$html .= $this->generate_element_desc($attributes);
|
366 |
/* ending the tag */
|
367 |
$html .= ' />';
|
368 |
|
369 |
+
if( isset($attributes['label']) ) {
|
370 |
+
if( isset($attributes['labelClass']) )
|
371 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
372 |
+
else
|
373 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
374 |
+
}
|
375 |
|
376 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
377 |
$html .= $this->generate_element_desc($attributes);
|
386 |
return $this->generate_number($attributes);
|
387 |
}
|
388 |
|
389 |
+
protected function generate_date($attributes) {
|
390 |
+
|
391 |
+
$element = 'rtDate';
|
392 |
+
if( is_array( $attributes ) ) {
|
393 |
+
$html = '<input type="date" ';
|
394 |
+
|
395 |
+
$html .= $this->processAttributes($element, $attributes);
|
396 |
+
|
397 |
+
$html .= ' />';
|
398 |
+
|
399 |
+
if( isset($attributes['label']) ) {
|
400 |
+
if( isset($attributes['labelClass']) )
|
401 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
402 |
+
else
|
403 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
404 |
+
}
|
405 |
+
|
406 |
+
if( isset($attributes['show_desc']) && $attributes['desc'] )
|
407 |
+
$html .= $this->generate_element_desc($attributes);
|
408 |
+
|
409 |
+
return $html;
|
410 |
+
} else
|
411 |
+
throw new rtFormInvalidArgumentsException( "attributes" );
|
412 |
+
}
|
413 |
+
|
414 |
+
public function get_date($attributes) {
|
415 |
+
return $this->generate_date($attributes);
|
416 |
+
}
|
417 |
+
|
418 |
|
419 |
protected function generate_hidden($attributes) {
|
420 |
|
430 |
/* ending the tag */
|
431 |
$html .= ' />';
|
432 |
|
433 |
+
if( isset($attributes['label']) ) {
|
434 |
+
if( isset($attributes['labelClass']) )
|
435 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
436 |
+
else
|
437 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
438 |
+
}
|
439 |
|
440 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
441 |
$html .= $this->generate_element_desc($attributes);
|
464 |
|
465 |
$html .= '</textarea>';
|
466 |
|
467 |
+
if( isset($attributes['label']) ) {
|
468 |
+
if( isset($attributes['labelClass']) )
|
469 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
470 |
+
else
|
471 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
472 |
+
}
|
473 |
|
474 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
475 |
$html .= $this->generate_element_desc($attributes);
|
628 |
|
629 |
$html .= '</select>';
|
630 |
|
631 |
+
if( isset($attributes['label']) ) {
|
632 |
+
if( isset($attributes['labelClass']) )
|
633 |
+
$html = $this->enclose_label($element, $html, $attributes['label'], $attributes['labelClass']);
|
634 |
+
else
|
635 |
+
$html = $this->enclose_label($element, $html, $attributes['label']);
|
636 |
+
}
|
637 |
|
638 |
if( isset($attributes['show_desc']) && $attributes['show_desc'] )
|
639 |
$html .= $this->generate_element_desc($attributes);
|
app/importers/RTMediaMigration.php
CHANGED
@@ -9,100 +9,101 @@ class RTMediaMigration {
|
|
9 |
|
10 |
public $bmp_table = "";
|
11 |
|
12 |
-
function __construct() {
|
13 |
global $wpdb;
|
14 |
$this->bmp_table = $wpdb->prefix . "rt_rtm_media";
|
15 |
-
|
16 |
-
add_action('admin_menu', array($this, 'menu'));
|
17 |
-
add_action('wp_ajax_bp_media_rt_db_migration', array($this, "migrate_to_new_db"));
|
18 |
-
|
19 |
-
if(isset($_REQUEST["page"]) && $_REQUEST["page"] == "rtmedia-migration" && isset($_REQUEST["hide"]) && $_REQUEST["hide"] =="true"){
|
20 |
-
$this->hide_migration_notice();
|
21 |
-
wp_safe_redirect($_SERVER["HTTP_REFERER"]);
|
22 |
}
|
23 |
-
if(get_site_option("rt_migration_hide_notice") !== false)
|
24 |
return true;
|
25 |
-
|
26 |
-
if (isset($_REQUEST["force"]) && $_REQUEST["force"] === "true")
|
27 |
$pending = false;
|
28 |
else
|
29 |
-
$pending = get_site_option("rtMigration-pending-count");
|
30 |
-
$total = $this->get_total_count();
|
31 |
-
|
32 |
-
if ($pending === false) {
|
33 |
-
$total = $this->get_total_count();
|
34 |
-
$done = $this->get_done_count();
|
35 |
$pending = $total - $done;
|
36 |
-
if ($pending < 0)
|
37 |
$pending = 0;
|
38 |
-
update_site_option("rtMigration-pending-count", $pending);
|
39 |
}
|
40 |
-
if ($pending > 0) {
|
41 |
-
if(!(isset($_REQUEST["page"]) && $_REQUEST["page"] == "rtmedia-migration"))
|
42 |
-
add_action('admin_notices', array(&$this, 'add_migration_notice'));
|
43 |
}
|
44 |
-
|
45 |
}
|
46 |
-
|
47 |
-
|
|
|
48 |
}
|
49 |
-
|
50 |
-
|
|
|
51 |
global $wpdb;
|
52 |
-
$sql = $wpdb->prepare("update $wpdb->postmeta set meta_value=replace(meta_value ,%s,%s) where meta_key = '_wp_attachment_metadata';","bp_media","rt_media");
|
53 |
-
$wpdb->get_row($sql);
|
54 |
-
update_option("rt_image_size_migration_fix", "fix");
|
55 |
}
|
56 |
}
|
57 |
|
58 |
-
function add_migration_notice() {
|
59 |
-
if (current_user_can( 'manage_options' ) )
|
60 |
-
$this->create_notice("<p><strong>rtMedia</strong> : Please Migrate your Database <a href='" . admin_url("admin.php?page=rtmedia-migration&force=true") . "'>Click Here</a>. <a href='" . admin_url("admin.php?page=rtmedia-migration&hide=true") . "' style='float:right'>" . __("Hide") . "</a> </p>");
|
61 |
}
|
62 |
|
63 |
-
function create_notice($message, $type = "error") {
|
64 |
echo '<div class="' . $type . '">' . $message . '</div>';
|
65 |
}
|
66 |
|
67 |
-
static function table_exists($table) {
|
68 |
global $wpdb;
|
69 |
|
70 |
-
if ($wpdb->query("SHOW TABLES LIKE '" . $table . "'") == 1) {
|
71 |
return true;
|
72 |
}
|
73 |
|
74 |
return false;
|
75 |
}
|
76 |
|
77 |
-
function menu() {
|
78 |
-
add_submenu_page('rtmedia-settings', __('Migration', 'buddypress-media'), __('Migration', 'buddypress-media'), 'manage_options', 'rtmedia-migration', array($this, 'test'));
|
79 |
}
|
80 |
|
81 |
-
function get_total_count() {
|
82 |
global $wpdb;
|
83 |
-
if (function_exists("bp_core_get_table_prefix"))
|
84 |
-
$bp_prefix = bp_core_get_table_prefix();
|
85 |
else
|
86 |
$bp_prefix = "";
|
87 |
$sql_album_usercount = "select count(*) FROM $wpdb->usermeta where meta_key ='bp-media-default-album' ";
|
88 |
|
89 |
-
$_SESSION["migration_user_album"] = $wpdb->get_var($sql_album_usercount);
|
90 |
-
$count = intval($_SESSION["migration_user_album"]);
|
91 |
|
92 |
-
if ($this->table_exists($bp_prefix . "bp_groups_groupmeta")) {
|
93 |
$sql_album_groupcount = "select count(*) FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album'";
|
94 |
-
$_SESSION["migration_group_album"] = $wpdb->get_var($sql_album_groupcount);
|
95 |
-
$count += intval($_SESSION["migration_group_album"]);
|
96 |
}
|
97 |
-
if ($this->table_exists($bp_prefix . "bp_activity")) {
|
98 |
//$sql_bpm_comment_count = "select count(*) from {$bp_prefix}bp_activity where component='activity' and type='activity_comment' and is_spam <> 1 and ;";
|
99 |
-
|
100 |
count(id)
|
101 |
FROM
|
102 |
{$bp_prefix}bp_activity
|
103 |
where
|
104 |
type = 'activity_comment'
|
105 |
-
and is_spam <>1
|
106 |
and item_id in (select distinct
|
107 |
a.meta_value
|
108 |
from
|
@@ -116,8 +117,8 @@ class RTMediaMigration {
|
|
116 |
|
117 |
//echo $sql_bpm_comment_count;
|
118 |
|
119 |
-
$_SESSION["migration_activity"] = $wpdb->get_var($sql_bpm_comment_count);
|
120 |
-
$count +=intval($_SESSION["migration_activity"]);
|
121 |
}
|
122 |
|
123 |
$sql = "select count(*)
|
@@ -136,15 +137,15 @@ class RTMediaMigration {
|
|
136 |
and a.meta_key = 'bp-media-key'";
|
137 |
|
138 |
|
139 |
-
$_SESSION["migration_media"] = $wpdb->get_var($sql);
|
140 |
-
$count += intval($_SESSION["migration_media"]);
|
141 |
-
|
142 |
return $count;
|
143 |
}
|
144 |
|
145 |
-
function get_last_imported() {
|
146 |
-
$album = get_site_option("rtmedia-global-albums");
|
147 |
-
$album_id = $album[0];
|
148 |
|
149 |
global $wpdb;
|
150 |
$sql = "select a.post_ID
|
@@ -154,16 +155,16 @@ class RTMediaMigration {
|
|
154 |
where
|
155 |
a.meta_key = 'bp-media-key' and (NOT p.ID IS NULL) and a.post_id not in (select media_id
|
156 |
from {$this->bmp_table} where blog_id = %d and media_id <> %d ) order by a.post_ID";
|
157 |
-
$sql = $wpdb->prepare($sql, get_current_blog_id(), $album_id);
|
158 |
-
$row = $wpdb->get_row($sql);
|
159 |
-
if ($row) {
|
160 |
return $row->post_ID;
|
161 |
} else {
|
162 |
return false;
|
163 |
}
|
164 |
}
|
165 |
|
166 |
-
function get_done_count($flag = false) {
|
167 |
global $wpdb;
|
168 |
$sql = "select count(*)
|
169 |
from {$this->bmp_table} where blog_id = %d and media_id in (select a.post_id
|
@@ -181,218 +182,217 @@ class RTMediaMigration {
|
|
181 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
182 |
and a.meta_key = 'bp-media-key')";
|
183 |
|
184 |
-
$media_count = $wpdb->get_var($wpdb->prepare($sql, get_current_blog_id()));
|
185 |
-
if ($flag)
|
186 |
return $media_count - 1;
|
187 |
-
$state = intval(get_site_option("rtmedia-migration", "0"));
|
188 |
-
if ($state == 5) {
|
189 |
-
$album_count = intval($_SESSION["migration_user_album"]);
|
190 |
-
$album_count += (isset($_SESSION["migration_group_album"])) ? intval($_SESSION["migration_group_album"]) : 0;
|
191 |
} else {
|
192 |
-
if ($state >0){
|
193 |
-
|
194 |
-
$bp_prefix = bp_core_get_table_prefix();
|
195 |
else
|
196 |
$bp_prefix = "";
|
197 |
$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
198 |
-
if ($this->table_exists($bp_prefix . "bp_groups_groupmeta")) {
|
199 |
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
200 |
}
|
201 |
$pending_count .= ")";
|
202 |
-
$pending_count = $wpdb->get_var($pending_count);
|
203 |
-
|
204 |
-
$album_count = intval($_SESSION["migration_user_album"]);
|
205 |
-
$album_count += (isset($_SESSION["migration_group_album"])) ? intval($_SESSION["migration_group_album"]) : 0;
|
206 |
-
$album_count = $album_count -
|
207 |
-
}
|
208 |
-
else{
|
209 |
$album_count = 0;
|
210 |
}
|
211 |
}
|
212 |
-
if (intval($_SESSION["migration_media"]) == intval($media_count)) {
|
213 |
-
$comment_sql = $_SESSION["migration_activity"];
|
214 |
} else {
|
215 |
-
$comment_sql = $wpdb->get_var("select count(*)
|
216 |
-
from $wpdb->comments a
|
217 |
where a.comment_post_ID in (select b.media_id from $this->bmp_table b left join
|
218 |
-
{$wpdb->posts} p ON (b.media_id = p.ID) where (NOT p.ID IS NULL) ) and a.comment_agent=''");
|
219 |
}
|
220 |
// echo $media_count . "--" . $album_count . "--" . $comment_sql;
|
221 |
return $media_count + $album_count + $comment_sql;
|
222 |
}
|
223 |
|
224 |
-
function return_migration() {
|
225 |
-
$total = $this->get_total_count();
|
226 |
-
$done = $this->get_done_count();
|
227 |
$pending = $total - $done;
|
228 |
-
if ($pending < 0) {
|
229 |
$pending = 0;
|
230 |
$done = $total;
|
231 |
}
|
232 |
-
if($done > $total){
|
233 |
$done = $total;
|
234 |
}
|
235 |
-
if($done == $total){
|
236 |
-
|
237 |
//Call flush_rules() as a method of the $wp_rewrite object
|
238 |
-
$wp_rewrite->flush_rules(true);
|
239 |
-
|
240 |
}
|
241 |
-
update_site_option("rtMigration-pending-count", $pending);
|
242 |
-
$pending_time = $this->formatSeconds($pending);
|
243 |
|
244 |
-
echo json_encode(array("status" => true, "done" => $done, "total" => $total,"pending"
|
245 |
-
die();
|
246 |
}
|
247 |
|
248 |
-
function manage_album() {
|
249 |
-
$album = get_site_option("rtmedia-global-albums");
|
250 |
-
$stage = intval(get_site_option("rtmedia-migration", "0"));
|
251 |
-
|
252 |
-
$album_rt_id = $album[0];
|
253 |
|
254 |
$album_post_type = "rtmedia_album";
|
255 |
-
|
256 |
global $wpdb;
|
257 |
-
|
258 |
-
$album_id =
|
259 |
-
|
260 |
-
if (function_exists("bp_core_get_table_prefix"))
|
261 |
-
$bp_prefix = bp_core_get_table_prefix();
|
262 |
else
|
263 |
$bp_prefix = "";
|
264 |
|
265 |
-
if($stage < 1){
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
$sql = $wpdb->prepare("update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;",'<ul class="bp-media-list-media">','<div class="rtmedia-activity-container"><ul class="rtmedia-list large-block-grid-3">');
|
272 |
-
$wpdb->get_row($sql);
|
273 |
-
$sql = $wpdb->prepare("update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;",'</ul>','</ul></div>');
|
274 |
-
$wpdb->get_row($sql);
|
275 |
-
|
276 |
-
|
277 |
$sql_group = "update $wpdb->posts set post_parent='{$album_id}' where post_parent in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
278 |
-
if ($this->table_exists($bp_prefix . "bp_groups_groupmeta")) {
|
279 |
$sql_group .= " or post_parent in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
280 |
}
|
281 |
-
$wpdb->query($sql_group);
|
282 |
$stage = 1;
|
283 |
-
update_site_option("rtmedia-migration", $stage);
|
284 |
-
$this->return_migration();
|
285 |
}
|
286 |
-
if($stage < 2){
|
287 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') limit 10";
|
288 |
-
$results = $wpdb->get_results($sql_delete);
|
289 |
$delete_ids = "";
|
290 |
$sep = "";
|
291 |
-
foreach($results as $result){
|
292 |
-
$this->search_and_replace($result->guid, trailingslashit(get_rtmedia_user_link($result->post_author)). "
|
293 |
$delete_ids .= $sep . $result->ID;
|
294 |
$sep = ",";
|
295 |
}
|
296 |
-
if($delete_ids != "")
|
297 |
-
|
298 |
-
if(count($results) < 10){
|
299 |
-
$stage =2;
|
300 |
}
|
301 |
-
update_site_option("rtmedia-migration", $stage);
|
302 |
-
$this->return_migration();
|
303 |
}
|
304 |
-
if($stage < 3){
|
305 |
-
|
306 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album') limit 10";
|
307 |
-
$results = $wpdb->get_results($sql_delete);
|
308 |
$delete_ids = "";
|
309 |
$sep = "";
|
310 |
-
if($results){
|
311 |
-
foreach($results as $result){
|
312 |
-
$group_id =
|
313 |
-
$this->search_and_replace(trailingslashit(get_rtmedia_group_link($group_id)). "albums/" . $result->ID, trailingslashit(get_rtmedia_group_link($group_id)). "
|
314 |
$delete_ids .= $sep . $result->ID;
|
315 |
$sep = ",";
|
316 |
}
|
317 |
-
if($delete_ids != "")
|
318 |
-
$wpdb->query("delete from $wpdb->posts where ID in ({$delete_ids})");
|
319 |
-
if(count($results) < 10){
|
320 |
-
$stage =3;
|
321 |
}
|
322 |
-
}else{
|
323 |
-
|
324 |
}
|
325 |
-
update_site_option("rtmedia-migration", $stage);
|
326 |
-
$this->return_migration();
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$this->return_migration();
|
331 |
-
|
332 |
}
|
333 |
-
|
334 |
|
335 |
$sql = "update $wpdb->posts set post_type='{$album_post_type}' where post_type='bp_media_album'";
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
return false;
|
341 |
}
|
342 |
|
343 |
-
function test() {
|
344 |
-
if(
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
}
|
349 |
global $rtmedia_error;
|
350 |
-
if(isset($rtmedia_error) && $rtmedia_error===true){
|
351 |
-
|
352 |
<div class="error"><p> Please Resolve create database error before migration.</p></div>
|
353 |
-
|
354 |
-
|
|
|
355 |
$prog = new rtProgress();
|
356 |
-
$total = $this->get_total_count();
|
357 |
-
$done = $this->get_done_count();
|
358 |
-
if($done >= $total){
|
359 |
$done = $total;
|
360 |
-
|
|
|
361 |
<div class="error"><p> Please Backup your <strong>DATABASE</strong> and <strong>UPLOAD</strong> folder before Migration.</p></div>
|
362 |
<?php }
|
363 |
-
|
364 |
?>
|
365 |
-
|
366 |
<div class="wrap">
|
367 |
-
|
368 |
<h2>rtMedia Migration</h2>
|
369 |
-
<h3><?php _e("It will migrate following things"); ?> </h3>
|
370 |
-
User Albums : <?php echo $_SESSION["migration_user_album"]; ?><br />
|
371 |
-
<?php if (isset($_SESSION["migration_group_album"])) { ?>
|
372 |
-
Groups Albums : <?php echo $_SESSION["migration_group_album"]; ?><br />
|
373 |
<?php } ?>
|
374 |
-
Media : <?php echo $_SESSION["migration_media"]; ?><br />
|
375 |
-
<?php if (isset($_SESSION["migration_activity"])) { ?>
|
376 |
-
Comments : <?php echo $_SESSION["migration_activity"]; ?><br />
|
377 |
<?php } ?>
|
378 |
<hr />
|
379 |
|
380 |
<?php
|
381 |
-
echo '<span class="pending">' . $this->formatSeconds($total - $done) . '</span><br />';
|
382 |
echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
|
383 |
-
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
384 |
|
385 |
-
$temp = $prog->progress($done, $total);
|
386 |
-
$prog->progress_ui($temp, true);
|
387 |
?>
|
388 |
<script type="text/javascript">
|
389 |
-
jQuery(document).ready(function(e){
|
390 |
-
if(db_total<1)
|
391 |
-
jQuery("#submit").attr('disabled',"disabled");
|
392 |
})
|
393 |
function db_start_migration(db_done, db_total) {
|
394 |
-
|
395 |
-
|
396 |
if (db_done < db_total) {
|
397 |
jQuery("#rtMediaSyncing").show();
|
398 |
jQuery.ajax({
|
@@ -403,11 +403,11 @@ class RTMediaMigration {
|
|
403 |
"done": db_done
|
404 |
},
|
405 |
success: function(sdata) {
|
406 |
-
|
407 |
-
try{
|
408 |
data = JSON.parse(sdata);
|
409 |
-
}catch(e){
|
410 |
-
jQuery("#submit").attr('disabled',"");
|
411 |
}
|
412 |
if (data.status) {
|
413 |
done = parseInt(data.done);
|
@@ -427,53 +427,53 @@ class RTMediaMigration {
|
|
427 |
jQuery("#rtMediaSyncing").hide();
|
428 |
}
|
429 |
},
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
});
|
435 |
} else {
|
436 |
alert("Migration completed.");
|
437 |
jQuery("#rtMediaSyncing").hide();
|
438 |
}
|
439 |
}
|
440 |
-
|
441 |
-
|
442 |
jQuery(document).on('click', '#submit', function(e) {
|
443 |
e.preventDefault();
|
444 |
-
|
445 |
db_start_migration(db_done, db_total);
|
446 |
jQuery(this).attr('disabled', 'disabled');
|
447 |
});
|
448 |
</script>
|
449 |
<hr />
|
450 |
-
<?php if(!(isset($rtmedia_error) && $rtmedia_error===true)){ ?>
|
451 |
-
|
452 |
<?php } ?>
|
453 |
|
454 |
</div>
|
455 |
<?php
|
456 |
}
|
457 |
|
458 |
-
function migrate_to_new_db($lastid = 0, $limit = 1) {
|
459 |
|
460 |
-
if (!isset($_SESSION["migration_media"]))
|
461 |
-
$this->get_total_count();
|
462 |
|
463 |
-
$state = intval(get_site_option("rtmedia-migration"));
|
464 |
-
if ($state < 5) {
|
465 |
-
if ($this->manage_album()) {
|
466 |
-
$this->migrate_encoding_options();
|
467 |
-
$this->return_migration();
|
468 |
}
|
469 |
}
|
470 |
|
471 |
-
if (intval($_SESSION["migration_media"]) >= $this->get_done_count(true)) {
|
472 |
|
473 |
-
if (
|
474 |
-
$lastid = $this->get_last_imported();
|
475 |
-
if (
|
476 |
-
$this->return_migration();
|
477 |
}
|
478 |
}
|
479 |
global $wpdb;
|
@@ -498,35 +498,35 @@ class RTMediaMigration {
|
|
498 |
left join
|
499 |
{$wpdb->posts} p ON (a.post_id = p.ID)
|
500 |
where
|
501 |
-
a.post_id >= %d and (NOT p.ID is NULL)
|
502 |
and a.meta_key = 'bp-media-key'
|
503 |
order by a.post_id
|
504 |
limit %d";
|
505 |
|
506 |
|
507 |
-
$results = $wpdb->get_results($wpdb->prepare($sql, $lastid, $limit));
|
508 |
|
509 |
-
if (function_exists("bp_core_get_table_prefix"))
|
510 |
-
$bp_prefix = bp_core_get_table_prefix();
|
511 |
else
|
512 |
$bp_prefix = "";
|
513 |
-
if ($results) {
|
514 |
|
515 |
-
foreach ($results as $result) {
|
516 |
-
$this->migrate_single_media($result);
|
517 |
}
|
518 |
}
|
519 |
} else {
|
520 |
-
|
521 |
//Call flush_rules() as a method of the $wp_rewrite object
|
522 |
-
$wp_rewrite->flush_rules(true);
|
523 |
// echo json_encode(array("status" => false, "done" => $done, "total" => $this->get_total_count()));
|
524 |
// die();
|
525 |
}
|
526 |
-
$this->return_migration();
|
527 |
}
|
528 |
|
529 |
-
function migrate_encoding_options() {
|
530 |
$encoding_mnigration_array = array(
|
531 |
'bp-media-encoding-api-key' => 'rtmedia-encoding-api-key',
|
532 |
'bp-media-encoding-usage-limit-mail' => 'rtmedia-encoding-usage-limit-mail',
|
@@ -536,25 +536,25 @@ class RTMediaMigration {
|
|
536 |
'bp_media_ffmpeg_options' => 'rtmedia-ffmpeg-options',
|
537 |
'bp_media_kaltura_options' => 'rtmedia-kaltura-options',
|
538 |
);
|
539 |
-
foreach ($encoding_mnigration_array as $key => $ma) {
|
540 |
-
if (($value = get_site_option($key)) !== false) {
|
541 |
-
update_site_option($ma, $value);
|
542 |
}
|
543 |
}
|
544 |
}
|
545 |
|
546 |
-
function migrate_single_media($result, $album = false) {
|
547 |
-
$blog_id = get_current_blog_id();
|
548 |
-
$old= $result;
|
549 |
-
if (function_exists("bp_core_get_table_prefix"))
|
550 |
-
$bp_prefix = bp_core_get_table_prefix();
|
551 |
else
|
552 |
$bp_prefix = "";
|
553 |
global $wpdb;
|
554 |
-
|
555 |
-
if ($album !== false && ! (is_object($result))) {
|
556 |
-
$id = $wpdb->get_var($wpdb->prepare("select ID from $this->bmp_table where media_id = %d", $result));
|
557 |
-
if ($id == NULL) {
|
558 |
$sql = "select
|
559 |
a.post_id as 'post_id',
|
560 |
a.meta_value as 'privacy',
|
@@ -578,38 +578,38 @@ class RTMediaMigration {
|
|
578 |
where
|
579 |
a.post_id = %d and (NOT p.ID IS NULL)
|
580 |
and a.meta_key = 'bp_media_privacy'";
|
581 |
-
$result = $wpdb->get_row($wpdb->prepare($sql, $result));
|
582 |
} else {
|
583 |
return $id;
|
584 |
}
|
585 |
}
|
586 |
-
if(!isset($result) || !isset($result->post_id)){
|
587 |
return $old;
|
588 |
}
|
589 |
$media_id = $result->post_id;
|
590 |
|
591 |
-
if (intval($result->context_id) > 0) {
|
592 |
$media_context = "profile";
|
593 |
-
$prefix = "users/" . abs(intval($result->context_id));
|
594 |
} else {
|
595 |
$media_context = "group";
|
596 |
-
$prefix = bp_get_groups_root_slug() . abs(intval($result->context_id));
|
597 |
}
|
598 |
|
599 |
|
600 |
-
$old_type ="";
|
601 |
-
if ($result->post_type != "attachment") {
|
602 |
$media_type = "album";
|
603 |
} else {
|
604 |
-
$mime_type = strtolower($result->post_mime_type);
|
605 |
$old_type = "";
|
606 |
-
if (strpos($mime_type, "image") === 0) {
|
607 |
$media_type = "photo";
|
608 |
$old_type = "photos";
|
609 |
-
} else if (strpos($mime_type, "audio") === 0) {
|
610 |
$media_type = "music";
|
611 |
$old_type = "music";
|
612 |
-
} else if (strpos($mime_type, "video") === 0) {
|
613 |
$media_type = "video";
|
614 |
$old_type = "videos";
|
615 |
} else {
|
@@ -617,14 +617,14 @@ class RTMediaMigration {
|
|
617 |
}
|
618 |
}
|
619 |
|
620 |
-
$activity_data = $wpdb->get_row($wpdb->prepare("select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id));
|
621 |
-
if ($media_type != 'album') {
|
622 |
-
$this->importmedia($media_id, $prefix);
|
623 |
}
|
624 |
|
625 |
-
if ($this->table_exists($bp_prefix . "bp_activity") && class_exists("BP_Activity_Activity")) {
|
626 |
$bp_activity = new BP_Activity_Activity();
|
627 |
-
|
628 |
*
|
629 |
FROM
|
630 |
{$bp_prefix}bp_activity
|
@@ -637,49 +637,48 @@ class RTMediaMigration {
|
|
637 |
$wpdb->posts p ON (a.post_id = p.ID)
|
638 |
where
|
639 |
(NOT p.ID IS NULL) and p.ID = %d
|
640 |
-
and a.meta_key = 'bp_media_child_activity')", $media_id);
|
641 |
-
$all_activity = $wpdb->get_results($activity_sql);
|
642 |
-
remove_all_actions("wp_insert_comment");
|
643 |
-
foreach ($all_activity as $activity) {
|
644 |
-
$comments = $bp_activity->get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
|
645 |
-
$exclude = get_post_meta($media_id, "rtmedia_imported_activity", true);
|
646 |
-
if (!is_array($exclude)) {
|
647 |
-
$exclude = array();
|
648 |
}
|
649 |
-
if ($comments)
|
650 |
-
$this->insert_comment($media_id, $comments, $exclude);
|
651 |
}
|
652 |
}
|
653 |
-
if (intval($result->parent) !== 0 ) {
|
654 |
-
$album_id = $this->migrate_single_media($result->parent, true);
|
655 |
} else {
|
656 |
$album_id = 0;
|
657 |
}
|
658 |
-
if (function_exists("bp_activity_get_meta"))
|
659 |
-
$likes = bp_activity_get_meta($result->activity_id, 'favorite_count');
|
660 |
else
|
661 |
$likes = 0;
|
662 |
|
663 |
-
$wpdb->insert(
|
664 |
$this->bmp_table, array(
|
665 |
'blog_id' => $blog_id,
|
666 |
'media_id' => $media_id,
|
667 |
'media_type' => $media_type,
|
668 |
"context" => $media_context,
|
669 |
-
"context_id" => abs(intval($result->context_id)),
|
670 |
"activity_id" => $result->activity_id,
|
671 |
-
"privacy" => intval($result->privacy) * 10,
|
672 |
"media_author" => $result->media_author,
|
673 |
"media_title" => $result->media_title,
|
674 |
"album_id" => $album_id,
|
675 |
"likes" => $likes
|
676 |
-
), array('%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d')
|
677 |
);
|
678 |
-
|
679 |
-
|
680 |
-
// Photo tag meta migration
|
681 |
//$photo_tag_meta = get_post_meta($media_id, "bp-media-user-tags", true);
|
682 |
-
|
683 |
// if($photo_tag_meta && !empty($photo_tag_meta)){
|
684 |
// $wpdb->insert(
|
685 |
// $wpdb->prefix . "rt_rtm_media_meta", array(
|
@@ -687,113 +686,110 @@ class RTMediaMigration {
|
|
687 |
// 'meta_key' => "user-tags",
|
688 |
// "meta_value" => maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
|
689 |
// }
|
690 |
-
if ($media_type != 'album' && function_exists('bp_core_get_user_domain') && $activity_data) {
|
691 |
-
if (function_exists("bp_core_get_table_prefix"))
|
692 |
-
$bp_prefix = bp_core_get_table_prefix();
|
693 |
else
|
694 |
$bp_prefix = "";
|
695 |
|
696 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
697 |
-
$parent_link = get_rtmedia_user_link($activity_data->user_id);
|
698 |
-
$activity_data->primary_link = $parent_link . "
|
699 |
-
$this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
|
700 |
-
$activity_data->action = str_replace($activity_data->old_primary_link, $activity_data->primary_link, $activity_data->action);
|
701 |
-
$activity_data->content = str_replace($activity_data->old_primary_link, $activity_data->primary_link, $activity_data->content);
|
702 |
global $last_baseurl, $last_newurl;
|
703 |
|
704 |
$replace_img = $last_newurl; //$last_baseurl . "rtMedia/$prefix/";
|
705 |
-
if (strpos($activity_data->content, $replace_img) === false)
|
706 |
-
$activity_data->content = str_replace($last_baseurl, $replace_img, $activity_data->content);
|
707 |
global $wpdb;
|
708 |
-
$wpdb->update($bp_prefix . "bp_activity", array("primary_link" => $activity_data->primary_link,
|
709 |
"action" => $activity_data->action,
|
710 |
-
"content" => $activity_data->content), array("id" => $activity_data->id));
|
711 |
-
}else{
|
712 |
-
if($media_context == "group"){
|
713 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
714 |
-
$parent_link = get_rtmedia_group_link( abs(intval($result->context_id)) );
|
715 |
-
$parent_link = trailingslashit($parent_link);
|
716 |
-
$activity_data->primary_link = trailingslashit( $parent_link . '
|
717 |
-
$this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
|
718 |
-
}else{
|
719 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
720 |
-
$parent_link = get_rtmedia_user_link($activity_data->user_id);
|
721 |
-
$parent_link = trailingslashit($parent_link);
|
722 |
-
$activity_data->primary_link = trailingslashit( $parent_link . '
|
723 |
-
$this->search_and_replace($activity_data->old_primary_link, $activity_data->primary_link);
|
724 |
}
|
725 |
}
|
726 |
-
if($old_type !=""){
|
727 |
-
if($media_context == "group"){
|
728 |
-
$parent_link = get_rtmedia_group_link( abs(intval($result->context_id)) );
|
729 |
-
$parent_link = trailingslashit($parent_link);
|
730 |
-
$this->search_and_replace(trailingslashit( $parent_link . $old_type . '/' . $media_id ), trailingslashit( $parent_link . '
|
731 |
-
|
732 |
-
|
733 |
-
$parent_link =
|
734 |
-
$parent_link
|
735 |
-
$this->search_and_replace(trailingslashit( $parent_link . $old_type . '/' . $media_id ), trailingslashit( $parent_link . 'media/' . $last_id ));
|
736 |
-
|
737 |
}
|
738 |
-
|
739 |
}
|
740 |
return $last_id;
|
741 |
}
|
742 |
|
743 |
-
function importmedia($id, $prefix) {
|
|
|
744 |
|
745 |
-
|
746 |
$delete = false;
|
747 |
-
$attached_file = get_attached_file($id);
|
748 |
-
$attached_file_option = get_post_meta($id, '_wp_attached_file', true);
|
749 |
-
$basename = wp_basename($attached_file);
|
750 |
-
$file_folder_path = trailingslashit(str_replace($basename, '', $attached_file));
|
751 |
|
752 |
|
753 |
-
$siteurl = get_option('siteurl');
|
754 |
-
$upload_path = trim(get_option('upload_path'));
|
755 |
|
756 |
-
if (empty($upload_path) || 'wp-content/uploads' == $upload_path) {
|
757 |
$dir = WP_CONTENT_DIR . '/uploads';
|
758 |
-
} elseif (0 !== strpos($upload_path, ABSPATH)) {
|
759 |
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
760 |
-
$dir = path_join(ABSPATH, $upload_path);
|
761 |
} else {
|
762 |
$dir = $upload_path;
|
763 |
}
|
764 |
|
765 |
-
if (
|
766 |
-
if (empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ))
|
767 |
$url = WP_CONTENT_URL . '/uploads';
|
768 |
else
|
769 |
-
$url = trailingslashit($siteurl) . $upload_path;
|
770 |
}
|
771 |
|
772 |
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
|
773 |
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
|
774 |
-
if (defined('UPLOADS') && !( is_multisite() && get_site_option('ms_files_rewriting') )) {
|
775 |
$dir = ABSPATH . UPLOADS;
|
776 |
-
$url = trailingslashit($siteurl) . UPLOADS;
|
777 |
}
|
778 |
|
779 |
// If multisite (and if not the main site in a post-MU network)
|
780 |
-
if (is_multisite() && !( is_main_site() && defined('MULTISITE') )) {
|
781 |
|
782 |
-
if (!get_site_option('ms_files_rewriting')) {
|
783 |
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
|
784 |
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
|
785 |
// prevents a four-digit ID from conflicting with a year-based directory for the main site.
|
786 |
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
|
787 |
// directory, as they never had wp-content/uploads for the main site.)
|
788 |
|
789 |
-
if (defined('MULTISITE'))
|
790 |
-
$ms_dir = '/sites/' . get_current_blog_id();
|
791 |
else
|
792 |
-
$ms_dir = '/' . get_current_blog_id();
|
793 |
|
794 |
$dir .= $ms_dir;
|
795 |
$url .= $ms_dir;
|
796 |
-
} elseif (defined('UPLOADS') && !ms_is_switched()) {
|
797 |
// Handle the old-form ms-files.php rewriting if the network still has that enabled.
|
798 |
// When ms-files rewriting is enabled, then we only listen to UPLOADS when:
|
799 |
// 1) we are not on the main site in a post-MU network,
|
@@ -806,104 +802,102 @@ class RTMediaMigration {
|
|
806 |
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
|
807 |
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
|
808 |
|
809 |
-
if (defined('BLOGUPLOADDIR'))
|
810 |
-
$dir = untrailingslashit(BLOGUPLOADDIR);
|
811 |
else
|
812 |
$dir = ABSPATH . UPLOADS;
|
813 |
-
$url = trailingslashit($siteurl) . 'files';
|
814 |
}
|
815 |
}
|
816 |
|
817 |
-
$basedir = trailingslashit($dir);
|
818 |
-
$baseurl = trailingslashit($url);
|
819 |
|
820 |
-
$new_file_folder_path = trailingslashit(str_replace($basedir, $basedir . "rtMedia/$prefix/", $file_folder_path));
|
821 |
|
822 |
-
$year_month = untrailingslashit(str_replace($basedir, '', $file_folder_path));
|
823 |
|
824 |
|
825 |
-
$metadata = wp_get_attachment_metadata($id);
|
826 |
-
$backup_metadata = get_post_meta($id, '_wp_attachment_backup_sizes', true);
|
827 |
-
$instagram_thumbs = get_post_meta($id, '_instagram_thumbs', true);
|
828 |
-
$instagram_full_images = get_post_meta($id, '_instagram_full_images', true);
|
829 |
-
$instagram_metadata = get_post_meta($id, '_instagram_metadata', true);
|
830 |
-
$encoding_job_id = get_post_meta($id, 'bp-media-encoding-job-id', true);
|
831 |
-
$ffmpeg_thumbnail_ids = get_post_meta($id, 'bp_media_thumbnail_ids', true);
|
832 |
-
$ffmpeg_thumbnail = get_post_meta($id, 'bp_media_thumbnail', true);
|
833 |
-
$ffmpeg_remote_id = get_post_meta($id, 'bp_media_ffmpeg_remote_id', true);
|
834 |
-
$kaltura_remote_id = get_post_meta($id, 'bp_media_kaltura_remote_id', true);
|
835 |
|
836 |
-
if (wp_mkdir_p($basedir . "rtMedia/$prefix/" . $year_month)) {
|
837 |
-
if (copy($attached_file, str_replace($basedir, $basedir . "rtMedia/$prefix/", $attached_file))) {
|
838 |
$delete = true;
|
839 |
|
840 |
-
if (isset($metadata['sizes'])) {
|
841 |
-
foreach ($metadata['sizes'] as $size) {
|
842 |
-
if (!copy($file_folder_path . $size['file'], $new_file_folder_path . $size['file'])) {
|
843 |
$delete = false;
|
844 |
-
|
845 |
} else {
|
846 |
-
$delete_sizes[] = $file_folder_path . $size['file'];
|
847 |
-
$this->search_and_replace(trailingslashit($baseurl . $year_month). $size['file'],trailingslashit($baseurl .
|
848 |
}
|
849 |
-
|
850 |
}
|
851 |
}
|
852 |
-
if ($backup_metadata) {
|
853 |
-
foreach ($backup_metadata as $backup_images) {
|
854 |
-
if (!copy($file_folder_path . $backup_images['file'], $new_file_folder_path . $backup_images['file'])) {
|
855 |
$delete = false;
|
856 |
} else {
|
857 |
-
$delete_sizes[] = $file_folder_path . $backup_images['file'];
|
858 |
-
$this->search_and_replace(trailingslashit($baseurl . $year_month). $backup_images['file'],trailingslashit($baseurl .
|
859 |
}
|
860 |
}
|
861 |
}
|
862 |
|
863 |
-
if ($instagram_thumbs) {
|
864 |
-
foreach ($instagram_thumbs as $key => $insta_thumb) {
|
865 |
-
try{
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
} catch (Exceptio $e){
|
874 |
$delete = false;
|
875 |
}
|
876 |
}
|
877 |
}
|
878 |
|
879 |
-
if ($instagram_full_images) {
|
880 |
-
foreach ($instagram_full_images as $key => $insta_full_image) {
|
881 |
-
if (!copy($insta_full_image, str_replace($basedir, $basedir . "rtMedia/$prefix/", $insta_full_image))) {
|
882 |
$delete = false;
|
883 |
} else {
|
884 |
-
$delete_sizes[] = $insta_full_image;
|
885 |
-
$instagram_full_images_new[$key] = str_replace($basedir, $basedir . "rtMedia/$prefix", $insta_full_image);
|
886 |
-
$this->search_and_replace(trailingslashit($baseurl . $year_month)
|
887 |
}
|
888 |
}
|
889 |
}
|
890 |
|
891 |
-
if ($instagram_metadata) {
|
892 |
$instagram_metadata_new = $instagram_metadata;
|
893 |
-
foreach ($instagram_metadata as $wp_size => $insta_metadata) {
|
894 |
-
if (isset($insta_metadata['file'])) {
|
895 |
-
if (!copy($basedir . $insta_metadata['file'], $basedir . "rtMedia/$prefix/" . $insta_metadata['file'])) {
|
896 |
$delete = false;
|
897 |
} else {
|
898 |
-
$delete_sizes[] = $basedir . $insta_metadata['file'];
|
899 |
-
$instagram_metadata_new[$wp_size]['file'] = "rtMedia/$prefix/" . $insta_metadata['file'];
|
900 |
-
if (isset($insta_metadata['sizes'])) {
|
901 |
-
foreach ($insta_metadata['sizes'] as $key => $insta_size) {
|
902 |
-
if (!copy($file_folder_path . $insta_size['file'], $new_file_folder_path . $insta_size['file'])) {
|
903 |
-
$delete = false;
|
904 |
} else {
|
905 |
-
$delete_sizes[] = $file_folder_path . $insta_size['file'];
|
906 |
-
$this->search_and_replace(trailingslashit($baseurl . $year_month)
|
907 |
}
|
908 |
}
|
909 |
}
|
@@ -912,109 +906,110 @@ class RTMediaMigration {
|
|
912 |
}
|
913 |
}
|
914 |
|
915 |
-
if ($delete) {
|
916 |
-
if (file_exists($attached_file))
|
917 |
-
unlink($attached_file);
|
918 |
|
919 |
-
if (isset($delete_sizes)) {
|
920 |
-
foreach ($delete_sizes as $delete_size) {
|
921 |
-
if (file_exists($delete_size))
|
922 |
-
unlink($delete_size);
|
923 |
}
|
924 |
}
|
925 |
-
update_post_meta($id, '_wp_attached_file', "rtMedia/$prefix/" . $attached_file_option);
|
926 |
-
if (isset($metadata['file'])) {
|
927 |
-
$metadata['file'] = "rtMedia/$prefix/" . $metadata['file'];
|
928 |
-
wp_update_attachment_metadata($id, $metadata);
|
929 |
}
|
930 |
-
if ($instagram_thumbs) {
|
931 |
-
update_rtmedia_meta($id, '_instagram_thumbs', $instagram_thumbs_new);
|
932 |
}
|
933 |
-
if ($instagram_full_images) {
|
934 |
-
update_rtmedia_meta($id, '_instagram_full_images', $instagram_full_images_new);
|
935 |
}
|
936 |
-
if ($instagram_metadata) {
|
937 |
-
update_rtmedia_meta($id, '_instagram_metadata', $instagram_metadata_new);
|
938 |
}
|
939 |
-
if ($encoding_job_id) {
|
940 |
-
update_rtmedia_meta($id, 'rtmedia-encoding-job-id', $encoding_job_id);
|
941 |
}
|
942 |
-
if ($ffmpeg_thumbnail_ids) {
|
943 |
-
update_rtmedia_meta($id, 'rtmedia-thumbnail-ids', $ffmpeg_thumbnail_ids);
|
944 |
}
|
945 |
-
if ($ffmpeg_thumbnail) {
|
946 |
$model = new RTMediaModel();
|
947 |
-
$model->update(array('cover_art' => $ffmpeg_thumbnail), array('id' => $id));
|
948 |
}
|
949 |
-
if ($ffmpeg_remote_id) {
|
950 |
-
update_rtmedia_meta($id, 'rtmedia-ffmpeg-remote-id', $ffmpeg_remote_id);
|
951 |
}
|
952 |
-
if ($kaltura_remote_id) {
|
953 |
-
update_rtmedia_meta($id, 'rtmedia-kaltura-remote-id', $kaltura_remote_id);
|
954 |
}
|
955 |
|
956 |
-
$attachment = array();
|
957 |
-
$attachment['ID'] = $id;
|
958 |
-
$old_guid = get_post_field('guid', $id);
|
959 |
-
$attachment['guid'] = str_replace($baseurl, $baseurl . "rtMedia/$prefix/", $old_guid);
|
960 |
/**
|
961 |
* For Activity
|
962 |
*/
|
963 |
global $last_baseurl, $last_newurl;
|
964 |
$last_baseurl = $baseurl;
|
965 |
$last_newurl = $baseurl . "rtMedia/$prefix/";
|
966 |
-
$this->search_and_replace($old_guid, $attachment['guid']);
|
967 |
-
wp_update_post($attachment);
|
968 |
}
|
969 |
}
|
970 |
}
|
971 |
}
|
972 |
-
|
973 |
-
function search_and_replace($old
|
974 |
global $wpdb;
|
975 |
-
if (function_exists("bp_core_get_table_prefix"))
|
976 |
-
$bp_prefix = bp_core_get_table_prefix();
|
977 |
else
|
978 |
-
$bp_prefix = "";
|
979 |
-
$sql = $wpdb->prepare("update {$bp_prefix}bp_activity set action=replace(action,%s,%s) ,content=replace(content,%s,%s), primary_link=replace(primary_link,%s,%s) where id > 0;"
|
980 |
-
$wpdb->get_row($sql);
|
981 |
}
|
982 |
-
|
|
|
983 |
|
984 |
$minuteInSeconds = 60;
|
985 |
$hourInSeconds = $minuteInSeconds * 60;
|
986 |
$dayInSeconds = $hourInSeconds * 24;
|
987 |
|
988 |
-
$days = floor($secondsLeft / $dayInSeconds);
|
989 |
$secondsLeft = $secondsLeft % $dayInSeconds;
|
990 |
|
991 |
-
$hours = floor($secondsLeft / $hourInSeconds);
|
992 |
$secondsLeft = $secondsLeft % $hourInSeconds;
|
993 |
|
994 |
-
$minutes = floor($secondsLeft / $minuteInSeconds);
|
995 |
|
996 |
$seconds = $secondsLeft % $minuteInSeconds;
|
997 |
|
998 |
-
$timeComponents = array();
|
999 |
|
1000 |
-
if ($days > 0) {
|
1001 |
-
$timeComponents[] = $days . " day" . ($days > 1 ? "s" : "");
|
1002 |
}
|
1003 |
|
1004 |
-
if ($hours > 0) {
|
1005 |
-
$timeComponents[] = $hours . " hour" . ($hours > 1 ? "s" : "");
|
1006 |
}
|
1007 |
|
1008 |
-
if ($minutes > 0) {
|
1009 |
-
$timeComponents[] = $minutes . " minute" . ($minutes > 1 ? "s" : "");
|
1010 |
}
|
1011 |
|
1012 |
-
if ($seconds > 0) {
|
1013 |
-
$timeComponents[] = $seconds . " second" . ($seconds > 1 ? "s" : "");
|
1014 |
}
|
1015 |
-
if (count($timeComponents) > 0) {
|
1016 |
-
$formattedTimeRemaining = implode(", ", $timeComponents);
|
1017 |
-
$formattedTimeRemaining = trim($formattedTimeRemaining);
|
1018 |
} else {
|
1019 |
$formattedTimeRemaining = "No time remaining.";
|
1020 |
}
|
@@ -1022,10 +1017,10 @@ class RTMediaMigration {
|
|
1022 |
return $formattedTimeRemaining;
|
1023 |
}
|
1024 |
|
1025 |
-
function insert_comment($media_id, $data, $exclude, $parent_commnet_id = 0) {
|
1026 |
-
foreach ($data as $cmnt) {
|
1027 |
$comment_id = 0;
|
1028 |
-
if (!key_exists(strval($cmnt->id), $exclude)) {
|
1029 |
$commentdata = array(
|
1030 |
"comment_date" => $cmnt->date_recorded,
|
1031 |
"comment_parent" => $parent_commnet_id,
|
@@ -1035,17 +1030,17 @@ class RTMediaMigration {
|
|
1035 |
'comment_post_ID' => $media_id,
|
1036 |
'comment_author' => $cmnt->display_name,
|
1037 |
'comment_author_url' => '',
|
1038 |
-
'comment_author_IP' => '');
|
1039 |
-
$comment_id = wp_insert_comment($commentdata);
|
1040 |
-
$exclude[strval($cmnt->id)] = $comment_id;
|
1041 |
} else {
|
1042 |
-
$comment_id = $exclude[strval($cmnt->id)];
|
1043 |
}
|
1044 |
|
1045 |
-
update_post_meta($media_id, "rtmedia_imported_activity", $exclude);
|
1046 |
|
1047 |
-
if (is_array($cmnt->children)) {
|
1048 |
-
$this->insert_comment($media_id, $cmnt->children, $exclude, $comment_id);
|
1049 |
}
|
1050 |
}
|
1051 |
}
|
9 |
|
10 |
public $bmp_table = "";
|
11 |
|
12 |
+
function __construct () {
|
13 |
global $wpdb;
|
14 |
$this->bmp_table = $wpdb->prefix . "rt_rtm_media";
|
15 |
+
|
16 |
+
add_action ( 'admin_menu', array( $this, 'menu' ) );
|
17 |
+
add_action ( 'wp_ajax_bp_media_rt_db_migration', array( $this, "migrate_to_new_db" ) );
|
18 |
+
|
19 |
+
if ( isset ( $_REQUEST[ "page" ] ) && $_REQUEST[ "page" ] == "rtmedia-migration" && isset ( $_REQUEST[ "hide" ] ) && $_REQUEST[ "hide" ] == "true" ) {
|
20 |
+
$this->hide_migration_notice ();
|
21 |
+
wp_safe_redirect ( $_SERVER[ "HTTP_REFERER" ] );
|
22 |
}
|
23 |
+
if ( get_site_option ( "rt_migration_hide_notice" ) !== false )
|
24 |
return true;
|
25 |
+
|
26 |
+
if ( isset ( $_REQUEST[ "force" ] ) && $_REQUEST[ "force" ] === "true" )
|
27 |
$pending = false;
|
28 |
else
|
29 |
+
$pending = get_site_option ( "rtMigration-pending-count" );
|
30 |
+
$total = $this->get_total_count ();
|
31 |
+
$done = $this->get_done_count ();
|
32 |
+
if ( $pending === false ) {
|
33 |
+
$total = $this->get_total_count ();
|
34 |
+
$done = $this->get_done_count ();
|
35 |
$pending = $total - $done;
|
36 |
+
if ( $pending < 0 )
|
37 |
$pending = 0;
|
38 |
+
update_site_option ( "rtMigration-pending-count", $pending );
|
39 |
}
|
40 |
+
if ( $pending > 0 ) {
|
41 |
+
if ( ! (isset ( $_REQUEST[ "page" ] ) && $_REQUEST[ "page" ] == "rtmedia-migration") )
|
42 |
+
add_action ( 'admin_notices', array( &$this, 'add_migration_notice' ) );
|
43 |
}
|
|
|
44 |
}
|
45 |
+
|
46 |
+
function hide_migration_notice () {
|
47 |
+
update_site_option ( "rt_migration_hide_notice", true );
|
48 |
}
|
49 |
+
|
50 |
+
function migrate_image_size_fix () {
|
51 |
+
if ( get_site_option ( "rt_image_size_migration_fix", "" ) == "" ) {
|
52 |
global $wpdb;
|
53 |
+
$sql = $wpdb->prepare ( "update $wpdb->postmeta set meta_value=replace(meta_value ,%s,%s) where meta_key = '_wp_attachment_metadata';", "bp_media", "rt_media" );
|
54 |
+
$wpdb->get_row ( $sql );
|
55 |
+
update_option ( "rt_image_size_migration_fix", "fix" );
|
56 |
}
|
57 |
}
|
58 |
|
59 |
+
function add_migration_notice () {
|
60 |
+
if ( current_user_can ( 'manage_options' ) )
|
61 |
+
$this->create_notice ( "<p><strong>rtMedia</strong> : Please Migrate your Database <a href='" . admin_url ( "admin.php?page=rtmedia-migration&force=true" ) . "'>Click Here</a>. <a href='" . admin_url ( "admin.php?page=rtmedia-migration&hide=true" ) . "' style='float:right'>" . __ ( "Hide" ) . "</a> </p>" );
|
62 |
}
|
63 |
|
64 |
+
function create_notice ( $message, $type = "error" ) {
|
65 |
echo '<div class="' . $type . '">' . $message . '</div>';
|
66 |
}
|
67 |
|
68 |
+
static function table_exists ( $table ) {
|
69 |
global $wpdb;
|
70 |
|
71 |
+
if ( $wpdb->query ( "SHOW TABLES LIKE '" . $table . "'" ) == 1 ) {
|
72 |
return true;
|
73 |
}
|
74 |
|
75 |
return false;
|
76 |
}
|
77 |
|
78 |
+
function menu () {
|
79 |
+
add_submenu_page ( 'rtmedia-settings', __ ( 'Migration', 'buddypress-media' ), __ ( 'Migration', 'buddypress-media' ), 'manage_options', 'rtmedia-migration', array( $this, 'test' ) );
|
80 |
}
|
81 |
|
82 |
+
function get_total_count () {
|
83 |
global $wpdb;
|
84 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
85 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
86 |
else
|
87 |
$bp_prefix = "";
|
88 |
$sql_album_usercount = "select count(*) FROM $wpdb->usermeta where meta_key ='bp-media-default-album' ";
|
89 |
|
90 |
+
$_SESSION[ "migration_user_album" ] = $wpdb->get_var ( $sql_album_usercount );
|
91 |
+
$count = intval ( $_SESSION[ "migration_user_album" ] );
|
92 |
|
93 |
+
if ( $this->table_exists ( $bp_prefix . "bp_groups_groupmeta" ) ) {
|
94 |
$sql_album_groupcount = "select count(*) FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album'";
|
95 |
+
$_SESSION[ "migration_group_album" ] = $wpdb->get_var ( $sql_album_groupcount );
|
96 |
+
$count += intval ( $_SESSION[ "migration_group_album" ] );
|
97 |
}
|
98 |
+
if ( $this->table_exists ( $bp_prefix . "bp_activity" ) ) {
|
99 |
//$sql_bpm_comment_count = "select count(*) from {$bp_prefix}bp_activity where component='activity' and type='activity_comment' and is_spam <> 1 and ;";
|
100 |
+
$sql_bpm_comment_count = "SELECT
|
101 |
count(id)
|
102 |
FROM
|
103 |
{$bp_prefix}bp_activity
|
104 |
where
|
105 |
type = 'activity_comment'
|
106 |
+
and is_spam <>1
|
107 |
and item_id in (select distinct
|
108 |
a.meta_value
|
109 |
from
|
117 |
|
118 |
//echo $sql_bpm_comment_count;
|
119 |
|
120 |
+
$_SESSION[ "migration_activity" ] = $wpdb->get_var ( $sql_bpm_comment_count );
|
121 |
+
$count +=intval ( $_SESSION[ "migration_activity" ] );
|
122 |
}
|
123 |
|
124 |
$sql = "select count(*)
|
137 |
and a.meta_key = 'bp-media-key'";
|
138 |
|
139 |
|
140 |
+
$_SESSION[ "migration_media" ] = $wpdb->get_var ( $sql );
|
141 |
+
$count += intval ( $_SESSION[ "migration_media" ] );
|
142 |
+
// var_dump($_SESSION);
|
143 |
return $count;
|
144 |
}
|
145 |
|
146 |
+
function get_last_imported () {
|
147 |
+
$album = get_site_option ( "rtmedia-global-albums" );
|
148 |
+
$album_id = $album[ 0 ];
|
149 |
|
150 |
global $wpdb;
|
151 |
$sql = "select a.post_ID
|
155 |
where
|
156 |
a.meta_key = 'bp-media-key' and (NOT p.ID IS NULL) and a.post_id not in (select media_id
|
157 |
from {$this->bmp_table} where blog_id = %d and media_id <> %d ) order by a.post_ID";
|
158 |
+
$sql = $wpdb->prepare ( $sql, get_current_blog_id (), $album_id );
|
159 |
+
$row = $wpdb->get_row ( $sql );
|
160 |
+
if ( $row ) {
|
161 |
return $row->post_ID;
|
162 |
} else {
|
163 |
return false;
|
164 |
}
|
165 |
}
|
166 |
|
167 |
+
function get_done_count ( $flag = false ) {
|
168 |
global $wpdb;
|
169 |
$sql = "select count(*)
|
170 |
from {$this->bmp_table} where blog_id = %d and media_id in (select a.post_id
|
182 |
a.post_id > 0 and (NOT p.ID IS NULL)
|
183 |
and a.meta_key = 'bp-media-key')";
|
184 |
|
185 |
+
$media_count = $wpdb->get_var ( $wpdb->prepare ( $sql, get_current_blog_id () ) );
|
186 |
+
if ( $flag )
|
187 |
return $media_count - 1;
|
188 |
+
$state = intval ( get_site_option ( "rtmedia-migration", "0" ) );
|
189 |
+
if ( $state == 5 ) {
|
190 |
+
$album_count = intval ( $_SESSION[ "migration_user_album" ] );
|
191 |
+
$album_count += (isset ( $_SESSION[ "migration_group_album" ] )) ? intval ( $_SESSION[ "migration_group_album" ] ) : 0;
|
192 |
} else {
|
193 |
+
if ( $state > 0 ) {
|
194 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
195 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
196 |
else
|
197 |
$bp_prefix = "";
|
198 |
$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
199 |
+
if ( $this->table_exists ( $bp_prefix . "bp_groups_groupmeta" ) ) {
|
200 |
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
201 |
}
|
202 |
$pending_count .= ")";
|
203 |
+
$pending_count = $wpdb->get_var ( $pending_count );
|
204 |
+
|
205 |
+
$album_count = intval ( $_SESSION[ "migration_user_album" ] );
|
206 |
+
$album_count += (isset ( $_SESSION[ "migration_group_album" ] )) ? intval ( $_SESSION[ "migration_group_album" ] ) : 0;
|
207 |
+
$album_count = $album_count - intval ( $pending_count );
|
208 |
+
} else {
|
|
|
209 |
$album_count = 0;
|
210 |
}
|
211 |
}
|
212 |
+
if ( intval ( $_SESSION[ "migration_media" ] ) == intval ( $media_count ) ) {
|
213 |
+
$comment_sql = $_SESSION[ "migration_activity" ];
|
214 |
} else {
|
215 |
+
$comment_sql = $wpdb->get_var ( "select count(*)
|
216 |
+
from $wpdb->comments a
|
217 |
where a.comment_post_ID in (select b.media_id from $this->bmp_table b left join
|
218 |
+
{$wpdb->posts} p ON (b.media_id = p.ID) where (NOT p.ID IS NULL) ) and a.comment_agent=''" );
|
219 |
}
|
220 |
// echo $media_count . "--" . $album_count . "--" . $comment_sql;
|
221 |
return $media_count + $album_count + $comment_sql;
|
222 |
}
|
223 |
|
224 |
+
function return_migration () {
|
225 |
+
$total = $this->get_total_count ();
|
226 |
+
$done = $this->get_done_count ();
|
227 |
$pending = $total - $done;
|
228 |
+
if ( $pending < 0 ) {
|
229 |
$pending = 0;
|
230 |
$done = $total;
|
231 |
}
|
232 |
+
if ( $done > $total ) {
|
233 |
$done = $total;
|
234 |
}
|
235 |
+
if ( $done == $total ) {
|
236 |
+
global $wp_rewrite;
|
237 |
//Call flush_rules() as a method of the $wp_rewrite object
|
238 |
+
$wp_rewrite->flush_rules ( true );
|
|
|
239 |
}
|
240 |
+
update_site_option ( "rtMigration-pending-count", $pending );
|
241 |
+
$pending_time = $this->formatSeconds ( $pending );
|
242 |
|
243 |
+
echo json_encode ( array( "status" => true, "done" => $done, "total" => $total, "pending" => $pending_time ) );
|
244 |
+
die ();
|
245 |
}
|
246 |
|
247 |
+
function manage_album () {
|
248 |
+
$album = get_site_option ( "rtmedia-global-albums" );
|
249 |
+
$stage = intval ( get_site_option ( "rtmedia-migration", "0" ) );
|
250 |
+
|
251 |
+
$album_rt_id = $album[ 0 ];
|
252 |
|
253 |
$album_post_type = "rtmedia_album";
|
254 |
+
|
255 |
global $wpdb;
|
256 |
+
|
257 |
+
$album_id = $wpdb->get_var ( $wpdb->prepare ( "select media_id from $this->bmp_table where id = %d", $album_rt_id ) );
|
258 |
+
|
259 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
260 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
261 |
else
|
262 |
$bp_prefix = "";
|
263 |
|
264 |
+
if ( $stage < 1 ) {
|
265 |
+
global $wpdb;
|
266 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
267 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
268 |
+
else
|
269 |
+
$bp_prefix = "";
|
270 |
+
$sql = $wpdb->prepare ( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '<ul class="bp-media-list-media">', '<div class="rtmedia-activity-container"><ul class="rtmedia-list large-block-grid-3">' );
|
271 |
+
$wpdb->get_row ( $sql );
|
272 |
+
$sql = $wpdb->prepare ( "update {$bp_prefix}bp_activity set content=replace(content,%s,%s) where id > 0;", '</ul>', '</ul></div>' );
|
273 |
+
$wpdb->get_row ( $sql );
|
274 |
+
|
275 |
+
|
276 |
$sql_group = "update $wpdb->posts set post_parent='{$album_id}' where post_parent in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
|
277 |
+
if ( $this->table_exists ( $bp_prefix . "bp_groups_groupmeta" ) ) {
|
278 |
$sql_group .= " or post_parent in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
|
279 |
}
|
280 |
+
$wpdb->query ( $sql_group );
|
281 |
$stage = 1;
|
282 |
+
update_site_option ( "rtmedia-migration", $stage );
|
283 |
+
$this->return_migration ();
|
284 |
}
|
285 |
+
if ( $stage < 2 ) {
|
286 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') limit 10";
|
287 |
+
$results = $wpdb->get_results ( $sql_delete );
|
288 |
$delete_ids = "";
|
289 |
$sep = "";
|
290 |
+
foreach ( $results as $result ) {
|
291 |
+
$this->search_and_replace ( $result->guid, trailingslashit ( get_rtmedia_user_link ( $result->post_author ) ) . RTMEDIA_MEDIA_SLUG . "/" . $album_rt_id );
|
292 |
$delete_ids .= $sep . $result->ID;
|
293 |
$sep = ",";
|
294 |
}
|
295 |
+
if ( $delete_ids != "" )
|
296 |
+
$wpdb->query ( "delete from $wpdb->posts where ID in ({$delete_ids})" );
|
297 |
+
if ( count ( $results ) < 10 ) {
|
298 |
+
$stage = 2;
|
299 |
}
|
300 |
+
update_site_option ( "rtmedia-migration", $stage );
|
301 |
+
$this->return_migration ();
|
302 |
}
|
303 |
+
if ( $stage < 3 ) {
|
304 |
+
if ( $this->table_exists ( $bp_prefix . "bp_groups_groupmeta" ) ) {
|
305 |
$sql_delete = "select * from $wpdb->posts where post_type='bp_media_album' and ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album') limit 10";
|
306 |
+
$results = $wpdb->get_results ( $sql_delete );
|
307 |
$delete_ids = "";
|
308 |
$sep = "";
|
309 |
+
if ( $results ) {
|
310 |
+
foreach ( $results as $result ) {
|
311 |
+
$group_id = abs ( intval ( get_post_meta ( $result->ID, "bp-media-key", true ) ) );
|
312 |
+
$this->search_and_replace ( trailingslashit ( get_rtmedia_group_link ( $group_id ) ) . "albums/" . $result->ID, trailingslashit ( get_rtmedia_group_link ( $group_id ) ) . RTMEDIA_MEDIA_SLUG . "/" . $album_rt_id );
|
313 |
$delete_ids .= $sep . $result->ID;
|
314 |
$sep = ",";
|
315 |
}
|
316 |
+
if ( $delete_ids != "" )
|
317 |
+
$wpdb->query ( "delete from $wpdb->posts where ID in ({$delete_ids})" );
|
318 |
+
if ( count ( $results ) < 10 ) {
|
319 |
+
$stage = 3;
|
320 |
}
|
321 |
+
} else {
|
322 |
+
$stage = 3;
|
323 |
}
|
324 |
+
update_site_option ( "rtmedia-migration", $stage );
|
325 |
+
$this->return_migration ();
|
326 |
+
} else {
|
327 |
+
$stage = 3;
|
328 |
+
update_site_option ( "rtmedia-migration", $stage );
|
329 |
+
$this->return_migration ();
|
330 |
+
}
|
331 |
}
|
332 |
+
|
333 |
|
334 |
$sql = "update $wpdb->posts set post_type='{$album_post_type}' where post_type='bp_media_album'";
|
335 |
+
if ( $wpdb->query ( $sql ) !== false ) {
|
336 |
+
update_site_option ( "rtmedia-migration", "5" );
|
337 |
+
return true;
|
338 |
+
}
|
339 |
return false;
|
340 |
}
|
341 |
|
342 |
+
function test () {
|
343 |
+
if ( ! $this->table_exists ( $this->bmp_table ) ) {
|
344 |
+
$obj = new RTDBUpdate();
|
345 |
+
$obj->install_db_version = "0";
|
346 |
+
$obj->do_upgrade ( true );
|
347 |
}
|
348 |
global $rtmedia_error;
|
349 |
+
if ( isset ( $rtmedia_error ) && $rtmedia_error === true ) {
|
350 |
+
?>
|
351 |
<div class="error"><p> Please Resolve create database error before migration.</p></div>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
|
355 |
$prog = new rtProgress();
|
356 |
+
$total = $this->get_total_count ();
|
357 |
+
$done = $this->get_done_count ();
|
358 |
+
if ( $done >= $total ) {
|
359 |
$done = $total;
|
360 |
+
} else {
|
361 |
+
?>
|
362 |
<div class="error"><p> Please Backup your <strong>DATABASE</strong> and <strong>UPLOAD</strong> folder before Migration.</p></div>
|
363 |
<?php }
|
|
|
364 |
?>
|
365 |
+
|
366 |
<div class="wrap">
|
367 |
+
|
368 |
<h2>rtMedia Migration</h2>
|
369 |
+
<h3><?php _e ( "It will migrate following things" ); ?> </h3>
|
370 |
+
User Albums : <?php echo $_SESSION[ "migration_user_album" ]; ?><br />
|
371 |
+
<?php if ( isset ( $_SESSION[ "migration_group_album" ] ) ) { ?>
|
372 |
+
Groups Albums : <?php echo $_SESSION[ "migration_group_album" ]; ?><br />
|
373 |
<?php } ?>
|
374 |
+
Media : <?php echo $_SESSION[ "migration_media" ]; ?><br />
|
375 |
+
<?php if ( isset ( $_SESSION[ "migration_activity" ] ) ) { ?>
|
376 |
+
Comments : <?php echo $_SESSION[ "migration_activity" ]; ?><br />
|
377 |
<?php } ?>
|
378 |
<hr />
|
379 |
|
380 |
<?php
|
381 |
+
echo '<span class="pending">' . $this->formatSeconds ( $total - $done ) . '</span><br />';
|
382 |
echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
|
383 |
+
echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
|
384 |
|
385 |
+
$temp = $prog->progress ( $done, $total );
|
386 |
+
$prog->progress_ui ( $temp, true );
|
387 |
?>
|
388 |
<script type="text/javascript">
|
389 |
+
jQuery(document).ready(function(e) {
|
390 |
+
if (db_total < 1)
|
391 |
+
jQuery("#submit").attr('disabled', "disabled");
|
392 |
})
|
393 |
function db_start_migration(db_done, db_total) {
|
394 |
+
|
395 |
+
|
396 |
if (db_done < db_total) {
|
397 |
jQuery("#rtMediaSyncing").show();
|
398 |
jQuery.ajax({
|
403 |
"done": db_done
|
404 |
},
|
405 |
success: function(sdata) {
|
406 |
+
|
407 |
+
try {
|
408 |
data = JSON.parse(sdata);
|
409 |
+
} catch (e) {
|
410 |
+
jQuery("#submit").attr('disabled', "");
|
411 |
}
|
412 |
if (data.status) {
|
413 |
done = parseInt(data.done);
|
427 |
jQuery("#rtMediaSyncing").hide();
|
428 |
}
|
429 |
},
|
430 |
+
error: function() {
|
431 |
+
alert("Error During Migration, Please Refresh Page then try again");
|
432 |
+
jQuery("#submit").removeAttr('disabled');
|
433 |
+
}
|
434 |
});
|
435 |
} else {
|
436 |
alert("Migration completed.");
|
437 |
jQuery("#rtMediaSyncing").hide();
|
438 |
}
|
439 |
}
|
440 |
+
var db_done = <?php echo $done; ?>;
|
441 |
+
var db_total = <?php echo $total; ?>;
|
442 |
jQuery(document).on('click', '#submit', function(e) {
|
443 |
e.preventDefault();
|
444 |
+
|
445 |
db_start_migration(db_done, db_total);
|
446 |
jQuery(this).attr('disabled', 'disabled');
|
447 |
});
|
448 |
</script>
|
449 |
<hr />
|
450 |
+
<?php if ( ! (isset ( $rtmedia_error ) && $rtmedia_error === true) ) { ?>
|
451 |
+
<input type="button" id="submit" value="start" class="button button-primary" />
|
452 |
<?php } ?>
|
453 |
|
454 |
</div>
|
455 |
<?php
|
456 |
}
|
457 |
|
458 |
+
function migrate_to_new_db ( $lastid = 0, $limit = 1 ) {
|
459 |
|
460 |
+
if ( ! isset ( $_SESSION[ "migration_media" ] ) )
|
461 |
+
$this->get_total_count ();
|
462 |
|
463 |
+
$state = intval ( get_site_option ( "rtmedia-migration" ) );
|
464 |
+
if ( $state < 5 ) {
|
465 |
+
if ( $this->manage_album () ) {
|
466 |
+
$this->migrate_encoding_options ();
|
467 |
+
$this->return_migration ();
|
468 |
}
|
469 |
}
|
470 |
|
471 |
+
if ( intval ( $_SESSION[ "migration_media" ] ) >= $this->get_done_count ( true ) ) {
|
472 |
|
473 |
+
if ( ! $lastid ) {
|
474 |
+
$lastid = $this->get_last_imported ();
|
475 |
+
if ( ! $lastid ) {
|
476 |
+
$this->return_migration ();
|
477 |
}
|
478 |
}
|
479 |
global $wpdb;
|
498 |
left join
|
499 |
{$wpdb->posts} p ON (a.post_id = p.ID)
|
500 |
where
|
501 |
+
a.post_id >= %d and (NOT p.ID is NULL)
|
502 |
and a.meta_key = 'bp-media-key'
|
503 |
order by a.post_id
|
504 |
limit %d";
|
505 |
|
506 |
|
507 |
+
$results = $wpdb->get_results ( $wpdb->prepare ( $sql, $lastid, $limit ) );
|
508 |
|
509 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
510 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
511 |
else
|
512 |
$bp_prefix = "";
|
513 |
+
if ( $results ) {
|
514 |
|
515 |
+
foreach ( $results as $result ) {
|
516 |
+
$this->migrate_single_media ( $result );
|
517 |
}
|
518 |
}
|
519 |
} else {
|
520 |
+
global $wp_rewrite;
|
521 |
//Call flush_rules() as a method of the $wp_rewrite object
|
522 |
+
$wp_rewrite->flush_rules ( true );
|
523 |
// echo json_encode(array("status" => false, "done" => $done, "total" => $this->get_total_count()));
|
524 |
// die();
|
525 |
}
|
526 |
+
$this->return_migration ();
|
527 |
}
|
528 |
|
529 |
+
function migrate_encoding_options () {
|
530 |
$encoding_mnigration_array = array(
|
531 |
'bp-media-encoding-api-key' => 'rtmedia-encoding-api-key',
|
532 |
'bp-media-encoding-usage-limit-mail' => 'rtmedia-encoding-usage-limit-mail',
|
536 |
'bp_media_ffmpeg_options' => 'rtmedia-ffmpeg-options',
|
537 |
'bp_media_kaltura_options' => 'rtmedia-kaltura-options',
|
538 |
);
|
539 |
+
foreach ( $encoding_mnigration_array as $key => $ma ) {
|
540 |
+
if ( ($value = get_site_option ( $key )) !== false ) {
|
541 |
+
update_site_option ( $ma, $value );
|
542 |
}
|
543 |
}
|
544 |
}
|
545 |
|
546 |
+
function migrate_single_media ( $result, $album = false ) {
|
547 |
+
$blog_id = get_current_blog_id ();
|
548 |
+
$old = $result;
|
549 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
550 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
551 |
else
|
552 |
$bp_prefix = "";
|
553 |
global $wpdb;
|
554 |
+
|
555 |
+
if ( $album !== false && ! (is_object ( $result )) ) {
|
556 |
+
$id = $wpdb->get_var ( $wpdb->prepare ( "select ID from $this->bmp_table where media_id = %d", $result ) );
|
557 |
+
if ( $id == NULL ) {
|
558 |
$sql = "select
|
559 |
a.post_id as 'post_id',
|
560 |
a.meta_value as 'privacy',
|
578 |
where
|
579 |
a.post_id = %d and (NOT p.ID IS NULL)
|
580 |
and a.meta_key = 'bp_media_privacy'";
|
581 |
+
$result = $wpdb->get_row ( $wpdb->prepare ( $sql, $result ) );
|
582 |
} else {
|
583 |
return $id;
|
584 |
}
|
585 |
}
|
586 |
+
if ( ! isset ( $result ) || ! isset ( $result->post_id ) ) {
|
587 |
return $old;
|
588 |
}
|
589 |
$media_id = $result->post_id;
|
590 |
|
591 |
+
if ( intval ( $result->context_id ) > 0 ) {
|
592 |
$media_context = "profile";
|
593 |
+
$prefix = "users/" . abs ( intval ( $result->context_id ) );
|
594 |
} else {
|
595 |
$media_context = "group";
|
596 |
+
$prefix = bp_get_groups_root_slug () . abs ( intval ( $result->context_id ) );
|
597 |
}
|
598 |
|
599 |
|
600 |
+
$old_type = "";
|
601 |
+
if ( $result->post_type != "attachment" ) {
|
602 |
$media_type = "album";
|
603 |
} else {
|
604 |
+
$mime_type = strtolower ( $result->post_mime_type );
|
605 |
$old_type = "";
|
606 |
+
if ( strpos ( $mime_type, "image" ) === 0 ) {
|
607 |
$media_type = "photo";
|
608 |
$old_type = "photos";
|
609 |
+
} else if ( strpos ( $mime_type, "audio" ) === 0 ) {
|
610 |
$media_type = "music";
|
611 |
$old_type = "music";
|
612 |
+
} else if ( strpos ( $mime_type, "video" ) === 0 ) {
|
613 |
$media_type = "video";
|
614 |
$old_type = "videos";
|
615 |
} else {
|
617 |
}
|
618 |
}
|
619 |
|
620 |
+
$activity_data = $wpdb->get_row ( $wpdb->prepare ( "select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id ) );
|
621 |
+
if ( $media_type != 'album' ) {
|
622 |
+
$this->importmedia ( $media_id, $prefix );
|
623 |
}
|
624 |
|
625 |
+
if ( $this->table_exists ( $bp_prefix . "bp_activity" ) && class_exists ( "BP_Activity_Activity" ) ) {
|
626 |
$bp_activity = new BP_Activity_Activity();
|
627 |
+
$activity_sql = $wpdb->prepare ( "SELECT
|
628 |
*
|
629 |
FROM
|
630 |
{$bp_prefix}bp_activity
|
637 |
$wpdb->posts p ON (a.post_id = p.ID)
|
638 |
where
|
639 |
(NOT p.ID IS NULL) and p.ID = %d
|
640 |
+
and a.meta_key = 'bp_media_child_activity')", $media_id );
|
641 |
+
$all_activity = $wpdb->get_results ( $activity_sql );
|
642 |
+
remove_all_actions ( "wp_insert_comment" );
|
643 |
+
foreach ( $all_activity as $activity ) {
|
644 |
+
$comments = $bp_activity->get_activity_comments ( $activity->id, $activity->mptt_left, $activity->mptt_right );
|
645 |
+
$exclude = get_post_meta ( $media_id, "rtmedia_imported_activity", true );
|
646 |
+
if ( ! is_array ( $exclude ) ) {
|
647 |
+
$exclude = array( );
|
648 |
}
|
649 |
+
if ( $comments )
|
650 |
+
$this->insert_comment ( $media_id, $comments, $exclude );
|
651 |
}
|
652 |
}
|
653 |
+
if ( intval ( $result->parent ) !== 0 ) {
|
654 |
+
$album_id = $this->migrate_single_media ( $result->parent, true );
|
655 |
} else {
|
656 |
$album_id = 0;
|
657 |
}
|
658 |
+
if ( function_exists ( "bp_activity_get_meta" ) )
|
659 |
+
$likes = bp_activity_get_meta ( $result->activity_id, 'favorite_count' );
|
660 |
else
|
661 |
$likes = 0;
|
662 |
|
663 |
+
$wpdb->insert (
|
664 |
$this->bmp_table, array(
|
665 |
'blog_id' => $blog_id,
|
666 |
'media_id' => $media_id,
|
667 |
'media_type' => $media_type,
|
668 |
"context" => $media_context,
|
669 |
+
"context_id" => abs ( intval ( $result->context_id ) ),
|
670 |
"activity_id" => $result->activity_id,
|
671 |
+
"privacy" => intval ( $result->privacy ) * 10,
|
672 |
"media_author" => $result->media_author,
|
673 |
"media_title" => $result->media_title,
|
674 |
"album_id" => $album_id,
|
675 |
"likes" => $likes
|
676 |
+
), array( '%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d' )
|
677 |
);
|
678 |
+
$last_id = $wpdb->insert_id;
|
679 |
+
|
680 |
+
// Photo tag meta migration
|
681 |
//$photo_tag_meta = get_post_meta($media_id, "bp-media-user-tags", true);
|
|
|
682 |
// if($photo_tag_meta && !empty($photo_tag_meta)){
|
683 |
// $wpdb->insert(
|
684 |
// $wpdb->prefix . "rt_rtm_media_meta", array(
|
686 |
// 'meta_key' => "user-tags",
|
687 |
// "meta_value" => maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
|
688 |
// }
|
689 |
+
if ( $media_type != 'album' && function_exists ( 'bp_core_get_user_domain' ) && $activity_data ) {
|
690 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
691 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
692 |
else
|
693 |
$bp_prefix = "";
|
694 |
|
695 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
696 |
+
$parent_link = get_rtmedia_user_link ( $activity_data->user_id );
|
697 |
+
$activity_data->primary_link = $parent_link . RTMEDIA_MEDIA_SLUG . "/" . $last_id;
|
698 |
+
$this->search_and_replace ( $activity_data->old_primary_link, $activity_data->primary_link );
|
699 |
+
$activity_data->action = str_replace ( $activity_data->old_primary_link, $activity_data->primary_link, $activity_data->action );
|
700 |
+
$activity_data->content = str_replace ( $activity_data->old_primary_link, $activity_data->primary_link, $activity_data->content );
|
701 |
global $last_baseurl, $last_newurl;
|
702 |
|
703 |
$replace_img = $last_newurl; //$last_baseurl . "rtMedia/$prefix/";
|
704 |
+
if ( strpos ( $activity_data->content, $replace_img ) === false )
|
705 |
+
$activity_data->content = str_replace ( $last_baseurl, $replace_img, $activity_data->content );
|
706 |
global $wpdb;
|
707 |
+
$wpdb->update ( $bp_prefix . "bp_activity", array( "primary_link" => $activity_data->primary_link,
|
708 |
"action" => $activity_data->action,
|
709 |
+
"content" => $activity_data->content ), array( "id" => $activity_data->id ) );
|
710 |
+
}else {
|
711 |
+
if ( $media_context == "group" ) {
|
712 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
713 |
+
$parent_link = get_rtmedia_group_link ( abs ( intval ( $result->context_id ) ) );
|
714 |
+
$parent_link = trailingslashit ( $parent_link );
|
715 |
+
$activity_data->primary_link = trailingslashit ( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id );
|
716 |
+
$this->search_and_replace ( $activity_data->old_primary_link, $activity_data->primary_link );
|
717 |
+
} else {
|
718 |
$activity_data->old_primary_link = $activity_data->primary_link;
|
719 |
+
$parent_link = get_rtmedia_user_link ( $activity_data->user_id );
|
720 |
+
$parent_link = trailingslashit ( $parent_link );
|
721 |
+
$activity_data->primary_link = trailingslashit ( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id );
|
722 |
+
$this->search_and_replace ( $activity_data->old_primary_link, $activity_data->primary_link );
|
723 |
}
|
724 |
}
|
725 |
+
if ( $old_type != "" ) {
|
726 |
+
if ( $media_context == "group" ) {
|
727 |
+
$parent_link = get_rtmedia_group_link ( abs ( intval ( $result->context_id ) ) );
|
728 |
+
$parent_link = trailingslashit ( $parent_link );
|
729 |
+
$this->search_and_replace ( trailingslashit ( $parent_link . $old_type . '/' . $media_id ), trailingslashit ( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id ) );
|
730 |
+
} else {
|
731 |
+
$parent_link = get_rtmedia_user_link ( $activity_data->user_id );
|
732 |
+
$parent_link = trailingslashit ( $parent_link );
|
733 |
+
$this->search_and_replace ( trailingslashit ( $parent_link . $old_type . '/' . $media_id ), trailingslashit ( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id ) );
|
|
|
|
|
734 |
}
|
|
|
735 |
}
|
736 |
return $last_id;
|
737 |
}
|
738 |
|
739 |
+
function importmedia ( $id, $prefix ) {
|
740 |
+
|
741 |
|
|
|
742 |
$delete = false;
|
743 |
+
$attached_file = get_attached_file ( $id );
|
744 |
+
$attached_file_option = get_post_meta ( $id, '_wp_attached_file', true );
|
745 |
+
$basename = wp_basename ( $attached_file );
|
746 |
+
$file_folder_path = trailingslashit ( str_replace ( $basename, '', $attached_file ) );
|
747 |
|
748 |
|
749 |
+
$siteurl = get_option ( 'siteurl' );
|
750 |
+
$upload_path = trim ( get_option ( 'upload_path' ) );
|
751 |
|
752 |
+
if ( empty ( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
|
753 |
$dir = WP_CONTENT_DIR . '/uploads';
|
754 |
+
} elseif ( 0 !== strpos ( $upload_path, ABSPATH ) ) {
|
755 |
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
756 |
+
$dir = path_join ( ABSPATH, $upload_path );
|
757 |
} else {
|
758 |
$dir = $upload_path;
|
759 |
}
|
760 |
|
761 |
+
if ( ! $url = get_option ( 'upload_url_path' ) ) {
|
762 |
+
if ( empty ( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
|
763 |
$url = WP_CONTENT_URL . '/uploads';
|
764 |
else
|
765 |
+
$url = trailingslashit ( $siteurl ) . $upload_path;
|
766 |
}
|
767 |
|
768 |
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
|
769 |
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
|
770 |
+
if ( defined ( 'UPLOADS' ) && ! ( is_multisite () && get_site_option ( 'ms_files_rewriting' ) ) ) {
|
771 |
$dir = ABSPATH . UPLOADS;
|
772 |
+
$url = trailingslashit ( $siteurl ) . UPLOADS;
|
773 |
}
|
774 |
|
775 |
// If multisite (and if not the main site in a post-MU network)
|
776 |
+
if ( is_multisite () && ! ( is_main_site () && defined ( 'MULTISITE' ) ) ) {
|
777 |
|
778 |
+
if ( ! get_site_option ( 'ms_files_rewriting' ) ) {
|
779 |
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
|
780 |
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
|
781 |
// prevents a four-digit ID from conflicting with a year-based directory for the main site.
|
782 |
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
|
783 |
// directory, as they never had wp-content/uploads for the main site.)
|
784 |
|
785 |
+
if ( defined ( 'MULTISITE' ) )
|
786 |
+
$ms_dir = '/sites/' . get_current_blog_id ();
|
787 |
else
|
788 |
+
$ms_dir = '/' . get_current_blog_id ();
|
789 |
|
790 |
$dir .= $ms_dir;
|
791 |
$url .= $ms_dir;
|
792 |
+
} elseif ( defined ( 'UPLOADS' ) && ! ms_is_switched () ) {
|
793 |
// Handle the old-form ms-files.php rewriting if the network still has that enabled.
|
794 |
// When ms-files rewriting is enabled, then we only listen to UPLOADS when:
|
795 |
// 1) we are not on the main site in a post-MU network,
|
802 |
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
|
803 |
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
|
804 |
|
805 |
+
if ( defined ( 'BLOGUPLOADDIR' ) )
|
806 |
+
$dir = untrailingslashit ( BLOGUPLOADDIR );
|
807 |
else
|
808 |
$dir = ABSPATH . UPLOADS;
|
809 |
+
$url = trailingslashit ( $siteurl ) . 'files';
|
810 |
}
|
811 |
}
|
812 |
|
813 |
+
$basedir = trailingslashit ( $dir );
|
814 |
+
$baseurl = trailingslashit ( $url );
|
815 |
|
816 |
+
$new_file_folder_path = trailingslashit ( str_replace ( $basedir, $basedir . "rtMedia/$prefix/", $file_folder_path ) );
|
817 |
|
818 |
+
$year_month = untrailingslashit ( str_replace ( $basedir, '', $file_folder_path ) );
|
819 |
|
820 |
|
821 |
+
$metadata = wp_get_attachment_metadata ( $id );
|
822 |
+
$backup_metadata = get_post_meta ( $id, '_wp_attachment_backup_sizes', true );
|
823 |
+
$instagram_thumbs = get_post_meta ( $id, '_instagram_thumbs', true );
|
824 |
+
$instagram_full_images = get_post_meta ( $id, '_instagram_full_images', true );
|
825 |
+
$instagram_metadata = get_post_meta ( $id, '_instagram_metadata', true );
|
826 |
+
$encoding_job_id = get_post_meta ( $id, 'bp-media-encoding-job-id', true );
|
827 |
+
$ffmpeg_thumbnail_ids = get_post_meta ( $id, 'bp_media_thumbnail_ids', true );
|
828 |
+
$ffmpeg_thumbnail = get_post_meta ( $id, 'bp_media_thumbnail', true );
|
829 |
+
$ffmpeg_remote_id = get_post_meta ( $id, 'bp_media_ffmpeg_remote_id', true );
|
830 |
+
$kaltura_remote_id = get_post_meta ( $id, 'bp_media_kaltura_remote_id', true );
|
831 |
|
832 |
+
if ( wp_mkdir_p ( $basedir . "rtMedia/$prefix/" . $year_month ) ) {
|
833 |
+
if ( copy ( $attached_file, str_replace ( $basedir, $basedir . "rtMedia/$prefix/", $attached_file ) ) ) {
|
834 |
$delete = true;
|
835 |
|
836 |
+
if ( isset ( $metadata[ 'sizes' ] ) ) {
|
837 |
+
foreach ( $metadata[ 'sizes' ] as $size ) {
|
838 |
+
if ( ! copy ( $file_folder_path . $size[ 'file' ], $new_file_folder_path . $size[ 'file' ] ) ) {
|
839 |
$delete = false;
|
|
|
840 |
} else {
|
841 |
+
$delete_sizes[ ] = $file_folder_path . $size[ 'file' ];
|
842 |
+
$this->search_and_replace ( trailingslashit ( $baseurl . $year_month ) . $size[ 'file' ], trailingslashit ( $baseurl . "rtMedia/$prefix/" . $year_month ) . $size[ 'file' ] );
|
843 |
}
|
|
|
844 |
}
|
845 |
}
|
846 |
+
if ( $backup_metadata ) {
|
847 |
+
foreach ( $backup_metadata as $backup_images ) {
|
848 |
+
if ( ! copy ( $file_folder_path . $backup_images[ 'file' ], $new_file_folder_path . $backup_images[ 'file' ] ) ) {
|
849 |
$delete = false;
|
850 |
} else {
|
851 |
+
$delete_sizes[ ] = $file_folder_path . $backup_images[ 'file' ];
|
852 |
+
$this->search_and_replace ( trailingslashit ( $baseurl . $year_month ) . $backup_images[ 'file' ], trailingslashit ( $baseurl . "rtMedia/$prefix/" . $year_month ) . $backup_images[ 'file' ] );
|
853 |
}
|
854 |
}
|
855 |
}
|
856 |
|
857 |
+
if ( $instagram_thumbs ) {
|
858 |
+
foreach ( $instagram_thumbs as $key => $insta_thumb ) {
|
859 |
+
try {
|
860 |
+
if ( ! copy ( str_replace ( $baseurl, $basedir, $insta_thumb ), str_replace ( $baseurl, $basedir . "rtMedia/$prefix/", $insta_thumb ) ) ) {
|
861 |
+
$delete = false;
|
862 |
+
} else {
|
863 |
+
$delete_sizes[ ] = str_replace ( $baseurl, $basedir, $insta_thumb );
|
864 |
+
$instagram_thumbs_new[ $key ] = str_replace ( $baseurl, $baseurl . "rtMedia/$prefix/", $insta_thumb );
|
865 |
+
$this->search_and_replace ( trailingslashit ( $baseurl . $year_month ) . $insta_thumb, trailingslashit ( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_thumb );
|
866 |
+
}
|
867 |
+
} catch ( Exceptio $e ) {
|
868 |
$delete = false;
|
869 |
}
|
870 |
}
|
871 |
}
|
872 |
|
873 |
+
if ( $instagram_full_images ) {
|
874 |
+
foreach ( $instagram_full_images as $key => $insta_full_image ) {
|
875 |
+
if ( ! copy ( $insta_full_image, str_replace ( $basedir, $basedir . "rtMedia/$prefix/", $insta_full_image ) ) ) {
|
876 |
$delete = false;
|
877 |
} else {
|
878 |
+
$delete_sizes[ ] = $insta_full_image;
|
879 |
+
$instagram_full_images_new[ $key ] = str_replace ( $basedir, $basedir . "rtMedia/$prefix", $insta_full_image );
|
880 |
+
$this->search_and_replace ( trailingslashit ( $baseurl . $year_month ) . $insta_full_image, trailingslashit ( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_full_image );
|
881 |
}
|
882 |
}
|
883 |
}
|
884 |
|
885 |
+
if ( $instagram_metadata ) {
|
886 |
$instagram_metadata_new = $instagram_metadata;
|
887 |
+
foreach ( $instagram_metadata as $wp_size => $insta_metadata ) {
|
888 |
+
if ( isset ( $insta_metadata[ 'file' ] ) ) {
|
889 |
+
if ( ! copy ( $basedir . $insta_metadata[ 'file' ], $basedir . "rtMedia/$prefix/" . $insta_metadata[ 'file' ] ) ) {
|
890 |
$delete = false;
|
891 |
} else {
|
892 |
+
$delete_sizes[ ] = $basedir . $insta_metadata[ 'file' ];
|
893 |
+
$instagram_metadata_new[ $wp_size ][ 'file' ] = "rtMedia/$prefix/" . $insta_metadata[ 'file' ];
|
894 |
+
if ( isset ( $insta_metadata[ 'sizes' ] ) ) {
|
895 |
+
foreach ( $insta_metadata[ 'sizes' ] as $key => $insta_size ) {
|
896 |
+
if ( ! copy ( $file_folder_path . $insta_size[ 'file' ], $new_file_folder_path . $insta_size[ 'file' ] ) ) {
|
897 |
+
$delete = false;
|
898 |
} else {
|
899 |
+
$delete_sizes[ ] = $file_folder_path . $insta_size[ 'file' ];
|
900 |
+
$this->search_and_replace ( trailingslashit ( $baseurl . $year_month ) . $insta_size[ 'file' ], trailingslashit ( $baseurl . "rtMedia/$prefix/" . $year_month ) . $insta_size[ 'file' ] );
|
901 |
}
|
902 |
}
|
903 |
}
|
906 |
}
|
907 |
}
|
908 |
|
909 |
+
if ( $delete ) {
|
910 |
+
if ( file_exists ( $attached_file ) )
|
911 |
+
unlink ( $attached_file );
|
912 |
|
913 |
+
if ( isset ( $delete_sizes ) ) {
|
914 |
+
foreach ( $delete_sizes as $delete_size ) {
|
915 |
+
if ( file_exists ( $delete_size ) )
|
916 |
+
unlink ( $delete_size );
|
917 |
}
|
918 |
}
|
919 |
+
update_post_meta ( $id, '_wp_attached_file', "rtMedia/$prefix/" . $attached_file_option );
|
920 |
+
if ( isset ( $metadata[ 'file' ] ) ) {
|
921 |
+
$metadata[ 'file' ] = "rtMedia/$prefix/" . $metadata[ 'file' ];
|
922 |
+
wp_update_attachment_metadata ( $id, $metadata );
|
923 |
}
|
924 |
+
if ( $instagram_thumbs ) {
|
925 |
+
update_rtmedia_meta ( $id, '_instagram_thumbs', $instagram_thumbs_new );
|
926 |
}
|
927 |
+
if ( $instagram_full_images ) {
|
928 |
+
update_rtmedia_meta ( $id, '_instagram_full_images', $instagram_full_images_new );
|
929 |
}
|
930 |
+
if ( $instagram_metadata ) {
|
931 |
+
update_rtmedia_meta ( $id, '_instagram_metadata', $instagram_metadata_new );
|
932 |
}
|
933 |
+
if ( $encoding_job_id ) {
|
934 |
+
update_rtmedia_meta ( $id, 'rtmedia-encoding-job-id', $encoding_job_id );
|
935 |
}
|
936 |
+
if ( $ffmpeg_thumbnail_ids ) {
|
937 |
+
update_rtmedia_meta ( $id, 'rtmedia-thumbnail-ids', $ffmpeg_thumbnail_ids );
|
938 |
}
|
939 |
+
if ( $ffmpeg_thumbnail ) {
|
940 |
$model = new RTMediaModel();
|
941 |
+
$model->update ( array( 'cover_art' => $ffmpeg_thumbnail ), array( 'id' => $id ) );
|
942 |
}
|
943 |
+
if ( $ffmpeg_remote_id ) {
|
944 |
+
update_rtmedia_meta ( $id, 'rtmedia-ffmpeg-remote-id', $ffmpeg_remote_id );
|
945 |
}
|
946 |
+
if ( $kaltura_remote_id ) {
|
947 |
+
update_rtmedia_meta ( $id, 'rtmedia-kaltura-remote-id', $kaltura_remote_id );
|
948 |
}
|
949 |
|
950 |
+
$attachment = array( );
|
951 |
+
$attachment[ 'ID' ] = $id;
|
952 |
+
$old_guid = get_post_field ( 'guid', $id );
|
953 |
+
$attachment[ 'guid' ] = str_replace ( $baseurl, $baseurl . "rtMedia/$prefix/", $old_guid );
|
954 |
/**
|
955 |
* For Activity
|
956 |
*/
|
957 |
global $last_baseurl, $last_newurl;
|
958 |
$last_baseurl = $baseurl;
|
959 |
$last_newurl = $baseurl . "rtMedia/$prefix/";
|
960 |
+
$this->search_and_replace ( $old_guid, $attachment[ 'guid' ] );
|
961 |
+
wp_update_post ( $attachment );
|
962 |
}
|
963 |
}
|
964 |
}
|
965 |
}
|
966 |
+
|
967 |
+
function search_and_replace ( $old, $new ) {
|
968 |
global $wpdb;
|
969 |
+
if ( function_exists ( "bp_core_get_table_prefix" ) )
|
970 |
+
$bp_prefix = bp_core_get_table_prefix ();
|
971 |
else
|
972 |
+
$bp_prefix = "";
|
973 |
+
$sql = $wpdb->prepare ( "update {$bp_prefix}bp_activity set action=replace(action,%s,%s) ,content=replace(content,%s,%s), primary_link=replace(primary_link,%s,%s) where id > 0;", $old, $new, $old, $new, $old, $new );
|
974 |
+
$wpdb->get_row ( $sql );
|
975 |
}
|
976 |
+
|
977 |
+
function formatSeconds ( $secondsLeft ) {
|
978 |
|
979 |
$minuteInSeconds = 60;
|
980 |
$hourInSeconds = $minuteInSeconds * 60;
|
981 |
$dayInSeconds = $hourInSeconds * 24;
|
982 |
|
983 |
+
$days = floor ( $secondsLeft / $dayInSeconds );
|
984 |
$secondsLeft = $secondsLeft % $dayInSeconds;
|
985 |
|
986 |
+
$hours = floor ( $secondsLeft / $hourInSeconds );
|
987 |
$secondsLeft = $secondsLeft % $hourInSeconds;
|
988 |
|
989 |
+
$minutes = floor ( $secondsLeft / $minuteInSeconds );
|
990 |
|
991 |
$seconds = $secondsLeft % $minuteInSeconds;
|
992 |
|
993 |
+
$timeComponents = array( );
|
994 |
|
995 |
+
if ( $days > 0 ) {
|
996 |
+
$timeComponents[ ] = $days . " day" . ($days > 1 ? "s" : "");
|
997 |
}
|
998 |
|
999 |
+
if ( $hours > 0 ) {
|
1000 |
+
$timeComponents[ ] = $hours . " hour" . ($hours > 1 ? "s" : "");
|
1001 |
}
|
1002 |
|
1003 |
+
if ( $minutes > 0 ) {
|
1004 |
+
$timeComponents[ ] = $minutes . " minute" . ($minutes > 1 ? "s" : "");
|
1005 |
}
|
1006 |
|
1007 |
+
if ( $seconds > 0 ) {
|
1008 |
+
$timeComponents[ ] = $seconds . " second" . ($seconds > 1 ? "s" : "");
|
1009 |
}
|
1010 |
+
if ( count ( $timeComponents ) > 0 ) {
|
1011 |
+
$formattedTimeRemaining = implode ( ", ", $timeComponents );
|
1012 |
+
$formattedTimeRemaining = trim ( $formattedTimeRemaining );
|
1013 |
} else {
|
1014 |
$formattedTimeRemaining = "No time remaining.";
|
1015 |
}
|
1017 |
return $formattedTimeRemaining;
|
1018 |
}
|
1019 |
|
1020 |
+
function insert_comment ( $media_id, $data, $exclude, $parent_commnet_id = 0 ) {
|
1021 |
+
foreach ( $data as $cmnt ) {
|
1022 |
$comment_id = 0;
|
1023 |
+
if ( ! key_exists ( strval ( $cmnt->id ), $exclude ) ) {
|
1024 |
$commentdata = array(
|
1025 |
"comment_date" => $cmnt->date_recorded,
|
1026 |
"comment_parent" => $parent_commnet_id,
|
1030 |
'comment_post_ID' => $media_id,
|
1031 |
'comment_author' => $cmnt->display_name,
|
1032 |
'comment_author_url' => '',
|
1033 |
+
'comment_author_IP' => '' );
|
1034 |
+
$comment_id = wp_insert_comment ( $commentdata );
|
1035 |
+
$exclude[ strval ( $cmnt->id ) ] = $comment_id;
|
1036 |
} else {
|
1037 |
+
$comment_id = $exclude[ strval ( $cmnt->id ) ];
|
1038 |
}
|
1039 |
|
1040 |
+
update_post_meta ( $media_id, "rtmedia_imported_activity", $exclude );
|
1041 |
|
1042 |
+
if ( is_array ( $cmnt->children ) ) {
|
1043 |
+
$this->insert_comment ( $media_id, $cmnt->children, $exclude, $comment_id );
|
1044 |
}
|
1045 |
}
|
1046 |
}
|
app/main/RTMedia.php
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Don't load this file directly!
|
5 |
*/
|
6 |
-
if ( ! defined( 'ABSPATH' ) )
|
7 |
-
|
8 |
|
9 |
/**
|
10 |
* BuddyPress Media
|
@@ -20,794 +19,835 @@ if ( ! defined( 'ABSPATH' ) )
|
|
20 |
*/
|
21 |
class RTMedia {
|
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 |
-
return $image_sizes;
|
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 |
-
'photo' => array(
|
167 |
-
'name' => 'photo',
|
168 |
-
'plural' => 'photos',
|
169 |
-
'label' => __( 'Photo', 'rtmedia' ),
|
170 |
-
'plural_label' => __( 'Photos', 'rtmedia' ),
|
171 |
-
'extn' => array( 'jpeg', 'png' ),
|
172 |
-
'thumbnail' => RTMEDIA_URL . 'app/assets/img/image_thumb.png'
|
173 |
-
),
|
174 |
-
'video' => array(
|
175 |
-
'name' => 'video',
|
176 |
-
'plural' => 'videos',
|
177 |
-
'label' => __( 'Video', 'rtmedia' ),
|
178 |
-
'plural_label' => __( 'Videos', 'rtmedia' ),
|
179 |
-
'extn' => array( 'mp4' ),
|
180 |
-
'thumbnail' => RTMEDIA_URL . 'app/assets/img/video_thumb.png'
|
181 |
-
),
|
182 |
-
'music' => array(
|
183 |
-
'name' => 'music',
|
184 |
-
'plural' => 'music',
|
185 |
-
'label' => __( 'Music', 'rtmedia' ),
|
186 |
-
'plural_label' => __( 'Music', 'rtmedia' ),
|
187 |
-
'extn' => array( 'mp3' ),
|
188 |
-
'thumbnail' => RTMEDIA_URL . 'app/assets/img/audio_thumb.png'
|
189 |
-
)
|
190 |
-
);
|
191 |
-
|
192 |
-
// filter for hooking additional media types
|
193 |
-
$allowed_types = apply_filters( 'rtmedia_allowed_types', $allowed_types );
|
194 |
-
|
195 |
-
// sanitize all the types
|
196 |
-
$allowed_types = $this->sanitize_allowed_types( $allowed_types );
|
197 |
-
|
198 |
-
// set the allowed types property
|
199 |
-
$this->allowed_types = $allowed_types;
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Sanitize all media sizes after hooking custom media types
|
204 |
-
*
|
205 |
-
* @param array $allowed_types allowed media types after hooking custom types
|
206 |
-
* @return array $allowed_types sanitized media types
|
207 |
-
*/
|
208 |
-
function sanitize_allowed_types( $allowed_types ) {
|
209 |
-
// check if the array is formatted properly
|
210 |
-
if ( ! is_array( $allowed_types ) && count( $allowed_types ) < 1 )
|
211 |
-
return;
|
212 |
-
|
213 |
-
//loop through each type
|
214 |
-
foreach ( $allowed_types as $key => &$type ) {
|
215 |
-
|
216 |
-
if ( ! isset( $type[ 'name' ] ) || // check if a name is set
|
217 |
-
empty( $type[ 'name' ] ) ||
|
218 |
-
! isset( $type[ 'extn' ] ) || // check if file extensions are set
|
219 |
-
empty( $type[ 'extn' ] ) || strstr( $type[ 'name' ], " " ) || strstr( $type[ 'name' ], "_" ) ) {
|
220 |
-
unset( $allowed_types[ $key ] ); // if not unset this type
|
221 |
-
continue;
|
222 |
-
}
|
223 |
-
|
224 |
-
// if thumbnail is not supplied, use the default thumbnail
|
225 |
-
if ( ! isset( $type[ 'thumbnail' ] ) || empty( $type[ 'thumbnail' ] ) ) {
|
226 |
-
$type[ 'thumbnail' ] = $this->default_thumbnail;
|
227 |
-
}
|
228 |
-
}
|
229 |
-
return $allowed_types;
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* Set the default sizes
|
234 |
-
*/
|
235 |
-
function set_default_sizes() {
|
236 |
-
$this->default_sizes = array(
|
237 |
-
'photo' => array(
|
238 |
-
'thumbnail' => array( 'width' => 150, 'height' => 150, 'crop' => 1 ),
|
239 |
-
'medium' => array( 'width' => 320, 'height' => 240, 'crop' => 1 ),
|
240 |
-
'large' => array( 'width' => 800, 'height' => 0, 'crop' => 1 )
|
241 |
-
),
|
242 |
-
'video' => array(
|
243 |
-
'activityPlayer' => array( 'width' => 320, 'height' => 240 ),
|
244 |
-
'singlePlayer' => array( 'width' => 640, 'height' => 480 )
|
245 |
-
),
|
246 |
-
'music' => array(
|
247 |
-
'activityPlayer' => array( 'width' => 320 ),
|
248 |
-
'singlePlayer' => array( 'width' => 640 )
|
249 |
-
),
|
250 |
-
'featured' => array(
|
251 |
-
'default' => array( 'width' => 100, 'height' => 100, 'crop' => 1 )
|
252 |
-
)
|
253 |
-
);
|
254 |
-
|
255 |
-
$this->default_sizes = apply_filters( 'rtmedia_allowed_sizes', $this->default_sizes );
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Set privacy options
|
260 |
-
*/
|
261 |
-
function set_privacy() {
|
262 |
-
|
263 |
-
$this->privacy_settings = array(
|
264 |
-
'levels' => array(
|
265 |
-
60 => __( '<strong>Private</strong> - Visible only to the user', 'rtmedia' ),
|
266 |
-
40 => __( '<strong>Friends</strong> - Visible to user\'s friends', 'rtmedia' ),
|
267 |
-
20 => __( '<strong>Users</strong> - Visible to registered users', 'rtmedia' ),
|
268 |
-
0 => __( '<strong>Public</strong> - Visible to the world', 'rtmedia' )
|
269 |
-
)
|
270 |
-
);
|
271 |
-
$this->privacy_settings = apply_filters( 'rtmedia_privacy_levels', $this->privacy_settings );
|
272 |
-
|
273 |
-
if ( function_exists( "bp_is_active" ) && ! bp_is_active( 'friends' ) ) {
|
274 |
-
unset( $this->privacy_settings[ 'levels' ][ 40 ] );
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Load admin screens
|
280 |
-
*
|
281 |
-
* @global RTMediaAdmin $rtmedia_admin Class for loading admin screen
|
282 |
-
*/
|
283 |
-
function admin_init() {
|
284 |
-
global $rtmedia_admin;
|
285 |
-
$rtmedia_admin = new RTMediaAdmin();
|
286 |
-
}
|
287 |
-
|
288 |
-
function media_screen() {
|
289 |
-
return;
|
290 |
-
}
|
291 |
-
|
292 |
-
function get_user_link( $user ) {
|
293 |
-
|
294 |
-
if ( function_exists( 'bp_core_get_user_domain' ) ) {
|
295 |
-
$parent_link = bp_core_get_user_domain( $user );
|
296 |
-
} else {
|
297 |
-
$parent_link = get_author_posts_url( $user );
|
298 |
-
}
|
299 |
-
|
300 |
-
return $parent_link;
|
301 |
-
}
|
302 |
-
|
303 |
-
public function init_buddypress_options() {
|
304 |
-
/**
|
305 |
-
* BuddyPress Settings
|
306 |
-
*/
|
307 |
-
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
308 |
-
|
309 |
-
$group = 0;
|
310 |
-
if ( isset( $bp_media_options[ 'enable_on_group' ] ) && ! empty( $bp_media_options[ 'enable_on_group' ] ) )
|
311 |
-
$group = $bp_media_options[ 'enable_on_group' ];
|
312 |
-
else if ( function_exists( "bp_is_active" ) )
|
313 |
-
$group = bp_is_active( 'groups' );
|
314 |
-
$this->options[ 'buddypress_enableOnGroup' ] = $group;
|
315 |
-
|
316 |
-
$activity = 0;
|
317 |
-
if ( isset( $bp_media_options[ 'activity_upload' ] ) && ! empty( $bp_media_options[ 'activity_upload' ] ) )
|
318 |
-
$activity = $bp_media_options[ 'activity_upload' ];
|
319 |
-
else if ( function_exists( "bp_is_active" ) )
|
320 |
-
$activity = bp_is_active( 'activity' );
|
321 |
-
$this->options[ 'buddypress_enableOnActivity' ] = $activity;
|
322 |
-
|
323 |
-
$this->options[ 'buddypress_enableOnProfile' ] = 1;
|
324 |
-
|
325 |
-
/* Last settings updated in options. Update them in DB & after this no other option would be saved in db */
|
326 |
-
rtmedia_update_site_option( 'rtmedia-options', $this->options );
|
327 |
-
}
|
328 |
-
|
329 |
-
public function init_site_options() {
|
330 |
-
|
331 |
-
$bp_media_options = rtmedia_get_site_option( 'bp_media_options' );
|
332 |
-
|
333 |
-
$defaults = array(
|
334 |
-
'general_enableAlbums' => 0,
|
335 |
-
'general_enableComments' => 0,
|
336 |
-
'general_downloadButton' => (isset( $bp_media_options[ 'download_enabled' ] )) ? $bp_media_options[ 'download_enabled' ] : 0,
|
337 |
-
'general_enableLightbox' => (isset( $bp_media_options[ 'enable_lightbox' ] )) ? $bp_media_options[ 'enable_lightbox' ] : 0,
|
338 |
-
'general_perPageMedia' => (isset( $bp_media_options[ 'default_count' ] )) ? $bp_media_options[ 'default_count' ] : 10,
|
339 |
-
'general_enableMediaEndPoint' => 0,
|
340 |
-
'general_showAdminMenu' => (isset( $bp_media_options[ 'show_admin_menu' ] )) ? $bp_media_options[ 'show_admin_menu' ] : 0,
|
341 |
-
);
|
342 |
-
|
343 |
-
|
344 |
-
foreach ( $this->allowed_types as $type ) {
|
345 |
-
// invalid keys handled in sanitize method
|
346 |
-
$defaults[ 'allowedTypes_' . $type[ 'name' ] . '_enabled' ] = 1;
|
347 |
-
$defaults[ 'allowedTypes_' . $type[ 'name' ] . '_featured' ] = 0;
|
348 |
-
}
|
349 |
-
|
350 |
-
/* Previous Sizes values from buddypress is migrated */
|
351 |
-
foreach ( $this->default_sizes as $type => $typeValue ) {
|
352 |
-
foreach ( $typeValue as $size => $sizeValue ) {
|
353 |
-
foreach ( $sizeValue as $dimension => $value ) {
|
354 |
-
switch ( $type ) {
|
355 |
-
case 'photo':
|
356 |
-
if ( isset( $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ] ) && ! empty( $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ] ) )
|
357 |
-
$value = $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ];
|
358 |
-
break;
|
359 |
-
case 'video':
|
360 |
-
case 'music':
|
361 |
-
$old = ($type == 'video') ? 'video' : ($type == 'music') ? 'audio' : '';
|
362 |
-
switch ( $size ) {
|
363 |
-
case 'activityPlayer':
|
364 |
-
if ( isset( $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ] ) && ! empty( $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ] ) )
|
365 |
-
$value = $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ];
|
366 |
-
break;
|
367 |
-
case 'singlePlayer':
|
368 |
-
if ( isset( $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ] ) && ! empty( $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ] ) )
|
369 |
-
$value = $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ];
|
370 |
-
break;
|
371 |
-
}
|
372 |
-
break;
|
373 |
-
}
|
374 |
-
$defaults[ 'defaultSizes_' . $type . '_' . $size . '_' . $dimension ] = $value;
|
375 |
-
}
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
-
/* Privacy */
|
380 |
-
$defaults[ 'privacy_enabled' ] = (isset( $bp_media_options[ 'privacy_enabled' ] )) ? $bp_media_options[ 'privacy_enabled' ] : 0;
|
381 |
-
$defaults[ 'privacy_default' ] = (isset( $bp_media_options[ 'default_privacy_level' ] )) ? $bp_media_options[ 'default_privacy_level' ] : 0;
|
382 |
-
$defaults[ 'privacy_userOverride' ] = (isset( $bp_media_options[ 'privacy_override_enabled' ] )) ? $bp_media_options[ 'privacy_override_enabled' ] : 0;
|
383 |
-
|
384 |
-
$this->options = $defaults;
|
385 |
-
|
386 |
-
$this->init_buddypress_options();
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Defines all the constants if undefined. Can be overridden by
|
391 |
-
* defining them elsewhere, say wp-config.php
|
392 |
-
*/
|
393 |
-
public function constants() {
|
394 |
-
|
395 |
-
/* If the plugin is installed. */
|
396 |
-
if ( ! defined( 'RTMEDIA_IS_INSTALLED' ) )
|
397 |
-
define( 'RTMEDIA_IS_INSTALLED', 1 );
|
398 |
-
|
399 |
-
/* Current Version. */
|
400 |
-
if ( ! defined( 'RTMEDIA_VERSION' ) )
|
401 |
-
define( 'RTMEDIA_VERSION', '3.0.0' );
|
402 |
-
|
403 |
-
/* Required Version */
|
404 |
-
if ( ! defined( 'RTMEDIA_REQUIRED_BP' ) )
|
405 |
-
define( 'RTMEDIA_REQUIRED_BP', '1.7' );
|
406 |
-
|
407 |
-
|
408 |
-
/* Slug Constants for building urls */
|
409 |
-
|
410 |
-
/* Media slugs */
|
411 |
-
|
412 |
-
if ( ! defined( 'RTMEDIA_MEDIA_SLUG' ) )
|
413 |
-
define( 'RTMEDIA_MEDIA_SLUG', 'media' );
|
414 |
-
|
415 |
-
if ( ! defined( 'RTMEDIA_MEDIA_LABEL' ) )
|
416 |
-
define( 'RTMEDIA_MEDIA_LABEL', __( 'Media', 'rtmedia' ) );
|
417 |
-
|
418 |
-
if ( ! defined( 'RTMEDIA_ALL_SLUG' ) )
|
419 |
-
define( 'RTMEDIA_ALL_SLUG', 'all' );
|
420 |
-
|
421 |
-
if ( ! defined( 'RTMEDIA_ALL_LABEL' ) )
|
422 |
-
define( 'RTMEDIA_ALL_LABEL', __( 'All', 'rtmedia' ) );
|
423 |
-
|
424 |
-
if ( ! defined( 'RTMEDIA_ALBUM_SLUG' ) )
|
425 |
-
define( 'RTMEDIA_ALBUM_SLUG', 'album' );
|
426 |
-
|
427 |
-
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_SLUG' ) )
|
428 |
-
define( 'RTMEDIA_ALBUM_PLURAL_SLUG', 'albums' );
|
429 |
-
|
430 |
-
if ( ! defined( 'RTMEDIA_ALBUM_LABEL' ) )
|
431 |
-
define( 'RTMEDIA_ALBUM_LABEL', __( 'Album', 'rtmedia' ) );
|
432 |
-
|
433 |
-
if ( ! defined( 'RTMEDIA_ALBUM_PLURAL_LABEL' ) )
|
434 |
-
define( 'RTMEDIA_ALBUM_PLURAL_LABEL', __( 'Albums', 'rtmedia' ) );
|
435 |
-
|
436 |
-
/* Upload slug */
|
437 |
-
if ( ! defined( 'RTMEDIA_UPLOAD_SLUG' ) )
|
438 |
-
define( 'RTMEDIA_UPLOAD_SLUG', 'upload' );
|
439 |
-
|
440 |
-
/* Upload slug */
|
441 |
-
if ( ! defined( 'RTMEDIA_UPLOAD_LABEL' ) )
|
442 |
-
define( 'RTMEDIA_UPLOAD_LABEL', __( 'Upload', 'rtmedia' ) );
|
443 |
-
|
444 |
-
/* Global Album/Wall Post */
|
445 |
-
if ( ! defined( 'RTMEDIA_GLOBAL_ALBUM_LABEL' ) )
|
446 |
-
define( 'RTMEDIA_GLOBAL_ALBUM_LABEL', __( 'Wall Post', 'rtmedia' ) );
|
447 |
-
|
448 |
-
$this->define_type_constants();
|
449 |
-
}
|
450 |
-
|
451 |
-
function define_type_constants() {
|
452 |
-
|
453 |
-
if ( ! isset( $this->allowed_types ) )
|
454 |
-
return;
|
455 |
-
foreach ( $this->allowed_types as $type ) {
|
456 |
-
|
457 |
-
if ( ! isset( $type[ 'name' ] ) || $type[ 'name' ] === '' )
|
458 |
-
continue;
|
459 |
-
|
460 |
-
$name = $type[ 'name' ];
|
461 |
-
|
462 |
-
if ( isset( $type[ 'plural' ] ) && $type[ 'plural' ] != '' ) {
|
463 |
-
$plural = $type[ 'plural' ];
|
464 |
-
} else {
|
465 |
-
$plural = $name . 's';
|
466 |
-
}
|
467 |
-
|
468 |
-
if ( isset( $type[ 'label' ] ) && $type[ 'label' ] != '' ) {
|
469 |
-
$label = $type[ 'label' ];
|
470 |
-
} else {
|
471 |
-
$label = ucfirst( $name );
|
472 |
-
}
|
473 |
-
|
474 |
-
if ( isset( $type[ 'label_plural' ] ) && $type[ 'label_plural' ] != '' ) {
|
475 |
-
$label_plural = $type[ 'label_plural' ];
|
476 |
-
} else {
|
477 |
-
$label_plural = ucfirst( $plural );
|
478 |
-
}
|
479 |
-
|
480 |
-
$slug = strtoupper( $name );
|
481 |
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
492 |
|
493 |
-
/**
|
494 |
-
* Hooks the plugin into BuddyPress via 'bp_include' action.
|
495 |
-
* Initialises the plugin's functionalities, options,
|
496 |
-
* loads media for Profiles and Groups.
|
497 |
-
* Creates Admin panels
|
498 |
-
* Loads accessory functions
|
499 |
-
*
|
500 |
-
* @global BPMediaAdmin $bp_media_admin
|
501 |
-
*/
|
502 |
-
function init() {
|
503 |
-
|
504 |
-
$this->set_allowed_types(); // Define allowed types
|
505 |
-
$this->constants(); // Define constants
|
506 |
-
$this->set_default_sizes(); // set default sizes
|
507 |
-
$this->set_privacy(); // set privacy
|
508 |
-
|
509 |
-
/**
|
510 |
-
* Load options/settings
|
511 |
-
*/
|
512 |
-
$this->set_site_options();
|
513 |
-
|
514 |
-
/**
|
515 |
-
*
|
516 |
-
* Buddypress Media Auto Upgradation
|
517 |
-
*/
|
518 |
-
$this->update_db();
|
519 |
-
|
520 |
-
/**
|
521 |
-
* Add a settings link to the Plugin list screen
|
522 |
-
*/
|
523 |
-
// add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
|
524 |
|
525 |
-
|
526 |
-
* BuddyPress - Media Navigation Tab Inject
|
527 |
-
*
|
528 |
-
*/
|
529 |
|
|
|
530 |
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
// new BPMediaActivity();
|
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 |
-
new $class();
|
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 |
-
global $rtmedia_buddypress_activity;
|
592 |
-
$rtmedia_buddypress_activity = new RTMediaBuddyPressActivity();
|
593 |
-
$media = new RTMediaMedia();
|
594 |
-
$media->delete_hook();
|
595 |
-
|
596 |
-
|
597 |
-
global $rtmedia_ajax;
|
598 |
-
$rtmedia_ajax = new RTMediaAJAX();
|
599 |
-
|
600 |
-
do_action( 'bp_media_init' ); // legacy For plugin using this actions
|
601 |
-
do_action( 'rtmedia_init' );
|
602 |
-
|
603 |
-
|
604 |
-
}
|
605 |
-
|
606 |
-
/**
|
607 |
-
* Loads translations
|
608 |
-
*/
|
609 |
-
static function load_translation() {
|
610 |
-
load_plugin_textdomain( 'rtmedia', false, basename( RTMEDIA_PATH ) . '/languages/' );
|
611 |
-
}
|
612 |
-
|
613 |
-
|
614 |
-
function check_global_album() {
|
615 |
-
$album = new RTMediaAlbum();
|
616 |
-
$global_album = $album->get_default();
|
617 |
-
//** Hack for plupload default name
|
618 |
-
if ( isset( $_POST[ "action" ] ) && isset( $_POST[ "mode" ] ) && $_POST[ "mode" ] == "file_upload" ) {
|
619 |
-
unset( $_POST[ "name" ] );
|
620 |
-
}
|
621 |
-
|
622 |
-
//**
|
623 |
-
global $rtmedia_error;
|
624 |
-
if(isset($rtmedia_error) && $rtmedia_error===true)
|
625 |
-
return false;
|
626 |
-
if ( ! $global_album ) {
|
627 |
-
$global_album = $album->add_global( __( "Wall Posts", "rtmedia", true ) );
|
628 |
-
}
|
629 |
-
}
|
630 |
-
|
631 |
-
function default_count() {
|
632 |
-
$count = $this->posts_per_page;
|
633 |
-
if ( array_key_exists( 'default_count', $this->options ) ) {
|
634 |
-
$count = $this->options[ 'default_count' ];
|
635 |
-
}
|
636 |
-
$count = ( ! is_int( $count )) ? 0 : $count;
|
637 |
-
return ( ! $count) ? 10 : $count;
|
638 |
-
}
|
639 |
-
|
640 |
-
static function plugin_get_version( $path = NULL ) {
|
641 |
-
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
642 |
-
$path = ($path) ? $path : RTMEDIA_PATH . 'index.php';
|
643 |
-
$plugin_data = get_plugin_data( $path );
|
644 |
-
$plugin_version = $plugin_data[ 'Version' ];
|
645 |
-
return $plugin_version;
|
646 |
-
}
|
647 |
-
|
648 |
-
function update_db() {
|
649 |
-
$rtMigration = new RTMediaMigration();
|
650 |
-
$update = new RTDBUpdate();
|
651 |
-
if ( $update->check_upgrade() ) {
|
652 |
-
$update->do_upgrade();
|
653 |
-
}else{
|
654 |
-
if($update->table_exists($rtMigration->bmp_table) == false){
|
655 |
-
$update->do_upgrade(true);
|
656 |
-
if($update->table_exists($rtMigration->bmp_table) == false){
|
657 |
-
add_action("admin_notice",array(&$this,"create_table_error_notice"));
|
658 |
-
}
|
659 |
-
}
|
660 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
661 |
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
$
|
666 |
-
|
|
|
667 |
}
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
function set_bp_bar() {
|
680 |
-
remove_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
681 |
-
}
|
682 |
-
|
683 |
-
function set_friends_object(){
|
684 |
-
if(is_user_logged_in()){
|
685 |
-
$user = get_current_user_id();
|
686 |
-
$friends = friends_get_friend_user_ids($user);
|
687 |
-
}else{
|
688 |
-
$user = 0;
|
689 |
-
}
|
690 |
-
|
691 |
-
}
|
692 |
-
|
693 |
-
function filter_image_sizes_details($sizes) {
|
694 |
-
if (isset($_REQUEST['post_id'])) {
|
695 |
-
$sizes = $this->unset_bp_media_image_sizes_details($sizes);
|
696 |
-
} elseif (isset($_REQUEST['id'])) { //For Regenerate Thumbnails Plugin
|
697 |
-
if ($parent_id = get_post_field('post_parent', $_REQUEST['id'])) {
|
698 |
-
$post_type = get_post_field('post_type', $parent_id);
|
699 |
-
if ($post_type == 'rtmedia_album') {
|
700 |
-
$bp_media_sizes = $this->image_sizes();
|
701 |
$sizes = array(
|
702 |
-
'rt_media_thumbnail' => $bp_media_sizes['thumbnail'],
|
703 |
-
'rt_media_activity_image' => $bp_media_sizes['activity'],
|
704 |
-
'rt_media_single_image' => $bp_media_sizes['single'],
|
705 |
-
'rt_media_featured_image' => $bp_media_sizes['featured'],
|
706 |
);
|
707 |
} else {
|
708 |
-
$sizes = $this->unset_bp_media_image_sizes_details($sizes);
|
709 |
}
|
710 |
} else {
|
711 |
-
$sizes = $this->unset_bp_media_image_sizes_details($sizes);
|
712 |
}
|
713 |
}
|
714 |
return $sizes;
|
715 |
}
|
716 |
|
717 |
-
function filter_image_sizes($sizes) {
|
718 |
-
if (isset($_REQUEST['postid'])) { //For Regenerate Thumbnails Plugin
|
719 |
-
if ($parent_id = get_post_field('post_parent', $_REQUEST['postid'])) {
|
720 |
-
$post_type = get_post_field('post_type', $parent_id);
|
721 |
-
if ($post_type == 'rtmedia_album') {
|
722 |
$sizes = array(
|
723 |
-
'rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image'
|
724 |
);
|
725 |
} else {
|
726 |
-
$sizes = $this->unset_bp_media_image_sizes($sizes);
|
727 |
}
|
728 |
} else {
|
729 |
-
$sizes = $this->unset_bp_media_image_sizes($sizes);
|
730 |
}
|
731 |
}
|
732 |
|
733 |
return $sizes;
|
734 |
}
|
735 |
|
736 |
-
function unset_bp_media_image_sizes_details($sizes) {
|
737 |
-
if (isset($sizes['rt_media_thumbnail']))
|
738 |
-
unset($sizes['rt_media_thumbnail']);
|
739 |
-
if (isset($sizes['rt_media_activity_image']))
|
740 |
-
unset($sizes['rt_media_activity_image']);
|
741 |
-
if (isset($sizes['rt_media_single_image']))
|
742 |
-
unset($sizes['rt_media_single_image']);
|
|
|
|
|
743 |
return $sizes;
|
744 |
}
|
745 |
|
746 |
-
function unset_bp_media_image_sizes($sizes) {
|
747 |
-
if (($key = array_search('rt_media_thumbnail', $sizes)) !== false)
|
748 |
-
unset($sizes[$key]);
|
749 |
-
if (($key = array_search('rt_media_activity_image', $sizes)) !== false)
|
750 |
-
unset($sizes[$key]);
|
751 |
-
if (($key = array_search('rt_media_single_image', $sizes)) !== false)
|
752 |
-
unset($sizes[$key]);
|
|
|
|
|
753 |
return $sizes;
|
754 |
}
|
755 |
|
756 |
-
|
757 |
-
|
758 |
}
|
759 |
|
760 |
-
function get_rtmedia_permalink( $id ) {
|
761 |
-
|
762 |
|
763 |
-
|
764 |
-
|
765 |
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
|
|
773 |
}
|
|
|
774 |
}
|
|
|
775 |
|
776 |
-
|
777 |
-
|
778 |
-
return trailingslashit( $parent_link . 'media/' . $id );
|
779 |
}
|
780 |
|
781 |
-
function get_rtmedia_user_link( $id ) {
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
}
|
789 |
|
790 |
-
function rtmedia_update_site_option( $option_name, $option_value ) {
|
791 |
-
|
792 |
}
|
793 |
|
794 |
-
function get_rtmedia_group_link( $group_id ){
|
795 |
-
|
796 |
-
|
797 |
}
|
798 |
|
799 |
-
function rtmedia_get_site_option( $option_name, $default = false ) {
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
}
|
812 |
|
813 |
/**
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Don't load this file directly!
|
4 |
*/
|
5 |
+
if ( ! defined ( 'ABSPATH' ) )
|
6 |
+
exit;
|
7 |
|
8 |
/**
|
9 |
* BuddyPress Media
|
19 |
*/
|
20 |
class RTMedia {
|
21 |
|
22 |
+
/**
|
23 |
+
* @var string default thumbnail url fallback for all media types
|
24 |
+
*/
|
25 |
+
private $default_thumbnail;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var array allowed media types
|
30 |
+
*/
|
31 |
+
public $allowed_types;
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @var array privacy settings
|
36 |
+
*/
|
37 |
+
public $privacy_settings;
|
38 |
+
|
39 |
+
/**
|
40 |
+
*
|
41 |
+
* @var array default media sizes
|
42 |
+
*/
|
43 |
+
public $default_sizes;
|
44 |
+
|
45 |
+
/**
|
46 |
+
*
|
47 |
+
* @var object default application wide privacy levels
|
48 |
+
*/
|
49 |
+
public $default_privacy = array(
|
50 |
+
'0' => 'Public',
|
51 |
+
'20' => 'Users',
|
52 |
+
'40' => 'Friends',
|
53 |
+
'60' => 'Private'
|
54 |
+
);
|
55 |
+
|
56 |
+
/**
|
57 |
+
*
|
58 |
+
* @var string Support forum url
|
59 |
+
*/
|
60 |
+
public $support_url = 'http://rtcamp.com/support/forum/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media';
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @var int Number of media items to show in one view.
|
65 |
+
*/
|
66 |
+
public $posts_per_page = 10;
|
67 |
+
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @var array The types of activity BuddyPress Media creates
|
71 |
+
*/
|
72 |
+
public $activity_types = array(
|
73 |
+
'media_upload',
|
74 |
+
'album_updated',
|
75 |
+
'album_created'
|
76 |
+
);
|
77 |
+
public $options;
|
78 |
+
public $render_options;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Constructs the class
|
82 |
+
* Defines constants and excerpt lengths, initiates admin notices,
|
83 |
+
* loads and initiates the plugin, loads translations.
|
84 |
+
* Initialises media counter
|
85 |
+
*
|
86 |
+
* @global int $bp_media_counter Media counter
|
87 |
+
*/
|
88 |
+
public function __construct () {
|
89 |
+
$this->default_thumbnail = apply_filters ( 'rtmedia_default_thumbnail', RTMEDIA_URL . 'assets/thumb_default.png' );
|
90 |
+
|
91 |
+
// check for global album --- after wordpress is fully loaded
|
92 |
+
add_action ( 'init', array( $this, 'check_global_album' ) );
|
93 |
+
|
94 |
+
// Hook it to WordPress
|
95 |
+
add_action ( 'plugins_loaded', array( $this, 'init' ), 20 );
|
96 |
+
|
97 |
+
// Load translations
|
98 |
+
add_action ( 'plugins_loaded', array( $this, 'load_translation' ), 10 );
|
99 |
+
|
100 |
+
//Admin Panel
|
101 |
+
add_action ( 'init', array( $this, 'admin_init' ) );
|
102 |
+
|
103 |
+
add_action ( 'wp_enqueue_scripts', array( 'RTMediaGalleryShortcode', 'register_scripts' ) );
|
104 |
+
//add_action('wp_footer', array('RTMediaGalleryShortcode', 'print_script'));
|
105 |
+
// Enqueue Plugin Scripts and Styles
|
106 |
+
add_action ( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ), 11 );
|
107 |
+
|
108 |
+
|
109 |
+
add_action ( 'rt_db_upgrade', array( $this, 'fix_parent_id' ) );
|
110 |
+
/* Includes db specific wrapper functions required to render the template */
|
111 |
+
include(RTMEDIA_PATH . 'app/main/controllers/template/rt-template-functions.php');
|
112 |
+
|
113 |
+
add_filter ( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_details' ) );
|
114 |
+
add_filter ( 'intermediate_image_sizes', array( $this, 'filter_image_sizes' ) );
|
115 |
+
}
|
116 |
+
|
117 |
+
function fix_parent_id () {
|
118 |
+
$site_global = get_site_option ( 'rtmedia-global-albums' );
|
119 |
+
if ( $site_global && is_array ( $site_global ) && isset ( $site_global[ 0 ] ) ) {
|
120 |
+
$model = new RTMediaModel();
|
121 |
+
$album_row = $model->get_by_id ( $site_global[ 0 ] );
|
122 |
+
if ( isset ( $album_row[ "result" ] ) && count ( $album_row[ "result" ] ) > 0 ) {
|
123 |
+
global $wpdb;
|
124 |
+
$row = $album_row[ "result" ][ 0 ];
|
125 |
+
$sql = "update $wpdb->posts p
|
126 |
+
left join
|
127 |
+
$model->table_name r ON p.ID = r.media_id
|
128 |
+
set
|
129 |
+
post_parent = {$row[ "media_id" ]}
|
130 |
+
where
|
131 |
+
p.guid like '%/rtMedia/%'
|
132 |
+
and (p.post_parent = 0 or p.post_parent is NULL)
|
133 |
+
and not r.id is NULL
|
134 |
+
and r.media_type <> 'album'";
|
135 |
+
$wpdb->query ( $sql );
|
136 |
+
}
|
|
|
137 |
}
|
138 |
+
}
|
139 |
+
|
140 |
+
function set_site_options () {
|
141 |
+
|
142 |
+
$rtmedia_options = rtmedia_get_site_option ( 'rtmedia-options' );
|
143 |
+
$bp_media_options = rtmedia_get_site_option ( 'bp_media_options' );
|
144 |
+
|
145 |
+
if ( $rtmedia_options == false ) {
|
146 |
+
$this->init_site_options ();
|
147 |
+
} else {
|
148 |
+
/* if new options added via filter then it needs to be updated */
|
149 |
+
$this->options = $rtmedia_options;
|
150 |
}
|
151 |
+
$this->add_image_sizes ();
|
152 |
+
}
|
153 |
+
|
154 |
+
public function image_sizes () {
|
155 |
+
$image_sizes = array( );
|
156 |
+
$image_sizes[ "thumbnail" ] = array( "width" => $this->options[ "defaultSizes_photo_thumbnail_width" ], "height" => $this->options[ "defaultSizes_photo_thumbnail_height" ], "crop" => ($this->options[ "defaultSizes_photo_thumbnail_crop" ] == "0") ? false : true );
|
157 |
+
$image_sizes[ "activity" ] = array( "width" => $this->options[ "defaultSizes_photo_medium_width" ], "height" => $this->options[ "defaultSizes_photo_medium_height" ], "crop" => ($this->options[ "defaultSizes_photo_medium_crop" ] == "0") ? false : true );
|
158 |
+
$image_sizes[ "single" ] = array( "width" => $this->options[ "defaultSizes_photo_large_width" ], "height" => $this->options[ "defaultSizes_photo_large_height" ], "crop" => ($this->options[ "defaultSizes_photo_large_crop" ] == "0") ? false : true );
|
159 |
+
$image_sizes[ "featured" ] = array( "width" => $this->options[ "defaultSizes_featured_default_width" ], "height" => $this->options[ "defaultSizes_featured_default_height" ], "crop" => ($this->options[ "defaultSizes_featured_default_crop" ] == "0") ? false : true );
|
160 |
+
return $image_sizes;
|
161 |
+
}
|
162 |
+
|
163 |
+
public function add_image_sizes () {
|
164 |
+
$bp_media_sizes = $this->image_sizes ();
|
165 |
+
add_image_size ( "rt_media_thumbnail", $bp_media_sizes[ 'thumbnail' ][ "width" ], $bp_media_sizes[ 'thumbnail' ][ "height" ], $bp_media_sizes[ 'thumbnail' ][ "crop" ] );
|
166 |
+
add_image_size ( "rt_media_activity_image", $bp_media_sizes[ 'activity' ][ "width" ], $bp_media_sizes[ 'activity' ][ "height" ], $bp_media_sizes[ 'activity' ][ "crop" ] );
|
167 |
+
add_image_size ( "rt_media_single_image", $bp_media_sizes[ 'single' ][ "width" ], $bp_media_sizes[ 'single' ][ "height" ], $bp_media_sizes[ 'single' ][ "crop" ] );
|
168 |
+
add_image_size ( "rt_media_featured_image", $bp_media_sizes[ 'featured' ][ "width" ], $bp_media_sizes[ 'featured' ][ "height" ], $bp_media_sizes[ 'featured' ][ "crop" ] );
|
169 |
+
add_action ( 'wp_footer', array( &$this, 'custome_style_for_activity_image_size' ) );
|
170 |
+
}
|
171 |
+
|
172 |
+
function custome_style_for_activity_image_size () {
|
173 |
+
?>
|
174 |
+
<style>
|
175 |
+
.rtmedia-activity-container .rtmedia-list .rtmedia-item-thumbnail{
|
176 |
+
max-width: <?php echo $this->options[ "defaultSizes_photo_medium_width" ]; ?>px;
|
177 |
+
max-height: <?php echo $this->options[ "defaultSizes_photo_medium_height" ]; ?>px;
|
178 |
+
}
|
179 |
+
.rtmedia-container .rtmedia-list-media li,.rtmedia-container .rtmedia-album-list li {
|
180 |
+
max-width: <?php echo $this->options[ "defaultSizes_photo_thumbnail_width" ]; ?>px;
|
181 |
+
max-height: <?php echo $this->options[ "defaultSizes_photo_thumbnail_height" ]; ?>px;
|
182 |
+
}
|
183 |
+
</style>
|
184 |
+
<?php
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Default allowed media types array
|
189 |
+
*/
|
190 |
+
function set_allowed_types () {
|
191 |
+
$allowed_types = array(
|
192 |
+
'photo' => array(
|
193 |
+
'name' => 'photo',
|
194 |
+
'plural' => 'photos',
|
195 |
+
'label' => __ ( 'Photo', 'rtmedia' ),
|
196 |
+
'plural_label' => __ ( 'Photos', 'rtmedia' ),
|
197 |
+
'extn' => array( 'jpg', 'jpeg', 'png', 'gif' ),
|
198 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/img/image_thumb.png'
|
199 |
+
),
|
200 |
+
'video' => array(
|
201 |
+
'name' => 'video',
|
202 |
+
'plural' => 'videos',
|
203 |
+
'label' => __ ( 'Video', 'rtmedia' ),
|
204 |
+
'plural_label' => __ ( 'Videos', 'rtmedia' ),
|
205 |
+
'extn' => array( 'mp4' ),
|
206 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/img/video_thumb.png'
|
207 |
+
),
|
208 |
+
'music' => array(
|
209 |
+
'name' => 'music',
|
210 |
+
'plural' => 'music',
|
211 |
+
'label' => __ ( 'Music', 'rtmedia' ),
|
212 |
+
'plural_label' => __ ( 'Music', 'rtmedia' ),
|
213 |
+
'extn' => array( 'mp3' ),
|
214 |
+
'thumbnail' => RTMEDIA_URL . 'app/assets/img/audio_thumb.png'
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
+
// filter for hooking additional media types
|
219 |
+
$allowed_types = apply_filters ( 'rtmedia_allowed_types', $allowed_types );
|
220 |
+
|
221 |
+
// sanitize all the types
|
222 |
+
$allowed_types = $this->sanitize_allowed_types ( $allowed_types );
|
223 |
+
|
224 |
+
// set the allowed types property
|
225 |
+
$this->allowed_types = $allowed_types;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Sanitize all media sizes after hooking custom media types
|
230 |
+
*
|
231 |
+
* @param array $allowed_types allowed media types after hooking custom types
|
232 |
+
* @return array $allowed_types sanitized media types
|
233 |
+
*/
|
234 |
+
function sanitize_allowed_types ( $allowed_types ) {
|
235 |
+
// check if the array is formatted properly
|
236 |
+
if ( ! is_array ( $allowed_types ) && count ( $allowed_types ) < 1 )
|
237 |
+
return;
|
238 |
+
|
239 |
+
//loop through each type
|
240 |
+
foreach ( $allowed_types as $key => &$type ) {
|
241 |
+
|
242 |
+
if ( ! isset ( $type[ 'name' ] ) || // check if a name is set
|
243 |
+
empty ( $type[ 'name' ] ) ||
|
244 |
+
! isset ( $type[ 'extn' ] ) || // check if file extensions are set
|
245 |
+
empty ( $type[ 'extn' ] ) || strstr ( $type[ 'name' ], " " ) || strstr ( $type[ 'name' ], "_" ) ) {
|
246 |
+
unset ( $allowed_types[ $key ] ); // if not unset this type
|
247 |
+
continue;
|
248 |
+
}
|
249 |
+
|
250 |
+
// if thumbnail is not supplied, use the default thumbnail
|
251 |
+
if ( ! isset ( $type[ 'thumbnail' ] ) || empty ( $type[ 'thumbnail' ] ) ) {
|
252 |
+
$type[ 'thumbnail' ] = $this->default_thumbnail;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
return $allowed_types;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Set the default sizes
|
260 |
+
*/
|
261 |
+
function set_default_sizes () {
|
262 |
+
$this->default_sizes = array(
|
263 |
+
'photo' => array(
|
264 |
+
'thumbnail' => array( 'width' => 150, 'height' => 150, 'crop' => 1 ),
|
265 |
+
'medium' => array( 'width' => 320, 'height' => 240, 'crop' => 1 ),
|
266 |
+
'large' => array( 'width' => 800, 'height' => 0, 'crop' => 1 )
|
267 |
+
),
|
268 |
+
'video' => array(
|
269 |
+
'activityPlayer' => array( 'width' => 320, 'height' => 240 ),
|
270 |
+
'singlePlayer' => array( 'width' => 640, 'height' => 480 )
|
271 |
+
),
|
272 |
+
'music' => array(
|
273 |
+
'activityPlayer' => array( 'width' => 320 ),
|
274 |
+
'singlePlayer' => array( 'width' => 640 )
|
275 |
+
),
|
276 |
+
'featured' => array(
|
277 |
+
'default' => array( 'width' => 100, 'height' => 100, 'crop' => 1 )
|
278 |
+
)
|
279 |
+
);
|
280 |
+
|
281 |
+
$this->default_sizes = apply_filters ( 'rtmedia_allowed_sizes', $this->default_sizes );
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Set privacy options
|
286 |
+
*/
|
287 |
+
function set_privacy () {
|
288 |
+
|
289 |
+
$this->privacy_settings = array(
|
290 |
+
'levels' => array(
|
291 |
+
60 => __ ( '<strong>Private</strong> - Visible only to the user', 'rtmedia' ),
|
292 |
+
40 => __ ( '<strong>Friends</strong> - Visible to user\'s friends', 'rtmedia' ),
|
293 |
+
20 => __ ( '<strong>Users</strong> - Visible to registered users', 'rtmedia' ),
|
294 |
+
0 => __ ( '<strong>Public</strong> - Visible to the world', 'rtmedia' )
|
295 |
+
)
|
296 |
+
);
|
297 |
+
$this->privacy_settings = apply_filters ( 'rtmedia_privacy_levels', $this->privacy_settings );
|
298 |
+
|
299 |
+
if ( function_exists ( "bp_is_active" ) && ! bp_is_active ( 'friends' ) ) {
|
300 |
+
unset ( $this->privacy_settings[ 'levels' ][ 40 ] );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Load admin screens
|
306 |
+
*
|
307 |
+
* @global RTMediaAdmin $rtmedia_admin Class for loading admin screen
|
308 |
+
*/
|
309 |
+
function admin_init () {
|
310 |
+
global $rtmedia_admin;
|
311 |
+
$rtmedia_admin = new RTMediaAdmin();
|
312 |
+
}
|
313 |
+
|
314 |
+
function media_screen () {
|
315 |
+
return;
|
316 |
+
}
|
317 |
+
|
318 |
+
function get_user_link ( $user ) {
|
319 |
+
|
320 |
+
if ( function_exists ( 'bp_core_get_user_domain' ) ) {
|
321 |
+
$parent_link = bp_core_get_user_domain ( $user );
|
322 |
+
} else {
|
323 |
+
$parent_link = get_author_posts_url ( $user );
|
324 |
+
}
|
325 |
+
|
326 |
+
return $parent_link;
|
327 |
+
}
|
328 |
+
|
329 |
+
public function init_buddypress_options () {
|
330 |
+
/**
|
331 |
+
* BuddyPress Settings
|
332 |
+
*/
|
333 |
+
$bp_media_options = rtmedia_get_site_option ( 'bp_media_options' );
|
334 |
+
|
335 |
+
$group = 0;
|
336 |
+
if ( isset ( $bp_media_options[ 'enable_on_group' ] ) && ! empty ( $bp_media_options[ 'enable_on_group' ] ) )
|
337 |
+
$group = $bp_media_options[ 'enable_on_group' ];
|
338 |
+
else if ( function_exists ( "bp_is_active" ) )
|
339 |
+
$group = bp_is_active ( 'groups' );
|
340 |
+
$this->options[ 'buddypress_enableOnGroup' ] = $group;
|
341 |
+
|
342 |
+
$activity = 0;
|
343 |
+
if ( isset ( $bp_media_options[ 'activity_upload' ] ) && ! empty ( $bp_media_options[ 'activity_upload' ] ) )
|
344 |
+
$activity = $bp_media_options[ 'activity_upload' ];
|
345 |
+
else if ( function_exists ( "bp_is_active" ) )
|
346 |
+
$activity = bp_is_active ( 'activity' );
|
347 |
+
$this->options[ 'buddypress_enableOnActivity' ] = $activity;
|
348 |
+
|
349 |
+
$this->options[ 'buddypress_enableOnProfile' ] = 1;
|
350 |
+
|
351 |
+
/* Last settings updated in options. Update them in DB & after this no other option would be saved in db */
|
352 |
+
rtmedia_update_site_option ( 'rtmedia-options', $this->options );
|
353 |
+
}
|
354 |
+
|
355 |
+
public function init_site_options () {
|
356 |
+
|
357 |
+
$bp_media_options = rtmedia_get_site_option ( 'bp_media_options' );
|
358 |
+
|
359 |
+
$defaults = array(
|
360 |
+
'general_enableAlbums' => 0,
|
361 |
+
'general_enableComments' => 0,
|
362 |
+
'general_downloadButton' => (isset ( $bp_media_options[ 'download_enabled' ] )) ? $bp_media_options[ 'download_enabled' ] : 0,
|
363 |
+
'general_enableLightbox' => (isset ( $bp_media_options[ 'enable_lightbox' ] )) ? $bp_media_options[ 'enable_lightbox' ] : 0,
|
364 |
+
'general_perPageMedia' => (isset ( $bp_media_options[ 'default_count' ] )) ? $bp_media_options[ 'default_count' ] : 10,
|
365 |
+
'general_enableMediaEndPoint' => 0,
|
366 |
+
'general_showAdminMenu' => (isset ( $bp_media_options[ 'show_admin_menu' ] )) ? $bp_media_options[ 'show_admin_menu' ] : 0,
|
367 |
+
);
|
368 |
+
|
369 |
+
|
370 |
+
foreach ( $this->allowed_types as $type ) {
|
371 |
+
// invalid keys handled in sanitize method
|
372 |
+
$defaults[ 'allowedTypes_' . $type[ 'name' ] . '_enabled' ] = 1;
|
373 |
+
$defaults[ 'allowedTypes_' . $type[ 'name' ] . '_featured' ] = 0;
|
374 |
+
}
|
375 |
+
|
376 |
+
/* Previous Sizes values from buddypress is migrated */
|
377 |
+
foreach ( $this->default_sizes as $type => $typeValue ) {
|
378 |
+
foreach ( $typeValue as $size => $sizeValue ) {
|
379 |
+
foreach ( $sizeValue as $dimension => $value ) {
|
380 |
+
switch ( $type ) {
|
381 |
+
case 'photo':
|
382 |
+
if ( isset ( $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ] ) && ! empty ( $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ] ) )
|
383 |
+
$value = $bp_media_options[ 'sizes' ][ 'image' ][ $size ][ $dimension ];
|
384 |
+
break;
|
385 |
+
case 'video':
|
386 |
+
case 'music':
|
387 |
+
$old = ($type == 'video') ? 'video' : ($type == 'music') ? 'audio' : '';
|
388 |
+
switch ( $size ) {
|
389 |
+
case 'activityPlayer':
|
390 |
+
if ( isset ( $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ] ) && ! empty ( $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ] ) )
|
391 |
+
$value = $bp_media_options[ 'sizes' ][ $old ][ 'medium' ][ $dimension ];
|
392 |
+
break;
|
393 |
+
case 'singlePlayer':
|
394 |
+
if ( isset ( $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ] ) && ! empty ( $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ] ) )
|
395 |
+
$value = $bp_media_options[ 'sizes' ][ $old ][ 'large' ][ $dimension ];
|
396 |
+
break;
|
397 |
+
}
|
398 |
+
break;
|
399 |
+
}
|
400 |
+
$defaults[ 'defaultSizes_' . $type . '_' . $size . '_' . $dimension ] = $value;
|
401 |
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
/* Privacy */
|
406 |
+
$defaults[ 'privacy_enabled' ] = (isset ( $bp_media_options[ 'privacy_enabled' ] )) ? $bp_media_options[ 'privacy_enabled' ] : 0;
|
407 |
+
$defaults[ 'privacy_default' ] = (isset ( $bp_media_options[ 'default_privacy_level' ] )) ? $bp_media_options[ 'default_privacy_level' ] : 0;
|
408 |
+
$defaults[ 'privacy_userOverride' ] = (isset ( $bp_media_options[ 'privacy_override_enabled' ] )) ? $bp_media_options[ 'privacy_override_enabled' ] : 0;
|
409 |
+
|
410 |
+
$this->options = $defaults;
|
411 |
+
|
412 |
+
$this->init_buddypress_options ();
|
413 |
+
}
|
414 |
|
415 |
/**
|
416 |
+
* Defines all the constants if undefined. Can be overridden by
|
417 |
+
* defining them elsewhere, say wp-config.php
|
418 |
+
*/
|
419 |
+
public function constants () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
421 |
+
/* If the plugin is installed. */
|
422 |
+
if ( ! defined ( 'RTMEDIA_IS_INSTALLED' ) )
|
423 |
+
define ( 'RTMEDIA_IS_INSTALLED', 1 );
|
424 |
+
|
425 |
+
/* Current Version. */
|
426 |
+
if ( ! defined ( 'RTMEDIA_VERSION' ) )
|
427 |
+
define ( 'RTMEDIA_VERSION', '3.0.0' );
|
428 |
+
|
429 |
+
/* Required Version */
|
430 |
+
if ( ! defined ( 'RTMEDIA_REQUIRED_BP' ) )
|
431 |
+
define ( 'RTMEDIA_REQUIRED_BP', '1.7' );
|
432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
|
434 |
+
/* Slug Constants for building urls */
|
|
|
|
|
|
|
435 |
|
436 |
+
/* Media slugs */
|
437 |
|
438 |
+
if ( ! defined ( 'RTMEDIA_MEDIA_SLUG' ) )
|
439 |
+
define ( 'RTMEDIA_MEDIA_SLUG', 'media' );
|
440 |
+
|
441 |
+
if ( ! defined ( 'RTMEDIA_MEDIA_LABEL' ) )
|
442 |
+
define ( 'RTMEDIA_MEDIA_LABEL', __ ( 'Media', 'rtmedia' ) );
|
443 |
+
|
444 |
+
if ( ! defined ( 'RTMEDIA_ALL_SLUG' ) )
|
445 |
+
define ( 'RTMEDIA_ALL_SLUG', 'all' );
|
446 |
+
|
447 |
+
if ( ! defined ( 'RTMEDIA_ALL_LABEL' ) )
|
448 |
+
define ( 'RTMEDIA_ALL_LABEL', __ ( 'All', 'rtmedia' ) );
|
449 |
+
|
450 |
+
if ( ! defined ( 'RTMEDIA_ALBUM_SLUG' ) )
|
451 |
+
define ( 'RTMEDIA_ALBUM_SLUG', 'album' );
|
452 |
+
|
453 |
+
if ( ! defined ( 'RTMEDIA_ALBUM_PLURAL_SLUG' ) )
|
454 |
+
define ( 'RTMEDIA_ALBUM_PLURAL_SLUG', 'albums' );
|
455 |
+
|
456 |
+
if ( ! defined ( 'RTMEDIA_ALBUM_LABEL' ) )
|
457 |
+
define ( 'RTMEDIA_ALBUM_LABEL', __ ( 'Album', 'rtmedia' ) );
|
458 |
+
|
459 |
+
if ( ! defined ( 'RTMEDIA_ALBUM_PLURAL_LABEL' ) )
|
460 |
+
define ( 'RTMEDIA_ALBUM_PLURAL_LABEL', __ ( 'Albums', 'rtmedia' ) );
|
461 |
+
|
462 |
+
/* Upload slug */
|
463 |
+
if ( ! defined ( 'RTMEDIA_UPLOAD_SLUG' ) )
|
464 |
+
define ( 'RTMEDIA_UPLOAD_SLUG', 'upload' );
|
465 |
+
|
466 |
+
/* Upload slug */
|
467 |
+
if ( ! defined ( 'RTMEDIA_UPLOAD_LABEL' ) )
|
468 |
+
define ( 'RTMEDIA_UPLOAD_LABEL', __ ( 'Upload', 'rtmedia' ) );
|
469 |
+
|
470 |
+
/* Global Album/Wall Post */
|
471 |
+
if ( ! defined ( 'RTMEDIA_GLOBAL_ALBUM_LABEL' ) )
|
472 |
+
define ( 'RTMEDIA_GLOBAL_ALBUM_LABEL', __ ( 'Wall Post', 'rtmedia' ) );
|
473 |
+
|
474 |
+
$this->define_type_constants ();
|
475 |
+
}
|
476 |
+
|
477 |
+
function define_type_constants () {
|
478 |
+
|
479 |
+
if ( ! isset ( $this->allowed_types ) )
|
480 |
+
return;
|
481 |
+
foreach ( $this->allowed_types as $type ) {
|
482 |
+
|
483 |
+
if ( ! isset ( $type[ 'name' ] ) || $type[ 'name' ] === '' )
|
484 |
+
continue;
|
485 |
+
|
486 |
+
$name = $type[ 'name' ];
|
487 |
+
|
488 |
+
if ( isset ( $type[ 'plural' ] ) && $type[ 'plural' ] != '' ) {
|
489 |
+
$plural = $type[ 'plural' ];
|
490 |
+
} else {
|
491 |
+
$plural = $name . 's';
|
492 |
+
}
|
493 |
+
|
494 |
+
if ( isset ( $type[ 'label' ] ) && $type[ 'label' ] != '' ) {
|
495 |
+
$label = $type[ 'label' ];
|
496 |
+
} else {
|
497 |
+
$label = ucfirst ( $name );
|
498 |
+
}
|
499 |
+
|
500 |
+
if ( isset ( $type[ 'label_plural' ] ) && $type[ 'label_plural' ] != '' ) {
|
501 |
+
$label_plural = $type[ 'label_plural' ];
|
502 |
+
} else {
|
503 |
+
$label_plural = ucfirst ( $plural );
|
504 |
+
}
|
505 |
+
|
506 |
+
$slug = strtoupper ( $name );
|
507 |
+
|
508 |
+
if ( ! defined ( 'RTMEDIA_' . $slug . '_SLUG' ) )
|
509 |
+
define ( 'RTMEDIA_' . $slug . '_SLUG', $name );
|
510 |
+
if ( ! defined ( 'RTMEDIA_' . $slug . '_PLURAL_SLUG' ) )
|
511 |
+
define ( 'RTMEDIA_' . $slug . '_PLURAL_SLUG', $plural );
|
512 |
+
if ( ! defined ( 'RTMEDIA_' . $slug . '_LABEL' ) )
|
513 |
+
define ( 'RTMEDIA_' . $slug . '_LABEL', $label );
|
514 |
+
if ( ! defined ( 'RTMEDIA_' . $slug . '_PLURAL_LABEL' ) )
|
515 |
+
define ( 'RTMEDIA_' . $slug . '_PLURAL_LABEL', $label_plural );
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Hooks the plugin into BuddyPress via 'bp_include' action.
|
521 |
+
* Initialises the plugin's functionalities, options,
|
522 |
+
* loads media for Profiles and Groups.
|
523 |
+
* Creates Admin panels
|
524 |
+
* Loads accessory functions
|
525 |
+
*
|
526 |
+
* @global BPMediaAdmin $bp_media_admin
|
527 |
+
*/
|
528 |
+
function init () {
|
529 |
+
|
530 |
+
$this->set_allowed_types (); // Define allowed types
|
531 |
+
$this->constants (); // Define constants
|
532 |
+
$this->redirect_on_change_slug ();
|
533 |
+
$this->set_default_sizes (); // set default sizes
|
534 |
+
$this->set_privacy (); // set privacy
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Load options/settings
|
538 |
+
*/
|
539 |
+
$this->set_site_options ();
|
540 |
+
|
541 |
+
/**
|
542 |
+
*
|
543 |
+
* Buddypress Media Auto Upgradation
|
544 |
+
*/
|
545 |
+
$this->update_db ();
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Add a settings link to the Plugin list screen
|
549 |
+
*/
|
550 |
+
// add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
|
551 |
+
|
552 |
+
/**
|
553 |
+
* BuddyPress - Media Navigation Tab Inject
|
554 |
+
*
|
555 |
+
*/
|
556 |
+
/**
|
557 |
+
* Load accessory functions
|
558 |
+
*/
|
559 |
// new BPMediaActivity();
|
560 |
+
$class_construct = array(
|
561 |
+
'deprecated' => true,
|
562 |
+
'interaction' => true,
|
563 |
+
//'template' => false,
|
564 |
+
'upload_shortcode' => false,
|
565 |
+
'gallery_shortcode' => false,
|
566 |
+
'upload_endpoint' => false,
|
567 |
+
'privacy' => false,
|
568 |
+
'nav' => true,
|
569 |
+
'like' => false,
|
570 |
+
'cover_art' => false,
|
571 |
+
'featured' => false,
|
572 |
+
'Group' => false
|
573 |
+
//'query' => false
|
574 |
+
);
|
575 |
+
global $rtmedia_nav;
|
576 |
+
|
577 |
+
/** Legacy code for Add-ons * */
|
578 |
+
$bp_class_construct = apply_filters ( 'bpmedia_class_construct', array( ) );
|
579 |
+
foreach ( $bp_class_construct as $classname => $global_scope ) {
|
580 |
+
$class = 'BPMedia' . ucfirst ( $classname );
|
581 |
+
if ( class_exists ( $class ) ) {
|
582 |
+
if ( $global_scope == true ) {
|
583 |
+
global ${'bp_media_' . $classname};
|
584 |
+
${'bp_media_' . $classname} = new $class();
|
585 |
+
} else {
|
586 |
+
new $class();
|
|
|
|
|
|
|
587 |
}
|
588 |
+
}
|
589 |
+
}
|
590 |
+
/** ------------------- * */
|
591 |
+
$class_construct = apply_filters ( 'rtmedia_class_construct', $class_construct );
|
592 |
+
|
593 |
+
foreach ( $class_construct as $key => $global_scope ) {
|
594 |
+
$classname = '';
|
595 |
+
$ck = explode ( '_', $key );
|
596 |
+
|
597 |
+
foreach ( $ck as $cn ) {
|
598 |
+
$classname .= ucfirst ( $cn );
|
599 |
+
}
|
600 |
+
|
601 |
+
$class = 'RTMedia' . $classname;
|
602 |
+
|
603 |
+
if ( class_exists ( $class ) ) {
|
604 |
+
if ( $global_scope == true ) {
|
605 |
+
global ${'rtmedia_' . $key};
|
606 |
+
${'rtmedia_' . $key} = new $class();
|
607 |
+
} else {
|
608 |
+
new $class();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
609 |
}
|
610 |
+
}
|
611 |
+
}
|
612 |
+
|
613 |
+
|
614 |
+
global $rtmedia_buddypress_activity;
|
615 |
+
$rtmedia_buddypress_activity = new RTMediaBuddyPressActivity();
|
616 |
+
$media = new RTMediaMedia();
|
617 |
+
$media->delete_hook ();
|
618 |
+
|
619 |
+
|
620 |
+
global $rtmedia_ajax;
|
621 |
+
$rtmedia_ajax = new RTMediaAJAX();
|
622 |
+
|
623 |
+
do_action ( 'bp_media_init' ); // legacy For plugin using this actions
|
624 |
+
do_action ( 'rtmedia_init' );
|
625 |
+
}
|
626 |
+
|
627 |
+
function redirect_on_change_slug () {
|
628 |
+
$old_slugs = get_site_option ( "rtmedia_old_media_slug", false, true );
|
629 |
+
$current_slugs = get_site_option ( "rtmedia_current_media_slug", false, false );
|
630 |
+
if ( $current_slugs === false ) {
|
631 |
+
update_site_option ( "rtmedia_current_media_slug", RTMEDIA_MEDIA_SLUG );
|
632 |
+
return;
|
633 |
+
}
|
634 |
+
if ( $current_slugs === RTMEDIA_MEDIA_SLUG )
|
635 |
+
return;
|
636 |
+
if ( $old_slugs === false )
|
637 |
+
$old_slugs = array( );
|
638 |
+
$old_slugs[ ] = $current_slugs;
|
639 |
+
update_site_option ( "rtmedia_current_media_slug", RTMEDIA_MEDIA_SLUG );
|
640 |
+
}
|
641 |
+
|
642 |
+
/**
|
643 |
+
* Loads translations
|
644 |
+
*/
|
645 |
+
static function load_translation () {
|
646 |
+
load_plugin_textdomain ( 'rtmedia', false, basename ( RTMEDIA_PATH ) . '/languages/' );
|
647 |
+
}
|
648 |
+
|
649 |
+
function check_global_album () {
|
650 |
+
$album = new RTMediaAlbum();
|
651 |
+
$global_album = $album->get_default ();
|
652 |
+
//** Hack for plupload default name
|
653 |
+
if ( isset ( $_POST[ "action" ] ) && isset ( $_POST[ "mode" ] ) && $_POST[ "mode" ] == "file_upload" ) {
|
654 |
+
unset ( $_POST[ "name" ] );
|
655 |
+
}
|
656 |
+
|
657 |
+
//**
|
658 |
+
global $rtmedia_error;
|
659 |
+
if ( isset ( $rtmedia_error ) && $rtmedia_error === true )
|
660 |
+
return false;
|
661 |
+
if ( ! $global_album ) {
|
662 |
+
$global_album = $album->add_global ( __ ( "Wall Posts", "rtmedia", true ) );
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
function default_count () {
|
667 |
+
$count = $this->posts_per_page;
|
668 |
+
if ( array_key_exists ( 'default_count', $this->options ) ) {
|
669 |
+
$count = $this->options[ 'default_count' ];
|
670 |
+
}
|
671 |
+
$count = ( ! is_int ( $count )) ? 0 : $count;
|
672 |
+
return ( ! $count) ? 10 : $count;
|
673 |
+
}
|
674 |
+
|
675 |
+
static function plugin_get_version ( $path = NULL ) {
|
676 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
677 |
+
$path = ($path) ? $path : RTMEDIA_PATH . 'index.php';
|
678 |
+
$plugin_data = get_plugin_data ( $path );
|
679 |
+
$plugin_version = $plugin_data[ 'Version' ];
|
680 |
+
return $plugin_version;
|
681 |
+
}
|
682 |
+
|
683 |
+
function update_db () {
|
684 |
+
$rtMigration = new RTMediaMigration();
|
685 |
+
$update = new RTDBUpdate();
|
686 |
+
if ( $update->check_upgrade () ) {
|
687 |
+
$update->do_upgrade ();
|
688 |
+
} else {
|
689 |
+
if ( $update->table_exists ( $rtMigration->bmp_table ) == false ) {
|
690 |
+
$update->do_upgrade ( true );
|
691 |
+
if ( $update->table_exists ( $rtMigration->bmp_table ) == false ) {
|
692 |
+
add_action ( "admin_notice", array( &$this, "create_table_error_notice" ) );
|
693 |
+
}
|
694 |
+
}
|
695 |
+
}
|
696 |
+
}
|
697 |
+
|
698 |
+
function create_table_error_notice () {
|
699 |
+
global $rtmedia_error;
|
700 |
+
$rtmedia_error = true;
|
701 |
+
echo "<div class='error'><p><strong>rtMedia</strong>: Can't Create Database table. Please check create table permission.</p></div>";
|
702 |
+
}
|
703 |
+
|
704 |
+
function enqueue_scripts_styles () {
|
705 |
+
wp_enqueue_script ( 'rtmedia-mejs', RTMEDIA_URL . 'lib/media-element/mediaelement-and-player.min.js', '', RTMEDIA_VERSION );
|
706 |
+
wp_enqueue_style ( 'rtmedia-mecss', RTMEDIA_URL . 'lib/media-element/mediaelementplayer.min.css', '', RTMEDIA_VERSION );
|
707 |
+
wp_enqueue_style ( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/main.css', '', RTMEDIA_VERSION );
|
708 |
+
wp_enqueue_script ( 'rtmedia-main', RTMEDIA_URL . 'app/assets/js/rtMedia.js', array( 'jquery', 'rtmedia-mejs' ), RTMEDIA_VERSION );
|
709 |
+
wp_enqueue_style ( 'rtmedia-magnific', RTMEDIA_URL . 'lib/magnific/magnific.css', '', RTMEDIA_VERSION );
|
710 |
+
wp_enqueue_script ( 'rtmedia-magnific', RTMEDIA_URL . 'lib/magnific/magnific.js', '', RTMEDIA_VERSION );
|
711 |
+
wp_localize_script ( 'rtmedia-main', 'rtmedia_ajax_url', admin_url ( 'admin-ajax.php' ) );
|
712 |
+
wp_localize_script ( 'rtmedia-main', 'rtmedia_lightbox_enabled', strval ( $this->options[ "general_enableLightbox" ] ) );
|
713 |
+
}
|
714 |
+
|
715 |
+
function set_bp_bar () {
|
716 |
+
remove_action ( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
717 |
+
}
|
718 |
|
719 |
+
function set_friends_object () {
|
720 |
+
if ( is_user_logged_in () ) {
|
721 |
+
$user = get_current_user_id ();
|
722 |
+
$friends = friends_get_friend_user_ids ( $user );
|
723 |
+
} else {
|
724 |
+
$user = 0;
|
725 |
}
|
726 |
+
}
|
727 |
+
|
728 |
+
function filter_image_sizes_details ( $sizes ) {
|
729 |
+
if ( isset ( $_REQUEST[ 'post_id' ] ) ) {
|
730 |
+
$sizes = $this->unset_bp_media_image_sizes_details ( $sizes );
|
731 |
+
} elseif ( isset ( $_REQUEST[ 'id' ] ) ) { //For Regenerate Thumbnails Plugin
|
732 |
+
$model = new RTMediaModel();
|
733 |
+
$result = $model->get_by_media_id ( $_REQUEST[ 'id' ] );
|
734 |
+
if ( $result ) {
|
735 |
+
if ( isset ( $result[ "result" ] ) && count ( $result[ "result" ] ) > 0 ) {
|
736 |
+
$bp_media_sizes = $this->image_sizes ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
737 |
$sizes = array(
|
738 |
+
'rt_media_thumbnail' => $bp_media_sizes[ 'thumbnail' ],
|
739 |
+
'rt_media_activity_image' => $bp_media_sizes[ 'activity' ],
|
740 |
+
'rt_media_single_image' => $bp_media_sizes[ 'single' ],
|
741 |
+
'rt_media_featured_image' => $bp_media_sizes[ 'featured' ],
|
742 |
);
|
743 |
} else {
|
744 |
+
$sizes = $this->unset_bp_media_image_sizes_details ( $sizes );
|
745 |
}
|
746 |
} else {
|
747 |
+
$sizes = $this->unset_bp_media_image_sizes_details ( $sizes );
|
748 |
}
|
749 |
}
|
750 |
return $sizes;
|
751 |
}
|
752 |
|
753 |
+
function filter_image_sizes ( $sizes ) {
|
754 |
+
if ( isset ( $_REQUEST[ 'postid' ] ) ) { //For Regenerate Thumbnails Plugin
|
755 |
+
if ( $parent_id = get_post_field ( 'post_parent', $_REQUEST[ 'postid' ] ) ) {
|
756 |
+
$post_type = get_post_field ( 'post_type', $parent_id );
|
757 |
+
if ( $post_type == 'rtmedia_album' ) {
|
758 |
$sizes = array(
|
759 |
+
'rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image', 'rt_media_featured_image'
|
760 |
);
|
761 |
} else {
|
762 |
+
$sizes = $this->unset_bp_media_image_sizes ( $sizes );
|
763 |
}
|
764 |
} else {
|
765 |
+
$sizes = $this->unset_bp_media_image_sizes ( $sizes );
|
766 |
}
|
767 |
}
|
768 |
|
769 |
return $sizes;
|
770 |
}
|
771 |
|
772 |
+
function unset_bp_media_image_sizes_details ( $sizes ) {
|
773 |
+
if ( isset ( $sizes[ 'rt_media_thumbnail' ] ) )
|
774 |
+
unset ( $sizes[ 'rt_media_thumbnail' ] );
|
775 |
+
if ( isset ( $sizes[ 'rt_media_activity_image' ] ) )
|
776 |
+
unset ( $sizes[ 'rt_media_activity_image' ] );
|
777 |
+
if ( isset ( $sizes[ 'rt_media_single_image' ] ) )
|
778 |
+
unset ( $sizes[ 'rt_media_single_image' ] );
|
779 |
+
if ( isset ( $sizes[ 'rt_media_featured_image' ] ) )
|
780 |
+
unset ( $sizes[ 'rt_media_featured_image' ] );
|
781 |
return $sizes;
|
782 |
}
|
783 |
|
784 |
+
function unset_bp_media_image_sizes ( $sizes ) {
|
785 |
+
if ( ($key = array_search ( 'rt_media_thumbnail', $sizes )) !== false )
|
786 |
+
unset ( $sizes[ $key ] );
|
787 |
+
if ( ($key = array_search ( 'rt_media_activity_image', $sizes )) !== false )
|
788 |
+
unset ( $sizes[ $key ] );
|
789 |
+
if ( ($key = array_search ( 'rt_media_single_image', $sizes )) !== false )
|
790 |
+
unset ( $sizes[ $key ] );
|
791 |
+
if ( ($key = array_search ( 'rt_media_featured_image', $sizes )) !== false )
|
792 |
+
unset ( $sizes[ $key ] );
|
793 |
return $sizes;
|
794 |
}
|
795 |
|
|
|
|
|
796 |
}
|
797 |
|
798 |
+
function get_rtmedia_permalink ( $id ) {
|
799 |
+
$mediaModel = new RTMediaModel();
|
800 |
|
801 |
+
$media = $mediaModel->get ( array( 'id' => $id ) );
|
802 |
+
global $rtmedia_query;
|
803 |
|
804 |
+
if ( $media[ 0 ]->context == 'group' )
|
805 |
+
$parent_link = get_rtmedia_group_link ( $media[ 0 ]->context_id );
|
806 |
+
else {
|
807 |
+
if ( isset ( $rtmedia_query->query ) && isset ( $rtmedia_query->query[ "context" ] ) && $rtmedia_query->query[ "context" ] == "group" ) {
|
808 |
+
$parent_link = get_rtmedia_group_link ( $rtmedia_query->query[ "context_id" ] );
|
809 |
+
} else {
|
810 |
+
if ( ! isset ( $media[ 0 ]->context ) ) {
|
811 |
+
$media[ 0 ]->media_author = $rtmedia_query->query[ "context_id" ];
|
812 |
}
|
813 |
+
$parent_link = get_rtmedia_user_link ( $media[ 0 ]->media_author );
|
814 |
}
|
815 |
+
}
|
816 |
|
817 |
+
$parent_link = trailingslashit ( $parent_link );
|
818 |
+
return trailingslashit ( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $id );
|
|
|
819 |
}
|
820 |
|
821 |
+
function get_rtmedia_user_link ( $id ) {
|
822 |
+
if ( function_exists ( 'bp_core_get_user_domain' ) ) {
|
823 |
+
$parent_link = bp_core_get_user_domain ( $id );
|
824 |
+
} else {
|
825 |
+
$parent_link = get_author_posts_url ( $id );
|
826 |
+
}
|
827 |
+
return $parent_link;
|
828 |
}
|
829 |
|
830 |
+
function rtmedia_update_site_option ( $option_name, $option_value ) {
|
831 |
+
update_site_option ( $option_name, $option_value );
|
832 |
}
|
833 |
|
834 |
+
function get_rtmedia_group_link ( $group_id ) {
|
835 |
+
$group = groups_get_group ( array( 'group_id' => $group_id ) );
|
836 |
+
return home_url ( bp_get_groups_root_slug () . '/' . $group->slug );
|
837 |
}
|
838 |
|
839 |
+
function rtmedia_get_site_option ( $option_name, $default = false ) {
|
840 |
+
$return_val = get_site_option ( $option_name );
|
841 |
+
if ( $return_val === false ) {
|
842 |
+
if ( function_exists ( "bp_get_option" ) ) {
|
843 |
+
$return_val = bp_get_option ( $option_name, $default );
|
844 |
+
rtmedia_update_site_option ( $option_name, $return_val );
|
845 |
+
}
|
846 |
+
}
|
847 |
+
if ( $default !== false && $return_val === false ) {
|
848 |
+
$return_val = $default;
|
849 |
+
}
|
850 |
+
return $return_val;
|
851 |
}
|
852 |
|
853 |
/**
|
app/main/contexts/RTMediaContext.php
CHANGED
@@ -23,26 +23,26 @@ class RTMediaContext {
|
|
23 |
* $type - Context Type. It can be any type among these. (post, page, custom_post, home_page, archive etc.)
|
24 |
* $id - context id of the context
|
25 |
*/
|
26 |
-
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
* @return \RTMediaContext
|
31 |
*/
|
32 |
-
function __construct() {
|
33 |
-
$this->set_context();
|
34 |
return $this;
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
*
|
39 |
*/
|
40 |
-
function set_context() {
|
41 |
global $post;
|
42 |
-
if (class_exists('BuddyPress')) {
|
43 |
-
$this->set_bp_context();
|
44 |
} else {
|
45 |
-
$this->set_wp_context();
|
46 |
}
|
47 |
}
|
48 |
|
@@ -50,50 +50,53 @@ class RTMediaContext {
|
|
50 |
*
|
51 |
* @global type $post
|
52 |
*/
|
53 |
-
function set_wp_context() {
|
54 |
global $post;
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
$this->type = $post->post_type;
|
60 |
$this->id = $post->ID;
|
61 |
-
|
|
|
|
|
|
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
*
|
66 |
*/
|
67 |
-
function set_bp_context() {
|
68 |
-
if (bp_is_blog_page()) {
|
69 |
-
$this->set_wp_context();
|
70 |
} else {
|
71 |
-
$this->set_bp_component_context();
|
72 |
}
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
*
|
77 |
*/
|
78 |
-
function set_bp_component_context() {
|
79 |
-
if (bp_displayed_user_id() && !bp_is_group())
|
80 |
$this->type = 'profile';
|
81 |
-
else if (!bp_displayed_user_id() && bp_is_group())
|
82 |
$this->type = 'group';
|
83 |
|
84 |
-
$this->id = $this->get_current_bp_component_id();
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
*
|
89 |
* @return type
|
90 |
*/
|
91 |
-
function get_current_bp_component_id() {
|
92 |
-
switch (bp_current_component()) {
|
93 |
-
case 'groups': return bp_get_current_group_id();
|
94 |
break;
|
95 |
default:
|
96 |
-
return bp_displayed_user_id();
|
97 |
break;
|
98 |
}
|
99 |
}
|
23 |
* $type - Context Type. It can be any type among these. (post, page, custom_post, home_page, archive etc.)
|
24 |
* $id - context id of the context
|
25 |
*/
|
26 |
+
public $type, $id;
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
* @return \RTMediaContext
|
31 |
*/
|
32 |
+
function __construct () {
|
33 |
+
$this->set_context ();
|
34 |
return $this;
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
*
|
39 |
*/
|
40 |
+
function set_context () {
|
41 |
global $post;
|
42 |
+
if ( class_exists ( 'BuddyPress' ) ) {
|
43 |
+
$this->set_bp_context ();
|
44 |
} else {
|
45 |
+
$this->set_wp_context ();
|
46 |
}
|
47 |
}
|
48 |
|
50 |
*
|
51 |
* @global type $post
|
52 |
*/
|
53 |
+
function set_wp_context () {
|
54 |
global $post;
|
55 |
+
if ( is_author () ) {
|
56 |
+
$this->type = 'profile';
|
57 |
+
$this->id = get_query_var ( 'author' );
|
58 |
+
} elseif ( isset ( $post->post_type ) ) {
|
59 |
$this->type = $post->post_type;
|
60 |
$this->id = $post->ID;
|
61 |
+
} else {
|
62 |
+
$this->type = 'profile';
|
63 |
+
$this->id = get_current_user_id ();
|
64 |
+
}
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
*
|
69 |
*/
|
70 |
+
function set_bp_context () {
|
71 |
+
if ( bp_is_blog_page () ) {
|
72 |
+
$this->set_wp_context ();
|
73 |
} else {
|
74 |
+
$this->set_bp_component_context ();
|
75 |
}
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
*
|
80 |
*/
|
81 |
+
function set_bp_component_context () {
|
82 |
+
if ( bp_displayed_user_id () && ! bp_is_group () )
|
83 |
$this->type = 'profile';
|
84 |
+
else if ( ! bp_displayed_user_id () && bp_is_group () )
|
85 |
$this->type = 'group';
|
86 |
|
87 |
+
$this->id = $this->get_current_bp_component_id ();
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
*
|
92 |
* @return type
|
93 |
*/
|
94 |
+
function get_current_bp_component_id () {
|
95 |
+
switch ( bp_current_component () ) {
|
96 |
+
case 'groups': return bp_get_current_group_id ();
|
97 |
break;
|
98 |
default:
|
99 |
+
return bp_displayed_user_id ();
|
100 |
break;
|
101 |
}
|
102 |
}
|
app/main/controllers/activity/RTMediaBuddyPressActivity.php
CHANGED
@@ -12,174 +12,172 @@
|
|
12 |
*/
|
13 |
class RTMediaBuddyPressActivity {
|
14 |
|
15 |
-
function __construct() {
|
16 |
global $rtmedia;
|
17 |
-
if ($rtmedia->options["buddypress_enableOnActivity"] !== 0) {
|
18 |
-
add_action("bp_after_activity_post_form", array(&$this, "bp_after_activity_post_form"));
|
19 |
-
add_action("bp_activity_posted_update", array(&$this, "bp_activity_posted_update"), 99, 3);
|
20 |
-
add_action("bp_groups_posted_update", array(&$this, "bp_groups_posted_update"), 99, 4);
|
21 |
}
|
22 |
-
add_action("bp_init", array($this, 'non_threaded_comments'));
|
23 |
-
add_action("bp_activity_comment_posted", array($this, "comment_sync"), 10, 2);
|
24 |
-
add_filter('bp_activity_allowed_tags', array(&$this, 'override_allowed_tags'));
|
25 |
-
add_filter('bp_get_activity_parent_content', array(&$this, 'bp_get_activity_parent_content'));
|
26 |
-
add_action('bp_activity_deleted_activities', array(&$this, 'bp_activity_deleted_activities'));
|
27 |
}
|
28 |
|
29 |
-
function bp_activity_deleted_activities( $activity_ids_deleted ){
|
30 |
//$activity_ids_deleted
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
$media = new RTMediaMedia();
|
35 |
-
remove_action('bp_activity_deleted_activities', array(&$this, 'bp_activity_deleted_activities'));
|
36 |
-
foreach($all_media as $single_media){
|
37 |
-
|
38 |
}
|
39 |
-
|
40 |
}
|
41 |
-
|
|
|
42 |
global $activities_template;
|
43 |
|
44 |
// Get the ID of the parent activity content
|
45 |
-
if (
|
46 |
return false;
|
47 |
|
48 |
// Bail if no parent content
|
49 |
-
if (empty($activities_template->activity_parents[$parent_id]))
|
50 |
return false;
|
51 |
|
52 |
// Bail if no action
|
53 |
-
if (empty($activities_template->activity_parents[$parent_id]->action))
|
54 |
return false;
|
55 |
|
56 |
// Content always includes action
|
57 |
-
$content = $activities_template->activity_parents[$parent_id]->action;
|
58 |
|
59 |
// Maybe append activity content, if it exists
|
60 |
-
if (!empty($activities_template->activity_parents[$parent_id]->content))
|
61 |
-
$content .= ' ' . $activities_template->activity_parents[$parent_id]->content;
|
62 |
|
63 |
// Remove the time since content for backwards compatibility
|
64 |
-
$content = str_replace('<span class="time-since">%s</span>', '', $content);
|
65 |
return $content;
|
66 |
}
|
67 |
|
68 |
-
function comment_sync($comment_id, $param) {
|
69 |
|
70 |
// comment_id 40
|
71 |
// Array( [id] => [content] => testing [user_id] => 1 [activity_id] => 26 [parent_id] => 26)
|
72 |
-
$activity = new BP_Activity_Activity($param['activity_id']);
|
73 |
-
if ($activity->type == 'rtmedia_update') {
|
74 |
$media_id = $activity->item_id;
|
75 |
$comment = new RTMediaComment();
|
76 |
-
$comment->add(array('comment_content' => $param['content'], 'comment_post_ID' => $media_id));
|
77 |
}
|
78 |
}
|
79 |
|
80 |
-
function non_threaded_comments() {
|
81 |
-
if (isset($_POST['action']) && $_POST['action'] == 'new_activity_comment') {
|
82 |
-
$activity_id = $_POST['form_id'];
|
83 |
-
$act = new BP_Activity_Activity($activity_id);
|
84 |
|
85 |
-
if ($act->type == 'rtmedia_update')
|
86 |
-
$_POST['comment_id'] = $_POST['form_id'];
|
87 |
}
|
88 |
}
|
89 |
|
90 |
-
function bp_groups_posted_update($content, $user_id, $group_id, $activity_id) {
|
91 |
-
$this->bp_activity_posted_update($content, $user_id, $activity_id);
|
92 |
}
|
93 |
|
94 |
-
function bp_activity_posted_update($content, $user_id, $activity_id) {
|
95 |
-
if (isset($_POST["rtMedia_attached_files"]) && is_array($_POST["rtMedia_attached_files"])) {
|
96 |
-
$objActivity = new RTMediaActivity($_POST["rtMedia_attached_files"], 0, $content);
|
97 |
global $wpdb, $bp;
|
98 |
-
$wpdb->update($bp->activity->table_name, array("type" => "rtmedia_update", "content" => $objActivity->create_activity_html()), array("id" => $activity_id));
|
99 |
$mediaObj = new RTMediaModel();
|
100 |
-
$sql = "update $mediaObj->table_name set activity_id = '"
|
101 |
-
$wpdb->query($sql);
|
102 |
}
|
103 |
-
if (isset($_POST['rtmedia-privacy'])) {
|
104 |
$privacy = -1;
|
105 |
-
if (is_rtmedia_privacy_enable()) {
|
106 |
-
if (is_rtmedia_privacy_user_overide()) {
|
107 |
-
|
108 |
-
|
109 |
} else {
|
110 |
-
$privacy = get_rtmedia_default_privacy();
|
111 |
}
|
112 |
-
}
|
113 |
-
bp_activity_update_meta($activity_id, 'rtmedia_privacy'
|
114 |
}
|
115 |
-
|
116 |
}
|
117 |
|
118 |
-
function bp_after_activity_post_form() {
|
119 |
-
$url = $_SERVER["REQUEST_URI"];
|
120 |
-
$url = trailingslashit($url);
|
121 |
-
|
122 |
$params = array(
|
123 |
-
'url' => (isset($url) && (strpos($url, "/media/") !== false)) ? str_replace("/media/", "/upload/", $url) : 'upload/',
|
124 |
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
125 |
'browse_button' => 'rtmedia-whts-new-upload-button',
|
126 |
'container' => 'rtmedia-whts-new-upload-container',
|
127 |
'drop_element' => 'rtmedia-whts-new-drag-drop-area',
|
128 |
-
'filters' => apply_filters('rtmedia_plupload_files_filter', array(array('title' => "Media Files", 'extensions' =>
|
129 |
-
'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
|
130 |
'multipart' => true,
|
131 |
'urlstream_upload' => true,
|
132 |
-
'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
133 |
-
'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
134 |
'file_data_name' => 'rtmedia_file', // key passed to $_FILE.
|
135 |
'multi_selection' => true,
|
136 |
-
'multipart_params' => apply_filters('rtmedia-multi-params', array('redirect' => 'no', 'rtmedia_update' => 'true', 'action' => 'wp_handle_upload', '_wp_http_referer' => $_SERVER['REQUEST_URI'], 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator(false, true)))
|
137 |
);
|
138 |
-
wp_enqueue_script('rtmedia-backbone', false, '', false, true);
|
139 |
-
$is_album = is_rtmedia_album() ? true : false;
|
140 |
-
$is_edit_allowed = is_rtmedia_edit_allowed() ? true : false;
|
141 |
-
wp_localize_script('rtmedia-backbone', 'is_album', $is_album);
|
142 |
-
wp_localize_script('rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed);
|
143 |
-
wp_localize_script('rtmedia-backbone', 'rtMedia_update_plupload_config', $params);
|
144 |
|
145 |
|
146 |
-
$uploadView = new RTMediaUploadView(array('activity' => true));
|
147 |
-
$uploadView->render('uploader');
|
148 |
}
|
149 |
|
150 |
-
function override_allowed_tags($activity_allowedtags) {
|
151 |
-
|
152 |
-
$activity_allowedtags['video'] = array();
|
153 |
-
$activity_allowedtags['video']['id'] = array();
|
154 |
-
$activity_allowedtags['video']['class'] = array();
|
155 |
-
$activity_allowedtags['video']['src'] = array();
|
156 |
-
$activity_allowedtags['video']['controls'] = array();
|
157 |
-
$activity_allowedtags['video']['preload'] = array();
|
158 |
-
$activity_allowedtags['video']['alt'] = array();
|
159 |
-
$activity_allowedtags['video']['title'] = array();
|
160 |
-
$activity_allowedtags['video']['width'] = array();
|
161 |
-
$activity_allowedtags['video']['height'] = array();
|
162 |
-
$activity_allowedtags['video']['poster'] = array();
|
163 |
-
$activity_allowedtags['audio'] = array();
|
164 |
-
$activity_allowedtags['audio']['id'] = array();
|
165 |
-
$activity_allowedtags['audio']['class'] = array();
|
166 |
-
$activity_allowedtags['audio']['src'] = array();
|
167 |
-
$activity_allowedtags['audio']['controls'] = array();
|
168 |
-
$activity_allowedtags['audio']['preload'] = array();
|
169 |
-
$activity_allowedtags['audio']['alt'] = array();
|
170 |
-
$activity_allowedtags['audio']['title'] = array();
|
171 |
-
$activity_allowedtags['audio']['width'] = array();
|
172 |
-
$activity_allowedtags['audio']['poster'] = array();
|
173 |
-
$activity_allowedtags['div'] = array();
|
174 |
-
$activity_allowedtags['div']['id'] = array();
|
175 |
-
$activity_allowedtags['div']['class'] = array();
|
176 |
-
$activity_allowedtags['a'] = array();
|
177 |
-
$activity_allowedtags['a']['title'] = array();
|
178 |
-
$activity_allowedtags['a']['href'] = array();
|
179 |
-
$activity_allowedtags['ul'] = array();
|
180 |
-
$activity_allowedtags['ul']['class'] = array();
|
181 |
-
$activity_allowedtags['li'] = array();
|
182 |
-
$activity_allowedtags['li']['class'] = array();
|
183 |
|
184 |
return $activity_allowedtags;
|
185 |
}
|
12 |
*/
|
13 |
class RTMediaBuddyPressActivity {
|
14 |
|
15 |
+
function __construct () {
|
16 |
global $rtmedia;
|
17 |
+
if ( $rtmedia->options[ "buddypress_enableOnActivity" ] !== 0 ) {
|
18 |
+
add_action ( "bp_after_activity_post_form", array( &$this, "bp_after_activity_post_form" ) );
|
19 |
+
add_action ( "bp_activity_posted_update", array( &$this, "bp_activity_posted_update" ), 99, 3 );
|
20 |
+
add_action ( "bp_groups_posted_update", array( &$this, "bp_groups_posted_update" ), 99, 4 );
|
21 |
}
|
22 |
+
add_action ( "bp_init", array( $this, 'non_threaded_comments' ) );
|
23 |
+
add_action ( "bp_activity_comment_posted", array( $this, "comment_sync" ), 10, 2 );
|
24 |
+
add_filter ( 'bp_activity_allowed_tags', array( &$this, 'override_allowed_tags' ) );
|
25 |
+
add_filter ( 'bp_get_activity_parent_content', array( &$this, 'bp_get_activity_parent_content' ) );
|
26 |
+
add_action ( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
27 |
}
|
28 |
|
29 |
+
function bp_activity_deleted_activities ( $activity_ids_deleted ) {
|
30 |
//$activity_ids_deleted
|
31 |
+
$rt_model = new RTMediaModel();
|
32 |
+
$all_media = $rt_model->get ( array( "activity_id" => $activity_ids_deleted ) );
|
33 |
+
if ( $all_media ) {
|
34 |
$media = new RTMediaMedia();
|
35 |
+
remove_action ( 'bp_activity_deleted_activities', array( &$this, 'bp_activity_deleted_activities' ) );
|
36 |
+
foreach ( $all_media as $single_media ) {
|
37 |
+
$media->delete ( $single_media->id, false, false );
|
38 |
}
|
39 |
+
}
|
40 |
}
|
41 |
+
|
42 |
+
function bp_get_activity_parent_content ( $content ) {
|
43 |
global $activities_template;
|
44 |
|
45 |
// Get the ID of the parent activity content
|
46 |
+
if ( ! $parent_id = $activities_template->activity->item_id )
|
47 |
return false;
|
48 |
|
49 |
// Bail if no parent content
|
50 |
+
if ( empty ( $activities_template->activity_parents[ $parent_id ] ) )
|
51 |
return false;
|
52 |
|
53 |
// Bail if no action
|
54 |
+
if ( empty ( $activities_template->activity_parents[ $parent_id ]->action ) )
|
55 |
return false;
|
56 |
|
57 |
// Content always includes action
|
58 |
+
$content = $activities_template->activity_parents[ $parent_id ]->action;
|
59 |
|
60 |
// Maybe append activity content, if it exists
|
61 |
+
if ( ! empty ( $activities_template->activity_parents[ $parent_id ]->content ) )
|
62 |
+
$content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
|
63 |
|
64 |
// Remove the time since content for backwards compatibility
|
65 |
+
$content = str_replace ( '<span class="time-since">%s</span>', '', $content );
|
66 |
return $content;
|
67 |
}
|
68 |
|
69 |
+
function comment_sync ( $comment_id, $param ) {
|
70 |
|
71 |
// comment_id 40
|
72 |
// Array( [id] => [content] => testing [user_id] => 1 [activity_id] => 26 [parent_id] => 26)
|
73 |
+
$activity = new BP_Activity_Activity ( $param[ 'activity_id' ] );
|
74 |
+
if ( $activity->type == 'rtmedia_update' ) {
|
75 |
$media_id = $activity->item_id;
|
76 |
$comment = new RTMediaComment();
|
77 |
+
$comment->add ( array( 'comment_content' => $param[ 'content' ], 'comment_post_ID' => $media_id ) );
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
function non_threaded_comments () {
|
82 |
+
if ( isset ( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'new_activity_comment' ) {
|
83 |
+
$activity_id = $_POST[ 'form_id' ];
|
84 |
+
$act = new BP_Activity_Activity ( $activity_id );
|
85 |
|
86 |
+
if ( $act->type == 'rtmedia_update' )
|
87 |
+
$_POST[ 'comment_id' ] = $_POST[ 'form_id' ];
|
88 |
}
|
89 |
}
|
90 |
|
91 |
+
function bp_groups_posted_update ( $content, $user_id, $group_id, $activity_id ) {
|
92 |
+
$this->bp_activity_posted_update ( $content, $user_id, $activity_id );
|
93 |
}
|
94 |
|
95 |
+
function bp_activity_posted_update ( $content, $user_id, $activity_id ) {
|
96 |
+
if ( isset ( $_POST[ "rtMedia_attached_files" ] ) && is_array ( $_POST[ "rtMedia_attached_files" ] ) ) {
|
97 |
+
$objActivity = new RTMediaActivity ( $_POST[ "rtMedia_attached_files" ], 0, $content );
|
98 |
global $wpdb, $bp;
|
99 |
+
$wpdb->update ( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html () ), array( "id" => $activity_id ) );
|
100 |
$mediaObj = new RTMediaModel();
|
101 |
+
$sql = "update $mediaObj->table_name set activity_id = '" . $activity_id . "' where id in (" . implode ( ",", $_POST[ "rtMedia_attached_files" ] ) . ")";
|
102 |
+
$wpdb->query ( $sql );
|
103 |
}
|
104 |
+
if ( isset ( $_POST[ 'rtmedia-privacy' ] ) ) {
|
105 |
$privacy = -1;
|
106 |
+
if ( is_rtmedia_privacy_enable () ) {
|
107 |
+
if ( is_rtmedia_privacy_user_overide () ) {
|
108 |
+
$privacy = $_POST[ 'rtmedia-privacy' ];
|
|
|
109 |
} else {
|
110 |
+
$privacy = get_rtmedia_default_privacy ();
|
111 |
}
|
112 |
+
}
|
113 |
+
bp_activity_update_meta ( $activity_id, 'rtmedia_privacy', $privacy );
|
114 |
}
|
|
|
115 |
}
|
116 |
|
117 |
+
function bp_after_activity_post_form () {
|
118 |
+
$url = $_SERVER[ "REQUEST_URI" ];
|
119 |
+
$url = trailingslashit ( $url );
|
|
|
120 |
$params = array(
|
121 |
+
'url' => (isset ( $url ) && (strpos ( $url, "/media/" ) !== false)) ? str_replace ( "/media/", "/upload/", $url ) : 'upload/',
|
122 |
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
123 |
'browse_button' => 'rtmedia-whts-new-upload-button',
|
124 |
'container' => 'rtmedia-whts-new-upload-container',
|
125 |
'drop_element' => 'rtmedia-whts-new-drag-drop-area',
|
126 |
+
'filters' => apply_filters ( 'rtmedia_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => get_rtmedia_allowed_upload_type () ) ) ),
|
127 |
+
'max_file_size' => min ( array( ini_get ( 'upload_max_filesize' ), ini_get ( 'post_max_size' ) ) ),
|
128 |
'multipart' => true,
|
129 |
'urlstream_upload' => true,
|
130 |
+
'flash_swf_url' => includes_url ( 'js/plupload/plupload.flash.swf' ),
|
131 |
+
'silverlight_xap_url' => includes_url ( 'js/plupload/plupload.silverlight.xap' ),
|
132 |
'file_data_name' => 'rtmedia_file', // key passed to $_FILE.
|
133 |
'multi_selection' => true,
|
134 |
+
'multipart_params' => apply_filters ( 'rtmedia-multi-params', array( 'redirect' => 'no', 'rtmedia_update' => 'true', 'action' => 'wp_handle_upload', '_wp_http_referer' => $_SERVER[ 'REQUEST_URI' ], 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator ( false, true ) ) )
|
135 |
);
|
136 |
+
wp_enqueue_script ( 'rtmedia-backbone', false, '', false, true );
|
137 |
+
$is_album = is_rtmedia_album () ? true : false;
|
138 |
+
$is_edit_allowed = is_rtmedia_edit_allowed () ? true : false;
|
139 |
+
wp_localize_script ( 'rtmedia-backbone', 'is_album', $is_album );
|
140 |
+
wp_localize_script ( 'rtmedia-backbone', 'is_edit_allowed', $is_edit_allowed );
|
141 |
+
wp_localize_script ( 'rtmedia-backbone', 'rtMedia_update_plupload_config', $params );
|
142 |
|
143 |
|
144 |
+
$uploadView = new RTMediaUploadView ( array( 'activity' => true ) );
|
145 |
+
$uploadView->render ( 'uploader' );
|
146 |
}
|
147 |
|
148 |
+
function override_allowed_tags ( $activity_allowedtags ) {
|
149 |
+
|
150 |
+
$activity_allowedtags[ 'video' ] = array( );
|
151 |
+
$activity_allowedtags[ 'video' ][ 'id' ] = array( );
|
152 |
+
$activity_allowedtags[ 'video' ][ 'class' ] = array( );
|
153 |
+
$activity_allowedtags[ 'video' ][ 'src' ] = array( );
|
154 |
+
$activity_allowedtags[ 'video' ][ 'controls' ] = array( );
|
155 |
+
$activity_allowedtags[ 'video' ][ 'preload' ] = array( );
|
156 |
+
$activity_allowedtags[ 'video' ][ 'alt' ] = array( );
|
157 |
+
$activity_allowedtags[ 'video' ][ 'title' ] = array( );
|
158 |
+
$activity_allowedtags[ 'video' ][ 'width' ] = array( );
|
159 |
+
$activity_allowedtags[ 'video' ][ 'height' ] = array( );
|
160 |
+
$activity_allowedtags[ 'video' ][ 'poster' ] = array( );
|
161 |
+
$activity_allowedtags[ 'audio' ] = array( );
|
162 |
+
$activity_allowedtags[ 'audio' ][ 'id' ] = array( );
|
163 |
+
$activity_allowedtags[ 'audio' ][ 'class' ] = array( );
|
164 |
+
$activity_allowedtags[ 'audio' ][ 'src' ] = array( );
|
165 |
+
$activity_allowedtags[ 'audio' ][ 'controls' ] = array( );
|
166 |
+
$activity_allowedtags[ 'audio' ][ 'preload' ] = array( );
|
167 |
+
$activity_allowedtags[ 'audio' ][ 'alt' ] = array( );
|
168 |
+
$activity_allowedtags[ 'audio' ][ 'title' ] = array( );
|
169 |
+
$activity_allowedtags[ 'audio' ][ 'width' ] = array( );
|
170 |
+
$activity_allowedtags[ 'audio' ][ 'poster' ] = array( );
|
171 |
+
$activity_allowedtags[ 'div' ] = array( );
|
172 |
+
$activity_allowedtags[ 'div' ][ 'id' ] = array( );
|
173 |
+
$activity_allowedtags[ 'div' ][ 'class' ] = array( );
|
174 |
+
$activity_allowedtags[ 'a' ] = array( );
|
175 |
+
$activity_allowedtags[ 'a' ][ 'title' ] = array( );
|
176 |
+
$activity_allowedtags[ 'a' ][ 'href' ] = array( );
|
177 |
+
$activity_allowedtags[ 'ul' ] = array( );
|
178 |
+
$activity_allowedtags[ 'ul' ][ 'class' ] = array( );
|
179 |
+
$activity_allowedtags[ 'li' ] = array( );
|
180 |
+
$activity_allowedtags[ 'li' ][ 'class' ] = array( );
|
181 |
|
182 |
return $activity_allowedtags;
|
183 |
}
|
app/main/controllers/media/RTMediaAlbum.php
CHANGED
@@ -12,495 +12,489 @@
|
|
12 |
*/
|
13 |
class RTMediaAlbum {
|
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 |
-
function add_global($title ='') {
|
189 |
|
190 |
// $super_user_ids = get_super_admins();
|
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 |
-
$attachment_ids = $wpdb->get_results("SELECT ID
|
451 |
FROM $wpdb->posts
|
452 |
-
WHERE post_parent = $post_id");
|
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 |
-
|
12 |
*/
|
13 |
class RTMediaAlbum {
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @var type
|
18 |
+
*
|
19 |
+
* Media object associated with the album. It works as an interface
|
20 |
+
* for the actions specific the media from this album
|
21 |
+
*/
|
22 |
+
var $media;
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
public function __construct () {
|
28 |
+
add_action ( 'init', array( &$this, 'register_post_types' ), 12 );
|
29 |
+
$this->media = new RTMediaMedia();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Register Custom Post Types required by rtMedia
|
34 |
+
*/
|
35 |
+
function register_post_types () {
|
36 |
+
|
37 |
+
/* Set up Album labels */
|
38 |
+
$album_labels = array(
|
39 |
+
'name' => __ ( 'Albums', 'rtmedia' ),
|
40 |
+
'singular_name' => __ ( 'Album', 'rtmedia' ),
|
41 |
+
'add_new' => __ ( 'Create', 'rtmedia' ),
|
42 |
+
'add_new_item' => __ ( 'Create Album', 'rtmedia' ),
|
43 |
+
'edit_item' => __ ( 'Edit Album', 'rtmedia' ),
|
44 |
+
'new_item' => __ ( 'New Album', 'rtmedia' ),
|
45 |
+
'all_items' => __ ( 'All Albums', 'rtmedia' ),
|
46 |
+
'view_item' => __ ( 'View Album', 'rtmedia' ),
|
47 |
+
'search_items' => __ ( 'Search Albums', 'rtmedia' ),
|
48 |
+
'not_found' => __ ( 'No album found', 'rtmedia' ),
|
49 |
+
'not_found_in_trash' => __ ( 'No album found in Trash', 'rtmedia' ),
|
50 |
+
'parent_item_colon' => '',
|
51 |
+
'menu_name' => __ ( 'Albums', 'rtmedia' )
|
52 |
+
);
|
53 |
+
|
54 |
+
/* Set up Album post type arguments */
|
55 |
+
$album_args = array(
|
56 |
+
'labels' => $album_labels,
|
57 |
+
'public' => false,
|
58 |
+
'publicly_queryable' => false,
|
59 |
+
'show_ui' => false,
|
60 |
+
'show_in_menu' => false,
|
61 |
+
'query_var' => false,
|
62 |
+
'capability_type' => 'post',
|
63 |
+
'has_archive' => false,
|
64 |
+
'hierarchical' => false,
|
65 |
+
'menu_position' => null,
|
66 |
+
'rewrite' => false,
|
67 |
+
'supports' => array(
|
68 |
+
'title',
|
69 |
+
'author',
|
70 |
+
'thumbnail',
|
71 |
+
'excerpt',
|
72 |
+
'comments'
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
/* register Album post type */
|
77 |
+
register_post_type ( 'rtmedia_album', $album_args );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Method verifies the nonce passed while performing any CRUD operations
|
82 |
+
* on the album.
|
83 |
+
*
|
84 |
+
* @param type $mode
|
85 |
+
* @return boolean
|
86 |
+
*/
|
87 |
+
function verify_nonce ( $mode ) {
|
88 |
+
|
89 |
+
$nonce = $_REQUEST[ "rtmedia_{$mode}_album_nonce" ];
|
90 |
+
$mode = $_REQUEST[ 'mode' ];
|
91 |
+
if ( wp_verify_nonce ( $nonce, 'rtmedia_' . $mode ) )
|
92 |
+
return true;
|
93 |
+
else
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* returns user_id of the current logged in user in wordpress
|
99 |
+
*
|
100 |
+
* @global type $current_user
|
101 |
+
* @return type
|
102 |
+
*/
|
103 |
+
function get_current_author () {
|
104 |
+
|
105 |
+
return get_current_user_id ();
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Adds a new album
|
110 |
+
*
|
111 |
+
* @global type $rtmedia_interaction
|
112 |
+
* @param type $title
|
113 |
+
* @param type $author_id
|
114 |
+
* @param type $new
|
115 |
+
* @param type $post_id
|
116 |
+
* @return type
|
117 |
+
*/
|
118 |
+
function add ( $title = '', $author_id = false, $new = true, $post_id = false, $context = false, $context_id = false ) {
|
119 |
+
|
120 |
+
/* action to perform any task before adding the album */
|
121 |
+
do_action ( 'rtmedia_before_add_album' );
|
122 |
+
|
123 |
+
$author_id = $author_id ? $author_id : $this->get_current_author ();
|
124 |
+
|
125 |
+
/* Album Details which will be passed to Database query to add the album */
|
126 |
+
$post_vars = array(
|
127 |
+
'post_title' => (empty ( $title )) ? 'Untitled Album' : $title,
|
128 |
+
'post_type' => 'rtmedia_album',
|
129 |
+
'post_author' => $author_id,
|
130 |
+
'post_status' => 'publish'
|
131 |
+
);
|
132 |
+
|
133 |
+
/* Check whether to create a new album in wp_post table
|
134 |
+
* This is the case when a user creates a album of his own. We need to
|
135 |
+
* create a separte post in wp_post which will work as parent for
|
136 |
+
* all the media uploaded to that album
|
137 |
+
*
|
138 |
+
* */
|
139 |
+
if ( $new )
|
140 |
+
$album_id = wp_insert_post ( $post_vars );
|
141 |
+
/**
|
142 |
+
* if user uploads any media directly to a post or a page or any custom
|
143 |
+
* post then the context in which the user is uploading a media becomes
|
144 |
+
* an album in itself. We do not need to create a separate album in this
|
145 |
+
* case.
|
146 |
+
*/
|
147 |
+
else
|
148 |
+
$album_id = $post_id;
|
149 |
+
|
150 |
+
$current_album = get_post ( $album_id, ARRAY_A );
|
151 |
+
if ( $context === false ) {
|
152 |
+
$context = (isset ( $rtmedia_interaction->context->type )) ? $rtmedia_interaction->context->type : NULL;
|
153 |
+
}
|
154 |
+
if ( $context_id === false ) {
|
155 |
+
$context = (isset ( $rtmedia_interaction->context->id )) ? $rtmedia_interaction->context->id : NULL;
|
156 |
+
}
|
157 |
+
// add in the media since album is also a media
|
158 |
+
//defaults
|
159 |
+
global $rtmedia_interaction;
|
160 |
+
$attributes = array(
|
161 |
+
'blog_id' => get_current_blog_id (),
|
162 |
+
'media_id' => $album_id,
|
163 |
+
'album_id' => NULL,
|
164 |
+
'media_title' => $current_album[ 'post_title' ],
|
165 |
+
'media_author' => $current_album[ 'post_author' ],
|
166 |
+
'media_type' => 'album',
|
167 |
+
'context' => $context,
|
168 |
+
'context_id' => $context_id,
|
169 |
+
'activity_id' => NULL,
|
170 |
+
'privacy' => NULL
|
171 |
+
);
|
172 |
+
|
173 |
+
$rtmedia_id = $this->media->insert_album ( $attributes );
|
174 |
+
|
175 |
+
/* action to perform any task after adding the album */
|
176 |
+
do_action ( 'rtmedia_after_add_album', $this );
|
177 |
+
|
178 |
+
return $rtmedia_id;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Wrapper method to add a global album
|
183 |
+
*
|
184 |
+
* @param type $title
|
185 |
+
* @return boolean
|
186 |
+
*/
|
187 |
+
function add_global ( $title = '' ) {
|
|
|
188 |
|
189 |
// $super_user_ids = get_super_admins();
|
190 |
+
$author_id = $this->get_current_author ();
|
191 |
+
/**
|
192 |
+
* only admin privilaged user can add a global album
|
193 |
+
*/
|
194 |
+
if ( current_user_can ( 'activate_plugins' ) ) {
|
195 |
+
|
196 |
+
$album_id = $this->add ( $title, $author_id, true, false );
|
197 |
+
|
198 |
+
$this->save_globals ( $album_id );
|
199 |
+
|
200 |
+
return $album_id;
|
201 |
+
}
|
202 |
+
else
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get the list of all global albums
|
208 |
+
* @return type
|
209 |
+
*/
|
210 |
+
static function get_globals () {
|
211 |
+
return get_site_option ( 'rtmedia-global-albums' );
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* There is a default global album which works as a Wall Post Album for the
|
216 |
+
* user.
|
217 |
+
*
|
218 |
+
* @return type
|
219 |
+
*/
|
220 |
+
static function get_default () {
|
221 |
+
$albums = self::get_globals ();
|
222 |
+
if ( isset ( $albums[ 0 ] ) )
|
223 |
+
return $albums[ 0 ];
|
224 |
+
else
|
225 |
+
return false;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Save global albums for newly added album
|
230 |
+
*
|
231 |
+
* @param type $album_ids
|
232 |
+
* @return boolean
|
233 |
+
*/
|
234 |
+
function save_globals ( $album_ids = false ) {
|
235 |
+
|
236 |
+
if ( ! $album_ids )
|
237 |
+
return false;
|
238 |
+
|
239 |
+
$albums = self::get_globals ();
|
240 |
+
|
241 |
+
if ( ! $albums )
|
242 |
+
$albums = array( );
|
243 |
+
|
244 |
+
if ( ! is_array ( $album_ids ) )
|
245 |
+
$album_ids = array( $album_ids );
|
246 |
+
|
247 |
+
$albums = array_merge ( $albums, $album_ids );
|
248 |
+
update_site_option ( 'rtmedia-global-albums', $albums );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Wrapper method to update details for any global album
|
253 |
+
*
|
254 |
+
* @param type $id
|
255 |
+
* @param type $title
|
256 |
+
* @return boolean
|
257 |
+
*/
|
258 |
+
function update_global ( $id, $title = '' ) {
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Only admin can update global albums
|
262 |
+
*/
|
263 |
+
$super_user_ids = get_super_admins ();
|
264 |
+
if ( in_array ( $this->get_current_author (), $super_user_ids ) ) {
|
265 |
+
|
266 |
+
return $this->update ( $id, $title );
|
267 |
+
}
|
268 |
+
else
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Update any album. Generic method for all the user.
|
274 |
+
*
|
275 |
+
* @param type $id
|
276 |
+
* @param type $title
|
277 |
+
* @return boolean
|
278 |
+
*/
|
279 |
+
function update ( $id, $title = '' ) {
|
280 |
+
|
281 |
+
/* Action to perform before updating the album */
|
282 |
+
do_action ( 'rtmedia_before_update_album', $this );
|
283 |
+
if ( empty ( $title ) && empty ( $id ) ) {
|
284 |
+
return false;
|
285 |
+
} else {
|
286 |
+
|
287 |
+
$args = array(
|
288 |
+
'ID' => $id,
|
289 |
+
'post_title' => $title
|
290 |
+
);
|
291 |
+
$status = wp_insert_post ( $args );
|
292 |
+
if ( get_class ( $status ) == 'WP_Error' || $status == 0 ) {
|
293 |
+
return false;
|
294 |
+
} else {
|
295 |
+
/* Action to perform after updating the album */
|
296 |
+
do_action ( 'rtmedia_after_update_album', $this );
|
297 |
+
return true;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Wrapper method to delete a global album
|
304 |
+
*
|
305 |
+
* @param type $id
|
306 |
+
* @return boolean
|
307 |
+
*/
|
308 |
+
function delete_global ( $id ) {
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Only admin can delete a global album
|
312 |
+
*/
|
313 |
+
$super_user_ids = get_super_admins ();
|
314 |
+
if ( in_array ( $this->get_current_author (), $super_user_ids ) ) {
|
315 |
+
|
316 |
+
$default_album = self::get_default ();
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Default album is NEVER deleted.
|
320 |
+
*/
|
321 |
+
if ( $id == $default_album )
|
322 |
+
return false;
|
323 |
+
|
324 |
+
/**
|
325 |
+
* If a global album is deleted then all the media of that album
|
326 |
+
* is merged to the default global album and then the album is deleted.
|
327 |
+
*/
|
328 |
+
//merge with the default album
|
329 |
+
$this->merge ( $default_album, $id );
|
330 |
+
|
331 |
+
return $this->delete ( $id );
|
332 |
+
}
|
333 |
+
else
|
334 |
+
return false;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Generic method to delete any album
|
339 |
+
*
|
340 |
+
* @param type $id
|
341 |
+
* @return type
|
342 |
+
*/
|
343 |
+
function delete ( $id ) {
|
344 |
+
|
345 |
+
/* action to perform any task befor deleting an album */
|
346 |
+
do_action ( 'rtmedia_before_delete_album', $this );
|
347 |
+
|
348 |
+
/**
|
349 |
+
* First fetch all the media from that album
|
350 |
+
*/
|
351 |
+
add_filter ( 'rt_db_model_per_page', array( $this, 'set_queries_per_page' ), 10, 2 );
|
352 |
+
$page = 1;
|
353 |
+
$flag = true;
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Delete each media from the album first
|
357 |
+
*/
|
358 |
+
while ( $media = $this->media->model->get_by_album_id ( $id, $page ) ) {
|
359 |
+
|
360 |
+
$media_id = $media[ 'result' ][ 0 ][ 'media_id' ];
|
361 |
+
|
362 |
+
$flag = wp_delete_attachment ( $media_id );
|
363 |
+
|
364 |
+
if ( ! $flag )
|
365 |
+
break;
|
366 |
+
|
367 |
+
$page ++;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* If all the media are deleted from the album then delete the album at last.
|
372 |
+
*/
|
373 |
+
if ( $flag ) {
|
374 |
+
$this->media->delete ( $id );
|
375 |
+
}
|
376 |
+
|
377 |
+
/* action to perform any task after deleting an album */
|
378 |
+
do_action ( 'rtmedia_after_delete_album', $this );
|
379 |
+
return $flag;
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Helper function to set number of queries in pagination
|
384 |
+
*
|
385 |
+
* @param int $per_page
|
386 |
+
* @param type $table_name
|
387 |
+
* @return int
|
388 |
+
*/
|
389 |
+
function set_queries_per_page ( $per_page, $table_name ) {
|
390 |
+
|
391 |
+
$per_page = 1;
|
392 |
+
return $per_page;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Generic function to merge two albums
|
397 |
+
*
|
398 |
+
* @param type $primary_album_id
|
399 |
+
* @param type $secondary_album_id
|
400 |
+
* @return type
|
401 |
+
*/
|
402 |
+
function merge ( $primary_album_id, $secondary_album_id ) {
|
403 |
+
|
404 |
+
add_filter ( 'rt_db_model_per_page', array( $this, 'set_queries_per_page' ), 10, 2 );
|
405 |
+
$page = 1;
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Transfer all the media from secondary album to primary album
|
409 |
+
*/
|
410 |
+
while ( $media = $this->media->model->get_by_album_id ( $secondary_album_id, $page ) ) {
|
411 |
+
|
412 |
+
$media_id = $media[ 'result' ][ 0 ][ 'media_id' ];
|
413 |
+
$this->media->move ( $media_id, $primary_album_id );
|
414 |
+
|
415 |
+
$page ++;
|
416 |
+
}
|
417 |
+
|
418 |
+
$author = $this->get_current_author ();
|
419 |
+
$admins = get_super_admins ();
|
420 |
+
$global_albums = self::get_globals ();
|
421 |
+
|
422 |
+
if ( in_array ( $secondary_album_id, $global_albums ) )
|
423 |
+
if ( in_array ( $author, $admins ) )
|
424 |
+
$this->delete_global ( $secondary_album_id );
|
425 |
+
else
|
426 |
+
return false;
|
427 |
+
else
|
428 |
+
$this->delete ( $secondary_album_id );
|
429 |
+
|
430 |
+
return $primary_album_id;
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Convert a post which is not indexed in rtMedia to an album.
|
435 |
+
*
|
436 |
+
* All the attachments from that post will become media of the new album.
|
437 |
+
*
|
438 |
+
* @global type $wpdb
|
439 |
+
* @param type $post_id
|
440 |
+
* @return boolean
|
441 |
+
*/
|
442 |
+
function convert_post ( $post_id ) {
|
443 |
+
|
444 |
+
global $wpdb;
|
445 |
+
/**
|
446 |
+
* Fetch all the attachments from the given post
|
447 |
+
*/
|
448 |
+
$attachment_ids = $wpdb->get_results ( "SELECT ID
|
|
|
449 |
FROM $wpdb->posts
|
450 |
+
WHERE post_parent = $post_id" );
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Create a album. Not a new album. Just give index to this post in rtMedia
|
454 |
+
*/
|
455 |
+
$album_id = $this->add ( $post[ 'post_title' ], $post[ 'post_author' ], false, $post_id );
|
456 |
+
|
457 |
+
$album_data = $this->model->get_by_media_id ( $album_id );
|
458 |
+
|
459 |
+
/* Album details */
|
460 |
+
$album_meta = array(
|
461 |
+
'album_id' => $album_id,
|
462 |
+
'context' => $album_data[ 'results' ][ 0 ][ 'context' ],
|
463 |
+
'context_id' => $album_data[ 'results' ][ 0 ][ 'context_id' ],
|
464 |
+
'activity_id' => $album_data[ 'results' ][ 0 ][ 'activity_id' ],
|
465 |
+
'privacy' => $album_data[ 'results' ][ 0 ][ 'privacy' ]
|
466 |
+
);
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Index attachments in rtMedia
|
470 |
+
*/
|
471 |
+
$this->media->insertmedia ( $attachment_ids, $album_meta );
|
472 |
+
|
473 |
+
return true;
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Check if a post is being indexed as an rtMedia album
|
478 |
+
* @param integer $post_id the post id to check
|
479 |
+
* @return boolean if a post is an rtmedia album
|
480 |
+
*/
|
481 |
+
function is_post_album ( $post_id ) {
|
482 |
+
$album = $this->model->get ( array( 'album_id' => $post_id ) );
|
483 |
+
if ( ! empty ( $album ) && count ( $album ) > 0 ) {
|
484 |
+
return true;
|
485 |
+
}
|
486 |
+
return false;
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Convert an existing post, with attachments indexed by rtMedia to rtMedia album
|
491 |
+
* @param integer $post_id The post id to convert
|
492 |
+
*/
|
493 |
+
function post_to_album ( $post_id ) {
|
494 |
+
$album_id = $this->add ( $post[ 'post_title' ], $post[ 'post_author' ], false, $post_id );
|
495 |
+
$this->model->update (
|
496 |
+
array( 'album_id' => $album_id ), array( 'context' => $post[ 'post_type' ], 'context_id' => $post_id )
|
497 |
+
);
|
498 |
+
}
|
|
|
|
|
|
|
|
|
499 |
|
500 |
+
}
|
app/main/controllers/media/RTMediaFeatured.php
CHANGED
@@ -19,7 +19,7 @@ class RTMediaFeatured extends RTMediaUserInteraction {
|
|
19 |
public $featured;
|
20 |
public $settings;
|
21 |
|
22 |
-
function __construct($user_id = false, $flag = false) {
|
23 |
$args = array(
|
24 |
'action' => 'featured',
|
25 |
'label' => 'Set Featured',
|
@@ -31,105 +31,110 @@ class RTMediaFeatured extends RTMediaUserInteraction {
|
|
31 |
'repeatable' => false,
|
32 |
'undoable' => true
|
33 |
);
|
34 |
-
|
35 |
-
|
36 |
$this->user_id = $user_id;
|
37 |
-
parent::__construct($args);
|
38 |
-
$this->settings();
|
39 |
//$this->get();
|
40 |
}
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
44 |
return false;
|
45 |
-
if(isset($this->action_query) && isset($this->action_query->id) && $this->action_query->id == $this->featured){
|
46 |
$this->label = $this->undo_label;
|
47 |
}
|
48 |
-
|
49 |
}
|
50 |
|
51 |
-
function set($media_id = false) {
|
52 |
-
if ($media_id === false) {
|
53 |
return;
|
54 |
}
|
55 |
-
if ($this->user_id === false)
|
56 |
-
$this->user_id = get_current_user_id();
|
57 |
-
update_user_meta($this->user_id, 'rtmedia_featured_media', $media_id);
|
58 |
}
|
59 |
|
60 |
-
function get() {
|
61 |
-
if ($this->user_id === false){
|
62 |
-
|
|
|
|
|
|
|
63 |
}
|
64 |
-
$this->featured = get_user_meta($this->user_id, "rtmedia_featured_media", true);
|
65 |
-
if ($this->featured == "")
|
66 |
-
$this->featured = get_user_meta($this->user_id, "bp_media_featured_media", true);
|
67 |
return $this->featured;
|
68 |
}
|
69 |
|
70 |
-
function settings() {
|
71 |
global $rtmedia;
|
72 |
-
$this->settings['photo'] = isset($rtmedia->options['allowedTypes_photo_featured']) ? $rtmedia->options['allowedTypes_photo_featured'] : 0;
|
73 |
-
$this->settings['video'] = isset($rtmedia->options['allowedTypes_video_featured']) ? $rtmedia->options['allowedTypes_video_featured'] : 0;
|
74 |
-
$this->settings['music'] = isset($rtmedia->options['allowedTypes_music_featured']) ? $rtmedia->options['allowedTypes_music_featured'] : 0;
|
75 |
-
$this->settings['width'] = isset($rtmedia->options['defaultSizes_featured_default_width']) ? $rtmedia->options['defaultSizes_featured_default_width'] : 400;
|
76 |
-
$this->settings['height'] = isset($rtmedia->options['defaultSizes_featured_default_height']) ? $rtmedia->options['defaultSizes_featured_default_height'] : 300;
|
77 |
-
$this->settings['crop'] = isset($rtmedia->options['defaultSizes_featured_default_crop']) ? $rtmedia->options['defaultSizes_featured_default_crop'] : 1;
|
78 |
}
|
79 |
|
80 |
-
function valid_type($type) {
|
81 |
-
if (isset($this->settings[$type]) && $this->settings[$type] > 0) {
|
82 |
return true;
|
83 |
}
|
84 |
return false;
|
85 |
}
|
86 |
-
|
87 |
-
|
|
|
88 |
}
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
95 |
}
|
96 |
}
|
97 |
|
98 |
-
function media_exists($id) {
|
99 |
global $wpdb;
|
100 |
-
$post_exists = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE id = '" . $id . "'", 'ARRAY_A');
|
101 |
-
if ($post_exists)
|
102 |
return true;
|
103 |
else
|
104 |
return false;
|
105 |
}
|
106 |
|
107 |
-
function content() {
|
108 |
-
$this->get();
|
109 |
-
$actions = $this->model->get(array('id' => $this->featured));
|
110 |
-
if(
|
111 |
return false;
|
112 |
-
|
113 |
-
$featured = $actions[0];
|
114 |
$type = $featured->media_type;
|
115 |
|
116 |
$content_xtra = '';
|
117 |
-
switch ($type) {
|
118 |
case 'video' :
|
119 |
-
$this->generate_featured_size($this->featured);
|
120 |
-
if ($featured->media_id) {
|
121 |
-
$image_array = image_downsize($featured->media_id, '
|
122 |
-
$content_xtra = 'poster="' . $image_array[0] . '" ';
|
123 |
}
|
124 |
-
$content = '<video class="bp-media-featured-media"' . $content_xtra . 'src="' . wp_get_attachment_url($this->featured) . '" width="' . $this->settings['width'] . '" height="' . $this->settings['height'] . '" type="video/mp4" id="bp_media_video_' . $this->featured . '" controls="controls" preload="none"></video>';
|
125 |
break;
|
126 |
case 'music' :
|
127 |
-
$content = '<audio class="bp-media-featured-media"' . $content_xtra . 'src="' . wp_get_attachment_url($this->featured) . '" width="' . $this->settings['width'] . '" type="audio/mp3" id="bp_media_audio_' . $this->featured . '" controls="controls" preload="none"></video>';
|
128 |
break;
|
129 |
case 'photo' :
|
130 |
-
$this->generate_featured_size($featured->media_id);
|
131 |
-
$image_array = image_downsize($featured->media_id, 'rt_media_featured_image');
|
132 |
-
$content = '<img src="' . $image_array[0] . '" alt="' . $featured->media_title . '" />';
|
133 |
break;
|
134 |
default :
|
135 |
return false;
|
@@ -137,53 +142,54 @@ class RTMediaFeatured extends RTMediaUserInteraction {
|
|
137 |
return $content;
|
138 |
}
|
139 |
|
140 |
-
function process() {
|
141 |
-
if (!isset($this->action_query->id))
|
142 |
return;
|
143 |
-
$return = array();
|
144 |
$this->model = new RTMediaModel();
|
145 |
-
$actions = $this->model->get(array('id' => $this->action_query->id));
|
146 |
-
$this->get();
|
147 |
-
if (intval($this->settings[$actions[0]->media_type]) == 1){
|
148 |
-
if($this->action_query->id == $this->featured){
|
149 |
-
$this->set(0);
|
150 |
-
$return["next"] = $this->label;
|
151 |
-
}else{
|
152 |
-
$this->set($this->action_query->id);
|
153 |
-
$return["next"] = $this->undo_label;
|
154 |
}
|
155 |
-
$return["status"] = true;
|
156 |
-
|
157 |
-
|
158 |
-
$return["
|
159 |
-
$return["error"] = "Media type is not allowed";
|
160 |
}
|
161 |
-
if (isset($_REQUEST["json"]) && $_REQUEST["json"] == "true") {
|
162 |
-
echo json_encode($return);
|
163 |
-
die();
|
164 |
} else {
|
165 |
-
wp_safe_redirect($_SERVER["HTTP_REFERER"]);
|
166 |
}
|
167 |
}
|
168 |
|
169 |
}
|
170 |
|
171 |
-
function rtmedia_featured($user_id = false) {
|
172 |
-
echo rtmedia_get_featured($user_id);
|
173 |
}
|
174 |
|
175 |
-
function rtmedia_get_featured($user_id = false) {
|
176 |
-
$featured = new RTMediaFeatured($user_id, false);
|
177 |
-
return $featured->content();
|
178 |
}
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
}
|
183 |
|
184 |
-
function bp_media_get_featured($user_id = false) {
|
185 |
-
return rtmedia_get_featured($user_id);
|
186 |
}
|
187 |
-
}
|
188 |
|
|
|
189 |
?>
|
19 |
public $featured;
|
20 |
public $settings;
|
21 |
|
22 |
+
function __construct ( $user_id = false, $flag = false ) {
|
23 |
$args = array(
|
24 |
'action' => 'featured',
|
25 |
'label' => 'Set Featured',
|
31 |
'repeatable' => false,
|
32 |
'undoable' => true
|
33 |
);
|
34 |
+
|
35 |
+
|
36 |
$this->user_id = $user_id;
|
37 |
+
parent::__construct ( $args );
|
38 |
+
$this->settings ();
|
39 |
//$this->get();
|
40 |
}
|
41 |
+
|
42 |
+
function before_render () {
|
43 |
+
$this->get ();
|
44 |
+
if ( ! $this->settings[ $this->media->media_type ] )
|
45 |
return false;
|
46 |
+
if ( isset ( $this->action_query ) && isset ( $this->action_query->id ) && $this->action_query->id == $this->featured ) {
|
47 |
$this->label = $this->undo_label;
|
48 |
}
|
|
|
49 |
}
|
50 |
|
51 |
+
function set ( $media_id = false ) {
|
52 |
+
if ( $media_id === false ) {
|
53 |
return;
|
54 |
}
|
55 |
+
if ( $this->user_id === false )
|
56 |
+
$this->user_id = get_current_user_id ();
|
57 |
+
update_user_meta ( $this->user_id, 'rtmedia_featured_media', $media_id );
|
58 |
}
|
59 |
|
60 |
+
function get () {
|
61 |
+
if ( $this->user_id === false ) {
|
62 |
+
if ( function_exists ( "bp_displayed_user_id" ) )
|
63 |
+
$this->user_id = bp_displayed_user_id ();
|
64 |
+
if ( ! $this->user_id )
|
65 |
+
$this->user_id = get_current_user_id ();
|
66 |
}
|
67 |
+
$this->featured = get_user_meta ( $this->user_id, "rtmedia_featured_media", true );
|
68 |
+
if ( $this->featured == "" )
|
69 |
+
$this->featured = get_user_meta ( $this->user_id, "bp_media_featured_media", true );
|
70 |
return $this->featured;
|
71 |
}
|
72 |
|
73 |
+
function settings () {
|
74 |
global $rtmedia;
|
75 |
+
$this->settings[ 'photo' ] = isset ( $rtmedia->options[ 'allowedTypes_photo_featured' ] ) ? $rtmedia->options[ 'allowedTypes_photo_featured' ] : 0;
|
76 |
+
$this->settings[ 'video' ] = isset ( $rtmedia->options[ 'allowedTypes_video_featured' ] ) ? $rtmedia->options[ 'allowedTypes_video_featured' ] : 0;
|
77 |
+
$this->settings[ 'music' ] = isset ( $rtmedia->options[ 'allowedTypes_music_featured' ] ) ? $rtmedia->options[ 'allowedTypes_music_featured' ] : 0;
|
78 |
+
$this->settings[ 'width' ] = isset ( $rtmedia->options[ 'defaultSizes_featured_default_width' ] ) ? $rtmedia->options[ 'defaultSizes_featured_default_width' ] : 400;
|
79 |
+
$this->settings[ 'height' ] = isset ( $rtmedia->options[ 'defaultSizes_featured_default_height' ] ) ? $rtmedia->options[ 'defaultSizes_featured_default_height' ] : 300;
|
80 |
+
$this->settings[ 'crop' ] = isset ( $rtmedia->options[ 'defaultSizes_featured_default_crop' ] ) ? $rtmedia->options[ 'defaultSizes_featured_default_crop' ] : 1;
|
81 |
}
|
82 |
|
83 |
+
function valid_type ( $type ) {
|
84 |
+
if ( isset ( $this->settings[ $type ] ) && $this->settings[ $type ] > 0 ) {
|
85 |
return true;
|
86 |
}
|
87 |
return false;
|
88 |
}
|
89 |
+
|
90 |
+
function get_last_media () {
|
91 |
+
|
92 |
}
|
93 |
+
|
94 |
+
function generate_featured_size ( $media_id ) {
|
95 |
+
$metadata = wp_get_attachment_metadata ( $media_id );
|
96 |
+
$resized = image_make_intermediate_size ( get_attached_file ( $media_id ), $this->settings[ 'width' ], $this->settings[ 'height' ], $this->settings[ 'crop' ] );
|
97 |
+
if ( $resized ) {
|
98 |
+
$metadata[ 'sizes' ][ 'rtmedia-featured' ] = $resized;
|
99 |
+
wp_update_attachment_metadata ( $media_id, $metadata );
|
100 |
}
|
101 |
}
|
102 |
|
103 |
+
function media_exists ( $id ) {
|
104 |
global $wpdb;
|
105 |
+
$post_exists = $wpdb->get_row ( "SELECT * FROM $wpdb->posts WHERE id = '" . $id . "'", 'ARRAY_A' );
|
106 |
+
if ( $post_exists )
|
107 |
return true;
|
108 |
else
|
109 |
return false;
|
110 |
}
|
111 |
|
112 |
+
function content () {
|
113 |
+
$this->get ();
|
114 |
+
$actions = $this->model->get ( array( 'id' => $this->featured ) );
|
115 |
+
if ( ! $actions )
|
116 |
return false;
|
117 |
+
|
118 |
+
$featured = $actions[ 0 ];
|
119 |
$type = $featured->media_type;
|
120 |
|
121 |
$content_xtra = '';
|
122 |
+
switch ( $type ) {
|
123 |
case 'video' :
|
124 |
+
$this->generate_featured_size ( $this->featured );
|
125 |
+
if ( $featured->media_id ) {
|
126 |
+
$image_array = image_downsize ( $featured->media_id, 'rt_media_thumbnail' );
|
127 |
+
$content_xtra = 'poster="' . $image_array[ 0 ] . '" ';
|
128 |
}
|
129 |
+
$content = '<video class="bp-media-featured-media"' . $content_xtra . 'src="' . wp_get_attachment_url ( $this->featured ) . '" width="' . $this->settings[ 'width' ] . '" height="' . $this->settings[ 'height' ] . '" type="video/mp4" id="bp_media_video_' . $this->featured . '" controls="controls" preload="none"></video>';
|
130 |
break;
|
131 |
case 'music' :
|
132 |
+
$content = '<audio class="bp-media-featured-media"' . $content_xtra . 'src="' . wp_get_attachment_url ( $this->featured ) . '" width="' . $this->settings[ 'width' ] . '" type="audio/mp3" id="bp_media_audio_' . $this->featured . '" controls="controls" preload="none"></video>';
|
133 |
break;
|
134 |
case 'photo' :
|
135 |
+
$this->generate_featured_size ( $featured->media_id );
|
136 |
+
$image_array = image_downsize ( $featured->media_id, 'rt_media_featured_image' );
|
137 |
+
$content = '<img src="' . $image_array[ 0 ] . '" alt="' . $featured->media_title . '" />';
|
138 |
break;
|
139 |
default :
|
140 |
return false;
|
142 |
return $content;
|
143 |
}
|
144 |
|
145 |
+
function process () {
|
146 |
+
if ( ! isset ( $this->action_query->id ) )
|
147 |
return;
|
148 |
+
$return = array( );
|
149 |
$this->model = new RTMediaModel();
|
150 |
+
$actions = $this->model->get ( array( 'id' => $this->action_query->id ) );
|
151 |
+
$this->get ();
|
152 |
+
if ( intval ( $this->settings[ $actions[ 0 ]->media_type ] ) == 1 ) {
|
153 |
+
if ( $this->action_query->id == $this->featured ) {
|
154 |
+
$this->set ( 0 );
|
155 |
+
$return[ "next" ] = $this->label;
|
156 |
+
} else {
|
157 |
+
$this->set ( $this->action_query->id );
|
158 |
+
$return[ "next" ] = $this->undo_label;
|
159 |
}
|
160 |
+
$return[ "status" ] = true;
|
161 |
+
} else {
|
162 |
+
$return[ "status" ] = false;
|
163 |
+
$return[ "error" ] = "Media type is not allowed";
|
|
|
164 |
}
|
165 |
+
if ( isset ( $_REQUEST[ "json" ] ) && $_REQUEST[ "json" ] == "true" ) {
|
166 |
+
echo json_encode ( $return );
|
167 |
+
die ();
|
168 |
} else {
|
169 |
+
wp_safe_redirect ( $_SERVER[ "HTTP_REFERER" ] );
|
170 |
}
|
171 |
}
|
172 |
|
173 |
}
|
174 |
|
175 |
+
function rtmedia_featured ( $user_id = false ) {
|
176 |
+
echo rtmedia_get_featured ( $user_id );
|
177 |
}
|
178 |
|
179 |
+
function rtmedia_get_featured ( $user_id = false ) {
|
180 |
+
$featured = new RTMediaFeatured ( $user_id, false );
|
181 |
+
return $featured->content ();
|
182 |
}
|
183 |
+
|
184 |
+
if ( ! function_exists ( "bp_media_featured" ) ) {
|
185 |
+
|
186 |
+
function bp_media_featured ( $user_id = false ) {
|
187 |
+
echo rtmedia_get_featured ( $user_id );
|
188 |
}
|
189 |
|
190 |
+
function bp_media_get_featured ( $user_id = false ) {
|
191 |
+
return rtmedia_get_featured ( $user_id );
|
192 |
}
|
|
|
193 |
|
194 |
+
}
|
195 |
?>
|
app/main/controllers/media/RTMediaMedia.php
CHANGED
@@ -29,26 +29,26 @@ class RTMediaMedia {
|
|
29 |
/**
|
30 |
* Initialises the model object of the mediua object
|
31 |
*/
|
32 |
-
public function __construct() {
|
33 |
|
34 |
$this->model = new RTMediaModel();
|
35 |
-
|
36 |
|
37 |
/**
|
38 |
* Generate nonce
|
39 |
* @param boolean $echo whether nonce should be echoed
|
40 |
* @return string json encoded nonce
|
41 |
*/
|
42 |
-
static function media_nonce_generator($id, $echo = true) {
|
43 |
-
if ($echo) {
|
44 |
-
wp_nonce_field('rtmedia_' . $id, 'rtmedia_media_nonce');
|
45 |
} else {
|
46 |
$token = array(
|
47 |
'action' => 'rtmedia_media_nonce',
|
48 |
-
'nonce' => wp_create_nonce('rtmedia_' . $id)
|
49 |
);
|
50 |
|
51 |
-
return json_encode($token);
|
52 |
}
|
53 |
}
|
54 |
|
@@ -59,12 +59,12 @@ class RTMediaMedia {
|
|
59 |
* @param string $mode The upload mode
|
60 |
* @return boolean whether the nonce is valid
|
61 |
*/
|
62 |
-
function verify_nonce($mode) {
|
63 |
|
64 |
-
$nonce = $_REQUEST["rtmedia_{$mode}_media_nonce"];
|
65 |
-
$mode = $_REQUEST['mode'];
|
66 |
|
67 |
-
if (wp_verify_nonce($nonce, 'rtmedia_' . $mode))
|
68 |
return true;
|
69 |
else
|
70 |
return false;
|
@@ -74,8 +74,8 @@ class RTMediaMedia {
|
|
74 |
* Adds a hook to delete_attachment tag called
|
75 |
* when a media is deleted externally out of rtMedia context
|
76 |
*/
|
77 |
-
public function delete_hook() {
|
78 |
-
add_action('delete_attachment', array($this, 'delete_wordpress_attachment'));
|
79 |
}
|
80 |
|
81 |
/**
|
@@ -83,16 +83,16 @@ class RTMediaMedia {
|
|
83 |
* @param array $attachments ids of the attachments created after upload
|
84 |
* @param array $taxonomies array of terms indexed by a taxonomy
|
85 |
*/
|
86 |
-
function add_taxonomy($attachments, $taxonomies) {
|
87 |
|
88 |
-
foreach ($attachments as $id) {
|
89 |
|
90 |
-
foreach ($taxonomies as $taxonomy => $terms) {
|
91 |
-
if (!taxonomy_exists($taxonomy)) {
|
92 |
continue;
|
93 |
}
|
94 |
|
95 |
-
wp_set_object_terms($id, $terms, $taxonomy);
|
96 |
}
|
97 |
}
|
98 |
}
|
@@ -103,19 +103,19 @@ class RTMediaMedia {
|
|
103 |
* @param array $custom_fields array of key value pairs of meta
|
104 |
* @return boolean success of meta
|
105 |
*/
|
106 |
-
function add_meta($attachments, $custom_fields) {
|
107 |
|
108 |
-
foreach ($attachments as $id) {
|
109 |
-
$row = array('media_id' => $id);
|
110 |
|
111 |
-
foreach ($custom_fields as $key => $value) {
|
112 |
|
113 |
-
if (!is_null($value)) {
|
114 |
-
$row['meta_key'] = $key;
|
115 |
-
$row['meta_value'] = $value;
|
116 |
-
$status = add_rtmedia_meta($id, $key, $value);
|
117 |
|
118 |
-
if (get_class($status) == 'WP_Error' || $status == 0)
|
119 |
return false;
|
120 |
}
|
121 |
}
|
@@ -129,8 +129,8 @@ class RTMediaMedia {
|
|
129 |
* for handling taxonomies
|
130 |
* @return boolean
|
131 |
*/
|
132 |
-
function is_multisite() {
|
133 |
-
return is_multisite();
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -140,30 +140,30 @@ class RTMediaMedia {
|
|
140 |
* @param type $file_object
|
141 |
* @return type
|
142 |
*/
|
143 |
-
function add($uploaded, $file_object) {
|
144 |
|
145 |
/* action to perform any task before adding a media */
|
146 |
-
do_action('rtmedia_before_add_media', $file_object, $uploaded);
|
147 |
|
148 |
/* Generate media details required to feed in database */
|
149 |
-
$attachments = $this->generate_post_array($uploaded, $file_object);
|
150 |
|
151 |
/* Insert the media as an attachment in Wordpress context */
|
152 |
-
$attachment_ids = $this->insert_attachment($attachments, $file_object);
|
153 |
|
154 |
/* check for multisite and if valid then add taxonomies */
|
155 |
-
if (
|
156 |
-
$this->add_taxonomy($attachment_ids, $uploaded['taxonomy']);
|
157 |
|
158 |
/* fetch custom fields and add them to meta table */
|
159 |
-
$this->add_meta($attachment_ids, $uploaded['custom_fields']);
|
160 |
|
161 |
|
162 |
/* add media in rtMedia context */
|
163 |
-
$media_ids = $this->insertmedia($attachment_ids, $uploaded);
|
164 |
|
165 |
/* action to perform any task after adding a media */
|
166 |
-
do_action('rtmedia_after_add_media', $media_ids, $file_object, $uploaded);
|
167 |
|
168 |
return $media_ids;
|
169 |
}
|
@@ -175,34 +175,34 @@ class RTMediaMedia {
|
|
175 |
* @param type $meta
|
176 |
* @return boolean
|
177 |
*/
|
178 |
-
function update($id, $data, $media_id) {
|
179 |
|
180 |
/* action to perform any task before updating a media */
|
181 |
-
do_action('rtmedia_before_update_media', $id);
|
182 |
|
183 |
-
$defaults = array();
|
184 |
-
$data = wp_parse_args($data, $defaults);
|
185 |
-
$where = array('id' => $id);
|
186 |
|
187 |
-
if (array_key_exists('media_title', $data) || array_key_exists('description', $data)) {
|
188 |
-
$post_data['ID'] = $media_id;
|
189 |
-
if (isset($data['media_title'])) {
|
190 |
-
$post_data['post_title'] = $data['media_title'];
|
191 |
-
$post_data['post_name'] = sanitize_title($data['media_title']);
|
192 |
}
|
193 |
-
if (isset($data['description'])) {
|
194 |
-
$post_data['post_content'] = $data['description'];
|
195 |
-
unset($data['description']);
|
196 |
}
|
197 |
-
wp_update_post($post_data);
|
198 |
}
|
199 |
|
200 |
-
$status = $this->model->update($data, $where);
|
201 |
|
202 |
/* action to perform any task after updating a media */
|
203 |
-
do_action('rtmedia_after_update_media', $id);
|
204 |
|
205 |
-
if ($status
|
206 |
return false;
|
207 |
} else {
|
208 |
return true;
|
@@ -215,11 +215,11 @@ class RTMediaMedia {
|
|
215 |
* @param type $media_id
|
216 |
* @return boolean
|
217 |
*/
|
218 |
-
function delete_wordpress_attachment($id){
|
219 |
-
$media = $this->model->get(array('media_id' => $id), false, false);
|
220 |
|
221 |
-
if ($media) {
|
222 |
-
$this->delete($media[0]->id,true);
|
223 |
}
|
224 |
}
|
225 |
|
@@ -229,43 +229,49 @@ class RTMediaMedia {
|
|
229 |
* @param type $media_id
|
230 |
* @return boolean
|
231 |
*/
|
232 |
-
function delete($id
|
233 |
-
do_action('rtmedia_before_delete_media', $id);
|
234 |
-
|
235 |
-
$media = $this->model->get(array('id' => $id), false, false);
|
236 |
|
237 |
$status = 0;
|
238 |
|
239 |
-
if ($media) {
|
240 |
/* delete meta */
|
241 |
//delete_rtmedia_meta($id);
|
242 |
-
if($delete_activity){
|
243 |
-
if ($media[0]->activity_id && function_exists('bp_activity_delete_by_activity_id')){
|
244 |
-
$related_media = $this->model->get(array('activity_id' => $media[0]->activity_id), false, false);
|
245 |
-
if(count($related_media) > 1 ){
|
246 |
-
$activity_media = array();
|
247 |
-
foreach($related_media as $temp_media){
|
248 |
-
if($temp_media->id == $id)
|
249 |
continue;
|
250 |
-
$activity_media[]
|
251 |
}
|
252 |
-
$objActivity = new RTMediaActivity($activity_media);
|
253 |
global $wpdb, $bp;
|
254 |
-
$wpdb->update($bp->activity->table_name, array("type" => "rtmedia_update", "content" => $objActivity->create_activity_html()), array("id" => $media[0]->activity_id));
|
255 |
-
}else{
|
256 |
-
bp_activity_delete_by_activity_id ($media[0]->activity_id);
|
257 |
}
|
258 |
}
|
259 |
}
|
260 |
-
if(
|
261 |
-
wp_delete_attachment($media[0]->media_id, true);
|
262 |
-
$status = $this->model->delete(array('id' => $id));
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
264 |
|
265 |
-
if ($status == 0) {
|
266 |
return false;
|
267 |
} else {
|
268 |
-
do_action('rtmedia_after_delete_media', $id);
|
269 |
return true;
|
270 |
}
|
271 |
}
|
@@ -278,31 +284,31 @@ class RTMediaMedia {
|
|
278 |
* @param type $album_id
|
279 |
* @return boolean
|
280 |
*/
|
281 |
-
function move($media_id, $album_id) {
|
282 |
|
283 |
global $wpdb;
|
284 |
/* update the post_parent value in wp_post table */
|
285 |
-
$status = $wpdb->update($wpdb->posts, array('post_parent' => $album_id), array('ID' => $media_id));
|
286 |
|
287 |
-
if (get_class($status) == 'WP_Error' || $status == 0) {
|
288 |
return false;
|
289 |
} else {
|
290 |
/* update album_id, context, context_id and privacy in rtMedia context */
|
291 |
-
$album_data = $this->model->get(array('media_id' => $media_id));
|
292 |
$data = array(
|
293 |
'album_id' => $album_id,
|
294 |
'context' => $album_data->context,
|
295 |
'context_id' => $album_data->context_id,
|
296 |
'privacy' => $album_data->privacy
|
297 |
);
|
298 |
-
return $this->update($media_id, $data);
|
299 |
}
|
300 |
}
|
301 |
|
302 |
/**
|
303 |
* Imports attachment as media
|
304 |
*/
|
305 |
-
function import_attachment() {
|
306 |
|
307 |
}
|
308 |
|
@@ -310,13 +316,13 @@ class RTMediaMedia {
|
|
310 |
* Check if BuddyPress and the activity component are enabled
|
311 |
* @return boolean
|
312 |
*/
|
313 |
-
function activity_enabled() {
|
314 |
|
315 |
-
if (!function_exists('bp_is_active') || !bp_is_active('activity'))
|
316 |
return false;
|
317 |
|
318 |
-
|
319 |
-
return $rtmedia->options['buddypress_enableOnActivity'];
|
320 |
}
|
321 |
|
322 |
/**
|
@@ -325,25 +331,25 @@ class RTMediaMedia {
|
|
325 |
* @param type $file_object
|
326 |
* @return type
|
327 |
*/
|
328 |
-
function generate_post_array($uploaded, $file_object) {
|
329 |
-
if ($uploaded['album_id']) {
|
330 |
$model = new RTMediaModel();
|
331 |
-
$parent_details = $model->get(array('id' => $uploaded['album_id']));
|
332 |
-
$album_id = $parent_details[0]->media_id;
|
333 |
} else {
|
334 |
$album_id = 0;
|
335 |
}
|
336 |
-
if ( ! in_array( $uploaded["context"]
|
337 |
-
$album_id = $uploaded["context_id"];
|
338 |
}
|
339 |
-
foreach ($file_object as $file) {
|
340 |
-
$attachments[] = array(
|
341 |
-
'post_mime_type' => $file['type'],
|
342 |
-
'guid' => $file['url'],
|
343 |
-
'post_title' => $uploaded['title'] ? $uploaded['title'] : $file['name'],
|
344 |
-
'post_content' => $uploaded['description'] ? $uploaded['description'] : '',
|
345 |
'post_parent' => $album_id,
|
346 |
-
'post_author' => $uploaded['media_author']
|
347 |
);
|
348 |
}
|
349 |
return $attachments;
|
@@ -356,17 +362,17 @@ class RTMediaMedia {
|
|
356 |
* @return type
|
357 |
* @throws Exception
|
358 |
*/
|
359 |
-
function insert_attachment($attachments, $file_object) {
|
360 |
-
foreach ($attachments as $key => $attachment) {
|
361 |
-
$attachment_id = wp_insert_attachment($attachment, $file_object[$key]['file'], $attachment['post_parent']);
|
362 |
-
if (!is_wp_error($attachment_id)) {
|
363 |
-
add_filter('intermediate_image_sizes', array($this, 'image_sizes'), 99);
|
364 |
-
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file_object[$key]['file']));
|
365 |
} else {
|
366 |
-
unlink($file_object[$key]['file']);
|
367 |
-
throw new Exception(__('Error creating attachment for the media file, please try again', 'buddypress-media'));
|
368 |
}
|
369 |
-
$updated_attachment_ids[] = $attachment_id;
|
370 |
}
|
371 |
|
372 |
return $updated_attachment_ids;
|
@@ -377,30 +383,30 @@ class RTMediaMedia {
|
|
377 |
* @param type $sizes
|
378 |
* @return type
|
379 |
*/
|
380 |
-
function image_sizes($sizes) {
|
381 |
-
return array('rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image');
|
382 |
}
|
383 |
|
384 |
/**
|
385 |
*
|
386 |
* @param type $attributes
|
387 |
*/
|
388 |
-
function insert_album($attributes) {
|
389 |
|
390 |
-
return $this->model->insert($attributes);
|
391 |
}
|
392 |
|
393 |
-
function set_media_type($mime_type) {
|
394 |
-
switch ($mime_type) {
|
395 |
case 'image':
|
396 |
-
|
397 |
-
|
398 |
case 'audio':
|
399 |
-
|
400 |
-
|
401 |
default:
|
402 |
-
|
403 |
-
|
404 |
}
|
405 |
}
|
406 |
|
@@ -409,60 +415,60 @@ class RTMediaMedia {
|
|
409 |
* @param type $attachment_ids
|
410 |
* @param type $uploaded
|
411 |
*/
|
412 |
-
function insertmedia($attachment_ids, $uploaded) {
|
413 |
|
414 |
$defaults = array(
|
415 |
-
'activity_id' => $this->activity_enabled(),
|
416 |
'privacy' => 0
|
417 |
);
|
418 |
|
419 |
-
$uploaded = wp_parse_args($uploaded, $defaults);
|
420 |
|
421 |
-
$blog_id = get_current_blog_id();
|
422 |
-
$media_id = Array();
|
423 |
-
foreach ($attachment_ids as $id) {
|
424 |
-
$attachment = get_post($id, ARRAY_A);
|
425 |
-
$mime_type = explode('/', $attachment['post_mime_type']);
|
426 |
|
427 |
$media = array(
|
428 |
'blog_id' => $blog_id,
|
429 |
'media_id' => $id,
|
430 |
-
'album_id' => $uploaded['album_id'],
|
431 |
-
'media_author' => $attachment['post_author'],
|
432 |
-
'media_title' => $attachment['post_title'],
|
433 |
-
'media_type' => $this->set_media_type($mime_type[0]),
|
434 |
-
'context' => $uploaded['context'],
|
435 |
-
'context_id' => $uploaded['context_id'],
|
436 |
-
'privacy' => $uploaded['privacy']
|
437 |
);
|
438 |
|
439 |
-
$media_id[] = $this->model->insert($media);
|
440 |
}
|
441 |
return $media_id;
|
442 |
}
|
443 |
|
444 |
-
function insert_activity($id, $media) {
|
445 |
-
if (
|
446 |
return;
|
447 |
-
$activity = new RTMediaActivity($id, $media->privacy);
|
448 |
-
$activity_content = $activity->create_activity_html();
|
449 |
-
$user = get_userdata($media->media_author);
|
450 |
-
$username = '<a href="' . get_rtmedia_user_link($media->media_author) . '">' . $user->user_nicename . '</a>';
|
451 |
-
$count = count($id);
|
452 |
-
$media_const = 'RTMEDIA_' . strtoupper($media->media_type);
|
453 |
-
if ($count > 1) {
|
454 |
$media_const .= '_PLURAL';
|
455 |
}
|
456 |
$media_const.='_LABEL';
|
457 |
|
458 |
-
$media_str = constant($media_const);
|
459 |
|
460 |
-
$action = sprintf(
|
461 |
-
_n(
|
462 |
'%s added a %s', '%s added %d %s.', $count, 'rtmedia'
|
463 |
), $username, $media->media_type, $media_str
|
464 |
);
|
465 |
-
|
466 |
$activity_args = array(
|
467 |
'action' => $action,
|
468 |
'content' => $activity_content,
|
@@ -470,27 +476,26 @@ class RTMediaMedia {
|
|
470 |
'primary_link' => '',
|
471 |
'item_id' => $id
|
472 |
);
|
473 |
-
|
474 |
-
if($media->context == "group" && function_exists("bp_get_group_status") && bp_get_group_status(groups_get_group(array("group_id"=> $media->context_id)))!= "public"){
|
475 |
-
$activity_args["hide_sitewide"] = true;
|
476 |
}
|
477 |
-
|
478 |
-
if ($media->context == 'group' || 'profile') {
|
479 |
-
$activity_args['component'] = $media->context;
|
480 |
}
|
481 |
|
482 |
-
$activity_id = bp_activity_add($activity_args);
|
483 |
-
|
484 |
|
485 |
|
486 |
-
$this->model->update(
|
487 |
-
array('activity_id' => $activity_id), array('id' => $id)
|
488 |
);
|
489 |
|
490 |
return $activity_id;
|
491 |
}
|
492 |
|
493 |
-
|
494 |
}
|
495 |
|
496 |
?>
|
29 |
/**
|
30 |
* Initialises the model object of the mediua object
|
31 |
*/
|
32 |
+
public function __construct () {
|
33 |
|
34 |
$this->model = new RTMediaModel();
|
35 |
+
}
|
36 |
|
37 |
/**
|
38 |
* Generate nonce
|
39 |
* @param boolean $echo whether nonce should be echoed
|
40 |
* @return string json encoded nonce
|
41 |
*/
|
42 |
+
static function media_nonce_generator ( $id, $echo = true ) {
|
43 |
+
if ( $echo ) {
|
44 |
+
wp_nonce_field ( 'rtmedia_' . $id, 'rtmedia_media_nonce' );
|
45 |
} else {
|
46 |
$token = array(
|
47 |
'action' => 'rtmedia_media_nonce',
|
48 |
+
'nonce' => wp_create_nonce ( 'rtmedia_' . $id )
|
49 |
);
|
50 |
|
51 |
+
return json_encode ( $token );
|
52 |
}
|
53 |
}
|
54 |
|
59 |
* @param string $mode The upload mode
|
60 |
* @return boolean whether the nonce is valid
|
61 |
*/
|
62 |
+
function verify_nonce ( $mode ) {
|
63 |
|
64 |
+
$nonce = $_REQUEST[ "rtmedia_{$mode}_media_nonce" ];
|
65 |
+
$mode = $_REQUEST[ 'mode' ];
|
66 |
|
67 |
+
if ( wp_verify_nonce ( $nonce, 'rtmedia_' . $mode ) )
|
68 |
return true;
|
69 |
else
|
70 |
return false;
|
74 |
* Adds a hook to delete_attachment tag called
|
75 |
* when a media is deleted externally out of rtMedia context
|
76 |
*/
|
77 |
+
public function delete_hook () {
|
78 |
+
add_action ( 'delete_attachment', array( $this, 'delete_wordpress_attachment' ) );
|
79 |
}
|
80 |
|
81 |
/**
|
83 |
* @param array $attachments ids of the attachments created after upload
|
84 |
* @param array $taxonomies array of terms indexed by a taxonomy
|
85 |
*/
|
86 |
+
function add_taxonomy ( $attachments, $taxonomies ) {
|
87 |
|
88 |
+
foreach ( $attachments as $id ) {
|
89 |
|
90 |
+
foreach ( $taxonomies as $taxonomy => $terms ) {
|
91 |
+
if ( ! taxonomy_exists ( $taxonomy ) ) {
|
92 |
continue;
|
93 |
}
|
94 |
|
95 |
+
wp_set_object_terms ( $id, $terms, $taxonomy );
|
96 |
}
|
97 |
}
|
98 |
}
|
103 |
* @param array $custom_fields array of key value pairs of meta
|
104 |
* @return boolean success of meta
|
105 |
*/
|
106 |
+
function add_meta ( $attachments, $custom_fields ) {
|
107 |
|
108 |
+
foreach ( $attachments as $id ) {
|
109 |
+
$row = array( 'media_id' => $id );
|
110 |
|
111 |
+
foreach ( $custom_fields as $key => $value ) {
|
112 |
|
113 |
+
if ( ! is_null ( $value ) ) {
|
114 |
+
$row[ 'meta_key' ] = $key;
|
115 |
+
$row[ 'meta_value' ] = $value;
|
116 |
+
$status = add_rtmedia_meta ( $id, $key, $value );
|
117 |
|
118 |
+
if ( get_class ( $status ) == 'WP_Error' || $status == 0 )
|
119 |
return false;
|
120 |
}
|
121 |
}
|
129 |
* for handling taxonomies
|
130 |
* @return boolean
|
131 |
*/
|
132 |
+
function is_multisite () {
|
133 |
+
return is_multisite ();
|
134 |
}
|
135 |
|
136 |
/**
|
140 |
* @param type $file_object
|
141 |
* @return type
|
142 |
*/
|
143 |
+
function add ( $uploaded, $file_object ) {
|
144 |
|
145 |
/* action to perform any task before adding a media */
|
146 |
+
do_action ( 'rtmedia_before_add_media', $file_object, $uploaded );
|
147 |
|
148 |
/* Generate media details required to feed in database */
|
149 |
+
$attachments = $this->generate_post_array ( $uploaded, $file_object );
|
150 |
|
151 |
/* Insert the media as an attachment in Wordpress context */
|
152 |
+
$attachment_ids = $this->insert_attachment ( $attachments, $file_object );
|
153 |
|
154 |
/* check for multisite and if valid then add taxonomies */
|
155 |
+
if ( ! $this->is_multisite () )
|
156 |
+
$this->add_taxonomy ( $attachment_ids, $uploaded[ 'taxonomy' ] );
|
157 |
|
158 |
/* fetch custom fields and add them to meta table */
|
159 |
+
$this->add_meta ( $attachment_ids, $uploaded[ 'custom_fields' ] );
|
160 |
|
161 |
|
162 |
/* add media in rtMedia context */
|
163 |
+
$media_ids = $this->insertmedia ( $attachment_ids, $uploaded );
|
164 |
|
165 |
/* action to perform any task after adding a media */
|
166 |
+
do_action ( 'rtmedia_after_add_media', $media_ids, $file_object, $uploaded );
|
167 |
|
168 |
return $media_ids;
|
169 |
}
|
175 |
* @param type $meta
|
176 |
* @return boolean
|
177 |
*/
|
178 |
+
function update ( $id, $data, $media_id ) {
|
179 |
|
180 |
/* action to perform any task before updating a media */
|
181 |
+
do_action ( 'rtmedia_before_update_media', $id );
|
182 |
|
183 |
+
$defaults = array( );
|
184 |
+
$data = wp_parse_args ( $data, $defaults );
|
185 |
+
$where = array( 'id' => $id );
|
186 |
|
187 |
+
if ( array_key_exists ( 'media_title', $data ) || array_key_exists ( 'description', $data ) ) {
|
188 |
+
$post_data[ 'ID' ] = $media_id;
|
189 |
+
if ( isset ( $data[ 'media_title' ] ) ) {
|
190 |
+
$post_data[ 'post_title' ] = $data[ 'media_title' ];
|
191 |
+
$post_data[ 'post_name' ] = sanitize_title ( $data[ 'media_title' ] );
|
192 |
}
|
193 |
+
if ( isset ( $data[ 'description' ] ) ) {
|
194 |
+
$post_data[ 'post_content' ] = $data[ 'description' ];
|
195 |
+
unset ( $data[ 'description' ] );
|
196 |
}
|
197 |
+
wp_update_post ( $post_data );
|
198 |
}
|
199 |
|
200 |
+
$status = $this->model->update ( $data, $where );
|
201 |
|
202 |
/* action to perform any task after updating a media */
|
203 |
+
do_action ( 'rtmedia_after_update_media', $id );
|
204 |
|
205 |
+
if ( $status === false ) {
|
206 |
return false;
|
207 |
} else {
|
208 |
return true;
|
215 |
* @param type $media_id
|
216 |
* @return boolean
|
217 |
*/
|
218 |
+
function delete_wordpress_attachment ( $id ) {
|
219 |
+
$media = $this->model->get ( array( 'media_id' => $id ), false, false );
|
220 |
|
221 |
+
if ( $media ) {
|
222 |
+
$this->delete ( $media[ 0 ]->id, true );
|
223 |
}
|
224 |
}
|
225 |
|
229 |
* @param type $media_id
|
230 |
* @return boolean
|
231 |
*/
|
232 |
+
function delete ( $id, $core = false, $delete_activity = true ) {
|
233 |
+
do_action ( 'rtmedia_before_delete_media', $id );
|
234 |
+
|
235 |
+
$media = $this->model->get ( array( 'id' => $id ), false, false );
|
236 |
|
237 |
$status = 0;
|
238 |
|
239 |
+
if ( $media ) {
|
240 |
/* delete meta */
|
241 |
//delete_rtmedia_meta($id);
|
242 |
+
if ( $delete_activity ) {
|
243 |
+
if ( $media[ 0 ]->activity_id && function_exists ( 'bp_activity_delete_by_activity_id' ) ) {
|
244 |
+
$related_media = $this->model->get ( array( 'activity_id' => $media[ 0 ]->activity_id ), false, false );
|
245 |
+
if ( count ( $related_media ) > 1 ) {
|
246 |
+
$activity_media = array( );
|
247 |
+
foreach ( $related_media as $temp_media ) {
|
248 |
+
if ( $temp_media->id == $id )
|
249 |
continue;
|
250 |
+
$activity_media[ ] = $temp_media->id;
|
251 |
}
|
252 |
+
$objActivity = new RTMediaActivity ( $activity_media );
|
253 |
global $wpdb, $bp;
|
254 |
+
$wpdb->update ( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html () ), array( "id" => $media[ 0 ]->activity_id ) );
|
255 |
+
}else {
|
256 |
+
bp_activity_delete_by_activity_id ( $media[ 0 ]->activity_id );
|
257 |
}
|
258 |
}
|
259 |
}
|
260 |
+
if ( ! $core )
|
261 |
+
wp_delete_attachment ( $media[ 0 ]->media_id, true );
|
262 |
+
$status = $this->model->delete ( array( 'id' => $id ) );
|
263 |
+
$rtMediaNav = new RTMediaNav();
|
264 |
+
if ( $media[ 0 ]->context == "group" ) {
|
265 |
+
$rtMediaNav->refresh_counts ( $media[ 0 ]->context_id, array( "context" => $media[ 0 ]->context, 'context_id' => $media[ 0 ]->context_id ) );
|
266 |
+
} else {
|
267 |
+
$rtMediaNav->refresh_counts ( $media[ 0 ]->media_author, array( "context" => "profile", 'media_author' => $media[ 0 ]->media_author ) );
|
268 |
+
}
|
269 |
}
|
270 |
|
271 |
+
if ( $status == 0 ) {
|
272 |
return false;
|
273 |
} else {
|
274 |
+
do_action ( 'rtmedia_after_delete_media', $id );
|
275 |
return true;
|
276 |
}
|
277 |
}
|
284 |
* @param type $album_id
|
285 |
* @return boolean
|
286 |
*/
|
287 |
+
function move ( $media_id, $album_id ) {
|
288 |
|
289 |
global $wpdb;
|
290 |
/* update the post_parent value in wp_post table */
|
291 |
+
$status = $wpdb->update ( $wpdb->posts, array( 'post_parent' => $album_id ), array( 'ID' => $media_id ) );
|
292 |
|
293 |
+
if ( get_class ( $status ) == 'WP_Error' || $status == 0 ) {
|
294 |
return false;
|
295 |
} else {
|
296 |
/* update album_id, context, context_id and privacy in rtMedia context */
|
297 |
+
$album_data = $this->model->get ( array( 'media_id' => $media_id ) );
|
298 |
$data = array(
|
299 |
'album_id' => $album_id,
|
300 |
'context' => $album_data->context,
|
301 |
'context_id' => $album_data->context_id,
|
302 |
'privacy' => $album_data->privacy
|
303 |
);
|
304 |
+
return $this->update ( $media_id, $data );
|
305 |
}
|
306 |
}
|
307 |
|
308 |
/**
|
309 |
* Imports attachment as media
|
310 |
*/
|
311 |
+
function import_attachment () {
|
312 |
|
313 |
}
|
314 |
|
316 |
* Check if BuddyPress and the activity component are enabled
|
317 |
* @return boolean
|
318 |
*/
|
319 |
+
function activity_enabled () {
|
320 |
|
321 |
+
if ( ! function_exists ( 'bp_is_active' ) || ! bp_is_active ( 'activity' ) )
|
322 |
return false;
|
323 |
|
324 |
+
global $rtmedia;
|
325 |
+
return $rtmedia->options[ 'buddypress_enableOnActivity' ];
|
326 |
}
|
327 |
|
328 |
/**
|
331 |
* @param type $file_object
|
332 |
* @return type
|
333 |
*/
|
334 |
+
function generate_post_array ( $uploaded, $file_object ) {
|
335 |
+
if ( $uploaded[ 'album_id' ] ) {
|
336 |
$model = new RTMediaModel();
|
337 |
+
$parent_details = $model->get ( array( 'id' => $uploaded[ 'album_id' ] ) );
|
338 |
+
$album_id = $parent_details[ 0 ]->media_id;
|
339 |
} else {
|
340 |
$album_id = 0;
|
341 |
}
|
342 |
+
if ( ! in_array ( $uploaded[ "context" ], array( "profile", "group" ) ) ) {
|
343 |
+
$album_id = $uploaded[ "context_id" ];
|
344 |
}
|
345 |
+
foreach ( $file_object as $file ) {
|
346 |
+
$attachments[ ] = array(
|
347 |
+
'post_mime_type' => $file[ 'type' ],
|
348 |
+
'guid' => $file[ 'url' ],
|
349 |
+
'post_title' => $uploaded[ 'title' ] ? $uploaded[ 'title' ] : $file[ 'name' ],
|
350 |
+
'post_content' => $uploaded[ 'description' ] ? $uploaded[ 'description' ] : '',
|
351 |
'post_parent' => $album_id,
|
352 |
+
'post_author' => $uploaded[ 'media_author' ]
|
353 |
);
|
354 |
}
|
355 |
return $attachments;
|
362 |
* @return type
|
363 |
* @throws Exception
|
364 |
*/
|
365 |
+
function insert_attachment ( $attachments, $file_object ) {
|
366 |
+
foreach ( $attachments as $key => $attachment ) {
|
367 |
+
$attachment_id = wp_insert_attachment ( $attachment, $file_object[ $key ][ 'file' ], $attachment[ 'post_parent' ] );
|
368 |
+
if ( ! is_wp_error ( $attachment_id ) ) {
|
369 |
+
add_filter ( 'intermediate_image_sizes', array( $this, 'image_sizes' ), 99 );
|
370 |
+
wp_update_attachment_metadata ( $attachment_id, wp_generate_attachment_metadata ( $attachment_id, $file_object[ $key ][ 'file' ] ) );
|
371 |
} else {
|
372 |
+
unlink ( $file_object[ $key ][ 'file' ] );
|
373 |
+
throw new Exception ( __ ( 'Error creating attachment for the media file, please try again', 'buddypress-media' ) );
|
374 |
}
|
375 |
+
$updated_attachment_ids[ ] = $attachment_id;
|
376 |
}
|
377 |
|
378 |
return $updated_attachment_ids;
|
383 |
* @param type $sizes
|
384 |
* @return type
|
385 |
*/
|
386 |
+
function image_sizes ( $sizes ) {
|
387 |
+
return array( 'rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image' );
|
388 |
}
|
389 |
|
390 |
/**
|
391 |
*
|
392 |
* @param type $attributes
|
393 |
*/
|
394 |
+
function insert_album ( $attributes ) {
|
395 |
|
396 |
+
return $this->model->insert ( $attributes );
|
397 |
}
|
398 |
|
399 |
+
function set_media_type ( $mime_type ) {
|
400 |
+
switch ( $mime_type ) {
|
401 |
case 'image':
|
402 |
+
return 'photo';
|
403 |
+
break;
|
404 |
case 'audio':
|
405 |
+
return 'music';
|
406 |
+
break;
|
407 |
default:
|
408 |
+
return $mime_type;
|
409 |
+
break;
|
410 |
}
|
411 |
}
|
412 |
|
415 |
* @param type $attachment_ids
|
416 |
* @param type $uploaded
|
417 |
*/
|
418 |
+
function insertmedia ( $attachment_ids, $uploaded ) {
|
419 |
|
420 |
$defaults = array(
|
421 |
+
'activity_id' => $this->activity_enabled (),
|
422 |
'privacy' => 0
|
423 |
);
|
424 |
|
425 |
+
$uploaded = wp_parse_args ( $uploaded, $defaults );
|
426 |
|
427 |
+
$blog_id = get_current_blog_id ();
|
428 |
+
$media_id = Array( );
|
429 |
+
foreach ( $attachment_ids as $id ) {
|
430 |
+
$attachment = get_post ( $id, ARRAY_A );
|
431 |
+
$mime_type = explode ( '/', $attachment[ 'post_mime_type' ] );
|
432 |
|
433 |
$media = array(
|
434 |
'blog_id' => $blog_id,
|
435 |
'media_id' => $id,
|
436 |
+
'album_id' => $uploaded[ 'album_id' ],
|
437 |
+
'media_author' => $attachment[ 'post_author' ],
|
438 |
+
'media_title' => $attachment[ 'post_title' ],
|
439 |
+
'media_type' => $this->set_media_type ( $mime_type[ 0 ] ),
|
440 |
+
'context' => $uploaded[ 'context' ],
|
441 |
+
'context_id' => $uploaded[ 'context_id' ],
|
442 |
+
'privacy' => $uploaded[ 'privacy' ]
|
443 |
);
|
444 |
|
445 |
+
$media_id[ ] = $this->model->insert ( $media );
|
446 |
}
|
447 |
return $media_id;
|
448 |
}
|
449 |
|
450 |
+
function insert_activity ( $id, $media ) {
|
451 |
+
if ( ! $this->activity_enabled () )
|
452 |
return;
|
453 |
+
$activity = new RTMediaActivity ( $id, $media->privacy );
|
454 |
+
$activity_content = $activity->create_activity_html ();
|
455 |
+
$user = get_userdata ( $media->media_author );
|
456 |
+
$username = '<a href="' . get_rtmedia_user_link ( $media->media_author ) . '">' . $user->user_nicename . '</a>';
|
457 |
+
$count = count ( $id );
|
458 |
+
$media_const = 'RTMEDIA_' . strtoupper ( $media->media_type );
|
459 |
+
if ( $count > 1 ) {
|
460 |
$media_const .= '_PLURAL';
|
461 |
}
|
462 |
$media_const.='_LABEL';
|
463 |
|
464 |
+
$media_str = constant ( $media_const );
|
465 |
|
466 |
+
$action = sprintf (
|
467 |
+
_n (
|
468 |
'%s added a %s', '%s added %d %s.', $count, 'rtmedia'
|
469 |
), $username, $media->media_type, $media_str
|
470 |
);
|
471 |
+
|
472 |
$activity_args = array(
|
473 |
'action' => $action,
|
474 |
'content' => $activity_content,
|
476 |
'primary_link' => '',
|
477 |
'item_id' => $id
|
478 |
);
|
479 |
+
|
480 |
+
if ( $media->context == "group" && function_exists ( "bp_get_group_status" ) && bp_get_group_status ( groups_get_group ( array( "group_id" => $media->context_id ) ) ) != "public" ) {
|
481 |
+
$activity_args[ "hide_sitewide" ] = true;
|
482 |
}
|
483 |
+
|
484 |
+
if ( $media->context == 'group' || 'profile' ) {
|
485 |
+
$activity_args[ 'component' ] = $media->context;
|
486 |
}
|
487 |
|
488 |
+
$activity_id = bp_activity_add ( $activity_args );
|
489 |
+
bp_activity_update_meta ( $activity_id, 'rtmedia_privacy', ($media->privacy == 0) ? -1 : $media->privacy );
|
490 |
|
491 |
|
492 |
+
$this->model->update (
|
493 |
+
array( 'activity_id' => $activity_id ), array( 'id' => $id )
|
494 |
);
|
495 |
|
496 |
return $activity_id;
|
497 |
}
|
498 |
|
|
|
499 |
}
|
500 |
|
501 |
?>
|
app/main/controllers/media/RTMediaUserInteraction.php
CHANGED
@@ -153,7 +153,7 @@ class RTMediaUserInteraction {
|
|
153 |
$friends = new RTMediaFriends();
|
154 |
$friends = $friends->get_friends_cache($this->interactor);
|
155 |
|
156 |
-
if(in_array($this->owner,$friends)) return 40;
|
157 |
|
158 |
return 20;
|
159 |
}
|
153 |
$friends = new RTMediaFriends();
|
154 |
$friends = $friends->get_friends_cache($this->interactor);
|
155 |
|
156 |
+
if($friends && in_array($this->owner,$friends)) return 40;
|
157 |
|
158 |
return 20;
|
159 |
}
|
app/main/controllers/privacy/RTMediaFriends.php
CHANGED
@@ -24,8 +24,8 @@ class RTMediaFriends {
|
|
24 |
|
25 |
function get_friends_cache( $user ) {
|
26 |
|
27 |
-
if(!class_exists('BuddyPress')) return;
|
28 |
-
if(!bp_is_active('friends'))return;
|
29 |
|
30 |
if ( ! $user )
|
31 |
return array();
|
24 |
|
25 |
function get_friends_cache( $user ) {
|
26 |
|
27 |
+
if(!class_exists('BuddyPress')) return array();
|
28 |
+
if(!bp_is_active('friends'))return array();
|
29 |
|
30 |
if ( ! $user )
|
31 |
return array();
|
app/main/controllers/privacy/RTMediaPrivacy.php
CHANGED
@@ -34,18 +34,23 @@ class RTMediaPrivacy {
|
|
34 |
function select_privacy_ui() {
|
35 |
global $rtmedia;
|
36 |
|
37 |
-
if (
|
38 |
return false;
|
39 |
|
40 |
-
if (
|
41 |
return false;
|
42 |
|
43 |
global $rtmedia_media;
|
44 |
$default = 0;
|
45 |
if (isset($rtmedia_media->privacy))
|
46 |
$default = $rtmedia_media->privacy;
|
47 |
-
else
|
48 |
-
$default =
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
$form = new rtForm();
|
51 |
$attributes = array(
|
@@ -161,7 +166,12 @@ class RTMediaPrivacy {
|
|
161 |
return;
|
162 |
}
|
163 |
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
$settings_link = trailingslashit($user_domain . 'settings');
|
167 |
|
@@ -194,26 +204,34 @@ class RTMediaPrivacy {
|
|
194 |
function content() {
|
195 |
if (buddypress()->current_action != 'privacy')
|
196 |
return;
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
global $rtmedia;
|
199 |
-
|
200 |
-
'title' => __("Default Privacy", "rtmedia"),
|
201 |
-
'callback' => array("RTMediaFormHandler", "radio"),
|
202 |
-
'args' => array(
|
203 |
-
'key' => 'privacy_default',
|
204 |
-
'radios' => $rtmedia->privacy_settings['levels'],
|
205 |
-
'default' => get_user_meta(get_current_user_id(), 'rtmedia-default-privacy')
|
206 |
-
)
|
207 |
-
);
|
208 |
?>
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
212 |
<div class="columns large-5">
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
215 |
</div>
|
216 |
</div>
|
|
|
|
|
|
|
|
|
|
|
217 |
<?php
|
218 |
}
|
219 |
|
34 |
function select_privacy_ui() {
|
35 |
global $rtmedia;
|
36 |
|
37 |
+
if (!is_rtmedia_privacy_enable())
|
38 |
return false;
|
39 |
|
40 |
+
if (!is_rtmedia_privacy_user_overide())
|
41 |
return false;
|
42 |
|
43 |
global $rtmedia_media;
|
44 |
$default = 0;
|
45 |
if (isset($rtmedia_media->privacy))
|
46 |
$default = $rtmedia_media->privacy;
|
47 |
+
else {
|
48 |
+
$default = get_user_meta(get_current_user_id(), 'rtmedia-default-privacy',true);
|
49 |
+
if(!$default){
|
50 |
+
$default = get_rtmedia_default_privacy();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
|
55 |
$form = new rtForm();
|
56 |
$attributes = array(
|
166 |
return;
|
167 |
}
|
168 |
|
169 |
+
if(!is_rtmedia_privacy_enable()){
|
170 |
+
return ;
|
171 |
+
}
|
172 |
+
if(!is_rtmedia_privacy_user_overide()){
|
173 |
+
return ;
|
174 |
+
}
|
175 |
|
176 |
$settings_link = trailingslashit($user_domain . 'settings');
|
177 |
|
204 |
function content() {
|
205 |
if (buddypress()->current_action != 'privacy')
|
206 |
return;
|
207 |
+
|
208 |
+
if(isset($_POST["rtmedia-default-privacy"])){
|
209 |
+
update_user_meta(get_current_user_id(), 'rtmedia-default-privacy', $_POST["rtmedia-default-privacy"]);
|
210 |
+
}
|
211 |
+
$default_privacy = get_user_meta(get_current_user_id(), 'rtmedia-default-privacy',true);
|
212 |
+
if($default_privacy === false){
|
213 |
+
$default_privacy = get_rtmedia_default_privacy();
|
214 |
+
}
|
215 |
global $rtmedia;
|
216 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
?>
|
218 |
+
<form method='post'>
|
219 |
+
<div class="">
|
220 |
+
<div class="section">
|
221 |
+
<div class="columns large-2"><h2><?php echo __("Default Privacy", "rtmedia"); ?></h2></div>
|
222 |
<div class="columns large-5">
|
223 |
+
<?php
|
224 |
+
foreach($rtmedia->privacy_settings['levels'] as $level=>$data){ ?>
|
225 |
+
<label><input type='radio' value='<?php echo $level;?>' name ='rtmedia-default-privacy' <?php echo ($default_privacy == $level)?"checked":""; ?> /> <?php _e($data);?></label><br/>
|
226 |
+
<?php } ?>
|
227 |
+
</div>
|
228 |
</div>
|
229 |
</div>
|
230 |
+
<br/>
|
231 |
+
<div class="submit">
|
232 |
+
<input type="submit" name="submit" value="<?php _e("Save Changes"); ?>" id="submit" class="auto">
|
233 |
+
</div>
|
234 |
+
</form>
|
235 |
<?php
|
236 |
}
|
237 |
|
app/main/controllers/shortcodes/RTMediaGalleryShortcode.php
CHANGED
@@ -14,96 +14,107 @@
|
|
14 |
*/
|
15 |
class RTMediaGalleryShortcode {
|
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 |
-
* Helper function to check whether the shortcode should be rendered or not
|
66 |
-
*
|
67 |
-
* @return type
|
68 |
-
*/
|
69 |
-
static function display_allowed() {
|
70 |
-
$flag=true;
|
71 |
-
|
72 |
-
//$flag = !(is_home() || is_post_type_archive() || is_author());
|
73 |
-
$flag = apply_filters('before_rtmedia_gallery_display', $flag);
|
74 |
-
return $flag;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Render a shortcode according to the attributes passed with it
|
79 |
-
*
|
80 |
-
* @param boolean $attr
|
81 |
-
*/
|
82 |
-
static function render($attr) {
|
83 |
-
if (self::display_allowed()) {
|
84 |
-
self::$add_script = true;
|
85 |
-
|
86 |
-
ob_start();
|
87 |
-
|
88 |
-
if ((!isset($attr)) || empty($attr))
|
89 |
-
$attr = true;
|
90 |
-
|
91 |
-
$attr = array('name' => 'gallery', 'attr' => $attr);
|
92 |
-
|
93 |
-
$template = new RTMediaTemplate();
|
94 |
-
$template->set_template('media-gallery', $attr);
|
95 |
-
|
96 |
-
return ob_get_clean();
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
static function print_script() {
|
101 |
-
if (!self::$add_script)
|
102 |
-
return;
|
103 |
-
if (!wp_script_is('rtmedia-backbone')){
|
104 |
-
wp_print_scripts('rtmedia-backbone');
|
105 |
-
}
|
106 |
-
}
|
107 |
|
108 |
}
|
109 |
|
14 |
*/
|
15 |
class RTMediaGalleryShortcode {
|
16 |
|
17 |
+
static $add_script;
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct () {
|
23 |
+
|
24 |
+
add_shortcode ( 'rtmedia_gallery', array( 'RTMediaGalleryShortcode', 'render' ) );
|
25 |
+
//add_action('init', array($this, 'register_scripts'));
|
26 |
+
//add_action('wp_footer', array($this, 'print_script'));
|
27 |
+
}
|
28 |
+
|
29 |
+
function register_scripts () {
|
30 |
+
wp_enqueue_script ( 'plupload-all' );
|
31 |
+
wp_enqueue_script ( 'rtmedia-backbone', RTMEDIA_URL . 'app/assets/js/rtMedia.backbone.js', array( 'plupload', 'backbone' ), false, true );
|
32 |
+
$template_url = RTMediaTemplate::locate_template ( "media-gallery-item", "media/", true );
|
33 |
+
wp_localize_script ( 'rtmedia-backbone', 'template_url', $template_url );
|
34 |
+
$url = trailingslashit ( $_SERVER[ "REQUEST_URI" ] );
|
35 |
+
|
36 |
+
if ( strpos ( $url, "/media" ) !== false ) {
|
37 |
+
$url_array = split ( "/media", $url );
|
38 |
+
$url = trailingslashit ( $url_array[ 0 ] ) . "upload/";
|
39 |
+
} else {
|
40 |
+
$url = trailingslashit ( $url ) . "upload/";
|
41 |
+
}
|
42 |
+
|
43 |
+
$params = array(
|
44 |
+
'url' => $url,
|
45 |
+
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
46 |
+
'browse_button' => 'rtMedia-upload-button',
|
47 |
+
'container' => 'rtmedia-upload-container',
|
48 |
+
'drop_element' => 'drag-drop-area',
|
49 |
+
'filters' => apply_filters ( 'rtmedia_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => get_rtmedia_allowed_upload_type () ) ) ),
|
50 |
+
'max_file_size' => min ( array( ini_get ( 'upload_max_filesize' ), ini_get ( 'post_max_size' ) ) ),
|
51 |
+
'multipart' => true,
|
52 |
+
'urlstream_upload' => true,
|
53 |
+
'flash_swf_url' => includes_url ( 'js/plupload/plupload.flash.swf' ),
|
54 |
+
'silverlight_xap_url' => includes_url ( 'js/plupload/plupload.silverlight.xap' ),
|
55 |
+
'file_data_name' => 'rtmedia_file', // key passed to $_FILE.
|
56 |
+
'multi_selection' => true,
|
57 |
+
'multipart_params' => apply_filters ( 'rtmedia-multi-params', array( 'redirect' => 'no', 'action' => 'wp_handle_upload', '_wp_http_referer' => $_SERVER[ 'REQUEST_URI' ], 'mode' => 'file_upload', 'rtmedia_upload_nonce' => RTMediaUploadView::upload_nonce_generator ( false, true ) ) )
|
58 |
+
);
|
59 |
+
wp_localize_script ( 'rtmedia-backbone', 'rtMedia_plupload_config', $params );
|
60 |
+
wp_localize_script ( 'rtmedia-backbone', 'rMedia_loading_file', admin_url ( "/images/loading.gif" ) );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Helper function to check whether the shortcode should be rendered or not
|
65 |
+
*
|
66 |
+
* @return type
|
67 |
+
*/
|
68 |
+
static function display_allowed () {
|
69 |
+
$flag = true;
|
70 |
+
|
71 |
+
//$flag = !(is_home() || is_post_type_archive() || is_author());
|
72 |
+
$flag = apply_filters ( 'before_rtmedia_gallery_display', $flag );
|
73 |
+
return $flag;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Render a shortcode according to the attributes passed with it
|
78 |
+
*
|
79 |
+
* @param boolean $attr
|
80 |
+
*/
|
81 |
+
static function render ( $attr ) {
|
82 |
+
if ( self::display_allowed () ) {
|
83 |
+
self::$add_script = true;
|
84 |
+
|
85 |
+
ob_start ();
|
86 |
+
|
87 |
+
if ( ( ! isset ( $attr )) || empty ( $attr ) )
|
88 |
+
$attr = true;
|
89 |
+
|
90 |
+
$attr = array( 'name' => 'gallery', 'attr' => $attr );
|
91 |
+
global $post;
|
92 |
+
if ( isset ( $attr ) && isset ( $attr[ "attr" ] ) ) {
|
93 |
+
if ( ! is_array ( $attr[ "attr" ] ) ) {
|
94 |
+
$attr[ "attr" ] = Array( );
|
95 |
}
|
96 |
+
if ( ! isset ( $attr[ "attr" ][ "context_id" ] ) && isset ( $post->ID ) ) {
|
97 |
+
$attr[ "attr" ][ "context_id" ] = $post->ID;
|
98 |
+
}
|
99 |
+
if ( ! isset ( $attr[ "attr" ][ "context" ] ) && isset ( $post->post_type ) ) {
|
100 |
+
$attr[ "attr" ][ "context" ] = $post->post_type;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
$template = new RTMediaTemplate();
|
105 |
+
$template->set_template ( 'media-gallery', $attr );
|
106 |
+
|
107 |
+
return ob_get_clean ();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
static function print_script () {
|
112 |
+
if ( ! self::$add_script )
|
113 |
+
return;
|
114 |
+
if ( ! wp_script_is ( 'rtmedia-backbone' ) ) {
|
115 |
+
wp_print_scripts ( 'rtmedia-backbone' );
|
116 |
+
}
|
117 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
}
|
120 |
|
app/main/controllers/shortcodes/RTMediaUploadShortcode.php
CHANGED
@@ -16,17 +16,16 @@ class RTMediaUploadShortcode {
|
|
16 |
/**
|
17 |
*
|
18 |
*/
|
19 |
-
public function __construct() {
|
20 |
|
21 |
|
22 |
|
23 |
-
add_shortcode('rtmedia_uploader', array('RTMediaUploadShortcode', 'pre_render'));
|
24 |
-
$method_name = strtolower(str_replace('RTMedia', '', __CLASS__));
|
25 |
|
26 |
-
if (is_callable("RTMediaDeprecated::{$method_name}", true, $callable_name)) {
|
27 |
-
$this->deprecated = RTMediaDeprecated::$method_name();
|
28 |
}
|
29 |
-
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -34,11 +33,10 @@ class RTMediaUploadShortcode {
|
|
34 |
*
|
35 |
* @return type
|
36 |
*/
|
37 |
-
static function display_allowed() {
|
38 |
-
|
39 |
-
$flag = (!(is_home() || is_post_type_archive() || is_author())) && is_user_logged_in();
|
40 |
|
41 |
-
$flag =
|
|
|
42 |
return $flag;
|
43 |
}
|
44 |
|
@@ -47,17 +45,30 @@ class RTMediaUploadShortcode {
|
|
47 |
*
|
48 |
* @param type $attr
|
49 |
*/
|
50 |
-
static function pre_render($attr) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
if (self::display_allowed()) {
|
53 |
|
54 |
-
ob_start();
|
55 |
|
56 |
self::$add_sc_script = true;
|
57 |
-
RTMediaUploadTemplate::render($attr);
|
58 |
|
59 |
self::$uploader_displayed = true;
|
60 |
-
return ob_get_clean();
|
61 |
}
|
62 |
}
|
63 |
|
16 |
/**
|
17 |
*
|
18 |
*/
|
19 |
+
public function __construct () {
|
20 |
|
21 |
|
22 |
|
23 |
+
add_shortcode ( 'rtmedia_uploader', array( 'RTMediaUploadShortcode', 'pre_render' ) );
|
24 |
+
$method_name = strtolower ( str_replace ( 'RTMedia', '', __CLASS__ ) );
|
25 |
|
26 |
+
if ( is_callable ( "RTMediaDeprecated::{$method_name}", true, $callable_name ) ) {
|
27 |
+
$this->deprecated = RTMediaDeprecated::$method_name ();
|
28 |
}
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
33 |
*
|
34 |
* @return type
|
35 |
*/
|
36 |
+
static function display_allowed () {
|
|
|
|
|
37 |
|
38 |
+
$flag = ( ! (is_home () || is_post_type_archive () || is_author ())) && is_user_logged_in () && (is_rtmedia_upload_music_enabled () || is_rtmedia_upload_photo_enabled () || is_rtmedia_upload_video_enabled ());
|
39 |
+
$flag = apply_filters ( 'before_rtmedia_uploader_display', $flag );
|
40 |
return $flag;
|
41 |
}
|
42 |
|
45 |
*
|
46 |
* @param type $attr
|
47 |
*/
|
48 |
+
static function pre_render ( $attr ) {
|
49 |
+
|
50 |
+
global $post;
|
51 |
+
if ( isset ( $attr ) && isset ( $attr[ "attr" ] ) ) {
|
52 |
+
if ( ! is_array ( $attr ) ) {
|
53 |
+
$attr = Array( );
|
54 |
+
}
|
55 |
+
if ( ! isset ( $attr[ "context_id" ] ) && isset ( $post->ID ) ) {
|
56 |
+
$attr[ "context_id" ] = $post->ID;
|
57 |
+
}
|
58 |
+
if ( ! isset ( $attr[ "context" ] ) && isset ( $post->post_type ) ) {
|
59 |
+
$attr[ "context" ] = $post->post_type;
|
60 |
+
}
|
61 |
+
}
|
62 |
|
63 |
+
if ( self::display_allowed () ) {
|
64 |
|
65 |
+
ob_start ();
|
66 |
|
67 |
self::$add_sc_script = true;
|
68 |
+
RTMediaUploadTemplate::render ( $attr );
|
69 |
|
70 |
self::$uploader_displayed = true;
|
71 |
+
return ob_get_clean ();
|
72 |
}
|
73 |
}
|
74 |
|
app/main/controllers/template/RTMediaAJAX.php
CHANGED
@@ -16,11 +16,11 @@ class RTMediaAJAX {
|
|
16 |
add_action('wp_ajax_rtmedia_backbone_template',array($this,'backbone_template'));
|
17 |
add_action('wp_ajax_rtmedia_create_album',array($this,'create_album'));
|
18 |
}
|
19 |
-
|
20 |
function backbone_template() {
|
21 |
include RTMEDIA_PATH.'templates/media/media-gallery-item.php';
|
22 |
}
|
23 |
-
|
24 |
function create_album(){
|
25 |
if ( isset($_POST['name']) && $_POST['name'] && is_rtmedia_album_enable()) {
|
26 |
if(isset($_POST['context']) && $_POST['context'] =="group"){
|
16 |
add_action('wp_ajax_rtmedia_backbone_template',array($this,'backbone_template'));
|
17 |
add_action('wp_ajax_rtmedia_create_album',array($this,'create_album'));
|
18 |
}
|
19 |
+
|
20 |
function backbone_template() {
|
21 |
include RTMEDIA_PATH.'templates/media/media-gallery-item.php';
|
22 |
}
|
23 |
+
|
24 |
function create_album(){
|
25 |
if ( isset($_POST['name']) && $_POST['name'] && is_rtmedia_album_enable()) {
|
26 |
if(isset($_POST['context']) && $_POST['context'] =="group"){
|
app/main/controllers/template/RTMediaNav.php
CHANGED
@@ -1,73 +1,67 @@
|
|
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 RTMediaNav
|
10 |
-
*
|
11 |
-
* @author saurabh
|
12 |
-
*/
|
13 |
class RTMediaNav {
|
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 |
// 'parent' => 'my-account',
|
72 |
// 'id' => 'my-account-buddypress',
|
73 |
// 'title' => __( 'My Account' ),
|
@@ -76,24 +70,24 @@ class RTMediaNav {
|
|
76 |
// 'class' => 'ab-sub-secondary'
|
77 |
// )
|
78 |
// ) );
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
// $wp_admin_bar->add_menu( array(
|
99 |
// 'parent' => 'my-account-' . RTMEDIA_MEDIA_SLUG,
|
@@ -102,219 +96,255 @@ class RTMediaNav {
|
|
102 |
// 'href' => trailingslashit( get_rtmedia_user_link( get_current_user_id() ) ) . 'media/'.RTMediaAlbum::get_default().'/'
|
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 |
// if(isset($rtmedia_query->action_query->id) && $rtmedia_query->action_query->id==RTMediaAlbum::get_default())
|
143 |
// $global_album = 'class = "current selected"';
|
144 |
// echo apply_filters( 'rtmedia_sub_nav_wall_post' ,
|
145 |
// '<li id="rtmedia-nav-item-wall-post-li" ' . $global_album . '><a id="rtmedia-nav-item-wall-post" href="' . trailingslashit( get_rtmedia_user_link( get_current_user_id() ) ) . 'media/' . RTMediaAlbum::get_default() . '/' . '">' . __("Wall Posts","rtmedia") . '</a></li>' );
|
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 |
-
$context = isset($rtmedia_query->query['context'])?$rtmedia_query->query['context']:'default';
|
178 |
-
$context_id = isset($rtmedia_query->query['context_id'])?$rtmedia_query->query['context_id']:0;
|
179 |
-
$name = strtoupper( $type[ 'name' ] );
|
180 |
-
$is_group = false;
|
181 |
-
$profile = self::profile_id();
|
182 |
-
if(!$profile){
|
183 |
-
$profile = self::group_id();
|
184 |
-
$is_group = true;
|
185 |
-
}
|
186 |
-
|
187 |
-
|
188 |
-
if(!$is_group){
|
189 |
-
$profile_link = trailingslashit(
|
190 |
-
get_rtmedia_user_link(
|
191 |
-
$profile
|
192 |
-
)
|
193 |
-
) ;
|
194 |
-
}else{
|
195 |
-
$profile_link = trailingslashit(
|
196 |
-
get_rtmedia_group_link(
|
197 |
-
$profile
|
198 |
-
)
|
199 |
-
) ;
|
200 |
-
}
|
201 |
-
|
202 |
-
echo apply_filters( 'rtmedia_sub_nav_' .$type['name'] ,
|
203 |
-
'<li id="rtmedia-nav-item-' . $type['name']
|
204 |
-
. '-' . $context .'-'. $context_id. '-li" ' . $selected
|
205 |
-
. '><a id="rtmedia-nav-item-' . $type['name'] . '" href="'
|
206 |
-
. $profile_link. 'media/'
|
207 |
-
. constant( 'RTMEDIA_' . $name . '_SLUG' ) . '/' . '">'
|
208 |
-
. $type['plural_label'] . '</a></li>',
|
209 |
-
$type['name']
|
210 |
-
);
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
}
|
215 |
-
|
216 |
-
function refresh_counts($user_id){
|
217 |
-
$model = new RTMediaModel();
|
218 |
-
$counts = $model->get_counts($user_id);
|
219 |
-
|
220 |
-
$media_count = array();
|
221 |
-
foreach($counts as $count){
|
222 |
-
$media_count[$count->privacy]= $count;
|
223 |
-
unset($media_count[$count->privacy]->privacy);
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
update_user_meta($user_id, 'rtmedia_count', $counts);
|
228 |
return $media_count;
|
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 |
-
function set_privacy() {
|
296 |
-
$user = $this->visitor_id();
|
297 |
-
$privacy = 0;
|
298 |
-
if ( $user ) {
|
299 |
-
$privacy = 20;
|
300 |
-
}
|
301 |
-
$profile = $this->profile_id();
|
302 |
-
if(class_exists('BuddyPress')&&bp_is_active('friends')){
|
303 |
-
|
304 |
-
if(friends_check_friendship_status( $user, $profile )){
|
305 |
-
$privacy = 40;
|
306 |
-
}
|
307 |
-
}
|
308 |
-
if($user===$profile){
|
309 |
-
$privacy = 60;
|
310 |
-
}
|
311 |
-
|
312 |
-
return $privacy;
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
}
|
319 |
|
320 |
-
?>
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class RTMediaNav {
|
4 |
|
5 |
+
function __construct ( $action = true ) {
|
6 |
+
if ( $action === false ) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
+
add_action ( 'admin_bar_menu', array( $this, 'admin_nav' ), 99 );
|
10 |
+
|
11 |
+
if ( class_exists ( 'BuddyPress' ) ) {
|
12 |
+
add_action ( 'bp_init', array( $this, 'custom_media_nav_tab' ), 10, 1 );
|
13 |
+
//add_action( 'bp_init', array( $this, 'custom_media_sub_nav_tab' ), 10, 20 );
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
function media_screen () {
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Load Custom tabs on BuddyPress
|
23 |
+
*
|
24 |
+
* @global object $bp global BuddyPress object
|
25 |
+
*/
|
26 |
+
function custom_media_nav_tab () {
|
27 |
+
global $bp;
|
28 |
+
if ( ! function_exists ( "bp_core_new_nav_item" ) )
|
29 |
+
return;
|
30 |
+
if ( bp_is_blog_page () || ( ! bp_is_group () && ! ( isset ( $bp->displayed_user ) && isset ( $bp->displayed_user->id )) ) )
|
31 |
+
return;
|
32 |
+
global $rtmedia;
|
33 |
+
if ( function_exists ( "bp_is_group" ) && ! bp_is_group () ) {
|
34 |
+
if ( isset ( $bp->displayed_user ) && isset ( $bp->displayed_user->id ) ) {
|
35 |
+
$profile_counts = $this->actual_counts ( $bp->displayed_user->id );
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( $rtmedia->options[ "buddypress_enableOnProfile" ] !== 0 ) {
|
39 |
+
bp_core_new_nav_item ( array(
|
40 |
+
'name' => RTMEDIA_MEDIA_LABEL . '<span>' . $profile_counts[ 'total' ][ 'all' ] . '</span>',
|
41 |
+
'slug' => RTMEDIA_MEDIA_SLUG,
|
42 |
+
'screen_function' => array( $this, 'media_screen' ),
|
43 |
+
'default_subnav_slug' => 'all'
|
44 |
+
) );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
if ( bp_is_group () && $rtmedia->options[ "buddypress_enableOnGroup" ] !== 0 ) {
|
48 |
+
global $bp;
|
49 |
+
$group_counts = $this->actual_counts ( $bp->groups->current_group->id, "group" );
|
50 |
+
$bp->bp_options_nav[ bp_get_current_group_slug () ][ 'media' ] = array(
|
51 |
+
'name' => RTMEDIA_MEDIA_LABEL . '<span>' . $group_counts[ 'total' ][ 'all' ] . '</span>',
|
52 |
+
'link' => ( (is_multisite ()) ? get_site_url ( get_current_blog_id () ) : get_site_url () ) . '/' . bp_get_groups_root_slug () . '/' . bp_get_current_group_slug () . '/' . RTMEDIA_MEDIA_SLUG,
|
53 |
+
'slug' => RTMEDIA_MEDIA_SLUG,
|
54 |
+
'user_has_access' => true,
|
55 |
+
'css_id' => 'rtmedia-media-nav',
|
56 |
+
'position' => 99,
|
57 |
+
'screen_function' => array( $this, 'media_screen' ),
|
58 |
+
'default_subnav_slug' => 'all'
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
function admin_nav () {
|
64 |
+
// $wp_admin_bar->add_menu( array(
|
65 |
// 'parent' => 'my-account',
|
66 |
// 'id' => 'my-account-buddypress',
|
67 |
// 'title' => __( 'My Account' ),
|
70 |
// 'class' => 'ab-sub-secondary'
|
71 |
// )
|
72 |
// ) );
|
73 |
+
global $wp_admin_bar;
|
74 |
|
75 |
+
if ( ! function_exists ( "bp_use_wp_admin_bar" ) )
|
76 |
+
return;
|
77 |
+
// Bail if this is an ajax request
|
78 |
+
if ( ! bp_use_wp_admin_bar () || defined ( 'DOING_AJAX' ) )
|
79 |
+
return;
|
80 |
|
81 |
+
// Only add menu for logged in user
|
82 |
+
if ( is_user_logged_in () ) {
|
83 |
|
84 |
+
// Add secondary parent item for all BuddyPress components
|
85 |
+
$wp_admin_bar->add_menu ( array(
|
86 |
+
'parent' => 'my-account',
|
87 |
+
'id' => 'my-account-' . RTMEDIA_MEDIA_SLUG,
|
88 |
+
'title' => RTMEDIA_MEDIA_LABEL,
|
89 |
+
'href' => trailingslashit ( get_rtmedia_user_link ( get_current_user_id () ) ) . RTMEDIA_MEDIA_SLUG . '/'
|
90 |
+
) );
|
91 |
|
92 |
// $wp_admin_bar->add_menu( array(
|
93 |
// 'parent' => 'my-account-' . RTMEDIA_MEDIA_SLUG,
|
96 |
// 'href' => trailingslashit( get_rtmedia_user_link( get_current_user_id() ) ) . 'media/'.RTMediaAlbum::get_default().'/'
|
97 |
// ) );
|
98 |
|
99 |
+
if ( is_rtmedia_album_enable () ) {
|
100 |
+
$wp_admin_bar->add_menu ( array(
|
101 |
+
'parent' => 'my-account-' . RTMEDIA_MEDIA_SLUG,
|
102 |
+
'id' => 'my-account-media-' . RTMEDIA_ALBUM_SLUG,
|
103 |
+
'title' => __ ( 'Albums', 'rtmedia' ),
|
104 |
+
'href' => trailingslashit ( get_rtmedia_user_link ( get_current_user_id () ) ) . RTMEDIA_MEDIA_SLUG . '/album/'
|
105 |
+
) );
|
106 |
+
}
|
107 |
+
|
108 |
+
global $rtmedia;
|
109 |
+
|
110 |
+
foreach ( $rtmedia->allowed_types as $type ) {
|
111 |
+
if ( ! $rtmedia->options[ 'allowedTypes_' . $type[ 'name' ] . '_enabled' ] )
|
112 |
+
continue;
|
113 |
+
$name = strtoupper ( $type[ 'name' ] );
|
114 |
+
$wp_admin_bar->add_menu ( array(
|
115 |
+
'parent' => 'my-account-' . constant ( 'RTMEDIA_MEDIA_SLUG' ),
|
116 |
+
'id' => 'my-account-media-' . constant ( 'RTMEDIA_' . $name . '_SLUG' ),
|
117 |
+
'title' => $type[ 'plural_label' ],
|
118 |
+
'href' => trailingslashit ( get_rtmedia_user_link ( get_current_user_id () ) ) . RTMEDIA_MEDIA_SLUG . '/' . constant ( 'RTMEDIA_' . $name . '_SLUG' ) . '/'
|
119 |
+
) );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public function sub_nav () {
|
125 |
+
|
126 |
+
if ( bp_is_group () ) {
|
127 |
+
global $bp;
|
128 |
+
$counts = $this->actual_counts ( $bp->groups->current_group->id, "group" );
|
129 |
+
} else {
|
130 |
+
$counts = $this->actual_counts ();
|
131 |
+
}
|
132 |
+
|
133 |
+
global $rtmedia, $rtmedia_query;
|
134 |
+
|
135 |
+
$default = false;
|
136 |
+
|
137 |
+
if ( ! isset ( $rtmedia_query->action_query->action ) || empty ( $rtmedia_query->action_query->action ) ) {
|
138 |
+
$default = true;
|
139 |
+
}
|
140 |
+
//print_r($rtmedia_query->action_query);
|
141 |
+
|
142 |
+
$global_album = '';
|
143 |
// if(isset($rtmedia_query->action_query->id) && $rtmedia_query->action_query->id==RTMediaAlbum::get_default())
|
144 |
// $global_album = 'class = "current selected"';
|
145 |
// echo apply_filters( 'rtmedia_sub_nav_wall_post' ,
|
146 |
// '<li id="rtmedia-nav-item-wall-post-li" ' . $global_album . '><a id="rtmedia-nav-item-wall-post" href="' . trailingslashit( get_rtmedia_user_link( get_current_user_id() ) ) . 'media/' . RTMediaAlbum::get_default() . '/' . '">' . __("Wall Posts","rtmedia") . '</a></li>' );
|
147 |
|
148 |
+
$albums = '';
|
149 |
+
if ( isset ( $rtmedia_query->action_query->media_type ) && $rtmedia_query->action_query->media_type == 'album' )
|
150 |
+
$albums = 'class="current selected"';
|
151 |
+
$other_count = 0;
|
152 |
+
if ( is_rtmedia_album_enable () ) {
|
153 |
+
if ( function_exists ( 'bp_is_group' ) && bp_is_group () ) {
|
154 |
+
$link = get_rtmedia_group_link ( bp_get_group_id () );
|
155 |
+
$model = new RTMediaModel();
|
156 |
+
$other_count = $model->get_other_album_count ( bp_get_group_id (), "group" );
|
157 |
+
} else {
|
158 |
+
if ( function_exists ( 'bp_displayed_user_id' ) && bp_displayed_user_id () ) {
|
159 |
+
$link = get_rtmedia_user_link ( bp_displayed_user_id () );
|
160 |
+
} elseif ( get_query_var ( 'author' ) ) {
|
161 |
+
$link = get_rtmedia_user_link ( get_query_var ( 'author' ) );
|
162 |
+
}
|
163 |
+
$model = new RTMediaModel();
|
164 |
+
$other_count = $model->get_other_album_count ( bp_displayed_user_id (), "profile" );
|
165 |
+
}
|
166 |
+
if ( ! isset ( $counts[ 'total' ][ "album" ] ) ) {
|
167 |
+
$counts[ 'total' ][ "album" ] = 0;
|
168 |
+
}
|
169 |
+
|
170 |
+
$counts[ 'total' ][ "album" ] = $counts[ 'total' ][ "album" ] + $other_count;
|
171 |
+
echo apply_filters ( 'rtmedia_sub_nav_albums', '<li id="rtmedia-nav-item-albums-li" ' . $albums . '><a id="rtmedia-nav-item-albums" href="' . trailingslashit ( $link ) . RTMEDIA_MEDIA_SLUG . '/album/">' . __ ( "Albums", "rtmedia" ) . '<span>' . ((isset ( $counts[ 'total' ][ "album" ] )) ? $counts[ 'total' ][ "album" ] : 0 ) . '</span>' . '</a></li>' );
|
172 |
+
}
|
173 |
+
|
174 |
+
foreach ( $rtmedia->allowed_types as $type ) {
|
175 |
+
//print_r($type);
|
176 |
+
if ( ! $rtmedia->options[ 'allowedTypes_' . $type[ 'name' ] . '_enabled' ] )
|
177 |
+
continue;
|
178 |
+
|
179 |
+
$selected = '';
|
180 |
+
|
181 |
+
if ( isset ( $rtmedia_query->action_query->media_type ) && $type[ 'name' ] == $rtmedia_query->action_query->media_type ) {
|
182 |
+
$selected = ' class="current selected"';
|
183 |
+
} else {
|
184 |
+
$selected = '';
|
185 |
+
}
|
186 |
+
|
187 |
+
$context = isset ( $rtmedia_query->query[ 'context' ] ) ? $rtmedia_query->query[ 'context' ] : 'default';
|
188 |
+
$context_id = isset ( $rtmedia_query->query[ 'context_id' ] ) ? $rtmedia_query->query[ 'context_id' ] : 0;
|
189 |
+
$name = strtoupper ( $type[ 'name' ] );
|
190 |
+
$is_group = false;
|
191 |
+
$profile = self::profile_id ();
|
192 |
+
if ( ! $profile ) {
|
193 |
+
$profile = self::group_id ();
|
194 |
+
$is_group = true;
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
if ( ! $is_group ) {
|
199 |
+
$profile_link = trailingslashit (
|
200 |
+
get_rtmedia_user_link (
|
201 |
+
$profile
|
202 |
+
)
|
203 |
+
);
|
204 |
+
} else {
|
205 |
+
$profile_link = trailingslashit (
|
206 |
+
get_rtmedia_group_link (
|
207 |
+
$profile
|
208 |
+
)
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
echo apply_filters ( 'rtmedia_sub_nav_' . $type[ 'name' ], '<li id="rtmedia-nav-item-' . $type[ 'name' ]
|
213 |
+
. '-' . $context . '-' . $context_id . '-li" ' . $selected
|
214 |
+
. '><a id="rtmedia-nav-item-' . $type[ 'name' ] . '" href="'
|
215 |
+
. $profile_link . RTMEDIA_MEDIA_SLUG . '/'
|
216 |
+
. constant ( 'RTMEDIA_' . $name . '_SLUG' ) . '/' . '">'
|
217 |
+
. $type[ 'plural_label' ] . '<span>' . ((isset ( $counts[ 'total' ][ $type[ 'name' ] ] )) ? $counts[ 'total' ][ $type[ 'name' ] ] : 0) . '</span>' . '</a></li>', $type[ 'name' ]
|
218 |
+
);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
function refresh_counts ( $user_id, $where ) {
|
223 |
+
$model = new RTMediaModel();
|
224 |
+
$counts = $model->get_counts ( $user_id, $where );
|
225 |
+
$media_count = array( );
|
226 |
+
foreach ( $counts as $count ) {
|
227 |
+
if ( ! isset ( $count->privacy ) ) {
|
228 |
+
$count->privacy = 0;
|
229 |
+
}
|
230 |
+
if ( isset ( $media_count[ strval ( $count->privacy ) ] ) ) {
|
231 |
+
foreach ( $media_count[ strval ( $count->privacy ) ] as $key => $val ) {
|
232 |
+
$media_count[ strval ( $count->privacy ) ]->{$key} = intval ( $count->{$key} ) + intval ( $val );
|
233 |
}
|
234 |
+
}
|
235 |
+
else
|
236 |
+
$media_count[ strval ( $count->privacy ) ] = $count;
|
237 |
+
unset ( $media_count[ strval ( $count->privacy ) ]->privacy );
|
238 |
+
}
|
239 |
+
|
240 |
+
if ( isset ( $where[ "context" ] ) ) {
|
241 |
+
if ( $where[ "context" ] == "profile" ) {
|
242 |
+
update_user_meta ( $user_id, 'rtmedia_counts', $media_count );
|
243 |
+
} else if ( $where[ "context" ] == "group" && function_exists ( "groups_update_groupmeta" ) ) {
|
244 |
+
groups_update_groupmeta ( $user_id, 'rtmedia_counts', $media_count );
|
245 |
+
}
|
246 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
return $media_count;
|
248 |
+
}
|
249 |
+
|
250 |
+
function get_counts ( $profile_id = false, $context = "profile" ) {
|
251 |
+
if ( $profile_id === false && $context = "profile" )
|
252 |
+
$profile_id = $this->profile_id ();
|
253 |
+
else if ( $profile_id === false && $context = "profile" )
|
254 |
+
$profile_id = $this->group_id ();
|
255 |
+
if ( ! $profile_id )
|
256 |
+
return false;
|
257 |
+
if ( $context == "profile" ) {
|
258 |
+
$counts = get_user_meta ( $profile_id, 'rtmedia_counts', true );
|
259 |
+
if ( $counts == false || empty ( $counts ) ) {
|
260 |
+
$counts = $this->refresh_counts ( $profile_id, array( "context" => $context, 'media_author' => $profile_id ) );
|
261 |
+
}
|
262 |
+
} else if ( function_exists ( "groups_get_groupmeta" ) && $context = "group" ) {
|
263 |
+
$counts = groups_get_groupmeta ( $profile_id, 'rtmedia_counts' );
|
264 |
+
if ( $counts === false || empty ( $counts ) ) {
|
265 |
+
$counts = $this->refresh_counts ( $profile_id, array( "context" => $context, 'context_id' => $profile_id ) );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
return $counts;
|
269 |
+
}
|
270 |
+
|
271 |
+
function profile_id () {
|
272 |
+
global $rtmedia_query;
|
273 |
+
if ( isset ( $rtmedia_query->query[ 'context' ] ) && ($rtmedia_query->query[ 'context' ] == 'profile') ) {
|
274 |
+
return $rtmedia_query->query[ 'context_id' ];
|
275 |
+
}
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
|
279 |
+
function group_id () {
|
280 |
+
global $rtmedia_query;
|
281 |
+
if ( isset ( $rtmedia_query->query[ 'context' ] ) && ($rtmedia_query->query[ 'context' ] == 'group') ) {
|
282 |
+
return $rtmedia_query->query[ 'context_id' ];
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
function actual_counts ( $profile_id = false, $context = "profile" ) {
|
287 |
+
if ( $profile_id === false ) {
|
288 |
+
if ( ! $this->profile_id () )
|
289 |
+
return;
|
290 |
+
}
|
291 |
+
|
292 |
+
$media_count = $this->get_counts ( $profile_id, $context );
|
293 |
+
$privacy = $this->set_privacy ( $profile_id );
|
294 |
+
return $this->process_count ( $media_count, $privacy );
|
295 |
+
}
|
296 |
+
|
297 |
+
function process_count ( $media_count, $privacy ) {
|
298 |
+
$total = array( 'all' => 0 );
|
299 |
+
|
300 |
+
foreach ( $media_count as $private => $ind_count ) {
|
301 |
+
if ( $private <= $privacy ) {
|
302 |
+
foreach ( $ind_count as $type => $ind_ind_count ) {
|
303 |
+
if ( $type != 'album' ) {
|
304 |
+
$total[ 'all' ]+= ( int ) $ind_ind_count;
|
305 |
+
}
|
306 |
+
if ( ! isset ( $total[ $type ] ) )
|
307 |
+
$total[ $type ] = 0;
|
308 |
+
$total[ $type ]+=( int ) $ind_ind_count;
|
309 |
+
}
|
310 |
+
} else {
|
311 |
+
unset ( $media_count[ $private ] );
|
312 |
+
}
|
313 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
+
$media_count[ 'total' ] = $total;
|
316 |
+
return $media_count;
|
317 |
+
}
|
318 |
+
|
319 |
+
function visitor_id () {
|
320 |
+
if ( is_user_logged_in () ) {
|
321 |
+
$user = get_current_user_id ();
|
322 |
+
} else {
|
323 |
+
$user = 0;
|
324 |
+
}
|
325 |
+
return $user;
|
326 |
+
}
|
327 |
+
|
328 |
+
function set_privacy ( $profile ) {
|
329 |
+
$user = $this->visitor_id ();
|
330 |
+
$privacy = 0;
|
331 |
+
if ( $user ) {
|
332 |
+
$privacy = 20;
|
333 |
+
}
|
334 |
+
if ( $profile === false )
|
335 |
+
$profile = $this->profile_id ();
|
336 |
+
if ( class_exists ( 'BuddyPress' ) && bp_is_active ( 'friends' ) ) {
|
337 |
+
|
338 |
+
if ( friends_check_friendship_status ( $user, $profile ) ) {
|
339 |
+
$privacy = 40;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
if ( $user === $profile ) {
|
343 |
+
$privacy = 60;
|
344 |
+
}
|
345 |
+
|
346 |
+
return $privacy;
|
347 |
+
}
|
348 |
|
349 |
}
|
350 |
|
|
app/main/controllers/template/RTMediaTemplate.php
CHANGED
@@ -86,10 +86,16 @@ class RTMediaTemplate {
|
|
86 |
return $this->get_default_template();
|
87 |
} else if ($shortcode_attr['name'] == 'gallery') {
|
88 |
$valid = $this->sanitize_gallery_attributes($shortcode_attr['attr']);
|
89 |
-
|
90 |
if ($valid) {
|
91 |
-
if (is_array($shortcode_attr['attr']))
|
92 |
$this->update_global_query($shortcode_attr['attr']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
include $this->locate_template($template);
|
94 |
} else {
|
95 |
echo __('Invalid attribute passed for rtmedia_gallery shortcode.', 'rtmedia');
|
@@ -97,7 +103,17 @@ class RTMediaTemplate {
|
|
97 |
}
|
98 |
}
|
99 |
}
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
function check_return_json() {
|
102 |
global $rtmedia_query;
|
103 |
if ($rtmedia_query->format == 'json') {
|
@@ -121,7 +137,7 @@ class RTMediaTemplate {
|
|
121 |
if ($rtmedia_query->media) {
|
122 |
foreach ($rtmedia_query->media as $key => $media) {
|
123 |
$media_array[$key] = $media;
|
124 |
-
list($src, $width, $height) = wp_get_attachment_image_src($media->media_id, '
|
125 |
if (!$src) {
|
126 |
global $rtmedia;
|
127 |
$src = $rtmedia->allowed_types[$media->media_type]["thumbnail"];
|
@@ -162,7 +178,7 @@ class RTMediaTemplate {
|
|
162 |
$state = $media->update($rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id);
|
163 |
$rtmedia_query->query(false);
|
164 |
do_action('rtmedia_after_update_media',$rtmedia_query->action_query->id, $state);
|
165 |
-
if($state){
|
166 |
add_action("rtmedia_before_template_load", array(&$this,"media_update_success_messege"));
|
167 |
}else{
|
168 |
add_action("rtmedia_before_template_load", array(&$this, "media_update_success_error"));
|
@@ -431,7 +447,6 @@ class RTMediaTemplate {
|
|
431 |
function update_global_query($attr) {
|
432 |
|
433 |
global $rtmedia_query;
|
434 |
-
|
435 |
$rtmedia_query->query($attr);
|
436 |
}
|
437 |
|
86 |
return $this->get_default_template();
|
87 |
} else if ($shortcode_attr['name'] == 'gallery') {
|
88 |
$valid = $this->sanitize_gallery_attributes($shortcode_attr['attr']);
|
|
|
89 |
if ($valid) {
|
90 |
+
if (is_array($shortcode_attr['attr'])){
|
91 |
$this->update_global_query($shortcode_attr['attr']);
|
92 |
+
}
|
93 |
+
global $rtaccount;
|
94 |
+
if(!isset($rtaccount)){
|
95 |
+
$rtaccount = 0;
|
96 |
+
}
|
97 |
+
//add_action("rtmedia_before_media_gallery",array(&$this,"")) ;
|
98 |
+
$this->add_hidden_fields_in_gallery();
|
99 |
include $this->locate_template($template);
|
100 |
} else {
|
101 |
echo __('Invalid attribute passed for rtmedia_gallery shortcode.', 'rtmedia');
|
103 |
}
|
104 |
}
|
105 |
}
|
106 |
+
function add_hidden_fields_in_gallery(){
|
107 |
+
global $rtmedia_query;
|
108 |
+
$return_str= "";
|
109 |
+
if($rtmedia_query->original_query && is_array($rtmedia_query->original_query)){
|
110 |
+
foreach($rtmedia_query->original_query as $key=>$val){
|
111 |
+
$return_str.= '<input name="' . $key . '" value="' . $val . '" type="hidden" />';
|
112 |
+
|
113 |
+
}
|
114 |
+
}
|
115 |
+
echo $return_str;
|
116 |
+
}
|
117 |
function check_return_json() {
|
118 |
global $rtmedia_query;
|
119 |
if ($rtmedia_query->format == 'json') {
|
137 |
if ($rtmedia_query->media) {
|
138 |
foreach ($rtmedia_query->media as $key => $media) {
|
139 |
$media_array[$key] = $media;
|
140 |
+
list($src, $width, $height) = wp_get_attachment_image_src($media->media_id, 'rt_media_thumbnail');
|
141 |
if (!$src) {
|
142 |
global $rtmedia;
|
143 |
$src = $rtmedia->allowed_types[$media->media_type]["thumbnail"];
|
178 |
$state = $media->update($rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id);
|
179 |
$rtmedia_query->query(false);
|
180 |
do_action('rtmedia_after_update_media',$rtmedia_query->action_query->id, $state);
|
181 |
+
if($state!==false){
|
182 |
add_action("rtmedia_before_template_load", array(&$this,"media_update_success_messege"));
|
183 |
}else{
|
184 |
add_action("rtmedia_before_template_load", array(&$this, "media_update_success_error"));
|
447 |
function update_global_query($attr) {
|
448 |
|
449 |
global $rtmedia_query;
|
|
|
450 |
$rtmedia_query->query($attr);
|
451 |
}
|
452 |
|
app/main/controllers/template/RTMediaUploadTemplate.php
CHANGED
@@ -9,24 +9,24 @@
|
|
9 |
*/
|
10 |
class RTMediaUploadTemplate {
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
return $view->render('uploader');
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
wp_register_script('bpm-plupload', RTMEDIA_URL . 'app/assets/js/bpm-plupload.js', array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers'), '1.0', true);
|
26 |
}
|
27 |
|
28 |
-
function print_script() {
|
29 |
-
if (
|
30 |
return;
|
31 |
$params = array(
|
32 |
'url' => 'upload',
|
@@ -34,31 +34,31 @@ class RTMediaUploadTemplate {
|
|
34 |
'browse_button' => 'browse-button',
|
35 |
'container' => 'bpm-file_upload-ui',
|
36 |
'drop_element' => 'drag-drop-area',
|
37 |
-
'filters' => apply_filters('bp_media_plupload_files_filter', array(array('title' => "Media Files", 'extensions' =>
|
38 |
-
'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
|
39 |
'multipart' => true,
|
40 |
'urlstream_upload' => true,
|
41 |
-
'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
42 |
-
'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
43 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
44 |
'multi_selection' => true,
|
45 |
-
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
46 |
);
|
47 |
|
48 |
-
foreach ((array) $params as $key => $value) {
|
49 |
-
if (!is_scalar($value))
|
50 |
continue;
|
51 |
|
52 |
-
$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
|
53 |
}
|
54 |
|
55 |
echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
|
56 |
echo "/* <![CDATA[ */\n";
|
57 |
-
echo "var bpm_plupload_params = " . json_encode($params) . ";\n";
|
58 |
echo "/* ]]> */\n";
|
59 |
echo "</script>\n";
|
60 |
|
61 |
-
wp_print_scripts('bpm-plupload');
|
62 |
}
|
63 |
|
64 |
}
|
9 |
*/
|
10 |
class RTMediaUploadTemplate {
|
11 |
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
function __construct () {
|
16 |
|
17 |
+
}
|
18 |
|
19 |
+
static function render ( $attr ) {
|
20 |
+
$view = new RTMediaUploadView ( $attr );
|
21 |
+
return $view->render ( 'uploader' );
|
22 |
+
}
|
23 |
|
24 |
+
function register_script () {
|
25 |
+
wp_register_script ( 'bpm-plupload', RTMEDIA_URL . 'app/assets/js/bpm-plupload.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ), '1.0', true );
|
26 |
}
|
27 |
|
28 |
+
function print_script () {
|
29 |
+
if ( ! $this->add_sc_script )
|
30 |
return;
|
31 |
$params = array(
|
32 |
'url' => 'upload',
|
34 |
'browse_button' => 'browse-button',
|
35 |
'container' => 'bpm-file_upload-ui',
|
36 |
'drop_element' => 'drag-drop-area',
|
37 |
+
'filters' => apply_filters ( 'bp_media_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => get_rtmedia_allowed_upload_type () ) ) ),
|
38 |
+
'max_file_size' => min ( array( ini_get ( 'upload_max_filesize' ), ini_get ( 'post_max_size' ) ) ),
|
39 |
'multipart' => true,
|
40 |
'urlstream_upload' => true,
|
41 |
+
'flash_swf_url' => includes_url ( 'js/plupload/plupload.flash.swf' ),
|
42 |
+
'silverlight_xap_url' => includes_url ( 'js/plupload/plupload.silverlight.xap' ),
|
43 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
44 |
'multi_selection' => true,
|
45 |
+
'multipart_params' => apply_filters ( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
46 |
);
|
47 |
|
48 |
+
foreach ( ( array ) $params as $key => $value ) {
|
49 |
+
if ( ! is_scalar ( $value ) )
|
50 |
continue;
|
51 |
|
52 |
+
$params[ $key ] = html_entity_decode ( ( string ) $value, ENT_QUOTES, 'UTF-8' );
|
53 |
}
|
54 |
|
55 |
echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
|
56 |
echo "/* <![CDATA[ */\n";
|
57 |
+
echo "var bpm_plupload_params = " . json_encode ( $params ) . ";\n";
|
58 |
echo "/* ]]> */\n";
|
59 |
echo "</script>\n";
|
60 |
|
61 |
+
wp_print_scripts ( 'bpm-plupload' );
|
62 |
}
|
63 |
|
64 |
}
|
app/main/controllers/template/rt-template-functions.php
CHANGED
@@ -5,10 +5,10 @@
|
|
5 |
* @global type $rtmedia_query
|
6 |
* @return type
|
7 |
*/
|
8 |
-
function have_rtmedia() {
|
9 |
global $rtmedia_query;
|
10 |
|
11 |
-
return $rtmedia_query->have_media();
|
12 |
}
|
13 |
|
14 |
/**
|
@@ -16,11 +16,11 @@ function have_rtmedia() {
|
|
16 |
* @global type $rtmedia_query
|
17 |
* @return type
|
18 |
*/
|
19 |
-
function rewind_rtmedia() {
|
20 |
|
21 |
global $rtmedia_query;
|
22 |
|
23 |
-
return $rtmedia_query->rewind_media();
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -28,20 +28,20 @@ function rewind_rtmedia() {
|
|
28 |
* @global type $rtmedia_query
|
29 |
* @return type
|
30 |
*/
|
31 |
-
function rtmedia() {
|
32 |
global $rtmedia_query;
|
33 |
|
34 |
-
return $rtmedia_query->rtmedia();
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
* echo the title of the media
|
39 |
* @global type $rtmedia_media
|
40 |
*/
|
41 |
-
function rtmedia_title() {
|
42 |
|
43 |
global $rtmedia_backbone;
|
44 |
-
if ($rtmedia_backbone['backbone']) {
|
45 |
echo '<%= media_title %>';
|
46 |
} else {
|
47 |
global $rtmedia_media;
|
@@ -49,61 +49,61 @@ function rtmedia_title() {
|
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
function rtmedia_media_gallery_class(){
|
54 |
global $rtmedia_query;
|
55 |
-
if(isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query["context_id"]))
|
56 |
-
echo "context-id-" . $rtmedia_query->media_query["context_id"];
|
57 |
}
|
58 |
-
|
59 |
-
|
|
|
60 |
$model = new RTMediaModel();
|
61 |
-
$media = $model->get_media(array('media_id' => $media_id), 0, 1);
|
62 |
-
return $media[0]->id;
|
63 |
} else {
|
64 |
global $rtmedia_media;
|
65 |
return $rtmedia_media->id;
|
66 |
}
|
67 |
}
|
68 |
|
69 |
-
function rtmedia_media_id($id = false) {
|
70 |
-
if ($id) {
|
71 |
$model = new RTMediaModel();
|
72 |
-
$media = $model->get_media(array('id' => $id), 0, 1);
|
73 |
-
return $media[0]->media_id;
|
74 |
} else {
|
75 |
global $rtmedia_media;
|
76 |
return $rtmedia_media->media_id;
|
77 |
}
|
78 |
}
|
79 |
|
80 |
-
function rtmedia_activity_id($id = false) {
|
81 |
-
if ($id) {
|
82 |
$model = new RTMediaModel();
|
83 |
-
$media = $model->get_media(array('id' => $id), 0, 1);
|
84 |
-
return $media[0]->activity_id;
|
85 |
} else {
|
86 |
global $rtmedia_media;
|
87 |
return $rtmedia_media->activity_id;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
-
function rtmedia_type($id = false) {
|
92 |
-
if ($id) {
|
93 |
$model = new RTMediaModel();
|
94 |
-
$media = $model->get_media(array('id' => $id), 0, 1);
|
95 |
-
return $media[0]->media_type;
|
96 |
} else {
|
97 |
global $rtmedia_media;
|
98 |
return $rtmedia_media->media_type;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
-
function rtmedia_cover_art($id=false) {
|
103 |
-
if ($id) {
|
104 |
$model = new RTMediaModel();
|
105 |
-
$media = $model->get_media(array('id' => $id), 0, 1);
|
106 |
-
return $media[0]->cover_art;
|
107 |
} else {
|
108 |
global $rtmedia_media;
|
109 |
return $rtmedia_media->cover_art;
|
@@ -114,32 +114,32 @@ function rtmedia_cover_art($id=false) {
|
|
114 |
* echo parmalink of the media
|
115 |
* @global type $rtmedia_media
|
116 |
*/
|
117 |
-
function rtmedia_permalink() {
|
118 |
|
119 |
global $rtmedia_backbone;
|
120 |
|
121 |
-
if ($rtmedia_backbone['backbone']) {
|
122 |
echo '<%= rt_permalink %>';
|
123 |
} else {
|
124 |
-
echo get_rtmedia_permalink(rtmedia_id());
|
125 |
}
|
126 |
}
|
127 |
|
128 |
-
function rtmedia_media($size_flag = true, $echo = true
|
129 |
$size_flag = true;
|
130 |
global $rtmedia_media, $rtmedia;
|
131 |
-
if (isset($rtmedia_media->media_type)) {
|
132 |
-
if ($rtmedia_media->media_type == 'photo') {
|
133 |
-
$html = wp_get_attachment_image($rtmedia_media->media_id, $media_size);
|
134 |
-
} elseif ($rtmedia_media->media_type == 'video') {
|
135 |
-
$size = " width=\"" . $rtmedia->options["defaultSizes_video_singlePlayer_width"] . "\" height=\"" . $rtmedia->options["defaultSizes_video_singlePlayer_height"] . "\" ";
|
136 |
-
|
137 |
-
$html = '<div class="flex-video"><video src="' . wp_get_attachment_url($rtmedia_media->media_id) . '" ' . $size . ' type="video/mp4" class="wp-video-shortcode" id="bp_media_video_' . $rtmedia_media->id . '" controls="controls" preload="none"></video></div>';
|
138 |
-
} elseif ($rtmedia_media->media_type == 'music') {
|
139 |
$size = ' width="600" height="0" ';
|
140 |
-
if (
|
141 |
$size = '';
|
142 |
-
$html = '<audio src="' . wp_get_attachment_url($rtmedia_media->media_id) . '" ' . $size . ' type="audio/mp3" class="wp-audio-shortcode" id="bp_media_audio_' . $rtmedia_media->id . '" controls="controls" preload="none"></audio>';
|
143 |
} else {
|
144 |
$html = false;
|
145 |
}
|
@@ -147,11 +147,11 @@ function rtmedia_media($size_flag = true, $echo = true,$media_size = "rt_media_s
|
|
147 |
$html = false;
|
148 |
}
|
149 |
|
150 |
-
|
151 |
|
152 |
-
$html = apply_filters('rtmedia_single_content_filter', $html, $rtmedia_media);
|
153 |
|
154 |
-
if ($echo)
|
155 |
echo $html;
|
156 |
else
|
157 |
return $html;
|
@@ -161,19 +161,19 @@ function rtmedia_media($size_flag = true, $echo = true,$media_size = "rt_media_s
|
|
161 |
* echo http url of the media
|
162 |
*/
|
163 |
|
164 |
-
function rtmedia_image($size = '
|
165 |
global $rtmedia_backbone;
|
166 |
|
167 |
-
if ($rtmedia_backbone['backbone']) {
|
168 |
echo '<%= guid %>';
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
-
if ($id) {
|
173 |
$model = new RTMediaModel();
|
174 |
-
$media = $model->get_media(array('id' => $id), false, false);
|
175 |
-
if (isset($media[0]))
|
176 |
-
$media_object = $media[0];
|
177 |
else
|
178 |
return false;
|
179 |
} else {
|
@@ -182,11 +182,11 @@ function rtmedia_image($size = 'thumbnail', $id = false) {
|
|
182 |
}
|
183 |
|
184 |
$thumbnail_id = 0;
|
185 |
-
if (isset($media_object->media_type)) {
|
186 |
-
if ($media_object->media_type == 'album' ||
|
187 |
-
$media_object->media_type != 'photo') {
|
188 |
-
$thumbnail_id = isset($media_object->cover_art) ? $media_object->cover_art : false;
|
189 |
-
} elseif ($media_object->media_type == 'photo') {
|
190 |
$thumbnail_id = $media_object->media_id;
|
191 |
} else {
|
192 |
$thumbnail_id = false;
|
@@ -195,75 +195,73 @@ function rtmedia_image($size = 'thumbnail', $id = false) {
|
|
195 |
$src = false;
|
196 |
}
|
197 |
|
198 |
-
if (
|
199 |
global $rtmedia;
|
200 |
-
if (isset($rtmedia->allowed_types[$media_object->media_type])
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$src = rtmedia_album_image($size);
|
205 |
} else {
|
206 |
$src = false;
|
207 |
}
|
208 |
} else {
|
209 |
-
list($src, $width, $height) = wp_get_attachment_image_src($thumbnail_id, $size);
|
210 |
}
|
211 |
|
212 |
-
$src = apply_filters('rtmedia_media_thumb', $src, $media_object->id, $media_object->media_type);
|
213 |
|
214 |
echo $src;
|
215 |
}
|
216 |
|
217 |
-
function rtmedia_album_image($size = 'thumbnail') {
|
218 |
global $rtmedia_media;
|
219 |
$model = new RTMediaModel();
|
220 |
-
$media = $model->get_media(array('album_id' => $rtmedia_media->id, 'media_type' => 'photo'), 0, 1);
|
221 |
|
222 |
-
if ($media) {
|
223 |
-
$src = rtmedia_image($size, $media[0]->id);
|
224 |
} else {
|
225 |
global $rtmedia;
|
226 |
-
$src = $rtmedia->allowed_types['photo']['thumbnail'];
|
227 |
}
|
228 |
return $src;
|
229 |
}
|
230 |
|
231 |
-
function rtmedia_sanitize_object($data, $exceptions = array()) {
|
232 |
-
foreach ($data as $key => $value) {
|
233 |
-
if (!in_array($key, array_merge(RTMediaMedia::$default_object, $exceptions)))
|
234 |
-
unset($data[$key]);
|
235 |
}
|
236 |
return $data;
|
237 |
}
|
238 |
|
239 |
-
function rtmedia_delete_allowed() {
|
240 |
global $rtmedia_media;
|
241 |
|
242 |
-
$flag = $rtmedia_media->media_author == get_current_user_id();
|
243 |
|
244 |
-
$flag = apply_filters('rtmedia_media_delete_priv', $flag);
|
245 |
|
246 |
return $flag;
|
247 |
}
|
248 |
|
249 |
-
function rtmedia_edit_allowed() {
|
250 |
|
251 |
global $rtmedia_media;
|
252 |
|
253 |
-
$flag = $rtmedia_media->media_author == get_current_user_id();
|
254 |
|
255 |
-
$flag = apply_filters('rtmedia_media_edit_priv', $flag);
|
256 |
|
257 |
return $flag;
|
258 |
}
|
259 |
|
260 |
-
function rtmedia_request_action() {
|
261 |
global $rtmedia_query;
|
262 |
return $rtmedia_query->action_query->action;
|
263 |
}
|
264 |
|
265 |
-
|
266 |
-
function rtmedia_title_input() {
|
267 |
global $rtmedia_media;
|
268 |
|
269 |
$name = 'media_title';
|
@@ -271,7 +269,7 @@ function rtmedia_title_input() {
|
|
271 |
|
272 |
$html = '';
|
273 |
|
274 |
-
if (rtmedia_request_action() == 'edit')
|
275 |
$html .= '<input type="text" name="' . $name . '" id="' . $name . '" value="' . $value . '">';
|
276 |
else
|
277 |
$html .= '<h2 name="' . $name . '" id="' . $name . '">' . $value . '</h2>';
|
@@ -281,7 +279,7 @@ function rtmedia_title_input() {
|
|
281 |
echo $html;
|
282 |
}
|
283 |
|
284 |
-
function rtmedia_description_input() {
|
285 |
global $rtmedia_media;
|
286 |
|
287 |
$name = 'description';
|
@@ -289,8 +287,8 @@ function rtmedia_description_input() {
|
|
289 |
|
290 |
$html = '';
|
291 |
|
292 |
-
if (rtmedia_request_action() == 'edit')
|
293 |
-
$html .= wp_editor($value, $name, array('media_buttons' => false));
|
294 |
else
|
295 |
$html .= '<div name="' . $name . '" id="' . $name . '">' . $value . '</div>';
|
296 |
|
@@ -303,7 +301,7 @@ function rtmedia_description_input() {
|
|
303 |
* echo media description
|
304 |
* @global type $rtmedia_media
|
305 |
*/
|
306 |
-
function rtmedia_description() {
|
307 |
global $rtmedia_media;
|
308 |
echo $rtmedia_media->post_content;
|
309 |
}
|
@@ -313,7 +311,7 @@ function rtmedia_description() {
|
|
313 |
* @global type $rtmedia_query
|
314 |
* @return type
|
315 |
*/
|
316 |
-
function rtmedia_count() {
|
317 |
global $rtmedia_query;
|
318 |
|
319 |
return $rtmedia_query->media_count;
|
@@ -324,7 +322,7 @@ function rtmedia_count() {
|
|
324 |
* @global type $rtmedia_query
|
325 |
* @return type
|
326 |
*/
|
327 |
-
function rtmedia_offset() {
|
328 |
global $rtmedia_query;
|
329 |
|
330 |
return ($rtmedia_query->action_query->page - 1) * $rtmedia_query->action_query->per_page_media;
|
@@ -335,7 +333,7 @@ function rtmedia_offset() {
|
|
335 |
* @global type $rtmedia_query
|
336 |
* @return type
|
337 |
*/
|
338 |
-
function rtmedia_per_page_media() {
|
339 |
global $rtmedia_query;
|
340 |
|
341 |
return $rtmedia_query->action_query->per_page_media;
|
@@ -346,7 +344,7 @@ function rtmedia_per_page_media() {
|
|
346 |
* @global type $rtmedia_query
|
347 |
* @return type
|
348 |
*/
|
349 |
-
function rtmedia_page() {
|
350 |
global $rtmedia_query;
|
351 |
|
352 |
return $rtmedia_query->action_query->page;
|
@@ -357,7 +355,7 @@ function rtmedia_page() {
|
|
357 |
* @global type $rtmedia_query
|
358 |
* @return type
|
359 |
*/
|
360 |
-
function rtmedia_current_media() {
|
361 |
global $rtmedia_query;
|
362 |
|
363 |
return $rtmedia_query->current_media;
|
@@ -366,26 +364,26 @@ function rtmedia_current_media() {
|
|
366 |
/**
|
367 |
*
|
368 |
*/
|
369 |
-
function rtmedia_actions() {
|
370 |
|
371 |
-
$actions = array();
|
372 |
|
373 |
-
if (is_user_logged_in() && rtmedia_edit_allowed()) {
|
374 |
|
375 |
-
$actions[] = '<form action="' . get_rtmedia_permalink(rtmedia_id()) . 'edit/">
|
376 |
-
<button type="submit" >' . __('Edit', 'rtmedia') . '</button></form>';
|
377 |
}
|
378 |
-
$actions = apply_filters('rtmedia_action_buttons_before_delete', $actions);
|
379 |
-
foreach ($actions as $action) {
|
380 |
echo $action;
|
381 |
}
|
382 |
-
$actions = array();
|
383 |
-
if (rtmedia_delete_allowed()) {
|
384 |
-
rtmedia_delete_form();
|
385 |
}
|
386 |
-
$actions = apply_filters('rtmedia_action_buttons_after_delete', $actions);
|
387 |
|
388 |
-
foreach ($actions as $action) {
|
389 |
echo $action;
|
390 |
}
|
391 |
}
|
@@ -393,16 +391,16 @@ function rtmedia_actions() {
|
|
393 |
/**
|
394 |
* rendering comments section
|
395 |
*/
|
396 |
-
function rtmedia_comments() {
|
397 |
|
398 |
$html = '<ul id="rtmedia_comment_ul" class="large-block-grid-1">';
|
399 |
|
400 |
global $wpdb, $rtmedia_media;
|
401 |
|
402 |
-
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '" . $rtmedia_media->media_id . "'", ARRAY_A);
|
403 |
|
404 |
-
foreach ($comments as $comment) {
|
405 |
-
$html .= rmedia_single_comment($comment);
|
406 |
}
|
407 |
|
408 |
$html .= '</ul>';
|
@@ -410,113 +408,113 @@ function rtmedia_comments() {
|
|
410 |
echo $html;
|
411 |
}
|
412 |
|
413 |
-
function rmedia_single_comment($comment) {
|
414 |
$html = "";
|
415 |
$html .= '<li class="rtmedia-comment">';
|
416 |
-
$html .= '<div class ="rtmedia-comment-author">' . (($comment['comment_author']) ? $comment['comment_author'] : 'Annonymous') . ' said : </div>';
|
417 |
-
$html .= '<div class="rtmedia-comment-content">' . $comment['comment_content'] . '</div>';
|
418 |
-
$html .= '<div class ="rtmedia-comment-date"> on ' . $comment['comment_date_gmt'] . '</div>';
|
419 |
// $html .= '<a href></a>';
|
420 |
$html .= '</li>';
|
421 |
return $html;
|
422 |
}
|
423 |
|
424 |
-
function rtmedia_pagination_prev_link() {
|
425 |
|
426 |
global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
|
427 |
|
428 |
-
$page_url = ((rtmedia_page() - 1) == 1) ? "" : "pg/" . (rtmedia_page() - 1);
|
429 |
-
$site_url = (is_multisite()) ? trailingslashit(get_site_url(get_current_blog_id())) : trailingslashit(get_site_url());
|
430 |
-
$author_name = get_query_var('author_name');
|
431 |
$link = '';
|
432 |
|
433 |
-
if ($rtmedia_interaction->context->type == "profile") {
|
434 |
-
if (function_exists("bp_core_get_user_domain"))
|
435 |
-
$link .= trailingslashit(bp_core_get_user_domain($rtmedia_media->media_author));
|
436 |
else
|
437 |
$link = $site_url . 'author/' . $author_name . '/';
|
438 |
-
} else if ($rtmedia_interaction->context->type == 'group') {
|
439 |
-
if (function_exists("bp_get_current_group_slug"))
|
440 |
-
$link .= $site_url . bp_get_groups_root_slug (). '/' . bp_get_current_group_slug() . '/';
|
441 |
} else {
|
442 |
-
$post = get_post($rtmedia_media->post_parent);
|
443 |
|
444 |
$link .= $site_url . $post->post_name . '/';
|
445 |
}
|
446 |
|
447 |
-
$link .= '
|
448 |
|
449 |
-
if (isset($rtmedia_query->action_query->media_type)) {
|
450 |
-
if (in_array($rtmedia_query->action_query->media_type, array("photo", "music", "video", "album")))
|
451 |
$link .= $rtmedia_query->action_query->media_type . '/';
|
452 |
}
|
453 |
return $link . $page_url;
|
454 |
}
|
455 |
|
456 |
-
function rtmedia_pagination_next_link() {
|
457 |
|
458 |
global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
|
459 |
|
460 |
-
$page_url = 'pg/' . (rtmedia_page() + 1);
|
461 |
-
$site_url = (is_multisite()) ? trailingslashit(get_site_url(get_current_blog_id())) : trailingslashit(get_site_url());
|
462 |
-
$author_name = get_query_var('author_name');
|
463 |
$link = '';
|
464 |
|
465 |
-
if ($rtmedia_interaction->context->type == "profile") {
|
466 |
-
if (function_exists("bp_core_get_user_domain"))
|
467 |
-
$link .= trailingslashit(bp_core_get_user_domain($rtmedia_media->media_author));
|
468 |
else
|
469 |
$link .= $site_url . 'author/' . $author_name . '/';
|
470 |
-
} else if ($rtmedia_interaction->context->type == 'group') {
|
471 |
-
if (function_exists("bp_get_current_group_slug"))
|
472 |
-
$link .= $site_url . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/';
|
473 |
} else {
|
474 |
-
$post = get_post($rtmedia_media->post_parent);
|
475 |
|
476 |
$link .= $site_url . $post->post_name . '/';
|
477 |
}
|
478 |
-
$link .= '
|
479 |
-
if(isset($rtmedia_query->media_query["album_id"]) && intval($rtmedia_query->media_query["album_id"]) > 0){
|
480 |
-
$link .= $rtmedia_query->media_query["album_id"] . "/";
|
481 |
}
|
482 |
-
if (isset($rtmedia_query->action_query->media_type)) {
|
483 |
-
if (in_array($rtmedia_query->action_query->media_type, array("photo", "music", "video", "album")))
|
484 |
$link .= $rtmedia_query->action_query->media_type . '/';
|
485 |
}
|
486 |
return $link . $page_url;
|
487 |
}
|
488 |
|
489 |
-
function rtmedia_comments_enabled() {
|
490 |
global $rtmedia;
|
491 |
-
return $rtmedia->options['general_enableComments'] && is_user_logged_in();
|
492 |
}
|
493 |
|
494 |
/**
|
495 |
*
|
496 |
* @return boolean
|
497 |
*/
|
498 |
-
function is_rtmedia_gallery() {
|
499 |
global $rtmedia_query;
|
500 |
-
return $rtmedia_query->is_gallery();
|
501 |
}
|
502 |
|
503 |
/**
|
504 |
*
|
505 |
* @return boolean
|
506 |
*/
|
507 |
-
function is_rtmedia_album_gallery() {
|
508 |
global $rtmedia_query;
|
509 |
-
return $rtmedia_query->is_album_gallery();
|
510 |
}
|
511 |
|
512 |
/**
|
513 |
*
|
514 |
* @return boolean
|
515 |
*/
|
516 |
-
function is_rtmedia_single() {
|
517 |
global $rtmedia_query;
|
518 |
-
if ($rtmedia_query)
|
519 |
-
return $rtmedia_query->is_single();
|
520 |
else
|
521 |
return false;
|
522 |
}
|
@@ -525,10 +523,10 @@ function is_rtmedia_single() {
|
|
525 |
*
|
526 |
* @return boolean
|
527 |
*/
|
528 |
-
function is_rtmedia_album() {
|
529 |
global $rtmedia_query;
|
530 |
-
if ($rtmedia_query)
|
531 |
-
return $rtmedia_query->is_album();
|
532 |
else
|
533 |
return false;
|
534 |
}
|
@@ -537,10 +535,10 @@ function is_rtmedia_album() {
|
|
537 |
*
|
538 |
* @return boolean
|
539 |
*/
|
540 |
-
function is_rtmedia_edit_allowed() {
|
541 |
global $rtmedia_query;
|
542 |
-
if ($rtmedia_query) {
|
543 |
-
if (isset($rtmedia_query->media_query['media_author']) && get_current_user_id() == $rtmedia_query->media_query['media_author'] && $rtmedia_query->action_query->action == 'edit')
|
544 |
return true;
|
545 |
else
|
546 |
return false;
|
@@ -549,331 +547,322 @@ function is_rtmedia_edit_allowed() {
|
|
549 |
}
|
550 |
}
|
551 |
|
552 |
-
add_action('rtmedia_add_edit_fields', 'rtmedia_image_editor',999);
|
553 |
|
554 |
-
function rtmedia_image_editor() {
|
555 |
global $rtmedia_query;
|
556 |
-
if ($rtmedia_query->media[0]->media_type == 'photo') {
|
557 |
-
$media_id = $rtmedia_query->media[0]->media_id;
|
558 |
-
$id = $rtmedia_query->media[0]->id;
|
559 |
//$editor = wp_get_image_editor(get_attached_file($id));
|
560 |
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
|
561 |
echo '<div class="rtmedia-image-editor-cotnainer">';
|
562 |
echo '<div class="rtmedia-image-editor" id="image-editor-' . $media_id . '"></div>';
|
563 |
-
$thumb_url = wp_get_attachment_image_src($media_id, 'thumbnail', true);
|
564 |
-
$nonce = wp_create_nonce("image_editor-$media_id");
|
565 |
echo '<div id="imgedit-response-' . $media_id . '"></div>';
|
566 |
echo '<div class="wp_attachment_image" id="media-head-' . $media_id . '">
|
567 |
-
<p id="thumbnail-head-' . $id . '"><img class="thumbnail" src="' . set_url_scheme($thumb_url[0]) . '" alt="" /></p>
|
568 |
<p><input type="button" class="rtmedia-image-edit" id="imgedit-open-btn-' . $media_id . '" onclick="imageEdit.open( \'' . $media_id . '\', \'' . $nonce . '\' )" class="button" value="Modifiy Image"> <span class="spinner"></span></p></div>';
|
569 |
echo '</div>';
|
570 |
}
|
571 |
}
|
572 |
|
573 |
-
function rtmedia_comment_form() {
|
574 |
?>
|
575 |
-
<form method="post" id="rt_media_comment_form" action="<?php echo get_rtmedia_permalink(rtmedia_id()); ?>comment/">
|
576 |
<div class="row">
|
577 |
<div class="large-12 columns">
|
578 |
-
<textarea style="width:100%" placeholder="<?php _e("Type Comment...", 'rtmedia'); ?>" name="comment_content" id="comment_content"></textarea>
|
579 |
</div>
|
580 |
</div>
|
581 |
-
<input type="submit" id="rt_media_comment_submit" value="<?php _e('Comment', 'rtmedia'); ?>">
|
582 |
-
<?php RTMediaComment::comment_nonce_generator(); ?>
|
583 |
</form>
|
584 |
<?php
|
585 |
}
|
586 |
|
587 |
-
function rtmedia_delete_form() {
|
588 |
|
589 |
-
$html = '<form method="post" action="' . get_rtmedia_permalink(rtmedia_id()) . 'delete/">';
|
590 |
-
$html .= '<input type="hidden" name="id" id="id" value="' . rtmedia_id() . '">';
|
591 |
$html .= '<input type="hidden" name="request_action" id="request_action" value="delete">';
|
592 |
echo $html;
|
593 |
-
RTMediaMedia::media_nonce_generator(rtmedia_id(), true);
|
594 |
-
echo '<input type="submit" value="' . __('Delete', 'rtmedia') . '"></form>';
|
595 |
}
|
596 |
|
597 |
/**
|
598 |
*
|
599 |
* @param type $attr
|
600 |
*/
|
601 |
-
function rtmedia_uploader($attr = '') {
|
602 |
-
if (function_exists('bp_is_blog_page') && !bp_is_blog_page()) {
|
603 |
-
if (function_exists('bp_is_user') && bp_is_user() && function_exists('bp_displayed_user_id') && bp_displayed_user_id() == get_current_user_id())
|
604 |
-
echo RTMediaUploadShortcode::pre_render($attr);
|
605 |
-
else if (function_exists('bp_is_group') && bp_is_group()){
|
606 |
-
if(can_user_upload_in_group())
|
607 |
-
echo RTMediaUploadShortcode::pre_render($attr);
|
608 |
}
|
609 |
-
|
610 |
}
|
611 |
}
|
612 |
|
613 |
-
function rtmedia_gallery($attr = '') {
|
614 |
-
echo RTMediaGalleryShortcode::render($attr);
|
615 |
}
|
616 |
|
617 |
-
function get_rtmedia_meta($id = false, $key = false) {
|
618 |
$rtmediameta = new RTMediaMeta();
|
619 |
-
return $rtmediameta->get_meta($id, $key);
|
620 |
}
|
621 |
|
622 |
-
function add_rtmedia_meta($id = false, $key = false, $value = false, $duplicate = false) {
|
623 |
-
$rtmediameta = new RTMediaMeta($id, $key, $value, $duplicate);
|
624 |
-
return $rtmediameta->add_meta($id, $key, $value, $duplicate);
|
625 |
}
|
626 |
|
627 |
-
function update_rtmedia_meta($id = false, $key = false, $value = false, $duplicate = false) {
|
628 |
$rtmediameta = new RTMediaMeta();
|
629 |
-
return $rtmediameta->update_meta($id, $key, $value, $duplicate);
|
630 |
}
|
631 |
|
632 |
-
function delete_rtmedia_meta($id = false, $key = false) {
|
633 |
$rtmediameta = new RTMediaMeta();
|
634 |
-
return $rtmediameta->delete_meta($id, $key);
|
635 |
}
|
636 |
|
637 |
-
function rtmedia_global_albums(){
|
638 |
-
|
639 |
-
|
640 |
}
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
$
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
|
|
653 |
$option = NULL;
|
654 |
|
655 |
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
|
665 |
-
return $option;
|
666 |
|
|
|
667 |
}
|
668 |
|
669 |
-
function rtmedia_user_album_list() {
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
$
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
)
|
684 |
-
)
|
685 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
686 |
}
|
687 |
}
|
688 |
|
689 |
-
if ($option)
|
690 |
return $option;
|
691 |
else
|
692 |
return false;
|
693 |
}
|
694 |
|
695 |
-
function rtmedia_group_album_list() {
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
$album_objects = $model->get_media(
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
foreach ($album_objects as $album) {
|
713 |
-
if (!in_array($album->id, $global_albums) && (( isset($rtmedia_query->media_query['album_id']) && ($album->id != $rtmedia_query->media_query['album_id'])) || !isset($rtmedia_query->media_query['album_id']) ))
|
714 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
715 |
}
|
716 |
}
|
717 |
|
718 |
-
if ($option)
|
719 |
return $option;
|
720 |
else
|
721 |
return false;
|
722 |
}
|
723 |
|
|
|
724 |
|
725 |
-
add_action('
|
726 |
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
if(!is_rtmedia_album_enable())
|
731 |
-
return ;
|
732 |
global $rtmedia_query;
|
733 |
-
|
734 |
-
|
735 |
-
if(isset($rtmedia_query->query['context']) && in_array($rtmedia_query->query['context'], array('profile', 'group'))){
|
736 |
-
switch ($rtmedia_query->query['context']){
|
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 |
-
add_action('rtmedia_before_media_gallery', 'rtmedia_album_edit');
|
765 |
|
766 |
-
function rtmedia_album_edit() {
|
767 |
|
768 |
-
if (!is_rtmedia_album() || !is_user_logged_in())
|
|
|
|
|
769 |
return;
|
770 |
-
if(! is_rtmedia_album_enable())
|
771 |
-
return ;
|
772 |
global $rtmedia_query;
|
773 |
-
|
774 |
-
if (isset($rtmedia_query->media_query)
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
if( $album_list = rtmedia_user_album_list()){ ?>
|
785 |
-
<input type="button" class="button rtmedia-merge" value="<?php _e('Merge', 'rtmedia'); ?>" />
|
786 |
<div class="rtmedia-merge-container">
|
787 |
-
<?php _e('Merge to', 'rtmedia'); ?>
|
788 |
<form method="post" class="album-merge-form" action="merge/">
|
789 |
<?php echo '<select name="album" class="rtmedia-merge-user-album-list">' . $album_list . '</select>'; ?>
|
790 |
-
<?php wp_nonce_field('rtmedia_merge_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_merge_album_nonce'); ?>
|
791 |
-
<input type="submit" class="rtmedia-move-selected" name="merge-album" value="<?php _e('Merge Album', 'rtmedia'); ?>" />
|
792 |
</form>
|
793 |
</div>
|
794 |
<?php
|
795 |
}
|
796 |
-
|
797 |
-
|
798 |
}
|
799 |
|
800 |
-
add_action('rtmedia_before_item', 'rtmedia_item_select');
|
801 |
|
802 |
-
function rtmedia_item_select() {
|
803 |
global $rtmedia_query, $rtmedia_backbone;
|
804 |
-
if ($rtmedia_backbone['backbone']) {
|
805 |
-
if ($rtmedia_backbone['is_album'] && $rtmedia_backbone['is_edit_allowed'])
|
806 |
echo '<input type="checkbox" name="move[]" value="<%= id %>" />';
|
807 |
-
} else if (is_rtmedia_album() && isset($rtmedia_query->media_query)
|
808 |
-
if(isset($rtmedia_query->media_query['media_author'])
|
809 |
-
|
810 |
-
echo '<input type="checkbox" name="selected[]" value="' . rtmedia_id() . '" />';
|
811 |
}
|
812 |
}
|
813 |
|
814 |
-
add_action('rtmedia_query_actions', 'rtmedia_album_merge_action');
|
815 |
|
816 |
-
function rtmedia_album_merge_action($actions) {
|
817 |
-
$actions['merge'] = __('Merge', 'rtmedia');
|
818 |
return $actions;
|
819 |
}
|
820 |
|
821 |
-
function rtmedia_sub_nav() {
|
822 |
-
|
|
|
|
|
823 |
}
|
824 |
|
825 |
-
function is_rtmedia_album_enable(){
|
826 |
global $rtmedia;
|
827 |
-
if(isset($rtmedia->options["general_enableAlbums"]) && $rtmedia->options["general_enableAlbums"] != "0"){
|
828 |
return true;
|
829 |
}
|
830 |
return false;
|
831 |
}
|
832 |
|
833 |
-
function rtmedia_load_template(){
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
}
|
838 |
|
839 |
-
function is_rtmedia_privacy_enable(){
|
840 |
global $rtmedia;
|
841 |
-
if(isset($rtmedia->options["privacy_enabled"]) && $rtmedia->options["privacy_enabled"] != "0"){
|
842 |
return true;
|
843 |
}
|
844 |
return false;
|
845 |
}
|
846 |
|
847 |
-
function is_rtmedia_privacy_user_overide(){
|
848 |
global $rtmedia;
|
849 |
-
if(isset($rtmedia->options["privacy_userOverride"]) && $rtmedia->options["privacy_userOverride"] != "0"){
|
850 |
return true;
|
851 |
}
|
852 |
return false;
|
853 |
}
|
854 |
|
855 |
-
function get_rtmedia_default_privacy(){
|
856 |
-
|
857 |
global $rtmedia;
|
858 |
-
if(isset($rtmedia->options["privacy_default"])){
|
859 |
-
return $rtmedia->options["privacy_default"];
|
860 |
}
|
861 |
return 0;
|
862 |
}
|
863 |
|
864 |
-
function is_rtmedia_group_media_enable(){
|
865 |
global $rtmedia;
|
866 |
-
if(isset($rtmedia->options["buddypress_enableOnGroup"]) && $rtmedia->options["buddypress_enableOnGroup"] != "0"){
|
867 |
return true;
|
868 |
}
|
869 |
return false;
|
870 |
}
|
871 |
-
|
872 |
-
|
873 |
-
$
|
874 |
-
$
|
|
|
875 |
$display_flag = false;
|
876 |
-
if (groups_is_user_member($user_id, $group->id)) {
|
877 |
// if ($upload_level == "admin") {
|
878 |
// if (groups_is_user_admin($user_id, $group->id)) {
|
879 |
// $display_flag = true;
|
@@ -889,27 +878,34 @@ function can_user_upload_in_group() {
|
|
889 |
}
|
890 |
return $display_flag;
|
891 |
}
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
$upload_level = "all";
|
902 |
}
|
903 |
}
|
904 |
-
$user_id = get_current_user_id();
|
905 |
$display_flag = false;
|
906 |
-
if (groups_is_user_member($user_id, $group_id)) {
|
907 |
-
if ($upload_level == "admin") {
|
908 |
-
if (groups_is_user_admin($user_id, $group_id) > 0) {
|
909 |
$display_flag = true;
|
910 |
}
|
911 |
-
} else if ($upload_level == "moderators") {
|
912 |
-
if (groups_is_user_mod($user_id, $group_id)) {
|
913 |
$display_flag = true;
|
914 |
}
|
915 |
} else {
|
@@ -917,4 +913,44 @@ function can_user_create_album_in_group($group_id = false, $user_id = false) {
|
|
917 |
}
|
918 |
}
|
919 |
return $display_flag;
|
920 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
* @global type $rtmedia_query
|
6 |
* @return type
|
7 |
*/
|
8 |
+
function have_rtmedia () {
|
9 |
global $rtmedia_query;
|
10 |
|
11 |
+
return $rtmedia_query->have_media ();
|
12 |
}
|
13 |
|
14 |
/**
|
16 |
* @global type $rtmedia_query
|
17 |
* @return type
|
18 |
*/
|
19 |
+
function rewind_rtmedia () {
|
20 |
|
21 |
global $rtmedia_query;
|
22 |
|
23 |
+
return $rtmedia_query->rewind_media ();
|
24 |
}
|
25 |
|
26 |
/**
|
28 |
* @global type $rtmedia_query
|
29 |
* @return type
|
30 |
*/
|
31 |
+
function rtmedia () {
|
32 |
global $rtmedia_query;
|
33 |
|
34 |
+
return $rtmedia_query->rtmedia ();
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
* echo the title of the media
|
39 |
* @global type $rtmedia_media
|
40 |
*/
|
41 |
+
function rtmedia_title () {
|
42 |
|
43 |
global $rtmedia_backbone;
|
44 |
+
if ( $rtmedia_backbone[ 'backbone' ] ) {
|
45 |
echo '<%= media_title %>';
|
46 |
} else {
|
47 |
global $rtmedia_media;
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
function rtmedia_media_gallery_class () {
|
|
|
53 |
global $rtmedia_query;
|
54 |
+
if ( isset ( $rtmedia_query->media_query ) && isset ( $rtmedia_query->media_query[ "context_id" ] ) )
|
55 |
+
echo "context-id-" . $rtmedia_query->media_query[ "context_id" ];
|
56 |
}
|
57 |
+
|
58 |
+
function rtmedia_id ( $media_id = false ) {
|
59 |
+
if ( $media_id ) {
|
60 |
$model = new RTMediaModel();
|
61 |
+
$media = $model->get_media ( array( 'media_id' => $media_id ), 0, 1 );
|
62 |
+
return $media[ 0 ]->id;
|
63 |
} else {
|
64 |
global $rtmedia_media;
|
65 |
return $rtmedia_media->id;
|
66 |
}
|
67 |
}
|
68 |
|
69 |
+
function rtmedia_media_id ( $id = false ) {
|
70 |
+
if ( $id ) {
|
71 |
$model = new RTMediaModel();
|
72 |
+
$media = $model->get_media ( array( 'id' => $id ), 0, 1 );
|
73 |
+
return $media[ 0 ]->media_id;
|
74 |
} else {
|
75 |
global $rtmedia_media;
|
76 |
return $rtmedia_media->media_id;
|
77 |
}
|
78 |
}
|
79 |
|
80 |
+
function rtmedia_activity_id ( $id = false ) {
|
81 |
+
if ( $id ) {
|
82 |
$model = new RTMediaModel();
|
83 |
+
$media = $model->get_media ( array( 'id' => $id ), 0, 1 );
|
84 |
+
return $media[ 0 ]->activity_id;
|
85 |
} else {
|
86 |
global $rtmedia_media;
|
87 |
return $rtmedia_media->activity_id;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
+
function rtmedia_type ( $id = false ) {
|
92 |
+
if ( $id ) {
|
93 |
$model = new RTMediaModel();
|
94 |
+
$media = $model->get_media ( array( 'id' => $id ), 0, 1 );
|
95 |
+
return $media[ 0 ]->media_type;
|
96 |
} else {
|
97 |
global $rtmedia_media;
|
98 |
return $rtmedia_media->media_type;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
+
function rtmedia_cover_art ( $id = false ) {
|
103 |
+
if ( $id ) {
|
104 |
$model = new RTMediaModel();
|
105 |
+
$media = $model->get_media ( array( 'id' => $id ), 0, 1 );
|
106 |
+
return $media[ 0 ]->cover_art;
|
107 |
} else {
|
108 |
global $rtmedia_media;
|
109 |
return $rtmedia_media->cover_art;
|
114 |
* echo parmalink of the media
|
115 |
* @global type $rtmedia_media
|
116 |
*/
|
117 |
+
function rtmedia_permalink () {
|
118 |
|
119 |
global $rtmedia_backbone;
|
120 |
|
121 |
+
if ( $rtmedia_backbone[ 'backbone' ] ) {
|
122 |
echo '<%= rt_permalink %>';
|
123 |
} else {
|
124 |
+
echo get_rtmedia_permalink ( rtmedia_id () );
|
125 |
}
|
126 |
}
|
127 |
|
128 |
+
function rtmedia_media ( $size_flag = true, $echo = true, $media_size = "rt_media_single_image" ) {
|
129 |
$size_flag = true;
|
130 |
global $rtmedia_media, $rtmedia;
|
131 |
+
if ( isset ( $rtmedia_media->media_type ) ) {
|
132 |
+
if ( $rtmedia_media->media_type == 'photo' ) {
|
133 |
+
$html = wp_get_attachment_image ( $rtmedia_media->media_id, $media_size );
|
134 |
+
} elseif ( $rtmedia_media->media_type == 'video' ) {
|
135 |
+
$size = " width=\"" . $rtmedia->options[ "defaultSizes_video_singlePlayer_width" ] . "\" height=\"" . $rtmedia->options[ "defaultSizes_video_singlePlayer_height" ] . "\" ";
|
136 |
+
|
137 |
+
$html = '<div class="flex-video"><video src="' . wp_get_attachment_url ( $rtmedia_media->media_id ) . '" ' . $size . ' type="video/mp4" class="wp-video-shortcode" id="bp_media_video_' . $rtmedia_media->id . '" controls="controls" preload="none"></video></div>';
|
138 |
+
} elseif ( $rtmedia_media->media_type == 'music' ) {
|
139 |
$size = ' width="600" height="0" ';
|
140 |
+
if ( ! $size_flag )
|
141 |
$size = '';
|
142 |
+
$html = '<audio src="' . wp_get_attachment_url ( $rtmedia_media->media_id ) . '" ' . $size . ' type="audio/mp3" class="wp-audio-shortcode" id="bp_media_audio_' . $rtmedia_media->id . '" controls="controls" preload="none"></audio>';
|
143 |
} else {
|
144 |
$html = false;
|
145 |
}
|
147 |
$html = false;
|
148 |
}
|
149 |
|
150 |
+
do_action ( 'rtmedia_after_' . $rtmedia_media->media_type, $rtmedia_media->id );
|
151 |
|
152 |
+
$html = apply_filters ( 'rtmedia_single_content_filter', $html, $rtmedia_media );
|
153 |
|
154 |
+
if ( $echo )
|
155 |
echo $html;
|
156 |
else
|
157 |
return $html;
|
161 |
* echo http url of the media
|
162 |
*/
|
163 |
|
164 |
+
function rtmedia_image ( $size = 'rt_media_thumbnail', $id = false ) {
|
165 |
global $rtmedia_backbone;
|
166 |
|
167 |
+
if ( $rtmedia_backbone[ 'backbone' ] ) {
|
168 |
echo '<%= guid %>';
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
+
if ( $id ) {
|
173 |
$model = new RTMediaModel();
|
174 |
+
$media = $model->get_media ( array( 'id' => $id ), false, false );
|
175 |
+
if ( isset ( $media[ 0 ] ) )
|
176 |
+
$media_object = $media[ 0 ];
|
177 |
else
|
178 |
return false;
|
179 |
} else {
|
182 |
}
|
183 |
|
184 |
$thumbnail_id = 0;
|
185 |
+
if ( isset ( $media_object->media_type ) ) {
|
186 |
+
if ( $media_object->media_type == 'album' ||
|
187 |
+
$media_object->media_type != 'photo' ) {
|
188 |
+
$thumbnail_id = isset ( $media_object->cover_art ) ? $media_object->cover_art : false;
|
189 |
+
} elseif ( $media_object->media_type == 'photo' ) {
|
190 |
$thumbnail_id = $media_object->media_id;
|
191 |
} else {
|
192 |
$thumbnail_id = false;
|
195 |
$src = false;
|
196 |
}
|
197 |
|
198 |
+
if ( ! $thumbnail_id ) {
|
199 |
global $rtmedia;
|
200 |
+
if ( isset ( $rtmedia->allowed_types[ $media_object->media_type ] ) && isset ( $rtmedia->allowed_types[ $media_object->media_type ][ 'thumbnail' ] ) ) {
|
201 |
+
$src = $rtmedia->allowed_types[ $media_object->media_type ][ 'thumbnail' ];
|
202 |
+
} elseif ( $media_object->media_type == 'album' ) {
|
203 |
+
$src = rtmedia_album_image ( $size );
|
|
|
204 |
} else {
|
205 |
$src = false;
|
206 |
}
|
207 |
} else {
|
208 |
+
list($src, $width, $height) = wp_get_attachment_image_src ( $thumbnail_id, $size );
|
209 |
}
|
210 |
|
211 |
+
$src = apply_filters ( 'rtmedia_media_thumb', $src, $media_object->id, $media_object->media_type );
|
212 |
|
213 |
echo $src;
|
214 |
}
|
215 |
|
216 |
+
function rtmedia_album_image ( $size = 'thumbnail' ) {
|
217 |
global $rtmedia_media;
|
218 |
$model = new RTMediaModel();
|
219 |
+
$media = $model->get_media ( array( 'album_id' => $rtmedia_media->id, 'media_type' => 'photo' ), 0, 1 );
|
220 |
|
221 |
+
if ( $media ) {
|
222 |
+
$src = rtmedia_image ( $size, $media[ 0 ]->id );
|
223 |
} else {
|
224 |
global $rtmedia;
|
225 |
+
$src = $rtmedia->allowed_types[ 'photo' ][ 'thumbnail' ];
|
226 |
}
|
227 |
return $src;
|
228 |
}
|
229 |
|
230 |
+
function rtmedia_sanitize_object ( $data, $exceptions = array( ) ) {
|
231 |
+
foreach ( $data as $key => $value ) {
|
232 |
+
if ( ! in_array ( $key, array_merge ( RTMediaMedia::$default_object, $exceptions ) ) )
|
233 |
+
unset ( $data[ $key ] );
|
234 |
}
|
235 |
return $data;
|
236 |
}
|
237 |
|
238 |
+
function rtmedia_delete_allowed () {
|
239 |
global $rtmedia_media;
|
240 |
|
241 |
+
$flag = $rtmedia_media->media_author == get_current_user_id ();
|
242 |
|
243 |
+
$flag = apply_filters ( 'rtmedia_media_delete_priv', $flag );
|
244 |
|
245 |
return $flag;
|
246 |
}
|
247 |
|
248 |
+
function rtmedia_edit_allowed () {
|
249 |
|
250 |
global $rtmedia_media;
|
251 |
|
252 |
+
$flag = $rtmedia_media->media_author == get_current_user_id ();
|
253 |
|
254 |
+
$flag = apply_filters ( 'rtmedia_media_edit_priv', $flag );
|
255 |
|
256 |
return $flag;
|
257 |
}
|
258 |
|
259 |
+
function rtmedia_request_action () {
|
260 |
global $rtmedia_query;
|
261 |
return $rtmedia_query->action_query->action;
|
262 |
}
|
263 |
|
264 |
+
function rtmedia_title_input () {
|
|
|
265 |
global $rtmedia_media;
|
266 |
|
267 |
$name = 'media_title';
|
269 |
|
270 |
$html = '';
|
271 |
|
272 |
+
if ( rtmedia_request_action () == 'edit' )
|
273 |
$html .= '<input type="text" name="' . $name . '" id="' . $name . '" value="' . $value . '">';
|
274 |
else
|
275 |
$html .= '<h2 name="' . $name . '" id="' . $name . '">' . $value . '</h2>';
|
279 |
echo $html;
|
280 |
}
|
281 |
|
282 |
+
function rtmedia_description_input () {
|
283 |
global $rtmedia_media;
|
284 |
|
285 |
$name = 'description';
|
287 |
|
288 |
$html = '';
|
289 |
|
290 |
+
if ( rtmedia_request_action () == 'edit' )
|
291 |
+
$html .= wp_editor ( $value, $name, array( 'media_buttons' => false ) );
|
292 |
else
|
293 |
$html .= '<div name="' . $name . '" id="' . $name . '">' . $value . '</div>';
|
294 |
|
301 |
* echo media description
|
302 |
* @global type $rtmedia_media
|
303 |
*/
|
304 |
+
function rtmedia_description () {
|
305 |
global $rtmedia_media;
|
306 |
echo $rtmedia_media->post_content;
|
307 |
}
|
311 |
* @global type $rtmedia_query
|
312 |
* @return type
|
313 |
*/
|
314 |
+
function rtmedia_count () {
|
315 |
global $rtmedia_query;
|
316 |
|
317 |
return $rtmedia_query->media_count;
|
322 |
* @global type $rtmedia_query
|
323 |
* @return type
|
324 |
*/
|
325 |
+
function rtmedia_offset () {
|
326 |
global $rtmedia_query;
|
327 |
|
328 |
return ($rtmedia_query->action_query->page - 1) * $rtmedia_query->action_query->per_page_media;
|
333 |
* @global type $rtmedia_query
|
334 |
* @return type
|
335 |
*/
|
336 |
+
function rtmedia_per_page_media () {
|
337 |
global $rtmedia_query;
|
338 |
|
339 |
return $rtmedia_query->action_query->per_page_media;
|
344 |
* @global type $rtmedia_query
|
345 |
* @return type
|
346 |
*/
|
347 |
+
function rtmedia_page () {
|
348 |
global $rtmedia_query;
|
349 |
|
350 |
return $rtmedia_query->action_query->page;
|
355 |
* @global type $rtmedia_query
|
356 |
* @return type
|
357 |
*/
|
358 |
+
function rtmedia_current_media () {
|
359 |
global $rtmedia_query;
|
360 |
|
361 |
return $rtmedia_query->current_media;
|
364 |
/**
|
365 |
*
|
366 |
*/
|
367 |
+
function rtmedia_actions () {
|
368 |
|
369 |
+
$actions = array( );
|
370 |
|
371 |
+
if ( is_user_logged_in () && rtmedia_edit_allowed () ) {
|
372 |
|
373 |
+
$actions[ ] = '<form action="' . get_rtmedia_permalink ( rtmedia_id () ) . 'edit/">
|
374 |
+
<button type="submit" >' . __ ( 'Edit', 'rtmedia' ) . '</button></form>';
|
375 |
}
|
376 |
+
$actions = apply_filters ( 'rtmedia_action_buttons_before_delete', $actions );
|
377 |
+
foreach ( $actions as $action ) {
|
378 |
echo $action;
|
379 |
}
|
380 |
+
$actions = array( );
|
381 |
+
if ( rtmedia_delete_allowed () ) {
|
382 |
+
rtmedia_delete_form ();
|
383 |
}
|
384 |
+
$actions = apply_filters ( 'rtmedia_action_buttons_after_delete', $actions );
|
385 |
|
386 |
+
foreach ( $actions as $action ) {
|
387 |
echo $action;
|
388 |
}
|
389 |
}
|
391 |
/**
|
392 |
* rendering comments section
|
393 |
*/
|
394 |
+
function rtmedia_comments () {
|
395 |
|
396 |
$html = '<ul id="rtmedia_comment_ul" class="large-block-grid-1">';
|
397 |
|
398 |
global $wpdb, $rtmedia_media;
|
399 |
|
400 |
+
$comments = $wpdb->get_results ( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '" . $rtmedia_media->media_id . "'", ARRAY_A );
|
401 |
|
402 |
+
foreach ( $comments as $comment ) {
|
403 |
+
$html .= rmedia_single_comment ( $comment );
|
404 |
}
|
405 |
|
406 |
$html .= '</ul>';
|
408 |
echo $html;
|
409 |
}
|
410 |
|
411 |
+
function rmedia_single_comment ( $comment ) {
|
412 |
$html = "";
|
413 |
$html .= '<li class="rtmedia-comment">';
|
414 |
+
$html .= '<div class ="rtmedia-comment-author">' . (($comment[ 'comment_author' ]) ? $comment[ 'comment_author' ] : 'Annonymous') . ' said : </div>';
|
415 |
+
$html .= '<div class="rtmedia-comment-content">' . $comment[ 'comment_content' ] . '</div>';
|
416 |
+
$html .= '<div class ="rtmedia-comment-date"> on ' . $comment[ 'comment_date_gmt' ] . '</div>';
|
417 |
// $html .= '<a href></a>';
|
418 |
$html .= '</li>';
|
419 |
return $html;
|
420 |
}
|
421 |
|
422 |
+
function rtmedia_pagination_prev_link () {
|
423 |
|
424 |
global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
|
425 |
|
426 |
+
$page_url = ((rtmedia_page () - 1) == 1) ? "" : "pg/" . (rtmedia_page () - 1);
|
427 |
+
$site_url = (is_multisite ()) ? trailingslashit ( get_site_url ( get_current_blog_id () ) ) : trailingslashit ( get_site_url () );
|
428 |
+
$author_name = get_query_var ( 'author_name' );
|
429 |
$link = '';
|
430 |
|
431 |
+
if ( $rtmedia_interaction->context->type == "profile" ) {
|
432 |
+
if ( function_exists ( "bp_core_get_user_domain" ) )
|
433 |
+
$link .= trailingslashit ( bp_core_get_user_domain ( $rtmedia_media->media_author ) );
|
434 |
else
|
435 |
$link = $site_url . 'author/' . $author_name . '/';
|
436 |
+
} else if ( $rtmedia_interaction->context->type == 'group' ) {
|
437 |
+
if ( function_exists ( "bp_get_current_group_slug" ) )
|
438 |
+
$link .= $site_url . bp_get_groups_root_slug () . '/' . bp_get_current_group_slug () . '/';
|
439 |
} else {
|
440 |
+
$post = get_post ( $rtmedia_media->post_parent );
|
441 |
|
442 |
$link .= $site_url . $post->post_name . '/';
|
443 |
}
|
444 |
|
445 |
+
$link .= RTMEDIA_MEDIA_SLUG . '/';
|
446 |
|
447 |
+
if ( isset ( $rtmedia_query->action_query->media_type ) ) {
|
448 |
+
if ( in_array ( $rtmedia_query->action_query->media_type, array( "photo", "music", "video", "album" ) ) )
|
449 |
$link .= $rtmedia_query->action_query->media_type . '/';
|
450 |
}
|
451 |
return $link . $page_url;
|
452 |
}
|
453 |
|
454 |
+
function rtmedia_pagination_next_link () {
|
455 |
|
456 |
global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
|
457 |
|
458 |
+
$page_url = 'pg/' . (rtmedia_page () + 1);
|
459 |
+
$site_url = (is_multisite ()) ? trailingslashit ( get_site_url ( get_current_blog_id () ) ) : trailingslashit ( get_site_url () );
|
460 |
+
$author_name = get_query_var ( 'author_name' );
|
461 |
$link = '';
|
462 |
|
463 |
+
if ( $rtmedia_interaction->context->type == "profile" ) {
|
464 |
+
if ( function_exists ( "bp_core_get_user_domain" ) )
|
465 |
+
$link .= trailingslashit ( bp_core_get_user_domain ( $rtmedia_media->media_author ) );
|
466 |
else
|
467 |
$link .= $site_url . 'author/' . $author_name . '/';
|
468 |
+
} else if ( $rtmedia_interaction->context->type == 'group' ) {
|
469 |
+
if ( function_exists ( "bp_get_current_group_slug" ) )
|
470 |
+
$link .= $site_url . bp_get_groups_root_slug () . '/' . bp_get_current_group_slug () . '/';
|
471 |
} else {
|
472 |
+
$post = get_post ( $rtmedia_media->post_parent );
|
473 |
|
474 |
$link .= $site_url . $post->post_name . '/';
|
475 |
}
|
476 |
+
$link .= RTMEDIA_MEDIA_SLUG . '/';
|
477 |
+
if ( isset ( $rtmedia_query->media_query[ "album_id" ] ) && intval ( $rtmedia_query->media_query[ "album_id" ] ) > 0 ) {
|
478 |
+
$link .= $rtmedia_query->media_query[ "album_id" ] . "/";
|
479 |
}
|
480 |
+
if ( isset ( $rtmedia_query->action_query->media_type ) ) {
|
481 |
+
if ( in_array ( $rtmedia_query->action_query->media_type, array( "photo", "music", "video", "album" ) ) )
|
482 |
$link .= $rtmedia_query->action_query->media_type . '/';
|
483 |
}
|
484 |
return $link . $page_url;
|
485 |
}
|
486 |
|
487 |
+
function rtmedia_comments_enabled () {
|
488 |
global $rtmedia;
|
489 |
+
return $rtmedia->options[ 'general_enableComments' ] && is_user_logged_in ();
|
490 |
}
|
491 |
|
492 |
/**
|
493 |
*
|
494 |
* @return boolean
|
495 |
*/
|
496 |
+
function is_rtmedia_gallery () {
|
497 |
global $rtmedia_query;
|
498 |
+
return $rtmedia_query->is_gallery ();
|
499 |
}
|
500 |
|
501 |
/**
|
502 |
*
|
503 |
* @return boolean
|
504 |
*/
|
505 |
+
function is_rtmedia_album_gallery () {
|
506 |
global $rtmedia_query;
|
507 |
+
return $rtmedia_query->is_album_gallery ();
|
508 |
}
|
509 |
|
510 |
/**
|
511 |
*
|
512 |
* @return boolean
|
513 |
*/
|
514 |
+
function is_rtmedia_single () {
|
515 |
global $rtmedia_query;
|
516 |
+
if ( $rtmedia_query )
|
517 |
+
return $rtmedia_query->is_single ();
|
518 |
else
|
519 |
return false;
|
520 |
}
|
523 |
*
|
524 |
* @return boolean
|
525 |
*/
|
526 |
+
function is_rtmedia_album () {
|
527 |
global $rtmedia_query;
|
528 |
+
if ( $rtmedia_query )
|
529 |
+
return $rtmedia_query->is_album ();
|
530 |
else
|
531 |
return false;
|
532 |
}
|
535 |
*
|
536 |
* @return boolean
|
537 |
*/
|
538 |
+
function is_rtmedia_edit_allowed () {
|
539 |
global $rtmedia_query;
|
540 |
+
if ( $rtmedia_query ) {
|
541 |
+
if ( isset ( $rtmedia_query->media_query[ 'media_author' ] ) && get_current_user_id () == $rtmedia_query->media_query[ 'media_author' ] && $rtmedia_query->action_query->action == 'edit' )
|
542 |
return true;
|
543 |
else
|
544 |
return false;
|
547 |
}
|
548 |
}
|
549 |
|
550 |
+
add_action ( 'rtmedia_add_edit_fields', 'rtmedia_image_editor', 999 );
|
551 |
|
552 |
+
function rtmedia_image_editor () {
|
553 |
global $rtmedia_query;
|
554 |
+
if ( $rtmedia_query->media[ 0 ]->media_type == 'photo' ) {
|
555 |
+
$media_id = $rtmedia_query->media[ 0 ]->media_id;
|
556 |
+
$id = $rtmedia_query->media[ 0 ]->id;
|
557 |
//$editor = wp_get_image_editor(get_attached_file($id));
|
558 |
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
|
559 |
echo '<div class="rtmedia-image-editor-cotnainer">';
|
560 |
echo '<div class="rtmedia-image-editor" id="image-editor-' . $media_id . '"></div>';
|
561 |
+
$thumb_url = wp_get_attachment_image_src ( $media_id, 'thumbnail', true );
|
562 |
+
$nonce = wp_create_nonce ( "image_editor-$media_id" );
|
563 |
echo '<div id="imgedit-response-' . $media_id . '"></div>';
|
564 |
echo '<div class="wp_attachment_image" id="media-head-' . $media_id . '">
|
565 |
+
<p id="thumbnail-head-' . $id . '"><img class="thumbnail" src="' . set_url_scheme ( $thumb_url[ 0 ] ) . '" alt="" /></p>
|
566 |
<p><input type="button" class="rtmedia-image-edit" id="imgedit-open-btn-' . $media_id . '" onclick="imageEdit.open( \'' . $media_id . '\', \'' . $nonce . '\' )" class="button" value="Modifiy Image"> <span class="spinner"></span></p></div>';
|
567 |
echo '</div>';
|
568 |
}
|
569 |
}
|
570 |
|
571 |
+
function rtmedia_comment_form () {
|
572 |
?>
|
573 |
+
<form method="post" id="rt_media_comment_form" action="<?php echo get_rtmedia_permalink ( rtmedia_id () ); ?>comment/">
|
574 |
<div class="row">
|
575 |
<div class="large-12 columns">
|
576 |
+
<textarea style="width:100%" placeholder="<?php _e ( "Type Comment...", 'rtmedia' ); ?>" name="comment_content" id="comment_content"></textarea>
|
577 |
</div>
|
578 |
</div>
|
579 |
+
<input type="submit" id="rt_media_comment_submit" value="<?php _e ( 'Comment', 'rtmedia' ); ?>">
|
580 |
+
<?php RTMediaComment::comment_nonce_generator (); ?>
|
581 |
</form>
|
582 |
<?php
|
583 |
}
|
584 |
|
585 |
+
function rtmedia_delete_form () {
|
586 |
|
587 |
+
$html = '<form method="post" action="' . get_rtmedia_permalink ( rtmedia_id () ) . 'delete/">';
|
588 |
+
$html .= '<input type="hidden" name="id" id="id" value="' . rtmedia_id () . '">';
|
589 |
$html .= '<input type="hidden" name="request_action" id="request_action" value="delete">';
|
590 |
echo $html;
|
591 |
+
RTMediaMedia::media_nonce_generator ( rtmedia_id (), true );
|
592 |
+
echo '<input type="submit" value="' . __ ( 'Delete', 'rtmedia' ) . '"></form>';
|
593 |
}
|
594 |
|
595 |
/**
|
596 |
*
|
597 |
* @param type $attr
|
598 |
*/
|
599 |
+
function rtmedia_uploader ( $attr = '' ) {
|
600 |
+
if ( function_exists ( 'bp_is_blog_page' ) && ! bp_is_blog_page () ) {
|
601 |
+
if ( function_exists ( 'bp_is_user' ) && bp_is_user () && function_exists ( 'bp_displayed_user_id' ) && bp_displayed_user_id () == get_current_user_id () )
|
602 |
+
echo RTMediaUploadShortcode::pre_render ( $attr );
|
603 |
+
else if ( function_exists ( 'bp_is_group' ) && bp_is_group () ) {
|
604 |
+
if ( can_user_upload_in_group () )
|
605 |
+
echo RTMediaUploadShortcode::pre_render ( $attr );
|
606 |
}
|
|
|
607 |
}
|
608 |
}
|
609 |
|
610 |
+
function rtmedia_gallery ( $attr = '' ) {
|
611 |
+
echo RTMediaGalleryShortcode::render ( $attr );
|
612 |
}
|
613 |
|
614 |
+
function get_rtmedia_meta ( $id = false, $key = false ) {
|
615 |
$rtmediameta = new RTMediaMeta();
|
616 |
+
return $rtmediameta->get_meta ( $id, $key );
|
617 |
}
|
618 |
|
619 |
+
function add_rtmedia_meta ( $id = false, $key = false, $value = false, $duplicate = false ) {
|
620 |
+
$rtmediameta = new RTMediaMeta ( $id, $key, $value, $duplicate );
|
621 |
+
return $rtmediameta->add_meta ( $id, $key, $value, $duplicate );
|
622 |
}
|
623 |
|
624 |
+
function update_rtmedia_meta ( $id = false, $key = false, $value = false, $duplicate = false ) {
|
625 |
$rtmediameta = new RTMediaMeta();
|
626 |
+
return $rtmediameta->update_meta ( $id, $key, $value, $duplicate );
|
627 |
}
|
628 |
|
629 |
+
function delete_rtmedia_meta ( $id = false, $key = false ) {
|
630 |
$rtmediameta = new RTMediaMeta();
|
631 |
+
return $rtmediameta->delete_meta ( $id, $key );
|
632 |
}
|
633 |
|
634 |
+
function rtmedia_global_albums () {
|
635 |
+
return RTMediaAlbum::get_globals (); //get_site_option('rtmedia-global-albums');
|
|
|
636 |
}
|
637 |
+
|
638 |
+
function rtmedia_global_album_list () {
|
639 |
+
global $rtmedia_query;
|
640 |
+
$model = new RTMediaModel();
|
641 |
+
$global_albums = rtmedia_global_albums ();
|
642 |
+
if ( ! empty ( $global_albums ) ) {
|
643 |
+
if ( is_array ( $global_albums ) ) {
|
644 |
+
$albums = implode ( ',', $global_albums );
|
645 |
+
} else {
|
646 |
+
return;
|
647 |
+
}
|
648 |
+
return;
|
649 |
+
}
|
650 |
$option = NULL;
|
651 |
|
652 |
|
653 |
+
$album_objects = $model->get_media ( array( 'id' => ($albums) ), false, false );
|
654 |
+
if ( $album_objects ) {
|
655 |
+
foreach ( $album_objects as $album ) {
|
656 |
+
if ( (isset ( $rtmedia_query->media_query[ 'album_id' ] ) && ($album_objects[ 0 ]->id != $rtmedia_query->media_query[ 'album_id' ])) || ! isset ( $rtmedia_query->media_query[ 'album_id' ] ) )
|
657 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
658 |
+
}
|
659 |
+
}
|
|
|
660 |
|
|
|
661 |
|
662 |
+
return $option;
|
663 |
}
|
664 |
|
665 |
+
function rtmedia_user_album_list () {
|
666 |
+
global $rtmedia_query;
|
667 |
+
$model = new RTMediaModel();
|
668 |
+
$option = rtmedia_global_album_list ();
|
669 |
+
$global_albums = rtmedia_global_albums ();
|
670 |
+
|
671 |
+
$global_album = get_site_option ( 'rtmedia-global-albums' );
|
672 |
+
$album_objects = $model->get_media ( array( 'media_author' => get_current_user_id (), 'media_type' => 'album' ), false, false );
|
673 |
+
if ( $album_objects ) {
|
674 |
+
foreach ( $album_objects as $album ) {
|
675 |
+
if ( ! in_array ( $album->id, $global_albums ) && (( isset ( $rtmedia_query->media_query[ 'album_id' ] ) && (
|
676 |
+
$album->id != $rtmedia_query->media_query[ 'album_id' ])) || ! isset ( $rtmedia_query->media_query[ 'album_id' ] )
|
677 |
+
)
|
678 |
+
)
|
|
|
|
|
679 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
680 |
}
|
681 |
}
|
682 |
|
683 |
+
if ( $option )
|
684 |
return $option;
|
685 |
else
|
686 |
return false;
|
687 |
}
|
688 |
|
689 |
+
function rtmedia_group_album_list () {
|
690 |
+
global $rtmedia_query;
|
691 |
+
$model = new RTMediaModel();
|
692 |
+
|
693 |
+
$option = rtmedia_global_album_list ();
|
694 |
+
$global_albums = rtmedia_global_albums ();
|
695 |
+
|
696 |
+
$album_objects = $model->get_media (
|
697 |
+
array(
|
698 |
+
'context' => $rtmedia_query->media_query[ 'context' ],
|
699 |
+
'context_id' => $rtmedia_query->media_query[ 'context_id' ],
|
700 |
+
'media_type' => 'album'
|
701 |
+
), false, false
|
702 |
+
);
|
703 |
+
if ( $album_objects ) {
|
704 |
+
foreach ( $album_objects as $album ) {
|
705 |
+
if ( ! in_array ( $album->id, $global_albums ) && (( isset ( $rtmedia_query->media_query[ 'album_id' ] ) && ($album->id != $rtmedia_query->media_query[ 'album_id' ])) || ! isset ( $rtmedia_query->media_query[ 'album_id' ] ) ) )
|
|
|
|
|
706 |
$option .= '<option value="' . $album->id . '">' . $album->media_title . '</option>';
|
707 |
}
|
708 |
}
|
709 |
|
710 |
+
if ( $option )
|
711 |
return $option;
|
712 |
else
|
713 |
return false;
|
714 |
}
|
715 |
|
716 |
+
add_action ( 'rtmedia_before_media_gallery', 'rtmedia_create_album' );
|
717 |
|
718 |
+
add_action ( 'rtmedia_before_album_gallery', 'rtmedia_create_album' );
|
719 |
|
720 |
+
function rtmedia_create_album () {
|
721 |
+
if ( ! is_rtmedia_album_enable () )
|
722 |
+
return;
|
|
|
|
|
723 |
global $rtmedia_query;
|
724 |
+
$user_id = get_current_user_id ();
|
725 |
+
$display = false;
|
726 |
+
if ( isset ( $rtmedia_query->query[ 'context' ] ) && in_array ( $rtmedia_query->query[ 'context' ], array( 'profile', 'group' ) ) ) {
|
727 |
+
switch ( $rtmedia_query->query[ 'context' ] ) {
|
728 |
+
case 'profile':
|
729 |
+
if ( $rtmedia_query->query[ 'context_id' ] == $user_id ) {
|
730 |
+
$display = true;
|
731 |
+
}
|
732 |
+
break;
|
733 |
+
case 'group':
|
734 |
+
$group_id = $rtmedia_query->query[ 'context_id' ];
|
735 |
+
if ( can_user_create_album_in_group () ) {
|
736 |
+
$display = true;
|
737 |
+
}
|
738 |
+
break;
|
739 |
+
}
|
740 |
+
}
|
741 |
+
if ( $display === true ) {
|
742 |
+
?>
|
743 |
+
<button type="button" class="button rtmedia-create-new-album-button"> Create New Album </button>
|
744 |
+
<div class="rtmedia-create-new-album-container">
|
745 |
+
<input type="text" id="rtmedia_album_name" value="" />
|
746 |
+
<input type="hidden" id="rtmedia_album_context" value="<?php echo $rtmedia_query->query[ 'context' ]; ?>">
|
747 |
+
<input type="hidden" id="rtmedia_album_context_id" value="<?php echo $rtmedia_query->query[ 'context_id' ]; ?>">
|
748 |
+
<button type="button" id="rtmedia_create_new_album">Create Album</button>
|
749 |
+
</div><?php
|
750 |
+
}
|
|
|
|
|
751 |
}
|
752 |
|
753 |
+
add_action ( 'rtmedia_before_media_gallery', 'rtmedia_album_edit' );
|
754 |
|
755 |
+
function rtmedia_album_edit () {
|
756 |
|
757 |
+
if ( ! is_rtmedia_album () || ! is_user_logged_in () )
|
758 |
+
return;
|
759 |
+
if ( ! is_rtmedia_album_enable () )
|
760 |
return;
|
|
|
|
|
761 |
global $rtmedia_query;
|
762 |
+
//var_dump($rtmedia_query);
|
763 |
+
if ( isset ( $rtmedia_query->media_query ) && ! in_array ( $rtmedia_query->media_query[ 'album_id' ], get_site_option ( 'rtmedia-global-albums' ) ) ) {
|
764 |
+
if ( isset ( $rtmedia_query->media_query[ 'media_author' ] ) && get_current_user_id () == $rtmedia_query->media_query[ 'media_author' ] ) {
|
765 |
+
?>
|
766 |
+
<a class="alignleft" href="edit/"><input type="button" class="button rtmedia-edit" value="<?php _e ( 'Edit', 'rtmedia' ); ?>" /></a>
|
767 |
+
<form method="post" class="album-delete-form alignleft" action="delete/">
|
768 |
+
<?php wp_nonce_field ( 'rtmedia_delete_album_' . $rtmedia_query->media_query[ 'album_id' ], 'rtmedia_delete_album_nonce' ); ?>
|
769 |
+
<input type="submit" name="album-delete" value="<?php _e ( 'Delete', 'rtmedia' ); ?>" />
|
770 |
+
</form>
|
771 |
+
<?php if ( $album_list = rtmedia_user_album_list () ) { ?>
|
772 |
+
<input type="button" class="button rtmedia-merge" value="<?php _e ( 'Merge', 'rtmedia' ); ?>" />
|
|
|
|
|
773 |
<div class="rtmedia-merge-container">
|
774 |
+
<?php _e ( 'Merge to', 'rtmedia' ); ?>
|
775 |
<form method="post" class="album-merge-form" action="merge/">
|
776 |
<?php echo '<select name="album" class="rtmedia-merge-user-album-list">' . $album_list . '</select>'; ?>
|
777 |
+
<?php wp_nonce_field ( 'rtmedia_merge_album_' . $rtmedia_query->media_query[ 'album_id' ], 'rtmedia_merge_album_nonce' ); ?>
|
778 |
+
<input type="submit" class="rtmedia-move-selected" name="merge-album" value="<?php _e ( 'Merge Album', 'rtmedia' ); ?>" />
|
779 |
</form>
|
780 |
</div>
|
781 |
<?php
|
782 |
}
|
783 |
+
}
|
784 |
+
}
|
785 |
}
|
786 |
|
787 |
+
add_action ( 'rtmedia_before_item', 'rtmedia_item_select' );
|
788 |
|
789 |
+
function rtmedia_item_select () {
|
790 |
global $rtmedia_query, $rtmedia_backbone;
|
791 |
+
if ( $rtmedia_backbone[ 'backbone' ] ) {
|
792 |
+
if ( $rtmedia_backbone[ 'is_album' ] && $rtmedia_backbone[ 'is_edit_allowed' ] )
|
793 |
echo '<input type="checkbox" name="move[]" value="<%= id %>" />';
|
794 |
+
} else if ( is_rtmedia_album () && isset ( $rtmedia_query->media_query ) && $rtmedia_query->action_query->action == 'edit' ) {
|
795 |
+
if ( isset ( $rtmedia_query->media_query[ 'media_author' ] ) && get_current_user_id () == $rtmedia_query->media_query[ 'media_author' ] )
|
796 |
+
echo '<input type="checkbox" name="selected[]" value="' . rtmedia_id () . '" />';
|
|
|
797 |
}
|
798 |
}
|
799 |
|
800 |
+
add_action ( 'rtmedia_query_actions', 'rtmedia_album_merge_action' );
|
801 |
|
802 |
+
function rtmedia_album_merge_action ( $actions ) {
|
803 |
+
$actions[ 'merge' ] = __ ( 'Merge', 'rtmedia' );
|
804 |
return $actions;
|
805 |
}
|
806 |
|
807 |
+
function rtmedia_sub_nav () {
|
808 |
+
global $rtMediaNav;
|
809 |
+
$rtMediaNav = new RTMediaNav();
|
810 |
+
$rtMediaNav->sub_nav ();
|
811 |
}
|
812 |
|
813 |
+
function is_rtmedia_album_enable () {
|
814 |
global $rtmedia;
|
815 |
+
if ( isset ( $rtmedia->options[ "general_enableAlbums" ] ) && $rtmedia->options[ "general_enableAlbums" ] != "0" ) {
|
816 |
return true;
|
817 |
}
|
818 |
return false;
|
819 |
}
|
820 |
|
821 |
+
function rtmedia_load_template () {
|
822 |
+
do_action ( "rtmedia_before_template_load" );
|
823 |
+
include(RTMediaTemplate::locate_template ());
|
824 |
+
do_action ( "rtmedia_after_template_load" );
|
825 |
}
|
826 |
|
827 |
+
function is_rtmedia_privacy_enable () {
|
828 |
global $rtmedia;
|
829 |
+
if ( isset ( $rtmedia->options[ "privacy_enabled" ] ) && $rtmedia->options[ "privacy_enabled" ] != "0" ) {
|
830 |
return true;
|
831 |
}
|
832 |
return false;
|
833 |
}
|
834 |
|
835 |
+
function is_rtmedia_privacy_user_overide () {
|
836 |
global $rtmedia;
|
837 |
+
if ( isset ( $rtmedia->options[ "privacy_userOverride" ] ) && $rtmedia->options[ "privacy_userOverride" ] != "0" ) {
|
838 |
return true;
|
839 |
}
|
840 |
return false;
|
841 |
}
|
842 |
|
843 |
+
function get_rtmedia_default_privacy () {
|
844 |
+
|
845 |
global $rtmedia;
|
846 |
+
if ( isset ( $rtmedia->options[ "privacy_default" ] ) ) {
|
847 |
+
return $rtmedia->options[ "privacy_default" ];
|
848 |
}
|
849 |
return 0;
|
850 |
}
|
851 |
|
852 |
+
function is_rtmedia_group_media_enable () {
|
853 |
global $rtmedia;
|
854 |
+
if ( isset ( $rtmedia->options[ "buddypress_enableOnGroup" ] ) && $rtmedia->options[ "buddypress_enableOnGroup" ] != "0" ) {
|
855 |
return true;
|
856 |
}
|
857 |
return false;
|
858 |
}
|
859 |
+
|
860 |
+
function can_user_upload_in_group () {
|
861 |
+
$group = groups_get_current_group ();
|
862 |
+
$upload_level = groups_get_groupmeta ( $group->id, "rt_upload_media_control_level" );
|
863 |
+
$user_id = get_current_user_id ();
|
864 |
$display_flag = false;
|
865 |
+
if ( groups_is_user_member ( $user_id, $group->id ) ) {
|
866 |
// if ($upload_level == "admin") {
|
867 |
// if (groups_is_user_admin($user_id, $group->id)) {
|
868 |
// $display_flag = true;
|
878 |
}
|
879 |
return $display_flag;
|
880 |
}
|
881 |
+
|
882 |
+
/**
|
883 |
+
*
|
884 |
+
* @param type $group_id
|
885 |
+
* @param type $user_id
|
886 |
+
* @return boolean
|
887 |
+
*/
|
888 |
+
function can_user_create_album_in_group ( $group_id = false, $user_id = false ) {
|
889 |
+
if ( $group_id == false ) {
|
890 |
+
$group = groups_get_current_group ();
|
891 |
+
$group_id = $group->id;
|
892 |
+
}
|
893 |
+
$upload_level = groups_get_groupmeta ( $group_id, "rt_media_group_control_level" );
|
894 |
+
if ( empty ( $upload_level ) ) {
|
895 |
+
$upload_level = groups_get_groupmeta ( $group_id, "bp_media_group_control_level" );
|
896 |
+
if ( empty ( $upload_level ) ) {
|
897 |
$upload_level = "all";
|
898 |
}
|
899 |
}
|
900 |
+
$user_id = get_current_user_id ();
|
901 |
$display_flag = false;
|
902 |
+
if ( groups_is_user_member ( $user_id, $group_id ) ) {
|
903 |
+
if ( $upload_level == "admin" ) {
|
904 |
+
if ( groups_is_user_admin ( $user_id, $group_id ) > 0 ) {
|
905 |
$display_flag = true;
|
906 |
}
|
907 |
+
} else if ( $upload_level == "moderators" ) {
|
908 |
+
if ( groups_is_user_mod ( $user_id, $group_id ) ) {
|
909 |
$display_flag = true;
|
910 |
}
|
911 |
} else {
|
913 |
}
|
914 |
}
|
915 |
return $display_flag;
|
916 |
+
}
|
917 |
+
|
918 |
+
function is_rtmedia_upload_video_enabled () {
|
919 |
+
global $rtmedia;
|
920 |
+
if ( isset ( $rtmedia->options[ "allowedTypes_video_enabled" ] ) && $rtmedia->options[ "allowedTypes_video_enabled" ] != "0" ) {
|
921 |
+
return true;
|
922 |
+
}
|
923 |
+
return false;
|
924 |
+
}
|
925 |
+
|
926 |
+
function is_rtmedia_upload_photo_enabled () {
|
927 |
+
global $rtmedia;
|
928 |
+
if ( isset ( $rtmedia->options[ "allowedTypes_photo_enabled" ] ) && $rtmedia->options[ "allowedTypes_photo_enabled" ] != "0" ) {
|
929 |
+
return true;
|
930 |
+
}
|
931 |
+
return false;
|
932 |
+
}
|
933 |
+
|
934 |
+
function is_rtmedia_upload_music_enabled () {
|
935 |
+
global $rtmedia;
|
936 |
+
if ( isset ( $rtmedia->options[ "allowedTypes_music_enabled" ] ) && $rtmedia->options[ "allowedTypes_music_enabled" ] != "0" ) {
|
937 |
+
return true;
|
938 |
+
}
|
939 |
+
return false;
|
940 |
+
}
|
941 |
+
|
942 |
+
function get_rtmedia_allowed_upload_type () {
|
943 |
+
global $rtmedia;
|
944 |
+
$allow_type_str = "";
|
945 |
+
$sep = "";
|
946 |
+
foreach ( $rtmedia->allowed_types as $type ) {
|
947 |
+
if ( call_user_func ( "is_rtmedia_upload_" . $type[ "name" ] . "_enabled" ) ) {
|
948 |
+
foreach ( $type[ "extn" ] as $extn ) {
|
949 |
+
$allow_type_str .= $sep . $extn;
|
950 |
+
$sep = ",";
|
951 |
+
}
|
952 |
+
}
|
953 |
+
}
|
954 |
+
return $allow_type_str;
|
955 |
+
}
|
956 |
+
|
app/main/controllers/upload/RTMediaUploadEndpoint.php
CHANGED
@@ -7,74 +7,81 @@
|
|
7 |
*/
|
8 |
class RTMediaUploadEndpoint {
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
public function __construct() {
|
16 |
-
add_action('rtmedia_upload_redirect', array($this, 'template_redirect'));
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
function template_redirect() {
|
23 |
-
|
24 |
-
if (!count($_POST)) {
|
25 |
-
include get_404_template();
|
26 |
} else {
|
27 |
-
$nonce = $_REQUEST['rtmedia_upload_nonce'];
|
28 |
-
$mode = $_REQUEST['mode'];
|
29 |
-
$rtupload =false;
|
30 |
$activity_id = -1;
|
31 |
-
if (wp_verify_nonce($nonce, 'rtmedia_upload_nonce')) {
|
32 |
$model = new RTMediaUploadModel();
|
33 |
-
$this->upload = $model->set_post_object();
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$rtupload = new RTMediaUpload($this->upload);
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
-
if(isset($_POST["redirect"]) && $_POST["redirect"]=="no" ){
|
61 |
// Ha ha ha
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
//wp_safe_redirect(wp_get_referer());
|
74 |
}
|
75 |
}
|
76 |
|
77 |
-
die();
|
78 |
}
|
79 |
|
80 |
}
|
7 |
*/
|
8 |
class RTMediaUploadEndpoint {
|
9 |
|
10 |
+
public $upload;
|
11 |
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function __construct () {
|
16 |
+
add_action ( 'rtmedia_upload_redirect', array( $this, 'template_redirect' ) );
|
17 |
}
|
18 |
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
function template_redirect () {
|
23 |
+
ob_start ();
|
24 |
+
if ( ! count ( $_POST ) ) {
|
25 |
+
include get_404_template ();
|
26 |
} else {
|
27 |
+
$nonce = $_REQUEST[ 'rtmedia_upload_nonce' ];
|
28 |
+
$mode = $_REQUEST[ 'mode' ];
|
29 |
+
$rtupload = false;
|
30 |
$activity_id = -1;
|
31 |
+
if ( wp_verify_nonce ( $nonce, 'rtmedia_upload_nonce' ) ) {
|
32 |
$model = new RTMediaUploadModel();
|
33 |
+
$this->upload = $model->set_post_object ();
|
34 |
+
if ( isset ( $_POST[ 'activity_id' ] ) && $_POST[ 'activity_id' ] != -1 ) {
|
35 |
+
$this->upload[ 'activity_id' ] = $_POST[ 'activity_id' ];
|
36 |
+
$activity_id = $_POST[ 'activity_id' ];
|
37 |
+
}
|
38 |
+
$rtupload = new RTMediaUpload ( $this->upload );
|
39 |
+
$mediaObj = new RTMediaMedia();
|
40 |
+
$media = $mediaObj->model->get ( array( 'id' => $rtupload->media_ids[ 0 ] ) );
|
41 |
+
$rtMediaNav = new RTMediaNav();
|
42 |
+
if ( $media[ 0 ]->context == "group" ) {
|
43 |
+
$rtMediaNav->refresh_counts ( $media[ 0 ]->context_id, array( "context" => $media[ 0 ]->context, 'context_id' => $media[ 0 ]->context_id ) );
|
44 |
+
} else {
|
45 |
+
$rtMediaNav->refresh_counts ( $media[ 0 ]->media_author, array( "context" => "profile", 'media_author' => $media[ 0 ]->media_author ) );
|
46 |
+
}
|
47 |
+
if ( $activity_id == -1 && ( ! (isset ( $_POST[ "rtmedia_update" ] ) && $_POST[ "rtmedia_update" ] == "true")) ) {
|
48 |
+
$activity_id = $mediaObj->insert_activity ( $rtupload->media_ids[ 0 ], $media[ 0 ] );
|
49 |
+
} else {
|
50 |
+
$mediaObj->model->update ( array( 'activity_id' => $activity_id ), array( 'id' => $rtupload->media_ids[ 0 ] ) );
|
51 |
+
$same_medias = $mediaObj->model->get ( array( 'activity_id' => $activity_id ) );
|
52 |
+
|
53 |
+
$update_activity_media = Array( );
|
54 |
+
foreach ( $same_medias as $a_media ) {
|
55 |
+
$update_activity_media[ ] = $a_media->id;
|
56 |
+
}
|
57 |
+
$privacy = 0;
|
58 |
+
if ( isset ( $_POST[ "privacy" ] ) ) {
|
59 |
+
$privacy = $_POST[ "privacy" ];
|
60 |
+
}
|
61 |
+
$objActivity = new RTMediaActivity ( $update_activity_media, $privacy, false );
|
62 |
+
global $wpdb, $bp;
|
63 |
+
$wpdb->update ( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html () ), array( "id" => $activity_id ) );
|
64 |
+
}
|
65 |
}
|
66 |
+
if ( isset ( $_POST[ "redirect" ] ) && $_POST[ "redirect" ] == "no" ) {
|
67 |
// Ha ha ha
|
68 |
+
ob_end_clean ();
|
69 |
+
if ( isset ( $_POST[ "rtmedia_update" ] ) && $_POST[ "rtmedia_update" ] == "true" ) {
|
70 |
+
header ( 'Content-type: application/json' );
|
71 |
+
echo json_encode ( $rtupload->media_ids );
|
72 |
+
} else {
|
73 |
+
// Media Upload Case - on album/post/profile/group
|
74 |
+
$data = array( 'activity_id' => $activity_id );
|
75 |
+
header ( 'Content-type: application/json' );
|
76 |
+
echo json_encode ( $data );
|
77 |
+
}
|
78 |
+
die ();
|
79 |
+
} else {
|
80 |
//wp_safe_redirect(wp_get_referer());
|
81 |
}
|
82 |
}
|
83 |
|
84 |
+
die ();
|
85 |
}
|
86 |
|
87 |
}
|
app/main/controllers/upload/RTMediaUploadModel.php
CHANGED
@@ -12,8 +12,8 @@ class RTMediaUploadModel {
|
|
12 |
'context' => false,
|
13 |
'context_id' => false,
|
14 |
'privacy' => 0,
|
15 |
-
'custom_fields' => array(),
|
16 |
-
'taxonomy' => array(),
|
17 |
'album_id' => false,
|
18 |
'files' => false,
|
19 |
'title' => false,
|
@@ -25,9 +25,9 @@ class RTMediaUploadModel {
|
|
25 |
*
|
26 |
* @return type
|
27 |
*/
|
28 |
-
function set_post_object() {
|
29 |
-
$this->upload = wp_parse_args($_POST, $this->upload);
|
30 |
-
$this->sanitize_object();
|
31 |
return $this->upload;
|
32 |
}
|
33 |
|
@@ -35,8 +35,8 @@ class RTMediaUploadModel {
|
|
35 |
*
|
36 |
* @return boolean
|
37 |
*/
|
38 |
-
function has_context() {
|
39 |
-
if (isset($this->upload['context_id']) && !empty($this->upload['context_id']))
|
40 |
return true;
|
41 |
return false;
|
42 |
}
|
@@ -45,60 +45,59 @@ class RTMediaUploadModel {
|
|
45 |
*
|
46 |
* @global type $rtmedia_interaction
|
47 |
*/
|
48 |
-
function sanitize_object() {
|
49 |
-
if (
|
50 |
|
51 |
global $rtmedia_interaction;
|
52 |
|
53 |
-
$this->upload['context'] = $rtmedia_interaction->context->type;
|
54 |
-
$this->upload['context_id'] = $rtmedia_interaction->context->id;
|
55 |
}
|
56 |
|
57 |
-
if (!is_array($this->upload['taxonomy']))
|
58 |
-
$this->upload['taxonomy'] = array($this->upload['taxonomy']);
|
59 |
|
60 |
-
if (!is_array($this->upload['custom_fields']))
|
61 |
-
$this->upload['custom_fields'] = array($this->upload['custom_fields']);
|
62 |
|
63 |
-
if (
|
64 |
-
$this->set_album_id();
|
65 |
|
66 |
-
if (
|
67 |
-
$this->set_author();
|
68 |
-
if(is_rtmedia_privacy_enable()){
|
69 |
-
if(is_rtmedia_privacy_user_overide()){
|
70 |
-
if(!isset($_POST["privacy"])){
|
71 |
-
$this->upload['privacy'] = get_rtmedia_default_privacy();
|
72 |
-
}else{
|
73 |
-
$this->upload['privacy'] = $_POST["privacy"];
|
74 |
}
|
75 |
-
}else{
|
76 |
-
$this->upload['privacy'] = get_rtmedia_default_privacy();
|
77 |
}
|
78 |
-
}else{
|
79 |
-
$this->upload['privacy'] = 0;
|
80 |
}
|
81 |
-
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
*
|
86 |
* @return type
|
87 |
*/
|
88 |
-
function has_author() {
|
89 |
-
return $this->upload['media_author'];
|
90 |
}
|
91 |
|
92 |
-
function set_author() {
|
93 |
-
$this->upload['media_author'] = get_current_user_id();
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
*
|
98 |
* @return boolean
|
99 |
*/
|
100 |
-
function has_album_id() {
|
101 |
-
if (
|
102 |
return false;
|
103 |
return true;
|
104 |
}
|
@@ -107,7 +106,7 @@ class RTMediaUploadModel {
|
|
107 |
*
|
108 |
* @return boolean
|
109 |
*/
|
110 |
-
function has_album_permissions() {
|
111 |
//yet to be coded for the privacy options of the album
|
112 |
return true;
|
113 |
}
|
@@ -117,29 +116,29 @@ class RTMediaUploadModel {
|
|
117 |
* @param type $id
|
118 |
* @return boolean
|
119 |
*/
|
120 |
-
function album_id_exists($id) {
|
121 |
return true;
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
*
|
126 |
*/
|
127 |
-
function set_album_id() {
|
128 |
-
if (class_exists('BuddyPress')) {
|
129 |
-
$this->set_bp_album_id();
|
130 |
} else {
|
131 |
-
$this->set_wp_album_id();
|
132 |
}
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
*
|
137 |
*/
|
138 |
-
function set_bp_album_id() {
|
139 |
-
if (bp_is_blog_page()) {
|
140 |
-
$this->set_wp_album_id();
|
141 |
} else {
|
142 |
-
$this->set_bp_component_album_id();
|
143 |
}
|
144 |
}
|
145 |
|
@@ -147,22 +146,22 @@ class RTMediaUploadModel {
|
|
147 |
*
|
148 |
* @throws RTMediaUploadException
|
149 |
*/
|
150 |
-
function set_wp_album_id() {
|
151 |
-
if (isset($this->upload['context']))
|
152 |
-
$this->upload['album_id'] = $this->upload['context_id'];
|
153 |
else
|
154 |
-
throw new RTMediaUploadException(9); // Invalid Context
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
*
|
159 |
*/
|
160 |
-
function set_bp_component_album_id() {
|
161 |
-
switch (bp_current_component()) {
|
162 |
-
case 'groups': $this->upload['album_id'] = RTMediaAlbum::get_default();
|
163 |
break;
|
164 |
default:
|
165 |
-
$this->upload['album_id'] = RTMediaAlbum::get_default();
|
166 |
break;
|
167 |
}
|
168 |
}
|
12 |
'context' => false,
|
13 |
'context_id' => false,
|
14 |
'privacy' => 0,
|
15 |
+
'custom_fields' => array( ),
|
16 |
+
'taxonomy' => array( ),
|
17 |
'album_id' => false,
|
18 |
'files' => false,
|
19 |
'title' => false,
|
25 |
*
|
26 |
* @return type
|
27 |
*/
|
28 |
+
function set_post_object () {
|
29 |
+
$this->upload = wp_parse_args ( $_POST, $this->upload );
|
30 |
+
$this->sanitize_object ();
|
31 |
return $this->upload;
|
32 |
}
|
33 |
|
35 |
*
|
36 |
* @return boolean
|
37 |
*/
|
38 |
+
function has_context () {
|
39 |
+
if ( isset ( $this->upload[ 'context_id' ] ) && ! empty ( $this->upload[ 'context_id' ] ) )
|
40 |
return true;
|
41 |
return false;
|
42 |
}
|
45 |
*
|
46 |
* @global type $rtmedia_interaction
|
47 |
*/
|
48 |
+
function sanitize_object () {
|
49 |
+
if ( ! $this->has_context () ) {
|
50 |
|
51 |
global $rtmedia_interaction;
|
52 |
|
53 |
+
$this->upload[ 'context' ] = $rtmedia_interaction->context->type;
|
54 |
+
$this->upload[ 'context_id' ] = $rtmedia_interaction->context->id;
|
55 |
}
|
56 |
|
57 |
+
if ( ! is_array ( $this->upload[ 'taxonomy' ] ) )
|
58 |
+
$this->upload[ 'taxonomy' ] = array( $this->upload[ 'taxonomy' ] );
|
59 |
|
60 |
+
if ( ! is_array ( $this->upload[ 'custom_fields' ] ) )
|
61 |
+
$this->upload[ 'custom_fields' ] = array( $this->upload[ 'custom_fields' ] );
|
62 |
|
63 |
+
if ( ! $this->has_album_id () || ! $this->has_album_permissions () )
|
64 |
+
$this->set_album_id ();
|
65 |
|
66 |
+
if ( ! $this->has_author () )
|
67 |
+
$this->set_author ();
|
68 |
+
if ( is_rtmedia_privacy_enable () ) {
|
69 |
+
if ( is_rtmedia_privacy_user_overide () ) {
|
70 |
+
if ( ! isset ( $_POST[ "privacy" ] ) ) {
|
71 |
+
$this->upload[ 'privacy' ] = get_rtmedia_default_privacy ();
|
72 |
+
} else {
|
73 |
+
$this->upload[ 'privacy' ] = $_POST[ "privacy" ];
|
74 |
}
|
75 |
+
} else {
|
76 |
+
$this->upload[ 'privacy' ] = get_rtmedia_default_privacy ();
|
77 |
}
|
78 |
+
} else {
|
79 |
+
$this->upload[ 'privacy' ] = 0;
|
80 |
}
|
|
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
*
|
85 |
* @return type
|
86 |
*/
|
87 |
+
function has_author () {
|
88 |
+
return $this->upload[ 'media_author' ];
|
89 |
}
|
90 |
|
91 |
+
function set_author () {
|
92 |
+
$this->upload[ 'media_author' ] = get_current_user_id ();
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
*
|
97 |
* @return boolean
|
98 |
*/
|
99 |
+
function has_album_id () {
|
100 |
+
if ( ! $this->upload[ 'album_id' ] || $this->upload[ 'album_id' ] == "undefined" )
|
101 |
return false;
|
102 |
return true;
|
103 |
}
|
106 |
*
|
107 |
* @return boolean
|
108 |
*/
|
109 |
+
function has_album_permissions () {
|
110 |
//yet to be coded for the privacy options of the album
|
111 |
return true;
|
112 |
}
|
116 |
* @param type $id
|
117 |
* @return boolean
|
118 |
*/
|
119 |
+
function album_id_exists ( $id ) {
|
120 |
return true;
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
*
|
125 |
*/
|
126 |
+
function set_album_id () {
|
127 |
+
if ( class_exists ( 'BuddyPress' ) ) {
|
128 |
+
$this->set_bp_album_id ();
|
129 |
} else {
|
130 |
+
$this->set_wp_album_id ();
|
131 |
}
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
*
|
136 |
*/
|
137 |
+
function set_bp_album_id () {
|
138 |
+
if ( bp_is_blog_page () ) {
|
139 |
+
$this->set_wp_album_id ();
|
140 |
} else {
|
141 |
+
$this->set_bp_component_album_id ();
|
142 |
}
|
143 |
}
|
144 |
|
146 |
*
|
147 |
* @throws RTMediaUploadException
|
148 |
*/
|
149 |
+
function set_wp_album_id () {
|
150 |
+
if ( isset ( $this->upload[ 'context' ] ) )
|
151 |
+
$this->upload[ 'album_id' ] = $this->upload[ 'context_id' ];
|
152 |
else
|
153 |
+
throw new RTMediaUploadException ( 9 ); // Invalid Context
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
*
|
158 |
*/
|
159 |
+
function set_bp_component_album_id () {
|
160 |
+
switch ( bp_current_component () ) {
|
161 |
+
case 'groups': $this->upload[ 'album_id' ] = RTMediaAlbum::get_default ();
|
162 |
break;
|
163 |
default:
|
164 |
+
$this->upload[ 'album_id' ] = RTMediaAlbum::get_default ();
|
165 |
break;
|
166 |
}
|
167 |
}
|
app/main/controllers/upload/RTMediaUploadView.php
CHANGED
@@ -7,100 +7,102 @@
|
|
7 |
*/
|
8 |
class RTMediaUploadView {
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
*
|
14 |
-
* @param type $attr
|
15 |
-
*/
|
16 |
-
function __construct($attr) {
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$token = array(
|
30 |
-
'action' => 'rtmedia_upload_nonce',
|
31 |
-
'nonce' => wp_create_nonce('rtmedia_upload_nonce')
|
32 |
-
);
|
33 |
-
|
34 |
-
return json_encode($token);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Render the uploader shortcode and attach the uploader panel
|
40 |
-
*
|
41 |
-
* @param type $template_name
|
42 |
-
*/
|
43 |
-
public function render($template_name) {
|
44 |
global $rtmedia_query;
|
45 |
$album = '';
|
46 |
-
if ( $rtmedia_query && is_rtmedia_album()){
|
47 |
-
$album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="'
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
),
|
63 |
// 'file_upload' => array( 'title' => __('File Upload','rtmedia'), 'content' => '<div id="rtmedia-uploader"><p>Your browser does not have HTML5 support.</p></div>'),
|
64 |
-
|
65 |
);
|
66 |
-
$tabs = apply_filters('rtmedia_upload_tabs', $tabs );
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
protected function locate_template($template) {
|
87 |
$located = '';
|
88 |
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
return $located;
|
102 |
}
|
103 |
|
104 |
}
|
105 |
-
|
106 |
?>
|
7 |
*/
|
8 |
class RTMediaUploadView {
|
9 |
|
10 |
+
private $attributes;
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @param type $attr
|
15 |
+
*/
|
16 |
+
function __construct ( $attr ) {
|
17 |
+
$this->attributes = $attr;
|
18 |
+
}
|
19 |
|
20 |
+
static function upload_nonce_generator ( $echo = true, $only_nonce = false ) {
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
if ( $echo ) {
|
23 |
+
wp_nonce_field ( 'rtmedia_upload_nonce', 'rtmedia_upload_nonce' );
|
24 |
+
} else {
|
25 |
+
if ( $only_nonce )
|
26 |
+
return wp_create_nonce ( 'rtmedia_upload_nonce' );
|
27 |
+
$token = array(
|
28 |
+
'action' => 'rtmedia_upload_nonce',
|
29 |
+
'nonce' => wp_create_nonce ( 'rtmedia_upload_nonce' )
|
30 |
+
);
|
31 |
|
32 |
+
return json_encode ( $token );
|
33 |
+
}
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* Render the uploader shortcode and attach the uploader panel
|
38 |
+
*
|
39 |
+
* @param type $template_name
|
40 |
+
*/
|
41 |
+
public function render ( $template_name ) {
|
42 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
global $rtmedia_query;
|
44 |
$album = '';
|
45 |
+
if ( $rtmedia_query && is_rtmedia_album () ) {
|
46 |
+
$album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query[ 'album_id' ] . '" />';
|
47 |
+
} elseif ( is_rtmedia_album_enable () && $rtmedia_query && is_rtmedia_gallery () ) {
|
48 |
+
|
49 |
+
if ( $rtmedia_query->query[ 'context' ] == 'profile' ) {
|
50 |
+
$album = '<select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list () . '</select>';
|
51 |
+
}
|
52 |
+
if ( $rtmedia_query->query[ 'context' ] == 'group' ) {
|
53 |
+
$album = '<select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list () . '</select>';
|
54 |
+
}
|
55 |
+
}
|
56 |
+
$tabs = array(
|
57 |
+
'file_upload' => array(
|
58 |
+
'default' => array( 'title' => __ ( 'File Upload', 'rtmedia' ), 'content' => '<div id="rtmedia-upload-container" ><div id="drag-drop-area" class="drag-drop">' . $album . '<input id="rtMedia-upload-button" value="Select" type="button" class="rtmedia-upload-input rtmedia-file" /></div><table id="rtMedia-queue-list"><tbody></tbody></table></div>' ),
|
59 |
+
'activity' => array( 'title' => __ ( 'File Upload', 'rtmedia' ), 'content' => '<div class="rtmedia-container"><div id="rtmedia-action-update"><input type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update" value="' . __ ( "Add Media", "rtmedia" ) . '" /></div><div id="div-attache-rtmedia"><div id="rtmedia-whts-new-upload-container" ><div id="rtmedia-whts-new-drag-drop-area" class="drag-drop"><input id="rtmedia-whts-new-upload-button" value="Select" type="button" class="rtmedia-upload-input rtmedia-file" /></div><div id="rtMedia-update-queue-list"></div></div></div></div>' )
|
60 |
+
),
|
|
|
61 |
// 'file_upload' => array( 'title' => __('File Upload','rtmedia'), 'content' => '<div id="rtmedia-uploader"><p>Your browser does not have HTML5 support.</p></div>'),
|
62 |
+
'link_input' => array( 'title' => __ ( 'Insert from URL', 'rtmedia' ), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />' ),
|
63 |
);
|
64 |
+
$tabs = apply_filters ( 'rtmedia_upload_tabs', $tabs );
|
65 |
+
|
66 |
+
$attr = $this->attributes;
|
67 |
+
$mode = (isset ( $_GET[ 'mode' ] ) && array_key_exists ( $_GET[ 'mode' ], $tabs )) ? $_GET[ 'mode' ] : 'file_upload';
|
68 |
+
if ( $attr && is_array ( $attr ) ) {
|
69 |
+
foreach ( $attr as $key => $val ) {
|
70 |
+
?>
|
71 |
+
<input type='hidden' value='<?php echo $val; ?>' name ='<?php echo $key; ?>' />
|
72 |
+
<?php
|
73 |
+
}
|
74 |
+
}
|
75 |
+
$upload_type = 'default';
|
76 |
+
if ( isset ( $attr[ 'activity' ] ) && $attr[ 'activity' ] )
|
77 |
+
$upload_type = 'activity';
|
78 |
+
|
79 |
+
$uploadHelper = new RTMediaUploadHelper();
|
80 |
+
include $this->locate_template ( $template_name );
|
81 |
}
|
82 |
|
83 |
+
/**
|
84 |
+
* Template Locator
|
85 |
+
*
|
86 |
+
* @param type $template
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
protected function locate_template ( $template ) {
|
90 |
$located = '';
|
91 |
|
92 |
+
$template_name = $template . '.php';
|
93 |
|
94 |
+
if ( ! $template_name )
|
95 |
+
$located = false;
|
96 |
+
if ( file_exists ( STYLESHEETPATH . '/rtmedia/upload/' . $template_name ) ) {
|
97 |
+
$located = STYLESHEETPATH . '/rtmedia/upload/' . $template_name;
|
98 |
+
} else if ( file_exists ( TEMPLATEPATH . '/rtmedia/upload/' . $template_name ) ) {
|
99 |
+
$located = TEMPLATEPATH . '/rtmedia/upload/' . $template_name;
|
100 |
+
} else {
|
101 |
+
$located = RTMEDIA_PATH . 'templates/upload/' . $template_name;
|
102 |
+
}
|
103 |
|
104 |
return $located;
|
105 |
}
|
106 |
|
107 |
}
|
|
|
108 |
?>
|
app/main/controllers/upload/processors/RTMediaUploadFile.php
CHANGED
@@ -12,7 +12,7 @@ class RTMediaUploadFile {
|
|
12 |
var $fake = false;
|
13 |
var $uploaded = false;
|
14 |
|
15 |
-
function __construct($uploaded) {
|
16 |
$this->uploaded = $uploaded;
|
17 |
}
|
18 |
|
@@ -22,41 +22,41 @@ class RTMediaUploadFile {
|
|
22 |
* @param type $files
|
23 |
* @return type
|
24 |
*/
|
25 |
-
function init($files) {
|
26 |
|
27 |
-
$this->set_file($files);
|
28 |
-
$this->unset_invalid_files();
|
29 |
-
$uploaded_file = $this->process();
|
30 |
return $uploaded_file;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* core process of upload
|
35 |
*/
|
36 |
-
function process() {
|
37 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
38 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
39 |
|
40 |
$upload_type = $this->fake ? 'wp_handle_sideload' : 'wp_handle_upload';
|
41 |
|
42 |
-
add_filter('upload_dir', array($this, 'upload_dir'));
|
43 |
-
foreach ($this->files as $key => $file) {
|
44 |
|
45 |
-
$uploaded_file[] = $upload_type($file, array('test_form' => false));
|
46 |
try {
|
47 |
-
if (isset($uploaded_file[$key]['error']) || $uploaded_file[$key] === null) {
|
48 |
-
array_pop($uploaded_file);
|
49 |
|
50 |
-
throw new RTMediaUploadException(0, __('Error Uploading File', 'rtmedia'));
|
51 |
}
|
52 |
-
$uploaded_file[$key]['name'] = $file['name'];
|
53 |
-
} catch (RTMediaUploadException $e) {
|
54 |
-
echo $e->getMessage();
|
55 |
}
|
56 |
|
57 |
-
if (strpos($file['type'], 'image') !== false) {
|
58 |
-
if (function_exists('read_exif_data')) {
|
59 |
-
$file = $this->exif($uploaded_file[$key]);
|
60 |
}
|
61 |
}
|
62 |
}
|
@@ -64,20 +64,20 @@ class RTMediaUploadFile {
|
|
64 |
return $uploaded_file;
|
65 |
}
|
66 |
|
67 |
-
function upload_dir($upload_dir) {
|
68 |
global $rtmedia_interaction;
|
69 |
-
if (isset($this->uploaded["context"]) && isset($this->uploaded["context_id"])) {
|
70 |
-
if ($this->uploaded["context"] != 'group') {
|
71 |
$rtmedia_upload_prefix = 'users/';
|
72 |
-
$id = get_current_user_id();
|
73 |
} else {
|
74 |
$rtmedia_upload_prefix = 'groups/';
|
75 |
-
$id = $this->uploaded["context_id"];
|
76 |
}
|
77 |
} else {
|
78 |
-
if ($rtmedia_interaction->context->type != 'group') {
|
79 |
$rtmedia_upload_prefix = 'users/';
|
80 |
-
$id = get_current_user_id();
|
81 |
} else {
|
82 |
$rtmedia_upload_prefix = 'groups/';
|
83 |
$id = $rtmedia_interaction->context->id;
|
@@ -85,35 +85,35 @@ class RTMediaUploadFile {
|
|
85 |
}
|
86 |
|
87 |
|
88 |
-
$upload_dir['path'] = trailingslashit(
|
89 |
-
str_replace($upload_dir['subdir'], '', $upload_dir['path']))
|
90 |
. 'rtMedia/' . $rtmedia_upload_prefix . $id .
|
91 |
-
$upload_dir['subdir'];
|
92 |
-
$upload_dir['url'] = trailingslashit(
|
93 |
-
str_replace($upload_dir['subdir'], '', $upload_dir['url']))
|
94 |
. 'rtMedia/' . $rtmedia_upload_prefix . $id
|
95 |
-
. $upload_dir['subdir'];
|
96 |
|
97 |
return $upload_dir;
|
98 |
}
|
99 |
|
100 |
-
function set_file($files) {
|
101 |
/**
|
102 |
* if files parameter is provided then take th file details from that object
|
103 |
*/
|
104 |
-
if ($files) {
|
105 |
$this->fake = true;
|
106 |
-
$this->populate_file_array((array) $uploaded['files']);
|
107 |
/**
|
108 |
* otherwise check for $_FILES global object from the form submitted
|
109 |
*/
|
110 |
-
} elseif (isset($_FILES['rtmedia_file'])) {
|
111 |
-
$this->populate_file_array($_FILES['rtmedia_file']);
|
112 |
} else {
|
113 |
/**
|
114 |
* No files could be found to upload
|
115 |
*/
|
116 |
-
throw new RTMediaUploadException(UPLOAD_ERR_NO_FILE);
|
117 |
}
|
118 |
}
|
119 |
|
@@ -121,13 +121,13 @@ class RTMediaUploadFile {
|
|
121 |
* gather the file information for upload process
|
122 |
* @param type $file_array
|
123 |
*/
|
124 |
-
function populate_file_array($file_array) {
|
125 |
-
$this->files[] = array(
|
126 |
-
'name' => isset($file_array['name']) ? $file_array['name'] : '',
|
127 |
-
'type' => isset($file_array['type']) ? $file_array['type'] : '',
|
128 |
-
'tmp_name' => isset($file_array['tmp_name']) ? $file_array['tmp_name'] : '',
|
129 |
-
'error' => isset($file_array['error']) ? $file_array['error'] : '',
|
130 |
-
'size' => isset($file_array['size']) ? $file_array['size'] : 0,
|
131 |
);
|
132 |
}
|
133 |
|
@@ -138,27 +138,30 @@ class RTMediaUploadFile {
|
|
138 |
* @return boolean
|
139 |
* @throws RTMediaUploadException
|
140 |
*/
|
141 |
-
function is_valid_type($file) {
|
142 |
try {
|
143 |
global $rtmedia;
|
144 |
-
$allowed_types = array();
|
145 |
-
$rtmedia->allowed_types = apply_filters('rtmedia_allowed_types', $rtmedia->allowed_types);
|
146 |
-
foreach ($rtmedia->allowed_types as $type) {
|
147 |
-
|
148 |
-
$
|
|
|
|
|
149 |
}
|
150 |
}
|
151 |
-
$file_data = wp_check_filetype($file['name']);
|
152 |
-
$allowed_types = apply_filters('rtmedia_plupload_files_filter', array(array('title' => "Media Files", 'extensions' => implode(",", $allowed_types))));
|
153 |
-
$allowed_types = explode(",", $allowed_types[0]["extensions"]);
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
157 |
}
|
158 |
}
|
159 |
// $is_valid = $this->id3_validate_type($file);
|
160 |
-
} catch (RTMediaUploadException $e) {
|
161 |
-
echo $e->getMessage();
|
162 |
return false;
|
163 |
}
|
164 |
return true;
|
@@ -167,137 +170,137 @@ class RTMediaUploadFile {
|
|
167 |
/**
|
168 |
* Remove invalid files
|
169 |
*/
|
170 |
-
function unset_invalid_files() {
|
171 |
$temp_array = $this->files;
|
172 |
$this->files = null;
|
173 |
-
foreach ($temp_array as $key => $file) {
|
174 |
-
if (apply_filters('rtmedia_valid_type_check', $this->is_valid_type($file), $file)) {
|
175 |
-
$this->files[] = $file;
|
176 |
}
|
177 |
}
|
178 |
}
|
179 |
|
180 |
-
function id3_validate_type($file) {
|
181 |
-
$file_type = explode('/', $file['type']);
|
182 |
-
$type = $file_type[0];
|
183 |
-
switch ($type) {
|
184 |
case 'video' :
|
185 |
-
include_once(trailingslashit(RTMEDIA_PATH) . 'lib/getid3/getid3.php');
|
186 |
try {
|
187 |
$getID3 = new getID3;
|
188 |
-
$vid_info = $getID3->analyze($file['tmp_name']);
|
189 |
-
} catch (Exception $e) {
|
190 |
-
$this->safe_unlink($file['tmp_name']);
|
191 |
$activity_content = false;
|
192 |
-
throw new RTMediaUploadException(0, __('MP4 file you have uploaded is corrupt.', 'buddypress-media'));
|
193 |
}
|
194 |
-
if (is_array($vid_info)) {
|
195 |
-
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'])) {
|
196 |
-
if (!($vid_info['fileformat'] == 'mp4' && $vid_info['video']['fourcc'] == 'avc1')) {
|
197 |
-
$this->safe_unlink($file['tmp_name']);
|
198 |
$activity_content = false;
|
199 |
-
throw new RTMediaUploadException(0, __('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'buddypress-media'));
|
200 |
}
|
201 |
} else {
|
202 |
-
$this->safe_unlink($file['tmp_name']);
|
203 |
$activity_content = false;
|
204 |
-
throw new RTMediaUploadException(0, __('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'buddypress-media'));
|
205 |
}
|
206 |
} else {
|
207 |
-
$this->safe_unlink($file['tmp_name']);
|
208 |
$activity_content = false;
|
209 |
-
throw new RTMediaUploadException(0, __('The MP4 file you have uploaded is not a video file.', 'buddypress-media'));
|
210 |
}
|
211 |
break;
|
212 |
case 'audio' :
|
213 |
-
include_once(trailingslashit(RTMEDIA_PATH) . 'lib/getid3/getid3.php');
|
214 |
try {
|
215 |
$getID3 = new getID3;
|
216 |
-
$file_info = $getID3->analyze($file['tmp_name']);
|
217 |
-
} catch (Exception $e) {
|
218 |
-
$this->safe_unlink($file['tmp_name']);
|
219 |
$activity_content = false;
|
220 |
-
throw new RTMediaUploadException(0, __('MP3 file you have uploaded is currupt.', 'buddypress-media'));
|
221 |
}
|
222 |
-
if (is_array($file_info)) {
|
223 |
-
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'])) {
|
224 |
-
if (!($file_info['fileformat'] == 'mp3' && $file_info['audio']['dataformat'] == 'mp3')) {
|
225 |
-
$this->safe_unlink($file['tmp_name']);
|
226 |
$activity_content = false;
|
227 |
-
throw new RTMediaUploadException(0, __('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'buddypress-media'));
|
228 |
}
|
229 |
} else {
|
230 |
-
$this->safe_unlink($file['tmp_name']);
|
231 |
$activity_content = false;
|
232 |
-
throw new RTMediaUploadException(0, __('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'buddypress-media'));
|
233 |
}
|
234 |
} else {
|
235 |
-
$this->safe_unlink($file['tmp_name']);
|
236 |
$activity_content = false;
|
237 |
-
throw new RTMediaUploadException(0, __('The MP3 file you have uploaded is not an audio file.', 'buddypress-media'));
|
238 |
}
|
239 |
break;
|
240 |
case 'image' :
|
241 |
break;
|
242 |
default :
|
243 |
-
$this->safe_unlink($file['tmp_name']);
|
244 |
$activity_content = false;
|
245 |
-
throw new RTMediaUploadException(0, __('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', 'buddypress-media'));
|
246 |
}
|
247 |
|
248 |
return true;
|
249 |
}
|
250 |
|
251 |
-
function safe_unlink($file_path) {
|
252 |
-
if (file_exists($file_path))
|
253 |
-
unlink($file_path);
|
254 |
}
|
255 |
|
256 |
-
function exif($file) {
|
257 |
-
$file_parts = pathinfo($file['file']);
|
258 |
-
if (in_array(strtolower($file_parts['extension']), array('jpg', 'jpeg', 'tiff'))) {
|
259 |
-
$exif = read_exif_data($file['file']);
|
260 |
-
$exif_orient = isset($exif['Orientation']) ? $exif['Orientation'] : 0;
|
261 |
$rotateImage = 0;
|
262 |
|
263 |
-
if (6 == $exif_orient) {
|
264 |
$rotateImage = 90;
|
265 |
$imageOrientation = 1;
|
266 |
-
} elseif (3 == $exif_orient) {
|
267 |
$rotateImage = 180;
|
268 |
$imageOrientation = 1;
|
269 |
-
} elseif (8 == $exif_orient) {
|
270 |
$rotateImage = 270;
|
271 |
$imageOrientation = 1;
|
272 |
}
|
273 |
|
274 |
-
if ($rotateImage) {
|
275 |
-
if (class_exists('Imagick')) {
|
276 |
$imagick = new Imagick();
|
277 |
-
$imagick->readImage($file['file']);
|
278 |
-
$imagick->rotateImage(new ImagickPixel(), $rotateImage);
|
279 |
-
$imagick->setImageOrientation($imageOrientation);
|
280 |
-
$imagick->writeImage($file['file']);
|
281 |
-
$imagick->clear();
|
282 |
-
$imagick->destroy();
|
283 |
} else {
|
284 |
$rotateImage = -$rotateImage;
|
285 |
|
286 |
-
switch ($file['type']) {
|
287 |
case 'image/jpeg':
|
288 |
-
$source = imagecreatefromjpeg($file['file']);
|
289 |
-
$rotate = imagerotate($source, $rotateImage, 0);
|
290 |
-
imagejpeg($rotate, $file['file']);
|
291 |
break;
|
292 |
case 'image/png':
|
293 |
-
$source = imagecreatefrompng($file['file']);
|
294 |
-
$rotate = imagerotate($source, $rotateImage, 0);
|
295 |
-
imagepng($rotate, $file['file']);
|
296 |
break;
|
297 |
case 'image/gif':
|
298 |
-
$source = imagecreatefromgif($file['file']);
|
299 |
-
$rotate = imagerotate($source, $rotateImage, 0);
|
300 |
-
imagegif($rotate, $file['file']);
|
301 |
break;
|
302 |
default:
|
303 |
break;
|
@@ -308,13 +311,13 @@ class RTMediaUploadFile {
|
|
308 |
return $file;
|
309 |
}
|
310 |
|
311 |
-
function arrayify($files) {
|
312 |
-
if (isset($files['name']) && !is_array($files['name'])) {
|
313 |
-
$updated_files[0] = $files;
|
314 |
} else {
|
315 |
-
foreach ($files as $key => $array) {
|
316 |
-
foreach ($array as $index => $value)
|
317 |
-
$updated_files[$index][$key] = $value;
|
318 |
}
|
319 |
}
|
320 |
return $updated_files;
|
12 |
var $fake = false;
|
13 |
var $uploaded = false;
|
14 |
|
15 |
+
function __construct ( $uploaded ) {
|
16 |
$this->uploaded = $uploaded;
|
17 |
}
|
18 |
|
22 |
* @param type $files
|
23 |
* @return type
|
24 |
*/
|
25 |
+
function init ( $files ) {
|
26 |
|
27 |
+
$this->set_file ( $files );
|
28 |
+
$this->unset_invalid_files ();
|
29 |
+
$uploaded_file = $this->process ();
|
30 |
return $uploaded_file;
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* core process of upload
|
35 |
*/
|
36 |
+
function process () {
|
37 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
38 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
39 |
|
40 |
$upload_type = $this->fake ? 'wp_handle_sideload' : 'wp_handle_upload';
|
41 |
|
42 |
+
add_filter ( 'upload_dir', array( $this, 'upload_dir' ) );
|
43 |
+
foreach ( $this->files as $key => $file ) {
|
44 |
|
45 |
+
$uploaded_file[ ] = $upload_type ( $file, array( 'test_form' => false ) );
|
46 |
try {
|
47 |
+
if ( isset ( $uploaded_file[ $key ][ 'error' ] ) || $uploaded_file[ $key ] === null ) {
|
48 |
+
array_pop ( $uploaded_file );
|
49 |
|
50 |
+
throw new RTMediaUploadException ( 0, __ ( 'Error Uploading File', 'rtmedia' ) );
|
51 |
}
|
52 |
+
$uploaded_file[ $key ][ 'name' ] = $file[ 'name' ];
|
53 |
+
} catch ( RTMediaUploadException $e ) {
|
54 |
+
echo $e->getMessage ();
|
55 |
}
|
56 |
|
57 |
+
if ( strpos ( $file[ 'type' ], 'image' ) !== false ) {
|
58 |
+
if ( function_exists ( 'read_exif_data' ) ) {
|
59 |
+
$file = $this->exif ( $uploaded_file[ $key ] );
|
60 |
}
|
61 |
}
|
62 |
}
|
64 |
return $uploaded_file;
|
65 |
}
|
66 |
|
67 |
+
function upload_dir ( $upload_dir ) {
|
68 |
global $rtmedia_interaction;
|
69 |
+
if ( isset ( $this->uploaded[ "context" ] ) && isset ( $this->uploaded[ "context_id" ] ) ) {
|
70 |
+
if ( $this->uploaded[ "context" ] != 'group' ) {
|
71 |
$rtmedia_upload_prefix = 'users/';
|
72 |
+
$id = get_current_user_id ();
|
73 |
} else {
|
74 |
$rtmedia_upload_prefix = 'groups/';
|
75 |
+
$id = $this->uploaded[ "context_id" ];
|
76 |
}
|
77 |
} else {
|
78 |
+
if ( $rtmedia_interaction->context->type != 'group' ) {
|
79 |
$rtmedia_upload_prefix = 'users/';
|
80 |
+
$id = get_current_user_id ();
|
81 |
} else {
|
82 |
$rtmedia_upload_prefix = 'groups/';
|
83 |
$id = $rtmedia_interaction->context->id;
|
85 |
}
|
86 |
|
87 |
|
88 |
+
$upload_dir[ 'path' ] = trailingslashit (
|
89 |
+
str_replace ( $upload_dir[ 'subdir' ], '', $upload_dir[ 'path' ] ) )
|
90 |
. 'rtMedia/' . $rtmedia_upload_prefix . $id .
|
91 |
+
$upload_dir[ 'subdir' ];
|
92 |
+
$upload_dir[ 'url' ] = trailingslashit (
|
93 |
+
str_replace ( $upload_dir[ 'subdir' ], '', $upload_dir[ 'url' ] ) )
|
94 |
. 'rtMedia/' . $rtmedia_upload_prefix . $id
|
95 |
+
. $upload_dir[ 'subdir' ];
|
96 |
|
97 |
return $upload_dir;
|
98 |
}
|
99 |
|
100 |
+
function set_file ( $files ) {
|
101 |
/**
|
102 |
* if files parameter is provided then take th file details from that object
|
103 |
*/
|
104 |
+
if ( $files ) {
|
105 |
$this->fake = true;
|
106 |
+
$this->populate_file_array ( ( array ) $uploaded[ 'files' ] );
|
107 |
/**
|
108 |
* otherwise check for $_FILES global object from the form submitted
|
109 |
*/
|
110 |
+
} elseif ( isset ( $_FILES[ 'rtmedia_file' ] ) ) {
|
111 |
+
$this->populate_file_array ( $_FILES[ 'rtmedia_file' ] );
|
112 |
} else {
|
113 |
/**
|
114 |
* No files could be found to upload
|
115 |
*/
|
116 |
+
throw new RTMediaUploadException ( UPLOAD_ERR_NO_FILE );
|
117 |
}
|
118 |
}
|
119 |
|
121 |
* gather the file information for upload process
|
122 |
* @param type $file_array
|
123 |
*/
|
124 |
+
function populate_file_array ( $file_array ) {
|
125 |
+
$this->files[ ] = array(
|
126 |
+
'name' => isset ( $file_array[ 'name' ] ) ? $file_array[ 'name' ] : '',
|
127 |
+
'type' => isset ( $file_array[ 'type' ] ) ? $file_array[ 'type' ] : '',
|
128 |
+
'tmp_name' => isset ( $file_array[ 'tmp_name' ] ) ? $file_array[ 'tmp_name' ] : '',
|
129 |
+
'error' => isset ( $file_array[ 'error' ] ) ? $file_array[ 'error' ] : '',
|
130 |
+
'size' => isset ( $file_array[ 'size' ] ) ? $file_array[ 'size' ] : 0,
|
131 |
);
|
132 |
}
|
133 |
|
138 |
* @return boolean
|
139 |
* @throws RTMediaUploadException
|
140 |
*/
|
141 |
+
function is_valid_type ( $file ) {
|
142 |
try {
|
143 |
global $rtmedia;
|
144 |
+
$allowed_types = array( );
|
145 |
+
$rtmedia->allowed_types = apply_filters ( 'rtmedia_allowed_types', $rtmedia->allowed_types );
|
146 |
+
foreach ( $rtmedia->allowed_types as $type ) {
|
147 |
+
if ( call_user_func ( "is_rtmedia_upload_" . $type[ "name" ] . "_enabled" ) ) {
|
148 |
+
foreach ( $type[ 'extn' ] as $extn ) {
|
149 |
+
$allowed_types[ ] = $extn;
|
150 |
+
}
|
151 |
}
|
152 |
}
|
153 |
+
$file_data = wp_check_filetype ( $file[ 'name' ] );
|
154 |
+
$allowed_types = apply_filters ( 'rtmedia_plupload_files_filter', array( array( 'title' => "Media Files", 'extensions' => implode ( ",", $allowed_types ) ) ) );
|
155 |
+
$allowed_types = explode ( ",", $allowed_types[ 0 ][ "extensions" ] );
|
156 |
+
|
157 |
+
if ( in_array ( strtolower ( $file_data[ "ext" ] ), $allowed_types ) == false ) {
|
158 |
+
if ( ! preg_match ( '/' . implode ( '|', $allowed_types ) . '/i', $file[ 'type' ], $result ) || ! isset ( $result[ 0 ] ) ) {
|
159 |
+
throw new RTMediaUploadException ( UPLOAD_ERR_EXTENSION );
|
160 |
}
|
161 |
}
|
162 |
// $is_valid = $this->id3_validate_type($file);
|
163 |
+
} catch ( RTMediaUploadException $e ) {
|
164 |
+
echo $e->getMessage ();
|
165 |
return false;
|
166 |
}
|
167 |
return true;
|
170 |
/**
|
171 |
* Remove invalid files
|
172 |
*/
|
173 |
+
function unset_invalid_files () {
|
174 |
$temp_array = $this->files;
|
175 |
$this->files = null;
|
176 |
+
foreach ( $temp_array as $key => $file ) {
|
177 |
+
if ( apply_filters ( 'rtmedia_valid_type_check', $this->is_valid_type ( $file ), $file ) ) {
|
178 |
+
$this->files[ ] = $file;
|
179 |
}
|
180 |
}
|
181 |
}
|
182 |
|
183 |
+
function id3_validate_type ( $file ) {
|
184 |
+
$file_type = explode ( '/', $file[ 'type' ] );
|
185 |
+
$type = $file_type[ 0 ];
|
186 |
+
switch ( $type ) {
|
187 |
case 'video' :
|
188 |
+
include_once(trailingslashit ( RTMEDIA_PATH ) . 'lib/getid3/getid3.php');
|
189 |
try {
|
190 |
$getID3 = new getID3;
|
191 |
+
$vid_info = $getID3->analyze ( $file[ 'tmp_name' ] );
|
192 |
+
} catch ( Exception $e ) {
|
193 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
194 |
$activity_content = false;
|
195 |
+
throw new RTMediaUploadException ( 0, __ ( 'MP4 file you have uploaded is corrupt.', 'buddypress-media' ) );
|
196 |
}
|
197 |
+
if ( is_array ( $vid_info ) ) {
|
198 |
+
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' ] ) ) {
|
199 |
+
if ( ! ($vid_info[ 'fileformat' ] == 'mp4' && $vid_info[ 'video' ][ 'fourcc' ] == 'avc1') ) {
|
200 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
201 |
$activity_content = false;
|
202 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'buddypress-media' ) );
|
203 |
}
|
204 |
} else {
|
205 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
206 |
$activity_content = false;
|
207 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'buddypress-media' ) );
|
208 |
}
|
209 |
} else {
|
210 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
211 |
$activity_content = false;
|
212 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP4 file you have uploaded is not a video file.', 'buddypress-media' ) );
|
213 |
}
|
214 |
break;
|
215 |
case 'audio' :
|
216 |
+
include_once(trailingslashit ( RTMEDIA_PATH ) . 'lib/getid3/getid3.php');
|
217 |
try {
|
218 |
$getID3 = new getID3;
|
219 |
+
$file_info = $getID3->analyze ( $file[ 'tmp_name' ] );
|
220 |
+
} catch ( Exception $e ) {
|
221 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
222 |
$activity_content = false;
|
223 |
+
throw new RTMediaUploadException ( 0, __ ( 'MP3 file you have uploaded is currupt.', 'buddypress-media' ) );
|
224 |
}
|
225 |
+
if ( is_array ( $file_info ) ) {
|
226 |
+
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' ] ) ) {
|
227 |
+
if ( ! ($file_info[ 'fileformat' ] == 'mp3' && $file_info[ 'audio' ][ 'dataformat' ] == 'mp3') ) {
|
228 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
229 |
$activity_content = false;
|
230 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'buddypress-media' ) );
|
231 |
}
|
232 |
} else {
|
233 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
234 |
$activity_content = false;
|
235 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'buddypress-media' ) );
|
236 |
}
|
237 |
} else {
|
238 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
239 |
$activity_content = false;
|
240 |
+
throw new RTMediaUploadException ( 0, __ ( 'The MP3 file you have uploaded is not an audio file.', 'buddypress-media' ) );
|
241 |
}
|
242 |
break;
|
243 |
case 'image' :
|
244 |
break;
|
245 |
default :
|
246 |
+
$this->safe_unlink ( $file[ 'tmp_name' ] );
|
247 |
$activity_content = false;
|
248 |
+
throw new RTMediaUploadException ( 0, __ ( 'Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', 'buddypress-media' ) );
|
249 |
}
|
250 |
|
251 |
return true;
|
252 |
}
|
253 |
|
254 |
+
function safe_unlink ( $file_path ) {
|
255 |
+
if ( file_exists ( $file_path ) )
|
256 |
+
unlink ( $file_path );
|
257 |
}
|
258 |
|
259 |
+
function exif ( $file ) {
|
260 |
+
$file_parts = pathinfo ( $file[ 'file' ] );
|
261 |
+
if ( in_array ( strtolower ( $file_parts[ 'extension' ] ), array( 'jpg', 'jpeg', 'tiff' ) ) ) {
|
262 |
+
$exif = read_exif_data ( $file[ 'file' ] );
|
263 |
+
$exif_orient = isset ( $exif[ 'Orientation' ] ) ? $exif[ 'Orientation' ] : 0;
|
264 |
$rotateImage = 0;
|
265 |
|
266 |
+
if ( 6 == $exif_orient ) {
|
267 |
$rotateImage = 90;
|
268 |
$imageOrientation = 1;
|
269 |
+
} elseif ( 3 == $exif_orient ) {
|
270 |
$rotateImage = 180;
|
271 |
$imageOrientation = 1;
|
272 |
+
} elseif ( 8 == $exif_orient ) {
|
273 |
$rotateImage = 270;
|
274 |
$imageOrientation = 1;
|
275 |
}
|
276 |
|
277 |
+
if ( $rotateImage ) {
|
278 |
+
if ( class_exists ( 'Imagick' ) ) {
|
279 |
$imagick = new Imagick();
|
280 |
+
$imagick->readImage ( $file[ 'file' ] );
|
281 |
+
$imagick->rotateImage ( new ImagickPixel (), $rotateImage );
|
282 |
+
$imagick->setImageOrientation ( $imageOrientation );
|
283 |
+
$imagick->writeImage ( $file[ 'file' ] );
|
284 |
+
$imagick->clear ();
|
285 |
+
$imagick->destroy ();
|
286 |
} else {
|
287 |
$rotateImage = -$rotateImage;
|
288 |
|
289 |
+
switch ( $file[ 'type' ] ) {
|
290 |
case 'image/jpeg':
|
291 |
+
$source = imagecreatefromjpeg ( $file[ 'file' ] );
|
292 |
+
$rotate = imagerotate ( $source, $rotateImage, 0 );
|
293 |
+
imagejpeg ( $rotate, $file[ 'file' ] );
|
294 |
break;
|
295 |
case 'image/png':
|
296 |
+
$source = imagecreatefrompng ( $file[ 'file' ] );
|
297 |
+
$rotate = imagerotate ( $source, $rotateImage, 0 );
|
298 |
+
imagepng ( $rotate, $file[ 'file' ] );
|
299 |
break;
|
300 |
case 'image/gif':
|
301 |
+
$source = imagecreatefromgif ( $file[ 'file' ] );
|
302 |
+
$rotate = imagerotate ( $source, $rotateImage, 0 );
|
303 |
+
imagegif ( $rotate, $file[ 'file' ] );
|
304 |
break;
|
305 |
default:
|
306 |
break;
|
311 |
return $file;
|
312 |
}
|
313 |
|
314 |
+
function arrayify ( $files ) {
|
315 |
+
if ( isset ( $files[ 'name' ] ) && ! is_array ( $files[ 'name' ] ) ) {
|
316 |
+
$updated_files[ 0 ] = $files;
|
317 |
} else {
|
318 |
+
foreach ( $files as $key => $array ) {
|
319 |
+
foreach ( $array as $index => $value )
|
320 |
+
$updated_files[ $index ][ $key ] = $value;
|
321 |
}
|
322 |
}
|
323 |
return $updated_files;
|
app/main/interactions/RTMediaInteraction.php
CHANGED
@@ -7,176 +7,165 @@
|
|
7 |
*/
|
8 |
class RTMediaInteraction {
|
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 |
-
$this->set_context();
|
41 |
-
$this->set_routers();
|
42 |
-
$this->set_query();
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Set up the route slugs' array
|
48 |
-
*/
|
49 |
-
function route_slugs(){
|
50 |
-
|
51 |
-
// filter to add custom slugs for routes
|
52 |
-
$this->slugs = apply_filters('rtmedia_default_routes',$this->slugs);
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
static function rewrite_rules() {
|
57 |
-
add_rewrite_rule('^/media/([0-9]*)/([^/]*)/?','index.php?media_id=$matches[1]&action=$matches[2]','bottom');
|
58 |
-
add_rewrite_rule('^/media/([0-9]*)/pg/([0-9]*)/?','index.php?media_id=$matches[1]&pg=$matches[2]','bottom');
|
59 |
-
add_rewrite_rule('^/media/nonce/([^/]*)/?','index.php?nonce_type=$matches[1]','bottom');
|
60 |
-
add_rewrite_rule('^/media/([A-Za-z]*)/pg/([0-9]*)/?','index.php?media_type=$matches[1]&pg=$matches[2]','bottom');
|
61 |
-
add_rewrite_rule('^/media/pg/([0-9]*)/?','index.php?pg=$matches[1]','bottom');
|
62 |
-
}
|
63 |
-
|
64 |
-
static function rewrite_tags(){
|
65 |
-
add_rewrite_tag('%media_id%','([0-9]*)');
|
66 |
-
add_rewrite_tag('%action%','([^/]*)');
|
67 |
-
add_rewrite_tag('%nonce_type%','([^/]*)');
|
68 |
-
add_rewrite_tag('%media_type%','([A-Za-z]*)');
|
69 |
-
add_rewrite_tag('%pg%','([0-9]*)');
|
70 |
-
}
|
71 |
-
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Just adds the current /{slug}/ to the rewite endpoint
|
75 |
-
*/
|
76 |
-
function endpoint(){
|
77 |
-
|
78 |
-
foreach($this->slugs as $slug){
|
79 |
-
add_rewrite_endpoint( $slug, EP_ALL );
|
80 |
-
}
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
function set_routers(){
|
85 |
-
|
86 |
-
|
87 |
-
// set up routes for each slug
|
88 |
-
foreach($this->slugs as $slug){
|
89 |
-
$this->routes[$slug] = new RTMediaRouter($slug);
|
90 |
-
}
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Sets up the default context
|
96 |
-
*/
|
97 |
-
function default_context() {
|
98 |
-
|
99 |
-
return new RTMediaContext();
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
*
|
104 |
-
* @param array $context the context array
|
105 |
-
* @todo the method should also allow objects
|
106 |
-
*/
|
107 |
-
function set_context( $context = false ) {
|
108 |
-
|
109 |
-
// take the context supplied and replace the context
|
110 |
-
if ( is_array( $context ) && isset( $context[ 'type' ] ) && isset( $context[ 'id' ] ) ) {
|
111 |
-
|
112 |
-
$context_object->type = $context[ 'type' ];
|
113 |
-
$context_object->id = $context[ 'id' ];
|
114 |
-
|
115 |
-
// if there is no context array supplied, set the default context
|
116 |
-
} else {
|
117 |
-
|
118 |
-
$context_object = $this->default_context();
|
119 |
-
}
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
//set the context property
|
124 |
-
|
125 |
-
$this->context = $context_object;
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Reset the context to the default context after temporarily setting it,
|
130 |
-
* Say, for an upload
|
131 |
-
*/
|
132 |
-
|
133 |
-
function rewind_context(){
|
134 |
-
|
135 |
-
$this->context = $this->default_context();
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
function set_query() {
|
140 |
-
global $rtmedia_query;
|
141 |
-
|
142 |
-
$args = array(
|
143 |
-
'context' => $this->context->type,
|
144 |
-
'context_id' => $this->context->id
|
145 |
-
);
|
146 |
-
|
147 |
-
$rtmedia_query = new RTMediaQuery($args);
|
148 |
-
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
function set_title($default,$sep){
|
153 |
-
global $wp_query;
|
154 |
-
|
155 |
-
if( ! array_key_exists('media',$wp_query->query_vars)) return $default;
|
156 |
-
|
157 |
-
$title = RTMEDIA_MEDIA_LABEL .' '. $sep .' ';
|
158 |
-
global $bp;
|
159 |
-
//echo get_post_field('post_title',$this->context->id);
|
160 |
-
switch($this->context->type){
|
161 |
-
case 'group':
|
162 |
-
$title .= ucfirst($bp->groups->slug);
|
163 |
-
break;
|
164 |
-
case 'profile':
|
165 |
-
if(class_exists('BuddyPress')){
|
166 |
-
$title .= ucfirst($bp->profile->slug);
|
167 |
-
}else{
|
168 |
-
$title .= get_query_var('author_name');
|
169 |
-
}
|
170 |
-
break;
|
171 |
-
default:
|
172 |
-
$title .= get_post_field('post_title',$this->context->id);
|
173 |
-
|
174 |
-
break;
|
175 |
-
}
|
176 |
-
$title .= ' '.$sep.' '.get_bloginfo( 'name' ) ;
|
177 |
-
return $title;
|
178 |
-
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
}
|
182 |
|
7 |
*/
|
8 |
class RTMediaInteraction {
|
9 |
|
10 |
+
public $context;
|
11 |
+
private $slugs = array(
|
12 |
+
RTMEDIA_MEDIA_SLUG,
|
13 |
+
'upload'
|
14 |
+
);
|
15 |
+
public $routes;
|
16 |
|
17 |
+
/**
|
18 |
+
* Initialise the interaction
|
19 |
+
*/
|
20 |
+
function __construct () {
|
21 |
|
22 |
+
// hook into the WordPress Rewrite Endpoint API
|
23 |
|
24 |
+
add_action ( 'init', array( $this, 'rewrite_rules' ) );
|
25 |
+
add_action ( 'init', array( $this, 'rewrite_tags' ) );
|
26 |
+
add_action ( 'init', array( $this, 'endpoint' ) );
|
27 |
|
28 |
|
29 |
+
// set up interaction and routes
|
30 |
+
add_action ( 'template_redirect', array( $this, 'init' ), 99 );
|
31 |
|
32 |
+
add_filter ( 'wp_title', array( $this, 'set_title' ), 9999, 2 );
|
33 |
+
}
|
34 |
|
35 |
+
function init () {
|
36 |
+
// set up the routes array
|
37 |
+
$this->route_slugs ();
|
38 |
+
$this->set_context ();
|
39 |
+
$this->set_routers ();
|
40 |
+
$this->set_query ();
|
41 |
+
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Set up the route slugs' array
|
45 |
+
*/
|
46 |
+
function route_slugs () {
|
47 |
|
48 |
+
// filter to add custom slugs for routes
|
49 |
+
$this->slugs = apply_filters ( 'rtmedia_default_routes', $this->slugs );
|
50 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
static function rewrite_rules () {
|
53 |
+
add_rewrite_rule ( '^/' . RTMEDIA_MEDIA_SLUG . '/([0-9]*)/([^/]*)/?', 'index.php?media_id=$matches[1]&action=$matches[2]', 'bottom' );
|
54 |
+
add_rewrite_rule ( '^/' . RTMEDIA_MEDIA_SLUG . '/([0-9]*)/pg/([0-9]*)/?', 'index.php?media_id=$matches[1]&pg=$matches[2]', 'bottom' );
|
55 |
+
add_rewrite_rule ( '^/' . RTMEDIA_MEDIA_SLUG . '/nonce/([^/]*)/?', 'index.php?nonce_type=$matches[1]', 'bottom' );
|
56 |
+
add_rewrite_rule ( '^/' . RTMEDIA_MEDIA_SLUG . '/([A-Za-z]*)/pg/([0-9]*)/?', 'index.php?media_type=$matches[1]&pg=$matches[2]', 'bottom' );
|
57 |
+
add_rewrite_rule ( '^/' . RTMEDIA_MEDIA_SLUG . '/pg/([0-9]*)/?', 'index.php?pg=$matches[1]', 'bottom' );
|
58 |
+
}
|
59 |
+
|
60 |
+
static function rewrite_tags () {
|
61 |
+
add_rewrite_tag ( '%media_id%', '([0-9]*)' );
|
62 |
+
add_rewrite_tag ( '%action%', '([^/]*)' );
|
63 |
+
add_rewrite_tag ( '%nonce_type%', '([^/]*)' );
|
64 |
+
add_rewrite_tag ( '%media_type%', '([A-Za-z]*)' );
|
65 |
+
add_rewrite_tag ( '%pg%', '([0-9]*)' );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Just adds the current /{slug}/ to the rewite endpoint
|
70 |
+
*/
|
71 |
+
function endpoint () {
|
72 |
+
|
73 |
+
foreach ( $this->slugs as $slug ) {
|
74 |
+
add_rewrite_endpoint ( $slug, EP_ALL );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
function set_routers () {
|
79 |
+
|
80 |
+
|
81 |
+
// set up routes for each slug
|
82 |
+
foreach ( $this->slugs as $slug ) {
|
83 |
+
$this->routes[ $slug ] = new RTMediaRouter ( $slug );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Sets up the default context
|
89 |
+
*/
|
90 |
+
function default_context () {
|
91 |
+
|
92 |
+
return new RTMediaContext();
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
*
|
97 |
+
* @param array $context the context array
|
98 |
+
* @todo the method should also allow objects
|
99 |
+
*/
|
100 |
+
function set_context ( $context = false ) {
|
101 |
+
|
102 |
+
// take the context supplied and replace the context
|
103 |
+
if ( is_array ( $context ) && isset ( $context[ 'type' ] ) && isset ( $context[ 'id' ] ) ) {
|
104 |
+
|
105 |
+
$context_object->type = $context[ 'type' ];
|
106 |
+
$context_object->id = $context[ 'id' ];
|
107 |
+
|
108 |
+
// if there is no context array supplied, set the default context
|
109 |
+
} else {
|
110 |
+
|
111 |
+
$context_object = $this->default_context ();
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
//set the context property
|
117 |
+
|
118 |
+
$this->context = $context_object;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Reset the context to the default context after temporarily setting it,
|
123 |
+
* Say, for an upload
|
124 |
+
*/
|
125 |
+
function rewind_context () {
|
126 |
+
|
127 |
+
$this->context = $this->default_context ();
|
128 |
+
}
|
129 |
+
|
130 |
+
function set_query () {
|
131 |
+
global $rtmedia_query;
|
132 |
+
|
133 |
+
$args = array(
|
134 |
+
'context' => $this->context->type,
|
135 |
+
'context_id' => $this->context->id
|
136 |
+
);
|
137 |
+
|
138 |
+
$rtmedia_query = new RTMediaQuery ( $args );
|
139 |
+
}
|
140 |
+
|
141 |
+
function set_title ( $default, $sep ) {
|
142 |
+
global $wp_query;
|
143 |
+
|
144 |
+
if ( ! array_key_exists ( 'media', $wp_query->query_vars ) )
|
145 |
+
return $default;
|
146 |
+
|
147 |
+
$title = RTMEDIA_MEDIA_LABEL . ' ' . $sep . ' ';
|
148 |
+
global $bp;
|
149 |
+
//echo get_post_field('post_title',$this->context->id);
|
150 |
+
switch ( $this->context->type ) {
|
151 |
+
case 'group':
|
152 |
+
$title .= ucfirst ( $bp->groups->slug );
|
153 |
+
break;
|
154 |
+
case 'profile':
|
155 |
+
if ( class_exists ( 'BuddyPress' ) ) {
|
156 |
+
$title .= ucfirst ( $bp->profile->slug );
|
157 |
+
} else {
|
158 |
+
$title .= get_query_var ( 'author_name' );
|
159 |
+
}
|
160 |
+
break;
|
161 |
+
default:
|
162 |
+
$title .= get_post_field ( 'post_title', $this->context->id );
|
163 |
+
|
164 |
+
break;
|
165 |
+
}
|
166 |
+
$title .= ' ' . $sep . ' ' . get_bloginfo ( 'name' );
|
167 |
+
return $title;
|
168 |
+
}
|
169 |
|
170 |
}
|
171 |
|
app/main/routers/RTMediaRouter.php
CHANGED
@@ -12,150 +12,139 @@
|
|
12 |
*/
|
13 |
class RTMediaRouter {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
function __construct( $slug = 'media' ) {
|
33 |
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
$this->template_redirect();
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
|
47 |
-
|
48 |
-
* Check if there is a constant defined for this route and use that instead
|
49 |
-
* So, this can be overridden by defining RTMEDIA_MEDIA_SLUG in wp-config.php
|
50 |
-
*
|
51 |
-
* @param string $slug The slug string passed for the route, in the constructor
|
52 |
-
*/
|
53 |
-
function slug($slug){
|
54 |
|
55 |
-
|
56 |
-
$slug_constant = 'RTMEDIA_' . strtoupper( $slug ) . '_SLUG';
|
57 |
|
58 |
-
// check if the constant is defined
|
59 |
-
if ( defined( $slug_constant ) ){
|
60 |
|
61 |
-
|
62 |
-
$slug = constant($slug_constant);
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
70 |
|
|
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
*
|
75 |
-
* @global object $wp_query
|
76 |
-
* @return boolean
|
77 |
-
*/
|
78 |
-
|
79 |
-
function is_template() {
|
80 |
-
global $wp_query;
|
81 |
-
|
82 |
-
$return = isset( $wp_query->query_vars[ $this->slug ] );
|
83 |
-
if($return){
|
84 |
-
if(isset($wp_query->query_vars['action']) && $wp_query->query_vars['action']== 'bp_avatar_upload')
|
85 |
-
$return = false;
|
86 |
-
}
|
87 |
-
|
88 |
-
if($return){
|
89 |
-
$wp_query->is_404 = false;
|
90 |
-
}
|
91 |
-
return $return;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Hook into the template redirect action to populate the global objects
|
96 |
-
*
|
97 |
-
*/
|
98 |
-
|
99 |
-
function template_redirect() {
|
100 |
-
|
101 |
-
// if it is not our route, return early
|
102 |
-
if(!$this->is_template())return;
|
103 |
-
|
104 |
-
status_header( 200 );
|
105 |
-
//set up the query variables
|
106 |
-
$this->set_query_vars();
|
107 |
-
|
108 |
-
|
109 |
-
// otherwise provide a hook for only this route,
|
110 |
-
// pass the slug to the function hooking here
|
111 |
-
do_action("rtmedia_".$this->slug."_redirect");
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Hook into the template_include filter to load custom template files
|
117 |
-
*
|
118 |
-
* @param string $template Template file path of the default template
|
119 |
-
* @return string File path of the template file to be loaded
|
120 |
-
*/
|
121 |
-
|
122 |
-
function template_include($template){
|
123 |
-
|
124 |
-
// if it is not our route, return the default template early
|
125 |
-
if(!$this->is_template())return $template;
|
126 |
-
|
127 |
-
// otherwise, apply a filter to the template,
|
128 |
-
// pass the template and slug to the function hooking here
|
129 |
-
// so it can load a custom template
|
130 |
-
|
131 |
-
|
132 |
-
$template_load = new RTMediaTemplate();
|
133 |
-
|
134 |
-
$template = $template_load->set_template($template);
|
135 |
-
|
136 |
-
|
137 |
-
$template = apply_filters("rtmedia_".$this->slug."_include",$template);
|
138 |
-
|
139 |
-
// return the template for inclusion in the theme
|
140 |
-
|
141 |
-
return $template;
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Break the request URL into an array of variables after the route slug
|
147 |
-
*
|
148 |
-
* @global object $wp_query
|
149 |
-
*/
|
150 |
-
|
151 |
-
function set_query_vars() {
|
152 |
-
|
153 |
-
global $wp_query;
|
154 |
-
$query_vars_array = explode('/',$wp_query->query_vars[ $this->slug ]);
|
155 |
-
|
156 |
-
$this->query_vars = apply_filters('rtmedia_query_vars',$query_vars_array);
|
157 |
-
|
158 |
-
}
|
159 |
|
160 |
}
|
161 |
|
12 |
*/
|
13 |
class RTMediaRouter {
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @var string The slug for the route
|
18 |
+
*/
|
19 |
+
public $slug;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var array The query variables passed to our route
|
24 |
+
*/
|
25 |
+
public $query_vars;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initialise the route
|
29 |
+
* @param string $slug The slug for which the route needs to be registered, for eg, /media/
|
30 |
+
*/
|
31 |
+
function __construct ( $slug = RTMEDIA_MEDIA_SLUG ) {
|
|
|
32 |
|
33 |
+
//set up the slug for the route
|
34 |
+
$this->slug ( $slug );
|
35 |
|
|
|
|
|
36 |
|
37 |
+
$this->template_redirect ();
|
38 |
+
|
39 |
+
//
|
40 |
+
add_filter ( 'template_include', array( $this, 'template_include' ), 0, 1 );
|
41 |
+
add_action ( 'wp_ajax_rtmedia_include_gallery_item', array( 'RTMediaTemplate', 'include_gallery_item' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Check if there is a constant defined for this route and use that instead
|
46 |
+
* So, this can be overridden by defining RTMEDIA_MEDIA_SLUG in wp-config.php
|
47 |
+
*
|
48 |
+
* @param string $slug The slug string passed for the route, in the constructor
|
49 |
+
*/
|
50 |
+
function slug ( $slug ) {
|
51 |
+
|
52 |
+
// create the slug constant name
|
53 |
+
$slug_constant = 'RTMEDIA_' . strtoupper ( $slug ) . '_SLUG';
|
54 |
+
|
55 |
+
// check if the constant is defined
|
56 |
+
if ( defined ( $slug_constant ) ) {
|
57 |
+
|
58 |
+
// assign the value of the constant instead
|
59 |
+
$slug = constant ( $slug_constant );
|
60 |
+
}
|
61 |
+
|
62 |
+
// set the slug property
|
63 |
+
$this->slug = $slug;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Checks if the route has been requested
|
68 |
+
*
|
69 |
+
* @global object $wp_query
|
70 |
+
* @return boolean
|
71 |
+
*/
|
72 |
+
function is_template () {
|
73 |
+
global $wp_query;
|
74 |
+
|
75 |
+
$return = isset ( $wp_query->query_vars[ $this->slug ] );
|
76 |
+
if ( $return ) {
|
77 |
+
if ( isset ( $wp_query->query_vars[ 'action' ] ) && $wp_query->query_vars[ 'action' ] == 'bp_avatar_upload' )
|
78 |
+
$return = false;
|
79 |
+
}
|
80 |
+
|
81 |
+
if ( $return ) {
|
82 |
+
$wp_query->is_404 = false;
|
83 |
+
}
|
84 |
+
return $return;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Hook into the template redirect action to populate the global objects
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
function template_redirect () {
|
92 |
+
|
93 |
+
// if it is not our route, return early
|
94 |
+
if ( ! $this->is_template () )
|
95 |
+
return;
|
96 |
+
|
97 |
+
status_header ( 200 );
|
98 |
+
//set up the query variables
|
99 |
+
$this->set_query_vars ();
|
100 |
+
|
101 |
+
|
102 |
+
// otherwise provide a hook for only this route,
|
103 |
+
// pass the slug to the function hooking here
|
104 |
+
do_action ( "rtmedia_" . $this->slug . "_redirect" );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Hook into the template_include filter to load custom template files
|
109 |
+
*
|
110 |
+
* @param string $template Template file path of the default template
|
111 |
+
* @return string File path of the template file to be loaded
|
112 |
+
*/
|
113 |
+
function template_include ( $template ) {
|
114 |
+
|
115 |
+
// if it is not our route, return the default template early
|
116 |
+
if ( ! $this->is_template () )
|
117 |
+
return $template;
|
118 |
|
119 |
+
// otherwise, apply a filter to the template,
|
120 |
+
// pass the template and slug to the function hooking here
|
121 |
+
// so it can load a custom template
|
122 |
|
123 |
|
124 |
+
$template_load = new RTMediaTemplate();
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
+
$template = $template_load->set_template ( $template );
|
|
|
127 |
|
|
|
|
|
128 |
|
129 |
+
$template = apply_filters ( "rtmedia_" . $this->slug . "_include", $template );
|
|
|
130 |
|
131 |
+
// return the template for inclusion in the theme
|
132 |
|
133 |
+
return $template;
|
134 |
+
}
|
135 |
|
136 |
+
/**
|
137 |
+
* Break the request URL into an array of variables after the route slug
|
138 |
+
*
|
139 |
+
* @global object $wp_query
|
140 |
+
*/
|
141 |
+
function set_query_vars () {
|
142 |
|
143 |
+
global $wp_query;
|
144 |
+
$query_vars_array = explode ( '/', $wp_query->query_vars[ $this->slug ] );
|
145 |
|
146 |
+
$this->query_vars = apply_filters ( 'rtmedia_query_vars', $query_vars_array );
|
147 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
}
|
150 |
|
app/main/routers/query/RTMediaQuery.php
CHANGED
@@ -12,760 +12,760 @@
|
|
12 |
*/
|
13 |
class RTMediaQuery {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
*
|
23 |
-
* @var array The query arguments for the current instance (variable)
|
24 |
-
*/
|
25 |
-
public $media_query = '';
|
26 |
-
|
27 |
-
/**
|
28 |
-
*
|
29 |
-
* @var object The current action object (edit/delete/custom)
|
30 |
-
*/
|
31 |
-
public $action_query = false;
|
32 |
-
|
33 |
-
/**
|
34 |
-
*
|
35 |
-
* @var object The currently relevant interaction object
|
36 |
-
*/
|
37 |
-
private $interaction;
|
38 |
-
|
39 |
-
/**
|
40 |
-
*
|
41 |
-
* @var array The actions recognised for the object
|
42 |
-
*/
|
43 |
-
public $actions = array(
|
44 |
-
'edit' => array( 'Edit', false ),
|
45 |
-
'delete' => array( 'Delete', false ),
|
46 |
-
'comment' => array( 'Comment', true )
|
47 |
-
);
|
48 |
-
public $media = '';
|
49 |
-
public $media_count = 0;
|
50 |
-
public $current_media = -1;
|
51 |
-
public $in_the_media_loop = false;
|
52 |
-
public $format = false;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Initialise the query
|
56 |
-
*
|
57 |
-
* @global object $rtmedia_interaction The global interaction object
|
58 |
-
* @param array $args The query arguments
|
59 |
-
*/
|
60 |
-
function __construct( $args = false ) {
|
61 |
-
|
62 |
-
// set up the interaction object relevant to just the query
|
63 |
-
// we only need information related to the media route
|
64 |
-
global $rtmedia_interaction;
|
65 |
-
|
66 |
-
$this->model = new RTMediaModel();
|
67 |
-
|
68 |
-
|
69 |
-
$this->interaction = $rtmedia_interaction->routes[ 'media' ];
|
70 |
-
|
71 |
-
$this->friendship = new RTMediaFriends();
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
// action manipulator hook
|
76 |
-
$this->set_actions();
|
77 |
-
|
78 |
-
//check and set the format to json, if needed
|
79 |
-
$this->set_json_format();
|
80 |
-
|
81 |
-
// set up the action query from the URL
|
82 |
-
$this->set_action_query();
|
83 |
-
|
84 |
-
add_filter( 'rtmedia-model-where-query', array( $this, 'privacy_filter' ),1,2 );
|
85 |
-
|
86 |
-
// if no args were supplied, initialise the $args
|
87 |
-
if ( empty( $args ) ) {
|
88 |
-
|
89 |
-
$this->init();
|
90 |
-
|
91 |
-
// otherwise just populate the query
|
92 |
-
} else {
|
93 |
-
|
94 |
-
$this->query( $args );
|
95 |
-
}
|
96 |
-
|
97 |
-
do_action('rtmedia_query_construct');
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Initialise the default args for the query
|
103 |
-
*/
|
104 |
-
function init() {
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
function set_media_type() {
|
109 |
-
if ( ! isset( $this->query[ 'media_type' ] ) ) {
|
110 |
-
if ( isset( $this->action_query->id ) ) {
|
111 |
-
$media = $this->model->get( array( 'id' => $this->action_query->id ) );
|
112 |
-
$media_type = $media[ 0 ]->media_type;
|
113 |
-
$this->query[ 'media_type' ] = $media_type;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
function is_single() {
|
119 |
-
/**
|
120 |
-
* // check the condition
|
121 |
-
* wont be true in case of multiple albums
|
122 |
-
*/
|
123 |
-
if ( ! isset( $this->action_query->id ) || $this->is_album() ) {
|
124 |
-
return false;
|
125 |
-
} else {
|
126 |
-
if ( isset( $this->query[ 'media_type' ] ) &&
|
127 |
-
$this->query[ 'media_type' ] == 'album' ) {
|
128 |
-
return false;
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
return true;
|
133 |
-
}
|
134 |
-
|
135 |
-
function is_album() {
|
136 |
-
if (isset( $this->query[ 'media_type' ] ) && $this->query[ 'media_type' ] == 'album' ) {
|
137 |
-
return true;
|
138 |
-
}
|
139 |
-
return false;
|
140 |
-
}
|
141 |
-
|
142 |
-
function is_gallery() {
|
143 |
-
if ( ! $this->is_single() )
|
144 |
-
return true;
|
145 |
-
|
146 |
-
return false;
|
147 |
-
}
|
148 |
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
*/
|
159 |
-
function set_json_format() {
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
$raw_query = $this->interaction->query_vars;
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
$modifier_type = 'default';
|
175 |
-
$modifier_value = false;
|
176 |
-
$format = '';
|
177 |
-
$pageno = 1;
|
178 |
-
$attributes = '';
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
// The first part of the query /media/{*}/
|
183 |
-
if ( is_array( $raw_query ) &&
|
184 |
-
count( $raw_query ) &&
|
185 |
-
! empty( $raw_query[ 0 ] ) ) {
|
186 |
-
|
187 |
-
//set the modifier value beforehand
|
188 |
-
$modifier_value = $raw_query[ 0 ];
|
189 |
-
|
190 |
-
if($modifier_value== "album" && !is_rtmedia_album_enable()){
|
191 |
-
include get_404_template();
|
192 |
-
die();
|
193 |
-
}
|
194 |
-
|
195 |
-
// requesting nonce /media/nonce/edit/ | /media/nonce/comment
|
196 |
-
// | /media/nonce/delete
|
197 |
-
|
198 |
-
if ( $modifier_value == 'nonce' ) {
|
199 |
-
|
200 |
-
$modifier_type = 'nonce';
|
201 |
-
|
202 |
-
// requesting media id /media/{id}/
|
203 |
-
} elseif ( is_numeric( $modifier_value ) ) {
|
204 |
-
|
205 |
-
$modifier_type = 'id';
|
206 |
-
|
207 |
-
// this block is unnecessary, please delete, asap
|
208 |
-
if ( isset( $_POST[ 'request_action' ] ) &&
|
209 |
-
$_POST[ 'request_action' ] == 'delete' ) {
|
210 |
-
|
211 |
-
$action = 'delete';
|
212 |
-
}
|
213 |
-
|
214 |
-
// requesting an upload screen /media/upload/
|
215 |
-
} elseif ( array_key_exists( $modifier_value, $this->actions ) ) {
|
216 |
-
// /media/edit/ | media/delete/ | /media/like/
|
217 |
|
218 |
-
|
219 |
-
|
220 |
-
} elseif ( $modifier_value == 'upload' ) {
|
221 |
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
224 |
|
225 |
-
|
226 |
-
|
|
|
|
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
231 |
|
232 |
-
|
233 |
-
$modifier_type = 'media_type';
|
234 |
-
}
|
235 |
-
}
|
236 |
|
|
|
237 |
|
238 |
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
-
$second_modifier = $raw_query[ 1 ];
|
242 |
|
243 |
|
244 |
-
|
|
|
|
|
|
|
245 |
|
246 |
-
|
|
|
247 |
|
248 |
-
|
249 |
-
|
|
|
|
|
250 |
|
251 |
-
|
252 |
-
|
253 |
|
254 |
-
|
|
|
|
|
255 |
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$action = $second_modifier;
|
262 |
-
}else if($second_modifier == "pg"){
|
263 |
-
if(isset($raw_query[ 2 ]) && is_numeric($raw_query[ 2 ])){
|
264 |
-
$pageno = $raw_query[ 2 ];
|
265 |
-
}
|
266 |
-
}
|
267 |
-
break;
|
268 |
-
|
269 |
-
case 'pg':
|
270 |
|
271 |
-
|
272 |
-
|
|
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
|
278 |
-
|
|
|
279 |
|
280 |
-
|
281 |
-
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
// /media/photos/page/2/
|
287 |
-
//elseif($second_modifier=='page'){
|
288 |
-
//$page = $second_modifier;
|
289 |
-
//pagination support
|
290 |
-
//}
|
291 |
-
break;
|
292 |
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
|
298 |
-
//the third part of the query /media/modifier/second_modifier/{*}
|
299 |
|
300 |
-
if ( isset( $raw_query[ 2 ] ) ) {
|
301 |
|
302 |
-
|
303 |
|
304 |
-
|
305 |
|
306 |
-
case 'nonce':
|
307 |
|
308 |
-
|
309 |
-
// /media/nonce/edit/title/
|
310 |
|
311 |
-
|
312 |
|
313 |
-
|
|
|
314 |
|
315 |
-
|
316 |
-
|
317 |
|
318 |
-
|
319 |
|
320 |
-
|
321 |
|
322 |
-
|
323 |
-
|
324 |
-
// /media/photos/edit/title/
|
325 |
-
// /media/photos/page/2/
|
326 |
-
if ( $second_modifier == 'pg' && is_numeric( $third_modifier ) ) {
|
327 |
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
|
|
331 |
|
332 |
-
|
333 |
-
default:
|
334 |
-
break;
|
335 |
-
}
|
336 |
-
}
|
337 |
|
|
|
|
|
338 |
|
339 |
-
|
|
|
|
|
340 |
|
341 |
-
|
342 |
-
//include get_404_template();
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
* setting parameters in action query object for pagination
|
347 |
-
*/
|
348 |
-
$per_page_media = intval( $rtmedia->options[ 'general_perPageMedia' ] );
|
349 |
-
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
/**
|
362 |
-
* additional actions to be added via action hook
|
363 |
-
*/
|
364 |
-
function set_actions() {
|
365 |
-
$this->actions = apply_filters( 'rtmedia_query_actions', $this->actions );
|
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 |
-
* Rewinds the db pool of media album and resets it to begining
|
751 |
-
*/
|
752 |
-
function rewind_media() {
|
753 |
-
$this->current_media = -1;
|
754 |
-
if ( $this->action_query->per_page_media > 0 ) {
|
755 |
-
$this->media = $this->media[ 0 ];
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
/**
|
760 |
-
*
|
761 |
-
* @return type
|
762 |
-
*/
|
763 |
-
function &get_data() {
|
764 |
-
|
765 |
-
$this->populate_data();
|
766 |
-
|
767 |
-
return $this->media;
|
768 |
-
}
|
769 |
|
770 |
}
|
771 |
|
12 |
*/
|
13 |
class RTMediaQuery {
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @var array The query arguments for the current instance
|
18 |
+
*/
|
19 |
+
public $query = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var array The query arguments for the current instance (variable)
|
24 |
+
*/
|
25 |
+
public $media_query = '';
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var object The current action object (edit/delete/custom)
|
30 |
+
*/
|
31 |
+
public $action_query = false;
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @var object The currently relevant interaction object
|
36 |
+
*/
|
37 |
+
private $interaction;
|
38 |
+
public $original_query;
|
39 |
+
|
40 |
+
/**
|
41 |
+
*
|
42 |
+
* @var array The actions recognised for the object
|
43 |
+
*/
|
44 |
+
public $actions = array(
|
45 |
+
'edit' => array( 'Edit', false ),
|
46 |
+
'delete' => array( 'Delete', false ),
|
47 |
+
'comment' => array( 'Comment', true )
|
48 |
+
);
|
49 |
+
public $media = '';
|
50 |
+
public $media_count = 0;
|
51 |
+
public $current_media = -1;
|
52 |
+
public $in_the_media_loop = false;
|
53 |
+
public $format = false;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Initialise the query
|
57 |
+
*
|
58 |
+
* @global object $rtmedia_interaction The global interaction object
|
59 |
+
* @param array $args The query arguments
|
60 |
+
*/
|
61 |
+
function __construct ( $args = false ) {
|
62 |
+
|
63 |
+
// set up the interaction object relevant to just the query
|
64 |
+
// we only need information related to the media route
|
65 |
+
global $rtmedia_interaction;
|
66 |
+
|
67 |
+
$this->model = new RTMediaModel();
|
68 |
+
|
69 |
+
|
70 |
+
$this->interaction = $rtmedia_interaction->routes[ RTMEDIA_MEDIA_SLUG ];
|
71 |
+
|
72 |
+
$this->friendship = new RTMediaFriends();
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
// action manipulator hook
|
77 |
+
$this->set_actions ();
|
78 |
+
|
79 |
+
//check and set the format to json, if needed
|
80 |
+
$this->set_json_format ();
|
81 |
+
|
82 |
+
// set up the action query from the URL
|
83 |
+
$this->set_action_query ();
|
84 |
+
|
85 |
+
add_filter ( 'rtmedia-model-where-query', array( $this, 'privacy_filter' ), 1, 2 );
|
86 |
+
|
87 |
+
// if no args were supplied, initialise the $args
|
88 |
+
if ( empty ( $args ) ) {
|
89 |
+
|
90 |
+
$this->init ();
|
91 |
+
|
92 |
+
// otherwise just populate the query
|
93 |
+
} else {
|
94 |
+
|
95 |
+
$this->query ( $args );
|
96 |
+
}
|
97 |
+
|
98 |
+
do_action ( 'rtmedia_query_construct' );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Initialise the default args for the query
|
103 |
+
*/
|
104 |
+
function init () {
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
function set_media_type () {
|
109 |
+
if ( ! isset ( $this->query[ 'media_type' ] ) ) {
|
110 |
+
if ( isset ( $this->action_query->id ) ) {
|
111 |
+
$media = $this->model->get ( array( 'id' => $this->action_query->id ) );
|
112 |
+
$media_type = $media[ 0 ]->media_type;
|
113 |
+
$this->query[ 'media_type' ] = $media_type;
|
114 |
+
}
|
115 |
+
} else {
|
116 |
|
117 |
+
}
|
118 |
+
}
|
|
|
|
|
119 |
|
120 |
+
function is_single () {
|
121 |
+
/**
|
122 |
+
* // check the condition
|
123 |
+
* wont be true in case of multiple albums
|
124 |
+
*/
|
125 |
+
if ( ! isset ( $this->action_query->id ) || $this->is_album () ) {
|
126 |
+
return false;
|
127 |
+
} else {
|
128 |
+
if ( isset ( $this->query[ 'media_type' ] ) &&
|
129 |
+
$this->query[ 'media_type' ] == 'album' ) {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
}
|
133 |
|
134 |
+
return true;
|
135 |
+
}
|
|
|
136 |
|
137 |
+
function is_album () {
|
138 |
+
if ( isset ( $this->query[ 'media_type' ] ) && $this->query[ 'media_type' ] == 'album' ) {
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
return false;
|
142 |
+
}
|
143 |
|
144 |
+
function is_gallery () {
|
145 |
+
if ( ! $this->is_single () )
|
146 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
+
return false;
|
149 |
+
}
|
|
|
150 |
|
151 |
+
function is_album_gallery () {
|
152 |
+
if ( isset ( $this->action_query->media_type ) && $this->action_query->media_type == 'album' ) {
|
153 |
+
return true;
|
154 |
+
}
|
155 |
+
return false;
|
156 |
+
}
|
157 |
|
158 |
+
/**
|
159 |
+
* json request
|
160 |
+
*/
|
161 |
+
function set_json_format () {
|
162 |
|
163 |
+
if ( isset ( $_GET[ 'json' ] ) || isset ( $_POST[ 'json' ] ) ) {
|
164 |
+
$this->format = 'json';
|
165 |
+
}
|
166 |
+
}
|
167 |
|
168 |
+
function set_action_query () {
|
|
|
|
|
|
|
169 |
|
170 |
+
$raw_query = $this->interaction->query_vars;
|
171 |
|
172 |
|
173 |
+
$bulk = false;
|
174 |
+
$action = false;
|
175 |
+
$attribute = false;
|
176 |
+
$modifier_type = 'default';
|
177 |
+
$modifier_value = false;
|
178 |
+
$format = '';
|
179 |
+
$pageno = 1;
|
180 |
+
$attributes = '';
|
181 |
|
|
|
182 |
|
183 |
|
184 |
+
// The first part of the query /media/{*}/
|
185 |
+
if ( is_array ( $raw_query ) &&
|
186 |
+
count ( $raw_query ) &&
|
187 |
+
! empty ( $raw_query[ 0 ] ) ) {
|
188 |
|
189 |
+
//set the modifier value beforehand
|
190 |
+
$modifier_value = $raw_query[ 0 ];
|
191 |
|
192 |
+
if ( $modifier_value == "album" && ! is_rtmedia_album_enable () ) {
|
193 |
+
include get_404_template ();
|
194 |
+
die ();
|
195 |
+
}
|
196 |
|
197 |
+
// requesting nonce /media/nonce/edit/ | /media/nonce/comment
|
198 |
+
// | /media/nonce/delete
|
199 |
|
200 |
+
if ( $modifier_value == 'nonce' ) {
|
201 |
+
|
202 |
+
$modifier_type = 'nonce';
|
203 |
|
204 |
+
// requesting media id /media/{id}/
|
205 |
+
} elseif ( is_numeric ( $modifier_value ) ) {
|
206 |
+
|
207 |
+
$modifier_type = 'id';
|
208 |
+
|
209 |
+
// this block is unnecessary, please delete, asap
|
210 |
+
if ( isset ( $_POST[ 'request_action' ] ) &&
|
211 |
+
$_POST[ 'request_action' ] == 'delete' ) {
|
212 |
|
213 |
+
$action = 'delete';
|
214 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
+
// requesting an upload screen /media/upload/
|
217 |
+
} elseif ( array_key_exists ( $modifier_value, $this->actions ) ) {
|
218 |
+
// /media/edit/ | media/delete/ | /media/like/
|
219 |
|
220 |
+
$action = $modifier_value;
|
221 |
+
$bulk = true;
|
222 |
+
} elseif ( $modifier_value == 'upload' ) {
|
223 |
|
224 |
+
$modifier_type = 'upload';
|
225 |
+
$action = 'upload';
|
226 |
|
227 |
+
// /media/pg/2/
|
228 |
+
} elseif ( $modifier_value == 'pg' ) {
|
229 |
|
230 |
+
//paginating default query
|
231 |
+
$modifier_type = 'pg';
|
232 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
+
// requesting by media type /media/photos | /media/videos/
|
235 |
+
$modifier_type = 'media_type';
|
236 |
+
}
|
237 |
+
}
|
238 |
|
|
|
239 |
|
|
|
240 |
|
241 |
+
if ( isset ( $raw_query[ 1 ] ) ) {
|
242 |
|
243 |
+
$second_modifier = $raw_query[ 1 ];
|
244 |
|
|
|
245 |
|
246 |
+
switch ( $modifier_type ) {
|
|
|
247 |
|
248 |
+
case 'nonce':
|
249 |
|
250 |
+
// /media/nonce/edit/ | /media/nonce/delete/
|
251 |
+
if ( array_key_exists ( $second_modifier, $this->actions ) ) {
|
252 |
|
253 |
+
$nonce_type = $second_modifier;
|
254 |
+
}
|
255 |
|
256 |
+
break;
|
257 |
|
258 |
+
case 'id':
|
259 |
|
260 |
+
// /media/23/edit/ | media/23/delete/ | /media/23/like/
|
261 |
+
if ( array_key_exists ( $second_modifier, $this->actions ) ) {
|
|
|
|
|
|
|
262 |
|
263 |
+
$action = $second_modifier;
|
264 |
+
} else if ( $second_modifier == "pg" ) {
|
265 |
+
if ( isset ( $raw_query[ 2 ] ) && is_numeric ( $raw_query[ 2 ] ) ) {
|
266 |
+
$pageno = $raw_query[ 2 ];
|
267 |
+
}
|
268 |
+
}
|
269 |
+
break;
|
270 |
|
271 |
+
case 'pg':
|
|
|
|
|
|
|
|
|
272 |
|
273 |
+
// /media/page/2/ | /media/page/3/
|
274 |
+
if ( is_numeric ( $second_modifier ) ) {
|
275 |
|
276 |
+
$pageno = $second_modifier;
|
277 |
+
}
|
278 |
+
break;
|
279 |
|
280 |
+
case 'media_type':
|
|
|
281 |
|
282 |
+
// /media/photos/edit/ | /media/videos/edit/
|
283 |
+
if ( array_key_exists ( $second_modifier, $this->actions ) ) {
|
|
|
|
|
|
|
|
|
284 |
|
285 |
+
$action = $second_modifier;
|
286 |
+
$bulk = true;
|
287 |
+
}
|
288 |
+
// /media/photos/page/2/
|
289 |
+
//elseif($second_modifier=='page'){
|
290 |
+
//$page = $second_modifier;
|
291 |
+
//pagination support
|
292 |
+
//}
|
293 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
+
default:
|
296 |
+
break;
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
//the third part of the query /media/modifier/second_modifier/{*}
|
301 |
+
|
302 |
+
if ( isset ( $raw_query[ 2 ] ) ) {
|
303 |
+
|
304 |
+
$third_modifier = $raw_query[ 2 ];
|
305 |
+
|
306 |
+
switch ( $modifier_type ) {
|
307 |
+
|
308 |
+
case 'nonce':
|
309 |
+
|
310 |
+
// leaving here for more granular nonce, in future, for eg,
|
311 |
+
// /media/nonce/edit/title/
|
312 |
+
|
313 |
+
break;
|
314 |
+
|
315 |
+
case 'id':
|
316 |
+
|
317 |
+
// leaving here for more granular editing, in future, for eg,
|
318 |
+
// /media/23/edit/title/
|
319 |
+
|
320 |
+
break;
|
321 |
+
|
322 |
+
case 'media_type':
|
323 |
+
|
324 |
+
// /media/photos/edit/ | /media/videos/edit/
|
325 |
+
// leaving here for more granular editing, in future, for eg,
|
326 |
+
// /media/photos/edit/title/
|
327 |
+
// /media/photos/page/2/
|
328 |
+
if ( $second_modifier == 'pg' && is_numeric ( $third_modifier ) ) {
|
329 |
+
|
330 |
+
$pageno = $third_modifier;
|
331 |
+
}
|
332 |
+
break;
|
333 |
+
|
334 |
+
case 'pg':
|
335 |
+
default:
|
336 |
+
break;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
global $rtmedia;
|
342 |
+
|
343 |
+
//if ( ! $rtmedia->get_option( 'media_end_point_enable' ) )
|
344 |
+
//include get_404_template();
|
345 |
+
|
346 |
+
/**
|
347 |
+
* set action query object
|
348 |
+
* setting parameters in action query object for pagination
|
349 |
+
*/
|
350 |
+
$per_page_media = intval ( $rtmedia->options[ 'general_perPageMedia' ] );
|
351 |
+
|
352 |
+
|
353 |
+
$this->action_query = ( object ) array(
|
354 |
+
$modifier_type => $modifier_value,
|
355 |
+
'action' => $action,
|
356 |
+
'bulk' => $bulk,
|
357 |
+
'page' => $pageno,
|
358 |
+
'per_page_media' => $per_page_media,
|
359 |
+
'attributes' => $attributes
|
360 |
+
);
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* additional actions to be added via action hook
|
365 |
+
*/
|
366 |
+
function set_actions () {
|
367 |
+
$this->actions = apply_filters ( 'rtmedia_query_actions', $this->actions );
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* get media query for the request
|
372 |
+
* @param type $query
|
373 |
+
* @return type
|
374 |
+
*/
|
375 |
+
function &query ( $query ) {
|
376 |
+
$this->original_query = $query;
|
377 |
+
$this->query = wp_parse_args ( $query, $this->query );
|
378 |
+
|
379 |
+
if ( isset ( $this->query ) && isset ( $this->query[ "global" ] ) && $this->query[ "global" ] == "true" ) {
|
380 |
+
if ( isset ( $this->query[ "context_id" ] ) )
|
381 |
+
unset ( $this->query[ "context_id" ] );
|
382 |
+
if ( isset ( $this->query[ "context" ] ) )
|
383 |
+
unset ( $this->query[ "context" ] );
|
384 |
+
if ( isset ( $this->query[ "album_id" ] ) )
|
385 |
+
unset ( $this->query[ "album_id" ] );
|
386 |
+
unset ( $this->query[ "global" ] );
|
387 |
+
}
|
388 |
+
$this->set_media_type ();
|
389 |
+
$this->media_query = $this->query;
|
390 |
+
return $this->get_data ();
|
391 |
+
}
|
392 |
+
|
393 |
+
function privacy_filter ( $where, $table_name ) {
|
394 |
+
$user = $this->get_user ();
|
395 |
+
|
396 |
+
$where .= " AND ({$table_name}.privacy is NULL OR {$table_name}.privacy=0";
|
397 |
+
if ( $user ) {
|
398 |
+
$where .= " OR ({$table_name}.privacy=20)";
|
399 |
+
$where .= " OR ({$table_name}.media_author={$user} AND {$table_name}.privacy>=40)";
|
400 |
+
if ( class_exists ( 'BuddyPress' ) ) {
|
401 |
+
if ( bp_is_active ( 'friends' ) ) {
|
402 |
+
$friends = $this->friendship->get_friends_cache ( $user );
|
403 |
+
$where .= " OR ({$table_name}.privacy=40 AND {$table_name}.media_author IN ('" . implode ( "','", $friends ) . "'))";
|
404 |
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
return $where . ')';
|
408 |
+
}
|
409 |
+
|
410 |
+
function get_user () {
|
411 |
+
if ( is_user_logged_in () ) {
|
412 |
+
$user = get_current_user_id ();
|
413 |
+
} else {
|
414 |
+
$user = 0;
|
415 |
+
}
|
416 |
+
return $user;
|
417 |
+
}
|
418 |
+
|
419 |
+
function set_privacy () {
|
420 |
+
$user = $this->get_user ();
|
421 |
+
if ( ! $user ) {
|
422 |
+
$privacy = 0;
|
423 |
+
} else {
|
424 |
+
$privacy = 20;
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
function populate_media () {
|
429 |
+
|
430 |
+
$this->set_privacy ();
|
431 |
+
if ( $this->is_single () )
|
432 |
+
$this->media_query[ 'id' ] = $this->action_query->id;
|
433 |
+
|
434 |
+
$allowed_media_types = array( );
|
435 |
+
|
436 |
+
// is this an album or some other media
|
437 |
+
$this->album_or_media ();
|
438 |
+
|
439 |
+
$order_by = $this->order_by ();
|
440 |
+
|
441 |
+
if ( isset ( $this->media_query[ 'context' ] ) ) {
|
442 |
+
|
443 |
+
if ( $this->media_query[ 'context' ] == 'profile' ) {
|
444 |
+
|
445 |
+
if ( ! $this->is_album_gallery () )
|
446 |
+
$this->media_query[ 'media_author' ] = $this->media_query[ 'context_id' ];
|
447 |
+
else
|
448 |
+
$author = $this->media_query[ 'context_id' ];
|
449 |
+
|
450 |
+
unset ( $this->media_query[ 'context' ] );
|
451 |
+
unset ( $this->media_query[ 'context_id' ] );
|
452 |
+
} else if ( $this->media_query[ 'context' ] == 'group' ) {
|
453 |
+
$group_id = $this->media_query[ 'context_id' ];
|
454 |
+
} else {
|
455 |
+
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
if ( $this->is_album_gallery () ) {
|
460 |
+
|
461 |
+
if ( isset ( $author ) ) {
|
462 |
+
$query_function = 'get_user_albums';
|
463 |
+
$context_id = $author;
|
464 |
+
} elseif ( isset ( $group_id ) ) {
|
465 |
+
$query_function = 'get_group_albums';
|
466 |
+
$context_id = $group_id;
|
467 |
+
}
|
468 |
+
|
469 |
+
if ( $order_by == ' ' )
|
470 |
+
$pre_media = $this->model->{$query_function} ( $context_id, ($this->action_query->page - 1) * $this->action_query->per_page_media, $this->action_query->per_page_media );
|
471 |
+
else
|
472 |
+
$pre_media = $this->model->{$query_function} ( $context_id, ($this->action_query->page - 1) * $this->action_query->per_page_media, $this->action_query->per_page_media, $order_by );
|
473 |
+
|
474 |
+
$media_for_total_count = $this->model->{$query_function} ( $context_id, false, false );
|
475 |
+
} else {
|
476 |
+
/**
|
477 |
+
* fetch media entries from rtMedia context
|
478 |
+
*/
|
479 |
+
if ( $order_by == ' ' )
|
480 |
+
$pre_media = $this->model->get_media ( $this->media_query, ($this->action_query->page - 1) * $this->action_query->per_page_media, $this->action_query->per_page_media );
|
481 |
+
else
|
482 |
+
$pre_media = $this->model->get_media ( $this->media_query, ($this->action_query->page - 1) * $this->action_query->per_page_media, $this->action_query->per_page_media, $order_by );
|
483 |
+
|
484 |
+
/**
|
485 |
+
* count total medias in album irrespective of pagination
|
486 |
+
*/
|
487 |
+
$media_for_total_count = $this->model->get_media ( $this->media_query, false, false );
|
488 |
+
}
|
489 |
+
|
490 |
+
$this->media_count = count ( $media_for_total_count );
|
491 |
+
|
492 |
+
if ( ! $pre_media )
|
493 |
+
return false;
|
494 |
+
else
|
495 |
+
return $pre_media;
|
496 |
+
|
497 |
+
/* removed because of indexing ---- 0,1,2 was required rather than post_ids
|
498 |
+
foreach ( $pre_media as $pre_medium ) {
|
499 |
+
$this->media[ $pre_medium->media_id ] = $pre_medium;
|
500 |
+
} */
|
501 |
+
}
|
502 |
+
|
503 |
+
function album_or_media () {
|
504 |
+
global $rtmedia;
|
505 |
+
foreach ( $rtmedia->allowed_types as $value ) {
|
506 |
+
$allowed_media_types[ ] = $value[ 'name' ];
|
507 |
+
}
|
508 |
+
|
509 |
+
if ( ! isset ( $this->media_query[ 'media_type' ] ) ) {
|
510 |
+
if ( isset ( $this->action_query->media_type ) &&
|
511 |
+
(
|
512 |
+
in_array ( $this->action_query->media_type, $allowed_media_types ) ||
|
513 |
+
$this->action_query->media_type == 'album'
|
514 |
+
)
|
515 |
+
) {
|
516 |
+
$this->media_query[ 'media_type' ] = $this->action_query->media_type;
|
517 |
+
} else {
|
518 |
+
$this->media_query[ 'media_type' ] = array( 'compare' => 'NOT IN', 'value' => array( 'album' ) );
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
|
523 |
+
function order_by () {
|
524 |
+
/**
|
525 |
+
* Handle order of the result set
|
526 |
+
*/
|
527 |
+
$order_by = '';
|
528 |
+
$order = '';
|
529 |
+
if ( isset ( $this->media_query[ 'order' ] ) ) {
|
530 |
+
$order = $this->media_query[ 'order' ];
|
531 |
+
unset ( $this->media_query[ 'order' ] );
|
532 |
+
}
|
533 |
+
|
534 |
+
if ( isset ( $this->media_query[ 'order_by' ] ) ) {
|
535 |
+
$order_by = $this->media_query[ 'order_by' ];
|
536 |
+
unset ( $this->media_query[ 'order_by' ] );
|
537 |
+
if ( $order_by == 'ratings' )
|
538 |
+
$order_by = 'ratings_average ' . $order . ', ratings_count';
|
539 |
+
}
|
540 |
+
$order_by .= ' ' . $order;
|
541 |
+
|
542 |
+
return $order_by = apply_filters ( 'rtmedia_model_order_by', $order_by );
|
543 |
+
}
|
544 |
+
|
545 |
+
function populate_album () {
|
546 |
+
$this->album = $this->media;
|
547 |
+
$this->media_query[ 'album_id' ] = $this->action_query->id;
|
548 |
+
unset ( $this->action_query->id );
|
549 |
+
unset ( $this->media_query[ 'id' ] );
|
550 |
+
unset ( $this->media_query[ 'media_type' ] );
|
551 |
+
return $this->populate_media ();
|
552 |
+
}
|
553 |
+
|
554 |
+
function populate_comments () {
|
555 |
+
|
556 |
+
$this->model = new RTMediaCommentModel();
|
557 |
+
global $rtmedia_interaction;
|
558 |
+
|
559 |
+
return $this->model->get ( array( 'post_id' => $rtmedia_interaction->context->id ) );
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* populate the data object for the page/album
|
564 |
+
*
|
565 |
+
* @return boolean
|
566 |
+
*/
|
567 |
+
function populate_data () {
|
568 |
+
unset ( $this->media_query->meta_query );
|
569 |
+
unset ( $this->media_query->tax_query );
|
570 |
+
$this->current_media = -1;
|
571 |
+
if ( $this->action_query->action == 'comments' && ! isset ( $this->action_query->id ) )
|
572 |
+
$this->media = $this->populate_comments ();
|
573 |
+
else
|
574 |
+
$this->media = $this->populate_media ();
|
575 |
+
|
576 |
+
if ( $this->is_album () ) {
|
577 |
+
$this->media = $this->populate_album ();
|
578 |
+
}
|
579 |
+
|
580 |
+
if ( empty ( $this->media ) )
|
581 |
+
return;
|
582 |
+
|
583 |
+
/**
|
584 |
+
* multiside manipulation
|
585 |
+
*/
|
586 |
+
if ( is_multisite () ) {
|
587 |
+
$blogs = array( );
|
588 |
+
foreach ( $this->media as $media ) {
|
589 |
+
$blogs[ $media->blog_id ][ ] = $media;
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
foreach ( $blogs as $blog_id => &$media ) {
|
594 |
+
switch_to_blog ( $blog_id );
|
595 |
+
if ( ! ($this->action_query->action == 'comments' && ! isset ( $this->action_query->id )) ) {
|
596 |
+
$this->populate_post_data ( $media );
|
597 |
+
wp_reset_query ();
|
598 |
+
}
|
599 |
+
}
|
600 |
+
restore_current_blog ();
|
601 |
+
} else {
|
602 |
+
if ( ! ($this->action_query->action == 'comments' && ! isset ( $this->action_query->id )) )
|
603 |
+
$this->populate_post_data ( $this->media );
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* helper method to fetch media id of each media from the map
|
609 |
+
* @param type $media
|
610 |
+
* @return type
|
611 |
+
*/
|
612 |
+
function get_media_id ( $media ) {
|
613 |
+
return $media->media_id;
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* helper method to find the array entry for the given media id
|
618 |
+
* @param type $id
|
619 |
+
* @return null
|
620 |
+
*/
|
621 |
+
function get_media_by_media_id ( $id ) {
|
622 |
+
|
623 |
+
foreach ( $this->media as $key => $media ) {
|
624 |
+
if ( $media->media_id == $id )
|
625 |
+
return $key;
|
626 |
+
}
|
627 |
+
return null;
|
628 |
+
}
|
629 |
+
|
630 |
+
/**
|
631 |
+
* populate the post data for the fetched media from rtMedia context
|
632 |
+
* @param type $media
|
633 |
+
*/
|
634 |
+
function populate_post_data ( $media ) {
|
635 |
+
if ( ! empty ( $media ) && is_array ( $media ) ) {
|
636 |
+
|
637 |
+
/**
|
638 |
+
* setting up query vars for WP_Query
|
639 |
+
*/
|
640 |
+
$media_post_query_args = array(
|
641 |
+
'orderby' => 'ID',
|
642 |
+
'order' => 'DESC',
|
643 |
+
'post_type' => 'any',
|
644 |
+
'post_status' => 'any',
|
645 |
+
'post__in' => array_map ( array( $this, 'get_media_id' ), $media ),
|
646 |
+
'ignore_sticky_posts' => 1,
|
647 |
+
'posts_per_page' => $this->action_query->per_page_media
|
648 |
+
);
|
649 |
+
|
650 |
+
/**
|
651 |
+
* setting up meta query vars
|
652 |
+
*/
|
653 |
+
if ( isset ( $this->query_vars->meta_query ) ) {
|
654 |
+
$media_post_query_args[ 'meta_query' ] = $this->query_vars->meta_query;
|
655 |
+
}
|
656 |
+
/**
|
657 |
+
* setting up taxonomy query vars
|
658 |
+
*/
|
659 |
+
if ( isset ( $this->query_vars->tax_query ) ) {
|
660 |
+
$media_post_query_args[ 'tax_query' ] = $this->query_vars->tax_query;
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* fetch relative data from WP_POST
|
665 |
+
*/
|
666 |
+
$media_post_query = new WP_Query ( $media_post_query_args );
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Merge the data with media object of the album
|
670 |
+
*/
|
671 |
+
$media_post_data = $media_post_query->posts;
|
672 |
+
|
673 |
+
foreach ( $media_post_data as $array_key => $post ) {
|
674 |
+
$key = $this->get_media_by_media_id ( $post->ID );
|
675 |
+
|
676 |
+
$this->media[ $key ] = ( object ) (array_merge ( ( array ) $this->media[ $key ], ( array ) $post ));
|
677 |
+
|
678 |
+
$this->media[ $key ]->id = intval ( $this->media[ $key ]->id );
|
679 |
+
|
680 |
+
unset ( $this->media[ $key ]->ID );
|
681 |
+
}
|
682 |
+
}
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Checks at any point of time any media is left to be processed in the db pool
|
687 |
+
* @return boolean
|
688 |
+
*/
|
689 |
+
function have_media () {
|
690 |
+
|
691 |
+
$total = $this->media_count;
|
692 |
+
$curr = $this->current_media;
|
693 |
+
$per_page = $this->action_query->per_page_media;
|
694 |
+
$offset = ($this->action_query->page - 1) * $this->action_query->per_page_media;
|
695 |
+
|
696 |
+
if ( $curr + 1 < $per_page && $total > $offset + $curr + 1 ) {
|
697 |
+
return true;
|
698 |
+
} elseif ( $curr + 1 == $per_page && $per_page > 0 ) {
|
699 |
+
do_action_ref_array ( 'rtmedia_loop_end', array( &$this ) );
|
700 |
+
// Do some cleaning up after the loop
|
701 |
+
$this->rewind_media ();
|
702 |
+
}
|
703 |
+
|
704 |
+
$this->in_the_media_loop = false;
|
705 |
+
return false;
|
706 |
+
}
|
707 |
+
|
708 |
+
/**
|
709 |
+
* moves ahead in the loop of media within the album
|
710 |
+
* @global type $rtmedia_media
|
711 |
+
*/
|
712 |
+
function rtmedia () {
|
713 |
+
global $rtmedia_media;
|
714 |
+
$this->in_the_media_loop = true;
|
715 |
+
|
716 |
+
if ( $this->current_media == -1 ) // loop has just started
|
717 |
+
do_action_ref_array ( 'rtmedia_loop_start', array( &$this ) );
|
718 |
+
|
719 |
+
return $rtmedia_media = $this->next_media ();
|
720 |
+
}
|
721 |
+
|
722 |
+
/**
|
723 |
+
* helper method for rt_album to move ahead in the db pool
|
724 |
+
* @return type
|
725 |
+
*/
|
726 |
+
function next_media () {
|
727 |
+
$this->current_media ++;
|
728 |
+
|
729 |
+
$this->rtmedia = $this->media[ $this->current_media ];
|
730 |
+
return $this->rtmedia;
|
731 |
+
}
|
732 |
+
|
733 |
+
function permalink () {
|
734 |
+
|
735 |
+
global $rtmedia_media;
|
736 |
+
$parent_link = '';
|
737 |
+
|
738 |
+
if ( function_exists ( 'bp_core_get_user_domain' ) ) {
|
739 |
+
$parent_link = bp_core_get_user_domain ( $rtmedia_media->media_author );
|
740 |
+
} else {
|
741 |
+
$parent_link = get_author_posts_url ( $rtmedia_media->media_author );
|
742 |
+
}
|
743 |
+
|
744 |
+
$link = trailingslashit ( $parent_link . 'media/' . $rtmedia_media->id );
|
745 |
+
|
746 |
+
return $link;
|
747 |
+
}
|
748 |
+
|
749 |
+
/**
|
750 |
+
* Rewinds the db pool of media album and resets it to begining
|
751 |
+
*/
|
752 |
+
function rewind_media () {
|
753 |
+
$this->current_media = -1;
|
754 |
+
if ( $this->action_query->per_page_media > 0 ) {
|
755 |
+
$this->media = $this->media[ 0 ];
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
/**
|
760 |
+
*
|
761 |
+
* @return type
|
762 |
+
*/
|
763 |
+
function &get_data () {
|
764 |
+
|
765 |
+
$this->populate_data ();
|
766 |
+
|
767 |
+
return $this->media;
|
768 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
|
770 |
}
|
771 |
|
app/services/RTMediaEncoding.php
CHANGED
@@ -10,94 +10,95 @@ class RTMediaEncoding {
|
|
10 |
protected $api_url = 'http://api.rtcamp.com/';
|
11 |
protected $sandbox_testing = 0;
|
12 |
protected $merchant_id = 'paypal@rtcamp.com';
|
13 |
-
public $uploaded = array();
|
14 |
-
public function __construct() {
|
15 |
-
$this->api_key = get_site_option('rtmedia-encoding-api-key');
|
16 |
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
// add_action('admin_init', array($this, 'encoding_settings'));
|
20 |
|
21 |
-
if ($this->api_key)
|
22 |
-
add_action('rtmedia_before_default_admin_widgets', array($this, 'usage_widget'));
|
23 |
}
|
24 |
|
25 |
-
add_action('admin_init', array($this, 'save_api_key'), 1);
|
26 |
-
|
27 |
-
if ($this->api_key) {
|
28 |
-
$usage_info = get_site_option('rtmedia-encoding-usage');
|
29 |
-
if ($usage_info) {
|
30 |
-
if (isset($usage_info[$this->api_key]->status) && $usage_info[$this->api_key]->status) {
|
31 |
-
if (isset($usage_info[$this->api_key]->remaining) && $usage_info[$this->api_key]->remaining > 0) {
|
32 |
-
if ($usage_info[$this->api_key]->remaining < 524288000 && !get_site_option('rtmedia-encoding-usage-limit-mail'))
|
33 |
-
$this->nearing_usage_limit($usage_info);
|
34 |
-
elseif ($usage_info[$this->api_key]->remaining > 524288000 && get_site_option('rtmedia-encoding-usage-limit-mail'))
|
35 |
-
update_site_option('rtmedia-encoding-usage-limit-mail', 0);
|
36 |
/**
|
37 |
* @todo update class_name
|
38 |
*/
|
39 |
-
if (!class_exists('RTMediaFFMPEG') && !class_exists('RTMediaKaltura'))
|
40 |
-
add_filter('rtmedia_after_add_media', array($this, 'encoding'), 10, 3);
|
41 |
-
$blacklist = array('localhost', '127.0.0.1');
|
42 |
-
if (!in_array($_SERVER['HTTP_HOST'], $blacklist)) {
|
43 |
-
add_filter('rtmedia_plupload_files_filter', array($this, 'allowed_types'));
|
44 |
-
add_filter('rtmedia_valid_type_check', array($this, 'bypass_video_audio'),'',2);
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
add_action('init', array($this, 'handle_callback'), 20);
|
52 |
-
add_action('wp_ajax_rtmedia_free_encoding_subscribe', array($this, 'free_encoding_subscribe'));
|
53 |
-
add_action('wp_ajax_rtmedia_unsubscribe_encoding_service', array($this, 'unsubscribe_encoding'));
|
54 |
-
add_action('wp_ajax_rtmedia_hide_encoding_notice', array($this, 'hide_encoding_notice'), 1);
|
55 |
-
add_action('wp_ajax_rtmedia_enter_api_key', array($this, 'enter_api_key'), 1);
|
56 |
-
add_action('wp_ajax_rtmedia_disable_encoding', array($this, 'disable_encoding'), 1);
|
57 |
}
|
58 |
|
59 |
-
function encoding($media_ids, $file_object, $uploaded) {
|
60 |
-
foreach ($file_object as $key => $single) {
|
61 |
-
if (preg_match('/video|audio/i', $single['type'], $type_array) && !in_array($single['type'], array('audio/mp3', 'video/mp4'))) {
|
62 |
|
63 |
-
$query_args = array('url' => urlencode($single['url']),
|
64 |
-
'callbackurl' => urlencode(home_url()),
|
65 |
'force' => 0,
|
66 |
-
'size' => filesize($single['file']),
|
67 |
-
'formats' => ($type_array[0] == 'video') ? 'mp4' : 'mp3');
|
68 |
$encoding_url = $this->api_url . 'job/new/';
|
69 |
-
$upload_url = add_query_arg($query_args, $encoding_url . $this->api_key);
|
70 |
-
$upload_page = wp_remote_get($upload_url, array('timeout' => 20));
|
71 |
|
72 |
-
if (!is_wp_error($upload_page) && (!isset($upload_page['headers']['status']) || (isset($upload_page['headers']['status']) && ($upload_page['headers']['status'] == 200)))) {
|
73 |
-
$upload_info = json_decode($upload_page['body']);
|
74 |
-
if (isset($upload_info->status) && $upload_info->status && isset($upload_info->job_id) && $upload_info->job_id) {
|
75 |
$job_id = $upload_info->job_id;
|
76 |
-
update_rtmedia_meta($media_ids[$key], 'rtmedia-encoding-job-id', $job_id);
|
77 |
} else {
|
78 |
// remove_filter('bp_media_plupload_files_filter', array($bp_media_admin->bp_media_encoding, 'allowed_types'));
|
79 |
// return parent::insertmedia($name, $description, $album_id, $group, $is_multiple, $is_activity, $parent_fallback_files, $author_id, $album_name);
|
80 |
}
|
81 |
}
|
82 |
-
$this->update_usage($this->api_key);
|
83 |
}
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
-
public function bypass_video_audio($flag
|
88 |
-
if ( isset($file['type']) ) {
|
89 |
-
$fileinfo = explode('/'
|
90 |
-
if (in_array($fileinfo[0],array('audio','video')))
|
91 |
-
|
92 |
}
|
93 |
return $flag;
|
94 |
}
|
95 |
|
96 |
-
public function is_valid_key($key) {
|
97 |
-
$validate_url = trailingslashit($this->api_url) . 'api/validate/' . $key;
|
98 |
-
$validation_page = wp_remote_get($validate_url, array('timeout' => 20));
|
99 |
-
if (!is_wp_error($validation_page)) {
|
100 |
-
$validation_info = json_decode($validation_page['body']);
|
101 |
$status = $validation_info->status;
|
102 |
} else {
|
103 |
$status = false;
|
@@ -105,89 +106,91 @@ class RTMediaEncoding {
|
|
105 |
return $status;
|
106 |
}
|
107 |
|
108 |
-
public function update_usage($key) {
|
109 |
-
$usage_url = trailingslashit($this->api_url) . 'api/usage/' . $key;
|
110 |
-
$usage_page = wp_remote_get($usage_url, array('timeout' => 20));
|
111 |
-
if (!is_wp_error($usage_page))
|
112 |
-
$usage_info = json_decode($usage_page['body']);
|
113 |
else
|
114 |
$usage_info = NULL;
|
115 |
-
update_site_option('rtmedia-encoding-usage', array($key => $usage_info));
|
116 |
return $usage_info;
|
117 |
}
|
118 |
|
119 |
-
public function nearing_usage_limit($usage_details) {
|
120 |
-
$subject = __('rtMedia Encoding: Nearing quota limit.', 'rtmedia');
|
121 |
-
$message = __('<p>You are nearing the quota limit for your rtMedia encoding service.</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'rtmedia');
|
122 |
-
$users = get_users(array('role' => 'administrator'));
|
123 |
-
if ($users) {
|
124 |
-
foreach ($users as $user)
|
125 |
-
$admin_email_ids[] = $user->user_email;
|
126 |
-
add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
|
127 |
-
wp_mail($admin_email_ids, $subject, sprintf($message, size_format($usage_details[$this->api_key]->used, 2), size_format($usage_details[$this->api_key]->remaining, 2), size_format($usage_details[$this->api_key]->total, 2)));
|
128 |
}
|
129 |
-
update_site_option('rtmedia-encoding-usage-limit-mail', 1);
|
130 |
}
|
131 |
|
132 |
-
public function usage_quota_over() {
|
133 |
-
$usage_details = get_site_option('rtmedia-encoding-usage');
|
134 |
-
if (
|
135 |
-
$subject = __('rtMedia Encoding: Usage quota over.', 'rtmedia');
|
136 |
-
$message = __('<p>Your usage quota is over. Upgrade your plan</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'rtmedia');
|
137 |
-
$users = get_users(array('role' => 'administrator'));
|
138 |
-
if ($users) {
|
139 |
-
foreach ($users as $user)
|
140 |
-
$admin_email_ids[] = $user->user_email;
|
141 |
-
add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
|
142 |
-
wp_mail($admin_email_ids, $subject, sprintf($message, size_format($usage_details[$this->api_key]->used, 2), 0, size_format($usage_details[$this->api_key]->total, 2)));
|
143 |
}
|
144 |
-
update_site_option('rtmedia-encoding-usage-limit-mail', 1);
|
145 |
}
|
146 |
}
|
147 |
|
148 |
-
public function save_api_key() {
|
149 |
-
if (isset($_GET['api_key_updated']) && $_GET['api_key_updated']) {
|
150 |
-
if (is_multisite()) {
|
151 |
-
add_action('network_admin_notices', array($this, 'successfully_subscribed_notice'));
|
152 |
}
|
153 |
-
add_action('admin_notices', array($this, 'successfully_subscribed_notice'));
|
154 |
}
|
155 |
-
if (isset($_GET['apikey']) && is_admin() && isset($_GET['page']) && ($_GET['page'] == 'rtmedia-addons') && $this->is_valid_key($_GET['apikey'])) {
|
156 |
-
if ($this->api_key && !(isset($_GET['update']) && $_GET['update'])) {
|
157 |
-
$unsubscribe_url = trailingslashit($this->api_url) . 'api/cancel/' . $this->api_key;
|
158 |
-
wp_remote_post($unsubscribe_url, array('timeout' => 120, 'body' => array('note' => 'Direct URL Input (API Key: ' . $_GET['apikey'] . ')')));
|
159 |
}
|
160 |
-
update_site_option('rtmedia-encoding-api-key', $_GET['apikey']);
|
161 |
-
$usage_info = $this->update_usage($_GET['apikey']);
|
162 |
-
$return_page = add_query_arg(array('page' => 'rtmedia-addons', 'api_key_updated' => $usage_info->plan->name), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php')));
|
163 |
-
wp_safe_redirect($return_page);
|
164 |
}
|
165 |
}
|
166 |
|
167 |
-
public function allowed_types($types) {
|
168 |
-
if (isset($types[0]) && isset($types[0]['extensions'])) {
|
169 |
-
|
170 |
-
|
|
|
|
|
171 |
}
|
172 |
return $types;
|
173 |
}
|
174 |
|
175 |
-
public function successfully_subscribed_notice() {
|
176 |
?>
|
177 |
<div class="updated">
|
178 |
-
<p><?php printf(__('You have successfully subscribed for the <strong>%s</strong> plan', 'rtmedia'), $_GET['api_key_updated']); ?></p>
|
179 |
</div><?php
|
180 |
}
|
181 |
|
182 |
-
public function encoding_subscription_form($name = 'No Name', $price = '0', $force = false) {
|
183 |
-
if ($this->api_key)
|
184 |
-
$this->update_usage($this->api_key);
|
185 |
$action = $this->sandbox_testing ? 'https://sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
|
186 |
-
$return_page = add_query_arg(array('page' => 'rtmedia-addons'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php')));
|
187 |
|
188 |
-
$usage_details = get_site_option('rtmedia-encoding-usage');
|
189 |
-
if (isset($usage_details[$this->api_key]->plan->name) && (strtolower($usage_details[$this->api_key]->plan->name) == strtolower($name)) && $usage_details[$this->api_key]->sub_status &&
|
190 |
-
$form = '<button data-plan="' . $name . '" data-price="' . $price . '" type="submit" class="button bpm-unsubscribe">' . __('Unsubscribe', 'rtmedia') . '</button>';
|
191 |
$form .= '<div id="bpm-unsubscribe-dialog" title="Unsubscribe">
|
192 |
<p>Just to improve our service we would like to know the reason for you to leave us.</p>
|
193 |
<p><textarea rows="3" cols="36" id="bpm-unsubscribe-note"></textarea></p>
|
@@ -195,7 +198,7 @@ class RTMediaEncoding {
|
|
195 |
} else {
|
196 |
$form = '<form method="post" action="' . $action . '" class="paypal-button" target="_top">
|
197 |
<input type="hidden" name="button" value="subscribe">
|
198 |
-
<input type="hidden" name="item_name" value="' . ucfirst($name) . '">
|
199 |
|
200 |
<input type="hidden" name="currency_code" value="USD">
|
201 |
|
@@ -215,10 +218,10 @@ class RTMediaEncoding {
|
|
215 |
<!-- Flag to no shipping -->
|
216 |
<input type="hidden" name="no_shipping" value="1">
|
217 |
|
218 |
-
<input type="hidden" name="notify_url" value="' . trailingslashit($this->api_url) . 'subscribe/paypal">
|
219 |
|
220 |
<!-- Flag to post payment return url -->
|
221 |
-
<input type="hidden" name="return" value="' . trailingslashit($this->api_url) . 'payment/process">
|
222 |
|
223 |
|
224 |
<!-- Flag to post payment data to given return url -->
|
@@ -233,297 +236,296 @@ class RTMediaEncoding {
|
|
233 |
return $form;
|
234 |
}
|
235 |
|
236 |
-
public function usage_widget() {
|
237 |
-
$usage_details = get_site_option('rtmedia-encoding-usage');
|
238 |
$content = '';
|
239 |
-
if ($usage_details && isset($usage_details[$this->api_key]->status) && $usage_details[$this->api_key]->status) {
|
240 |
-
if (isset($usage_details[$this->api_key]->plan->name))
|
241 |
-
$content .= '<p><strong>' . __('Current Plan', 'rtmedia') . ':</strong> ' . $usage_details[$this->api_key]->plan->name . ($usage_details[$this->api_key]->sub_status ? '' : ' (' . __('Unsubscribed', 'rtmedia') . ')') . '</p>';
|
242 |
-
if (isset($usage_details[$this->api_key]->used))
|
243 |
-
$content .= '<p><span class="encoding-used"></span><strong>' . __('Used', 'rtmedia') . ':</strong> ' . (($used_size = size_format($usage_details[$this->api_key]->used, 2)) ? $used_size : '0MB') . '</p>';
|
244 |
-
if (isset($usage_details[$this->api_key]->remaining))
|
245 |
-
$content .= '<p><span class="encoding-remaining"></span><strong>' . __('Remaining', 'rtmedia') . ':</strong> ' . (($remaining_size = size_format($usage_details[$this->api_key]->remaining, 2)) ? $remaining_size : '0MB') . '</p>';
|
246 |
-
if (isset($usage_details[$this->api_key]->total))
|
247 |
-
$content .= '<p><strong>' . __('Total', 'rtmedia') . ':</strong> ' . size_format($usage_details[$this->api_key]->total, 2) . '</p>';
|
248 |
$usage = new rtProgress();
|
249 |
-
$content .= $usage->progress_ui($usage->progress($usage_details[$this->api_key]->used, $usage_details[$this->api_key]->total), false);
|
250 |
-
if ($usage_details[$this->api_key]->remaining <= 0)
|
251 |
-
$content .= '<div class="error below-h2"><p>' . __('Your usage limit has been reached. Upgrade your plan.', 'rtmedia') . '</p></div>';
|
252 |
} else {
|
253 |
-
$content .= '<div class="error below-h2"><p>' . __('Your API key is not valid or is expired.', 'rtmedia') . '</p></div>';
|
254 |
}
|
255 |
-
new RTMediaAdminWidget('rtmedia-encoding-usage', __('Encoding Usage', 'rtmedia'), $content);
|
256 |
}
|
257 |
|
258 |
-
public function encoding_service_intro() {
|
259 |
?>
|
260 |
-
<p><?php _e('rtMedia team has started offering an audio/video encoding service.', 'rtmedia'); ?></p>
|
261 |
<p>
|
262 |
-
<label for="new-api-key"><?php _e('Enter API KEY', 'rtmedia'); ?></label>
|
263 |
<input id="new-api-key" type="text" name="new-api-key" value="<?php echo $this->api_key; ?>" size="60" />
|
264 |
-
<input type="submit" id="api-key-submit" name="api-key-submit" value="<?php echo __('Submit', 'rtmedia'); ?>" class="button-primary" />
|
265 |
-
<?php if ($this->api_key) { ?><br /><br /><input type="submit" id="disable-encoding" name="disable-encoding" value="Disable Encoding" class="button-secondary" /><?php } ?>
|
266 |
</p>
|
267 |
<table class="bp-media-encoding-table widefat fixed" cellspacing="0">
|
268 |
<tbody>
|
269 |
<!-- Results table headers -->
|
270 |
<thead>
|
271 |
<tr>
|
272 |
-
<th><?php _e('Feature\Plan', 'rtmedia'); ?></th>
|
273 |
-
<th><?php _e('Free', 'rtmedia'); ?></th>
|
274 |
-
<th><?php _e('Silver', 'rtmedia'); ?></th>
|
275 |
-
<th><?php _e('Gold', 'rtmedia'); ?></th>
|
276 |
-
<th><?php _e('Platinum', 'rtmedia'); ?></th>
|
277 |
</tr>
|
278 |
</thead>
|
279 |
<tr>
|
280 |
-
<th><?php _e('File Size Limit', 'rtmedia'); ?></th>
|
281 |
<td>200MB (<del>20MB</del>)</td>
|
282 |
<td colspan="3" class="column-posts">16GB (<del>2GB</del>)</td>
|
283 |
</tr>
|
284 |
<tr>
|
285 |
-
<th><?php _e('Bandwidth (monthly)', 'rtmedia'); ?></th>
|
286 |
<td>10GB (<del>1GB</del>)</td>
|
287 |
<td>100GB</td>
|
288 |
<td>1TB</td>
|
289 |
<td>10TB</td>
|
290 |
</tr>
|
291 |
<tr>
|
292 |
-
<th><?php _e('Overage Bandwidth', 'rtmedia'); ?></th>
|
293 |
-
<td><?php _e('Not Available', 'rtmedia'); ?></td>
|
294 |
<td>$0.10 per GB</td>
|
295 |
<td>$0.08 per GB</td>
|
296 |
<td>$0.05 per GB</td>
|
297 |
</tr>
|
298 |
<tr>
|
299 |
-
<th><?php _e('Amazon S3 Support', 'rtmedia'); ?></th>
|
300 |
-
<td><?php _e('Not Available', 'rtmedia'); ?></td>
|
301 |
-
<td colspan="3" class="column-posts"><?php _e('Coming Soon', 'rtmedia'); ?></td>
|
302 |
</tr>
|
303 |
<tr>
|
304 |
-
<th><?php _e('HD Profile', 'rtmedia'); ?></th>
|
305 |
-
<td><?php _e('Not Available', 'rtmedia'); ?></td>
|
306 |
-
<td colspan="3" class="column-posts"><?php _e('Coming Soon', 'rtmedia'); ?></td>
|
307 |
</tr>
|
308 |
<tr>
|
309 |
-
<th><?php _e('Webcam Recording', 'rtmedia'); ?></th>
|
310 |
-
<td colspan="4" class="column-posts"><?php _e('Coming Soon', 'rtmedia'); ?></td>
|
311 |
</tr>
|
312 |
<tr>
|
313 |
-
<th><?php _e('Pricing', 'rtmedia'); ?></th>
|
314 |
-
<td><?php _e('Free', 'rtmedia'); ?></td>
|
315 |
-
<td><?php _e('$9/month', 'rtmedia'); ?></td>
|
316 |
-
<td><?php _e('$99/month', 'rtmedia'); ?></td>
|
317 |
-
<td><?php _e('$999/month', 'rtmedia'); ?></td>
|
318 |
</tr>
|
319 |
<tr>
|
320 |
<th></th>
|
321 |
<td><?php
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
<form id="encoding-try-now-form" method="get" action="">
|
328 |
-
<button type="submit" class="encoding-try-now button button-primary"><?php _e('Try Now', 'rtmedia'); ?></button>
|
329 |
</form><?php }
|
330 |
-
|
331 |
</td>
|
332 |
-
<td><?php echo $this->encoding_subscription_form('silver', 9.0) ?></td>
|
333 |
-
<td><?php echo $this->encoding_subscription_form('gold', 99.0) ?></td>
|
334 |
-
<td><?php echo $this->encoding_subscription_form('platinum', 999.0) ?></td>
|
335 |
</tr>
|
336 |
</tbody>
|
337 |
</table><br /><?php
|
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 |
// $media_entry = new BPMediaHostWordpress($attachment_id);
|
378 |
// $activity_content = str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $media_entry->get_media_activity_content());
|
379 |
// $wpdb->update($wpdb->prefix . 'bp_activity', array('content' => $activity_content), array('id' => $media[0]->activity_id));
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
}
|
388 |
-
} else {
|
389 |
-
$flag = __('Could not read file.', 'rtmedia');
|
390 |
-
error_log($flag);
|
391 |
}
|
392 |
} else {
|
393 |
-
$flag = __('
|
394 |
-
error_log($flag);
|
395 |
}
|
|
|
|
|
|
|
|
|
396 |
|
397 |
|
398 |
-
|
399 |
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
<p><code>%s</code></p>
|
411 |
-
<p>You can <a href="%s">retry the download</a>.</p>', 'rtmedia'), get_edit_post_link($attachment_id), $flag, $download_link);
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
}
|
419 |
-
_e($flag);
|
420 |
-
} elseif ($flag) {
|
421 |
-
_e($flag);
|
422 |
-
} else {
|
423 |
-
_e("Done", 'rtmedia');
|
424 |
}
|
425 |
-
|
|
|
|
|
|
|
|
|
426 |
}
|
|
|
427 |
}
|
|
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
} else {
|
445 |
-
echo json_encode(array('error' => $subscription_info->message));
|
446 |
-
}
|
447 |
} else {
|
448 |
-
echo json_encode(array('error' =>
|
449 |
}
|
|
|
|
|
450 |
}
|
451 |
-
die();
|
452 |
}
|
|
|
|
|
453 |
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
}
|
469 |
-
} else {
|
470 |
-
echo json_encode(array('error' => __('Something went wrong please try again.', 'rtmedia')));
|
471 |
}
|
472 |
-
|
|
|
473 |
}
|
|
|
|
|
474 |
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
}
|
481 |
-
die();
|
482 |
}
|
|
|
|
|
483 |
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
} else {
|
498 |
-
$rtmedia_upload_prefix = 'groups/';
|
499 |
-
$id = $this->uploaded["context_id"];
|
500 |
-
}
|
501 |
} else {
|
502 |
-
|
503 |
-
|
504 |
-
$id = $this->uploaded["media_author"];
|
505 |
-
} else {
|
506 |
-
$rtmedia_upload_prefix = 'groups/';
|
507 |
-
$id = $rtmedia_interaction->context->id;
|
508 |
-
}
|
509 |
}
|
510 |
-
|
511 |
-
if (
|
512 |
-
$
|
|
|
|
|
|
|
|
|
513 |
}
|
|
|
514 |
|
|
|
|
|
|
|
515 |
|
516 |
-
$upload_dir['path'] = trailingslashit(
|
517 |
-
str_replace($upload_dir['subdir'], '', $upload_dir['path']))
|
518 |
-
. 'rtMedia/' . $rtmedia_upload_prefix . $id .
|
519 |
-
$upload_dir['subdir'];
|
520 |
-
$upload_dir['url'] = trailingslashit(
|
521 |
-
str_replace($upload_dir['subdir'], '', $upload_dir['url']))
|
522 |
-
. 'rtMedia/' . $rtmedia_upload_prefix . $id
|
523 |
-
. $upload_dir['subdir'];
|
524 |
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
|
|
|
528 |
}
|
529 |
-
|
|
|
|
10 |
protected $api_url = 'http://api.rtcamp.com/';
|
11 |
protected $sandbox_testing = 0;
|
12 |
protected $merchant_id = 'paypal@rtcamp.com';
|
13 |
+
public $uploaded = array( );
|
|
|
|
|
14 |
|
15 |
+
public function __construct () {
|
16 |
+
$this->api_key = get_site_option ( 'rtmedia-encoding-api-key' );
|
17 |
+
|
18 |
+
if ( is_admin () ) {
|
19 |
|
20 |
// add_action('admin_init', array($this, 'encoding_settings'));
|
21 |
|
22 |
+
if ( $this->api_key )
|
23 |
+
add_action ( 'rtmedia_before_default_admin_widgets', array( $this, 'usage_widget' ) );
|
24 |
}
|
25 |
|
26 |
+
add_action ( 'admin_init', array( $this, 'save_api_key' ), 1 );
|
27 |
+
|
28 |
+
if ( $this->api_key ) {
|
29 |
+
$usage_info = get_site_option ( 'rtmedia-encoding-usage' );
|
30 |
+
if ( $usage_info ) {
|
31 |
+
if ( isset ( $usage_info[ $this->api_key ]->status ) && $usage_info[ $this->api_key ]->status ) {
|
32 |
+
if ( isset ( $usage_info[ $this->api_key ]->remaining ) && $usage_info[ $this->api_key ]->remaining > 0 ) {
|
33 |
+
if ( $usage_info[ $this->api_key ]->remaining < 524288000 && ! get_site_option ( 'rtmedia-encoding-usage-limit-mail' ) )
|
34 |
+
$this->nearing_usage_limit ( $usage_info );
|
35 |
+
elseif ( $usage_info[ $this->api_key ]->remaining > 524288000 && get_site_option ( 'rtmedia-encoding-usage-limit-mail' ) )
|
36 |
+
update_site_option ( 'rtmedia-encoding-usage-limit-mail', 0 );
|
37 |
/**
|
38 |
* @todo update class_name
|
39 |
*/
|
40 |
+
if ( ! class_exists ( 'RTMediaFFMPEG' ) && ! class_exists ( 'RTMediaKaltura' ) )
|
41 |
+
add_filter ( 'rtmedia_after_add_media', array( $this, 'encoding' ), 10, 3 );
|
42 |
+
$blacklist = array( 'localhost', '127.0.0.1' );
|
43 |
+
if ( ! in_array ( $_SERVER[ 'HTTP_HOST' ], $blacklist ) ) {
|
44 |
+
add_filter ( 'rtmedia_plupload_files_filter', array( $this, 'allowed_types' ) );
|
45 |
+
add_filter ( 'rtmedia_valid_type_check', array( $this, 'bypass_video_audio' ), '', 2 );
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
add_action ( 'init', array( $this, 'handle_callback' ), 20 );
|
53 |
+
add_action ( 'wp_ajax_rtmedia_free_encoding_subscribe', array( $this, 'free_encoding_subscribe' ) );
|
54 |
+
add_action ( 'wp_ajax_rtmedia_unsubscribe_encoding_service', array( $this, 'unsubscribe_encoding' ) );
|
55 |
+
add_action ( 'wp_ajax_rtmedia_hide_encoding_notice', array( $this, 'hide_encoding_notice' ), 1 );
|
56 |
+
add_action ( 'wp_ajax_rtmedia_enter_api_key', array( $this, 'enter_api_key' ), 1 );
|
57 |
+
add_action ( 'wp_ajax_rtmedia_disable_encoding', array( $this, 'disable_encoding' ), 1 );
|
58 |
}
|
59 |
|
60 |
+
function encoding ( $media_ids, $file_object, $uploaded ) {
|
61 |
+
foreach ( $file_object as $key => $single ) {
|
62 |
+
if ( preg_match ( '/video|audio/i', $single[ 'type' ], $type_array ) && ! in_array ( $single[ 'type' ], array( 'audio/mp3', 'video/mp4' ) ) ) {
|
63 |
|
64 |
+
$query_args = array( 'url' => urlencode ( $single[ 'url' ] ),
|
65 |
+
'callbackurl' => urlencode ( home_url () ),
|
66 |
'force' => 0,
|
67 |
+
'size' => filesize ( $single[ 'file' ] ),
|
68 |
+
'formats' => ($type_array[ 0 ] == 'video') ? 'mp4' : 'mp3' );
|
69 |
$encoding_url = $this->api_url . 'job/new/';
|
70 |
+
$upload_url = add_query_arg ( $query_args, $encoding_url . $this->api_key );
|
71 |
+
$upload_page = wp_remote_get ( $upload_url, array( 'timeout' => 20 ) );
|
72 |
|
73 |
+
if ( ! is_wp_error ( $upload_page ) && ( ! isset ( $upload_page[ 'headers' ][ 'status' ] ) || (isset ( $upload_page[ 'headers' ][ 'status' ] ) && ($upload_page[ 'headers' ][ 'status' ] == 200))) ) {
|
74 |
+
$upload_info = json_decode ( $upload_page[ 'body' ] );
|
75 |
+
if ( isset ( $upload_info->status ) && $upload_info->status && isset ( $upload_info->job_id ) && $upload_info->job_id ) {
|
76 |
$job_id = $upload_info->job_id;
|
77 |
+
update_rtmedia_meta ( $media_ids[ $key ], 'rtmedia-encoding-job-id', $job_id );
|
78 |
} else {
|
79 |
// remove_filter('bp_media_plupload_files_filter', array($bp_media_admin->bp_media_encoding, 'allowed_types'));
|
80 |
// return parent::insertmedia($name, $description, $album_id, $group, $is_multiple, $is_activity, $parent_fallback_files, $author_id, $album_name);
|
81 |
}
|
82 |
}
|
83 |
+
$this->update_usage ( $this->api_key );
|
84 |
}
|
85 |
}
|
86 |
}
|
87 |
+
|
88 |
+
public function bypass_video_audio ( $flag, $file ) {
|
89 |
+
if ( isset ( $file[ 'type' ] ) ) {
|
90 |
+
$fileinfo = explode ( '/', $file[ 'type' ] );
|
91 |
+
if ( in_array ( $fileinfo[ 0 ], array( 'audio', 'video' ) ) )
|
92 |
+
$flag = true;
|
93 |
}
|
94 |
return $flag;
|
95 |
}
|
96 |
|
97 |
+
public function is_valid_key ( $key ) {
|
98 |
+
$validate_url = trailingslashit ( $this->api_url ) . 'api/validate/' . $key;
|
99 |
+
$validation_page = wp_remote_get ( $validate_url, array( 'timeout' => 20 ) );
|
100 |
+
if ( ! is_wp_error ( $validation_page ) ) {
|
101 |
+
$validation_info = json_decode ( $validation_page[ 'body' ] );
|
102 |
$status = $validation_info->status;
|
103 |
} else {
|
104 |
$status = false;
|
106 |
return $status;
|
107 |
}
|
108 |
|
109 |
+
public function update_usage ( $key ) {
|
110 |
+
$usage_url = trailingslashit ( $this->api_url ) . 'api/usage/' . $key;
|
111 |
+
$usage_page = wp_remote_get ( $usage_url, array( 'timeout' => 20 ) );
|
112 |
+
if ( ! is_wp_error ( $usage_page ) )
|
113 |
+
$usage_info = json_decode ( $usage_page[ 'body' ] );
|
114 |
else
|
115 |
$usage_info = NULL;
|
116 |
+
update_site_option ( 'rtmedia-encoding-usage', array( $key => $usage_info ) );
|
117 |
return $usage_info;
|
118 |
}
|
119 |
|
120 |
+
public function nearing_usage_limit ( $usage_details ) {
|
121 |
+
$subject = __ ( 'rtMedia Encoding: Nearing quota limit.', 'rtmedia' );
|
122 |
+
$message = __ ( '<p>You are nearing the quota limit for your rtMedia encoding service.</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'rtmedia' );
|
123 |
+
$users = get_users ( array( 'role' => 'administrator' ) );
|
124 |
+
if ( $users ) {
|
125 |
+
foreach ( $users as $user )
|
126 |
+
$admin_email_ids[ ] = $user->user_email;
|
127 |
+
add_filter ( 'wp_mail_content_type', create_function ( '', 'return "text/html";' ) );
|
128 |
+
wp_mail ( $admin_email_ids, $subject, sprintf ( $message, size_format ( $usage_details[ $this->api_key ]->used, 2 ), size_format ( $usage_details[ $this->api_key ]->remaining, 2 ), size_format ( $usage_details[ $this->api_key ]->total, 2 ) ) );
|
129 |
}
|
130 |
+
update_site_option ( 'rtmedia-encoding-usage-limit-mail', 1 );
|
131 |
}
|
132 |
|
133 |
+
public function usage_quota_over () {
|
134 |
+
$usage_details = get_site_option ( 'rtmedia-encoding-usage' );
|
135 |
+
if ( ! $usage_details[ $this->api_key ]->remaining ) {
|
136 |
+
$subject = __ ( 'rtMedia Encoding: Usage quota over.', 'rtmedia' );
|
137 |
+
$message = __ ( '<p>Your usage quota is over. Upgrade your plan</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'rtmedia' );
|
138 |
+
$users = get_users ( array( 'role' => 'administrator' ) );
|
139 |
+
if ( $users ) {
|
140 |
+
foreach ( $users as $user )
|
141 |
+
$admin_email_ids[ ] = $user->user_email;
|
142 |
+
add_filter ( 'wp_mail_content_type', create_function ( '', 'return "text/html";' ) );
|
143 |
+
wp_mail ( $admin_email_ids, $subject, sprintf ( $message, size_format ( $usage_details[ $this->api_key ]->used, 2 ), 0, size_format ( $usage_details[ $this->api_key ]->total, 2 ) ) );
|
144 |
}
|
145 |
+
update_site_option ( 'rtmedia-encoding-usage-limit-mail', 1 );
|
146 |
}
|
147 |
}
|
148 |
|
149 |
+
public function save_api_key () {
|
150 |
+
if ( isset ( $_GET[ 'api_key_updated' ] ) && $_GET[ 'api_key_updated' ] ) {
|
151 |
+
if ( is_multisite () ) {
|
152 |
+
add_action ( 'network_admin_notices', array( $this, 'successfully_subscribed_notice' ) );
|
153 |
}
|
154 |
+
add_action ( 'admin_notices', array( $this, 'successfully_subscribed_notice' ) );
|
155 |
}
|
156 |
+
if ( isset ( $_GET[ 'apikey' ] ) && is_admin () && isset ( $_GET[ 'page' ] ) && ($_GET[ 'page' ] == 'rtmedia-addons') && $this->is_valid_key ( $_GET[ 'apikey' ] ) ) {
|
157 |
+
if ( $this->api_key && ! (isset ( $_GET[ 'update' ] ) && $_GET[ 'update' ]) ) {
|
158 |
+
$unsubscribe_url = trailingslashit ( $this->api_url ) . 'api/cancel/' . $this->api_key;
|
159 |
+
wp_remote_post ( $unsubscribe_url, array( 'timeout' => 120, 'body' => array( 'note' => 'Direct URL Input (API Key: ' . $_GET[ 'apikey' ] . ')' ) ) );
|
160 |
}
|
161 |
+
update_site_option ( 'rtmedia-encoding-api-key', $_GET[ 'apikey' ] );
|
162 |
+
$usage_info = $this->update_usage ( $_GET[ 'apikey' ] );
|
163 |
+
$return_page = add_query_arg ( array( 'page' => 'rtmedia-addons', 'api_key_updated' => $usage_info->plan->name ), (is_multisite () ? network_admin_url ( 'admin.php' ) : admin_url ( 'admin.php' ) ) );
|
164 |
+
wp_safe_redirect ( $return_page );
|
165 |
}
|
166 |
}
|
167 |
|
168 |
+
public function allowed_types ( $types ) {
|
169 |
+
if ( isset ( $types[ 0 ] ) && isset ( $types[ 0 ][ 'extensions' ] ) ) {
|
170 |
+
if ( is_rtmedia_upload_video_enabled () )
|
171 |
+
$types[ 0 ][ 'extensions' ] .= ',mov,m4v,m2v,avi,mpg,flv,wmv,mkv,webm,ogv,mxf,asf,vob,mts,qt,mpeg,x-msvideo'; //Allow all types of file to be uploded
|
172 |
+
if ( is_rtmedia_upload_music_enabled () )
|
173 |
+
$types[ 0 ][ 'extensions' ] .= ',wma,ogg,wav,m4a'; //Allow all types of file to be uploded
|
174 |
}
|
175 |
return $types;
|
176 |
}
|
177 |
|
178 |
+
public function successfully_subscribed_notice () {
|
179 |
?>
|
180 |
<div class="updated">
|
181 |
+
<p><?php printf ( __ ( 'You have successfully subscribed for the <strong>%s</strong> plan', 'rtmedia' ), $_GET[ 'api_key_updated' ] ); ?></p>
|
182 |
</div><?php
|
183 |
}
|
184 |
|
185 |
+
public function encoding_subscription_form ( $name = 'No Name', $price = '0', $force = false ) {
|
186 |
+
if ( $this->api_key )
|
187 |
+
$this->update_usage ( $this->api_key );
|
188 |
$action = $this->sandbox_testing ? 'https://sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
|
189 |
+
$return_page = add_query_arg ( array( 'page' => 'rtmedia-addons' ), (is_multisite () ? network_admin_url ( 'admin.php' ) : admin_url ( 'admin.php' ) ) );
|
190 |
|
191 |
+
$usage_details = get_site_option ( 'rtmedia-encoding-usage' );
|
192 |
+
if ( isset ( $usage_details[ $this->api_key ]->plan->name ) && (strtolower ( $usage_details[ $this->api_key ]->plan->name ) == strtolower ( $name )) && $usage_details[ $this->api_key ]->sub_status && ! $force ) {
|
193 |
+
$form = '<button data-plan="' . $name . '" data-price="' . $price . '" type="submit" class="button bpm-unsubscribe">' . __ ( 'Unsubscribe', 'rtmedia' ) . '</button>';
|
194 |
$form .= '<div id="bpm-unsubscribe-dialog" title="Unsubscribe">
|
195 |
<p>Just to improve our service we would like to know the reason for you to leave us.</p>
|
196 |
<p><textarea rows="3" cols="36" id="bpm-unsubscribe-note"></textarea></p>
|
198 |
} else {
|
199 |
$form = '<form method="post" action="' . $action . '" class="paypal-button" target="_top">
|
200 |
<input type="hidden" name="button" value="subscribe">
|
201 |
+
<input type="hidden" name="item_name" value="' . ucfirst ( $name ) . '">
|
202 |
|
203 |
<input type="hidden" name="currency_code" value="USD">
|
204 |
|
218 |
<!-- Flag to no shipping -->
|
219 |
<input type="hidden" name="no_shipping" value="1">
|
220 |
|
221 |
+
<input type="hidden" name="notify_url" value="' . trailingslashit ( $this->api_url ) . 'subscribe/paypal">
|
222 |
|
223 |
<!-- Flag to post payment return url -->
|
224 |
+
<input type="hidden" name="return" value="' . trailingslashit ( $this->api_url ) . 'payment/process">
|
225 |
|
226 |
|
227 |
<!-- Flag to post payment data to given return url -->
|
236 |
return $form;
|
237 |
}
|
238 |
|
239 |
+
public function usage_widget () {
|
240 |
+
$usage_details = get_site_option ( 'rtmedia-encoding-usage' );
|
241 |
$content = '';
|
242 |
+
if ( $usage_details && isset ( $usage_details[ $this->api_key ]->status ) && $usage_details[ $this->api_key ]->status ) {
|
243 |
+
if ( isset ( $usage_details[ $this->api_key ]->plan->name ) )
|
244 |
+
$content .= '<p><strong>' . __ ( 'Current Plan', 'rtmedia' ) . ':</strong> ' . $usage_details[ $this->api_key ]->plan->name . ($usage_details[ $this->api_key ]->sub_status ? '' : ' (' . __ ( 'Unsubscribed', 'rtmedia' ) . ')') . '</p>';
|
245 |
+
if ( isset ( $usage_details[ $this->api_key ]->used ) )
|
246 |
+
$content .= '<p><span class="encoding-used"></span><strong>' . __ ( 'Used', 'rtmedia' ) . ':</strong> ' . (($used_size = size_format ( $usage_details[ $this->api_key ]->used, 2 )) ? $used_size : '0MB') . '</p>';
|
247 |
+
if ( isset ( $usage_details[ $this->api_key ]->remaining ) )
|
248 |
+
$content .= '<p><span class="encoding-remaining"></span><strong>' . __ ( 'Remaining', 'rtmedia' ) . ':</strong> ' . (($remaining_size = size_format ( $usage_details[ $this->api_key ]->remaining, 2 )) ? $remaining_size : '0MB') . '</p>';
|
249 |
+
if ( isset ( $usage_details[ $this->api_key ]->total ) )
|
250 |
+
$content .= '<p><strong>' . __ ( 'Total', 'rtmedia' ) . ':</strong> ' . size_format ( $usage_details[ $this->api_key ]->total, 2 ) . '</p>';
|
251 |
$usage = new rtProgress();
|
252 |
+
$content .= $usage->progress_ui ( $usage->progress ( $usage_details[ $this->api_key ]->used, $usage_details[ $this->api_key ]->total ), false );
|
253 |
+
if ( $usage_details[ $this->api_key ]->remaining <= 0 )
|
254 |
+
$content .= '<div class="error below-h2"><p>' . __ ( 'Your usage limit has been reached. Upgrade your plan.', 'rtmedia' ) . '</p></div>';
|
255 |
} else {
|
256 |
+
$content .= '<div class="error below-h2"><p>' . __ ( 'Your API key is not valid or is expired.', 'rtmedia' ) . '</p></div>';
|
257 |
}
|
258 |
+
new RTMediaAdminWidget ( 'rtmedia-encoding-usage', __ ( 'Encoding Usage', 'rtmedia' ), $content );
|
259 |
}
|
260 |
|
261 |
+
public function encoding_service_intro () {
|
262 |
?>
|
263 |
+
<p><?php _e ( 'rtMedia team has started offering an audio/video encoding service.', 'rtmedia' ); ?></p>
|
264 |
<p>
|
265 |
+
<label for="new-api-key"><?php _e ( 'Enter API KEY', 'rtmedia' ); ?></label>
|
266 |
<input id="new-api-key" type="text" name="new-api-key" value="<?php echo $this->api_key; ?>" size="60" />
|
267 |
+
<input type="submit" id="api-key-submit" name="api-key-submit" value="<?php echo __ ( 'Submit', 'rtmedia' ); ?>" class="button-primary" />
|
268 |
+
<?php if ( $this->api_key ) { ?><br /><br /><input type="submit" id="disable-encoding" name="disable-encoding" value="Disable Encoding" class="button-secondary" /><?php } ?>
|
269 |
</p>
|
270 |
<table class="bp-media-encoding-table widefat fixed" cellspacing="0">
|
271 |
<tbody>
|
272 |
<!-- Results table headers -->
|
273 |
<thead>
|
274 |
<tr>
|
275 |
+
<th><?php _e ( 'Feature\Plan', 'rtmedia' ); ?></th>
|
276 |
+
<th><?php _e ( 'Free', 'rtmedia' ); ?></th>
|
277 |
+
<th><?php _e ( 'Silver', 'rtmedia' ); ?></th>
|
278 |
+
<th><?php _e ( 'Gold', 'rtmedia' ); ?></th>
|
279 |
+
<th><?php _e ( 'Platinum', 'rtmedia' ); ?></th>
|
280 |
</tr>
|
281 |
</thead>
|
282 |
<tr>
|
283 |
+
<th><?php _e ( 'File Size Limit', 'rtmedia' ); ?></th>
|
284 |
<td>200MB (<del>20MB</del>)</td>
|
285 |
<td colspan="3" class="column-posts">16GB (<del>2GB</del>)</td>
|
286 |
</tr>
|
287 |
<tr>
|
288 |
+
<th><?php _e ( 'Bandwidth (monthly)', 'rtmedia' ); ?></th>
|
289 |
<td>10GB (<del>1GB</del>)</td>
|
290 |
<td>100GB</td>
|
291 |
<td>1TB</td>
|
292 |
<td>10TB</td>
|
293 |
</tr>
|
294 |
<tr>
|
295 |
+
<th><?php _e ( 'Overage Bandwidth', 'rtmedia' ); ?></th>
|
296 |
+
<td><?php _e ( 'Not Available', 'rtmedia' ); ?></td>
|
297 |
<td>$0.10 per GB</td>
|
298 |
<td>$0.08 per GB</td>
|
299 |
<td>$0.05 per GB</td>
|
300 |
</tr>
|
301 |
<tr>
|
302 |
+
<th><?php _e ( 'Amazon S3 Support', 'rtmedia' ); ?></th>
|
303 |
+
<td><?php _e ( 'Not Available', 'rtmedia' ); ?></td>
|
304 |
+
<td colspan="3" class="column-posts"><?php _e ( 'Coming Soon', 'rtmedia' ); ?></td>
|
305 |
</tr>
|
306 |
<tr>
|
307 |
+
<th><?php _e ( 'HD Profile', 'rtmedia' ); ?></th>
|
308 |
+
<td><?php _e ( 'Not Available', 'rtmedia' ); ?></td>
|
309 |
+
<td colspan="3" class="column-posts"><?php _e ( 'Coming Soon', 'rtmedia' ); ?></td>
|
310 |
</tr>
|
311 |
<tr>
|
312 |
+
<th><?php _e ( 'Webcam Recording', 'rtmedia' ); ?></th>
|
313 |
+
<td colspan="4" class="column-posts"><?php _e ( 'Coming Soon', 'rtmedia' ); ?></td>
|
314 |
</tr>
|
315 |
<tr>
|
316 |
+
<th><?php _e ( 'Pricing', 'rtmedia' ); ?></th>
|
317 |
+
<td><?php _e ( 'Free', 'rtmedia' ); ?></td>
|
318 |
+
<td><?php _e ( '$9/month', 'rtmedia' ); ?></td>
|
319 |
+
<td><?php _e ( '$99/month', 'rtmedia' ); ?></td>
|
320 |
+
<td><?php _e ( '$999/month', 'rtmedia' ); ?></td>
|
321 |
</tr>
|
322 |
<tr>
|
323 |
<th></th>
|
324 |
<td><?php
|
325 |
+
$usage_details = get_site_option ( 'rtmedia-encoding-usage' );
|
326 |
+
if ( isset ( $usage_details[ $this->api_key ]->plan->name ) && (strtolower ( $usage_details[ $this->api_key ]->plan->name ) == 'free') ) {
|
327 |
+
echo '<button disabled="disabled" type="submit" class="encoding-try-now button button-primary">' . __ ( 'Current Plan', 'rtmedia' ) . '</button>';
|
328 |
+
} else {
|
329 |
+
?>
|
330 |
<form id="encoding-try-now-form" method="get" action="">
|
331 |
+
<button type="submit" class="encoding-try-now button button-primary"><?php _e ( 'Try Now', 'rtmedia' ); ?></button>
|
332 |
</form><?php }
|
333 |
+
?>
|
334 |
</td>
|
335 |
+
<td><?php echo $this->encoding_subscription_form ( 'silver', 9.0 ) ?></td>
|
336 |
+
<td><?php echo $this->encoding_subscription_form ( 'gold', 99.0 ) ?></td>
|
337 |
+
<td><?php echo $this->encoding_subscription_form ( 'platinum', 999.0 ) ?></td>
|
338 |
</tr>
|
339 |
</tbody>
|
340 |
</table><br /><?php
|
341 |
+
}
|
342 |
|
343 |
+
/**
|
344 |
+
* Function to handle the callback request by the FFMPEG encoding server
|
345 |
+
*
|
346 |
+
* @since 1.0
|
347 |
+
*/
|
348 |
+
public function handle_callback () {
|
349 |
+
if ( isset ( $_GET[ 'job_id' ] ) && isset ( $_GET[ 'download_url' ] ) ) {
|
350 |
+
$flag = false;
|
351 |
+
global $wpdb;
|
352 |
+
$model = new RTDBModel ( 'rtm_media_meta' );
|
353 |
+
$meta_details = $model->get ( array( 'meta_value' => $_GET[ 'job_id' ], 'meta_key' => 'rtmedia-encoding-job-id' ) );
|
354 |
+
if ( isset ( $meta_details[ 0 ] ) ) {
|
355 |
+
$id = maybe_unserialize ( $meta_details[ 0 ]->media_id );
|
356 |
+
$model = new RTMediaModel();
|
357 |
+
$media = $model->get_media ( array( 'id' => $id ), 0, 1 );
|
358 |
+
$this->media_author = $media[ 0 ]->media_author;
|
359 |
+
$attachment_id = $media[ 0 ]->media_id;
|
360 |
+
$this->uploaded[ "context" ] = $media[ 0 ]->context;
|
361 |
+
$this->uploaded[ "context_id" ] = $media[ 0 ]->context_id;
|
362 |
+
$this->uploaded[ "media_author" ] = $media[ 0 ]->media_author;
|
363 |
+
$attachemnt_post = get_post ( $attachment_id );
|
364 |
+
$download_url = urldecode ( $_GET[ 'download_url' ] );
|
365 |
+
$new_wp_attached_file_pathinfo = pathinfo ( $download_url );
|
366 |
+
$post_mime_type = $new_wp_attached_file_pathinfo[ 'extension' ] == 'mp4' ? 'video/mp4' : 'audio/mp3';
|
367 |
+
try {
|
368 |
+
$file_bits = file_get_contents ( $download_url );
|
369 |
+
} catch ( Exception $e ) {
|
370 |
+
$flag = $e->getMessage ();
|
371 |
+
}
|
372 |
+
if ( $file_bits ) {
|
373 |
+
unlink ( get_attached_file ( $attachment_id ) );
|
374 |
+
add_filter ( 'upload_dir', array( $this, 'upload_dir' ) );
|
375 |
+
$upload_info = wp_upload_bits ( $new_wp_attached_file_pathinfo[ 'basename' ], null, $file_bits );
|
376 |
+
$wpdb->update ( $wpdb->posts, array( 'guid' => $upload_info[ 'url' ], 'post_mime_type' => $post_mime_type ), array( 'ID' => $attachment_id ) );
|
377 |
+
$old_wp_attached_file = get_post_meta ( $attachment_id, '_wp_attached_file', true );
|
378 |
+
$old_wp_attached_file_pathinfo = pathinfo ( $old_wp_attached_file );
|
379 |
+
update_post_meta ( $attachment_id, '_wp_attached_file', str_replace ( $old_wp_attached_file_pathinfo[ 'basename' ], $new_wp_attached_file_pathinfo[ 'basename' ], $old_wp_attached_file ) );
|
380 |
// $media_entry = new BPMediaHostWordpress($attachment_id);
|
381 |
// $activity_content = str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $media_entry->get_media_activity_content());
|
382 |
// $wpdb->update($wpdb->prefix . 'bp_activity', array('content' => $activity_content), array('id' => $media[0]->activity_id));
|
383 |
+
// Check if uplaod is through activity upload
|
384 |
+
|
385 |
+
$activity_id = $media[ 0 ]->activity_id;
|
386 |
+
if ( $activity_id ) {
|
387 |
+
$content = $wpdb->get_var ( "SELECT content FROM {$wpdb->prefix}bp_activity WHERE id = $activity_id" );
|
388 |
+
$activity_content = str_replace ( $attachemnt_post->guid, $upload_info[ 'url' ], $content );
|
389 |
+
$wpdb->update ( $wpdb->prefix . 'bp_activity', array( 'content' => $activity_content ), array( 'id' => $activity_id ) );
|
|
|
|
|
|
|
|
|
390 |
}
|
391 |
} else {
|
392 |
+
$flag = __ ( 'Could not read file.', 'rtmedia' );
|
393 |
+
error_log ( $flag );
|
394 |
}
|
395 |
+
} else {
|
396 |
+
$flag = __ ( 'Something went wrong. The required attachment id does not exists. It must have been deleted.', 'rtmedia' );
|
397 |
+
error_log ( $flag );
|
398 |
+
}
|
399 |
|
400 |
|
401 |
+
$this->update_usage ( $this->api_key );
|
402 |
|
403 |
+
if ( isset ( $_SERVER[ 'REMOTE_ADDR' ] ) && ($_SERVER[ 'REMOTE_ADDR' ] == '4.30.110.155') ) {
|
404 |
+
$mail = true;
|
405 |
+
} else {
|
406 |
+
$mail = false;
|
407 |
+
}
|
408 |
|
409 |
+
if ( $flag && $mail ) {
|
410 |
+
$download_link = add_query_arg ( array( 'job_id' => $_GET[ 'job_id' ], 'download_url' => $_GET[ 'download_url' ] ), home_url () );
|
411 |
+
$subject = __ ( 'rtMedia Encoding: Download Failed', 'rtmedia' );
|
412 |
+
$message = sprintf ( __ ( '<p><a href="%s">Media</a> was successfully encoded but there was an error while downloading:</p>
|
413 |
<p><code>%s</code></p>
|
414 |
+
<p>You can <a href="%s">retry the download</a>.</p>', 'rtmedia' ), get_edit_post_link ( $attachment_id ), $flag, $download_link );
|
415 |
+
$users = get_users ( array( 'role' => 'administrator' ) );
|
416 |
+
if ( $users ) {
|
417 |
+
foreach ( $users as $user )
|
418 |
+
$admin_email_ids[ ] = $user->user_email;
|
419 |
+
add_filter ( 'wp_mail_content_type', create_function ( '', 'return "text/html";' ) );
|
420 |
+
wp_mail ( $admin_email_ids, $subject, $message );
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
}
|
422 |
+
_e ( $flag );
|
423 |
+
} elseif ( $flag ) {
|
424 |
+
_e ( $flag );
|
425 |
+
} else {
|
426 |
+
_e ( "Done", 'rtmedia' );
|
427 |
}
|
428 |
+
die ();
|
429 |
}
|
430 |
+
}
|
431 |
|
432 |
+
public function free_encoding_subscribe () {
|
433 |
+
$email = get_site_option ( 'admin_email' );
|
434 |
+
$usage_details = get_site_option ( 'rtmedia-encoding-usage' );
|
435 |
+
if ( isset ( $usage_details[ $this->api_key ]->plan->name ) && (strtolower ( $usage_details[ $this->api_key ]->plan->name ) == 'free') ) {
|
436 |
+
echo json_encode ( array( 'error' => 'Your free subscription is already activated.' ) );
|
437 |
+
} else {
|
438 |
+
$free_subscription_url = add_query_arg ( array( 'email' => urlencode ( $email ) ), trailingslashit ( $this->api_url ) . 'api/free/' );
|
439 |
+
if ( $this->api_key ) {
|
440 |
+
$free_subscription_url = add_query_arg ( array( 'email' => urlencode ( $email ), 'apikey' => $this->api_key ), $free_subscription_url );
|
441 |
+
}
|
442 |
+
$free_subscribe_page = wp_remote_get ( $free_subscription_url, array( 'timeout' => 120 ) );
|
443 |
+
if ( ! is_wp_error ( $free_subscribe_page ) && ( ! isset ( $free_subscribe_page[ 'headers' ][ 'status' ] ) || (isset ( $free_subscribe_page[ 'headers' ][ 'status' ] ) && ($free_subscribe_page[ 'headers' ][ 'status' ] == 200))) ) {
|
444 |
+
$subscription_info = json_decode ( $free_subscribe_page[ 'body' ] );
|
445 |
+
if ( isset ( $subscription_info->status ) && $subscription_info->status ) {
|
446 |
+
echo json_encode ( array( 'apikey' => $subscription_info->apikey ) );
|
|
|
|
|
|
|
447 |
} else {
|
448 |
+
echo json_encode ( array( 'error' => $subscription_info->message ) );
|
449 |
}
|
450 |
+
} else {
|
451 |
+
echo json_encode ( array( 'error' => 'Something went wrong please try again.' ) );
|
452 |
}
|
|
|
453 |
}
|
454 |
+
die ();
|
455 |
+
}
|
456 |
|
457 |
+
public function hide_encoding_notice () {
|
458 |
+
update_site_option ( 'rtmedia-encoding-service-notice', true );
|
459 |
+
update_site_option ( 'rtmedia-encoding-expansion-notice', true );
|
460 |
+
echo true;
|
461 |
+
die ();
|
462 |
+
}
|
463 |
|
464 |
+
public function unsubscribe_encoding () {
|
465 |
+
$unsubscribe_url = trailingslashit ( $this->api_url ) . 'api/cancel/' . $this->api_key;
|
466 |
+
$unsubscribe_page = wp_remote_post ( $unsubscribe_url, array( 'timeout' => 120, 'body' => array( 'note' => $_GET[ 'note' ] ) ) );
|
467 |
+
if ( ! is_wp_error ( $unsubscribe_page ) && ( ! isset ( $unsubscribe_page[ 'headers' ][ 'status' ] ) || (isset ( $unsubscribe_page[ 'headers' ][ 'status' ] ) && ($unsubscribe_page[ 'headers' ][ 'status' ] == 200))) ) {
|
468 |
+
$subscription_info = json_decode ( $unsubscribe_page[ 'body' ] );
|
469 |
+
if ( isset ( $subscription_info->status ) && $subscription_info->status ) {
|
470 |
+
echo json_encode ( array( 'updated' => __ ( 'Your subscription was cancelled successfully', 'rtmedia' ), 'form' => $this->encoding_subscription_form ( $_GET[ 'plan' ], $_GET[ 'price' ] ) ) );
|
|
|
|
|
|
|
471 |
}
|
472 |
+
} else {
|
473 |
+
echo json_encode ( array( 'error' => __ ( 'Something went wrong please try again.', 'rtmedia' ) ) );
|
474 |
}
|
475 |
+
die ();
|
476 |
+
}
|
477 |
|
478 |
+
public function enter_api_key () {
|
479 |
+
if ( isset ( $_GET[ 'apikey' ] ) ) {
|
480 |
+
echo json_encode ( array( 'apikey' => $_GET[ 'apikey' ] ) );
|
481 |
+
} else {
|
482 |
+
echo json_encode ( array( 'error' => __ ( 'Please enter the api key.', 'rtmedia' ) ) );
|
|
|
|
|
483 |
}
|
484 |
+
die ();
|
485 |
+
}
|
486 |
|
487 |
+
public function disable_encoding () {
|
488 |
+
update_site_option ( 'rtmedia-encoding-api-key', '' );
|
489 |
+
_e ( 'Encoding disabled successfully.', 'rtmedia' );
|
490 |
+
die ();
|
491 |
+
}
|
492 |
|
493 |
+
function upload_dir ( $upload_dir ) {
|
494 |
+
global $rtmedia_interaction, $rt_media_media;
|
495 |
+
if ( isset ( $this->uploaded[ "context" ] ) && isset ( $this->uploaded[ "context_id" ] ) ) {
|
496 |
+
if ( $this->uploaded[ "context" ] != 'group' ) {
|
497 |
+
$rtmedia_upload_prefix = 'users/';
|
498 |
+
$id = $this->uploaded[ "media_author" ];
|
|
|
|
|
|
|
|
|
|
|
499 |
} else {
|
500 |
+
$rtmedia_upload_prefix = 'groups/';
|
501 |
+
$id = $this->uploaded[ "context_id" ];
|
|
|
|
|
|
|
|
|
|
|
502 |
}
|
503 |
+
} else {
|
504 |
+
if ( $rtmedia_interaction->context->type != 'group' ) {
|
505 |
+
$rtmedia_upload_prefix = 'users/';
|
506 |
+
$id = $this->uploaded[ "media_author" ];
|
507 |
+
} else {
|
508 |
+
$rtmedia_upload_prefix = 'groups/';
|
509 |
+
$id = $rtmedia_interaction->context->id;
|
510 |
}
|
511 |
+
}
|
512 |
|
513 |
+
if ( ! $id ) {
|
514 |
+
$id = $this->media_author;
|
515 |
+
}
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
|
518 |
+
$upload_dir[ 'path' ] = trailingslashit (
|
519 |
+
str_replace ( $upload_dir[ 'subdir' ], '', $upload_dir[ 'path' ] ) )
|
520 |
+
. 'rtMedia/' . $rtmedia_upload_prefix . $id .
|
521 |
+
$upload_dir[ 'subdir' ];
|
522 |
+
$upload_dir[ 'url' ] = trailingslashit (
|
523 |
+
str_replace ( $upload_dir[ 'subdir' ], '', $upload_dir[ 'url' ] ) )
|
524 |
+
. 'rtMedia/' . $rtmedia_upload_prefix . $id
|
525 |
+
. $upload_dir[ 'subdir' ];
|
526 |
|
527 |
+
return $upload_dir;
|
528 |
}
|
529 |
+
|
530 |
+
}
|
531 |
+
?>
|
index.php
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
|
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: 3.0.
|
7 |
Author: rtCamp
|
8 |
Text Domain: rtmedia
|
9 |
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
@@ -15,45 +16,43 @@
|
|
15 |
* @package BuddyPressMedia
|
16 |
* @subpackage Main
|
17 |
*/
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
*/
|
25 |
-
define( 'RTMEDIA_PATH', plugin_dir_path( __FILE__ ) );
|
26 |
}
|
27 |
|
28 |
-
if ( ! defined( 'BP_MEDIA_PATH' ) ){
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
}
|
36 |
|
37 |
|
38 |
-
if ( ! defined( 'RTMEDIA_URL' ) ){
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
}
|
46 |
|
47 |
-
if ( ! defined( 'RTMEDIA_BASE_NAME' ) ){
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
}
|
55 |
|
56 |
-
|
57 |
/**
|
58 |
* Auto Loader Function
|
59 |
*
|
@@ -61,47 +60,47 @@ if ( ! defined( 'RTMEDIA_BASE_NAME' ) ){
|
|
61 |
*
|
62 |
* @param string $class_name The name of the class to autoload
|
63 |
*/
|
64 |
-
function rtmedia_autoloader( $class_name ) {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
'app/helper/db/' . $class_name . '.php',
|
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 |
* Register the autoloader function into spl_autoload
|
103 |
*/
|
104 |
-
spl_autoload_register( 'rtmedia_autoloader' );
|
105 |
|
106 |
/**
|
107 |
* Instantiate the BuddyPressMedia class.
|
@@ -112,4 +111,3 @@ $rtmedia = new RTMedia();
|
|
112 |
/*
|
113 |
* Look Ma! Very few includes! Next File: /app/main/RTMedia.php
|
114 |
*/
|
115 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
|
5 |
Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
6 |
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!
|
7 |
+
Version: 3.0.9
|
8 |
Author: rtCamp
|
9 |
Text Domain: rtmedia
|
10 |
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
16 |
* @package BuddyPressMedia
|
17 |
* @subpackage Main
|
18 |
*/
|
19 |
+
if ( ! defined ( 'RTMEDIA_PATH' ) ) {
|
20 |
|
21 |
+
/**
|
22 |
+
* The server file system path to the plugin directory
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
define ( 'RTMEDIA_PATH', plugin_dir_path ( __FILE__ ) );
|
|
|
|
|
26 |
}
|
27 |
|
28 |
+
if ( ! defined ( 'BP_MEDIA_PATH' ) ) {
|
29 |
|
30 |
+
/**
|
31 |
+
* Legacy support
|
32 |
+
*
|
33 |
+
*/
|
34 |
+
define ( 'BP_MEDIA_PATH', RTMEDIA_PATH );
|
35 |
}
|
36 |
|
37 |
|
38 |
+
if ( ! defined ( 'RTMEDIA_URL' ) ) {
|
39 |
|
40 |
+
/**
|
41 |
+
* The url to the plugin directory
|
42 |
+
*
|
43 |
+
*/
|
44 |
+
define ( 'RTMEDIA_URL', plugin_dir_url ( __FILE__ ) );
|
45 |
}
|
46 |
|
47 |
+
if ( ! defined ( 'RTMEDIA_BASE_NAME' ) ) {
|
48 |
|
49 |
+
/**
|
50 |
+
* The url to the plugin directory
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
define ( 'RTMEDIA_BASE_NAME', plugin_basename ( __FILE__ ) );
|
54 |
}
|
55 |
|
|
|
56 |
/**
|
57 |
* Auto Loader Function
|
58 |
*
|
60 |
*
|
61 |
* @param string $class_name The name of the class to autoload
|
62 |
*/
|
63 |
+
function rtmedia_autoloader ( $class_name ) {
|
64 |
+
$rtlibpath = array(
|
65 |
+
'app/services/' . $class_name . '.php',
|
66 |
+
'app/helper/' . $class_name . '.php',
|
67 |
'app/helper/db/' . $class_name . '.php',
|
68 |
+
'app/admin/' . $class_name . '.php',
|
69 |
+
'app/main/interactions/' . $class_name . '.php',
|
70 |
+
'app/main/routers/' . $class_name . '.php',
|
71 |
+
'app/main/routers/query/' . $class_name . '.php',
|
72 |
+
'app/main/controllers/upload/' . $class_name . '.php',
|
73 |
+
'app/main/controllers/upload/processors/' . $class_name . '.php',
|
74 |
+
'app/main/controllers/shortcodes/' . $class_name . '.php',
|
75 |
+
'app/main/controllers/template/' . $class_name . '.php',
|
76 |
+
'app/main/controllers/media/' . $class_name . '.php',
|
77 |
+
'app/main/controllers/group/' . $class_name . '.php',
|
78 |
+
'app/main/controllers/privacy/' . $class_name . '.php',
|
79 |
+
'app/main/controllers/activity/' . $class_name . '.php',
|
80 |
+
'app/main/deprecated/' . $class_name . '.php',
|
81 |
+
'app/main/contexts/' . $class_name . '.php',
|
82 |
+
'app/main/' . $class_name . '.php',
|
83 |
+
'app/main/includes/' . $class_name . '.php',
|
84 |
+
'app/main/widgets/' . $class_name . '.php',
|
85 |
+
'app/main/upload/' . $class_name . '.php',
|
86 |
+
'app/main/upload/processors/' . $class_name . '.php',
|
87 |
+
'app/main/template/' . $class_name . '.php',
|
88 |
+
'app/log/' . $class_name . '.php',
|
89 |
+
'app/importers/' . $class_name . '.php',
|
90 |
+
);
|
91 |
+
foreach ( $rtlibpath as $path ) {
|
92 |
+
$path = RTMEDIA_PATH . $path;
|
93 |
+
if ( file_exists ( $path ) ) {
|
94 |
+
include $path;
|
95 |
+
break;
|
96 |
+
}
|
97 |
+
}
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
* Register the autoloader function into spl_autoload
|
102 |
*/
|
103 |
+
spl_autoload_register ( 'rtmedia_autoloader' );
|
104 |
|
105 |
/**
|
106 |
* Instantiate the BuddyPressMedia class.
|
111 |
/*
|
112 |
* Look Ma! Very few includes! Next File: /app/main/RTMedia.php
|
113 |
*/
|
|
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
|
8 |
Tested up to: WordPress 3.5.2 + BuddyPress 1.7
|
9 |
-
Stable tag: 3.0.
|
10 |
|
11 |
rtMedia adds albums, audio/video encoding, privacy/sharing, front-end uploads & more. All this works nicely on mobile/tablets devices.
|
12 |
|
@@ -160,6 +160,18 @@ Please visit [rtMedia's Features page](http://rtcamp.com/buddypress-media/?utm_s
|
|
160 |
|
161 |
Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
= 3.0.7 =
|
164 |
* Fixed rewrite rule issue
|
165 |
* Fixed comment issue on media
|
@@ -509,9 +521,8 @@ Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap
|
|
509 |
|
510 |
== Upgrade Notice ==
|
511 |
|
512 |
-
= 3.0.
|
513 |
-
|
514 |
-
|
515 |
== Sponsors ==
|
516 |
|
517 |
* *[Henry Wright](http://profiles.wordpress.org/henrywright-1)* has kindly sponsored the *Featured Media* feature.
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: WordPress 3.5
|
8 |
Tested up to: WordPress 3.5.2 + BuddyPress 1.7
|
9 |
+
Stable tag: 3.0.9
|
10 |
|
11 |
rtMedia adds albums, audio/video encoding, privacy/sharing, front-end uploads & more. All this works nicely on mobile/tablets devices.
|
12 |
|
160 |
|
161 |
Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
|
162 |
|
163 |
+
= 3.0.9 =
|
164 |
+
* Add Media Count
|
165 |
+
* Fixed Setting for Upload media
|
166 |
+
* Fixed Feature image issue
|
167 |
+
* Other minor bug fixes
|
168 |
+
|
169 |
+
= 3.0.8 =
|
170 |
+
* Fixed gallery and upload shortcode
|
171 |
+
* Fixed duplicate media in popup
|
172 |
+
* Fixed privacy user setting
|
173 |
+
* Fixed post parent issue and regenerate thumbnail issue
|
174 |
+
|
175 |
= 3.0.7 =
|
176 |
* Fixed rewrite rule issue
|
177 |
* Fixed comment issue on media
|
521 |
|
522 |
== Upgrade Notice ==
|
523 |
|
524 |
+
= 3.0.9 =
|
525 |
+
Requires BuddyPress 1.7 or higher, if using BuddyPress. * Add Media Count,Setting for Upload media,Feature image and other issues
|
|
|
526 |
== Sponsors ==
|
527 |
|
528 |
* *[Henry Wright](http://profiles.wordpress.org/henrywright-1)* has kindly sponsored the *Featured Media* feature.
|
templates/media/album-gallery-item.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<li class="rtmedia-list-item">
|
2 |
<div class="rtmedia-item-thumbnail">
|
3 |
-
<a href ="<?php rtmedia_permalink(); ?>">
|
4 |
-
<img src="<?php rtmedia_image('
|
5 |
</a>
|
6 |
</div>
|
7 |
|
8 |
<div class="rtmedia-item-title">
|
9 |
-
<h4 title="<?php echo rtmedia_title(); ?>">
|
10 |
-
<a href="<?php rtmedia_permalink(); ?>">
|
11 |
-
<?php echo rtmedia_title(); ?>
|
12 |
</a>
|
13 |
</h4>
|
14 |
</div>
|
1 |
<li class="rtmedia-list-item">
|
2 |
<div class="rtmedia-item-thumbnail">
|
3 |
+
<a href ="<?php rtmedia_permalink (); ?>">
|
4 |
+
<img src="<?php rtmedia_image ( 'rt_media_thumbnail' ); ?>" >
|
5 |
</a>
|
6 |
</div>
|
7 |
|
8 |
<div class="rtmedia-item-title">
|
9 |
+
<h4 title="<?php echo rtmedia_title (); ?>">
|
10 |
+
<a href="<?php rtmedia_permalink (); ?>">
|
11 |
+
<?php echo rtmedia_title (); ?>
|
12 |
</a>
|
13 |
</h4>
|
14 |
</div>
|
templates/media/album-gallery.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<div class="rtmedia-container">
|
2 |
-
|
3 |
-
|
4 |
|
5 |
-
<?php if (have_rtmedia()) { ?>
|
6 |
|
7 |
-
<h2><?php echo __('Album Gallery','rtmedia'); ?></h2>
|
8 |
|
9 |
<ul class="rtmedia-list rtmedia-album-list">
|
10 |
|
11 |
-
<?php while (have_rtmedia()) : rtmedia(); ?>
|
12 |
|
13 |
<?php include ('album-gallery-item.php'); ?>
|
14 |
|
@@ -16,50 +16,50 @@
|
|
16 |
|
17 |
</ul>
|
18 |
|
19 |
-
<div class='rtmedia_next_prev row'>
|
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 |
-
</div>
|
45 |
-
|
46 |
|
47 |
</div>
|
48 |
|
49 |
<!-- template for single media in gallery -->
|
50 |
<script id="rtmedia-gallery-item-template" type="text/template">
|
51 |
<div class="rtmedia-item-thumbnail">
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
</div>
|
56 |
|
57 |
<div class="rtmedia-item-title">
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
</div>
|
64 |
</script>
|
65 |
<!-- rtmedia_actions remained in script tag -->
|
1 |
<div class="rtmedia-container">
|
2 |
+
<?php do_action ( 'rtmedia_before_album_gallery' ); ?>
|
3 |
+
<?php rtmedia_uploader () ?>
|
4 |
|
5 |
+
<?php if ( have_rtmedia () ) { ?>
|
6 |
|
7 |
+
<h2><?php echo __ ( 'Album Gallery', 'rtmedia' ); ?></h2>
|
8 |
|
9 |
<ul class="rtmedia-list rtmedia-album-list">
|
10 |
|
11 |
+
<?php while ( have_rtmedia () ) : rtmedia (); ?>
|
12 |
|
13 |
<?php include ('album-gallery-item.php'); ?>
|
14 |
|
16 |
|
17 |
</ul>
|
18 |
|
19 |
+
<div class='rtmedia_next_prev row'>
|
20 |
+
<!-- these links will be handled by backbone later
|
21 |
+
-- get request parameters will be removed -->
|
22 |
+
<?php
|
23 |
+
$display = '';
|
24 |
+
if ( rtmedia_offset () != 0 )
|
25 |
+
$display = 'style="display:block;"';
|
26 |
+
else
|
27 |
+
$display = 'style="display:none;"';
|
28 |
+
?>
|
29 |
+
<a id="rtMedia-galary-prev" <?php echo $display; ?> href="<?php echo rtmedia_pagination_prev_link (); ?>"><?php echo __ ( 'Prev', 'rtmedia' ); ?></a>
|
30 |
|
31 |
+
<?php
|
32 |
+
$display = '';
|
33 |
+
if ( rtmedia_offset () + rtmedia_per_page_media () < rtmedia_count () )
|
34 |
+
$display = 'style="display:block;"';
|
35 |
+
else
|
36 |
+
$display = 'style="display:none;"';
|
37 |
+
?>
|
38 |
+
<a id="rtMedia-galary-next" <?php echo $display; ?> href="<?php echo rtmedia_pagination_next_link (); ?>"><?php echo __ ( 'Next', 'rtmedia' ); ?></a>
|
39 |
|
40 |
|
41 |
+
<?php } else { ?>
|
42 |
+
<p><?php echo __ ( "Oops !! There's no media found for the request !!", "rtmedia" ); ?></p>
|
43 |
+
<?php } ?>
|
44 |
+
</div>
|
45 |
+
<?php do_action ( 'rtmedia_after_album_gallery' ); ?>
|
46 |
|
47 |
</div>
|
48 |
|
49 |
<!-- template for single media in gallery -->
|
50 |
<script id="rtmedia-gallery-item-template" type="text/template">
|
51 |
<div class="rtmedia-item-thumbnail">
|
52 |
+
<a href ="media/<%= id %>">
|
53 |
+
<img src="<%= guid %>">
|
54 |
+
</a>
|
55 |
</div>
|
56 |
|
57 |
<div class="rtmedia-item-title">
|
58 |
+
<h4 title="<%= media_title %>">
|
59 |
+
<a href="media/<%= id %>">
|
60 |
+
<%= media_title %>
|
61 |
+
</a>
|
62 |
+
</h4>
|
63 |
</div>
|
64 |
</script>
|
65 |
<!-- rtmedia_actions remained in script tag -->
|
templates/media/media-gallery.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<div class="rtmedia-container">
|
2 |
-
<?php do_action('rtmedia_before_media_gallery'); ?>
|
3 |
|
4 |
-
<?php rtmedia_uploader() ?>
|
5 |
|
6 |
-
<h2><?php echo __('Media Gallery', 'rtmedia'); ?></h2>
|
7 |
-
<ul class="rtmedia-list rtmedia-list-media <?php echo rtmedia_media_gallery_class()
|
8 |
-
<?php if (have_rtmedia()) { ?>
|
9 |
|
10 |
|
11 |
|
12 |
-
<?php while (have_rtmedia()) : rtmedia(); ?>
|
13 |
|
14 |
<?php include ('media-gallery-item.php'); ?>
|
15 |
|
@@ -17,31 +17,31 @@
|
|
17 |
|
18 |
</ul>
|
19 |
|
20 |
-
<div class='rtmedia_next_prev row'>
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
</div>
|
41 |
<?php } else { ?>
|
42 |
-
<p><?php echo __("Oops !! There's no media found for the request !!", "rtmedia"); ?></p>
|
43 |
<?php } ?>
|
44 |
</ul>
|
45 |
-
|
46 |
|
47 |
</div>
|
1 |
<div class="rtmedia-container">
|
2 |
+
<?php do_action ( 'rtmedia_before_media_gallery' ); ?>
|
3 |
|
4 |
+
<?php rtmedia_uploader () ?>
|
5 |
|
6 |
+
<h2><?php echo __ ( 'Media Gallery', 'rtmedia' ); ?></h2>
|
7 |
+
<ul class="rtmedia-list rtmedia-list-media <?php echo rtmedia_media_gallery_class (); ?>">
|
8 |
+
<?php if ( have_rtmedia () ) { ?>
|
9 |
|
10 |
|
11 |
|
12 |
+
<?php while ( have_rtmedia () ) : rtmedia (); ?>
|
13 |
|
14 |
<?php include ('media-gallery-item.php'); ?>
|
15 |
|
17 |
|
18 |
</ul>
|
19 |
|
20 |
+
<div class='rtmedia_next_prev row'>
|
21 |
+
<!-- these links will be handled by backbone later
|
22 |
+
-- get request parameters will be removed -->
|
23 |
+
<?php
|
24 |
+
$display = '';
|
25 |
+
if ( rtmedia_offset () != 0 )
|
26 |
+
$display = 'style="display:block;"';
|
27 |
+
else
|
28 |
+
$display = 'style="display:none;"';
|
29 |
+
?>
|
30 |
+
<a id="rtMedia-galary-prev" <?php echo $display; ?> href="<?php echo rtmedia_pagination_prev_link (); ?>"><?php echo __ ( 'Prev', 'rtmedia' ); ?></a>
|
31 |
+
|
32 |
+
<?php
|
33 |
+
$display = '';
|
34 |
+
if ( rtmedia_offset () + rtmedia_per_page_media () < rtmedia_count () )
|
35 |
+
$display = 'style="display:block;"';
|
36 |
+
else
|
37 |
+
$display = 'style="display:none;"';
|
38 |
+
?>
|
39 |
+
<a id="rtMedia-galary-next" <?php echo $display; ?> href="<?php echo rtmedia_pagination_next_link (); ?>"><?php echo __ ( 'Next', 'rtmedia' ); ?></a>
|
40 |
+
</div>
|
41 |
<?php } else { ?>
|
42 |
+
<p><?php echo __ ( "Oops !! There's no media found for the request !!", "rtmedia" ); ?></p>
|
43 |
<?php } ?>
|
44 |
</ul>
|
45 |
+
<?php do_action ( 'rtmedia_after_media_gallery' ); ?>
|
46 |
|
47 |
</div>
|
templates/upload/uploader.php
CHANGED
@@ -1,53 +1,52 @@
|
|
1 |
-
<?php if (is_array($tabs) && count($tabs)) { ?>
|
2 |
-
<div class="rtmedia-container">
|
3 |
-
<div class="rtmedia-uploader no-js">
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
8 |
// $tab_html = '<ul>';
|
9 |
// foreach ( $tabs as $key => $tab ) {
|
10 |
// $tab_html .= '<li class="'.$key.'"><a href="'.add_query_arg(array('mode' => $key)).'" title="'.esc_attr($tab['title']).'">'.$tab['title'].'</a></li>';
|
11 |
// }
|
12 |
// $tab_html .= '</ul>';
|
13 |
// echo $tab_html;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
global $rtmedia_interaction;
|
32 |
// $context_flag = $context_id_flag = $album_id_flag = false;
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
</div>
|
52 |
-
|
53 |
-
|
1 |
+
<?php if ( is_array ( $tabs ) && count ( $tabs ) ) { ?>
|
2 |
+
<div class="rtmedia-container">
|
3 |
+
<div class="rtmedia-uploader no-js">
|
4 |
+
<form id="rtmedia-uploader-form" method="post" action="upload" enctype="multipart/form-data">
|
5 |
+
<?php do_action ( 'rtmedia_before_uploader' ); ?>
|
6 |
|
7 |
+
<?php
|
8 |
// $tab_html = '<ul>';
|
9 |
// foreach ( $tabs as $key => $tab ) {
|
10 |
// $tab_html .= '<li class="'.$key.'"><a href="'.add_query_arg(array('mode' => $key)).'" title="'.esc_attr($tab['title']).'">'.$tab['title'].'</a></li>';
|
11 |
// }
|
12 |
// $tab_html .= '</ul>';
|
13 |
// echo $tab_html;
|
14 |
+
echo '<div class="rtm-tab-content-wrapper">';
|
15 |
+
echo '<div id="rtm-' . $mode . '-ui" class="rtm-tab-content">';
|
16 |
+
do_action ( 'rtmedia_before_' . $mode . '_ui' );
|
17 |
+
echo $tabs[ $mode ][ $upload_type ][ 'content' ];
|
18 |
+
echo '<input type="hidden" name="mode" value="' . $mode . '" />';
|
19 |
+
do_action ( 'rtmedia_after_' . $mode . '_ui', $attr );
|
20 |
+
echo '</div>';
|
21 |
+
echo '</div>';
|
22 |
+
?>
|
23 |
+
|
24 |
+
<?php do_action ( 'rtmedia_after_uploader' ); ?>
|
25 |
+
|
26 |
+
<?php RTMediaUploadView::upload_nonce_generator ( true ); ?>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
global $rtmedia_interaction;
|
|
|
|
|
30 |
// $context_flag = $context_id_flag = $album_id_flag = false;
|
31 |
+
if ( ! empty ( $attr ) ) {
|
32 |
+
|
33 |
+
foreach ( $attr as $key => $value ) {
|
34 |
+
|
35 |
+
if ( $key == 'context' )
|
36 |
+
echo '<input type="hidden" name="context" value="' . $value . '" />';
|
37 |
+
if ( $key == 'context_id' )
|
38 |
+
echo '<input type="hidden" name="context_id" value="' . $value . '" />';
|
39 |
+
if ( $key == 'privacy' )
|
40 |
+
echo '<input type="hidden" name="privacy" value="' . $value . '" />';
|
41 |
+
if ( $key == 'album_id' )
|
42 |
+
echo '<input type="hidden" name="album_id" value="' . $value . '" />';
|
43 |
+
}
|
44 |
+
}
|
45 |
+
?>
|
46 |
+
|
47 |
+
<input type="submit" id='rtMedia-start-upload' name="rtmedia-upload" value="<?php echo RTMEDIA_UPLOAD_LABEL; ?>" />
|
48 |
+
</form>
|
49 |
+
</div>
|
50 |
</div>
|
51 |
+
<?php
|
52 |
+
}
|