/** * * @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; } }
public function setup_settings_privacy_nav($wp_admin_nav) { // Setup the logged in user variables if (is_rtmedia_privacy_user_overide()) { $settings_link = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()); // Add the "Profile" subnav item $wp_admin_nav[] = array('parent' => 'my-account-' . buddypress()->settings->id, 'id' => 'my-account-' . buddypress()->settings->id . '-privacy', 'title' => _x('Privacy', 'My Account Privacy sub nav', 'rtmedia'), 'href' => trailingslashit($settings_link . 'privacy')); } return $wp_admin_nav; }
/** * * @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; } }
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)); } } }
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); } }
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)); } } }