/** * Edit album option * * @global RTMediaQuery $rtmedia_query * * @param array $options * * @return array|void */ function rtmedia_album_edit($options) { if (!is_rtmedia_album() || !is_user_logged_in()) { return; } if (!is_rtmedia_album_enable()) { return; } global $rtmedia_query; if (isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && !in_array(intval($rtmedia_query->media_query['album_id']), array_map('intval', rtmedia_get_site_option('rtmedia-global-albums')), true)) { if (rtmedia_is_album_editable() || is_rt_admin()) { $options[] = "<a href='edit/' class='rtmedia-edit' title='" . esc_attr__('Edit Album', 'buddypress-media') . "' ><i class='rtmicon dashicons dashicons-edit'></i>" . esc_html__('Edit Album', 'buddypress-media') . '</a>'; $options[] = '<form method="post" class="album-delete-form rtmedia-inline" action="delete/">' . wp_nonce_field('rtmedia_delete_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_delete_album_nonce') . '<button type="submit" name="album-delete" class="rtmedia-delete-album" title="' . esc_attr__('Delete Album', 'buddypress-media') . '"><i class="dashicons dashicons-trash rtmicon"></i>' . esc_html__('Delete Album', 'buddypress-media') . '</button></form>'; if (is_rtmedia_group_album()) { $album_list = rtmedia_group_album_list(); } else { $album_list = rtmedia_user_album_list(); } if ($album_list) { $options[] = '<a href="#rtmedia-merge" class="rtmedia-reveal-modal rtmedia-modal-link" title="' . esc_attr__('Merge Album', 'buddypress-media') . '"><i class="dashicons dashicons-randomize"></i>' . esc_html__('Merge Album', 'buddypress-media') . '</a>'; } } } return $options; }
function flush_rules() { $rtmedia_version = rtmedia_get_site_option("rtmedia_flush_rules_plugin_version"); if (!$rtmedia_version) { $rtmedia_version = "0"; } $plugin_data = get_plugin_data(RTMEDIA_PATH . 'index.php'); $new_version = "0"; if (isset($plugin_data) && isset($plugin_data['Version'])) { $new_version = $plugin_data['Version']; } if (version_compare($new_version, $rtmedia_version, '>')) { flush_rewrite_rules(false); rtmedia_update_site_option('rtmedia_flush_rules_plugin_version', $new_version); } }
function add_admin_notice() { $pending = $this->get_pending_count(); if ($pending < 0) { $pending = 0; } rtmedia_update_site_option('rtmedia_media_size_import_pending_count', $pending); $hide_admin_option = rtmedia_get_site_option('rtmedia_hide_media_size_import_notice'); if ($hide_admin_option) { return; } if ($pending > 0) { if (!(isset($_REQUEST['page']) && 'rtmedia-migration-media-size-import' == $_REQUEST['page'])) { $site_option = get_site_option('rtmedia_media_size_import_notice'); if (!$site_option || 'hide' != $site_option) { rtmedia_update_site_option('rtmedia_media_size_import_notice', 'show'); add_action('admin_notices', array(&$this, 'add_rtmedia_media_size_import_notice')); } } } }
function add_admin_notice() { $pending = $this->get_pending_count(); if ($pending < 0) { $pending = 0; } rtmedia_update_site_option("rtmedia_media_size_import_pending_count", $pending); $hide_admin_option = rtmedia_get_site_option('rtmedia_hide_media_size_import_notice'); if ($hide_admin_option) { return; } if ($pending > 0) { if (!(isset($_REQUEST["page"]) && $_REQUEST["page"] == "rtmedia-migration-media-size-import")) { $site_option = get_site_option("rtmedia_media_size_import_notice"); if (!$site_option || $site_option != "hide") { rtmedia_update_site_option("rtmedia_media_size_import_notice", "show"); add_action('admin_notices', array(&$this, 'add_rtmedia_media_size_import_notice')); } } } }
/** * * @param type $media_ids * @param type $file_object * @param type $uploaded * @param string $autoformat thumbnails for genrating thumbs only */ function encoding($media_ids, $file_object, $uploaded, $autoformat = true) { foreach ($file_object as $key => $single) { $type_arry = explode(".", $single['url']); $type = strtolower($type_arry[sizeof($type_arry) - 1]); $not_allowed_type = array("mp3"); if (preg_match('/video|audio/i', $single['type'], $type_array) && !in_array($single['type'], array('audio/mp3')) && !in_array($type, $not_allowed_type)) { $options = rtmedia_get_site_option('rtmedia-options'); $options_vedio_thumb = $options['general_videothumbs']; if ($options_vedio_thumb == "") { $options_vedio_thumb = 3; } /** fORMAT * */ if ($single['type'] == 'video/mp4' || $type == "mp4") { $autoformat = "thumbnails"; } $query_args = array('url' => urlencode($single['url']), 'callbackurl' => urlencode(trailingslashit(home_url()) . "index.php"), 'force' => 0, 'size' => filesize($single['file']), 'formats' => $autoformat === true ? $type_array[0] == 'video' ? 'mp4' : 'mp3' : $autoformat, 'thumbs' => $options_vedio_thumb, 'rt_id' => $media_ids[$key]); $encoding_url = $this->api_url . 'job/new/'; $upload_url = add_query_arg($query_args, $encoding_url . $this->api_key); //error_log(var_export($upload_url, true)); //var_dump($upload_url); $upload_page = wp_remote_get($upload_url, array('timeout' => 200)); //error_log(var_export($upload_page, true)); if (!is_wp_error($upload_page) && (!isset($upload_page['headers']['status']) || isset($upload_page['headers']['status']) && $upload_page['headers']['status'] == 200)) { $upload_info = json_decode($upload_page['body']); if (isset($upload_info->status) && $upload_info->status && isset($upload_info->job_id) && $upload_info->job_id) { $job_id = $upload_info->job_id; update_rtmedia_meta($media_ids[$key], 'rtmedia-encoding-job-id', $job_id); $model = new RTMediaModel(); $model->update(array('cover_art' => '0'), array('id' => $media_ids[$key])); } else { // remove_filter('bp_media_plupload_files_filter', array($bp_media_admin->bp_media_encoding, 'allowed_types')); // return parent::insertmedia($name, $description, $album_id, $group, $is_multiple, $is_activity, $parent_fallback_files, $author_id, $album_name); } } $this->update_usage($this->api_key); } } }
function add_admin_notice() { $pending = $this->get_pending_count(); if ($pending < 0) { $pending = 0; } rtmedia_update_site_option('rtmedia_media_size_import_pending_count', $pending); $hide_admin_option = rtmedia_get_site_option('rtmedia_hide_media_size_import_notice'); if ($hide_admin_option) { return; } if ($pending > 0) { $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); if (!(isset($page) && 'rtmedia-migration-media-size-import' === $page)) { $site_option = get_site_option('rtmedia_media_size_import_notice'); if (!$site_option || 'hide' !== $site_option) { rtmedia_update_site_option('rtmedia_media_size_import_notice', 'show'); add_action('admin_notices', array(&$this, 'add_rtmedia_media_size_import_notice')); } } } }
function add_admin_notice() { $pending = $this->get_pending_count(); $upgrade_done = rtmedia_get_site_option('rtmedia_activity_done_upgrade'); if ($upgrade_done) { return; } if ($pending < 0) { $pending = 0; } rtmedia_update_site_option('rtmedia_media_activity_upgrade_pending', $pending); if ($pending > 0) { if (!(isset($_REQUEST['page']) && 'rtmedia-activity-upgrade' == $_REQUEST['page'])) { $site_option = get_site_option('rtmedia_activity_upgrade_notice'); if (!$site_option || 'hide' != $site_option) { rtmedia_update_site_option('rtmedia_activity_upgrade_notice', 'show'); add_action('admin_notices', array(&$this, 'add_rtmedia_media_activity_upgrade_notice')); } } } else { rtmedia_update_site_option('rtmedia_activity_done_upgrade', true); } }
function add_admin_notice() { $pending = $this->get_pending_count(); $upgrade_done = rtmedia_get_site_option('rtmedia_activity_done_upgrade'); if ($upgrade_done) { return; } if ($pending < 0) { $pending = 0; } rtmedia_update_site_option('rtmedia_media_activity_upgrade_pending', $pending); $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING); if ($pending > 0) { if (!(isset($page) && 'rtmedia-activity-upgrade' === $page)) { $site_option = get_site_option('rtmedia_activity_upgrade_notice'); if (!$site_option || 'hide' !== $site_option) { rtmedia_update_site_option('rtmedia_activity_upgrade_notice', 'show'); add_action('admin_notices', array(&$this, 'add_rtmedia_media_activity_upgrade_notice')); } } } else { rtmedia_update_site_option('rtmedia_activity_done_upgrade', true); } }
function importmedia($id, $prefix) { $delete = false; $attached_file = get_attached_file($id); $attached_file_option = get_post_meta($id, '_wp_attached_file', true); $basename = wp_basename($attached_file); $file_folder_path = trailingslashit(str_replace($basename, '', $attached_file)); $siteurl = get_option('siteurl'); $upload_path = trim(get_option('upload_path')); if (empty($upload_path) || 'wp-content/uploads' == $upload_path) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif (0 !== strpos($upload_path, ABSPATH)) { // $dir is absolute, $upload_path is (maybe) relative to ABSPATH $dir = path_join(ABSPATH, $upload_path); } else { $dir = $upload_path; } if (!($url = get_option('upload_url_path'))) { if (empty($upload_path) || 'wp-content/uploads' == $upload_path || $upload_path == $dir) { $url = WP_CONTENT_URL . '/uploads'; } else { $url = trailingslashit($siteurl) . $upload_path; } } // Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled. // We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. if (defined('UPLOADS') && !(is_multisite() && rtmedia_get_site_option('ms_files_rewriting'))) { $dir = ABSPATH . UPLOADS; $url = trailingslashit($siteurl) . UPLOADS; } // If multisite (and if not the main site in a post-MU network) if (is_multisite() && !(is_main_site() && defined('MULTISITE'))) { if (!rtmedia_get_site_option('ms_files_rewriting')) { // If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward: // Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory // prevents a four-digit ID from conflicting with a year-based directory for the main site. // But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra // directory, as they never had wp-content/uploads for the main site.) if (defined('MULTISITE')) { $ms_dir = '/sites/' . get_current_blog_id(); } else { $ms_dir = '/' . get_current_blog_id(); } $dir .= $ms_dir; $url .= $ms_dir; } elseif (defined('UPLOADS') && !ms_is_switched()) { // Handle the old-form ms-files.php rewriting if the network still has that enabled. // When ms-files rewriting is enabled, then we only listen to UPLOADS when: // 1) we are not on the main site in a post-MU network, // as wp-content/uploads is used there, and // 2) we are not switched, as ms_upload_constants() hardcodes // these constants to reflect the original blog ID. // // Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. // (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as // as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) if (defined('BLOGUPLOADDIR')) { $dir = untrailingslashit(BLOGUPLOADDIR); } else { $dir = ABSPATH . UPLOADS; } $url = trailingslashit($siteurl) . 'files'; } } $basedir = trailingslashit($dir); $baseurl = trailingslashit($url); $new_file_folder_path = trailingslashit(str_replace($basedir, $basedir . "rtMedia/{$prefix}/", $file_folder_path)); $year_month = untrailingslashit(str_replace($basedir, '', $file_folder_path)); $metadata = wp_get_attachment_metadata($id); $backup_metadata = get_post_meta($id, '_wp_attachment_backup_sizes', true); $instagram_thumbs = get_post_meta($id, '_instagram_thumbs', true); $instagram_full_images = get_post_meta($id, '_instagram_full_images', true); $instagram_metadata = get_post_meta($id, '_instagram_metadata', true); $encoding_job_id = get_post_meta($id, 'bp-media-encoding-job-id', true); $ffmpeg_thumbnail_ids = get_post_meta($id, 'bp_media_thumbnail_ids', true); $ffmpeg_thumbnail = get_post_meta($id, 'bp_media_thumbnail', true); $ffmpeg_remote_id = get_post_meta($id, 'bp_media_ffmpeg_remote_id', true); $kaltura_remote_id = get_post_meta($id, 'bp_media_kaltura_remote_id', true); if (wp_mkdir_p($basedir . "rtMedia/{$prefix}/" . $year_month)) { if (copy($attached_file, str_replace($basedir, $basedir . "rtMedia/{$prefix}/", $attached_file))) { $delete = true; if (isset($metadata['sizes'])) { foreach ($metadata['sizes'] as $size) { if (!copy($file_folder_path . $size['file'], $new_file_folder_path . $size['file'])) { $delete = false; } else { $delete_sizes[] = $file_folder_path . $size['file']; $this->search_and_replace(trailingslashit($baseurl . $year_month) . $size['file'], trailingslashit($baseurl . "rtMedia/{$prefix}/" . $year_month) . $size['file']); } } } if ($backup_metadata) { foreach ($backup_metadata as $backup_images) { if (!copy($file_folder_path . $backup_images['file'], $new_file_folder_path . $backup_images['file'])) { $delete = false; } else { $delete_sizes[] = $file_folder_path . $backup_images['file']; $this->search_and_replace(trailingslashit($baseurl . $year_month) . $backup_images['file'], trailingslashit($baseurl . "rtMedia/{$prefix}/" . $year_month) . $backup_images['file']); } } } if ($instagram_thumbs) { foreach ($instagram_thumbs as $key => $insta_thumb) { try { if (!copy(str_replace($baseurl, $basedir, $insta_thumb), str_replace($baseurl, $basedir . "rtMedia/{$prefix}/", $insta_thumb))) { $delete = false; } else { $delete_sizes[] = str_replace($baseurl, $basedir, $insta_thumb); $instagram_thumbs_new[$key] = str_replace($baseurl, $baseurl . "rtMedia/{$prefix}/", $insta_thumb); $this->search_and_replace(trailingslashit($baseurl . $year_month) . $insta_thumb, trailingslashit($baseurl . "rtMedia/{$prefix}/" . $year_month) . $insta_thumb); } } catch (Exceptio $e) { $delete = false; } } } if ($instagram_full_images) { foreach ($instagram_full_images as $key => $insta_full_image) { if (!copy($insta_full_image, str_replace($basedir, $basedir . "rtMedia/{$prefix}/", $insta_full_image))) { $delete = false; } else { $delete_sizes[] = $insta_full_image; $instagram_full_images_new[$key] = str_replace($basedir, $basedir . "rtMedia/{$prefix}", $insta_full_image); $this->search_and_replace(trailingslashit($baseurl . $year_month) . $insta_full_image, trailingslashit($baseurl . "rtMedia/{$prefix}/" . $year_month) . $insta_full_image); } } } if ($instagram_metadata) { $instagram_metadata_new = $instagram_metadata; foreach ($instagram_metadata as $wp_size => $insta_metadata) { if (isset($insta_metadata['file'])) { if (!copy($basedir . $insta_metadata['file'], $basedir . "rtMedia/{$prefix}/" . $insta_metadata['file'])) { $delete = false; } else { $delete_sizes[] = $basedir . $insta_metadata['file']; $instagram_metadata_new[$wp_size]['file'] = "rtMedia/{$prefix}/" . $insta_metadata['file']; if (isset($insta_metadata['sizes'])) { foreach ($insta_metadata['sizes'] as $key => $insta_size) { if (!copy($file_folder_path . $insta_size['file'], $new_file_folder_path . $insta_size['file'])) { $delete = false; } else { $delete_sizes[] = $file_folder_path . $insta_size['file']; $this->search_and_replace(trailingslashit($baseurl . $year_month) . $insta_size['file'], trailingslashit($baseurl . "rtMedia/{$prefix}/" . $year_month) . $insta_size['file']); } } } } } } } if ($delete) { if (file_exists($attached_file)) { unlink($attached_file); } if (isset($delete_sizes)) { foreach ($delete_sizes as $delete_size) { if (file_exists($delete_size)) { unlink($delete_size); } } } update_post_meta($id, '_wp_attached_file', "rtMedia/{$prefix}/" . $attached_file_option); if (isset($metadata['file'])) { $metadata['file'] = "rtMedia/{$prefix}/" . $metadata['file']; wp_update_attachment_metadata($id, $metadata); } if ($instagram_thumbs) { update_rtmedia_meta($id, '_instagram_thumbs', $instagram_thumbs_new); } if ($instagram_full_images) { update_rtmedia_meta($id, '_instagram_full_images', $instagram_full_images_new); } if ($instagram_metadata) { update_rtmedia_meta($id, '_instagram_metadata', $instagram_metadata_new); } if ($encoding_job_id) { update_rtmedia_meta($id, 'rtmedia-encoding-job-id', $encoding_job_id); } if ($ffmpeg_thumbnail_ids) { update_rtmedia_meta($id, 'rtmedia-thumbnail-ids', $ffmpeg_thumbnail_ids); } if ($ffmpeg_thumbnail) { $model = new RTMediaModel(); $model->update(array('cover_art' => $ffmpeg_thumbnail), array('id' => $id)); } if ($ffmpeg_remote_id) { update_rtmedia_meta($id, 'rtmedia-ffmpeg-remote-id', $ffmpeg_remote_id); } if ($kaltura_remote_id) { update_rtmedia_meta($id, 'rtmedia-kaltura-remote-id', $kaltura_remote_id); } $attachment = array(); $attachment['ID'] = $id; $old_guid = get_post_field('guid', $id); $attachment['guid'] = str_replace($baseurl, $baseurl . "rtMedia/{$prefix}/", $old_guid); /** * For Activity */ global $last_baseurl, $last_newurl; $last_baseurl = $baseurl; $last_newurl = $baseurl . "rtMedia/{$prefix}/"; $this->search_and_replace($old_guid, $attachment['guid']); wp_update_post($attachment); } } } }
function check_global_album() { //todo: Nonce required $album = new RTMediaAlbum(); $global_album = $album->get_default(); // @codingStandardsIgnoreStart //** Hack for plupload default name if (isset($_POST['action']) && isset($_POST['mode']) && 'file_upload' === sanitize_text_field($_POST['mode'])) { unset($_POST['name']); } // @codingStandardsIgnoreEnd //** global $rtmedia_error; if (isset($rtmedia_error) && true === $rtmedia_error) { return false; } if (!$global_album) { $global_album = $album->add_global(esc_html__('Wall Posts', 'buddypress-media')); } // fix multisite global album doesn't exist issue. if (is_multisite() && !rtmedia_get_site_option('rtmedia_fix_multisite_global_albums', false)) { $model = new RTMediaModel(); $global_albums = rtmedia_global_albums(); $album_objects = $model->get_media(array('id' => $global_albums), false, false); if (empty($album_objects)) { $global_album = $album->add_global(esc_html__('Wall Posts', 'buddypress-media')); } rtmedia_update_site_option('rtmedia_fix_multisite_global_albums', true); } }
function redirect_on_change_slug() { $old_slugs = rtmedia_get_site_option("rtmedia_old_media_slug", false, true); $current_slugs = rtmedia_get_site_option("rtmedia_current_media_slug", false, false); if ($current_slugs === false) { rtmedia_update_site_option("rtmedia_current_media_slug", RTMEDIA_MEDIA_SLUG); return; } if ($current_slugs === RTMEDIA_MEDIA_SLUG) { return; } if ($old_slugs === false) { $old_slugs = array(); } $old_slugs[] = $current_slugs; rtmedia_update_site_option("rtmedia_current_media_slug", RTMEDIA_MEDIA_SLUG); }
function rtmedia_api_process_request() { $rtmedia_enable_json_api = false; if (function_exists('rtmedia_get_site_option')) { $rtmedia_options = rtmedia_get_site_option('rtmedia-options'); if (!empty($rtmedia_options)) { if ($rtmedia_options['rtmedia_enable_api']) { $rtmedia_enable_json_api = true; } } } if (!$rtmedia_enable_json_api) { wp_send_json($this->rtmedia_api_response_object('FALSE', $this->ec_api_disabled, $this->msg_api_disabled)); } $method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING); if (empty($method)) { wp_send_json($this->rtmedia_api_response_object('FALSE', $this->ec_method_missing, $this->msg_method_missing)); } if (!class_exists('BuddyPress')) { wp_send_json($this->rtmedia_api_response_object('FALSE', $this->ec_bp_missing, $this->msg_bp_missing)); } $this->rtmediajsonapifunction = new RTMediaJsonApiFunctions(); $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING); if (!empty($token)) { $this->rtmediajsonapifunction->rtmedia_api_verfiy_token(); $this->user_id = $this->rtmediajsonapifunction->rtmedia_api_get_user_id_from_token($token); //add filter add_filter('rtmedia_current_user', array($this->rtmediajsonapifunction, 'rtmedia_api_set_user_id')); } //Process Request switch ($method) { case 'wp_login': $this->rtmedia_api_process_wp_login_request(); break; case 'wp_logout': //todo implement this function rtmedia_api_process_wp_logout_request if needed //$this->rtmedia_api_process_wp_logout_request(); break; case 'wp_register': $this->rtmedia_api_process_wp_register_request(); break; case 'wp_forgot_password': $this->rtmedia_api_process_wp_forgot_password_request(); break; case 'bp_get_profile': $this->rtmedia_api_process_bp_get_profile_request(); break; case 'bp_get_activities': $this->rtmedia_api_process_bp_get_activities_request(); break; case 'add_rtmedia_comment': $this->rtmedia_api_process_add_rtmedia_comment_request(); break; case 'like_media': $this->rtmedia_api_process_like_media_request(); break; case 'get_rtmedia_comments': $this->rtmedia_api_process_get_rtmedia_comments_request(); break; case 'get_likes_rtmedia': $this->rtmedia_api_process_get_likes_rtmedia_request(); break; case 'remove_comment': $this->rtmedia_api_process_remove_comment_request(); break; case 'update_profile': $this->rtmedia_api_process_update_profile_request(); break; case 'rtmedia_upload_media': $this->rtmedia_api_process_rtmedia_upload_media_request(); break; case 'rtmedia_gallery': $this->rtmedia_api_process_rtmedia_gallery_request(); break; case 'rtmedia_get_media_details': $this->rtmedia_api_process_rtmedia_get_media_details_request(); break; default: wp_send_json($this->rtmedia_api_response_object('FALSE', $this->ec_invalid_request_type, $this->msg_invalid_request_type)); } wp_die(); }
?> </button> <input type="hidden" name="move-selected" value="move"> <button type="button" name="delete-selected" class="button rtmedia-delete-selected" title='<?php esc_attr_e('Delete Selected media from the album.', 'buddypress-media'); ?> '><?php esc_html_e('Delete', 'buddypress-media'); ?> </button> </p> <p class="rtmedia-move-container"> <?php $global_albums = rtmedia_get_site_option('rtmedia-global-albums'); ?> <span><?php esc_html_e('Move selected media to the album : ', 'buddypress-media'); ?> </span> <select name="album" class="rtmedia-user-album-list"><?php echo rtmedia_user_album_list(); ?> </select> <input type="button" class="rtmedia-move-selected" name="move-selected" value="<?php esc_attr_e('Move Selected', 'buddypress-media'); ?> "/> </p>
/** * Check if activity privacy migration is done or not. * * @return bool|mixed|void */ function can_use_rtm_ac_privacy() { return rtmedia_get_site_option('rtmedia_activity_done_upgrade'); }
function rtmedia_api_process_request() { $rtmedia_enable_json_api = FALSE; if (function_exists('rtmedia_get_site_option')) { $rtmedia_options = rtmedia_get_site_option('rtmedia-options'); if (!empty($rtmedia_options)) { if ($rtmedia_options['rtmedia_enable_api']) { $rtmedia_enable_json_api = TRUE; } } } if (!$rtmedia_enable_json_api) { echo $this->rtmedia_api_response_object('FALSE', $this->ec_api_disabled, $this->msg_api_disabled); die; } if (empty($_POST['method'])) { echo $this->rtmedia_api_response_object('FALSE', $this->ec_method_missing, $this->msg_method_missing); die; } if (!class_exists('BuddyPress')) { echo $this->rtmedia_api_response_object('FALSE', $this->ec_bp_missing, $this->msg_bp_missing); die; } $this->rtmediajsonapifunction = new RTMediaJsonApiFunctions(); if (!empty($_POST['token'])) { $this->rtmediajsonapifunction->rtmedia_api_verfiy_token(); $this->user_id = $this->rtmediajsonapifunction->rtmedia_api_get_user_id_from_token($_POST['token']); //add filter add_filter('rtmedia_current_user', array($this->rtmediajsonapifunction, 'rtmedia_api_set_user_id')); } //Process Request $method = !empty($_POST['method']) ? $_POST['method'] : ''; switch ($method) { case 'wp_login': $this->rtmedia_api_process_wp_login_request(); break; case 'wp_logout': $this->rtmedia_api_process_wp_logout_request(); break; case 'wp_register': $this->rtmedia_api_process_wp_register_request(); break; case 'wp_forgot_password': $this->rtmedia_api_process_wp_forgot_password_request(); break; case 'bp_get_profile': $this->rtmedia_api_process_bp_get_profile_request(); break; case 'bp_get_activities': $this->rtmedia_api_process_bp_get_activities_request(); break; case 'add_rtmedia_comment': $this->rtmedia_api_process_add_rtmedia_comment_request(); break; case 'like_media': $this->rtmedia_api_process_like_media_request(); break; case 'get_rtmedia_comments': $this->rtmedia_api_process_get_rtmedia_comments_request(); break; case 'get_likes_rtmedia': $this->rtmedia_api_process_get_likes_rtmedia_request(); break; case 'remove_comment': $this->rtmedia_api_process_remove_comment_request(); break; case 'update_profile': $this->rtmedia_api_process_update_profile_request(); break; case 'rtmedia_upload_media': $this->rtmedia_api_process_rtmedia_upload_media_request(); break; case 'rtmedia_gallery': $this->rtmedia_api_process_rtmedia_gallery_request(); break; case 'rtmedia_get_media_details': $this->rtmedia_api_process_rtmedia_get_media_details_request(); break; default: echo $this->rtmedia_api_response_object('FALSE', $this->ec_invalid_request_type, $this->msg_invalid_request_type); exit; } die(1); }
function check_global_album() { $album = new RTMediaAlbum(); $global_album = $album->get_default(); //** Hack for plupload default name if (isset($_POST["action"]) && isset($_POST["mode"]) && $_POST["mode"] == "file_upload") { unset($_POST["name"]); } //** global $rtmedia_error; if (isset($rtmedia_error) && $rtmedia_error === true) { return false; } if (!$global_album) { $global_album = $album->add_global(__("Wall Posts", 'buddypress-media')); } // fix multisite global album doesn't exist issue. if (is_multisite() && !rtmedia_get_site_option('rtmedia_fix_multisite_global_albums', false)) { $model = new RTMediaModel(); $global_albums = rtmedia_global_albums(); $album_objects = $model->get_media(array('id' => $global_albums), false, false); if (empty($album_objects)) { $global_album = $album->add_global(__("Wall Posts", 'buddypress-media')); } rtmedia_update_site_option('rtmedia_fix_multisite_global_albums', true); } }
function activity_privacy($sql, $select_sql, $from_sql, $where_sql, $sort, $pag_sql = '') { if (is_rt_admin()) { return $sql; } $sql = ''; $where = ''; global $bp, $wpdb; $rtmedia_model = new RTMediaModel(); if (is_user_logged_in()) { $user = get_current_user_id(); } else { $user = 0; } $activity_upgrade_done = rtmedia_get_site_option('rtmedia_activity_done_upgrade'); // admin has upgraded rtmedia activity so we can use rt_rtm_activity table for rtmedia related activity filters if ($activity_upgrade_done) { $rtmedia_activity_model = new RTMediaActivityModel(); $where .= " (ra.privacy is NULL OR ra.privacy <= 0) "; if ($user) { $where .= "OR ((ra.privacy=20)"; $where .= " OR (a.user_id={$user} AND ra.privacy >= 40)"; if (class_exists('BuddyPress')) { if (bp_is_active('friends')) { $friendship = new RTMediaFriends(); $friends = $friendship->get_friends_cache($user); if (isset($friends) && !empty($friends) != "") { $where .= " OR (ra.privacy=40 AND a.user_id IN ('" . implode("','", $friends) . "'))"; } } } $where .= ')'; } if (function_exists("bp_core_get_table_prefix")) { $bp_prefix = bp_core_get_table_prefix(); } else { $bp_prefix = ""; } if (strpos($select_sql, "SELECT DISTINCT") === false) { $select_sql = str_replace("SELECT", "SELECT DISTINCT", $select_sql); } $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID LEFT JOIN {$rtmedia_model->table_name} m ON ( a.id = m.activity_id AND m.blog_id = '" . get_current_blog_id() . "' ) LEFT JOIN {$rtmedia_activity_model->table_name} ra ON ( a.id = ra.activity_id and ra.blog_id = '" . get_current_blog_id() . "' ) "; $where_sql = $where_sql . " AND (NOT EXISTS (SELECT m.activity_id FROM {$bp_prefix}bp_activity_meta m WHERE m.meta_key='rtmedia_privacy' AND m.activity_id=a.id) OR ( {$where} ) )"; $newsql = "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}"; } else { $where .= " (m.max_privacy is NULL OR m.max_privacy <= 0) "; if ($user) { $where .= "OR ((m.max_privacy=20)"; $where .= " OR (a.user_id={$user} AND m.max_privacy >= 40)"; if (class_exists('BuddyPress')) { if (bp_is_active('friends')) { $friendship = new RTMediaFriends(); $friends = $friendship->get_friends_cache($user); if (isset($friends) && !empty($friends) != "") { $where .= " OR (m.max_privacy=40 AND a.user_id IN ('" . implode("','", $friends) . "'))"; } } } $where .= ')'; } if (function_exists("bp_core_get_table_prefix")) { $bp_prefix = bp_core_get_table_prefix(); } else { $bp_prefix = ""; } if (strpos($select_sql, "SELECT DISTINCT") === false) { $select_sql = str_replace("SELECT", "SELECT DISTINCT", $select_sql); } $media_table = "SELECT *, max( privacy ) as max_privacy from {$rtmedia_model->table_name} group by activity_id"; $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID LEFT JOIN ( {$media_table} ) m ON ( a.id = m.activity_id AND m.blog_id = '" . get_current_blog_id() . "' ) "; $where_sql = $where_sql . " AND (NOT EXISTS (SELECT m.activity_id FROM {$bp_prefix}bp_activity_meta m WHERE m.meta_key='rtmedia_privacy' AND m.activity_id=a.id) OR ( {$where} ) )"; $newsql = "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}"; } return $newsql; }
function rtmedia_album_edit($options) { if (!is_rtmedia_album() || !is_user_logged_in()) { return; } if (!is_rtmedia_album_enable()) { return; } global $rtmedia_query; ?> <?php if (isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && !in_array($rtmedia_query->media_query['album_id'], rtmedia_get_site_option('rtmedia-global-albums'))) { //if ( isset ( $rtmedia_query->media_query[ 'media_author' ] ) && get_current_user_id () == $rtmedia_query->media_query[ 'media_author' ] ) { if (rtmedia_is_album_editable() || is_rt_admin()) { $options[] = "<a href='edit/' class='rtmedia-edit' title='" . __('Edit Album', 'rtmedia') . "' ><i class='rtmicon-edit rtmicon-fw'></i>" . __('Edit Album', 'rtmedia') . "</a>"; $options[] = '<form method="post" class="album-delete-form rtmedia-inline" action="delete/">' . wp_nonce_field('rtmedia_delete_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_delete_album_nonce') . '<button type="submit" name="album-delete" class="rtmedia-delete-album" title="' . __('Delete Album', 'rtmedia') . '"><i class="rtmicon-trash-o rtmicon-fw"></i>' . __('Delete Album', 'rtmedia') . '</button></form>'; if (is_rtmedia_group_album()) { $album_list = rtmedia_group_album_list(); } else { $album_list = rtmedia_user_album_list(); } if ($album_list) { $options[] = '<a href="#rtmedia-merge" class="rtmedia-reveal-modal rtmedia-modal-link" title="' . __('Merge Album', 'rtmedia') . '"><i class="rtmicon-code-fork rtmicon-fw"></i>' . __('Merge Album', 'rtmedia') . '</a>'; } } } return $options; }
function rtmedia_update_template_notice() { $site_option = rtmedia_get_site_option('rtmedia-update-template-notice-v3_9_4'); if (!$site_option || 'hide' != $site_option) { rtmedia_update_site_option('rtmedia-update-template-notice-v3_9_4', 'show'); if (is_dir(get_template_directory() . '/rtmedia')) { echo '<div class="error rtmedia-update-template-notice"><p>' . esc_html__('Please update rtMedia template files if you have overridden the default rtMedia templates in your theme. If not, you can ignore and hide this notice.', 'buddypress-media') . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . esc_html__('Hide', 'buddypress-media') . '</a>' . ' </p></div>'; ?> <script type="text/javascript"> function rtmedia_hide_template_override_notice() { var data = { action: 'rtmedia_hide_template_override_notice' }; jQuery.post( ajaxurl, data, function ( response ) { response = response.trim(); if ( '1' === response ) jQuery( '.rtmedia-update-template-notice' ).remove(); } ); } </script> <?php } } }
public function site_default() { global $rtmedia; return rtmedia_get_site_option('privacy_settings'); }
/** * Get the list of all global albums * * @return type */ static function get_globals() { return rtmedia_get_site_option('rtmedia-global-albums'); }
/** * Generate migration_html. * * @access public * * @param type $page * * @return bool */ public function migration_html($page = '') { $pending_rtmedia_migrate = rtmedia_get_site_option('rtMigration-pending-count'); $content = ' '; $flag = true; if (false === $pending_rtmedia_migrate || 0 == $pending_rtmedia_migrate) { $content .= __('There is no media found to migrate.', 'buddypress-media'); $flag = false; } $content = apply_filters('rtmedia_migration_content_filter', $content); if ($flag) { $content .= ' <div class="rtmedia-migration-support">'; $content .= ' <p>' . __('Click', 'buddypress-media') . ' <a href="' . get_admin_url() . 'admin.php?page=rtmedia-migration">' . __('here', 'buddypress-media') . '</a>' . __('here to migrate media from rtMedia 2.x to rtMedia 3.0+.', 'buddypress-media') . '</p>'; $content .= '</div>'; } ?> <div id="rtmedia-migration-html"> <?php echo $content; ?> </div> <?php }
/** * Show allowed types. * * @access public * * @param void * * @return void */ public function allowed_types() { $allowed_types = rtmedia_get_site_option('upload_filetypes', 'jpg jpeg png gif'); $allowed_types = explode(' ', $allowed_types); $allowed_types = implode(', ', $allowed_types); echo '<span class="description">' . sprintf(__('Currently your network allows uploading of the following file types. You can change the settings <a href="%s">here</a>.<br /><code>%s</code></span>', 'rtmedia'), network_admin_url('settings.php#upload_filetypes'), $allowed_types); }
/** * Show allowed types. * * @access public * * @param void * * @return void */ public function allowed_types() { $allowed_types = rtmedia_get_site_option('upload_filetypes', 'jpg jpeg png gif'); $allowed_types = explode(' ', $allowed_types); $allowed_types = implode(', ', $allowed_types); echo '<span class="description">' . sprintf(esc_html__('Currently your network allows uploading of the following file types. You can change the settings %s', 'buddypress-media'), '<a href="' . esc_url(network_admin_url('settings.php#upload_filetypes')) . '">' . esc_html__('here', 'buddypress-media') . '</a><br /><code>' . esc_html($allowed_types) . '</code>') . '</span>'; }