Skip to content

Commit

Permalink
Merge pull request #25 from moderntribe/fix/85214-tweaks
Browse files Browse the repository at this point in the history
tweaks
  • Loading branch information
zbtirrell authored Aug 18, 2017
2 parents 5dec712 + 1914f94 commit 5e57e60
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 75 deletions.
69 changes: 35 additions & 34 deletions admin/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Note that the following columns are deprectated as of DB version 1.4,
// but cannot be dropped due to the neccessities of the upgrade process:
// show_address, show_locale, show_country, show_venue, show_venue_url, show_venue_phone

$gp_db[] = "CREATE TABLE " . GIGPRESS_SHOWS . " (
show_id INTEGER(4) AUTO_INCREMENT,
show_artist_id INTEGER(4) NOT NULL,
Expand All @@ -37,7 +37,7 @@
show_country VARCHAR(2),
show_venue VARCHAR(255),
show_venue_url VARCHAR(255),
show_venue_phone VARCHAR(255),
show_venue_phone VARCHAR(255),
PRIMARY KEY (show_id)
) $charset_collate";

Expand All @@ -57,9 +57,9 @@
venue_city VARCHAR(255) NOT NULL,
venue_state VARCHAR(255),
venue_postal_code VARCHAR(32),
venue_country VARCHAR(2) NOT NULL,
venue_country VARCHAR(2) NOT NULL,
venue_url VARCHAR(255),
venue_phone VARCHAR(255),
venue_phone VARCHAR(255),
PRIMARY KEY (venue_id)
) $charset_collate";

Expand All @@ -79,15 +79,16 @@
$default_settings = array(
'age_restrictions' => 'All Ages | All Ages/Licensed | No Minors',
'alternate_clock' => 0,
'artist_label' => 'Artist',
'artist_link' => 1,
'artist_label' => 'Artist',
'artist_link' => 1,
'autocreate_post' => 0,
'buy_tickets_label' => 'Buy Tickets',
'buy_tickets_label' => 'Buy Tickets',
'category_exclude' => 0,
'country_view' => 'long',
'date_format_long' => 'l, F jS Y',
'date_format' => 'm/d/y',
'db_version' => GIGPRESS_DB_VERSION,
'default_artist' => '',
'default_country' => 'US',
'default_date' => '',
'default_time' => '00:00:01',
Expand All @@ -109,7 +110,7 @@
'related_date' => 'now',
'relatedlink_city' => 0,
'relatedlink_date' => 0,
'relatedlink_notes' => 1,
'relatedlink_notes' => 1,
'rss_head' => 1,
'rss_limit' => 100,
'rss_list' => 1,
Expand All @@ -121,7 +122,7 @@
'timezone' => $timezone,
'tour_label' => 'Tour',
'user_level' => 'edit_posts',
'welcome' => 'yes'
'welcome' => 'yes',
);

