From 53d25822065914d2367a14b119971bbf28791c92 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 4 Mar 2016 16:29:25 -0500 Subject: [PATCH] fixed db issue added sql updates and fixed deleting of categories --- index.php | 2 +- models/admin/events/categories.php | 27 +++++----- ..._V0.0.1.sql => create_database_V0.0.2.sql} | 26 ++++++++- setup/databaseScripts/dbVersions.php | 3 +- .../update_database_V0.0.2.php | 25 +++++++++ .../update_database_V0.0.2.sql | 54 +++++++++++++++++++ 6 files changed, 120 insertions(+), 17 deletions(-) rename setup/databaseScripts/{create_database_V0.0.1.sql => create_database_V0.0.2.sql} (90%) create mode 100644 setup/databaseScripts/update_database_V0.0.2.php create mode 100644 setup/databaseScripts/update_database_V0.0.2.sql diff --git a/index.php b/index.php index 3da07b6..822fd64 100644 --- a/index.php +++ b/index.php @@ -39,7 +39,7 @@ * version from this plugin. */ define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.58'); diff --git a/models/admin/events/categories.php b/models/admin/events/categories.php index 098664d..a881f2d 100644 --- a/models/admin/events/categories.php +++ b/models/admin/events/categories.php @@ -99,7 +99,7 @@ class GlmMembersAdmin_events_categories extends GlmDataEventsCategories // parent::__construct(false, false, true); } - + public function modelAction($actionData = false) { @@ -168,16 +168,6 @@ class GlmMembersAdmin_events_categories extends GlmDataEventsCategories } - // retrieve category names - $entries = $Categories->getList(); - foreach($entries as $keys=>$value){ - $index[] = $keys; - } - - foreach($index as $id){ - $entries[] = $Categories->getEntry($id); - $names[] = $entries[$id]['name']; - } /* * @@ -199,10 +189,19 @@ class GlmMembersAdmin_events_categories extends GlmDataEventsCategories $sql = "DELETE FROM " . $table . "categories WHERE name = " . "'$title'". " ;"; - $this->wpdb->query($sql); + $this->wpdb->query($sql); + + } + // retrieve category names + $entries = $Categories->getList(); + foreach($entries as $keys=>$value){ + $index[] = $keys; + } + + foreach($index as $id){ + $entries[] = $Categories->getEntry($id); + $names[] = $entries[$id]['name']; } - - // Compile template data $templateData = array( 'displayData' => $displayData, diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.2.sql similarity index 90% rename from setup/databaseScripts/create_database_V0.0.1.sql rename to setup/databaseScripts/create_database_V0.0.2.sql index 763f970..221caf6 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -41,11 +41,14 @@ CREATE TABLE {prefix}recurrences ( event INTEGER NULL, -- Pointer to event start_time DATETIME NULL, -- Start of first occurance (date and time) end_time DATETIME NULL, -- End of first occurance (date and time) + from_date DATE NULL, -- From Date for recurrences + to_date DATE NULL, -- To Date for recurrences all_day BOOLEAN NULL, -- Flag indicating if this is an all-day event (inforational only) month_of_year SMALLINT UNSIGNED NULL, -- Month of year (bitmap) week_of_month TINYINT UNSIGNED NULL, -- Week of the month (bitmap) day_of_week TINYINT UNSIGNED NULL, -- Day of the week (bitmap) day_of_month INTEGER UNSIGNED NULL, -- Day of the month (bitmap) + last_day_of_month BOOLEAN NULL, -- Last day of the month holiday INT NULL, -- Pointer to holidays list (for future development) holiday_offset TINYINT, -- Offset from holiday (from -128 to +127 days) PRIMARY KEY (id), @@ -59,6 +62,7 @@ CREATE TABLE {prefix}times ( id INT NOT NULL AUTO_INCREMENT, event INT NULL, -- Pointer to the primary record for the event custom_event INT NULL, -- Pointer to a customized copy of the event record (if set) + recur_id INT NULL, -- Pointer to recurrance entry active BOOLEAN NULL, -- Active flag - normally set but used to temporarily dissable a specific date start_time DATETIME NULL, -- Date and time event starts end_time DATETIME NULL, -- Date and time event ends @@ -113,7 +117,8 @@ CREATE TABLE {prefix}events ( slideshow BOOLEAN NULL, -- Option to mark for use in slide show major BOOLEAN NULL, -- Option to mark as a major event name TINYTEXT NULL, -- Name of this event - header TINYTEXT NULL, -- Header text for front-end display + name_slug TINYTEXT NULL, -- Slug for this event + header TINYTEXT NULL, -- Header text for front-end display - NOT CURRENTLY USED intro TINYTEXT NULL, -- Intro text for front-end display descr TEXT NULL, -- Full description text image TINYTEXT NULL, -- Image file name @@ -129,3 +134,22 @@ CREATE TABLE {prefix}events ( INDEX(slideshow), INDEX(major) ); + +---- + +-- Event Management Settings +CREATE TABLE {prefix}management ( + id INT NOT NULL AUTO_INCREMENT, + canonical_event_page TINYTEXT NULL, -- Canonical page slug for event detail + PRIMARY KEY (id) +); + +---- + +-- Set default event management entry +INSERT INTO {prefix}management + ( id, canonical_event_page ) + VALUES + ( 1, 'event-detail' ) +; + diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 57ac568..919ea67 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -14,6 +14,7 @@ */ $glmMembersEventsDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 6) + '0.0.1' => array('version' => '0.0.1', 'tables' => 6), + '0.0.2' => array('version' => '0.0.2', 'tables' => 7) ); diff --git a/setup/databaseScripts/update_database_V0.0.2.php b/setup/databaseScripts/update_database_V0.0.2.php new file mode 100644 index 0000000..37c440e --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.2.php @@ -0,0 +1,25 @@ +wpdb->get_results('SELECT id, name FROM '.GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'events;', ARRAY_A); +if ($eventRecords && count($eventRecords) > 0) { + foreach ($eventRecords as $i) { + $slug = sanitize_title($i['name']); + $this->wpdb->update( + GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'events', + array( + 'name_slug' => $slug + ), + array( 'id' => $i['id'] ), + array( '%s' ), + array( '%d') + ); + } +} + +?> \ No newline at end of file diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql new file mode 100644 index 0000000..5e7a175 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.2.sql @@ -0,0 +1,54 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 12/09/14 15:27:15 +-- Database Version: 0.0.2 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashses + + +-- Event Management Settings +CREATE TABLE {prefix}management ( + id INT NOT NULL AUTO_INCREMENT, + canonical_event_page TINYTEXT NULL, -- Canonical page slug for event detail + PRIMARY KEY (id) +); + +---- + +-- Set default event management entry +INSERT INTO {prefix}management + ( id, canonical_event_page ) + VALUES + ( 1, 'event-detail' ) +; + +---- + +-- Add slug to event table +ALTER TABLE {prefix}events ADD COLUMN name_slug TINYTEXT; + +---- + +-- Add from date to recurrence table +ALTER TABLE {prefix}recurrences ADD COLUMN from_date DATE; + +---- + +-- Add to date to recurrence table +ALTER TABLE {prefix}recurrences ADD COLUMN to_date DATE; + +---- + +-- Add to date to recurrence table +ALTER TABLE {prefix}recurrences ADD COLUMN last_day_of_month BOOLEAN; + +---- + +-- Add to recurrence ID to times table +ALTER TABLE {prefix}times ADD COLUMN recur_id INT; + + + + + -- 2.17.1