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 return_migration($media = false, $migrate = true)
 {
     $total = $this->get_total_count();
     $pending = $this->get_pending_count($media->id);
     $done = $total - $pending;
     if ($pending < 0) {
         $pending = 0;
         $done = $total;
     }
     if ($done > $total) {
         $done = $total;
     }
     rtmedia_update_site_option('rtmedia_media_size_import_pending_count', $pending);
     $pending_time = rtmedia_migrate_formatseconds($pending) . ' (estimated)';
     echo json_encode(array('status' => true, 'done' => $done, 'total' => $total, 'pending' => $pending_time, 'media_id' => $media->id, 'imported' => $migrate));
     die;
 }
 /**
  * Save global albums for newly added album
  *
  * @param type $album_ids
  *
  * @return boolean
  */
 function save_globals($album_ids = false)
 {
     if (!$album_ids) {
         return false;
     }
     $albums = self::get_globals();
     if (!$albums) {
         $albums = array();
     }
     if (!is_array($album_ids)) {
         $album_ids = array($album_ids);
     }
     $albums = array_merge($albums, $album_ids);
     rtmedia_update_site_option('rtmedia-global-albums', $albums);
 }
Exemple #4
0
 function rtmedia_hide_template_override_notice()
 {
     if (rtmedia_update_site_option('rtmedia-update-template-notice-v3_9_4', 'hide')) {
         echo '1';
     } else {
         echo '0';
     }
     die;
 }
 function migrate_encoding_options()
 {
     $encoding_mnigration_array = array('bp-media-encoding-api-key' => 'rtmedia-encoding-api-key', 'bp-media-encoding-usage-limit-mail' => 'rtmedia-encoding-usage-limit-mail', 'bp-media-encoding-usage' => 'rtmedia-encoding-usage', 'bpmedia_encoding_service_notice' => 'rtmedia-encoding-service-notice', 'bpmedia_encoding_expansion_notice' => 'rtmedia-encoding-expansion-notice', 'bp_media_ffmpeg_options' => 'rtmedia-ffmpeg-options', 'bp_media_kaltura_options' => 'rtmedia-kaltura-options');
     foreach ($encoding_mnigration_array as $key => $ma) {
         if (false !== ($value = rtmedia_get_site_option($key))) {
             rtmedia_update_site_option($ma, $value);
         }
     }
 }
Exemple #6
0
 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 return_upgrade($activity_data, $upgrade = true)
 {
     $total = $this->get_total_count();
     $pending = $this->get_pending_count($activity_data->activity_id);
     $done = $total - $pending;
     if ($pending < 0) {
         $pending = 0;
         $done = $total;
     }
     if ($done > $total) {
         $done = $total;
     }
     rtmedia_update_site_option('rtmedia_media_activity_upgrade_pending', $pending);
     $pending_time = rtmedia_migrate_formatseconds($pending) . ' (estimated)';
     echo wp_json_encode(array('status' => true, 'done' => $done, 'total' => $total, 'pending' => $pending_time, 'activity_id' => $activity_data->activity_id, 'imported' => $upgrade));
     die;
 }
