/**
  *
  * @global type $rtmedia_interaction
  */
 function sanitize_object()
 {
     if (!$this->has_context()) {
         global $rtmedia_interaction;
         $this->upload['context'] = $rtmedia_interaction->context->type;
         $this->upload['context_id'] = $rtmedia_interaction->context->id;
     }
     if (!is_array($this->upload['taxonomy'])) {
         $this->upload['taxonomy'] = array($this->upload['taxonomy']);
     }
     if (!is_array($this->upload['custom_fields'])) {
         $this->upload['custom_fields'] = array($this->upload['custom_fields']);
     }
     if (!$this->has_album_id() || !$this->has_album_permissions()) {
         $this->set_album_id();
     }
     if (!$this->has_author()) {
         $this->set_author();
     }
     if (is_rtmedia_privacy_enable()) {
         if (is_rtmedia_privacy_user_overide()) {
             if (!isset($_POST["privacy"])) {
                 $this->upload['privacy'] = get_rtmedia_default_privacy();
             } else {
                 $this->upload['privacy'] = $_POST["privacy"];
             }
         } else {
             $this->upload['privacy'] = get_rtmedia_default_privacy();
         }
     } else {
         $this->upload['privacy'] = 0;
     }
 }
    /**
     * Render the uploader shortcode and attach the uploader panel
     *
     * @param type $template_name
     */
    public function render($template_name)
    {
        global $rtmedia_query;
        $album = '';
        if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album()) {
            $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />';
        } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') {
                $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>';
            }
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>';
            }
        }
        $up_privacy = $privacy = "";
        //uploader privacy dropdown for uploader under rtMedia Media tab.
        if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false)) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                // if the context is group, then set the media privacy to public
                $privacy = "<input type='hidden' name='privacy' value='0'/>";
            } else {
                $up_privacy = new RTMediaPrivacy();
                $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy');
                if ($up_privacy) {
                    $privacy = "<span><i class='rtmicon-eye'></i> <label for='privacy'> " . __('Privacy: ', 'rtmedia') . "</label>" . $up_privacy . "</span>";
                }
            }
        }
        $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop row">' . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", "rtmedia") . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'rtmedia') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'rtmedia') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'rtmedia') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="row">' . wp_nonce_field('rtmedia_' . get_current_user_id(), 'rtmedia_media_delete_nonce') . '<table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div class="rtmedia-container"><div id="rtmedia-action-update"><button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update"><i class="rtmicon-plus-circle"></i>' . apply_filters('rtmedia_attach_file_message', __('Attach Files', 'rtmedia')) . '</button>' . $up_privacy . '</div><div id="rtmedia-whts-new-upload-container"><div id="rtm-upload-start-notice"><span>' . __('Upload will start only after you enter content and click Post Update.', 'rtmedia') . '</span></div><table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div></div>')), 'link_input' => array('title' => __('Insert from URL', 'rtmedia'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />'));
        $tabs = apply_filters('rtmedia_upload_tabs', $tabs);
        $attr = $this->attributes;
        $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload';
        if ($attr && is_array($attr)) {
            foreach ($attr as $key => $val) {
                ?>
                <input type='hidden' id="rt_upload_hf_<?php 
                echo sanitize_key($key);
                ?>
" value='<?php 
                echo $val;
                ?>
' name ='<?php 
                echo $key;
                ?>
' />
                <?php 
            }
        }
        $upload_type = 'default';
        if (isset($attr['activity']) && $attr['activity']) {
            $upload_type = 'activity';
        }
        $uploadHelper = new RTMediaUploadHelper();
        include $this->locate_template($template_name);
    }
