From: Chuck Scott Date: Tue, 23 Feb 2016 21:59:51 +0000 (-0500) Subject: Added initial database setup and data definition classes X-Git-Tag: v1.0.0^2~193 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=bd75500535ac86ece58aa1f214993ca7fcbce9a9;p=WP-Plugins%2Fglm-member-db-events.git Added initial database setup and data definition classes --- diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php new file mode 100644 index 0000000..d81cdf7 --- /dev/null +++ b/classes/data/dataCategories.php @@ -0,0 +1,182 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEventsCategories extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Name + 'name' => array( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'unique' => true, + 'use' => 'a' + ), + + // Description + 'descr' => array( + 'field' => 'descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Parent - for adding, deleting and editing, has selection tabels + 'parent' => array( + 'field' => 'parent', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'force_list' => true, + 'required' => false, + 'use' => 'a' + ) + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/classes/data/dataEventCategories.php b/classes/data/dataEventCategories.php new file mode 100644 index 0000000..bd2bc02 --- /dev/null +++ b/classes/data/dataEventCategories.php @@ -0,0 +1,181 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEventsEventCategories extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Event ID + 'event' => array( + 'field' => 'event', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Category ID + 'category' => array( + 'field' => 'category', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Category Name - for easy reference + 'category_name' => array( + 'field' => 'category', + 'as' => 'category_name', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'use' => 'gl' + ) + + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/classes/data/dataEvents.php b/classes/data/dataEvents.php index 648e2d6..b234626 100644 --- a/classes/data/dataEvents.php +++ b/classes/data/dataEvents.php @@ -110,7 +110,7 @@ class GlmDataEvents extends GlmDataAbstract /* * Table Name */ - $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'eventstable'; + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events'; /* * Table Data Fields @@ -125,11 +125,162 @@ class GlmDataEvents extends GlmDataAbstract 'use' => 'a' ), - // Active flag - 'active' => array ( - 'field' => 'active', + // Status + 'status' => array ( + 'field' => 'status', + 'type' => 'list', + 'list' => $this->config['status'], + 'required' => true, + 'default' => $this->config['status_numb']['Pending'], + 'use' => 'a' + ), + + // Custom Time Pointer + 'custom_time' => array ( + 'field' => 'custom_time', + 'type' => 'integer', + 'use' => 'gle' + ), + + // Root Event Pointer + 'root_event' => array ( + 'field' => 'root_event', + 'type' => 'integer', + 'use' => 'gle' + ), + + // Date/Time Created + 'created' => array ( + 'field' => 'created', + 'type' => 'datetime', + 'use' => 'lgie' + ), + + // Date/Time Updated + 'updated' => array ( + 'field' => 'updated', + 'type' => 'datetime', + 'use' => 'a' + ), + + // Date/Time Approved + 'approved' => array ( + 'field' => 'approved', + 'type' => 'datetime', + 'use' => 'lge' + ), + + // Reference Type - Insert new record + 'ref_type_insert' => array ( + 'field' => 'ref_type', + 'type' => 'integer', + 'use' => 'i' + ), + + // Reference Type - Output only + 'ref_type' => array ( + 'field' => 'ref_type', + 'type' => 'list', + 'list' => $this->config['ref_type'], + 'use' => 'lged' + ), + + // Reference Target - Insert new record and for recall + 'ref_dest' => array ( + 'field' => 'ref_dest', + 'type' => 'integer', + 'use' => 'ilged' + ), + + // Hide Address flag + 'hide_address' => array ( + 'field' => 'hide_address', 'type' => 'checkbox', - 'default' => true, + 'default' => false, + 'use' => 'a' + ), + + // Featured Event flag + 'featured' => array ( + 'field' => 'featured', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Slide Show flag + 'slideshow' => array ( + 'field' => 'slideshow', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Major Event flag + 'major' => array ( + 'field' => 'major', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Event Name + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Header + 'header' => array ( + 'field' => 'header', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Intro Text + 'intro' => array ( + 'field' => 'intro', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Description + 'descr' => array ( + 'field' => 'descr', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Event Image + 'image' => array( + 'field' => 'image', + 'type' => 'image', + 'use' => 'a' + ), + + // Evnet URL + 'url' => array ( + 'field' => 'url', + 'type' => 'text', + 'use' => 'a' + ), + + // Cost (description) + 'cost' => array ( + 'field' => 'cost', + 'type' => 'text', + 'use' => 'a' + ), + + // Notes (informational) + 'notes' => array ( + 'field' => 'notes', + 'type' => 'text', 'use' => 'a' ) diff --git a/classes/data/dataLocations.php b/classes/data/dataLocations.php new file mode 100644 index 0000000..7ae85a8 --- /dev/null +++ b/classes/data/dataLocations.php @@ -0,0 +1,338 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEventsLocations extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'locations'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Event ID + 'event' => array( + 'field' => 'event', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Location Name + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Location Address + 'address' => array ( + 'field' => 'address', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + + // City - References main plugin cities table + 'city' => array ( + 'field' => 'city', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'use' => 'a' + ), + + // State + 'state' => array ( + 'field' => 'state', + 'type' => 'list', + 'list' => $this->config['states'], + 'default' => 'MI', + 'use' => 'a' + ), + + // ZIP / Postal Code + 'zip' => array ( + 'field' => 'zip', + 'type' => 'text', + 'use' => 'a' + ), + + // Country + 'country' => array ( + 'field' => 'country', + 'type' => 'list', + 'list' => $this->config['countries'], + 'default' => 'US', + 'use' => 'a' + ), + + // Latitude + 'lat' => array( + 'field' => 'lat', + 'type' => 'float', + 'default' => $this->config['settings']['maps_default_lat'], + 'use' => 'a' + ), + + // Longitude + 'lon' => array( + 'field' => 'lon', + 'type' => 'float', + 'default' => $this->config['settings']['maps_default_lon'], + 'use' => 'a' + ), + + // Region - References main plugin regions table + 'region' => array ( + 'field' => 'region', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'regions', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + // 'force_list' => true, + 'use' => 'a' + ), + + // Phone Number + 'phone' => array ( + 'field' => 'phone', + 'type' => 'text', + 'use' => 'a' + ), + + // URL + 'url' => array ( + 'field' => 'url', + 'type' => 'text', + 'use' => 'a' + ), + + // E-Mail + 'email' => array ( + 'field' => 'email', + 'type' => 'text', + 'use' => 'a' + ), + + // ZIP / Postal Code + 'zip' => array ( + 'field' => 'zip', + 'type' => 'text', + 'use' => 'a' + ), + + // Contact Reference - Points to Contacts add-on contacts table + 'region' => array ( + 'field' => 'region', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'regions', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + // 'force_list' => true, + 'use' => 'a' + ), + + // Contact Reference Placeholder if no Contacts Add-On (see below) + 'contact_addon_id' => array( + 'field' => 'contact_addon_id', + 'type' => 'integer', + 'use' => 'a' + ), + + /* + * Using first and last name for compatibility with contacts add-on data + */ + + // Contact First Name + 'contact_fname' => array ( + 'field' => 'contact_fname', + 'type' => 'text', + 'use' => 'a' + ), + + // Contact Last Name + 'contact_lname' => array ( + 'field' => 'contact_lname', + 'type' => 'text', + 'use' => 'a' + ), + + // Contact phone + 'contact_phone' => array ( + 'field' => 'contact_phone', + 'type' => 'text', + 'use' => 'a' + ), + + // Contact E-Mail Address + 'contact_email' => array ( + 'field' => 'contact_email', + 'type' => 'text', + 'use' => 'a' + ) + + ); + + // If the Contacts add-on exists + if (isset($this->config['addOns']['glm-member-db-contacts'])) { + + // Contact Reference - Points to Contacts add-on contacts table + $this->fields['contact_addon_id'] = array ( + 'field' => 'contact_addon_id', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + // 'force_list' => true, + 'use' => 'a' + ); + + + } + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/classes/data/dataRecurrences.php b/classes/data/dataRecurrences.php new file mode 100644 index 0000000..11e2baa --- /dev/null +++ b/classes/data/dataRecurrences.php @@ -0,0 +1,237 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEventsRecurrences extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Event ID + 'event' => array( + 'field' => 'event', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Start Date & Time + 'start_time' => array ( + 'field' => 'start_time', + 'type' => 'datetime', + 'use' => 'a' + ), + + // End Date & Time + 'end_time' => array ( + 'field' => 'end_time', + 'type' => 'datetime', + 'use' => 'a' + ), + + // All Day Flag + 'all_day' => array ( + 'field' => 'all_day', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Month of Year - multi-pick (bitmap) + 'month_of_year' => array( + 'field' => 'month_of_year', + 'type' => 'bitmap', + 'bitmap' => $this->config['month'], + 'default' => 0, // no months selected + 'use' => 'a' + ), + + // Week of Month - multi-pick (bitmap) + 'week_of_month' => array( + 'field' => 'week_of_month', + 'type' => 'bitmap', + 'bitmap' => $this->config['week'], + 'default' => 0, // no weeks selected + 'use' => 'a' + ), + + // Day of Week - multi-pick (bitmap) + 'day_of_week' => array( + 'field' => 'day_of_week', + 'type' => 'bitmap', + 'bitmap' => $this->config['day'], + 'default' => 0, // no days selected + 'use' => 'a' + ), + + // Day of Month - multi-pick (bitmap) + 'day_of_month' => array( + 'field' => 'day_of_month', + 'type' => 'bitmap', + 'bitmap' => $this->config['day'], + 'default' => 0, // no day selected + 'use' => 'a' + ), + + /* + * Following included for future Holiday feature + */ + + // Holiday Index + 'holiday' => array( + 'field' => 'holiday', + 'type' => 'integer', + 'use' => 'g' + ), + + // Holiday Offset (days +/-) + 'holiday_offset' => array( + 'field' => 'holiday_offset', + 'type' => 'integer', + 'use' => 'g' + ) + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/classes/data/dataTimes.php b/classes/data/dataTimes.php new file mode 100644 index 0000000..68be173 --- /dev/null +++ b/classes/data/dataTimes.php @@ -0,0 +1,199 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEventsTimes extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'times'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Event ID + 'event' => array( + 'field' => 'event', + 'type' => 'integer', + 'required' => true, + 'use' => 'glei' + ), + + // Custom Event ID + 'custom_event' => array( + 'field' => 'custom_event', + 'type' => 'integer', + 'required' => true, + 'use' => 'glei' + ), + + // Active Flag + 'active' => array ( + 'field' => 'active', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Start Date & Time + 'start_time' => array ( + 'field' => 'start_time', + 'type' => 'datetime', + 'use' => 'a' + ), + + // End Date & Time + 'end_time' => array ( + 'field' => 'end_time', + 'type' => 'datetime', + 'use' => 'a' + ), + + // All Day Flag + 'all_day' => array ( + 'field' => 'all_day', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ) + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/index.php b/index.php index 1a6d35d..4143566 100644 --- a/index.php +++ b/index.php @@ -3,27 +3,12 @@ * Plugin Name: GLM Members Database Events * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 0.0.6 + * Version: 0.0.1 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 */ -/********************************************************************** - * NOTE: THIS IS A EVENTS FILE - DO NOT USE UNMODIFIED - * - * Please change all references to events, Events, or EVENTS to a name - * appropriate for your new Add-On. - * - * This is the main file for this add-on. It is the file called by - * WordPress to run aspects of this add-on. - * - * NOTE: Versions in this file must be reset as appropriate when - * creating a new add-on. Be sure to preserve the versions listed - * for "...MIN_MEMBERS_REQUIRED_VERSION". - * - * Remove this message before using this file in production! - **********************************************************************/ /** * Gaslight Media Members Database Events Add-On @@ -53,11 +38,11 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '0.0.6'); -// define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '0.0.1'); +define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.1'); // 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.57'); +define('GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.58'); // Check if plugin version is not current in WordPress option and if needed updated it if (GLM_MEMBERS_EVENTS_PLUGIN_VERSION != get_option('glmMembersDatabaseEventsPluginVersion')) { diff --git a/readme.txt b/readme.txt index 06bf0ea..1198adc 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -=== Gaslight Media Member Database Events Child Plugin === +=== Gaslight Media Member Database Events Add-On Plugin === Contributors: cscott@gaslightmedia.com Donate link: http://www.gaslightmedia.com Tags: Gaslight Media,Plugin,Members Events @@ -8,12 +8,12 @@ Stable tag: 4.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -This is the Gaslight Media Members Database Events Child Plugin. +This is the Gaslight Media Members Database Events Add-On Plugin. == Description == -The Gaslight Media Members Database Events Child Plugin is an add-on to the Gaslight Media Members Database, -which is required to install and run this plugin +The Gaslight Media Members Database Events Add-On Plugin adds Events capabilities to the base plugin. +The Gaslight Media base Members Database plugin (or later core plugin) is required to activate this add-on. == Installation == diff --git a/setup/databaseScripts/SAMPLE.create_database_V0.0.1.sql b/setup/databaseScripts/SAMPLE.create_database_V0.0.1.sql deleted file mode 100644 index 2671913..0000000 --- a/setup/databaseScripts/SAMPLE.create_database_V0.0.1.sql +++ /dev/null @@ -1,42 +0,0 @@ --- Gaslight Media Members Database - Events --- File Created: 12/02/15 15:27:15 --- Database Version: 0.0.1 --- Database Creation Script --- --- This file is called to create a new set of tables for this --- add-on for the most receint database version for this add-on. --- --- There should only be one such file in this directory --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes - - --- ********************************************************************** --- NOTE: THIS IS A EVENTS FILE - DO NOT USE UNMODIFIED --- --- Please change all references to events, Events, or EVENTS to a name --- appropriate for your new Add-On. --- --- Tables and queries in this file are events only. --- --- Remove this message before using this file in production! --- **********************************************************************/ - - --- Events Management Settings -CREATE TABLE {prefix}management ( - id INT NOT NULL AUTO_INCREMENT, - canonical_events_page TINYTEXT NULL, -- Canonical page slug for detail - PRIMARY KEY (id) -); - ----- - --- Set default events management entry -INSERT INTO {prefix}management - ( id, canonical_events_page ) - VALUES - ( 1, 'events data' ) -; - diff --git a/setup/databaseScripts/SAMPLE.dbVersions.php b/setup/databaseScripts/SAMPLE.dbVersions.php deleted file mode 100644 index 5e76b0e..0000000 --- a/setup/databaseScripts/SAMPLE.dbVersions.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -$glmMembersEventsDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 2), - '0.0.2' => array('version' => '0.0.2', 'tables' => 3) -); - diff --git a/setup/databaseScripts/SAMPLE.update_database_V0.0.2.php b/setup/databaseScripts/SAMPLE.update_database_V0.0.2.php deleted file mode 100644 index a07182c..0000000 --- a/setup/databaseScripts/SAMPLE.update_database_V0.0.2.php +++ /dev/null @@ -1,36 +0,0 @@ -wpdb->get_results('SELECT id, title FROM '.GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'eventss;', ARRAY_A); - -// If there's any events records -if ($eventsRecords && count($eventsRecords) > 0) { - - // For each events record - foreach ($eventsRecords as $p) { - - // Create a slug from the title - $slug = sanitize_title($p['title']).'-'.$p['id']; - - // Store this value back into the record - $this->wpdb->update( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'eventss', - array( - 'events_slug' => $slug - ), - array( 'id' => $p['id'] ), - array( '%s' ), - array( '%d') - ); - } - -} diff --git a/setup/databaseScripts/SAMPLE.update_database_V0.0.2.sql b/setup/databaseScripts/SAMPLE.update_database_V0.0.2.sql deleted file mode 100644 index 286cb84..0000000 --- a/setup/databaseScripts/SAMPLE.update_database_V0.0.2.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Gaslight Media Members Database --- 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 - --- Package Management Settings -CREATE TABLE {prefix}management ( - id INT NOT NULL AUTO_INCREMENT, - canonical_package_page TINYTEXT NULL, -- Canonical page slug for package detail - PRIMARY KEY (id) -); - ----- - --- Set default package management entry -INSERT INTO {prefix}management - ( id, canonical_package_page ) - VALUES - ( 1, 'package-detail' ) -; - ----- - -ALTER TABLE {prefix}packages ADD COLUMN package_slug TINYTEXT; - - - diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql new file mode 100644 index 0000000..257bbd6 --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -0,0 +1,133 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 12/02/15 15:27:15 +-- Database Version: 0.0.1 +-- Database Creation Script +-- +-- This file is called to create a new set of tables for this +-- add-on for the most receint database version for this add-on. +-- +-- There should only be one such file in this directory +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Categories - Categories for events +CREATE TABLE {prefix}categories ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NULL, -- Name of event category + descr TINYTEXT NULL, -- Description of this category + parent INT NULL, -- Parent category, null or 0 if this is a top level category + PRIMARY KEY (id), + INDEX(parent) +); + +---- + +-- Event-Category - Categories for specific event records +CREATE TABLE {prefix}event_categories ( + id INT NOT NULL AUTO_INCREMENT, + event INT NULL, -- Pointer to the event + category INT NULL, -- Pointer to the category + PRIMARY KEY (id), + INDEX(event), + INDEX(category) +); + +---- + +-- Event Recurrence - Defines how an event recurs +CREATE TABLE {prefix}recurrences ( + id INT NOT NULL AUTO_INCREMENT, + 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) + 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) + holiday INT NULL, -- Pointer to holidays list (for future development) + holiday_offset TINYINT -- Offset from holiday (from -128 to +127 days) + PRIMARY KEY (id), + INDEX(event) +); + +---- + +-- Times - List of actual event times for single and recurring events +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) + 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 + all_day BOOLEAN NULL, -- All Day flag + PRIMARY KEY (id), + INDEX(event), + INDEX(start_time), + INDEX(end_time) +); + +---- + +-- Locations - Locations for event - If there's no location pointing to an event try to use the referernced entity in events table +CREATE TABLE {prefix}locations ( + id INT NOT NULL AUTO_INCREMENT, + event INT NULL, -- Pointer to the primary or custom event record + name TINYTEXT NULL, -- Name of location + address TINYTEXT NULL, -- Street Address + city INT NULL, -- Pointer to city - references main plugin city table + state TINYTEXT NULL, -- Two character state abreviation + zip TINYTEXT NULL, -- ZIP/Postal code + country TINYTEXT NULL, -- Country Code + lat FLOAT NULL, -- Latitude of location + lon FLOAT NULL, -- Longitude of location + region INT NULL, -- Pointer to Region - references main plugin region table + phone TINYTEXT NULL, -- Location Phone # + url TINYTEXT NULL, -- Location URL + email TINYTEXT NULL, -- Location E-Mail Address + contact_addon_id INT NULL, -- ID of Contact from contact add-on (optional and if available) + contact_fname TINYTEXT NULL, -- Contact first name for this location (optional) + contact_lname TINYTEXT NULL, -- Contact last name for this location (optional) + contact_phone TINYTEXT NULL, -- Contact phone for this location (optional) + contact_email TINYTEXT NULL, -- Contact E-Mail address (optional) + PRIMARY KEY (id), + INDEX(name) +); + +---- + +-- Events - Base event information - May also be entries here referenced by the "times" table for a custom date. +CREATE TABLE {prefix}events ( + id INT NOT NULL AUTO_INCREMENT, + status INT NULL, -- Status for this event, see config['status'] + custom_time INT NULL, -- If this is a custom record for a specific instance (date) this points to that times table entry + root_event INT NULL, -- Root event pointer if this is a custom record for a specific instance (date) (if custom_time is set) + created DATETIME NULL, -- Date/Time event was created or date custom event record was created if custom record + updated DATETIME NULL, -- Date/Time this event record was last updated + approved DATETIME NULL, -- Date/Ttime this event record was approved + ref_type INT NULL, -- Type of entity this contact is associated with - See config['ref_type'] + ref_dest INT NULL, -- Pointer to the specific entity of ref_type this contact is associated with + hide_address BOOLEAN NULL, -- Option to hide address on front-end + featured BOOLEAN NULL, -- Option to mark as featured event + 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 + intro TINYTEXT NULL, -- Intro text for front-end display + descr TEXT NULL, -- Full description text + image TINYTEXT NULL, -- Image file name + url TINYTEXT NULL, -- Event URL + cost TINYTEXT NULL, -- Description of event cost + notes TEXT NULL, -- Internal notes for this event + PRIMARY KEY (id), + INDEX(custom_time), + INDEX(root_event), + INDEX(ref_type), + INDEX(ref_dest), + INDEX(featured), + INDEX(slideshow), + INDEX(major), + INDEX(name) +); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php new file mode 100644 index 0000000..57ac568 --- /dev/null +++ b/setup/databaseScripts/dbVersions.php @@ -0,0 +1,19 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +$glmMembersEventsDbVersions = array( + '0.0.1' => array('version' => '0.0.1', 'tables' => 6) +); + diff --git a/setup/databaseScripts/examples/create_database_V0.0.1.sql b/setup/databaseScripts/examples/create_database_V0.0.1.sql new file mode 100644 index 0000000..d4598c9 --- /dev/null +++ b/setup/databaseScripts/examples/create_database_V0.0.1.sql @@ -0,0 +1,42 @@ +-- Gaslight Media Members Database - Sample +-- File Created: 12/02/15 15:27:15 +-- Database Version: 0.0.1 +-- Database Creation Script +-- +-- This file is called to create a new set of tables for this +-- add-on for the most receint database version for this add-on. +-- +-- There should only be one such file in this directory +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + + +-- ********************************************************************** +-- NOTE: THIS IS A SAMPLE FILE - DO NOT USE UNMODIFIED +-- +-- Please change all references to sample, Sample, or SAMPLE to a name +-- appropriate for your new Add-On. +-- +-- Tables and queries in this file are sample only. +-- +-- Remove this message before using this file in production! +-- **********************************************************************/ + + +-- Sample Table +CREATE TABLE {prefix}sometablename ( + id INT NOT NULL AUTO_INCREMENT, + somefield TINYTEXT NULL, + PRIMARY KEY (id) +); + +---- + +-- Sample default entry in table +INSERT INTO {prefix}sometablename + ( id, somefield ) + VALUES + ( 1, 'sample data' ) +; + diff --git a/setup/databaseScripts/examples/dbVersions.php b/setup/databaseScripts/examples/dbVersions.php new file mode 100644 index 0000000..1b9b48b --- /dev/null +++ b/setup/databaseScripts/examples/dbVersions.php @@ -0,0 +1,40 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + + +/********************************************************************** + * NOTE: THIS IS A SAMPLE FILE - DO NOT USE UNMODIFIED + * + * Please change all references to sample, Sample, or SAMPLE to a name + * appropriate for your new Add-On. + * + * This file lists all versions of the database tables for this add-on. + * The last entry in the array below should be for the most recent + * version and should match the "create_database_V..." file in this + * directory. + * + * NOTE: When first creating a new add-on with database tables, there + * should only be one line in the array below and there should be no + * "update_database..." files in this directory. + * + * Remove this message before using this file in production! + **********************************************************************/ + + +$glmMembersSampleDbVersions = array( + '0.0.1' => array('version' => '0.0.1', 'tables' => 1), + '0.0.2' => array('version' => '0.0.2', 'tables' => 2) +); + diff --git a/setup/databaseScripts/examples/readme.txt b/setup/databaseScripts/examples/readme.txt new file mode 100644 index 0000000..f4f3b48 --- /dev/null +++ b/setup/databaseScripts/examples/readme.txt @@ -0,0 +1,21 @@ +DATABASE EXAMPLE FILES +---------------------- + +*** THESE ARE EXAMPLES ONLY *** + +The files in this directory are examples only. Do not use any of these as they are! + +The example here is of a set of one table for the add-on that is initially created +by the create_database_V0.0.1.sql script. That file creates one table and inserts +one entry into that table. + +In this example, the database is later updated by two files. Either of these may +be included separately if only a PHP file is needed to update the database, or +just an SQL script. Sometimes both are needed. + +There is also an entry in the dbVersions.php file that describes the update. + +Note that the number of tables needs to be set to the updated number for each update. + +Also note taht the SQL update scripts are run before the PHP update scripts. + diff --git a/setup/databaseScripts/examples/update_database_V0.0.2.php b/setup/databaseScripts/examples/update_database_V0.0.2.php new file mode 100644 index 0000000..5b47ba2 --- /dev/null +++ b/setup/databaseScripts/examples/update_database_V0.0.2.php @@ -0,0 +1,54 @@ +wpdb->get_results('SELECT id, title FROM '.GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX.'sometablename;', ARRAY_A); + +// If there's any records +if ($sampleRecords && count($sampleRecords) > 0) { + + // For each record + foreach ($sampleRecords as $p) { + + // Create a slug from the somefield field + $newData = sanitize_title($p['somefield']).'-'.$p['id']; + + // Store this value back into the record in the new yetanotherfield field + $this->wpdb->update( + GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX.'sometablename', + array( + 'yetanotherfield' => $slug + ), + array( 'id' => $p['id'] ), + array( '%s' ), + array( '%d') + ); + } + +} diff --git a/setup/databaseScripts/examples/update_database_V0.0.2.sql b/setup/databaseScripts/examples/update_database_V0.0.2.sql new file mode 100644 index 0000000..c8f89af --- /dev/null +++ b/setup/databaseScripts/examples/update_database_V0.0.2.sql @@ -0,0 +1,21 @@ +-- Gaslight Media Members Database +-- 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 + +-- A sample database update script +CREATE TABLE {prefix}anothertablename ( + id INT NOT NULL AUTO_INCREMENT, + anotherfield TINYTEXT NULL, + PRIMARY KEY (id) +); + +---- + +ALTER TABLE {prefix}sometablename ADD COLUMN yetanotherfield TINYTEXT; + + + diff --git a/setup/databaseScripts/readme.txt b/setup/databaseScripts/readme.txt index ff3b4e7..8d2866e 100644 --- a/setup/databaseScripts/readme.txt +++ b/setup/databaseScripts/readme.txt @@ -1,4 +1,10 @@ This directory contains database creation and update scripts for this add-on. -This directly is optional. If there are no data tables added by this add-on, -this directory should be omitted. +The files in this directory are checked by the checkDatabase() function in the +main plugin classes/glmPluginSupport.php file. + +This directory is optional. If there are no data tables that need to be created +for this add-on, there should be no files in this directory. The directory may +also be deleted. + +See the "examples" directory for a sample of what can go in this directory.