Exemple #8
0
 function rtmedia_hide_template_override_notice()
 {
     if (check_ajax_referer('rtmedia_template_notice', '_rtm_nonce') && rtmedia_update_site_option('rtmedia-update-template-notice-v3_9_4', 'hide')) {
         echo '1';
     } else {
         echo '0';
     }
     die;
 }
 /**
  * Sanitizes the settings
  *
  * @access public
  * @global type $rtmedia_admin
  *
  * @param  type $input
  *
  * @return type $input
  */
 public function sanitize($input)
 {
     global $rtmedia_admin;
     if (isset($_POST['refresh-count'])) {
         if ($rtmedia_admin->update_count()) {
             if (is_multisite()) {
                 rtmedia_update_site_option('rtm-recount-success', __('Recounting of media files done successfully', 'rtmedia'));
             } else {
                 add_settings_error(__('Recount Success', 'rtmedia'), 'rtm-recount-success', __('Recounting of media files done successfully', 'rtmedia'), 'updated');
             }
         } else {
             if (is_multisite()) {
                 rtmedia_update_site_option('rtm-recount-fail', __('Recounting Failed', 'rtmedia'));
             } else {
                 add_settings_error(__('Recount Fail', 'rtmedia'), 'rtm-recount-fail', __('Recounting Failed', 'rtmedia'));
             }
         }
     }
     //            if (!isset($_POST['rtmedia_options']['enable_on_profile']) && !isset($_POST['rtmedia_options']['enable_on_group'])) {
     //                if (is_multisite())
     //                    update_site_option('rtm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', 'rtmedia'));
     //                else
     //                    add_settings_error(__('Enable BuddyPress Media', 'rtmedia'), 'rtm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', 'rtmedia'));
     //                $input['enable_on_profile'] = 1;
     //            }
     if (!isset($_POST['rtmedia_options']['videos_enabled']) && !isset($_POST['rtmedia_options']['audio_enabled']) && !isset($_POST['rtmedia_options']['images_enabled'])) {
         if (is_multisite()) {
             rtmedia_update_site_option('rtm-media-type', __('Atleast one Media Type Must be selected', 'rtmedia'));
         } else {
             add_settings_error(__('Media Type', 'rtmedia'), 'rtm-media-type', __('Atleast one Media Type Must be selected', 'rtmedia'));
         }
         $input['images_enabled'] = 1;
     }
     $input['default_count'] = intval($_POST['rtmedia_options']['default_count']);
     if (!is_int($input['default_count']) || $input['default_count'] < 0 || empty($input['default_count'])) {
         if (is_multisite()) {
             rtmedia_update_site_option('rtm-media-default-count', __('"Number of media" count value should be numeric and greater than 0.', 'rtmedia'));
         } else {
             add_settings_error(__('Default Count', 'rtmedia'), 'rtm-media-default-count', __('"Number of media" count value should be numeric and greater than 0.', 'rtmedia'));
         }
         $input['default_count'] = 10;
     }
     if (is_multisite()) {
         rtmedia_update_site_option('rtm-settings-saved', __('Settings saved.', 'rtmedia'));
     }
     do_action('rtmedia_sanitize_settings', $_POST, $input);
     return $input;
 }
Exemple #10
0
 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 rtmedia_hide_template_override_notice()
 {
     if (rtmedia_update_site_option("rtmedia-update-template-notice-v3_13", "hide")) {
         echo "1";
     } else {
         echo "0";
     }
     die;
 }
 function return_migration($media, $migrate = true)
 {
     $total = $this->get_total_count();
     $pending = $this->get_pending_count($media->id);
     $done = $total - $pending;
     if ($pending < 0) {
         $pending = 0;
         $done = $total;
     }
     if ($done > $total) {
         $done = $total;
     }
     rtmedia_update_site_option('rtmedia_media_size_import_pending_count', $pending);
     $pending_time = rtmedia_migrate_formatseconds($pending) . " (estimated)";
     echo json_encode(array("status" => true, "done" => $done, "total" => $total, "pending" => $pending_time, "media_id" => $media->id, "imported" => $migrate));
     die;
 }
Exemple #13
0
 /**
  * Sanitizes the settings
  *
  * @access public
  * @global type $rtmedia_admin
  *
  * @param  type $input
  *
  * @return type $input
  */
 public function sanitize($input)
 {
     $rtmedia_options = filter_input(INPUT_POST, 'rtmedia-options', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     if (!isset($rtmedia_options['videos_enabled']) && !isset($rtmedia_options['audio_enabled']) && !isset($rtmedia_options['images_enabled'])) {
         if (is_multisite()) {
             rtmedia_update_site_option('rtm-media-type', esc_html__('Atleast one Media Type Must be selected', 'buddypress-media'));
         } else {
             add_settings_error(esc_html__('Media Type', 'buddypress-media'), 'rtm-media-type', esc_html__('Atleast one Media Type Must be selected', 'buddypress-media'));
         }
         $input['images_enabled'] = 1;
     }
     $input['default_count'] = intval($rtmedia_options['default_count']);
     if (!is_int($input['default_count']) || $input['default_count'] < 0 || empty($input['default_count'])) {
         if (is_multisite()) {
             rtmedia_update_site_option('rtm-media-default-count', esc_html__('"Number of media" count value should be numeric and greater than 0.', 'buddypress-media'));
         } else {
             add_settings_error(esc_html__('Default Count', 'buddypress-media'), 'rtm-media-default-count', esc_html__('"Number of media" count value should be numeric and greater than 0.', 'buddypress-media'));
         }
         $input['default_count'] = 10;
     }
     if (is_multisite()) {
         rtmedia_update_site_option('rtm-settings-saved', esc_html__('Settings saved.', 'buddypress-media'));
     }
     do_action('rtmedia_sanitize_settings', $_POST, $input);
     // @codingStandardsIgnoreLine
     return $input;
 }
Exemple #14
0
 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);
 }