Exemplo n.º 3
0
 /**
  *
  * @global type $rtmedia_interaction
  */
 function sanitize_object()
 {
     if (!$this->has_context()) {
         // Set context_id to Logged in user id if context is profile and context_id is not provided
         if ('profile' === $this->upload['context'] || 'bp_member' === $this->upload['context']) {
             $this->upload['context'] = 'profile';
             $this->upload['context_id'] = get_current_user_id();
         } else {
             global $rtmedia_interaction;
             $this->upload['context'] = $rtmedia_interaction->context->type;
             $this->upload['context_id'] = $rtmedia_interaction->context->id;
         }
     }
     if (!is_array($this->upload['taxonomy'])) {
         $this->upload['taxonomy'] = array($this->upload['taxonomy']);
     }
     if (!is_array($this->upload['custom_fields'])) {
         $this->upload['custom_fields'] = array($this->upload['custom_fields']);
     }
     if (!$this->has_album_id() || !$this->has_album_permissions()) {
         $this->set_album_id();
     }
     if (!$this->has_author()) {
         $this->set_author();
     }
     if (is_rtmedia_privacy_enable()) {
         if (is_rtmedia_privacy_user_overide()) {
             $privacy = filter_input(INPUT_POST, 'privacy', FILTER_SANITIZE_NUMBER_INT);
             if (is_null($privacy)) {
                 $this->upload['privacy'] = get_rtmedia_default_privacy();
             } else {
                 $this->upload['privacy'] = $privacy;
             }
         } else {
             $this->upload['privacy'] = get_rtmedia_default_privacy();
         }
     } else {
         $this->upload['privacy'] = 0;
     }
 }
Exemplo n.º 4
0
 function add_nav()
 {
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     if (!is_rtmedia_profile_media_enable()) {
         return;
     }
     if (!is_rtmedia_privacy_enable()) {
         return;
     }
     if (!is_rtmedia_privacy_user_overide()) {
         return;
     }
     $settings_link = trailingslashit($user_domain . 'settings');
     $defaults = array('name' => $this->title(), 'slug' => 'privacy', 'parent_slug' => 'settings', 'parent_url' => $settings_link, 'item_css_id' => 'rtmedia-privacy-settings', 'user_has_access' => true, 'site_admin_only' => false, 'position' => 80, 'screen_function' => array($this, 'settings_ui'), 'link' => '');
     bp_core_new_subnav_item($defaults);
 }
 function bp_activity_posted_update($content, $user_id, $activity_id)
 {
     global $wpdb, $bp;
     $updated_content = '';
     // hook for rtmedia buddypress before activity posted
     do_action('rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id);
     if (isset($_POST['rtMedia_attached_files']) && is_array($_POST['rtMedia_attached_files'])) {
         $updated_content = $wpdb->get_var("select content from  {$bp->activity->table_name} where  id= {$activity_id}");
         $objActivity = new RTMediaActivity($_POST['rtMedia_attached_files'], 0, $updated_content);
         $html_content = $objActivity->create_activity_html();
         bp_activity_update_meta($activity_id, 'bp_old_activity_content', $html_content);
         bp_activity_update_meta($activity_id, 'bp_activity_text', $updated_content);
         $wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $html_content), array('id' => $activity_id));
         $mediaObj = new RTMediaModel();
         $sql = "update {$mediaObj->table_name} set activity_id = '" . $activity_id . "' where blog_id = '" . get_current_blog_id() . "' and id in (" . implode(',', $_POST['rtMedia_attached_files']) . ')';
         $wpdb->query($sql);
     }
     // hook for rtmedia buddypress after activity posted
     do_action('rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id);
     if (isset($_POST['rtmedia-privacy'])) {
         $privacy = -1;
         if (is_rtmedia_privacy_enable()) {
             if (is_rtmedia_privacy_user_overide()) {
                 $privacy = $_POST['rtmedia-privacy'];
             } else {
                 $privacy = get_rtmedia_default_privacy();
             }
         }
         bp_activity_update_meta($activity_id, 'rtmedia_privacy', $privacy);
         // insert/update activity details in rtmedia activity table
         $rtmedia_activity_model = new RTMediaActivityModel();
         if (!$rtmedia_activity_model->check($activity_id)) {
             $rtmedia_activity_model->insert(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy));
         } else {
             $rtmedia_activity_model->update(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy), array('activity_id' => $activity_id));
         }
     }
 }
