예제 #1
0
 /**
  * ------------------------------------------------------------------------
  * Migrate Media Information
  */
 public function ajax_migrate_media_information()
 {
     global $wpdb;
     $mime_types = awpcp_mime_types();
     if (!awpcp_table_exists(AWPCP_TABLE_ADPHOTOS)) {
         return $this->ajax_response(0, 0);
     }
     $cursor = get_option('awpcp-migrate-media-information-cursor', 0);
     $total = $this->count_pending_images($cursor);
     $sql = 'SELECT * FROM ' . AWPCP_TABLE_ADPHOTOS . ' ';
     $sql .= 'WHERE ad_id > %d ORDER BY key_id LIMIT 0, 100';
     $results = $wpdb->get_results($wpdb->prepare($sql, $cursor));
     $uploads = awpcp_setup_uploads_dir();
     $uploads = array_shift($uploads);
     foreach ($results as $image) {
         $cursor = $image->ad_id;
         $filename = awpcp_get_image_url($image->image_name);
         if (empty($filename)) {
             continue;
         }
         $path = str_replace(AWPCPUPLOADURL, $uploads, $filename);
         $mime_type = $mime_types->get_file_mime_type($path);
         $entry = array('ad_id' => $image->ad_id, 'path' => $image->image_name, 'name' => $image->image_name, 'mime_type' => strtolower($mime_type), 'enabled' => !$image->disabled, 'is_primary' => $image->is_primary, 'created' => awpcp_datetime());
         $wpdb->insert(AWPCP_TABLE_MEDIA, $entry);
     }
     update_option('awpcp-migrate-media-information-cursor', $cursor);
     $remaining = $this->count_pending_images($cursor);
     if (0 === $remaining) {
         // TODO: do this in the next version upgrade
         // $wpdb->query( 'DROP TABLE ' . AWPCP_TABLE_ADPHOTOS );
         delete_option('awpcp-migrate-media-information');
         $this->update_pending_upgrades_status();
     }
     return $this->ajax_response($total, $remaining);
 }
예제 #2
0
 private function upgrade_to_3_0_2($oldversion)
 {
     global $wpdb;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $manual_upgrade_required = false;
     $settings = awpcp()->settings;
     // fix for all Ads being (visually) marked as featured (part of #527).
     $layout = $settings->get_option('displayadlayoutcode');
     $layout = str_replace('awpcp_featured_ad_wrapper', '$isfeaturedclass', $layout);
     $settings->update_option('displayadlayoutcode', $layout);
     // create awpcp_ad_regions table
     dbDelta($this->create_ad_regions_table);
     // create awpcp_media table
     dbDelta($this->create_media_table);
     // Create ad metadata table.
     dbDelta($this->create_ad_meta_table);
     // migrate old regions
     if (awpcp_column_exists(AWPCP_TABLE_ADS, 'ad_country')) {
         update_option('awpcp-migrate-regions-information', true);
         // the following option was used as the cursor during the first
         // upgrade. However, we had to rollback some of the modifications
         // and the upgrade had to be run again. The new cursor is:
         // 'awpcp-migrate-regions-info-cursor'.
         delete_option('awpcp-migrate-regions-information-cursor');
         $manual_upgrade_required = true;
     }
     // migrate media regions
     if (awpcp_table_exists(AWPCP_TABLE_ADPHOTOS)) {
         update_option('awpcp-migrate-media-information', true);
         $manual_upgrade_required = true;
     }
     // add columns required for email verification feature
     $this->columns->create(AWPCP_TABLE_ADS, 'verified', "TINYINT(1) NOT NULL DEFAULT 1");
     $this->columns->create(AWPCP_TABLE_ADS, 'verified_at', "DATETIME");
     // add payer email column
     $this->columns->create(AWPCP_TABLE_ADS, 'payer_email', "VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `payment_status`");
     $this->columns->create(AWPCP_TABLE_PAYMENTS, 'payment_gateway', "VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `payment_status`");
     $this->columns->create(AWPCP_TABLE_PAYMENTS, 'payer_email', "VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `payment_status`");
     if (awpcp_column_exists(AWPCP_TABLE_ADS, 'payer_email')) {
         $wpdb->query("UPDATE " . AWPCP_TABLE_ADS . " SET payer_email = ad_contact_email");
     }
     if ($manual_upgrade_required) {
         update_option('awpcp-pending-manual-upgrade', true);
     }
 }
예제 #3
0
/**
 * @deprecated since 2.0.7
 */
function checkfortable($table)
{
    return awpcp_table_exists($table);
}