From 22c7027ac8697b339198faca259570863b0508a6 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 11 Nov 2015 13:22:51 -0500 Subject: [PATCH] See logs for all the stuff that's been done. --- classes/data/dataAccommodationTypes.php | 12 +- classes/data/dataAmenities.php | 12 +- classes/data/dataCategories.php | 18 +- classes/data/dataCategoryMemberInfo.php | 12 +- classes/data/dataCities.php | 12 +- classes/data/dataImages.php | 37 +- classes/data/dataMemberInfo.php | 772 +++++++++--------- classes/data/dataMemberTypes.php | 56 +- classes/data/dataMembers.php | 374 ++++----- classes/data/dataRegions.php | 70 +- classes/glmPluginSupport.php | 2 +- config/plugin.ini | 22 - controllers/admin.php | 298 ++----- controllers/front.php | 81 +- css/admin.css | 2 +- defines.php | 14 +- glm-member-db.php | 106 +++ js/admin.js | 22 +- js/imageUpload/imageUpload.js | 764 ++++++++--------- lib/EasyPassword/EasyPassword.php | 38 +- lib/EasyPassword/EasyPassword.words | 1 - lib/GlmDataAbstract/DataAbstract.php | 1 - .../create_database_V1.0.43.sql | 19 +- .../databaseScripts/drop_database_V1.0.43.sql | 1 - .../update_database_V1.0.43.sql | 8 + models/admin/member/index.php | 7 +- models/admin/member/memberInfo.php | 4 +- models/admin/members/list.php | 1 + views/admin/member/header.html | 30 +- views/admin/member/index.html | 8 +- views/admin/member/memberInfo.html | 6 +- views/admin/members/header.html | 3 +- views/admin/members/list.html | 8 +- 33 files changed, 1401 insertions(+), 1420 deletions(-) diff --git a/classes/data/dataAccommodationTypes.php b/classes/data/dataAccommodationTypes.php index ef803e5b..230fde5a 100644 --- a/classes/data/dataAccommodationTypes.php +++ b/classes/data/dataAccommodationTypes.php @@ -88,15 +88,15 @@ class GlmDataAccommodationTypes extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name diff --git a/classes/data/dataAmenities.php b/classes/data/dataAmenities.php index a8b20548..8dd81656 100644 --- a/classes/data/dataAmenities.php +++ b/classes/data/dataAmenities.php @@ -88,15 +88,15 @@ class GlmDataAmenities extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index 2fe54225..8eef4563 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -88,15 +88,15 @@ class GlmDataCategories extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name @@ -136,7 +136,7 @@ class GlmDataCategories extends GlmDataAbstract 'required' => false, 'use' => 'a' ), - +/* // Parent ID 'parent_id' => array( 'field' => 'parent', @@ -144,7 +144,7 @@ class GlmDataCategories extends GlmDataAbstract 'type' => 'integer', 'use' => 'a' ), - +*/ // Description 'descr' => array( 'field' => 'descr', @@ -267,7 +267,7 @@ class GlmDataCategories extends GlmDataAbstract // Check if the new category name/parent already exists $sql = " SELECT id - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cateogry + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories WHERE name = '$name' AND parent = $parentID ;"; diff --git a/classes/data/dataCategoryMemberInfo.php b/classes/data/dataCategoryMemberInfo.php index 5cfeb56e..68ef0b88 100644 --- a/classes/data/dataCategoryMemberInfo.php +++ b/classes/data/dataCategoryMemberInfo.php @@ -88,15 +88,15 @@ class GlmDataCategoryMemberInfo extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name diff --git a/classes/data/dataCities.php b/classes/data/dataCities.php index 8b4156c4..591aeeef 100644 --- a/classes/data/dataCities.php +++ b/classes/data/dataCities.php @@ -88,15 +88,15 @@ class GlmDataCities extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name diff --git a/classes/data/dataImages.php b/classes/data/dataImages.php index e40e06ed..36a71809 100644 --- a/classes/data/dataImages.php +++ b/classes/data/dataImages.php @@ -88,15 +88,15 @@ class GlmDataImages extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name @@ -375,14 +375,23 @@ class GlmDataImages extends GlmDataAbstract glmMembersAdmin::addNotice("      Deleting size $k.", 'Process'); } - // Delete each image size - unlink(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$imgData['file_name']); + // Check if the image actually exists - May not if we're doing development + if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$imgData['file_name'])) { + + // Delete each image size + unlink(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$imgData['file_name']); + + } } - // Also delete the original - unlink(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/original/'.$imgData['file_name']); + // Check if the image actually exists - May not if we're doing development + if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/original/'.$imgData['file_name'])) { + // Also delete the original + unlink(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/original/'.$imgData['file_name']); + + } } } } @@ -441,9 +450,13 @@ class GlmDataImages extends GlmDataAbstract reset($sizes); while (list($k, $v) = each($sizes)) { - // Copy src file to dst file for this size - copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName, GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$dstName); + // Check if the source image exists + if (is_file(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName)) { + // Copy src file to dst file for this size + copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$srcName, GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$dstName); + + } } // Add this image to the images table diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index 23e1d60c..f58a524f 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -42,296 +42,296 @@ class GlmDataMemberInfo extends GlmDataAbstract */ public $config; /** - * Field definitions - * - * @var $ini - * @access public - */ - public $table; + * Field definitions + * + * @var $ini + * @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; + /** + * 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; - /** - * Constructor - * - * @param object $d - * database connection - * - * @return void - * @access public - */ - function __construct($wpdb, $config) - { - - // 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_PLUGIN_DB_PREFIX . 'member_info'; - - /* - * Table Data Fields - */ - $this->fields = array ( - - 'id' => array ( - 'field' => 'id', - 'type' => 'integer', - 'view_only' => true, - 'use' => 'a' - ), - - // Member Pointer - 'member' => array ( - 'field' => 'member', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', - 'p_field' => 'name', - 'p_static' => true, - 'required' => true, - 'use' => 'a' - ), - - // Member Name (stored by member updates) for sorting - 'member_name' => array( - 'field' => 'member_name', - 'type' => 'text', - 'use' => 'lg' - ), - - // Member Slug - 'member_slug' => array ( - 'field' => 'member', - 'as' => 'member_slug', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', - 'p_field' => 'member_slug', - 'p_static' => true, - 'required' => true, - 'use' => 'gle' - ), - - // Member Pointer index - 'member_pointer' => array ( - 'field' => 'member', - 'as' => 'member_pointer', - 'type' => 'integer', - 'required' => true, - 'use' => 'gle' - ), - - // Reference Name - Not displayed to user - 'reference_name' => array ( - 'field' => 'reference_name', - 'type' => 'text', - 'use' => 'a' - ), - - // Status - 'status' => array ( - 'field' => 'status', - 'type' => 'list', - 'list' => $this->config['status'], - 'required' => true, - 'default' => $this->config['status_numb']['Pending'], - 'use' => 'a' - ), - - // Create Time - 'create_time' => array ( - 'field' => 'create_time', - 'type' => 'datetime', - 'use' => 'lgie' - ), - - // Last Modify Time - 'modify_time' => array ( - 'field' => 'modify_time', - 'type' => 'datetime', - 'use' => 'a' - ), - - // Description - 'descr' => array( - 'field' => 'descr', - 'type' => 'text', - 'use' => 'a' - ), - - // Short description - 'short_descr' => array ( - 'field' => 'short_descr', - 'type' => 'text', - 'use' => 'a' - ), - - // Address Line 1 - 'addr1' => array ( - 'field' => 'addr1', - 'type' => 'text', - 'use' => 'a' - ), - - // Address Line 2 - 'addr2' => array ( - 'field' => 'addr2', - 'type' => 'text', - 'use' => 'a' - ), - - // City - '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 - '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 - 'phone' => array( - 'field' => 'phone', - 'type' => 'phone', - 'use' => 'a' - ), - - // Toll Free - 'toll_free' => array( - 'field' => 'toll_free', - 'type' => 'phone', - 'use' => 'a' - ), - - // E-Mail Address - 'email' => array( - 'field' => 'email', - 'type' => 'email', - 'use' => 'a' - ), - - // URL - 'url' => array( - 'field' => 'url', - 'type' => 'text', - 'use' => 'a' - ), - - // Logo - 'logo' => array( - 'field' => 'logo', - 'type' => 'image', - 'use' => 'a' - ), - - // Credit Cards Accepted - multi-pick - 'cc_type' => array( - 'field' => 'cc_type', - 'type' => 'bitmap', - 'bitmap' => $this->config['credit_card'], - 'default' => 0, // no cards selected - 'use' => 'a' - ), - - // Notes - 'notes' => array ( - 'field' => 'notes', - 'type' => 'text', - 'use' => 'a' - ) - - ); - - if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); - } + /** + * Constructor + * + * @param object $d + * database connection + * + * @return void + * @access public + */ + function __construct($wpdb, $config) + { + + // 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_PLUGIN_DB_PREFIX . 'member_info'; + + /* + * Table Data Fields + */ + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Member Pointer + 'member' => array ( + 'field' => 'member', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'name', + 'p_static' => true, + 'required' => true, + 'use' => 'a' + ), + + // Member Name (stored by member updates) for sorting + 'member_name' => array( + 'field' => 'member_name', + 'type' => 'text', + 'use' => 'lg' + ), + + // Member Slug + 'member_slug' => array ( + 'field' => 'member', + 'as' => 'member_slug', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'member_slug', + 'p_static' => true, + 'required' => true, + 'use' => 'gle' + ), + + // Member Pointer index + 'member_pointer' => array ( + 'field' => 'member', + 'as' => 'member_pointer', + 'type' => 'integer', + 'required' => true, + 'use' => 'gle' + ), + + // Reference Name - Not displayed to user + 'reference_name' => array ( + 'field' => 'reference_name', + 'type' => 'text', + 'use' => 'a' + ), + + // Status + 'status' => array ( + 'field' => 'status', + 'type' => 'list', + 'list' => $this->config['status'], + 'required' => true, + 'default' => $this->config['status_numb']['Pending'], + 'use' => 'a' + ), + + // Create Time + 'create_time' => array ( + 'field' => 'create_time', + 'type' => 'datetime', + 'use' => 'lgie' + ), + + // Last Modify Time + 'modify_time' => array ( + 'field' => 'modify_time', + 'type' => 'datetime', + 'use' => 'a' + ), + + // Description + 'descr' => array( + 'field' => 'descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Short description + 'short_descr' => array ( + 'field' => 'short_descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Address Line 1 + 'addr1' => array ( + 'field' => 'addr1', + 'type' => 'text', + 'use' => 'a' + ), + + // Address Line 2 + 'addr2' => array ( + 'field' => 'addr2', + 'type' => 'text', + 'use' => 'a' + ), + + // City + '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 + '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 + 'phone' => array( + 'field' => 'phone', + 'type' => 'phone', + 'use' => 'a' + ), + + // Toll Free + 'toll_free' => array( + 'field' => 'toll_free', + 'type' => 'phone', + 'use' => 'a' + ), + + // E-Mail Address + 'email' => array( + 'field' => 'email', + 'type' => 'email', + 'use' => 'a' + ), + + // URL + 'url' => array( + 'field' => 'url', + 'type' => 'text', + 'use' => 'a' + ), + + // Logo + 'logo' => array( + 'field' => 'logo', + 'type' => 'image', + 'use' => 'a' + ), + + // Credit Cards Accepted - multi-pick + 'cc_type' => array( + 'field' => 'cc_type', + 'type' => 'bitmap', + 'bitmap' => $this->config['credit_card'], + 'default' => 0, // no cards selected + 'use' => 'a' + ), + + // Notes + 'notes' => array ( + 'field' => 'notes', + 'type' => 'text', + 'use' => 'a' + ) + + ); + + if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); + } } @@ -362,32 +362,32 @@ class GlmDataMemberInfo extends GlmDataAbstract return false; - } + } - /* - * 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) - { + /* + * 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) + { - // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry) - if ($a != 'l' && $a != 'g' && $a != 'e') { - return $r; - } + // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry) + if ($a != 'l' && $a != 'g' && $a != 'e') { + return $r; + } - // Get Member Category data for this entry - $sql = " + // Get Member Category data for this entry + $sql = " SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr, COALESCE ( ( @@ -401,92 +401,92 @@ class GlmDataMemberInfo extends GlmDataAbstract WHERE C.id = CMI.category AND CMI.member_info = ".$r['id']." ;"; - $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A); - - // Get Amenity Data for this entry - $sql = " - SELECT A.* - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenities AS A, - ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenity_ref AS R - WHERE R.ref_type = ".$this->config['ref_type_numb']['MemberInfo']." - AND R.ref_dest = ".$r['id']." - AND A.id = R.amenity + $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A); + + // Get Amenity Data for this entry + $sql = " + SELECT A.* + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenities AS A, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenity_ref AS R + WHERE R.ref_type = ".$this->config['ref_type_numb']['MemberInfo']." + AND R.ref_dest = ".$r['id']." + AND A.id = R.amenity ;"; - $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A); + $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A); - return $r; - } + return $r; + } - /* - * Get Apha list of first characters in member name - * for those members that have active info. - * - * @param string $where Where clause - * Note the table refernces M and I. - * @param string $selected Optional selected alpha character - * - * @return object Class object - * - */ - public function getAlphaList($where = '', $selected = '') - { - - $sql = " - SELECT DISTINCT LEFT(M.name, 1) AS alpha - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members M, - ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T - WHERE T.status = ".$this->config['status_numb']['Active']." - AND M.id = T.member - $where - ORDER BY alpha - ;"; - $alphaData = $this->wpdb->get_results($sql, ARRAY_A); + /* + * Get Apha list of first characters in member name + * for those members that have active info. + * + * @param string $where Where clause + * Note the table refernces M and I. + * @param string $selected Optional selected alpha character + * + * @return object Class object + * + */ + public function getAlphaList($where = '', $selected = '') + { - // Set selected - foreach ($alphaData as $k=>$v) { - $alphaData[$k]['default'] = ($v['alpha'] == $selected); - } + $sql = " + SELECT DISTINCT LEFT(M.name, 1) AS alpha + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members M, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T + WHERE T.status = ".$this->config['status_numb']['Active']." + AND M.id = T.member + $where + ORDER BY alpha + ;"; + $alphaData = $this->wpdb->get_results($sql, ARRAY_A); - return $alphaData; + // Set selected + foreach ($alphaData as $k=>$v) { + $alphaData[$k]['default'] = ($v['alpha'] == $selected); + } - } + return $alphaData; - /* - * Get simplified list of member info records. - * - * @param string $where Where clause - * Note the table refernces M and I. - * - * @return object Class object - * - */ - public function getSimpleMemberInfoList($where = '') - { - - // Save current list of fields - $f = $this->fields; - - // Replace fields list with limited list - $this->fields = array( - 'id' => $f['id'], - 'member' => $f['member'], - 'member_name' => $f['member_name'], - 'member_slug' => $f['member_slug'], - 'member_pointer' => $f['member_pointer'], - 'reference_name' => $f['reference_name'], - 'status' => $f['status'], - 'create_time' => $f['create_time'], + } + + /* + * Get simplified list of member info records. + * + * @param string $where Where clause + * Note the table refernces M and I. + * + * @return object Class object + * + */ + public function getSimpleMemberInfoList($where = '') + { + + // Save current list of fields + $f = $this->fields; + + // Replace fields list with limited list + $this->fields = array( + 'id' => $f['id'], + 'member' => $f['member'], + 'member_name' => $f['member_name'], + 'member_slug' => $f['member_slug'], + 'member_pointer' => $f['member_pointer'], + 'reference_name' => $f['reference_name'], + 'status' => $f['status'], + 'create_time' => $f['create_time'], 'modify_time' => $f['modify_time'] - ); + ); - // Get the simplified list - $list = $this->getList($where); + // Get the simplified list + $list = $this->getList($where); - // Restore full fields list - $this->fields = $f; + // Restore full fields list + $this->fields = $f; - return $list; - } + return $list; + } } diff --git a/classes/data/dataMemberTypes.php b/classes/data/dataMemberTypes.php index 887f3bbe..935605bb 100644 --- a/classes/data/dataMemberTypes.php +++ b/classes/data/dataMemberTypes.php @@ -88,15 +88,15 @@ class GlmDataMemberTypes extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name @@ -108,28 +108,28 @@ class GlmDataMemberTypes extends GlmDataAbstract */ $this->fields = array( - 'id' => array( - 'field' => 'id', - 'type' => 'integer', - 'view_only' => true, - 'use' => 'a' - ), - - // Member Type Name - 'name' => array( - 'field' => 'name', - 'type' => 'text', - 'required' => true, - 'unique' => true, - 'use' => 'a' - ), - - // Description - 'descr' => array( - 'field' => 'descr', - 'type' => 'text', - 'use' => 'a' - ) + 'id' => array( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Member Type Name + 'name' => array( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'unique' => true, + 'use' => 'a' + ), + + // Description + 'descr' => array( + 'field' => 'descr', + 'type' => 'text', + 'use' => 'a' + ) ); diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index d1e7739b..296a0bd6 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -41,195 +41,195 @@ class GlmDataMembers extends GlmDataAbstract { */ public $config; /** - * Field definitions - * - * @var $ini - * @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; - - /** - * Constructor - * - * @param object $d - * database connection - * - * @return void - * @access public - */ - function __construct($wpdb, $config) - { + * Field definitions + * + * @var $ini + * @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; + + /** + * Constructor + * + * @param object $d + * database connection + * + * @return void + * @access public + */ + function __construct($wpdb, $config) + { // 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_PLUGIN_DB_PREFIX . 'members'; - - /* - * Table Data Fields - */ - $this->fields = array ( - - 'id' => array ( - 'field' => 'id', - 'type' => 'integer', - 'view_only' => true, - 'use' => 'a' - ), - - // Status - 'access' => array ( - 'field' => 'access', - 'type' => 'list', - 'list' => $this->config['memb_access'], - 'l_blank' => true, - 'required' => true, - 'default' => 30, - 'force_list' => true, - 'use' => 'a' - ), - - // Member Type - 'member_type' => array ( - 'field' => 'member_type', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_type', - 'p_field' => 'name', - 'p_orderby' => 'name', - 'p_blank' => true, - 'required' => true, - 'force_list' => true, - 'use' => 'a' - ), - - // Member Name - 'name' => array ( - 'field' => 'name', - 'type' => 'text', - 'required' => true, - 'unique' => true, - 'use' => 'a' - ), - - // Member Name (stored by member updates) for sorting - 'member_slug' => array( - 'field' => 'member_slug', - 'type' => 'text', - 'required' => true, - 'use' => 'a' - ), - - // Date created - 'created' => array ( - 'field' => 'created', - 'type' => 'date', - 'required' => true, - 'use' => 'a' - ), - - // Active Version - 'active_id' => array ( - 'field' => 'id', - 'as' => 'active_id', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', - 'p_field' => 'id', - 'p_id' => 'member', - 'p_where' => 'status = '.$this->config['status_numb']['Active'], - 'p_static' => true, - 'use' => 'gl' - ), - - /* - * Has pending information - * - * This is returning the sum of the ID field for all matching entries in the other table - * where the ID of the member entry is equal to the 'member' column in the member_info - * table and only for those entries where the status column is set to Pending. - * - * If this returns a value of 0, there are no pending informaation records for this member. - * If it returns a positive value, there are. The actual positive number returned is - * of course not anything useable, only that it's positive. - * - */ - 'pending' => array ( - 'field' => 'id', - 'as' => 'pending', - 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', - 'p_field' => 'member', - 'p_id' => 'member', - 'p_where' => 'status = '.$this->config['status_numb']['Pending'], - 'p_sum' => true, - 'use' => 'gl' - ) - - ); - - if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); - } - - } - - /* - * Get a simple members list - Name and ID only - * - * @return array Array of Name and ID for all members - * @access public - */ - public function getSimpleMembersList() - { - - // Save the current fields array and make a copy - $fSave = $this->fields; - $f = $fSave; - - // Remove what we don't want form the copy and get the list - unset($f['access'], $f['member_type'], $f['created']); - $this->fields = $f; - $memberList = $this->getList(); - - // Restore the fields list - $this->fields = $fSave; - - return $memberList; - } + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members'; + + /* + * Table Data Fields + */ + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Status + 'access' => array ( + 'field' => 'access', + 'type' => 'list', + 'list' => $this->config['memb_access'], + 'l_blank' => true, + 'required' => true, + 'default' => 30, + 'force_list' => true, + 'use' => 'a' + ), + + // Member Type + 'member_type' => array ( + 'field' => 'member_type', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_type', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'required' => true, + 'force_list' => true, + 'use' => 'a' + ), + + // Member Name + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'unique' => true, + 'use' => 'a' + ), + + // Member Name (stored by member updates) for sorting + 'member_slug' => array( + 'field' => 'member_slug', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Date created + 'created' => array ( + 'field' => 'created', + 'type' => 'date', + 'required' => true, + 'use' => 'a' + ), + + // Active Version + 'active_id' => array ( + 'field' => 'id', + 'as' => 'active_id', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', + 'p_field' => 'id', + 'p_id' => 'member', + 'p_where' => 'status = '.$this->config['status_numb']['Active'], + 'p_static' => true, + 'use' => 'gl' + ), + + /* + * Has pending information + * + * This is returning the sum of the ID field for all matching entries in the other table + * where the ID of the member entry is equal to the 'member' column in the member_info + * table and only for those entries where the status column is set to Pending. + * + * If this returns a value of 0, there are no pending informaation records for this member. + * If it returns a positive value, there are. The actual positive number returned is + * of course not anything useable, only that it's positive. + * + */ + 'pending' => array ( + 'field' => 'id', + 'as' => 'pending', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', + 'p_field' => 'member', + 'p_id' => 'member', + 'p_where' => 'status = '.$this->config['status_numb']['Pending'], + 'p_sum' => true, + 'use' => 'gl' + ) + + ); + + if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); + } + + } + + /* + * Get a simple members list - Name and ID only + * + * @return array Array of Name and ID for all members + * @access public + */ + public function getSimpleMembersList() + { + + // Save the current fields array and make a copy + $fSave = $this->fields; + $f = $fSave; + + // Remove what we don't want form the copy and get the list + unset($f['access'], $f['member_type'], $f['created']); + $this->fields = $f; + $memberList = $this->getList(); + + // Restore the fields list + $this->fields = $fSave; + + return $memberList; + } } diff --git a/classes/data/dataRegions.php b/classes/data/dataRegions.php index 09ccaefd..7d798406 100644 --- a/classes/data/dataRegions.php +++ b/classes/data/dataRegions.php @@ -88,15 +88,15 @@ class GlmDataRegions extends GlmDataAbstract { // If this class is not being extended along with existing $wpdb and $config - if (!$this->wpdb) { + if (!$this->wpdb) { - // Save WordPress Database object - $this->wpdb = $wpdb; + // Save WordPress Database object + $this->wpdb = $wpdb; - // Save plugin configuration object - $this->config = $config; + // Save plugin configuration object + $this->config = $config; - } + } /* * Table Name @@ -108,35 +108,35 @@ class GlmDataRegions extends GlmDataAbstract */ $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' - ), - - // Short Description - 'short_descr' => array( - 'field' => 'short_descr', - 'type' => 'text', - 'use' => 'a' - ) + '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' + ), + + // Short Description + 'short_descr' => array( + 'field' => 'short_descr', + 'type' => 'text', + 'use' => 'a' + ) ); diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 93b18a6e..8d6ca556 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -38,7 +38,7 @@ class GlmPluginSupport '0.1' => array('version' => '0.1', 'tables' => 26), '1.0.28' => array('version' => '1.0.28', 'tables' => 26), '1.0.30' => array('version' => '1.0.30', 'tables' => 26), - '1.0.43' => array('version' => '1.0.43', 'tables' => 27) + '1.0.43' => array('version' => '1.0.43', 'tables' => 26) ); /* diff --git a/config/plugin.ini b/config/plugin.ini index 15c6d2db..0b18102b 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -113,28 +113,6 @@ facility_type_numb['BedAndBreakfast'] = 20 facility_type_numb['Restaurant'] = 30 facility_type_numb['Golf'] = 40 -; -; Contact Type -; -contact_type[0] = 'None' -contact_type[10] = 'Personal' -contact_type[20] = 'Role' - -contact_type_numb['None'] = 0 -contact_type_numb['Personal'] = 10 -contact_type_numb['Role'] = 20 - -; -; Contact Permissions -; -permission_type[0] = 'None' -permission_type[50] = 'Member All' -permission_type[99] = 'All' - -permission_type_numb['None'] = 0 -permission_type_numb['MemberAll'] = 50 -permission_type_numb['All'] = 99 - ; ; Invoice Delivery ; diff --git a/controllers/admin.php b/controllers/admin.php index eefa6eb4..3eb77fb9 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -13,65 +13,6 @@ * @link http://dev.gaslightmedia.com/ */ -/** - * Array of valid menu items and actions. - * - * - * The higher level elements are valid menu items. These correlate to - * actual menu or sub menu items that are hooks back to this controller - * class. - * - * The lower level items below each menu item are actions that may be specified - * by a "glmMembersAction" form field. - */ -$GLOBALS['glmMembersAdminValidActions'] = array( - - 'ajax' => array( - 'imageUpload' - ), - 'dashboardWidget' => array( - 'index' - ), - 'members' => array( - 'index', // member list - 'list', - 'reports', - 'other' - ), - 'member' => array( - 'index', // Member Dashboard - 'memberInfo', - 'locations', - 'facilities', - 'activities', - 'accommodations' - ) - , - 'configure' => array( - 'index', // Member Types - 'categories', - 'cities', - 'regions', - 'accommodationTypes', - 'amenities' - ), - 'management' => array( - 'index', // General Options - 'terms', - 'development', - 'import', - 'addons', - 'hooks' - ), - 'shortcodes' => array( - 'index' - ), - 'error' => array( - 'index', - 'badAction' - ) -); - // Load glmPluginSupport class require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); @@ -207,27 +148,30 @@ class glmMembersAdmin extends GlmPluginSupport exit(); } - // Add hooks to WordPress + // Add admin menus add_action('admin_menu', - array( - $this, - 'configureMenus' - )); + array( + $this, + 'configureMenus' + ) + ); // Add admin scripts and css add_action('admin_enqueue_scripts', - array( - $this, - 'glmMembersAdminScripts' - )); + array( + $this, + 'glmMembersAdminScripts' + ) + ); // Add dashboard widget add_action( 'wp_dashboard_setup', - array( - $this, - 'glmMembersAdminDashboardWidget' + array( + $this, + 'glmMembersAdminDashboardWidget' - )); + ) + ); // Add AJAX image upload action add_action( 'wp_ajax_glm_members_admin_ajax', @@ -273,10 +217,10 @@ class glmMembersAdmin extends GlmPluginSupport } // Check for a valid action - if (!in_array($glmAction, $GLOBALS['glmMembersAdminValidActions']['ajax'], true)) { + if (!isset($GLOBALS['glmMembersValidActions']['adminActions']['ajax'][$glmAction])) { // Menu item/Action not in valid actions array - trigger_error ( 'ERROR: The specified action is not valid.', E_USER_ERROR); + trigger_error ( 'ERROR: The specified action is not valid - '.$glmAction, E_USER_ERROR); } // Build model and path and class names @@ -380,77 +324,74 @@ class glmMembersAdmin extends GlmPluginSupport { // Add a new main menu item for management and display of Members - add_menu_page('Members', 'Member DB', 'glm_members_edit', - 'glm-members-admin-menu-members', - array( - $this, - 'glmMembersAdminMenuMembers' - ), false, '91.123'); - - /* - * Add a submenu for the "Members" section - * Note that this uses the main menu item's slug for both the parent and menu slug - * to create a sub-menu with a title different from the main menu title - */ - - add_submenu_page('glm-members-admin-menu-members', 'Members', - 'Members', 'glm_members_edit', 'glm-members-admin-menu-members', - array( - $this, - 'glmMembersAdminMenuMembers' - )); + add_menu_page( + 'Members', + 'Member DB', + 'glm_members_edit', + 'glm-members-admin-menu-members', + function() {$this->controller('members');}, + false, + '91.123' + ); // Add a submenu for Member List - add_submenu_page('glm-members-admin-menu-members', 'Member List', - '  Member List', 'glm_members_edit', 'glm-members-admin-menu-members-list', - array( - $this, - 'glmMembersAdminMenuMembersList' - )); + add_submenu_page( + 'glm-members-admin-menu-members', + 'Member List', + '  Member List', + 'glm_members_edit', + 'glm-members-admin-menu-members-list', + function() {$this->controller('members', 'list');} + ); // Add a submenu for the "Member" section - add_submenu_page('glm-members-admin-menu-members', 'Member Information', - 'Add Member', 'glm_members_edit', 'glm-members-admin-menu-member', - array( - $this, - 'glmMembersAdminMenuMember' - )); + add_submenu_page( + 'glm-members-admin-menu-members', + 'Member Information', + 'Add Member', + 'glm_members_edit', + 'glm-members-admin-menu-member', + function() {$this->controller('member');} + ); // Add a submenu for the "Configure" section - add_submenu_page('glm-members-admin-menu-members', - 'Configure Members Database', 'Configure', - 'glm_members_configure', 'glm-members-admin-menu-configure', - array( - $this, - 'glmMembersAdminMenuConfigure' - )); + add_submenu_page( + 'glm-members-admin-menu-members', + 'Configure Members Database', + 'Configure', + 'glm_members_configure', + 'glm-members-admin-menu-configure', + function() {$this->controller('configure');} + ); // Add a submenu for the "Management" section - add_submenu_page('glm-members-admin-menu-members', - 'Member DB Management', 'Management', - 'glm_members_management', 'glm-members-admin-menu-management', - array( - $this, - 'glmMembersAdminMenuManagement' - )); + add_submenu_page( + 'glm-members-admin-menu-members', + 'Member DB Management', + 'Management', + 'glm_members_management', + 'glm-members-admin-menu-management', + function() {$this->controller('management');} + ); // Add a submenu for the "Shortcode Reference" section - add_submenu_page('glm-members-admin-menu-members', - 'Shortcode Reference', 'Shortcodes', - 'glm_members_info', 'glm-members-admin-menu-shortcodes', - array( - $this, - 'glmMembersAdminMenuShortcodes' - )); - - + add_submenu_page( + 'glm-members-admin-menu-members', + 'Shortcode Reference', + 'Shortcodes', + 'glm_members_info', + 'glm-members-admin-menu-shortcodes', + function() {$this->controller('shortcodes');} + ); + // For each add-on, read in their menu additions + foreach ($this->config['addOns'] as $a) { + require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php'); + require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php'); + } } - - - /** * Add Admin Dashboard Widget * @@ -467,12 +408,9 @@ class glmMembersAdmin extends GlmPluginSupport if ( current_user_can( 'glm_members_info' ) ) { wp_add_dashboard_widget( - 'glm_members_admin_dashboard_widget', - 'Member DB Summary', - array( - $this, - 'glmMembersAdminDashboardContent' - ) + 'glm_members_admin_dashboard_widget', + 'Member DB Summary', + function() {$this->controller('dashboardWidget'); } ); // Set widget default position to right column @@ -484,68 +422,6 @@ class glmMembersAdmin extends GlmPluginSupport } } - /** - * Admin dashboard widget content - * - * (no prameters) - * - * @return void - * @access public - */ - - - /* - * Menu item specific "Callback" methods - * - * These methods are called by WordPress when specific menu items are - * selected by the - * user or a form action is submitted associated with the menu item. - * - * These methods call the controller and pass it the menu item that was - * called - * but perform no other work. - * - */ - - // Dashboard Widget - public function glmMembersAdminDashboardContent () - { - $this->controller('dashboardWidget'); - } - - // Main Plugin Menu Item - public function glmMembersAdminMenuMembers () - { - $this->controller('members'); - } - - // A test third-level admin menu - public function glmMembersAdminMenuMembersList() - { - $this->controller('members', 'list'); - } - - // Add Sub Menu Items - public function glmMembersAdminMenuMember () - { - $this->controller('member'); - } - - public function glmMembersAdminMenuConfigure () - { - $this->controller('configure'); - } - - public function glmMembersAdminMenuManagement () - { - $this->controller('management'); - } - - public function glmMembersAdminMenuShortcodes () - { - $this->controller('shortcodes'); - } - /** * Admin controller * @@ -598,6 +474,7 @@ class glmMembersAdmin extends GlmPluginSupport */ public function controller ($menuItem, $action = false) { + $errorMsg = ''; /* @@ -669,7 +546,7 @@ class glmMembersAdmin extends GlmPluginSupport $modelRedirect = false; // Verify that we have the requested menu item in the valid actions - if (!isset($GLOBALS['glmMembersAdminValidActions'][$menuItem])) { + if (!isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem])) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { $this->addNotice('Error in Admin Controller: Menu Item not specified!', 'Alert'); @@ -678,13 +555,13 @@ class glmMembersAdmin extends GlmPluginSupport $modelRedirect = true; $menuItem = 'error'; $action = 'index'; - $errorMsg .= "Model doesn't exist: ".$modelName; + $errorMsg .= "Menu not in valid list: ".$menuItem; } // Verify Menu item and action using array at top of this file - if (! isset($GLOBALS['glmMembersAdminValidActions'][$menuItem]) || - ! in_array($action, $GLOBALS['glmMembersAdminValidActions'][$menuItem])) { + if (! isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem]) || + ! isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem][$action])) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { $this->addNotice('Error in Admin Controller: Requested Menu Item is invalid! - '.$menuItem, 'Alert'); @@ -698,13 +575,16 @@ class glmMembersAdmin extends GlmPluginSupport * Execute the selected model */ + // Get name of plugin where model and view are located + $plugIn = $GLOBALS['glmMembersValidActions']['adminActions'][$menuItem][$action]; + // Build model and path and class names - $modelName = GLM_MEMBERS_PLUGIN_PATH . '/models/admin/' . $menuItem . - '/' . $action . '.php'; + $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/admin/$menuItem/$action.php"; $className = 'GlmMembersAdmin_' . $menuItem . '_' . $action; // Create hook to add page tabs by add-on plugins $addOnTabs = array(); + $addOnTabs = apply_filters( 'glm-member-db-add-tab-for-'.$menuItem, $addOnTabs @@ -777,7 +657,9 @@ class glmMembersAdmin extends GlmPluginSupport } // Check for invalid or missing view file - if (!$view || !is_file(GLM_MEMBERS_PLUGIN_PATH . '/views/'.$view)) { + $viewFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views/$view"; + + if (!$view || !is_file($viewFile)) { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { $this->addNotice("Error in Admin Controller: Requested View file doesn't exist - ".$view, 'Alert'); @@ -831,6 +713,8 @@ class glmMembersAdmin extends GlmPluginSupport // Load Smarty Template support $smarty = new smartyTemplateSupport(); + $smarty->template->addTemplateDir(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views"); + // Add standard template parameters $smarty->templateAssign ( 'addOnTabs', $addOnTabs); $smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG); @@ -854,7 +738,6 @@ class glmMembersAdmin extends GlmPluginSupport $smarty->templateAssign ( 'thisAction', $action); - // If there's an error message, add that also if ($errorMsg != '') { $smarty->templateAssign('errorMsg', $errorMsg); @@ -877,7 +760,6 @@ class glmMembersAdmin extends GlmPluginSupport } // Generate output from model data and view - $smarty->template->display($view); // Restore timezone that was set before our code was called diff --git a/controllers/front.php b/controllers/front.php index 3bab226a..f8cea960 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -14,30 +14,6 @@ * @link http://dev.gaslightmedia.com/ */ -/** - * Array of valid menu items and actions. - * - * - * The higher level elements are valid menu items. These correlate to - * actual menu or sub menu items that are hooks back to this controller - * class. - * - * The lower level items below each menu item are actions that may be specified - * by a "glmMembersAction" form field. - */ -$GLOBALS['glmMembersFrontValidActions'] = array( - - 'members' => array( - 'list', - 'detail' - ), - 'error' => array( - 'index', - 'badAction' - ) - -); - // Load glmPluginSupport class require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); @@ -81,39 +57,45 @@ class glmMembersFront extends GlmPluginSupport // Setup rewrite for member detail pages add_filter( 'rewrite_rules_array', - array( - $this, - 'glm_members_insert_rewrite_rules' - )); + array( + $this, + 'glm_members_insert_rewrite_rules' + ) + ); add_filter('query_vars', - array( - $this, - 'glm_members_RewriteQueryVars' - )); + array( + $this, + 'glm_members_RewriteQueryVars' + ) + ); add_filter( 'init', - array( - $this, - 'glm_members_flush_rules' - )); + array( + $this, + 'glm_members_flush_rules' + ) + ); // Add front-end scripts and css add_action('wp_enqueue_scripts', - array( - $this, - 'glmMembersFrontScripts' - )); + array( + $this, + 'glmMembersFrontScripts' + ) + ); add_shortcode('glm-members-list', - array( - $this, - 'controller' - )); + array( + $this, + 'controller' + ) + ); add_shortcode('glm-member-detail', - array( - $this, - 'controller' - )); + array( + $this, + 'controller' + ) + ); } @@ -167,7 +149,8 @@ class glmMembersFront extends GlmPluginSupport GLM_MEMBERS_PLUGIN_URL . 'js/front.js', array( 'jquery' - )); + ) + ); wp_enqueue_script('glm-members-front-js'); // A simple set of styles for things I haven't found as a WordPress diff --git a/css/admin.css b/css/admin.css index 08fc3bfa..69a5ad07 100644 --- a/css/admin.css +++ b/css/admin.css @@ -13,7 +13,7 @@ font-weight: bold; } .glm-notice { - color: blue; + color: #0073AA; font-weight: bold; } .glm-required { diff --git a/defines.php b/defines.php index 714cd302..01e8d32c 100644 --- a/defines.php +++ b/defines.php @@ -7,8 +7,9 @@ // NOTE: Plugin & Database versions are defined in "/glm-member-db.php". -define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Members Database'); -define('GLM_MEMBERS_PLUGIN_DIR', 'glm-member-db'); +define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Member Database'); +define('GLM_MEMBERS_PLUGIN_SHORT_NAME', 'GLM Member DB'); +define('GLM_MEMBERS_PLUGIN_SLUG', 'glm-member-db'); // Determine which system we're running on - If not provided, assume PRODUCTION $host = getenv('GLM_HOST_ID'); @@ -34,19 +35,22 @@ $WPUploadDir = wp_upload_dir(); define('GLM_MEMBERS_SITE_BASE_URL', home_url('/') ); define('GLM_MEMBERS_PLUGIN_URL', plugin_dir_url(__FILE__)); define('GLM_MEMBERS_PLUGIN_ADMIN_URL', admin_url('admin.php')); -define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_DIR); +define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_SLUG); define('GLM_MEMBERS_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]); -define('GLM_MEMBERS_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM_MEMBERS_PLUGIN_DIR); +define('GLM_MEMBERS_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM_MEMBERS_PLUGIN_SLUG); // Directories define('GLM_MEMBERS_PLUGIN_PATH', dirname(__FILE__)); define('GLM_MEMBERS_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts'); define('GLM_MEMBERS_PLUGIN_CLASS_PATH', GLM_MEMBERS_PLUGIN_PATH.'/classes'); define('GLM_MEMBERS_PLUGIN_LIB_PATH', GLM_MEMBERS_PLUGIN_PATH.'/lib'); -define('GLM_MEMBERS_PLUGIN_MEDIA_PATH', $WPUploadDir['basedir'].'/'.GLM_MEMBERS_PLUGIN_DIR); +define('GLM_MEMBERS_PLUGIN_MEDIA_PATH', $WPUploadDir['basedir'].'/'.GLM_MEMBERS_PLUGIN_SLUG); define('GLM_MEMBERS_PLUGIN_IMAGES_PATH', GLM_MEMBERS_PLUGIN_MEDIA_PATH.'/images'); define('GLM_MEMBERS_PLUGIN_CONFIG_PATH', GLM_MEMBERS_PLUGIN_PATH.'/config'); +$pluginsPath = str_replace(GLM_MEMBERS_PLUGIN_SLUG, '', GLM_MEMBERS_PLUGIN_PATH); +define('GLM_MEMBERS_WORDPRESS_PLUGIN_PATH', $pluginsPath); + // Database table prefixes global $wpdb; define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_'); diff --git a/glm-member-db.php b/glm-member-db.php index 6387bb53..20755e39 100644 --- a/glm-member-db.php +++ b/glm-member-db.php @@ -36,6 +36,81 @@ define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.43'); define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.43'); +/** + * Array of valid menu items and actions. + * + * The higher level elements are valid menu items. These correlate to + * actual menu or sub menu items that are hooks back to this controller + * class. + * + * The lower level items below each menu item are actions that may be specified + * by a "glmMembersAction" form field. + * + * The string after the action is the slug of the plugin where the model/view + * is to perform that action. + * + * This array is extended to include valid menus and actions from any add-on + * plugins. + */ +$GLOBALS['glmMembersValidActions'] = array( + 'adminActions' => array( + 'ajax' => array( + 'imageUpload' => 'glm-member-db' + ), + 'dashboardWidget' => array( + 'index' => 'glm-member-db' + ), + 'members' => array( + 'index' => 'glm-member-db', // member list + 'list' => 'glm-member-db', + 'reports' => 'glm-member-db', + 'other' => 'glm-member-db' + ), + 'member' => array( + 'index' => 'glm-member-db', // Member Dashboard + 'memberInfo' => 'glm-member-db', + 'locations' => 'glm-member-db', + 'facilities' => 'glm-member-db', + 'activities' => 'glm-member-db', + 'accommodations' => 'glm-member-db' + ) + , + 'configure' => array( + 'index' => 'glm-member-db', // Member Types + 'categories' => 'glm-member-db', + 'cities' => 'glm-member-db', + 'regions' => 'glm-member-db', + 'accommodationTypes' => 'glm-member-db', + 'amenities' => 'glm-member-db' + ), + 'management' => array( + 'index' => 'glm-member-db', // General Options + 'terms' => 'glm-member-db', + 'development' => 'glm-member-db', + 'import' => 'glm-member-db', + 'addons' => 'glm-member-db', + 'hooks' => 'glm-member-db' + ), + 'shortcodes' => array( + 'index' => 'glm-member-db' + ), + 'error' => array( + 'index' => 'glm-member-db', + 'badAction' => 'glm-member-db' + ) + ), + 'frontActions' => array( + 'members' => array( + 'list' => 'glm-member-db', + 'detail' => 'glm-member-db' + ), + 'error' => array( + 'index' => 'glm-member-db', + 'badAction' => 'glm-member-db' + ) + ) +); + /* * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) * @@ -187,7 +262,9 @@ if (!defined('ABSPATH')) { } /* + * * Some initial setup and tests + * */ $startupNotices = ''; @@ -201,10 +278,39 @@ require_once('config.php'); // Try to set the DB version option to false (new plugin) - If it's already set this won't do anything. add_option('glmMembersDatabaseDbVersion', false); +/* + * + * Hook in add-ons and integrate their actions + * + */ + // Create hook for registering add-on plugins and their features $config['addOns'] = array(); $config['addOns'] = apply_filters('glm-member-db-register-addon', $config['addOns']); +// If any add-ons have registered, integrate their actions and drop the actions array from the $config object as they're not needed there +if (count($config['addOns']) > 0) { + foreach ($config['addOns'] as $a) { + + // Add valid actions from add-on + if (isset($a['actions'])) { + $GLOBALS['glmMembersValidActions'] = array_merge_recursive($GLOBALS['glmMembersValidActions'], $a['actions']); + } + + // Check for add-on config file + $iniFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.'/'.$a['slug'].'/config/plugin.ini'; + if (isset($iniFile)) { + + // Parse the add-on's configuration file + $addOnIni = parse_ini_file($iniFile); + + // Replace parameters that are in the theme ini file + $config = array_replace($config, $addOnIni); + + } + } +} + /* * * Activate and Deactivate hooks diff --git a/js/admin.js b/js/admin.js index 564f1eb5..17d8de5c 100644 --- a/js/admin.js +++ b/js/admin.js @@ -3,16 +3,16 @@ jQuery(document).ready(function($){ - /* - * Use media uploaded for all file/image uploads - */ + /* + * Use media uploaded for all file/image uploads + */ var custom_uploader; - + $('.glm-protp-upload-button').click(function(e) { - + e.preventDefault(); - + var id = $(this).attr('data-id'); //If the uploader object has already been created, reopen the dialog @@ -20,7 +20,7 @@ jQuery(document).ready(function($){ custom_uploader.open(); return; } - + //Extend the wp.media object var custom_uploader = wp.media.frames.file_frame = wp.media({ title: 'Choose the desired image below or select "Upload Files" to select a new image.', @@ -32,13 +32,13 @@ jQuery(document).ready(function($){ //When a file is selected, grab the URL and set it as the text field's value custom_uploader.on('select', function() { - attachment = custom_uploader.state().get('selection').first().toJSON(); + attachment = custom_uploader.state().get('selection').first().toJSON(); $('#' + id).val(attachment.url); }); - + //Open the uploader dialog custom_uploader.open(); - + }); - + }); \ No newline at end of file diff --git a/js/imageUpload/imageUpload.js b/js/imageUpload/imageUpload.js index 9fdf5f59..0234c2c2 100644 --- a/js/imageUpload/imageUpload.js +++ b/js/imageUpload/imageUpload.js @@ -1,400 +1,400 @@ /* * Gaslight Media HTML5 Image Upload Support for glm-member-db plugin. - * + * * Author: Chuck Scott - * - * Developed from information in + * + * Developed from information in * http://www.sitepoint.com/html5-file-drag-and-drop/ * http://hayageek.com/drag-and-drop-file-upload-jquery/ - * + * * See also the following methods in classes/data/dataImages.php in this plugin. * galleryPositionOrder() * galleryImageDataUpdate() - * + * */ jQuery(document).ready(function($) { - - var drop; - var recordID; - var refType; - var recordID; - var maxFileSize; - var allowedTypes; - var files; - var uploadStatusTemplate; - var imageDataTemplate; - var galleryImages; - var newImageAdded = false; - - // Setup Drag and Drop when Add and - if (window.File && window.FileList && window.FileReader) { - - // is XHR2 available? - var xhr = new XMLHttpRequest(); - if (xhr.upload) { - - // Change from Drag/Drop not supported to drop here text - $('.glm-imageBrowseButton').addClass('glm-imageItemHidden'); - $('.glm-imageDropText').removeClass('glm-imageItemHidden'); - $('.glm-imageDrop').removeClass('glm-imageItemHidden'); - - // Prevent dropping on the document - $(document).on('dragenter', function (e) { - e.stopPropagation(); - e.preventDefault(); - }); - $(document).on('dragover', function (e) { - e.stopPropagation(); - e.preventDefault(); - }); - $(document).on('drop', function (e) { - e.preventDefault(); - }); - - // For each image drop area on the page - $('.glm-imageDrop').each(function() { - drop = $(this); - initDrop(); - }); - - } else { - alert('Your Web browser does not support "Drag & Drop" image uploads using "XHR2".\nThat capability is required to upload images for the image gallery on this page.\nConsider upgrading your browser.'); - } - - } - - // Setup an image drop area - function initDrop() { - - // Get information from the field on where this image file is going - refType = drop.attr("data-refType"); - recordID = drop.attr("data-recordID"); - maxFileSize = drop.attr("data-maxFileSizeKB") * 1000; - allowedTypes = drop.attr("data-allowedTypes"); - - uploadStatusTemplate = drop.children('.glm-imageUploadStatusTemplate').html(); - imageDataTemplate = drop.children('.glm-galleryImageDataTemplate').html(); - galleryImages = drop.parent().parent().children('.glm-galleryImages'); - - // Change drop destination appearance only when dragging over a file. - drop.on('dragenter', function(e){ - e.stopPropagation(); - e.preventDefault(); - drop.parent().addClass('glm-imageDropDragOver'); - }); - drop.on('dragover', function(e){ - e.stopPropagation(); - e.preventDefault(); - }); - drop.on('dragleave', function(e){ - e.stopPropagation(); - e.preventDefault(); - drop.parent().removeClass('glm-imageDropDragOver'); - }); - - // File drop action - $('.glm-imageDrop').on('drop', function (e) { - e.preventDefault(); - files = e.originalEvent.dataTransfer.files; - handleFileDrop(); - drop.parent().removeClass('glm-imageDropDragOver'); - }); - - } - - /* - * This function sets up AJAX processing of the list of files. It then fires - * off the processFile() function to do the first file. When the AJAX call - * in sendFileToServer() completes, the complete: function will call - * processFile() again to do the next file, if one exists. - */ - var thisFile = 0; - var numbFiles = 0; - - function handleFileDrop() { - - // Reset file pointer and set number of last file - thisFile = 0; - numbFiles = files.length; - - // Start with the first file - processFile(); - - } - - /* - * Process the current file - AJAX complete: will call back to this function - * for the next file - */ - function processFile() { - - // If we still have files to process - if (thisFile < numbFiles) { - - file = files[thisFile]; - - // Setup field pairs for sending in request - var fd = new FormData(); - - // Add file upload information - fd.append('file', file); - - /* - * Add "action" post parameter specifying where WordPress should - * route the request. In this case we are routing this AJAX request - * to the admin controller glmMembersAdminAjax() method which will - * route the request to the proper file in the models/admin/ajax - * directory of this plugin. - * - * see "add_action( 'wp_ajax_glm_members_admin_ajax',..." in admin - * controller. - */ - fd.append( 'action', 'glm_members_admin_ajax' ); - - // Tell admin controller where to route AJAX call - // (models/admin/ajax/imageUpload.php) - fd.append('glm_action', 'imageUpload'); - - // Tell image upload AJAX processor who the image is for - fd.append('glm_refType', refType); - fd.append('glm_refDest', recordID); - - // Setup status display area - var status = new createStatusbar(file, thisFile, numbFiles); - - statusArea.fadeIn( function() { - - // Check image size and alert the user if it's too big - if (file.size > maxFileSize) { - - alert("This image file is too large to process.\nTo use this image, consider resizing it before uploading.\n\nMaximum image size is " + (maxFileSize/1000) + "KB."); - statusArea.fadeOut(); - processFile(); - - // Check the image mime type and alert the user if it's not - // permitted - } else if (allowedTypes.indexOf(file.type) < 0) { - - alert("The file is not an accepted image type.\nTo use this image, consider resaving it as a differnt image type.\n"); - statusArea.fadeOut(); - processFile(); - - } else { - // When status has faded in, Send the files - sendFileToServer(fd, status); - } - - }); - - thisFile++; - - } else { - - // Reset expanded image and sortable events - setupExpandedImageEvents(); - - } - - } - - function createStatusbar(file, thisFile, numbFiles) - { - var statusDone = false; - - /* - * We need to redefine these values inside this function so the - * reader.onload function can see them. - */ - var curFile = thisFile + 1; - var lastFile = numbFiles; - - // Get status area for this drop area - statusArea = drop.siblings('.glm-imageUploadStatus'); - - // Make status area visible (overlay) and clear contents - statusArea.html(''); - - // If file is an image + + var drop; + var recordID; + var refType; + var recordID; + var maxFileSize; + var allowedTypes; + var files; + var uploadStatusTemplate; + var imageDataTemplate; + var galleryImages; + var newImageAdded = false; + + // Setup Drag and Drop when Add and + if (window.File && window.FileList && window.FileReader) { + + // is XHR2 available? + var xhr = new XMLHttpRequest(); + if (xhr.upload) { + + // Change from Drag/Drop not supported to drop here text + $('.glm-imageBrowseButton').addClass('glm-imageItemHidden'); + $('.glm-imageDropText').removeClass('glm-imageItemHidden'); + $('.glm-imageDrop').removeClass('glm-imageItemHidden'); + + // Prevent dropping on the document + $(document).on('dragenter', function (e) { + e.stopPropagation(); + e.preventDefault(); + }); + $(document).on('dragover', function (e) { + e.stopPropagation(); + e.preventDefault(); + }); + $(document).on('drop', function (e) { + e.preventDefault(); + }); + + // For each image drop area on the page + $('.glm-imageDrop').each(function() { + drop = $(this); + initDrop(); + }); + + } else { + alert('Your Web browser does not support "Drag & Drop" image uploads using "XHR2".\nThat capability is required to upload images for the image gallery on this page.\nConsider upgrading your browser.'); + } + + } + + // Setup an image drop area + function initDrop() { + + // Get information from the field on where this image file is going + refType = drop.attr("data-refType"); + recordID = drop.attr("data-recordID"); + maxFileSize = drop.attr("data-maxFileSizeKB") * 1000; + allowedTypes = drop.attr("data-allowedTypes"); + + uploadStatusTemplate = drop.children('.glm-imageUploadStatusTemplate').html(); + imageDataTemplate = drop.children('.glm-galleryImageDataTemplate').html(); + galleryImages = drop.parent().parent().children('.glm-galleryImages'); + + // Change drop destination appearance only when dragging over a file. + drop.on('dragenter', function(e){ + e.stopPropagation(); + e.preventDefault(); + drop.parent().addClass('glm-imageDropDragOver'); + }); + drop.on('dragover', function(e){ + e.stopPropagation(); + e.preventDefault(); + }); + drop.on('dragleave', function(e){ + e.stopPropagation(); + e.preventDefault(); + drop.parent().removeClass('glm-imageDropDragOver'); + }); + + // File drop action + $('.glm-imageDrop').on('drop', function (e) { + e.preventDefault(); + files = e.originalEvent.dataTransfer.files; + handleFileDrop(); + drop.parent().removeClass('glm-imageDropDragOver'); + }); + + } + + /* + * This function sets up AJAX processing of the list of files. It then fires + * off the processFile() function to do the first file. When the AJAX call + * in sendFileToServer() completes, the complete: function will call + * processFile() again to do the next file, if one exists. + */ + var thisFile = 0; + var numbFiles = 0; + + function handleFileDrop() { + + // Reset file pointer and set number of last file + thisFile = 0; + numbFiles = files.length; + + // Start with the first file + processFile(); + + } + + /* + * Process the current file - AJAX complete: will call back to this function + * for the next file + */ + function processFile() { + + // If we still have files to process + if (thisFile < numbFiles) { + + file = files[thisFile]; + + // Setup field pairs for sending in request + var fd = new FormData(); + + // Add file upload information + fd.append('file', file); + + /* + * Add "action" post parameter specifying where WordPress should + * route the request. In this case we are routing this AJAX request + * to the admin controller glmMembersAdminAjax() method which will + * route the request to the proper file in the models/admin/ajax + * directory of this plugin. + * + * see "add_action( 'wp_ajax_glm_members_admin_ajax',..." in admin + * controller. + */ + fd.append( 'action', 'glm_members_admin_ajax' ); + + // Tell admin controller where to route AJAX call + // (models/admin/ajax/imageUpload.php) + fd.append('glm_action', 'imageUpload'); + + // Tell image upload AJAX processor who the image is for + fd.append('glm_refType', refType); + fd.append('glm_refDest', recordID); + + // Setup status display area + var status = new createStatusbar(file, thisFile, numbFiles); + + statusArea.fadeIn( function() { + + // Check image size and alert the user if it's too big + if (file.size > maxFileSize) { + + alert("This image file is too large to process.\nTo use this image, consider resizing it before uploading.\n\nMaximum image size is " + (maxFileSize/1000) + "KB."); + statusArea.fadeOut(); + processFile(); + + // Check the image mime type and alert the user if it's not + // permitted + } else if (allowedTypes.indexOf(file.type) < 0) { + + alert("The file is not an accepted image type.\nTo use this image, consider resaving it as a differnt image type.\n"); + statusArea.fadeOut(); + processFile(); + + } else { + // When status has faded in, Send the files + sendFileToServer(fd, status); + } + + }); + + thisFile++; + + } else { + + // Reset expanded image and sortable events + setupExpandedImageEvents(); + + } + + } + + function createStatusbar(file, thisFile, numbFiles) + { + var statusDone = false; + + /* + * We need to redefine these values inside this function so the + * reader.onload function can see them. + */ + var curFile = thisFile + 1; + var lastFile = numbFiles; + + // Get status area for this drop area + statusArea = drop.siblings('.glm-imageUploadStatus'); + + // Make status area visible (overlay) and clear contents + statusArea.html(''); + + // If file is an image // var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/; // if (regex.test(file.name.toLowerCase())) { - // Create HTML5 file reader and load image - var reader = new FileReader(); - reader.onload = function (e) { - - // Using a copy of the supplied template, add file information - // to statusbar - statusbar = uploadStatusTemplate; - statusbar = statusbar.replace('{ thisFile }', curFile); - statusbar = statusbar.replace('{ numbFiles }', lastFile); - statusbar = statusbar.replace('{ fileImage }', e.target.result); - statusbar = statusbar.replace('{ fileName }', file.name); - statusbar = statusbar.replace('{ fileType }', file.type); - - // Fix up file size string and replace that - var sizeStr=""; - var sizeKB = file.size/1024; - if(parseInt(sizeKB) > 1024) - { - var sizeMB = sizeKB/1024; - sizeStr = sizeMB.toFixed(2)+" MB"; - } - else - { - sizeStr = sizeKB.toFixed(2)+" KB"; - } - - // If a large file, notify user it will take time. - if (file.size > 100000 && file.type == 'image/png') { - sizeStr += ' -- NOTE: Processing for this image may be slow!'; - } - - statusbar = statusbar.replace('{ fileSize }', sizeStr); - - // Assign the HTML to the status area - statusArea.html(statusbar); - - } + // Create HTML5 file reader and load image + var reader = new FileReader(); + reader.onload = function (e) { + + // Using a copy of the supplied template, add file information + // to statusbar + statusbar = uploadStatusTemplate; + statusbar = statusbar.replace('{ thisFile }', curFile); + statusbar = statusbar.replace('{ numbFiles }', lastFile); + statusbar = statusbar.replace('{ fileImage }', e.target.result); + statusbar = statusbar.replace('{ fileName }', file.name); + statusbar = statusbar.replace('{ fileType }', file.type); + + // Fix up file size string and replace that + var sizeStr=""; + var sizeKB = file.size/1024; + if(parseInt(sizeKB) > 1024) + { + var sizeMB = sizeKB/1024; + sizeStr = sizeMB.toFixed(2)+" MB"; + } + else + { + sizeStr = sizeKB.toFixed(2)+" KB"; + } + + // If a large file, notify user it will take time. + if (file.size > 100000 && file.type == 'image/png') { + sizeStr += ' -- NOTE: Processing for this image may be slow!'; + } + + statusbar = statusbar.replace('{ fileSize }', sizeStr); + + // Assign the HTML to the status area + statusArea.html(statusbar); + + } reader.readAsDataURL(file); - - this.setProgress = function(progress) - { - statusArea.find('.glm-progressBar').css('width', progress + '%'); - } - - this.setAbort = function(jqxhr) - { - var sb = this.statusbar; - $('#imageUploadCancel').click(function() - { - jqxhr.abort(); - sb.hide(); - }); - } - } - - /* - * Sends file to image plugin via AJAX submission targeting WordPress AJAX - * handler. - */ - function sendFileToServer(fd, status) - { - // Send one (or more) images to the server. Normally only one image here for now. - var jqXHR=$.ajax({ - xhr: function() { - var xhrobj = $.ajaxSettings.xhr(); - if (xhrobj.upload) { - xhrobj.upload.addEventListener('progress', function(event) { - - // calculate progress periodically and set the progress bar - var percent = 0; - var position = event.loaded || event.position; - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - status.setProgress(percent); - }, false); - - } - return xhrobj; - }, - url: ajaxurl, - type: "POST", - contentType:false, - processData: false, - cache: false, - data: fd, - success: function(data){ - - // Parse returned data - fileData = JSON.parse(data); - - // Check for success - if (fileData.status) { - - // Add image(s) to gallery display - for (f of fileData.files) { - - // Using a copy of the supplied template, add image information - imageData = imageDataTemplate; - imageData = imageData.replace(/{ id }/g, f.id); - imageData = imageData.replace(/\{ filename \}/g, f.newFileName); - galleryImages.prepend(imageData); - - // Enable the fields that were just added - $("#" + f.id + " input, #" + f.id + " textarea").removeAttr('disabled'); - - // Prepend image ID to position order input field - $("#galleryPositionOrder").val(f.id + ',' + $("#galleryPositionOrder").val()); - - } - - } else { - alert("Upload Failed\nReason: " + fileData.message); - } - - }, - complete: function() { - - // When status area has faded - statusArea.fadeOut( function() { - - // Process the next file, if one exists. - processFile(); - - }); - - } - }); - - return jqXHR; - - } - - /* - * This function is used to start handling of various things and - * to restart handling when an image has been added. I neede to - * do this because .on() didn't cover this situation. - */ - function setupExpandedImageEvents() { - - // Handle expanded images on hover for image gallery - $('.glm-galleryImage').on("mouseenter", function(){ - id = $(this).attr("data-id"); - var imgTitle = $("#galleryImage_caption_" + id).val(); - $('#glm-galleryImageLarger_' + id).dialog({ - title: imgTitle, - dialogClass: "no-close", - autoOpen: true, - resizable: false, - width: 'auto', - minWidth: 100, - minHeight: 100, - create: function() { - - $(this).dialog('option', 'maxHeight', $(window).height() * .9); - $(this).dialog('option', 'maxWidth', $(window).width() * .9); - }, - position: { my: "left+10 top+10", at: "right top", of: $(this), collision: "fit" } - }); - }); - $('.glm-galleryImage').on("mouseleave", function(){ - id = $(this).attr("data-id"); - $('#glm-galleryImageLarger_' + id).dialog("close"); - }); - - // Make images sortable and store the list of IDs in a hidden input field when order has changed. - $('.glm-galleryImages').sortable({ - update: function(event, ui) { - var sortedIDs = $(this).sortable('toArray'); - $('#galleryPositionOrder').val(sortedIDs); - } - }); - - } - setupExpandedImageEvents(); + + this.setProgress = function(progress) + { + statusArea.find('.glm-progressBar').css('width', progress + '%'); + } + + this.setAbort = function(jqxhr) + { + var sb = this.statusbar; + $('#imageUploadCancel').click(function() + { + jqxhr.abort(); + sb.hide(); + }); + } + } + + /* + * Sends file to image plugin via AJAX submission targeting WordPress AJAX + * handler. + */ + function sendFileToServer(fd, status) + { + // Send one (or more) images to the server. Normally only one image here for now. + var jqXHR=$.ajax({ + xhr: function() { + var xhrobj = $.ajaxSettings.xhr(); + if (xhrobj.upload) { + xhrobj.upload.addEventListener('progress', function(event) { + + // calculate progress periodically and set the progress bar + var percent = 0; + var position = event.loaded || event.position; + var total = event.total; + if (event.lengthComputable) { + percent = Math.ceil(position / total * 100); + } + status.setProgress(percent); + }, false); + + } + return xhrobj; + }, + url: ajaxurl, + type: "POST", + contentType:false, + processData: false, + cache: false, + data: fd, + success: function(data){ + + // Parse returned data + fileData = JSON.parse(data); + + // Check for success + if (fileData.status) { + + // Add image(s) to gallery display + for (f of fileData.files) { + + // Using a copy of the supplied template, add image information + imageData = imageDataTemplate; + imageData = imageData.replace(/{ id }/g, f.id); + imageData = imageData.replace(/\{ filename \}/g, f.newFileName); + galleryImages.prepend(imageData); + + // Enable the fields that were just added + $("#" + f.id + " input, #" + f.id + " textarea").removeAttr('disabled'); + + // Prepend image ID to position order input field + $("#galleryPositionOrder").val(f.id + ',' + $("#galleryPositionOrder").val()); + + } + + } else { + alert("Upload Failed\nReason: " + fileData.message); + } + + }, + complete: function() { + + // When status area has faded + statusArea.fadeOut( function() { + + // Process the next file, if one exists. + processFile(); + + }); + + } + }); + + return jqXHR; + + } + + /* + * This function is used to start handling of various things and + * to restart handling when an image has been added. I neede to + * do this because .on() didn't cover this situation. + */ + function setupExpandedImageEvents() { + + // Handle expanded images on hover for image gallery + $('.glm-galleryImage').on("mouseenter", function(){ + id = $(this).attr("data-id"); + var imgTitle = $("#galleryImage_caption_" + id).val(); + $('#glm-galleryImageLarger_' + id).dialog({ + title: imgTitle, + dialogClass: "no-close", + autoOpen: true, + resizable: false, + width: 'auto', + minWidth: 100, + minHeight: 100, + create: function() { + + $(this).dialog('option', 'maxHeight', $(window).height() * .9); + $(this).dialog('option', 'maxWidth', $(window).width() * .9); + }, + position: { my: "left+10 top+10", at: "right top", of: $(this), collision: "fit" } + }); + }); + $('.glm-galleryImage').on("mouseleave", function(){ + id = $(this).attr("data-id"); + $('#glm-galleryImageLarger_' + id).dialog("close"); + }); + + // Make images sortable and store the list of IDs in a hidden input field when order has changed. + $('.glm-galleryImages').sortable({ + update: function(event, ui) { + var sortedIDs = $(this).sortable('toArray'); + $('#galleryPositionOrder').val(sortedIDs); + } + }); + + } + setupExpandedImageEvents(); }); diff --git a/lib/EasyPassword/EasyPassword.php b/lib/EasyPassword/EasyPassword.php index d4e19dc9..2438ece5 100644 --- a/lib/EasyPassword/EasyPassword.php +++ b/lib/EasyPassword/EasyPassword.php @@ -8,6 +8,7 @@ * * This is a highly modified version of this password generator for this application only. * For original code please refer to original author. +* */ @@ -16,23 +17,40 @@ class EasyPassword // Get a random dictionary word from a text file function dictionaryWord() { - $path = 'EasyPassword.words'; + $path = dirname(__FILE__).'/EasyPassword.words'; $fileload = @file($path); $i = count($fileload)-1; $random = rtrim($fileload[rand(0,$i)]); return $random; } - // This is the function to produce the password - function generateEasyPassword() - { - $word1 = $this->dictionaryWord(); - $numb = rand(1, 9); // Generate specified amount of numbers - $word2 = $this->dictionaryWord(); + // Generate random capitalization - either all characters ('all')or just first and last ('firstlast') + function randomCaps($s, $type = 'full') { + + switch ($type) { + case 'firstlast': + if (rand(0, 1)) $s[0] = strtoupper($s[0]); + $last = strlen($s) - 1; + if (rand(0, 1)) $s[$last] = strtoupper($s[$last]); + break; + case 'all': + default: + for ($i = 0 ; $i < strlen($s) ; $i++) { + if (rand(0, 1)) $s[$i] = strtoupper($s[$i]); + } + break; + } + return $s; + } - $keys = array ($word1,$numb,$word2); // Place password components in an array - $rand_keys = array_rand($keys,3); // Randomize the 3 password components - return $keys[$rand_keys[0]].$keys[$rand_keys[1]].$keys[$rand_keys[2]]; // Return the resulting password + // This is the function to produce the password - optionally provide a type for capitalization + function generateEasyPassword($type = 'firstlast') + { + $numbPunct = '123456789!@#$%&_-:;.?/'; + $word1 = $this->randomCaps($this->dictionaryWord(), $type); + $char = $numbPunct[rand(0, strlen($numbPunct)-1)]; + $word2 = $this->randomCaps($this->dictionaryWord(), $type); + return $word1.$char.$word2; } diff --git a/lib/EasyPassword/EasyPassword.words b/lib/EasyPassword/EasyPassword.words index f03284cd..0e07f042 100644 --- a/lib/EasyPassword/EasyPassword.words +++ b/lib/EasyPassword/EasyPassword.words @@ -615,7 +615,6 @@ sense separate serious servant -sex shade shake shame diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index a7cc1f24..67fd6da0 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -2965,7 +2965,6 @@ abstract class GlmDataAbstract if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE && class_exists('glmMembersAdmin')) { glmMembersAdmin::addNotice($sql, 'DataBlock', "DataAbstract - getList() query"); } - $list = $this->wpdb->get_results($sql, ARRAY_A); if (count($list) == 0) { diff --git a/misc/databaseScripts/create_database_V1.0.43.sql b/misc/databaseScripts/create_database_V1.0.43.sql index 61fd9694..d6ac3f9a 100644 --- a/misc/databaseScripts/create_database_V1.0.43.sql +++ b/misc/databaseScripts/create_database_V1.0.43.sql @@ -153,9 +153,11 @@ CREATE TABLE {prefix}cities ( CREATE TABLE {prefix}contacts ( id INT NOT NULL AUTO_INCREMENT, active BOOLEAN NULL, -- Contact is active flag + fname TINYTEXT NULL, -- First name of contact lname TINYTEXT NULL, -- Last name of contact contact_type INT NULL, -- Contact type - see contact_type table (individual, role, ...) + contact_role INT NULL, -- Contact WordPress user Role org TINYTEXT NULL, -- Organization name addr1 TINYTEXT NULL, -- Address line 1 - Address is for contact, not necessarily for organization addr2 TINYTEXT NULL, -- Address line 2 @@ -190,23 +192,6 @@ CREATE TABLE {prefix}contacts ( INDEX(email(20)) ); ----- - --- Mapping of permissions to specific contacts -CREATE TABLE {prefix}contact_permissions ( - id INT NOT NULL AUTO_INCREMENT, - permission INT NULL, -- Index of permission - see permissions table in plugin.ini - contact INT NULL, -- Pointer to specific contact - PRIMARY KEY (id), - CONSTRAINT {prefix}contact_fk_1 - FOREIGN KEY (contact) - REFERENCES {prefix}contacts (id) - ON DELETE CASCADE, - INDEX(permission), - INDEX(contact) -); - - ---- -- Facilities - Facilities are separate functional units of a member, either physically or operationally diff --git a/misc/databaseScripts/drop_database_V1.0.43.sql b/misc/databaseScripts/drop_database_V1.0.43.sql index cc75793c..553101a3 100644 --- a/misc/databaseScripts/drop_database_V1.0.43.sql +++ b/misc/databaseScripts/drop_database_V1.0.43.sql @@ -14,7 +14,6 @@ DROP TABLE IF EXISTS {prefix}category_member_info, {prefix}categories, {prefix}cities, - {prefix}contact_permissions, {prefix}contacts, {prefix}facilities, {prefix}files, diff --git a/misc/databaseScripts/update_database_V1.0.43.sql b/misc/databaseScripts/update_database_V1.0.43.sql index 3235219c..7a07b1c8 100644 --- a/misc/databaseScripts/update_database_V1.0.43.sql +++ b/misc/databaseScripts/update_database_V1.0.43.sql @@ -195,3 +195,11 @@ ALTER TABLE {prefix}restaurants MODIFY alcohol BOOLEAN; ALTER TABLE {prefix}restaurants MODIFY non_smoking BOOLEAN; +---- + +DROP TABLE {prefix}contact_permissions IF EXISTS; + +---- + +ALTER TABLE {prefix}contacts ADD COLUMN contact_role INT; + diff --git a/models/admin/member/index.php b/models/admin/member/index.php index 30b7c881..d88174e0 100644 --- a/models/admin/member/index.php +++ b/models/admin/member/index.php @@ -119,14 +119,9 @@ class GlmMembersAdmin_member_index extends GlmDataMembers $memberID = $actionData['memberID']; // Otherwise check if one was supplied by the user or passed from somewhere else - } elseif (isset($_REQUEST['id'])) { - - // Make sure it's a number - $memberID = $_REQUEST['id']-0; - - // Not sure why I have this. Need to look for it. } elseif (isset($_REQUEST['member'])) { + // Make sure it's a number $memberID = $_REQUEST['member']-0; } diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index 01a3b908..4550b20e 100644 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -241,8 +241,8 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo $this->memberID = $_REQUEST['member']-0; // If a member info record ID is supplied, get that and make sure it's an integer - if (isset($_REQUEST['id'])) { - $this->memberInfoID = $_REQUEST['id']-0; + if (isset($_REQUEST['memberInfo'])) { + $this->memberInfoID = $_REQUEST['memberInfo']-0; $this->haveMemberInfo = true; } diff --git a/models/admin/members/list.php b/models/admin/members/list.php index 6bd88f03..d34b478a 100644 --- a/models/admin/members/list.php +++ b/models/admin/members/list.php @@ -107,6 +107,7 @@ class GlmMembersAdmin_members_list extends GlmDataMembers $filterPending = false; $filterArchived = false; $filterName = false; + $filterCat = false; $haveFilter = false; if (isset($_REQUEST['filterName'])) { diff --git a/views/admin/member/header.html b/views/admin/member/header.html index 81d99bb8..1398eac9 100644 --- a/views/admin/member/header.html +++ b/views/admin/member/header.html @@ -1,19 +1,31 @@ +{* Sometimes this header is called without a memberInfoID. It's easier to handle it here that to set this in all models that don't need it. *} +{if !isset($memberInfoID)} + {assign var="memberInfoID" value="false"} +{/if} +{if !isset($memberInfo)} + {assign var="memberInfo" value="false"} +{/if} +

Member Data

diff --git a/views/admin/member/index.html b/views/admin/member/index.html index acdd2055..25d1748e 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -18,7 +18,7 @@ {if $haveMember} - + {else} @@ -93,6 +93,7 @@

+ {if $haveMember} @@ -105,7 +106,6 @@ - {if $haveMember} {if $haveInfoRecords} {assign var="i" value="0"} @@ -115,12 +115,12 @@ {else} {/if} - + diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index 1f87a456..fd8529a1 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -67,7 +67,7 @@ {if $memberInfoID && $memberInfo} - + {else} @@ -273,9 +273,9 @@ {/foreach} -- 2.17.1
{$m.status.name}{$m.status.name} {$m.reference_name} {$m.create_time.datetime} {$m.modify_time.datetime} - Clone  + Clone  {if $m.status.name != 'Active'}Activate{/if}
Parent Category: {foreach from=$categories item=v} - {/foreach} @@ -56,10 +56,10 @@ {$m.created.date} - {if $m.pending > 0}Pending{/if} + {if $m.pending > 0}{$m.pending} Pending{/if} - Active Info + Active Info