Exemplo n.º 6
0
    /**
     * Render the uploader shortcode and attach the uploader panel
     *
     * @param type $template_name
     */
    public function render($template_name)
    {
        global $rtmedia_query;
        $album = '';
        if (apply_filters('rtmedia_render_select_album_upload', true)) {
            if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album($rtmedia_query->media_query['album_id'])) {
                $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />';
            } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) {
                if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') {
                    $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>';
                }
                if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                    $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>';
                }
            }
        }
        $up_privacy = $privacy = "";
        //uploader privacy dropdown for uploader under rtMedia Media tab.
        if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false) || isset($rtmedia_query->is_upload_shortcode) && !isset($this->attributes['privacy'])) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group' || function_exists('bp_is_groups_component') && bp_is_groups_component()) {
                // if the context is group, then set the media privacy to public
                $privacy = "<input type='hidden' name='privacy' value='0'/>";
            } else {
                $up_privacy = new RTMediaPrivacy();
                $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy');
                if ($up_privacy) {
                    $privacy = "<span> <label for='privacy'> <i class='dashicons dashicons-visibility rtmicon'></i> " . __('Privacy: ', 'buddypress-media') . "</label>" . $up_privacy . "</span>";
                }
            }
        }
        $upload_tabs = array('file_upload' => array('title' => __('File Upload', 'buddypress-media'), 'class' => array('rtm-upload-tab', 'active'), 'content' => '<div class="rtm-upload-tab-content" data-id="rtm-upload-tab">' . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", 'buddypress-media') . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'buddypress-media') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'buddypress-media') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle rtmicon-fw"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . '</div>'));
        $upload_tabs = apply_filters('rtmedia_uploader_tabs', $upload_tabs);
        if (is_array($upload_tabs) && !empty($upload_tabs)) {
            if (sizeof($upload_tabs) == 1 && isset($upload_tabs['file_upload'])) {
                $upload_tab_html = $upload_tabs['file_upload']['content'];
            } else {
                $upload_tab_html = '<div class="rtm-uploader-main-wrapper"><div class="rtm-uploader-tabs"><ul>';
                foreach ($upload_tabs as $single_tab) {
                    $upload_tab_html .= '<li class="' . implode(' ', $single_tab['class']) . '">' . $single_tab['title'] . '</li>';
                }
                $upload_tab_html .= '</ul></div>';
                foreach ($upload_tabs as $single_tab) {
                    $upload_tab_html .= $single_tab['content'];
                }
                $upload_tab_html .= '</div>';
            }
        } else {
            $upload_tab_html = '';
        }
        $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop clearfix">' . apply_filters('rtmedia_uploader_before_album_privacy', "") . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . $upload_tab_html . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'buddypress-media') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="clearfix">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist"></ul></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div class="rtmedia-plupload-container rtmedia-container clearfix">' . '<div id="rtmedia-action-update" class="clearfix">' . '<div class="rtm-upload-button-wrapper">' . '<div id="rtmedia-whts-new-upload-container">' . '</div>' . '<button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update" title="' . apply_filters('rtmedia_attach_media_button_title', __('Attach Media', 'buddypress-media')) . '">' . '<span class="dashicons dashicons-admin-media"></span>' . apply_filters('rtmedia_attach_file_message', '') . '</button>' . '</div>' . $up_privacy . '</div>' . '</div>' . '<div class="rtmedia-plupload-notice">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist">' . '</ul>' . '</div>')), 'link_input' => array('title' => __('Insert from URL', 'buddypress-media'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />'));
        $tabs = apply_filters('rtmedia_upload_tabs', $tabs);
        $attr = $this->attributes;
        $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload';
        if ($attr && is_array($attr)) {
            foreach ($attr as $key => $val) {
                ?>
				<input type='hidden' id="rt_upload_hf_<?php 
                echo sanitize_key($key);
                ?>
" value='<?php 
                echo $val;
                ?>
' name ='<?php 
                echo $key;
                ?>
' />
				<?php 
            }
        }
        $upload_type = 'default';
        if (isset($attr['activity']) && $attr['activity']) {
            $upload_type = 'activity';
        }
        $uploadHelper = new RTMediaUploadHelper();
        include $this->locate_template($template_name);
    }
 function bp_activity_posted_update($content, $user_id, $activity_id)
 {
     global $wpdb, $bp;
     $updated_content = "";
     // hook for rtmedia buddypress before activity posted
     do_action('rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id);
     if (isset($_POST["rtMedia_attached_files"]) && is_array($_POST["rtMedia_attached_files"])) {
         $updated_content = $wpdb->get_var("select content from  {$bp->activity->table_name} where  id= {$activity_id}");
         $objActivity = new RTMediaActivity($_POST["rtMedia_attached_files"], 0, $updated_content);
         $html_content = $objActivity->create_activity_html();
         bp_activity_update_meta($activity_id, "bp_old_activity_content", $html_content);
         bp_activity_update_meta($activity_id, "bp_activity_text", $updated_content);
         $wpdb->update($bp->activity->table_name, array("type" => "rtmedia_update", "content" => $html_content), array("id" => $activity_id));
         $mediaObj = new RTMediaModel();
         $sql = "update {$mediaObj->table_name} set activity_id = '" . $activity_id . "' where blog_id = '" . get_current_blog_id() . "' and id in (" . implode(",", $_POST["rtMedia_attached_files"]) . ")";
         $wpdb->query($sql);
     }
     // hook for rtmedia buddypress after activity posted
     do_action('rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id);
     if (isset($_POST['rtmedia-privacy'])) {
         $privacy = -1;
         if (is_rtmedia_privacy_enable()) {
             if (is_rtmedia_privacy_user_overide()) {
                 $privacy = $_POST['rtmedia-privacy'];
             } else {
                 $privacy = get_rtmedia_default_privacy();
             }
         }
         bp_activity_update_meta($activity_id, 'rtmedia_privacy', $privacy);
     }
 }
Exemplo n.º 8
0
 function bp_activity_posted_update($content, $user_id, $activity_id)
 {
     global $wpdb, $bp;
     $updated_content = '';
     // hook for rtmedia buddypress before activity posted
     do_action('rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id);
     $rtmedia_attached_files = filter_input(INPUT_POST, 'rtMedia_attached_files', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     if (is_array($rtmedia_attached_files)) {
         $updated_content = $wpdb->get_var("select content from  {$bp->activity->table_name} where  id= {$activity_id} limit 1");
         // @codingStandardsIgnoreLine
         $obj_activity = new RTMediaActivity($rtmedia_attached_files, 0, $updated_content);
         $html_content = $obj_activity->create_activity_html();
         bp_activity_update_meta($activity_id, 'bp_old_activity_content', $html_content);
         bp_activity_update_meta($activity_id, 'bp_activity_text', $updated_content);
         $wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $html_content), array('id' => $activity_id));
         $media_obj = new RTMediaModel();
         //Credit faisal : https://gist.github.com/faishal/c4306ae7267fff976465
         $in_str_arr = array_fill(0, count($rtmedia_attached_files), '%d');
         $in_str = join(',', $in_str_arr);
         $sql = $wpdb->prepare("update {$media_obj->table_name} set activity_id = %d where blog_id = %d and ", $activity_id, get_current_blog_id());
         // @codingStandardsIgnoreLine
         $form_id_where = $wpdb->prepare("id IN ({$in_str})", $rtmedia_attached_files);
         $sql .= $form_id_where;
         $wpdb->query($sql);
         // @codingStandardsIgnoreLine
     }
     // hook for rtmedia buddypress after activity posted
     do_action('rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id);
     $rtmedia_privacy = filter_input(INPUT_POST, 'rtmedia-privacy', FILTER_SANITIZE_NUMBER_INT);
     if (null !== $rtmedia_privacy) {
         $privacy = -1;
         if (is_rtmedia_privacy_enable()) {
             if (is_rtmedia_privacy_user_overide()) {
                 $privacy = $rtmedia_privacy;
             } else {
                 $privacy = get_rtmedia_default_privacy();
             }
         }
         bp_activity_update_meta($activity_id, 'rtmedia_privacy', $privacy);
         // insert/update activity details in rtmedia activity table
         $rtmedia_activity_model = new RTMediaActivityModel();
         if (!$rtmedia_activity_model->check($activity_id)) {
             $rtmedia_activity_model->insert(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy));
         } else {
             $rtmedia_activity_model->update(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy), array('activity_id' => $activity_id));
         }
     }
 }