Added "File Library" main Associate menu option.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 16 Jan 2018 17:16:40 +0000 (12:16 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 16 Jan 2018 17:16:40 +0000 (12:16 -0500)
Updated database with file_library and file_library_categories tables (the later is not yet in use).
Copied code from js/imageUpload to js/fileLibraryUpload and modified to serve for the File Library.
Created models and views to support new feature.

18 files changed:
classes/data/dataFileLibrary.php [new file with mode: 0644]
classes/data/settings/dataSettingsGeneral.php
defines.php
index.php
js/fileLibraryUpload/fileLibraryUpload.css [new file with mode: 0644]
js/fileLibraryUpload/fileLibraryUpload.js [new file with mode: 0644]
models/admin/ajax/fileLibraryUpload.php [new file with mode: 0644]
models/admin/fileLibrary/index.php [new file with mode: 0644]
setup/adminMenus.php
setup/databaseScripts/create_database_V1.1.32.sql [deleted file]
setup/databaseScripts/create_database_V1.1.33.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/drop_database_V1.1.32.sql [deleted file]
setup/databaseScripts/drop_database_V1.1.33.sql [new file with mode: 0644]
setup/databaseScripts/update_database_V1.1.33.sql [new file with mode: 0644]
setup/validActions.php
views/admin/fileLibrary/index.html [new file with mode: 0644]
views/admin/management/index.html

diff --git a/classes/data/dataFileLibrary.php b/classes/data/dataFileLibrary.php
new file mode 100644 (file)
index 0000000..ecd1c4e
--- /dev/null
@@ -0,0 +1,181 @@
+<?php
+/**
+ * GLM Member-DB WordPress Plugin
+ * File Library data class
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataFileLibrary.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * EventManagementDataFileLibrary class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package EventManagement
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataFiles.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataFileLibrary extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    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)
+    {
+
+        // 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 . 'file_library';
+
+        /*
+         * Table Data Fields
+         */
+        $this->fields = array(
+
+            'id' => array(
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+
+            // Original file name
+            'name' => array(
+                'field' => 'name',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // File Name
+            'file_name' => array(
+                'field' => 'file_name',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Description
+            'descr' => array(
+                'field' => 'descr',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Title
+            'title' => array(
+                'field' => 'title',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            
+            // Last Access time
+            'last_access_time' => array(
+                'field' => 'last_access_time',
+                'type' => 'datetime',
+                '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 )
+    {
+        
+        if (in_array($a, array('l','g'))) {
+            
+            $r['link_url'] = GLM_MEMBERS_WORDPRESS_FILE_LIBRARY_URL.$r['file_name'];
+        }
+        
+        return $r;
+    }
+    
+}
index d42854e..98aa1b8 100644 (file)
@@ -157,7 +157,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                 'type' => 'checkbox',
                 'use' => 'a'
             ),
-
+            
+            // Enable File Library Menu
+            'file_library' => array(
+                'field' => 'file_library',
+                'type' => 'checkbox',
+                'use' => 'a'
+            ),
+            
             // Google Maps API Key
             'google_maps_api_key' => array(
                 'field' => 'google_maps_api_key',
index b3bd2c5..3b6ed84 100644 (file)
@@ -79,11 +79,13 @@ define('GLM_MEMBERS_PLUGIN_LIB_PATH', GLM_MEMBERS_PLUGIN_PATH.'/lib');
 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_FILES_PATH', GLM_MEMBERS_PLUGIN_MEDIA_PATH.'/files');
+define('GLM_MEMBERS_PLUGIN_FILE_LIBRARY_PATH', GLM_MEMBERS_PLUGIN_MEDIA_PATH.'/fileLibrary');
 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);
 define('GLM_MEMBERS_WORDPRESS_PLUGIN_URL', WP_PLUGIN_URL);
+define('GLM_MEMBERS_WORDPRESS_FILE_LIBRARY_URL', GLM_MEMBERS_PLUGIN_MEDIA_URL.'/fileLibrary/');
 
 // Database defines
 global $wpdb;
index 642ee22..4585ded 100644 (file)
--- a/index.php
+++ b/index.php
@@ -45,7 +45,7 @@ if (!defined('ABSPATH')) {
  */
 
 define('GLM_MEMBERS_PLUGIN_VERSION', '2.10.20');
-define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.32');
+define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.33');
 
 // Check if plugin version is not current in WordPress option and if needed updated it
 if (GLM_MEMBERS_PLUGIN_VERSION != get_option('glmMembersDatabasePluginVersion')) {
diff --git a/js/fileLibraryUpload/fileLibraryUpload.css b/js/fileLibraryUpload/fileLibraryUpload.css
new file mode 100644 (file)
index 0000000..4337ba9
--- /dev/null
@@ -0,0 +1,203 @@
+.glm-fileLibraryDropContainer
+{
+    position: relative;
+    text-align: center;
+    padding: 0 1em 1em 1em;
+    background-color: #eee;
+    border: 2px solid #ccc;
+    border-radius: 7px;
+    cursor: default;
+    margin-left: auto;
+    margin-right: auto;
+    margin-bottom: 1em;
+    width: 50%;
+    height: 2em;
+}
+.glm-fileLibraryDrop
+{
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    top: 0;
+    left: 0;
+    z-index: 10;
+    border-radius: 7px;
+    height: 100%;
+    background-color: #000;
+    opacity: .0;
+    filter: alpha(opacity=0); /* For IE8 and earlier */
+
+}
+.glm-fileLibraryDropText
+{
+    color: #666;
+    z-index: 9;
+}
+.glm-noFileDropText
+{
+    color: #666;
+}
+.glm-fileLibraryItemHidden
+{
+    display: none;
+    z-index: 9;
+}
+.glm-fileLibraryDropDragOver
+{
+    border: 2px solid #000 important;
+    background-color: #fff;
+}
+.glm-fileLibraryUploadStatus
+{
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    top: 20px;
+    left: 10px;
+    z-index: 11;
+    border: 2px solid black;
+    border-radius: 7px;
+    height: 8rem;
+    background-color: #fff;
+    box-shadow: 10px 10px 5px grey;
+    padding: 1rem;
+}
+
+.glm-statusTable
+{
+    width: 100%;
+/*    table-layout: fixed; */
+    line-height: 80%;
+}
+.glm-statusPrompt
+{
+    width: 10%;
+    padding: 0px;
+    font-weight: bold;
+    text-align: right;
+}
+.glm-statusValue
+{
+    width: 65%;
+    padding: 0px;
+    text-align: left;
+}
+.glm-progressBarContainer
+{
+    height: 100%;
+    width: 95%;
+    background-color: #ccc;
+    border: 1px solid black;
+    line-height: 1em;
+}
+.glm-progressBar
+{
+    height: 1em;
+    background-color: red;
+    width: 0%;
+}
+
+/* Files */
+.glm-fileLibraryContainer
+{
+    margin: .5em 1em 1em 1em;
+    padding: .5em;
+    border: 2px solid #ccc;
+    text-align: center;
+    width: 90%;
+}
+
+.glm-fileLibraryDrop
+{
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    top: 0;
+    left: 0;
+    z-index: 10;
+    border-radius: 7px;
+    height: 100%;
+    background-color: #000;
+    opacity: .0;
+    filter: alpha(opacity=0); /* For IE8 and earlier */
+
+}
+.glm-fileLibraryDropText
+{
+    color: #666;
+    z-index: 9;
+}
+.glm-noFileDropText
+{
+    color: #666;
+}
+.glm-fileLibraryItemHidden
+{
+    display: none;
+    z-index: 9;
+}
+#glm-table-files {
+    width: 90%;
+}
+.glm-fileLibraryDropDragOver
+{
+    border: 2px solid #000 important;
+    background-color: #fff;
+}
+/*.glm-fileLibraryData {
+    width: 70%;
+    float: right;
+}
+.glm-fileLibrary {
+    width: 30%;
+    float: left;
+}*/
+.glm-statusTable
+{
+    width: 100%;
+/*    table-layout: fixed; */
+    line-height: 80%;
+}
+.glm-statusPrompt
+{
+    width: 10%;
+    padding: 0px;
+    font-weight: bold;
+    text-align: right;
+}
+.glm-statusValue
+{
+    width: 65%;
+    padding: 0px;
+    text-align: left;
+}
+.glm-statusFileTD
+{
+    max-width: 100%;
+    overflow: hidden;
+    padding: 13px;
+    display: table-cell;
+    vertical-align: middle;
+}
+.glm-statusFileContainer
+{
+    display: block;
+    width: 100px;
+    height: 100%;
+}
+.glm-statusFileContainer img
+{
+    position: absolute;
+    top: 0px;
+    right: 0px;
+    bottom: 0px;
+    left: 0px;
+    /* Maintain aspect ratio */
+    max-height:100%;
+    max-width: 100%;
+}
+
+.glm-file-library-table-left
+{
+    text-align: left;
+}
diff --git a/js/fileLibraryUpload/fileLibraryUpload.js b/js/fileLibraryUpload/fileLibraryUpload.js
new file mode 100644 (file)
index 0000000..bec4ed6
--- /dev/null
@@ -0,0 +1,365 @@
+/*
+ * Gaslight Media HTML5 Image Upload Support for glm-member-db plugin.
+ *
+ * Author: Chuck Scott <cscott@gaslightmedia.com>
+ *
+ * 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 fileDrop;
+    var recordID;
+    var refType;
+    var recordID;
+    var maxFileSize;
+    var allowedTypes;
+    var files;
+    var uploadStatusTemplate;
+    var imageDataTemplate;
+    var galleryImages;
+    var galleryFiles;
+    var newImageAdded = false;
+    var enableDraggable = true;
+    var statusArea = false;
+
+    // Setup Drag and Drop when Add
+    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-fileLibraryBrowseButton').addClass('glm-fileLibraryItemHidden');
+            $('.glm-fileLibraryDropText').removeClass('glm-fileLibraryItemHidden');
+            $('.glm-fileLibraryDrop').removeClass('glm-fileLibraryItemHidden');
+
+            // 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 file drop area on the page
+            $('.glm-fileLibraryDrop').each(function() {
+                fileDrop = $(this);
+                initFileDrop();
+            });
+
+        } else {
+            alert('Your Web browser does not support "Drag & Drop" uploads using "XHR2".\nThat capability is required to upload images for the image gallery on this page.\nConsider upgrading your browser.');
+        }
+
+    }
+
+    // Setup a File fileDrop area
+    function initFileDrop() {
+
+        maxFileSize = fileDrop.attr("data-maxFileSizeKB") * 1000;
+        allowedTypes = fileDrop.attr("data-allowedTypes");
+
+        uploadStatusTemplate = fileDrop.children('.glm-fileLibraryUploadStatusTemplate').html();
+        galleryFiles = $('#glm-newFileContainer');
+
+        // Change fileDrop destination appearance only when dragging over a file.
+        fileDrop.on('dragenter', function(e){
+               e.stopPropagation();
+               e.preventDefault();
+               fileDrop.parent().addClass('glm-fileLibraryDropDragOver');
+        });
+        fileDrop.on('dragover', function(e){
+               e.stopPropagation();
+               e.preventDefault();
+        });
+        fileDrop.on('dragleave', function(e){
+               e.stopPropagation();
+               e.preventDefault();
+               fileDrop.parent().removeClass('glm-fileLibraryDropDragOver');
+        });
+
+        // File fileDrop action
+        $('.glm-fileLibraryDrop').on('drop', function (e) {
+            e.preventDefault();
+            files = e.originalEvent.dataTransfer.files;
+            handleFileOnlyDrop();
+            fileDrop.parent().removeClass('glm-fileLibraryDropDragOver');          
+        });
+    }
+
+    /*
+     * 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;
+    
+    /*
+     * This function sets up AJAX processing for just files and not images
+     */
+    function handleFileOnlyDrop() {
+
+        // Reset file pointer and set number of last file
+        thisFile = 0;
+        numbFiles = files.length;
+
+        // Process only Files
+        processOnlyFiles();
+    }
+
+    function processOnlyFiles() {
+
+        // 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 the AJAX call.
+            // (models/admin/ajax/fileUpload.php)
+            fd.append( 'glm_action', 'fileLibraryUpload' );
+            
+            // Setup status display area
+            var status = new createStatusbar(file, thisFile, numbFiles, true);
+
+            statusArea.fadeIn( function() {
+
+                // Check image size and alert the user if it's too big
+                if (file.size > maxFileSize) {
+
+                    alert("This file is too large to process.\n\nMaximum image size is " + (maxFileSize/1000) + "KB.");
+                    statusArea.fadeOut();
+                    processOnlyFiles();
+
+                // 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 type.\nTo use this file, consider resaving it as a different file type.\n");
+                    statusArea.fadeOut();
+                    processOnlyFiles();
+
+                } else {
+
+                    // When status has faded in, Send the files
+                    sendFileToServer(fd, status);
+
+                }
+
+            });
+
+            thisFile++;
+
+        }
+
+    }
+
+    function createStatusbar(file, thisFile, numbFiles, onlyFile)
+    {
+        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 = fileDrop.siblings('.glm-fileLibraryUploadStatus');
+
+        // Make status area visible (overlay) and clear contents
+        statusArea.html('');
+
+        // 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;
+            if ( !( onlyFile ) ) {
+                statusbar = statusbar.replace('bust-stupid-ngg-image-selection', 'img');
+            }
+            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;
+            if ( !( onlyFile ) ) {
+                $('#imageUploadCancel').click(function()
+                {
+                    jqxhr.abort();
+                    sb.hide();
+                });
+            } else {
+                $('#fileUploadCancel').click(function()
+                {
+                    jqxhr.abort();
+                    sb.hide();
+                });
+            }
+        }
+    }    
+
+    /*
+     * Uploads the image 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 files(s) to files display
+                    for ( var i = 0; i < fileData.files.length; i++ ) {
+                        // Using a copy of the supplied template, add file information
+                        fData = $('#glm-fileLibraryDataTemplate').html();
+                        fData = fData.replace(/{ id }/g, fileData.files[i].id);
+                        fData = fData.replace(/\{ filename \}/g, fileData.files[i].newFileName);
+                        fData = fData.replace(/\{ fileurl \}/g, fileData.files[i].newFileUrl);
+                        fData = fData.replace(/\{ newfilename \}/g, fileData.files[i].newFileName);
+                        $('#glm-newFileContainer').prepend(fData);
+                        $('.glm-NewFileHidden').removeClass('glm-fileLibraryItemHidden');
+
+                        // Enable the fields that were just added
+                        $("#" + fileData.files[i].id + " input, #" + fileData.files[i].id + " textarea").removeAttr('disabled');
+
+                        // Prepend file ID to position order input field
+                        $("#filePositionOrder").val(fileData.files[i].id + ',' + $("#filePositionOrder").val());
+                    }
+
+                } else {
+                    alert("Upload Failed\nReason: " + fileData.message);
+                }
+
+            },
+            complete: function() {
+
+                // When status area has faded
+                statusArea.fadeOut( function() {
+                    processOnlyFiles();
+                });
+
+            }
+        });
+
+        return jqXHR;
+
+    }
+
+    // Copy an element to the clipboard
+    function copyToClipboard(text) {
+        var $temp = $("<input>");
+        $("body").append($temp);
+        $temp.val(text).select();
+        document.execCommand("copy");
+        $temp.remove();
+    }
+
+    $('body').on('click', '.glm-file-library-copy', function(e) {
+        copyToClipboard($(this).attr('data-link'));
+    });
+    
+    
+});
diff --git a/models/admin/ajax/fileLibraryUpload.php b/models/admin/ajax/fileLibraryUpload.php
new file mode 100644 (file)
index 0000000..0281dde
--- /dev/null
@@ -0,0 +1,258 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * File Library Upload by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataFileLibrary.php';
+
+/*
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_fileLibraryUpload extends GlmDataFileLibrary
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct(false, false);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This modelAction takes an AJAX image upload and stores the image in the
+     * media/images directory of the plugin.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Echos JSON string as response and does not return
+     */
+    public function modelAction ($actionData = false)
+    {
+
+        $return = array(
+            'status' => false,       // Assume we didn't get files or nothing works
+            'files' => false,       // Provide submitted data along with stored image data
+            'message' => ''
+        );
+
+/*
+        // Check for valid refType - See validActions in Admin Controller
+        if (!isset($_REQUEST['glm_refType']) || !isset($this->config['ref_type_table'][$_REQUEST['glm_refType']])) {
+            $return['message'] = 'Invalid target table does not exists!';
+            echo json_encode($return);
+            die();
+        }
+        $refType = $_REQUEST['glm_refType'];
+        $refTable = $this->config['ref_type_table'][$_REQUEST['glm_refType']];
+*/
+        
+        // Check for uploaded files
+        if (!isset($_FILES) || count($_FILES) == 0) {
+            $return['message'] = 'No image file provided!';
+            echo json_encode($return);
+            die();
+        }
+
+/*        
+        // Check for valid target record ID
+        if (!isset($_REQUEST['glm_refDest']) || ($_REQUEST['glm_refDest']-0) <= 0) {
+            $return['message'] = 'Invalid target ID!';
+            echo json_encode($return);
+            die();
+        }
+        $refDest = ($_REQUEST['glm_refDest']-0);
+
+        
+        // Make sure the record actually exists
+        $sql = "SELECT id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."$refTable WHERE id = $refDest;";
+        $record = $this->wpdb->get_row($sql, ARRAY_A);
+        if (count($record['id']) != 1) {
+            $return['message'] = "Specified target record (".$record['id'].") does not exist in table (".$refTable.")!\n\n".$sql;
+            echo json_encode($return);
+            die();
+        }
+*/
+        
+        // For each submitted file (usually only one)
+        foreach( $_FILES as $file ) {
+
+            // Is there a file of the right type with a temp file that exists
+            if (isset($file['name']) && is_file($file['tmp_name'])) {
+
+                // Store the image
+                $file = $this->storeFile($file);
+
+                $return['files'][] = $file;
+
+                // Indicate if we actually stored an image
+                $return['status'] = ($file != false);
+                $return['noimage'] = true;
+
+            } else {
+
+                // File was not uploaded or of the wrong type
+                $file['message'] = 'Image file "'.$file['name'].'" was not uploaded or is not a valid image file!';
+                $file['status'] = false;
+
+            }
+
+        }
+
+        // Return stored image data
+        echo json_encode($return);
+        die();
+    }
+
+
+    /*
+     * Store a single image file using a reference table to link to a table.
+     *
+     * Images are stored in various sizes in the media/images/{size} directories
+     * which are created if they don't already exist.
+     *
+     * @param $file array Array containing uploaded file data
+     *
+     * @return array
+     *
+     */
+    public function storeFile ($file)
+    {
+        
+        // Check for fileLibrary media directory
+        if (!file_exists(GLM_MEMBERS_PLUGIN_FILE_LIBRARY_PATH)) {
+            mkdir(GLM_MEMBERS_PLUGIN_FILE_LIBRARY_PATH);
+        }
+        
+
+        // If $file is just a URL to an image, then simulate the file array from a form submission
+        if (!is_array($file)) {
+            if ( preg_match( '/^http/', $file ) ) {
+                $fileName = basename( $file );
+            } else {
+                $fileName = $file;
+            }
+            $file = array(
+                'tmp_name' => $file,
+                'name'     => $fileName
+            );
+        }
+
+        // Get the desired file name and add a timestamps to it to ensure that it's unique
+        $fInfo = pathinfo($file['name']);
+
+        // Strip all characters from the file name other than the permitted characters.
+        $fInfo['filename'] = preg_replace('/([^a-zA-Z0-9-_\.]+)/','_', $fInfo['filename']);
+
+        // Build new file name
+        $newFilename = strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']);
+
+        // If the file is in the FILES array
+        if ( isset( $_FILES['file'] ) ) {
+            $fileUploaded = move_uploaded_file( $_FILES['file']['tmp_name'], GLM_MEMBERS_PLUGIN_FILE_LIBRARY_PATH . '/'. $newFilename );
+        } else {
+            // Use wordpress remote get method
+            $wp_response = wp_remote_get( $file['tmp_name'] );
+            if ( is_array( $wp_response ) ) {
+                $fileContents = $wp_response['body'];
+                $fp = fopen( GLM_MEMBERS_PLUGIN_FILE_LIBRARY_PATH . '/'. $newFilename, 'w' );
+                fwrite( $fp, $fileContents );
+                fclose( $fp );
+                $fileUploaded = true;
+            } else {
+                $fileUploaded = false;
+            }
+        }
+
+        // If we have a good image
+        if ( $fileUploaded ) {
+
+            $file['newFileName'] = $newFilename;
+            $file['newFileUrl'] = GLM_MEMBERS_WORDPRESS_FILE_LIBRARY_URL.$newFilename;
+
+            // Store image name in images table
+            $sql = "
+                INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."file_library
+                    (
+                        name,
+                        file_name,
+                        descr,
+                        title
+                    )
+                VALUES
+                    (
+                        '".$file['name']."',
+                        '".$file['newFileName']."',
+                        '',
+                        ''
+                    );
+            ";        
+            $this->wpdb->query($sql);
+            $queryError = $this->wpdb->last_error;
+
+            if ($queryError) {
+                $file['error'] = true;
+                $file['message'] = $queryError."\n".$sql;
+            }
+
+            // Get new ID and data from the new record
+            $file['id'] = $this->wpdb->insert_id;
+
+            return $file;
+
+        // Otherwise we don't have a good image, so fail
+        } else {
+            return false;
+        }
+
+
+    }
+
+}
diff --git a/models/admin/fileLibrary/index.php b/models/admin/fileLibrary/index.php
new file mode 100644 (file)
index 0000000..c6f85db
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin File Library Upload
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataFileLibrary.php';
+
+/*
+ * This model is called when the "Shortcodes" menu is selected
+ *
+ */
+class GlmMembersAdmin_fileLibrary_index extends GlmDataFileLibrary
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+        
+        // Run constructor for members data class
+        parent::__construct(false, false);
+
+    }
+
+    public function modelAction($actionData = false) {
+        
+        $paging = false;
+        
+        // File Library Upload scripts and css
+        wp_register_script(
+            'glm-members-admin-filelibrary-upload',
+            GLM_MEMBERS_PLUGIN_URL . 'js/fileLibraryUpload/fileLibraryUpload.js',
+            array(
+                'jquery'
+            ),
+            GLM_MEMBERS_PLUGIN_VERSION
+            );
+        wp_enqueue_script('glm-members-admin-filelibrary-upload', false, array('jquery'), false, true);
+        wp_register_style(
+            'glm-members-admin-filelibrary-upload-css',
+            GLM_MEMBERS_PLUGIN_URL . 'js/fileLibraryUpload/fileLibraryUpload.css',
+            false,
+            GLM_MEMBERS_PLUGIN_VERSION
+            );
+        wp_enqueue_style('glm-members-admin-filelibrary-upload-css');
+        
+        $haveFiles  = false;
+
+        $files = $this->getList();
+        if ($files && count($files) > 0) {
+            $haveFiles = true;
+        }
+/*        
+        // Update image gallery titles, descriptions, and image positions then return current image gallery
+        $this->imageGallery = $Images->galleryImageDataUpdate($this->config['ref_type_numb']['MemberInfo'], $this->memberInfoID, 'galleryPositionOrder');
+        $this->haveImageGallery = ($this->imageGallery != false);
+        
+        // Update file captions, descriptions, and file positions then
+        // return current files data.
+        $this->files     = $Files->filesDataUpdate( $this->config['ref_type_numb']['MemberInfo'], $this->memberInfoID, 'filePositionOrder' );
+        $this->haveFiles = ($this->files != false);
+*/
+        
+        // echo "<pre>".print_r($files,1)."</pre>";
+        
+        // Compile template data
+        $templateData = array(
+            'haveFiles'     => $haveFiles,
+            'files'         => $files,
+            'paging'        => $paging
+        );
+        
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'admin/fileLibrary/index.html',
+            'data' => $templateData
+        );
+
+    }
+}
index b27f32f..4b46f7b 100644 (file)
@@ -127,6 +127,18 @@ if (current_user_can('glm_members_members')) {
 
 }
 
+// Add a submenu for the "Files"
+if ($this->config['settings']['file_library']) {
+    add_submenu_page(
+        'glm-members-admin-menu-members',
+        'Files Library',
+        'Files Library',
+        'glm_members_settings',
+        'glm-members-admin-menu-fileLibrary',
+        function() {$this->controller('fileLibrary');}
+        );
+}
+
 // Add a submenu for the "Settings" section
 add_submenu_page(
     'glm-members-admin-menu-members',
diff --git a/setup/databaseScripts/create_database_V1.1.32.sql b/setup/databaseScripts/create_database_V1.1.32.sql
deleted file mode 100644 (file)
index d7b19d6..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
--- Gaslight Media Members Database
--- File Created: 12/29/16 12:06:00
--- Database Version: 1.1.32
--- Database Creation Script
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
---
--- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
---
-
--- Amenities
-CREATE TABLE {prefix}amenities (
-  id INT NOT NULL AUTO_INCREMENT,
-  active TINYINT(1) NULL,                   -- Amenity is active flag
-  name TINYTEXT NULL,                       -- Name of amenity
-  descr TEXT NULL,                          -- Description of amenity
-  short_descr TINYTEXT NULL,                -- Short description of amenity
-  ref_type INT NULL,                        -- Type of entity these amenities are associated with - see plugin.ini ref_type tables
-  uses_value BOOLEAN NULL,                  -- Flag indicating whether the amenity requires a quantity number
-  PRIMARY KEY (id),
-  INDEX(name(20))
-);
-
-----
-
--- Amenity Reference - Links a specific amenity to a specific entity of type ref_type
-CREATE TABLE {prefix}amenity_ref (
-  id INT NOT NULL AUTO_INCREMENT,
-  amenity INT NULL,                         -- Pointer to amenity in amenities table
-  ref_type INT NULL,                        -- Copy of ref_type from matching amenities table entry - to simplify searches
-  ref_dest INT NULL,                        -- Pointer to the specific entity of type ref_type
-  amenity_value TINYTEXT NULL,              -- Quantity if amenity uses values
-  PRIMARY KEY (id),
-  INDEX(ref_type),
-  INDEX(ref_dest)
-);
-
-----
-
--- groups
-CREATE TABLE {prefix}amenity_groups (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TINYTEXT NULL,                     -- Name of the Group
-    PRIMARY KEY (id),
-    INDEX(name(20))
-);
-
-----
-
--- Amenity Group - Links a specific amenity to groups
-CREATE TABLE {prefix}grouped_amenities (
-    id INT NOT NULL AUTO_INCREMENT,
-    group_id INT,                              -- Pointer to the group
-    amenity_id INT,                            -- Pointer to the Amenity
-    searchable BOOLEAN DEFAULT '0',         -- Flag indicating whether the amenity group will show in the search form
-    PRIMARY KEY (id)
-);
-
-----
-
--- Member Cateogries - used with member information records
-CREATE TABLE {prefix}categories (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Name of this category
-  descr TEXT NULL,                          -- Description of this category
-  short_descr TINYTEXT NULL,                -- Short description of this category
-  parent INT NULL,                          -- Pointer to parent category in this table - if there is one
-  PRIMARY KEY (id)
-);
-
-----
-
--- Mapping of categories to specific member information records
-CREATE TABLE {prefix}category_member_info (
-  id INT NOT NULL AUTO_INCREMENT,
-  category INT NULL,                        -- Pointer to category in categories table
-  member_info INT NULL,                     -- Pointer to member information record
-  PRIMARY KEY (id),
-  CONSTRAINT {prefix}categories_fk_1
-    FOREIGN KEY (category)
-    REFERENCES {prefix}categories (id)
-    ON DELETE CASCADE,
-  INDEX(category),
-  INDEX(member_info)
-);
-
-----
-
--- Cities
-CREATE TABLE {prefix}cities (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Name of city
-  PRIMARY KEY (id)
-);
-
-----
-
--- Member Click Through Stats Data - Totals of URL click-throughs - Preserved for 2 years
-CREATE TABLE {prefix}clickthrough_stats (
-  member INT NOT NULL,                          -- ID of member
-  stat_type INT NOT NULL,                       -- Type of stat 1 = day, 2 = week, 3 = month
-  stat_date DATE NOT NULL,                      -- Date for which these stats are accumulated (date or first date of week or month)
-  clicks INT NULL,                          -- Number of Clicks
-  PRIMARY KEY (member, stat_type, stat_date),
-  INDEX (member),
-  INDEX (stat_type),
-  INDEX (stat_date)
-);
-
-----
-
--- Files - Files are stored under /wp-content/uploads/glm-member-db/files/
-CREATE TABLE {prefix}files (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Original name of the file - might be URL if copied via HTTP
-  status TINYINT(1) NULL,                   -- Display/Use status - See plugin.ini status table
-  file_name TINYTEXT NULL,                  -- Stored file name for the file
-  descr TEXT NULL,                          -- Description
-  caption TINYTEXT NULL,                    -- Caption for the image
-  position INT NULL,                        -- Numeric position for sequence of display
-  ref_type INT NULL,                        -- Type of entity this image is associated with
-  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this image is associated with
-  PRIMARY KEY (id),
-  INDEX(name(20)),
-  INDEX(file_name(20)),
-  INDEX(ref_type),
-  INDEX(ref_dest)
-);
-
-----
-
--- Images - Images are stored under /wp-content/uploads/glm-member-db/images/{size}/
-CREATE TABLE {prefix}images (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Original name of the image - might be URL if copied via HTTP
-  status TINYINT(1) NULL,                   -- Display/Use status - See plugin.ini status table
-  selected BOOLEAN NULL,                    -- A single special image in the current gallery for this entity
-  featured BOOLEAN null,                    -- Image is a member of a group of featured images
-  file_name TINYTEXT NULL,                  -- Stored file name for the image
-  descr TEXT NULL,                          -- Description
-  caption TINYTEXT NULL,                    -- Caption for the image
-  position INT NULL,                        -- Numeric position for sequence of display
-  ref_type INT NULL,                        -- Type of entity this image is associated with
-  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this image is associated with
-  PRIMARY KEY (id),
-  INDEX(name(20)),
-  INDEX(file_name(20)),
-  INDEX(ref_type),
-  INDEX(ref_dest)
-);
-
-----
-
--- Primary member records - One for each member
-CREATE TABLE {prefix}members (
-  id INT NOT NULL AUTO_INCREMENT,
-  access INT NULL,                          -- Access type - See access table in plugin.ini
-  member_type INT NULL,                     -- Pointer to member type in member_type table
-  created DATE NULL,                        -- Date member record was created
-  name TINYTEXT NULL,                       -- Member name
-  member_slug TINYTEXT NULL,                -- Member name slug for canonical URLs (lowercase, "-" for spaces, no punctuation)
-  notes TEXT NULL,                          -- General notes - Not displayed in front-end
-  old_member_id INT NULL,                   -- Old member ID if imported from old database
-  featured BOOLEAN DEFAULT '0',             -- Whether the member is featured
-  PRIMARY KEY (id),
-  INDEX(name(20)),
-  INDEX(member_slug(20)),
-  INDEX(created)
-);
-
-----
-
--- Member Detail Display Stats Data - Totals of times detail page is displayed - Preserved for 2 years
-CREATE TABLE {prefix}member_detail_stats (
-  member INT NOT NULL,                          -- ID of member
-  stat_type INT NOT NULL,                       -- Type of stat 1 = day, 2 = week, 3 = month
-  stat_date DATE NOT NULL,                      -- Date for which these stats are accumulated (date or first date of week or month)
-  clicks INT NULL,                          -- Number of Clicks
-  PRIMARY KEY (member, stat_type, stat_date),
-  INDEX (member),
-  INDEX (stat_type),
-  INDEX (stat_date)
-);
-
-----
-
--- Member information version record - May be multiples per member - Only one with status "Active" for a distinct date range
-CREATE TABLE {prefix}member_info (
-  id INT NOT NULL AUTO_INCREMENT,
-  member INT NULL,                          -- Pointer to member record in table members
-  member_name TINYTEXT NULL,                -- Copy of member name from members table entry for fast reference
-  status INT NULL,                          -- Status of this member information record - See plugin.ini status table
-  reference_name TINYTEXT NULL,             -- Reference name for this member information record - Not displayed on front-end
-  descr TEXT NULL,                          -- Description
-  short_descr TEXT NULL,                    -- Short description
-  addr1 TINYTEXT NULL,                      -- Main member location address line 1
-  addr2 TINYTEXT NULL,                      -- Address line 2
-  city INT NULL,                            -- Pointer to City in cities table
-  state TINYTEXT NULL,                      -- Two character state code - matches states.ini entries
-  country TINYTEXT NULL,                    -- Two character country code - matches countries.ini entries
-  zip TINYTEXT NULL,                        -- ZIP/Postal code
-  lat FLOAT NULL,                           -- Latitude of member's location
-  lon FLOAT NULL,                           -- Longitude of member's location
-  region INT NULL,                          -- Pointer to entry in regions table
-  county INT NULL,                          -- Pointer to entry in regions table
-  phone TINYTEXT NULL,                      -- Primary phone number
-  toll_free TINYTEXT NULL,                  -- Toll Free phone number
-  url TINYTEXT NULL,                        -- URL with information about this member
-  reservation_url TEXT NULL,                -- Reservation URL
-  email TINYTEXT NULL,                      -- Main E-Mail address for this member
-  logo TINYTEXT NULL,                       -- Member logo
-  cc_type INT NULL,                         -- Bitmap of credit card types accepted - See credit_card array in plugin.ini
-  video_url TINYTEXT NULL,                  -- Video URL
-  video_file TINYTEXT NULL,                 -- Video File Name
-  video_title TINYTEXT NULL,                -- Video Title
-  video_descr TEXT NULL,                    -- Video Description
-  video_type INT NULL,                      -- Video Type - See plugin.ini video type table.
-  live_cam_url TINYTEXT NULL,               -- Live Cam URL
-  live_cam_title TINYTEXT NULL,             -- Live Cam Title
-  live_cam_descr TEXT NULL,                 -- Live Cam Description
-  live_cam_type INT NULL,                   -- Live Cam Type - See plugin.ini video type table.
-  mailing_addr1 TINYTEXT NULL,              -- Mailing Address 1
-  mailing_addr2 TINYTEXT NULL,              -- Mailing Address 2
-  mailing_city INT NULL,                    -- Mailing City  (Pointer to City in cities table)
-  mailing_state TINYTEXT NULL,              -- Mailing State (Two character state code - matches states.ini entries)
-  mailing_zip TINYTEXT NULL,                -- Mailing ZIP/Postal code
-  notes TEXT NULL,                          -- General notes - Not displayed in front-end
-  create_time TIMESTAMP NULL,               -- Create date/time
-  modify_time TIMESTAMP NULL,               -- Last update date/time
-  PRIMARY KEY (id),
-  INDEX(status),
-  INDEX(city),
-  INDEX(zip(10)),
-  INDEX(lat),
-  INDEX(lon),
-  INDEX(region),
-  INDEX(county)
-);
-
-----
-
--- Member type - Can be used to assign members to different "classes" of membership (i.e. Full, Associate, Premium)
--- Mostly for internal use by the member organization, but could be displayed - Consider a short_description if they are.
-CREATE TABLE {prefix}member_type (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Name of member type
-  descr TINYTEXT NULL,                      -- Description of member type
-  PRIMARY KEY (id)
-);
-
-----
-
--- Regions - Used to segment members into various geographical regions - can be cities, counties, or other logical regions
-CREATE TABLE {prefix}regions (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Name of region
-  descr TEXT NULL,                          -- Description of region
-  short_descr TINYTEXT NULL,                -- Short description of region
-  PRIMARY KEY (id)
-);
-
-----
-
--- Counties
-CREATE TABLE {prefix}counties (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                       -- Name of county
-  descr TEXT NULL,                          -- Description of county
-  short_descr TINYTEXT NULL,                -- Short description of county
-  PRIMARY KEY (id)
-);
-
-----
-
--- General settings available on Management page in admin - Only 1 entry in this table
--- Items in this table should be all self-explanatory
-CREATE TABLE {prefix}settings_general (
-  id INT NOT NULL AUTO_INCREMENT,
-  admin_debug BOOLEAN DEFAULT '0',
-  admin_debug_verbose BOOLEAN DEFAULT '0',
-  front_debug BOOLEAN DEFAULT '0',
-  front_debug_verbose BOOLEAN DEFAULT '0',
-  enable_members BOOLEAN DEFAULT '1',
-  google_maps_api_key TINYTEXT DEFAULT '',
-  maps_default_lat FLOAT DEFAULT '45.3749',
-  maps_default_lon FLOAT DEFAULT '-84.9592',
-  maps_default_zoom INTEGER DEFAULT '10',
-  time_zone TINYTEXT DEFAULT NULL,
-  canonical_member_page TINYTEXT DEFAULT NULL,
-  phone_infix TINYTEXT DEFAULT NULL,
-  phone_format TINYTEXT DEFAULT NULL,
-  default_state TINYTEXT DEFAULT NULL,
-  enable_counties BOOLEAN DEFAULT '0',
-  enable_multiple_profiles BOOLEAN DEFAULT '0',
-  memb_info_location BOOLEAN DEFAULT '1',
-  memb_info_contact BOOLEAN DEFAULT '1',
-  memb_info_categories BOOLEAN DEFAULT '1',
-  memb_info_images BOOLEAN DEFAULT '1',
-  memb_info_files BOOLEAN DEFAULT '1',
-  memb_info_video BOOLEAN DEFAULT '1',
-  memb_info_cam BOOLEAN DEFAULT '1',
-  list_show_map BOOLEAN DEFAULT '1',
-  list_show_list BOOLEAN DEFAULT '1',
-  list_order_list SMALLINT DEFAULT '10',
-  list_pagination BOOLEAN DEFAULT '1',
-  list_pagination_count SMALLINT DEFAULT '20',
-  list_show_search_filters_opened BOOLEAN DEFAULT '0',
-  list_show_search BOOLEAN DEFAULT '1',
-  list_show_search_text BOOLEAN DEFAULT '1',
-  list_show_search_category BOOLEAN DEFAULT '1',
-  list_show_search_amenities BOOLEAN DEFAULT '1',
-  list_show_search_region BOOLEAN DEFAULT '1',
-  list_show_search_alpha BOOLEAN DEFAULT '1',
-  list_floating_search BOOLEAN DEFAULT '0',
-  list_floating_search_distance_top INTEGER DEFAULT '0',    -- How far from the top the sticky Search/Filters box should hover
-  list_show_detail_link BOOLEAN DEFAULT '1',
-  list_show_logo BOOLEAN DEFAULT '1',
-  list_logo_size TINYTEXT NULL,
-  list_logo_for_mobile BOOLEAN DEFAULT '1',
-  list_show_address BOOLEAN DEFAULT '1',
-  list_show_street BOOLEAN DEFAULT '1',
-  list_show_citystatezip BOOLEAN DEFAULT '1',
-  list_show_country BOOLEAN DEFAULT '1',
-  list_show_region BOOLEAN DEFAULT '1',
-  list_show_descr BOOLEAN DEFAULT '0',
-  list_show_short_descr BOOLEAN DEFAULT '1',
-  list_show_phone BOOLEAN DEFAULT '1',
-  list_show_tollfree BOOLEAN DEFAULT '1',
-  list_show_url BOOLEAN DEFAULT '1',
-  list_show_url_newtarget BOOLEAN DEFAULT '1',
-  list_show_email BOOLEAN DEFAULT '1',
-  list_show_categories BOOLEAN DEFAULT '0',
-  list_show_creditcards BOOLEAN DEFAULT '0',
-  list_show_amenities BOOLEAN DEFAULT '0',
-  list_show_logo_filler BOOLEAN DEFAULT '1',
-  list_show_live_cam BOOLEAN DEFAULT '1',
-  list_map_show_opened BOOLEAN DEFAULT '0',
-  list_map_show_detaillink BOOLEAN DEFAULT '1',
-  list_map_show_logo BOOLEAN DEFAULT '0',
-  list_map_logo_size TINYTEXT NULL,
-  list_map_show_descr BOOLEAN DEFAULT '0',
-  list_map_show_short_descr BOOLEAN DEFAULT '1',
-  list_map_show_address BOOLEAN DEFAULT '1',
-  list_map_show_street BOOLEAN DEFAULT '1',
-  list_map_show_citystatezip BOOLEAN DEFAULT '1',
-  list_map_show_country BOOLEAN DEFAULT '1',
-  list_map_show_region BOOLEAN DEFAULT '1',
-  list_map_show_phone BOOLEAN DEFAULT '1',
-  list_map_show_tollfree BOOLEAN DEFAULT '1',
-  list_map_show_url BOOLEAN DEFAULT '1',
-  list_map_show_url_newtarget BOOLEAN DEFAULT '1',
-  list_map_show_email BOOLEAN DEFAULT '1',
-  list_map_show_categories BOOLEAN DEFAULT '0',
-  list_map_show_creditcards BOOLEAN DEFAULT '0',
-  list_map_show_amenities BOOLEAN DEFAULT '0',
-  list_show_packages BOOLEAN DEFAULT '0',
-  list_show_packages_link BOOLEAN DEFAULT '0',
-  list_header_text TINYTEXT DEFAULT NULL,
-  detail_show_map BOOLEAN DEFAULT '1',
-  detail_show_directions BOOLEAN DEFAULT '1',
-  detail_show_logo BOOLEAN DEFAULT '1',
-  detail_logo_size TINYTEXT NULL,
-  detail_show_descr BOOLEAN DEFAULT '1',
-  detail_show_short_descr BOOLEAN DEFAULT '0',
-  detail_show_address BOOLEAN DEFAULT '1',
-  detail_show_street BOOLEAN DEFAULT '1',
-  detail_show_citystatezip BOOLEAN DEFAULT '1',
-  detail_show_country BOOLEAN DEFAULT '1',
-  detail_show_region BOOLEAN DEFAULT '1',
-  detail_show_phone BOOLEAN DEFAULT '1',
-  detail_show_tollfree BOOLEAN DEFAULT '1',
-  detail_show_url BOOLEAN DEFAULT '1',
-  detail_show_url_newtarget BOOLEAN DEFAULT '1',
-  detail_show_email BOOLEAN DEFAULT '1',
-  detail_show_categories BOOLEAN DEFAULT '0',
-  detail_show_creditcards BOOLEAN DEFAULT '0',
-  detail_show_amenities BOOLEAN DEFAULT '1',
-  detail_show_imagegallery BOOLEAN DEFAULT '1',
-  detail_show_coupons BOOLEAN DEFAULT '0',
-  detail_show_packages BOOLEAN DEFAULT '0',
-  detail_show_events BOOLEAN DEFAULT '0',
-  detail_show_video BOOLEAN DEFAULT '0',
-  detail_show_live_cam BOOLEAN DEFAULT '0',
-  detail_top_offset_autoscroll INTEGER DEFAULT '0', -- Determines the distance from the top when autoscrolling to a section on member detail pages
-  detail_map_show_logo BOOLEAN DEFAULT '0',
-  detail_map_logo_size TINYTEXT NULL,
-  detail_map_show_descr BOOLEAN DEFAULT '0',
-  detail_map_show_short_descr BOOLEAN DEFAULT '1',
-  detail_map_show_address BOOLEAN DEFAULT '1',
-  detail_map_show_street BOOLEAN DEFAULT '1',
-  detail_map_show_citystatezip BOOLEAN DEFAULT '1',
-  detail_map_show_country BOOLEAN DEFAULT '1',
-  detail_map_show_region BOOLEAN DEFAULT '1',
-  detail_map_show_phone BOOLEAN DEFAULT '1',
-  detail_map_show_tollfree BOOLEAN DEFAULT '1',
-  detail_map_show_url BOOLEAN DEFAULT '1',
-  detail_map_show_url_newtarget BOOLEAN DEFAULT '1',
-  detail_map_show_email BOOLEAN DEFAULT '1',
-  detail_map_show_categories BOOLEAN DEFAULT '0',
-  detail_map_show_creditcards BOOLEAN DEFAULT '0',
-  detail_map_show_amenities BOOLEAN DEFAULT '0',
-  members_only_support_email TINYTEXT DEFAULT '',
-  members_only_support_phone TINYTEXT DEFAULT '',
-  short_desc_char_limit INTEGER DEFAULT '120',    -- How many characters the short description is limited to - also used for importing
-  PRIMARY KEY (id)
-);
-
-----
-
--- Set default entry
-INSERT INTO {prefix}settings_general
-    ( id, time_zone, canonical_member_page, list_logo_size, list_map_logo_size, detail_logo_size, detail_map_logo_size, list_pagination, list_pagination_count, enable_counties, enable_multiple_profiles)
-   VALUES
-    ( 1, 'America/Detroit', 'member-detail', 'large', 'thumb', 'large', 'thumb', '1', 20, 0, 0 )
-;
-
-----
-
--- Terms used in site modifiable on Management page in admin - Only 1 entry in this table
--- Terms in this table should be all self-explanatory
-CREATE TABLE {prefix}settings_terms (
-  id INT NOT NULL AUTO_INCREMENT,
-  term_admin_menu_members TINYTEXT NULL,
-  term_admin_menu_member_list TINYTEXT NULL,
-  term_admin_menu_member TINYTEXT NULL,
-  term_admin_menu_configure TINYTEXT NULL,
-  term_admin_menu_settings TINYTEXT NULL,
-  term_admin_menu_shortcodes TINYTEXT NULL,
-  term_admin_menu_members_dashboard TINYTEXT NULL,
-  term_admin_menu_members_list TINYTEXT NULL,
-  term_admin_menu_members_reports TINYTEXT NULL,
-  term_admin_menu_member_dashboard TINYTEXT NULL,
-  term_admin_menu_member_info TINYTEXT NULL,
-  term_admin_menu_member_locations TINYTEXT NULL,
-  term_admin_menu_member_facilities TINYTEXT NULL,
-  term_admin_menu_member_attractions TINYTEXT NULL,
-  term_admin_menu_member_contacts TINYTEXT NULL,
-  term_admin_menu_configure_member_types TINYTEXT NULL,
-  term_admin_menu_configure_member_cats TINYTEXT NULL,
-  term_admin_menu_configure_accom_types TINYTEXT NULL,
-  term_admin_menu_configure_amenities TINYTEXT NULL,
-  term_admin_menu_configure_cities TINYTEXT NULL,
-  term_admin_menu_configure_counties TINYTEXT NULL,
-  term_admin_menu_configure_regions TINYTEXT NULL,
-  term_admin_menu_settings_general TINYTEXT NULL,
-  term_admin_menu_settings_terms TINYTEXT NULL,
-  term_admin_menu_settings_development TINYTEXT NULL,
-  term_member TINYTEXT NULL,
-  term_member_cap TINYTEXT NULL,
-  term_member_plur TINYTEXT NULL,
-  term_member_plur_cap TINYTEXT NULL,
-  term_location TINYTEXT NULL,
-  term_location_cap TINYTEXT NULL,
-  term_location_plur TINYTEXT NULL,
-  term_location_plur_cap TINYTEXT NULL,
-  term_county TINYTEXT NULL,
-  term_county_cap TINYTEXT NULL,
-  term_county_plur TINYTEXT NULL,
-  term_county_plur_cap TINYTEXT NULL,
-  term_facility TINYTEXT NULL,
-  term_facility_cap TINYTEXT NULL,
-  term_facility_plur TINYTEXT NULL,
-  term_facility_plur_cap TINYTEXT NULL,
-  term_attraction TINYTEXT NULL,
-  term_attraction_cap TINYTEXT NULL,
-  term_attraction_plur TINYTEXT NULL,
-  term_attraction_plur_cap TINYTEXT NULL,
-  term_contact TINYTEXT NULL,
-  term_contact_cap TINYTEXT NULL,
-  term_contact_plur TINYTEXT NULL,
-  term_contact_plur_cap TINYTEXT NULL,
-  term_webcam_cap TINYTEXT NULL,
-  PRIMARY KEY (id)
-);
-
-----
-
--- Default terms entry
-INSERT INTO {prefix}settings_terms
-    (
-    id,
-    term_admin_menu_members,
-    term_admin_menu_member_list,
-    term_admin_menu_member,
-    term_admin_menu_configure,
-    term_admin_menu_settings,
-    term_admin_menu_shortcodes,
-    term_admin_menu_members_dashboard,
-    term_admin_menu_members_list,
-    term_admin_menu_members_reports,
-    term_admin_menu_member_dashboard,
-    term_admin_menu_member_info,
-    term_admin_menu_member_locations,
-    term_admin_menu_member_facilities,
-    term_admin_menu_member_attractions,
-    term_admin_menu_member_contacts,
-    term_admin_menu_configure_member_types,
-    term_admin_menu_configure_member_cats,
-    term_admin_menu_configure_accom_types,
-    term_admin_menu_configure_amenities,
-    term_admin_menu_configure_cities,
-    term_admin_menu_configure_counties,
-    term_admin_menu_configure_regions,
-    term_admin_menu_settings_general,
-    term_admin_menu_settings_terms,
-    term_admin_menu_settings_development,
-    term_member,
-    term_member_cap,
-    term_member_plur,
-    term_member_plur_cap,
-    term_location,
-    term_location_cap,
-    term_location_plur,
-    term_location_plur_cap,
-    term_county,
-    term_county_cap,
-    term_county_plur,
-    term_county_plur_cap,
-    term_facility,
-    term_facility_cap,
-    term_facility_plur,
-    term_facility_plur_cap,
-    term_attraction,
-    term_attraction_cap,
-    term_attraction_plur,
-    term_attraction_plur_cap,
-    term_contact,
-    term_contact_cap,
-    term_contact_plur,
-    term_contact_plur_cap,
-    term_webcam_cap
-    )
-   VALUES
-    (
-    1,
-    'Members',
-    'Member',
-    'Member',
-    'Configure',
-    'Management',
-    'Shortcodes',
-    'Dashboard',
-    'Member List',
-    'Reports',
-    'Member Dashboard',
-    'Member Info',
-    'Locations',
-    'Facilities',
-    'Attractions',
-    'Contacts',
-    'Member Types',
-    'Member Categories',
-    'Accommodation Types',
-    'Amenities',
-    'Cities',
-    'Counties',
-    'Regions',
-    'General Settings',
-    'Terms & Phrases',
-    'Development',
-    'member',
-    'Member',
-    'members',
-    'Members',
-    'location',
-    'Location',
-    'locations',
-    'Locations',
-    'county',
-    'County',
-    'counties',
-    'Counties',
-    'facility',
-    'Facility',
-    'facilities',
-    'Facilities',
-    'attraction',
-    'Attraction',
-    'attractions',
-    'Attractions',
-    'contact',
-    'Contact',
-    'contacts',
-    'Contacts',
-    'Webcam'
-    )
-;
-
-----
-
--- Shortcode Output Cache
-CREATE TABLE {prefix}cache (
-    shortcode TINYTEXT NULL,
-    cache_code TINYTEXT NOT NULL,
-    created DATETIME NULL,
-    html MEDIUMTEXT NULL,
-    PRIMARY KEY (cache_code(20)),
-    INDEX (created)
-);
-
-----
-
--- Theme Settings - Only 1 entry in this table
-CREATE TABLE {prefix}settings_theme (
-    id INT NOT NULL AUTO_INCREMENT,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Default Theme Settings entry
-INSERT INTO {prefix}settings_theme
-    (
-    id
-    )
-   VALUES
-    (
-    1
-    )
-;
-
diff --git a/setup/databaseScripts/create_database_V1.1.33.sql b/setup/databaseScripts/create_database_V1.1.33.sql
new file mode 100644 (file)
index 0000000..1fd8d26
--- /dev/null
@@ -0,0 +1,650 @@
+-- Gaslight Media Members Database
+-- File Created: 12/29/16 12:06:00
+-- Database Version: 1.1.32
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+--
+-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
+--
+
+-- Amenities
+CREATE TABLE {prefix}amenities (
+  id INT NOT NULL AUTO_INCREMENT,
+  active TINYINT(1) NULL,                   -- Amenity is active flag
+  name TINYTEXT NULL,                       -- Name of amenity
+  descr TEXT NULL,                          -- Description of amenity
+  short_descr TINYTEXT NULL,                -- Short description of amenity
+  ref_type INT NULL,                        -- Type of entity these amenities are associated with - see plugin.ini ref_type tables
+  uses_value BOOLEAN NULL,                  -- Flag indicating whether the amenity requires a quantity number
+  PRIMARY KEY (id),
+  INDEX(name(20))
+);
+
+----
+
+-- Amenity Reference - Links a specific amenity to a specific entity of type ref_type
+CREATE TABLE {prefix}amenity_ref (
+  id INT NOT NULL AUTO_INCREMENT,
+  amenity INT NULL,                         -- Pointer to amenity in amenities table
+  ref_type INT NULL,                        -- Copy of ref_type from matching amenities table entry - to simplify searches
+  ref_dest INT NULL,                        -- Pointer to the specific entity of type ref_type
+  amenity_value TINYTEXT NULL,              -- Quantity if amenity uses values
+  PRIMARY KEY (id),
+  INDEX(ref_type),
+  INDEX(ref_dest)
+);
+
+----
+
+-- groups
+CREATE TABLE {prefix}amenity_groups (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NULL,                     -- Name of the Group
+    PRIMARY KEY (id),
+    INDEX(name(20))
+);
+
+----
+
+-- Amenity Group - Links a specific amenity to groups
+CREATE TABLE {prefix}grouped_amenities (
+    id INT NOT NULL AUTO_INCREMENT,
+    group_id INT,                              -- Pointer to the group
+    amenity_id INT,                            -- Pointer to the Amenity
+    searchable BOOLEAN DEFAULT '0',         -- Flag indicating whether the amenity group will show in the search form
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Member Cateogries - used with member information records
+CREATE TABLE {prefix}categories (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of this category
+  descr TEXT NULL,                          -- Description of this category
+  short_descr TINYTEXT NULL,                -- Short description of this category
+  parent INT NULL,                          -- Pointer to parent category in this table - if there is one
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Mapping of categories to specific member information records
+CREATE TABLE {prefix}category_member_info (
+  id INT NOT NULL AUTO_INCREMENT,
+  category INT NULL,                        -- Pointer to category in categories table
+  member_info INT NULL,                     -- Pointer to member information record
+  PRIMARY KEY (id),
+  CONSTRAINT {prefix}categories_fk_1
+    FOREIGN KEY (category)
+    REFERENCES {prefix}categories (id)
+    ON DELETE CASCADE,
+  INDEX(category),
+  INDEX(member_info)
+);
+
+----
+
+-- Cities
+CREATE TABLE {prefix}cities (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of city
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Member Click Through Stats Data - Totals of URL click-throughs - Preserved for 2 years
+CREATE TABLE {prefix}clickthrough_stats (
+  member INT NOT NULL,                          -- ID of member
+  stat_type INT NOT NULL,                       -- Type of stat 1 = day, 2 = week, 3 = month
+  stat_date DATE NOT NULL,                      -- Date for which these stats are accumulated (date or first date of week or month)
+  clicks INT NULL,                          -- Number of Clicks
+  PRIMARY KEY (member, stat_type, stat_date),
+  INDEX (member),
+  INDEX (stat_type),
+  INDEX (stat_date)
+);
+
+----
+
+-- Files - Files are stored under /wp-content/uploads/glm-member-db/files/
+CREATE TABLE {prefix}files (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Original name of the file - might be URL if copied via HTTP
+  status TINYINT(1) NULL,                   -- Display/Use status - See plugin.ini status table
+  file_name TINYTEXT NULL,                  -- Stored file name for the file
+  descr TEXT NULL,                          -- Description
+  caption TINYTEXT NULL,                    -- Caption for the image
+  position INT NULL,                        -- Numeric position for sequence of display
+  ref_type INT NULL,                        -- Type of entity this image is associated with
+  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this image is associated with
+  PRIMARY KEY (id),
+  INDEX(name(20)),
+  INDEX(file_name(20)),
+  INDEX(ref_type),
+  INDEX(ref_dest)
+);
+
+----
+
+-- Images - Images are stored under /wp-content/uploads/glm-member-db/images/{size}/
+CREATE TABLE {prefix}images (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Original name of the image - might be URL if copied via HTTP
+  status TINYINT(1) NULL,                   -- Display/Use status - See plugin.ini status table
+  selected BOOLEAN NULL,                    -- A single special image in the current gallery for this entity
+  featured BOOLEAN null,                    -- Image is a member of a group of featured images
+  file_name TINYTEXT NULL,                  -- Stored file name for the image
+  descr TEXT NULL,                          -- Description
+  caption TINYTEXT NULL,                    -- Caption for the image
+  position INT NULL,                        -- Numeric position for sequence of display
+  ref_type INT NULL,                        -- Type of entity this image is associated with
+  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this image is associated with
+  PRIMARY KEY (id),
+  INDEX(name(20)),
+  INDEX(file_name(20)),
+  INDEX(ref_type),
+  INDEX(ref_dest)
+);
+
+----
+
+-- Primary member records - One for each member
+CREATE TABLE {prefix}members (
+  id INT NOT NULL AUTO_INCREMENT,
+  access INT NULL,                          -- Access type - See access table in plugin.ini
+  member_type INT NULL,                     -- Pointer to member type in member_type table
+  created DATE NULL,                        -- Date member record was created
+  name TINYTEXT NULL,                       -- Member name
+  member_slug TINYTEXT NULL,                -- Member name slug for canonical URLs (lowercase, "-" for spaces, no punctuation)
+  notes TEXT NULL,                          -- General notes - Not displayed in front-end
+  old_member_id INT NULL,                   -- Old member ID if imported from old database
+  featured BOOLEAN DEFAULT '0',             -- Whether the member is featured
+  PRIMARY KEY (id),
+  INDEX(name(20)),
+  INDEX(member_slug(20)),
+  INDEX(created)
+);
+
+----
+
+-- Member Detail Display Stats Data - Totals of times detail page is displayed - Preserved for 2 years
+CREATE TABLE {prefix}member_detail_stats (
+  member INT NOT NULL,                          -- ID of member
+  stat_type INT NOT NULL,                       -- Type of stat 1 = day, 2 = week, 3 = month
+  stat_date DATE NOT NULL,                      -- Date for which these stats are accumulated (date or first date of week or month)
+  clicks INT NULL,                          -- Number of Clicks
+  PRIMARY KEY (member, stat_type, stat_date),
+  INDEX (member),
+  INDEX (stat_type),
+  INDEX (stat_date)
+);
+
+----
+
+-- Member information version record - May be multiples per member - Only one with status "Active" for a distinct date range
+CREATE TABLE {prefix}member_info (
+  id INT NOT NULL AUTO_INCREMENT,
+  member INT NULL,                          -- Pointer to member record in table members
+  member_name TINYTEXT NULL,                -- Copy of member name from members table entry for fast reference
+  status INT NULL,                          -- Status of this member information record - See plugin.ini status table
+  reference_name TINYTEXT NULL,             -- Reference name for this member information record - Not displayed on front-end
+  descr TEXT NULL,                          -- Description
+  short_descr TEXT NULL,                    -- Short description
+  addr1 TINYTEXT NULL,                      -- Main member location address line 1
+  addr2 TINYTEXT NULL,                      -- Address line 2
+  city INT NULL,                            -- Pointer to City in cities table
+  state TINYTEXT NULL,                      -- Two character state code - matches states.ini entries
+  country TINYTEXT NULL,                    -- Two character country code - matches countries.ini entries
+  zip TINYTEXT NULL,                        -- ZIP/Postal code
+  lat FLOAT NULL,                           -- Latitude of member's location
+  lon FLOAT NULL,                           -- Longitude of member's location
+  region INT NULL,                          -- Pointer to entry in regions table
+  county INT NULL,                          -- Pointer to entry in regions table
+  phone TINYTEXT NULL,                      -- Primary phone number
+  toll_free TINYTEXT NULL,                  -- Toll Free phone number
+  url TINYTEXT NULL,                        -- URL with information about this member
+  reservation_url TEXT NULL,                -- Reservation URL
+  email TINYTEXT NULL,                      -- Main E-Mail address for this member
+  logo TINYTEXT NULL,                       -- Member logo
+  cc_type INT NULL,                         -- Bitmap of credit card types accepted - See credit_card array in plugin.ini
+  video_url TINYTEXT NULL,                  -- Video URL
+  video_file TINYTEXT NULL,                 -- Video File Name
+  video_title TINYTEXT NULL,                -- Video Title
+  video_descr TEXT NULL,                    -- Video Description
+  video_type INT NULL,                      -- Video Type - See plugin.ini video type table.
+  live_cam_url TINYTEXT NULL,               -- Live Cam URL
+  live_cam_title TINYTEXT NULL,             -- Live Cam Title
+  live_cam_descr TEXT NULL,                 -- Live Cam Description
+  live_cam_type INT NULL,                   -- Live Cam Type - See plugin.ini video type table.
+  mailing_addr1 TINYTEXT NULL,              -- Mailing Address 1
+  mailing_addr2 TINYTEXT NULL,              -- Mailing Address 2
+  mailing_city INT NULL,                    -- Mailing City  (Pointer to City in cities table)
+  mailing_state TINYTEXT NULL,              -- Mailing State (Two character state code - matches states.ini entries)
+  mailing_zip TINYTEXT NULL,                -- Mailing ZIP/Postal code
+  notes TEXT NULL,                          -- General notes - Not displayed in front-end
+  create_time TIMESTAMP NULL,               -- Create date/time
+  modify_time TIMESTAMP NULL,               -- Last update date/time
+  PRIMARY KEY (id),
+  INDEX(status),
+  INDEX(city),
+  INDEX(zip(10)),
+  INDEX(lat),
+  INDEX(lon),
+  INDEX(region),
+  INDEX(county)
+);
+
+----
+
+-- Member type - Can be used to assign members to different "classes" of membership (i.e. Full, Associate, Premium)
+-- Mostly for internal use by the member organization, but could be displayed - Consider a short_description if they are.
+CREATE TABLE {prefix}member_type (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of member type
+  descr TINYTEXT NULL,                      -- Description of member type
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Regions - Used to segment members into various geographical regions - can be cities, counties, or other logical regions
+CREATE TABLE {prefix}regions (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of region
+  descr TEXT NULL,                          -- Description of region
+  short_descr TINYTEXT NULL,                -- Short description of region
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Counties
+CREATE TABLE {prefix}counties (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of county
+  descr TEXT NULL,                          -- Description of county
+  short_descr TINYTEXT NULL,                -- Short description of county
+  PRIMARY KEY (id)
+);
+
+----
+
+-- File Library Cateogries - used with "Files Library" - Created due to PDF failures in WordPress Media Library
+CREATE TABLE {prefix}file_library_categories (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of this category
+  descr TEXT NULL,                          -- Description of this category
+  short_descr TINYTEXT NULL,                -- Short description of this category
+  parent INT NULL,                          -- Pointer to parent category in this table - if there is one
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Files Library - Files are stored under /wp-content/uploads/glm-member-db/filesLibrary/
+CREATE TABLE {prefix}file_library (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Original name of the file - might be URL if copied via HTTP
+  file_name TINYTEXT NULL,                  -- Stored file name for the file
+  descr TEXT NULL,                          -- Description
+  title TINYTEXT NULL,                      -- File title
+  last_access_time DATETIME DEFAULT NOW(),  -- Upload time or last access time
+  PRIMARY KEY (id),
+  INDEX(name(20)),
+  INDEX(file_name(20))
+);
+
+----
+
+-- General settings available on Management page in admin - Only 1 entry in this table
+-- Items in this table should be all self-explanatory
+CREATE TABLE {prefix}settings_general (
+  id INT NOT NULL AUTO_INCREMENT,
+  admin_debug BOOLEAN DEFAULT '0',
+  admin_debug_verbose BOOLEAN DEFAULT '0',
+  front_debug BOOLEAN DEFAULT '0',
+  front_debug_verbose BOOLEAN DEFAULT '0',
+  enable_members BOOLEAN DEFAULT '1',
+  google_maps_api_key TINYTEXT DEFAULT '',
+  maps_default_lat FLOAT DEFAULT '45.3749',
+  maps_default_lon FLOAT DEFAULT '-84.9592',
+  maps_default_zoom INTEGER DEFAULT '10',
+  time_zone TINYTEXT DEFAULT NULL,
+  canonical_member_page TINYTEXT DEFAULT NULL,
+  phone_infix TINYTEXT DEFAULT NULL,
+  phone_format TINYTEXT DEFAULT NULL,
+  default_state TINYTEXT DEFAULT NULL,
+  enable_counties BOOLEAN DEFAULT '0',
+  enable_multiple_profiles BOOLEAN DEFAULT '0',
+  memb_info_location BOOLEAN DEFAULT '1',
+  memb_info_contact BOOLEAN DEFAULT '1',
+  memb_info_categories BOOLEAN DEFAULT '1',
+  memb_info_images BOOLEAN DEFAULT '1',
+  memb_info_files BOOLEAN DEFAULT '1',
+  memb_info_video BOOLEAN DEFAULT '1',
+  memb_info_cam BOOLEAN DEFAULT '1',
+  file_library BOOLEAN DEFAULT '0',
+  list_show_map BOOLEAN DEFAULT '1',
+  list_show_list BOOLEAN DEFAULT '1',
+  list_order_list SMALLINT DEFAULT '10',
+  list_pagination BOOLEAN DEFAULT '1',
+  list_pagination_count SMALLINT DEFAULT '20',
+  list_show_search_filters_opened BOOLEAN DEFAULT '0',
+  list_show_search BOOLEAN DEFAULT '1',
+  list_show_search_text BOOLEAN DEFAULT '1',
+  list_show_search_category BOOLEAN DEFAULT '1',
+  list_show_search_amenities BOOLEAN DEFAULT '1',
+  list_show_search_region BOOLEAN DEFAULT '1',
+  list_show_search_alpha BOOLEAN DEFAULT '1',
+  list_floating_search BOOLEAN DEFAULT '0',
+  list_floating_search_distance_top INTEGER DEFAULT '0',    -- How far from the top the sticky Search/Filters box should hover
+  list_show_detail_link BOOLEAN DEFAULT '1',
+  list_show_logo BOOLEAN DEFAULT '1',
+  list_logo_size TINYTEXT NULL,
+  list_logo_for_mobile BOOLEAN DEFAULT '1',
+  list_show_address BOOLEAN DEFAULT '1',
+  list_show_street BOOLEAN DEFAULT '1',
+  list_show_citystatezip BOOLEAN DEFAULT '1',
+  list_show_country BOOLEAN DEFAULT '1',
+  list_show_region BOOLEAN DEFAULT '1',
+  list_show_descr BOOLEAN DEFAULT '0',
+  list_show_short_descr BOOLEAN DEFAULT '1',
+  list_show_phone BOOLEAN DEFAULT '1',
+  list_show_tollfree BOOLEAN DEFAULT '1',
+  list_show_url BOOLEAN DEFAULT '1',
+  list_show_url_newtarget BOOLEAN DEFAULT '1',
+  list_show_email BOOLEAN DEFAULT '1',
+  list_show_categories BOOLEAN DEFAULT '0',
+  list_show_creditcards BOOLEAN DEFAULT '0',
+  list_show_amenities BOOLEAN DEFAULT '0',
+  list_show_logo_filler BOOLEAN DEFAULT '1',
+  list_show_live_cam BOOLEAN DEFAULT '1',
+  list_map_show_opened BOOLEAN DEFAULT '0',
+  list_map_show_detaillink BOOLEAN DEFAULT '1',
+  list_map_show_logo BOOLEAN DEFAULT '0',
+  list_map_logo_size TINYTEXT NULL,
+  list_map_show_descr BOOLEAN DEFAULT '0',
+  list_map_show_short_descr BOOLEAN DEFAULT '1',
+  list_map_show_address BOOLEAN DEFAULT '1',
+  list_map_show_street BOOLEAN DEFAULT '1',
+  list_map_show_citystatezip BOOLEAN DEFAULT '1',
+  list_map_show_country BOOLEAN DEFAULT '1',
+  list_map_show_region BOOLEAN DEFAULT '1',
+  list_map_show_phone BOOLEAN DEFAULT '1',
+  list_map_show_tollfree BOOLEAN DEFAULT '1',
+  list_map_show_url BOOLEAN DEFAULT '1',
+  list_map_show_url_newtarget BOOLEAN DEFAULT '1',
+  list_map_show_email BOOLEAN DEFAULT '1',
+  list_map_show_categories BOOLEAN DEFAULT '0',
+  list_map_show_creditcards BOOLEAN DEFAULT '0',
+  list_map_show_amenities BOOLEAN DEFAULT '0',
+  list_show_packages BOOLEAN DEFAULT '0',
+  list_show_packages_link BOOLEAN DEFAULT '0',
+  list_header_text TINYTEXT DEFAULT NULL,
+  detail_show_map BOOLEAN DEFAULT '1',
+  detail_show_directions BOOLEAN DEFAULT '1',
+  detail_show_logo BOOLEAN DEFAULT '1',
+  detail_logo_size TINYTEXT NULL,
+  detail_show_descr BOOLEAN DEFAULT '1',
+  detail_show_short_descr BOOLEAN DEFAULT '0',
+  detail_show_address BOOLEAN DEFAULT '1',
+  detail_show_street BOOLEAN DEFAULT '1',
+  detail_show_citystatezip BOOLEAN DEFAULT '1',
+  detail_show_country BOOLEAN DEFAULT '1',
+  detail_show_region BOOLEAN DEFAULT '1',
+  detail_show_phone BOOLEAN DEFAULT '1',
+  detail_show_tollfree BOOLEAN DEFAULT '1',
+  detail_show_url BOOLEAN DEFAULT '1',
+  detail_show_url_newtarget BOOLEAN DEFAULT '1',
+  detail_show_email BOOLEAN DEFAULT '1',
+  detail_show_categories BOOLEAN DEFAULT '0',
+  detail_show_creditcards BOOLEAN DEFAULT '0',
+  detail_show_amenities BOOLEAN DEFAULT '1',
+  detail_show_imagegallery BOOLEAN DEFAULT '1',
+  detail_show_coupons BOOLEAN DEFAULT '0',
+  detail_show_packages BOOLEAN DEFAULT '0',
+  detail_show_events BOOLEAN DEFAULT '0',
+  detail_show_video BOOLEAN DEFAULT '0',
+  detail_show_live_cam BOOLEAN DEFAULT '0',
+  detail_top_offset_autoscroll INTEGER DEFAULT '0', -- Determines the distance from the top when autoscrolling to a section on member detail pages
+  detail_map_show_logo BOOLEAN DEFAULT '0',
+  detail_map_logo_size TINYTEXT NULL,
+  detail_map_show_descr BOOLEAN DEFAULT '0',
+  detail_map_show_short_descr BOOLEAN DEFAULT '1',
+  detail_map_show_address BOOLEAN DEFAULT '1',
+  detail_map_show_street BOOLEAN DEFAULT '1',
+  detail_map_show_citystatezip BOOLEAN DEFAULT '1',
+  detail_map_show_country BOOLEAN DEFAULT '1',
+  detail_map_show_region BOOLEAN DEFAULT '1',
+  detail_map_show_phone BOOLEAN DEFAULT '1',
+  detail_map_show_tollfree BOOLEAN DEFAULT '1',
+  detail_map_show_url BOOLEAN DEFAULT '1',
+  detail_map_show_url_newtarget BOOLEAN DEFAULT '1',
+  detail_map_show_email BOOLEAN DEFAULT '1',
+  detail_map_show_categories BOOLEAN DEFAULT '0',
+  detail_map_show_creditcards BOOLEAN DEFAULT '0',
+  detail_map_show_amenities BOOLEAN DEFAULT '0',
+  members_only_support_email TINYTEXT DEFAULT '',
+  members_only_support_phone TINYTEXT DEFAULT '',
+  short_desc_char_limit INTEGER DEFAULT '120',    -- How many characters the short description is limited to - also used for importing
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Set default entry
+INSERT INTO {prefix}settings_general
+    ( id, time_zone, canonical_member_page, list_logo_size, list_map_logo_size, detail_logo_size, detail_map_logo_size, list_pagination, list_pagination_count, enable_counties, enable_multiple_profiles)
+   VALUES
+    ( 1, 'America/Detroit', 'member-detail', 'large', 'thumb', 'large', 'thumb', '1', 20, 0, 0 )
+;
+
+----
+
+-- Terms used in site modifiable on Management page in admin - Only 1 entry in this table
+-- Terms in this table should be all self-explanatory
+CREATE TABLE {prefix}settings_terms (
+  id INT NOT NULL AUTO_INCREMENT,
+  term_admin_menu_members TINYTEXT NULL,
+  term_admin_menu_member_list TINYTEXT NULL,
+  term_admin_menu_member TINYTEXT NULL,
+  term_admin_menu_configure TINYTEXT NULL,
+  term_admin_menu_settings TINYTEXT NULL,
+  term_admin_menu_shortcodes TINYTEXT NULL,
+  term_admin_menu_members_dashboard TINYTEXT NULL,
+  term_admin_menu_members_list TINYTEXT NULL,
+  term_admin_menu_members_reports TINYTEXT NULL,
+  term_admin_menu_member_dashboard TINYTEXT NULL,
+  term_admin_menu_member_info TINYTEXT NULL,
+  term_admin_menu_member_locations TINYTEXT NULL,
+  term_admin_menu_member_facilities TINYTEXT NULL,
+  term_admin_menu_member_attractions TINYTEXT NULL,
+  term_admin_menu_member_contacts TINYTEXT NULL,
+  term_admin_menu_configure_member_types TINYTEXT NULL,
+  term_admin_menu_configure_member_cats TINYTEXT NULL,
+  term_admin_menu_configure_accom_types TINYTEXT NULL,
+  term_admin_menu_configure_amenities TINYTEXT NULL,
+  term_admin_menu_configure_cities TINYTEXT NULL,
+  term_admin_menu_configure_counties TINYTEXT NULL,
+  term_admin_menu_configure_regions TINYTEXT NULL,
+  term_admin_menu_settings_general TINYTEXT NULL,
+  term_admin_menu_settings_terms TINYTEXT NULL,
+  term_admin_menu_settings_development TINYTEXT NULL,
+  term_member TINYTEXT NULL,
+  term_member_cap TINYTEXT NULL,
+  term_member_plur TINYTEXT NULL,
+  term_member_plur_cap TINYTEXT NULL,
+  term_location TINYTEXT NULL,
+  term_location_cap TINYTEXT NULL,
+  term_location_plur TINYTEXT NULL,
+  term_location_plur_cap TINYTEXT NULL,
+  term_county TINYTEXT NULL,
+  term_county_cap TINYTEXT NULL,
+  term_county_plur TINYTEXT NULL,
+  term_county_plur_cap TINYTEXT NULL,
+  term_facility TINYTEXT NULL,
+  term_facility_cap TINYTEXT NULL,
+  term_facility_plur TINYTEXT NULL,
+  term_facility_plur_cap TINYTEXT NULL,
+  term_attraction TINYTEXT NULL,
+  term_attraction_cap TINYTEXT NULL,
+  term_attraction_plur TINYTEXT NULL,
+  term_attraction_plur_cap TINYTEXT NULL,
+  term_contact TINYTEXT NULL,
+  term_contact_cap TINYTEXT NULL,
+  term_contact_plur TINYTEXT NULL,
+  term_contact_plur_cap TINYTEXT NULL,
+  term_webcam_cap TINYTEXT NULL,
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Default terms entry
+INSERT INTO {prefix}settings_terms
+    (
+    id,
+    term_admin_menu_members,
+    term_admin_menu_member_list,
+    term_admin_menu_member,
+    term_admin_menu_configure,
+    term_admin_menu_settings,
+    term_admin_menu_shortcodes,
+    term_admin_menu_members_dashboard,
+    term_admin_menu_members_list,
+    term_admin_menu_members_reports,
+    term_admin_menu_member_dashboard,
+    term_admin_menu_member_info,
+    term_admin_menu_member_locations,
+    term_admin_menu_member_facilities,
+    term_admin_menu_member_attractions,
+    term_admin_menu_member_contacts,
+    term_admin_menu_configure_member_types,
+    term_admin_menu_configure_member_cats,
+    term_admin_menu_configure_accom_types,
+    term_admin_menu_configure_amenities,
+    term_admin_menu_configure_cities,
+    term_admin_menu_configure_counties,
+    term_admin_menu_configure_regions,
+    term_admin_menu_settings_general,
+    term_admin_menu_settings_terms,
+    term_admin_menu_settings_development,
+    term_member,
+    term_member_cap,
+    term_member_plur,
+    term_member_plur_cap,
+    term_location,
+    term_location_cap,
+    term_location_plur,
+    term_location_plur_cap,
+    term_county,
+    term_county_cap,
+    term_county_plur,
+    term_county_plur_cap,
+    term_facility,
+    term_facility_cap,
+    term_facility_plur,
+    term_facility_plur_cap,
+    term_attraction,
+    term_attraction_cap,
+    term_attraction_plur,
+    term_attraction_plur_cap,
+    term_contact,
+    term_contact_cap,
+    term_contact_plur,
+    term_contact_plur_cap,
+    term_webcam_cap
+    )
+   VALUES
+    (
+    1,
+    'Members',
+    'Member',
+    'Member',
+    'Configure',
+    'Management',
+    'Shortcodes',
+    'Dashboard',
+    'Member List',
+    'Reports',
+    'Member Dashboard',
+    'Member Info',
+    'Locations',
+    'Facilities',
+    'Attractions',
+    'Contacts',
+    'Member Types',
+    'Member Categories',
+    'Accommodation Types',
+    'Amenities',
+    'Cities',
+    'Counties',
+    'Regions',
+    'General Settings',
+    'Terms & Phrases',
+    'Development',
+    'member',
+    'Member',
+    'members',
+    'Members',
+    'location',
+    'Location',
+    'locations',
+    'Locations',
+    'county',
+    'County',
+    'counties',
+    'Counties',
+    'facility',
+    'Facility',
+    'facilities',
+    'Facilities',
+    'attraction',
+    'Attraction',
+    'attractions',
+    'Attractions',
+    'contact',
+    'Contact',
+    'contacts',
+    'Contacts',
+    'Webcam'
+    )
+;
+
+----
+
+-- Shortcode Output Cache
+CREATE TABLE {prefix}cache (
+    shortcode TINYTEXT NULL,
+    cache_code TINYTEXT NOT NULL,
+    created DATETIME NULL,
+    html MEDIUMTEXT NULL,
+    PRIMARY KEY (cache_code(20)),
+    INDEX (created)
+);
+
+----
+
+-- Theme Settings - Only 1 entry in this table
+CREATE TABLE {prefix}settings_theme (
+    id INT NOT NULL AUTO_INCREMENT,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Default Theme Settings entry
+INSERT INTO {prefix}settings_theme
+    (
+    id
+    )
+   VALUES
+    (
+    1
+    )
+;
+
index 6dc1e56..7081304 100644 (file)
@@ -63,7 +63,8 @@ $glmMembersDbVersions = array(
     '1.1.29' => array('version' => '1.1.29', 'tables' => 19, 'date' => '04/10/17'),
     '1.1.30' => array('version' => '1.1.30', 'tables' => 19, 'date' => '04/12/17'),
     '1.1.31' => array('version' => '1.1.31', 'tables' => 20, 'date' => '04/23/17'),
-    '1.1.32' => array('version' => '1.1.32', 'tables' => 20, 'date' => '06/14/17')
+    '1.1.32' => array('version' => '1.1.32', 'tables' => 20, 'date' => '06/14/17'),
+    '1.1.33' => array('version' => '1.1.33', 'tables' => 22, 'date' => '01/15/18')
 );
 
 
diff --git a/setup/databaseScripts/drop_database_V1.1.32.sql b/setup/databaseScripts/drop_database_V1.1.32.sql
deleted file mode 100644 (file)
index ef327d8..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
--- Gaslight Media Members Database
--- File Created: 12/09/14 15:27:15
--- Database Version: 1.1.23
--- Database Deletion Script
--- Note: Tables with DELETE CASCADE must appear before referenced table
-
-DROP TABLE IF EXISTS
-    {prefix}amenities,
-    {prefix}amenity_ref,
-    {prefix}category_member_info,
-    {prefix}cities,
-    {prefix}clickthrough_stats,
-    {prefix}images,
-    {prefix}files,
-    {prefix}members,
-    {prefix}member_detail_stats,
-    {prefix}member_info,
-    {prefix}member_type,
-    {prefix}regions,
-    {prefix}counties,
-    {prefix}settings_general,
-    {prefix}settings_terms,
-    {prefix}settings_theme,
-    {prefix}categories,
-    {prefix}amenity_groups,
-    {prefix}grouped_amenities,
-    {prefix}cache
-;
-
diff --git a/setup/databaseScripts/drop_database_V1.1.33.sql b/setup/databaseScripts/drop_database_V1.1.33.sql
new file mode 100644 (file)
index 0000000..ed1f62d
--- /dev/null
@@ -0,0 +1,31 @@
+-- Gaslight Media Members Database
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 1.1.23
+-- Database Deletion Script
+-- Note: Tables with DELETE CASCADE must appear before referenced table
+
+DROP TABLE IF EXISTS
+    {prefix}amenities,
+    {prefix}amenity_ref,
+    {prefix}category_member_info,
+    {prefix}cities,
+    {prefix}clickthrough_stats,
+    {prefix}images,
+    {prefix}files,
+    {prefix}members,
+    {prefix}member_detail_stats,
+    {prefix}member_info,
+    {prefix}member_type,
+    {prefix}regions,
+    {prefix}counties,
+    {prefix}settings_general,
+    {prefix}settings_terms,
+    {prefix}settings_theme,
+    {prefix}categories,
+    {prefix}amenity_groups,
+    {prefix}grouped_amenities,
+    {prefix}cache,
+    {prefix}file_library_categories,
+    {prefix}file_library
+;
+
diff --git a/setup/databaseScripts/update_database_V1.1.33.sql b/setup/databaseScripts/update_database_V1.1.33.sql
new file mode 100644 (file)
index 0000000..d17d8fe
--- /dev/null
@@ -0,0 +1,36 @@
+-- Gaslight Media Members Database
+-- File Created: 01/15/18
+-- Database Version: 1.1.33
+-- 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 dashes.
+
+-- File Library Cateogries - used with "Files Library" - Created due to PDF failures in WordPress Media Library
+CREATE TABLE {prefix}file_library_categories (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Name of this category
+  descr TEXT NULL,                          -- Description of this category
+  short_descr TINYTEXT NULL,                -- Short description of this category
+  parent INT NULL,                          -- Pointer to parent category in this table - if there is one
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Files Library - Files are stored under /wp-content/uploads/glm-member-db/filesLibrary/
+CREATE TABLE {prefix}file_library (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                       -- Original name of the file - might be URL if copied via HTTP
+  file_name TINYTEXT NULL,                  -- Stored file name for the file
+  descr TEXT NULL,                          -- Description
+  title TINYTEXT NULL,                      -- File title
+  last_access_time DATETIME DEFAULT NOW(),  -- Upload time or last access time
+  PRIMARY KEY (id),
+  INDEX(name(20)),
+  INDEX(file_name(20))
+);
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN file_library BOOLEAN DEFAULT '0';
\ No newline at end of file
index ff0a155..dbd1157 100644 (file)
@@ -35,6 +35,7 @@ $glmMembersValidActions = array(
         'ajax' => array(
             'imageUpload'        => 'glm-member-db',
             'fileUpload'         => 'glm-member-db',
+            'fileLibraryUpload'  => 'glm-member-db',
             'newOldMemberIdsCsv' => 'glm-member-db',
             'membersListExport'  => 'glm-member-db',
             'memberClickThrough' => 'glm-member-db',
@@ -48,6 +49,9 @@ $glmMembersValidActions = array(
         'dashboardWidget' => array(
             'index' => 'glm-member-db',
         ),
+        'fileLibrary' => array(
+            'index' => 'glm-member-db',
+        ),
         'members' => array(
             'index'   => 'glm-member-db',            // member list
             'list'    => 'glm-member-db',
diff --git a/views/admin/fileLibrary/index.html b/views/admin/fileLibrary/index.html
new file mode 100644 (file)
index 0000000..acfaf3a
--- /dev/null
@@ -0,0 +1,149 @@
+<div class="wrap glm-associate-admin-wrap">
+
+    <h2>Files Library</h2>
+    <div id="glm-admin-content-container">
+    
+        <div class="glm-admin-table glm-admin-table-inner-wrapper">
+            <div class="glm-row glm-admin-table">
+                <div class="glm-admin-table-inner">
+                    <div class="glm-fileLibraryDropContainer" style="padding: 1rem;">
+                        <!-- All fields with class "glm-fileLibraryDrop" are automatically processed by imageUpload.js -->
+<!-- MAXIMUM FILE SIZE SETTING - See data-maxFileSizeKB below -->                        
+                        <div class="glm-fileLibraryDrop glm-fileLibraryItemHidden"
+                             data-refType=""
+                             data-recordID=""
+                             data-maxFileSizeKB="5000"
+                             data-allowedTypes="application/pdf,application/msword,image/jpeg,image/png,image/gif,image/x-ms-bmp"
+                            >
+                            <!-- The contents of this div are read by imageUpload.js to use for display of upload progress. -->
+                            <div class="glm-fileLibraryUploadStatusTemplate glm-fileLibraryItemHidden">
+    
+                                <!-- Start of upload status pop-up template - Parameters are of the form "[name]" -->
+                                <b><u>Uploading File { thisFile } of { numbFiles }</u></b>
+                                <table class="glm-statusTable">
+                                    <tr>
+                                        <th>File Name</th>
+                                        <th>File Type</th>
+                                        <th>File Size</th>
+                                        <th>&nbsp;</th>
+                                    </tr>
+                                    <tr>
+                                        <td>{ fileName }</td>
+                                        <td>{ fileType }</td>
+                                        <td>{ fileSize }</td>
+                                        <td>
+                                           <div id="fileLibraryUploadCancel" class="button button-primary glm-right">Cancel Upload</div>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Progress Bar</th>
+                                        <td colspan="3">
+                                            <div class="glm-statusValue glm-progressBarWrapper"><div class="glm-progressBarContainer"><div class="glm-progressBar"></div></div></div>
+                                        </td>
+                                    </tr>
+                                </table>
+                                <!-- End of template -->
+    
+                            </div>
+                            <!-- The contents of this div are read by imageUpload.js to use as a template for inserting a new file into the gallery area -->
+                            <table>
+                                <!-- Note that the template gets wrapped in a tbody and we copy it from there because the browser may create one after the table tag -->
+                                <tbody id="glm-fileLibraryDataTemplate" class="glm-fileLibraryItemHidden">
+                                <tr class="alternate">
+                                    <th class="glm-file-library-table-left">
+                                        <div class="glm-file-library-copy button button-secondary glm-button-small" style="margin: 0 .2em 0 .2em;" data-link="{ fileurl }">Copy Link URL</div>
+                                        { newfilename }
+                                    </th>
+                                    <td class="glm-file-library-table-left">
+                                        { filename }
+                                    </td>
+                                    <td class="glm-file-library-table-left">
+                                        &nbsp
+                                    </td>
+                                    <td class="glm-file-library-table-left">
+                                        &nbsp
+                                    </td>
+                                    <td class="glm-file-library-table-left">
+                                        <div class="button button-secondary glm-button-small glm-admin-edit-active-profile" style="margin: 0 .2em 0 .2em;">Edit</div>
+                                        <div class="button button-secondary glm-button-small glm-admin-edit-active-profile" style="margin: 0 .2em 0 .2em;">Delete</div>
+                                    </td>
+                                </tr>
+                                <!-- End of template -->
+                                </tbody>
+                            </table>
+                        </div> <!-- Overlay of parent for drag/drop detection -->
+                        <div class="glm-fileLibraryUploadStatus glm-fileLibraryItemHidden"></div> <!-- Overlay for Upload Status Bars -->
+                        <div class="glm-fileLibraryDropText glm-fileLibraryItemHidden">Drag and drop new files here</div>
+                        <div class="glm-noFileDropText glm-fileLibraryItemHidden">HTML5 file drag-and-drop not supported by your browser.<br>Use "Browse" button above to upload an file.</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    
+   <p>NOTE: The "Copy" button will copy the entire URL for the uploaded file to the user's "Clipboard".</p>
+   <div class="glm-admin-table">
+        <div class="glm-admin-table-inner">
+    {if $paging}
+        <input type="Submit" name="pageSelect" value="Previous {$limit}" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
+        <input type="Submit" name="pageSelect" value="Next {$limit}" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
+    {/if}
+        <table class="wp-list-table striped glm-admin-table-single">
+            <thead>
+                <tr>
+                    <th class="glm-file-library-table-left">File</th>
+                    <th class="glm-file-library-table-left">Original Name</th>
+                    <th class="glm-file-library-table-left">Title</th>
+                    <th class="glm-file-library-table-left">Last Access</th>
+                    <th>&nbsp;</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr class="glm-NewFileHidden glm-fileLibraryItemHidden" style="background-color: #fff;"><th colspan="4" style="color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;New Uploads</th></tr>
+            </tbody>
+            <tbody id="glm-newFileContainer">
+            </tbody>
+            <tbody>
+                <tr class="glm-NewFileHidden glm-fileLibraryItemHidden" style="background-color: #fff;"><td colspan="4">&nbsp;</td></tr>
+                <tr class="glm-NewFileHidden glm-fileLibraryItemHidden" style="background-color: #fff;"><th colspan="4" style="color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;Previous Uploads</th></tr>            
+    {if $haveFiles}
+        {assign var="i" value="0"}
+        {foreach $files as $f}
+            {if $i++ is odd by 1}
+                <tr>
+            {else}
+                <tr class="alternate">
+            {/if}
+                    <td class="glm-file-library-table-left">
+                        <div class="glm-file-library-copy button button-secondary glm-button-small" style="margin: 0 .2em 0 .2em;" data-link="{$f.link_url}">Copy Link URL</div>
+                        {$f.file_name}
+                    </td>
+                    <td class="glm-file-library-table-left">
+                        {$f.name}
+                    </td>
+                    <td class="glm-file-library-table-left">
+                        {$f.title}
+                    </td>
+                    <td class="glm-file-library-table-left">
+                        {$f.last_access_time.datetime}
+                    </td>
+                    <td class="glm-file-library-table-left">
+                        <div class="button button-secondary glm-button-small glm-admin-edit-active-profile" style="margin: 0 .2em 0 .2em;">Edit</div>
+                        <div class="button button-secondary glm-button-small glm-admin-edit-active-profile" style="margin: 0 .2em 0 .2em;">Delete</div>
+                    </td>
+                </tr>
+        {/foreach}
+    {else}
+                <tr class="alternate"><td colspan="4">(no files listed)</td></tr>
+    {/if}
+            </tbody>
+        </table>
+    {if $paging}
+        <input type="Submit" name="pageSelect" value="Previous {$limit}" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
+        <input type="Submit" name="pageSelect" value="Next {$limit}" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
+    {/if}
+   </div>
+   </div>
+   </div>
+
+            
+{include file='admin/footer.html'}
index dbe35f1..dd82dcd 100644 (file)
@@ -91,7 +91,7 @@
             {/foreach}
         </table>
 
-            <!-- Misc Settings -->
+            <!-- Member Related Settings -->
 
         <table id="glm-table-misc" class="glm-admin-table glm-settings-table">
             <tr><td colspan="2"><h2>Members Related Settings</h2></td></tr>
                 </td>
             </tr>
 
+            <!-- Misc. Settings -->
+            
             <tr><td colspan="2"><h2>Misc. Settings</h2></td></tr>
+            <tr>
+                <th>Enable File Library Menu:</th>
+                <td>
+                    <input type="checkbox" name="file_library"{if $genSettings.fieldData.file_library.value} checked="checked"{/if}>
+                </td>
+            </tr>
             <tr>
                 <th {if $genSettings.fieldRequired.google_maps_api_key}class="glm-required"{/if}>Google Maps API Key:</th>
                 <td {if $genSettings.fieldFail.google_maps_api_key}class="glm-form-bad-input glm-form-bad-input-misc"{/if}>