From: Chuck Scott Date: Mon, 21 Mar 2016 19:51:02 +0000 (-0400) Subject: Added events to member menu and added more fields. X-Git-Tag: v1.0.0^2~163 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=22555ce28c418495bb548452c19d2385523b7d22;p=WP-Plugins%2Fglm-member-db-events.git Added events to member menu and added more fields. --- diff --git a/classes/data/dataEvents.php b/classes/data/dataEvents.php index 2a2fab3..118a845 100644 --- a/classes/data/dataEvents.php +++ b/classes/data/dataEvents.php @@ -196,6 +196,17 @@ class GlmDataEvents extends GlmDataAbstract 'use' => 'ilged' ), + // Member Name (need to update this to be Reference Type aware + 'ref_name' => array( + 'field' => 'ref_dest', + 'as' => 'ref_name', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'name', + 'p_static' => true, + 'use' => 'lge' + ), + // Hide Address flag 'hide_address' => array ( 'field' => 'hide_address', @@ -277,13 +288,20 @@ class GlmDataEvents extends GlmDataAbstract 'use' => 'a' ), - // Evnet URL + // Event URL 'url' => array ( 'field' => 'url', 'type' => 'text', 'use' => 'a' ), + // Ticket URL + 'ticket_url' => array ( + 'field' => 'ticket_url', + 'type' => 'text', + 'use' => 'a' + ), + // Cost (description) 'cost' => array ( 'field' => 'cost', @@ -291,6 +309,49 @@ class GlmDataEvents extends GlmDataAbstract 'use' => 'a' ), + // Admin Reference Type + 'admin_ref_type' => array ( + 'field' => 'admin_ref_type', + 'type' => 'list', + 'list' => $this->config['ref_type'], + 'use' => 'ilged' + ), + + // Admnin Reference Target + 'admin_ref_dest' => array ( + 'field' => 'admin_ref_dest', + 'type' => 'integer', + 'use' => 'ilged' + ), + + // Admin Contact Name + 'admin_name' => array ( + 'field' => 'admin_name', + 'type' => 'text', + 'use' => 'a' + ), + + // Admin Contact Organization Name + 'admin_org' => array ( + 'field' => 'admin_org', + 'type' => 'text', + 'use' => 'a' + ), + + // Admin Contact E-Mail Name + 'admin_email' => array ( + 'field' => 'admin_email', + 'type' => 'text', + 'use' => 'a' + ), + + // Admin Contact Phone + 'admin_phone' => array ( + 'field' => 'admin_phone', + 'type' => 'text', + 'use' => 'a' + ), + // Notes (informational) 'notes' => array ( 'field' => 'notes', @@ -424,6 +485,10 @@ class GlmDataEvents extends GlmDataAbstract public function deleteEvent($id = false) { + // Load locations data class + require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataLocations.php'); + $Locations = new GlmDataEventsLocations($this->wpdb, $this->config); + // Load recurrences data class to deal with event times require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php'); $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config); @@ -440,6 +505,13 @@ class GlmDataEvents extends GlmDataAbstract return false; } + // Delete all location data for this event + $sql = " + DELETE FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'locations'." + WHERE event = $id + ;"; + $this->wpdb->query($sql); + // Get list of all recurrences $recur = $Recurrences->getList("T.event = $id"); if ($recur) { @@ -448,7 +520,10 @@ class GlmDataEvents extends GlmDataAbstract foreach($recur as $k=>$v) { // Delete all times and custom events - $this->deleteTimeEntriesForRecurrance($v['id'], true); + $Recurrences->deleteTimeEntriesForRecurrance($v['id'], true); + + // Delete the Recurrence record + $Recurrences->deleteEntry($v['id'], true); } } diff --git a/classes/data/dataRecurrences.php b/classes/data/dataRecurrences.php index 731109d..048febf 100644 --- a/classes/data/dataRecurrences.php +++ b/classes/data/dataRecurrences.php @@ -146,7 +146,15 @@ class GlmDataEventsRecurrences extends GlmDataAbstract 'type' => 'date', 'default' => time(), 'required' => true, - 'use' => 'ne' + 'use' => 'negil' + ), + + // Start Time Only Flag + 'start_time_only' => array ( + 'field' => 'start_time_only', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'a' ), // End Date & Time @@ -361,9 +369,13 @@ class GlmDataEventsRecurrences extends GlmDataAbstract $from = new DateTime($recurData['from_date']['date']); $to = new DateTime($recurData['to_date']['date']); - // Calculate interval for single event + // Calculate interval for single event - If start time only, then start and end are the same $start = new DateTime($recurData['start_time']['datetime']); - $end = new DateTime($recurData['end_time']['datetime']); + if ($recurData['start_time_only']) { + $end = new DateTime($recurData['start_time']['datetime']); + } else { + $end = new DateTime($recurData['end_time']['datetime']); + } $length = $start->diff($end); // Determine years for scan diff --git a/index.php b/index.php index 4084b29..8b6b7e9 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.4'); +define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.5'); // 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/list.php b/models/admin/events/list.php index 61e8adb..666095b 100644 --- a/models/admin/events/list.php +++ b/models/admin/events/list.php @@ -117,6 +117,52 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $haveTimes = false; $firstTime = false; $lastTime = false; + $memberID = false; + $haveMember = false; + $memberName = false; + $memberData = false; + + // Check for Member Menu Use + if (defined('GLM_EVENTS_MEMBER_MENU')) { + + // Try to get member ID + $memberID = (isset($_REQUEST['member']) ? $_REQUEST['member'] : 0); + + // If not a valid member ID + if ($memberID > 0) { + + // Get member data + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config); + $memberData = $MemberInfo->getEntry($memberID); + + if (!$memberData) { + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'No member data found for provided member ID.' + ) + ); + } + } else { + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'No member ID was provided.' + ) + ); + } + + $haveMember = true; + $memberName = $memberData['member_name']; + + } // Get a list of categories $Categories = new GlmDataEventsCategories($this->wpdb, $this->config); @@ -339,14 +385,21 @@ class GlmMembersAdmin_events_list extends GlmDataEvents case 'list': default: + $where = ''; + // Add "selected" element default false; reset($categories); while (list($k, $v) = each($categories)) { $categories[$k]['selected'] = false; } + // Check if the list is for a specific member + if (defined('GLM_EVENTS_MEMBER_MENU') && $memberID) { + $where .= "T.ref_dest = $memberID"; + } + // Determine number of events in list - $events = $this->getList(); + $events = $this->getList($where); if ($events) { $numbEvents = count($events); } @@ -419,7 +472,11 @@ class GlmMembersAdmin_events_list extends GlmDataEvents 'times' => $times, 'haveTimes' => $haveTimes, 'firstTime' => $firstTime, - 'lastTime' => $lastTime + 'lastTime' => $lastTime, + 'memberID' => $memberID, + 'haveMember' => $haveMember, + 'memberName' => $memberName, + 'memberData' => $memberData ); // Return status, any suggested view, and any data to controller diff --git a/models/admin/member/events.php b/models/admin/member/events.php index a5cfd8e..9654411 100644 --- a/models/admin/member/events.php +++ b/models/admin/member/events.php @@ -13,10 +13,14 @@ * @link http://dev.gaslightmedia.com/ */ -// Load Contacts data abstract -require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php'); +// Inform the events code that we're working from the member area +define('GLM_EVENTS_MEMBER_MENU', true); -class GlmMembersAdmin_events_list extends GlmDataEvents +// Load the events index +require GLM_MEMBERS_EVENTS_PLUGIN_PATH."/models/admin/events/list.php"; + +// Extend the events index class +class GlmMembersAdmin_member_events extends GlmMembersAdmin_events_list { /** @@ -76,144 +80,10 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $this->config = $config; /* - * Run constructor for the Contacts data class - * - * Note, the third parameter is a flag that indicates to the Contacts - * data class that it should flag a group of fields as 'view_only'. + * Run constructor for the Events class */ - parent::__construct(false, false, true); + parent::__construct($wpdb, $config); } - public function modelAction($actionData = false) - { - - $numbEvents = 0; - $option = 'list'; - $events = false; - $event = false; - $haveEvent = false; - $eventID = false; - $eventUpdated = false; - $eventUpdateError = false; - $view = 'list'; - - // Get a list of categories - require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); - $Categories = new GlmDataEventsCategories($this->wpdb, $this->config); - $categories = $Categories->getListSortedParentChild(false); - - // Get any provided option - if (isset($_REQUEST['option'])) { - $option = $_REQUEST['option']; - } - - // Get event ID if supplied - if (isset($_REQUEST['event'])) { - - // Make sure it's numeric - $eventID = ($_REQUEST['event'] - 0); - - if ($eventID <= 0) { - $eventID = false; - } - } - - // Do selected option - switch ($option) { - - case 'add': - - $event = $this->newEntry(); - - $view = 'edit'; - - break; - - case 'insert': - - $event = $this->insertEntry(); - if ($event['status']) { - $eventID = $event['id']; - $haveEvent = true; - $eventUpdated = true; - } else { - $option = 'add'; - } - - $view = 'edit'; - - break; - - case 'edit': - - $event = $this->editEntry($eventID); - - if ($event['status']) { - $haveEvent = true; - } - $view = 'edit'; - - break; - - case 'update': - - // Try to update this event - $event = $this->updateEntry($eventID); - - // Check if that was successful - if ($event['status']) { - $eventUpdated = true; - $event = $this->editEntry($eventID); - } else { - $eventUpdateError = true; - } - - $haveEvent = true; - $view = 'edit'; - - break; - - case 'list': - default: - - // Add "selected" element default false; - reset($categories); - while (list($k, $v) = each($categories)) { - $categories[$k]['selected'] = false; - } - - // Determine number of events in list - $events = $this->getList(); - if ($events) { - $numbEvents = count($events); - } - - break; - - } - - $templateData = array( - 'option' => $option, - 'events' => $events, - 'event' => $event, - 'haveEvent' => $haveEvent, - 'eventID' => $eventID, - 'eventUpdated' => $eventUpdated, - 'eventUpdateError' => $eventUpdateError, - 'numbEvents' => $numbEvents, - 'categories' => $categories - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => "admin/events/$view.html", - 'data' => $templateData - ); - - } - - -} +} \ No newline at end of file diff --git a/setup/adminTabs.php b/setup/adminTabs.php index c4721e5..1f32580 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -39,7 +39,8 @@ add_filter('glm-member-db-add-tab-for-member', array( 'text' => 'Events', 'menu' => 'member', - 'action' => 'events' + 'action' => 'events', + 'option' => 'list' ), ); diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql index 286d8a1..9c511d1 100644 --- a/setup/databaseScripts/create_database_V0.0.4.sql +++ b/setup/databaseScripts/create_database_V0.0.4.sql @@ -40,6 +40,7 @@ CREATE TABLE {prefix}recurrences ( id INT NOT NULL AUTO_INCREMENT, event INTEGER NULL, -- Pointer to event start_time DATETIME NULL, -- Start of first occurrence (date and time) + start_time_only BOOLEAN NULL, -- Use end of first occurrence flag end_time DATETIME NULL, -- End of first occurrence (date and time) from_date DATE NULL, -- From Date for recurrences to_date DATE NULL, -- To Date for recurrences @@ -125,7 +126,14 @@ CREATE TABLE {prefix}events ( descr TEXT NULL, -- Full description text image TINYTEXT NULL, -- Image file name url TINYTEXT NULL, -- Event URL + ticket_url TINYTEXT NULL, -- Ticket URL cost TINYTEXT NULL, -- Description of event cost + admin_ref_type INT NULL, -- Type of admin contact if using a member contact + admin_ref_dest INT NULL, -- Pointer to admin contact record if using a member contact + admin_name TINYTEXT NULL, -- Admin Contact Name if not using a member contact + admin_org TINYTEXT NULL, -- Admin Contact Organization if not using a member contact + admin_email TINYTEXT NULL, -- Admin Contact E-Mail if not using a member contact + admin_phone TINYTEXT NULL, -- Admin Contact Phone if not using a member contact old_event_id INT NULL, -- ID of event from old site for reference notes TEXT NULL, -- Internal notes for this event PRIMARY KEY (id), diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index a4254ae..ec69524 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -17,6 +17,7 @@ $glmMembersEventsDbVersions = array( '0.0.1' => array('version' => '0.0.1', 'tables' => 6), '0.0.2' => array('version' => '0.0.2', 'tables' => 7), '0.0.3' => array('version' => '0.0.3', 'tables' => 7), - '0.0.4' => array('version' => '0.0.4', 'tables' => 7) + '0.0.4' => array('version' => '0.0.4', 'tables' => 7), + '0.0.5' => array('version' => '0.0.5', 'tables' => 7) ); diff --git a/setup/databaseScripts/update_database_V0.0.5.sql b/setup/databaseScripts/update_database_V0.0.5.sql new file mode 100644 index 0000000..a8d1c49 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.5.sql @@ -0,0 +1,59 @@ +-- 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 + + +-- Add contact refernce type +ALTER TABLE {prefix}events ADD COLUMN admin_ref_type INTEGER; + +---- + +-- Add contact pointer +ALTER TABLE {prefix}events ADD COLUMN admin_ref_dest INTEGER; + +---- + +-- Add contact name +ALTER TABLE {prefix}events ADD COLUMN admin_name TINYTEXT; + +---- + +-- Add contact organization +ALTER TABLE {prefix}events ADD COLUMN admin_org TINYTEXT; + +---- + +-- Add contact email +ALTER TABLE {prefix}events ADD COLUMN admin_email TINYTEXT; + +---- + +-- Add contact phone +ALTER TABLE {prefix}events ADD COLUMN admin_phone TINYTEXT; + +---- + +-- Add use end time +ALTER TABLE {prefix}recurrences ADD COLUMN start_time_only BOOLEAN; + +---- + +-- Set start_time_only to false +UPDATE {prefix}recurrences SET start_time_only = FALSE; + +---- + +-- Add ticket URL +ALTER TABLE {prefix}events ADD COLUMN ticket_url TINYTEXT; + + + + + + + + diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index a3bcab4..075ee80 100644 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -1,31 +1,44 @@ -{include file='admin/events/header.html'} +{if $haveMember} + {include file='admin/member/header.html'} +{else} + {include file='admin/events/header.html'} +{/if} {if apply_filters('glm_members_permit_admin_members_packaging_edit_package', true)} - + {if $haveMember} + Return to Events List + {else} Return to Events List + {/if} {if $option == 'edit'} Delete this Event -

Edit Event

{else}

Add new Event

{/if} -
- + + + {if $haveMember} + + + + {else} - {if $haveEvent} + {/if} + {if $haveEvent} - {else} + {else} - {/if} + {/if}