global $gpo;
Expand Down Expand Up @@ -153,7 +154,7 @@
function gigpress_install() {

global $wpdb, $gp_db, $default_settings;

if($wpdb->get_var("SHOW TABLES LIKE '" . GIGPRESS_SHOWS . "'") != GIGPRESS_SHOWS) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($gp_db);
Expand All @@ -165,18 +166,18 @@ function gigpress_install() {
// Upgrade checks and functions

if ( $gpo['db_version'] < GIGPRESS_DB_VERSION ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($gp_db);

switch($gpo['db_version']) {
case "1.0":
gigpress_db_upgrade_110();
gigpress_db_upgrade_120();
gigpress_db_upgrade_130();
gigpress_db_upgrade_140();
gigpress_db_upgrade_160();
break;
break;
case "1.1":
gigpress_db_upgrade_120();
gigpress_db_upgrade_130();
Expand All @@ -199,7 +200,7 @@ function gigpress_install() {
gigpress_db_upgrade_160();
break;
}

$gpo['db_version'] = GIGPRESS_DB_VERSION;
update_option('gigpress_settings', $gpo);

Expand All @@ -215,16 +216,16 @@ function gigpress_db_upgrade_110() {
$getshows = $wpdb->get_results("
SELECT * FROM " . GIGPRESS_SHOWS . " WHERE show_multi IS NULL
");

// Update each one's show_expire with its show_date
if($getshows) {
foreach($getshows as $show) {
$wpdb->update(GIGPRESS_SHOWS, array('show_expire' => $show->show_date), array('show_id' => $show->show_id), array('%s'), array('%d'));
$wpdb->update(GIGPRESS_SHOWS, array('show_expire' => $show->show_date), array('show_id' => $show->show_id), array('%s'), array('%d'));
}
};

// Now set show_time to NA
$settime = $wpdb->update(GIGPRESS_SHOWS, array('show_time' => '00:00:01'), array('show_time' =>
$settime = $wpdb->update(GIGPRESS_SHOWS, array('show_time' => '00:00:01'), array('show_time' =>
''));

}
Expand All @@ -235,14 +236,14 @@ function gigpress_db_upgrade_120() {
global $wpdb;

// Set status for all shows and tours
$wpdb->update(GIGPRESS_SHOWS, array('show_status' => 'active'), array('show_status' => ''));
$wpdb->update(GIGPRESS_TOURS, array('tour_status' => 'active'), array('tour_status' => ''));
$wpdb->update(GIGPRESS_SHOWS, array('show_status' => 'active'), array('show_status' => ''));
$wpdb->update(GIGPRESS_TOURS, array('tour_status' => 'active'), array('tour_status' => ''));

}


function gigpress_db_upgrade_130() {

global $gpo;
$gpo['date_format_long'] = $gpo['date_format'];

Expand All @@ -257,14 +258,14 @@ function gigpress_db_upgrade_140() {
$artist_name = (!empty($gpo['band'])) ? strip_tags($gpo['band']) : get_bloginfo('name');
$artist = array('artist_name' => $artist_name);
$wpdb->insert(GIGPRESS_ARTISTS, $artist);

$gpo['default_artist'] = $wpdb->insert_id;

$wpdb->update(GIGPRESS_SHOWS, array('show_artist_id' => $wpdb->insert_id), array('show_artist_id' => 0));

// Find all venues
$venues = $wpdb->get_results("SELECT DISTINCT show_venue as venue_name, show_address as venue_address, show_locale as venue_city, show_country as venue_country, show_venue_phone as venue_phone, show_venue_url as venue_url FROM " . GIGPRESS_SHOWS . "", ARRAY_A);

// Insert them into the database
foreach($venues as $venue) {
$wpdb->insert(GIGPRESS_VENUES, $venue);
Expand All @@ -275,27 +276,27 @@ function gigpress_db_upgrade_140() {
"show_country" => $venue['venue_country']
);
$values = array("show_venue_id" => $wpdb->insert_id);
$wpdb->update(GIGPRESS_SHOWS, $values, $where);
$wpdb->update(GIGPRESS_SHOWS, $values, $where);
}

$gpo['age_restrictions'] = 'All Ages | All Ages/Licensed | No Minors';
$gpo['artist_label'] = 'Artist';
$gpo['artist_label'] = 'Artist';
$gpo['country_view'] = 'short';
$gpo['default_title'] = '%artist% at %venue% on %date%';
$gpo['display_subscriptions'] = 1;
$gpo['load_jquery'] = 1;
$gpo['related_date'] = 'now';
$gpo['widget_feeds'] = 1;
$gpo['widget_group_by_artist'] = 0;

}

function gigpress_db_upgrade_160() {

global $wpdb, $gpo;
$gpo['artist_link'] = 1;
$gpo['external_link_label'] = 'More information';

// Add alpha values for all existing artists
$artists = $wpdb->get_results(
"SELECT * FROM " . GIGPRESS_ARTISTS
Expand Down Expand Up @@ -338,7 +339,7 @@ function gigpress_uninstall() {

delete_option('gigpress_settings');

global $wpdb;
global $wpdb;
$wpdb->query('DROP TABLE IF EXISTS . '
. GIGPRESS_SHOWS . ', '
. GIGPRESS_TOURS . ', '
Expand Down
Loading

0 comments on commit 5e57e60

Please sign in to comment.