Restructure social database tables and move from settings to management.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 13 May 2016 18:20:43 +0000 (14:20 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 13 May 2016 18:20:43 +0000 (14:20 -0400)
17 files changed:
classes/data/dataSocialUrls.php [new file with mode: 0644]
classes/data/dataSocials.php
classes/data/dataUrls.php [deleted file]
index.php
models/admin/management/social.php [new file with mode: 0644]
models/admin/member/social.php
models/admin/settings/social.php [deleted file]
setup/adminTabs.php
setup/databaseScripts/create_database_V0.0.1.sql [deleted file]
setup/databaseScripts/create_database_V0.0.2.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/readme.txt
setup/databaseScripts/update_database_V0.0.2.sql [new file with mode: 0644]
setup/validActions.php
views/admin/management/social.html [new file with mode: 0644]
views/admin/member/social.html
views/admin/settings/social.html [deleted file]

diff --git a/classes/data/dataSocialUrls.php b/classes/data/dataSocialUrls.php
new file mode 100644 (file)
index 0000000..3ccafe0
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Social
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Gaslight Media <dev@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**********************************************************************
+ *  NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED
+ *
+ *  Please change all references to social, Social, or SOCIAL to a name
+ *  appropriate for your new Add-On.
+ *
+ *  Data fields in this file are social only.
+ *
+ *  Remove this message before using this file in production!
+ **********************************************************************/
+
+// Member Info Data required
+require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
+
+/**
+ * GlmDataUrls class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author   Gaslight Media <dev@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataSocialUrls extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Data Table Name
+     *
+     * @var $table
+     * @access public
+     */
+    public $table;
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = false;
+    /**
+     * MemberInfo DB object
+     *
+     * @var $MemberInfo
+     * @access public
+     */
+    public $MemberInfo;
+
+    /**
+     * Constructor
+     *
+     * @param object $d database connection
+     * @param array $config Configuration array
+     * @param bool $limitedEdit Flag to say indicate limited edit requested
+     *
+     * @return void
+     * @access public
+     */
+    public function __construct($wpdb, $config, $limitedEdit = false)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+        if (!$this->wpdb) {
+
+            // Save WordPress Database object
+            $this->wpdb = $wpdb;
+
+            // Save plugin configuration object
+            $this->config = $config;
+
+        }
+
+        /*
+         * Table Name
+         */
+        $this->table = GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'social_urls';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+            // The id of this url record
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+
+            // Reference Type - Insert new record
+            'ref_type_insert' => array (
+                'field' => 'ref_type',
+                'type' => 'integer',
+                'use' => 'i'
+            ),
+
+            // Reference Type - Output only
+            'ref_type' => array (
+                'field' => 'ref_type',
+                'type' => 'list',
+                    'list' => $this->config['ref_type'],
+                'use' => 'lged'
+            ),
+
+            // Ref_name (member name - need to update this to be Reference Type aware)
+            'ref_dest' => array (
+                'field' => 'ref_dest',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => true,
+                'use' => 'a'
+            ),
+
+            // Reference Target ID
+            'ref_dest_id' => array (
+                'field' => 'ref_dest',
+                'as' => 'ref_dest_id',
+                'type' => 'integer',
+                'use' => 'ilged'
+            ),
+
+
+            // The member's URL for a certain medium
+            'url' => array (
+                'field' => 'url',
+                'type' => 'text',
+                'default' => true,
+                'use' => 'a'
+            ),
+            // The social medium
+            'social' => array (
+                'field' => 'social',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socials',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => true,
+                'use' => 'a'
+            )
+        );
+    }
+
+    /*
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * In this case we're using it to append an array of category
+     * data to each member result and also sort by member name.
+     *
+     * @param array $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing($r, $a)
+    {
+        return $r;
+    }
+
+}
+
+?>
index 7dba8f1..dc6d5f0 100644 (file)
  * @release  SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
  */
 
-/**********************************************************************
- *  NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED
- *
- *  Please change all references to social, Social, or SOCIAL to a name
- *  appropriate for your new Add-On.
- *
- *  Data fields in this file are social only.
- *
- *  Remove this message before using this file in production!
- **********************************************************************/
-
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
 /**
  * GlmDataSocials class
  *
@@ -143,23 +129,15 @@ class GlmDataSocials extends GlmDataAbstract
                 'default' => true,
                 'use' => 'a'
             ),
-            
-            // X Position of icon in sprite
-            'xpos' => array (
+
+            // Base 64 Image Icon
+            'b64icon' => array (
                 'field' => 'xpos',
                 'type' => 'integer',
                 'view_only' => true,
                 'use' => 'a'
             ),
 
-            // Y Position of icon in sprite
-            'ypos' => array(
-                'field' => 'ypos',
-                'type' => 'integer',
-                'required' => true,
-                'use' => 'a'
-            ),
-
             // Base url of the social record
             'baseurl' => array(
                 'field' => 'baseurl',
@@ -176,6 +154,7 @@ class GlmDataSocials extends GlmDataAbstract
                 'use' => 'a'
             )
         );
+
     }
 
     /*
diff --git a/classes/data/dataUrls.php b/classes/data/dataUrls.php
deleted file mode 100644 (file)
index 2e3218e..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-<?php
-/**
- * GLM Member-DB WordPress Add-On Plugin
- * Data Class Social
- *
- * PHP version 5.3
- *
- * @category Data
- * @package  GLM Member-DB
- * @author   Gaslight Media <dev@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @release  SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
- */
-
-/**********************************************************************
- *  NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED
- *
- *  Please change all references to social, Social, or SOCIAL to a name
- *  appropriate for your new Add-On.
- *
- *  Data fields in this file are social only.
- *
- *  Remove this message before using this file in production!
- **********************************************************************/
-
-// Member Info Data required
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
-/**
- * GlmDataUrls class
- *
- * PHP version 5
- *
- * @category Data
- * @package GLM Member DB
- * @author   Gaslight Media <dev@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
- *          Exp $
- */
-class GlmDataUrls extends GlmDataAbstract
-{
-
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-    /**
-     * Plugin Configuration Data
-     *
-     * @var $config
-     * @access public
-     */
-    public $config;
-    /**
-     * Data Table Name
-     *
-     * @var $table
-     * @access public
-     */
-    public $table;
-    /**
-     * Field definitions
-     *
-     * 'type' is type of field as defined by the application
-     * text Regular text field
-     * pointer Pointer to an entry in another table
-     * 'filters' is the filter name for a particular filter ID in PHP filter
-     * functions
-     * See PHP filter_id()
-     *
-     * 'use' is when to use the field
-     * l = List
-     * g = Get
-     * n = New
-     * i = Insert
-     * e = Edit
-     * u = Update
-     * d = Delete
-     * a = All
-     *
-     * @var $ini
-     * @access public
-     */
-    public $fields = false;
-    /**
-     * MemberInfo DB object
-     *
-     * @var $MemberInfo
-     * @access public
-     */
-    public $MemberInfo;
-
-    /**
-     * Constructor
-     *
-     * @param object $d database connection
-     * @param array $config Configuration array
-     * @param bool $limitedEdit Flag to say indicate limited edit requested
-     *
-     * @return void
-     * @access public
-     */
-    public function __construct($wpdb, $config, $limitedEdit = false)
-    {
-
-        // If this class is not being extended along with existing $wpdb and $config
-        if (!$this->wpdb) {
-
-            // Save WordPress Database object
-            $this->wpdb = $wpdb;
-
-            // Save plugin configuration object
-            $this->config = $config;
-
-        }
-
-        /*
-         * Table Name
-         */
-        $this->table = GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'urls';
-
-        /*
-         * Table Data Fields
-         */
-
-        $this->fields = array (
-            // The id of this url record
-            'id' => array (
-                'field' => 'id',
-                'type' => 'integer',
-                'view_only' => true,
-                'use' => 'a'
-            ),
-
-            // The id of the associated member
-            'member_id' => array (
-                'field' => 'member_id',
-                'type' => 'integer',
-                'default' => true,
-                'use' => 'a'
-            ),
-            // The member's URL for a certain medium
-            'url' => array (
-                'field' => 'url',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            // The social medium
-            'medium' => array (
-                'field' => 'medium',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            )
-        );
-    }
-
-    /*
-     * Entry Post Processing Call-Back Method
-     *
-     * Perform post-processing for all result entries.
-     *
-     * In this case we're using it to append an array of category
-     * data to each member result and also sort by member name.
-     *
-     * @param array $r Array of field result data for a single entry
-     * @param string $a Action being performed (l, i, g, ...)
-     *
-     * @return object Class object
-     *
-     */
-    public function entryPostProcessing($r, $a)
-    {
-        return $r;
-    }
-
-}
-
-?>
index d003341..ad639d8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -54,7 +54,7 @@
  *  version from this plugin.
  */
 define('GLM_MEMBERS_SOCIAL_PLUGIN_VERSION', '0.0.6');
-define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.1');
+define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.2');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_SOCIAL_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.57');
@@ -91,8 +91,6 @@ if (!defined('ABSPATH')) {
 * Some initial setup and tests
 */
 
-$startupNotices = '';
-
 // Get standard defined parameters
 require_once('defines.php');
 
@@ -117,13 +115,13 @@ function glmMembersSocialPluginRequired() {
  * Check installation, activation, and version of main Member DB plugin
  */
 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
-$plugin_name = 'glm-member-db/glm-member-db.php';
+$plugin_name = 'glm-member-db/index.php';
 $is_active = is_plugin_active($plugin_name);
 
 // If it's not active, then warn user and deactivate this add-on plugin
 if ($is_active != '1') {
     add_action( 'admin_notices', 'glmMembersSocialPluginRequired' );
-    deactivate_plugins('/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'.php');
+    deactivate_plugins('/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'/index.php');
 }
 
 // Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on
diff --git a/models/admin/management/social.php b/models/admin/management/social.php
new file mode 100644 (file)
index 0000000..1c6b07f
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Member User Profile
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Gaslight Media <dev@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/
+ */
+
+// Load Management Social data abstract
+require_once GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php';
+
+/**
+ * GlmMembersAdmin_management_socials
+ *
+ * PHP version 5
+ *
+ * @category Model
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmMembersAdmin_management_social extends GlmDataSocials
+{
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Member ID
+     *
+     * @var $memberID
+     * @access public
+     */
+    public $memberID = false;
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 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 social data class
+        parent::__construct(false, false);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+
+        $success = true;
+        $socialUpdated = false;
+        $socialError = false;
+        $statusMessage = 'Social Updated';
+        $option = false;
+        $debug = true;
+
+        $socialList = $this->getList();
+
+        if (isset($_REQUEST['option'])) {
+            $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING));
+        } else {
+            $option = "default";
+        }
+
+        switch ($option) {
+            case "submit":
+                $Socials->updateEntry();
+                break;
+            case "social";
+            default:
+
+                break;
+        }
+
+        // If we had a fatal error, redirect to the error page
+        if ($socialError) {
+            return array(
+                'status' => $success,
+                'option' => $option,
+                'menuItemRedirect' => 'error',
+                'modelRedirect' => 'index',
+                'view' => 'admin/error/index.html',
+                'data' => false
+            );
+        }
+
+//        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+//            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data');
+//        }
+        // Refresh the URL list before sending it to the front
+
+        // Compile template data
+        $templateData = array(
+            'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL,
+            'socialUpdated' => $socialUpdated,
+            'socialError' => $socialError,
+            'option' => $option,
+            'socials' => $socialList,
+            'statusMessage' => $statusMessage
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status' => true,
+            'modelRedirect' => false,
+            'view' => 'admin/management/social.html',
+            'data' => $templateData
+        );
+    }
+}
index 71d0475..6cf0131 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-class GlmMembersAdmin_member_social //extends GlmDataUrls
+
+// Load Management Social data abstract
+require_once GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocialUrls.php';
+
+/**
+ * GlmMembersAdmin_member_social
+ *
+ * PHP version 5
+ *
+ * @category Model
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmMembersAdmin_member_social extends GlmDataSocialUrls
 {
     /**
      * WordPress Database Object
@@ -53,6 +69,10 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
 
         // Save plugin configuration object
         $this->config = $config;
+
+        // Run constructor for social data class
+        parent::__construct(false, false);
+
     }
 
     public function modelAction($actionData = false)
@@ -72,7 +92,6 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
                 'data'             => false
             );
         }
-        $displayData   = 'Hello, World! This is the Social Add-On "social" model talking to you from inside WordPress.';
         $success       = true;
         $urlUpdated    = false;
         $haveMember    = true;
@@ -80,7 +99,7 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
         $option        = false;
         $debug         = false;
         $statusMessage = "Update complete";
-        
+
         require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataUrls.php');
         $Urls     = new GlmDataUrls($this->wpdb, $this->config);
         $urlStats = $Urls->getStats();
@@ -90,18 +109,18 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
         }
         $urlList = $Urls->getList("member_id = " . $memberID);
         //$urlList = $Urls->getList();
-        
+
         require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php');
         $Socials    = new GlmDataSocials($this->wpdb, $this->config);
         $socialList = $Socials->getList();
-        
+
         // Get the option or set to default
         if (isset($_REQUEST['option'])) {
             $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING));
         } else {
             $option = "default";
         }
-        
+
 
         switch ($option) {
             case "submit":
@@ -167,11 +186,11 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
                 $statusMessage = "Social Media URLs Updated";
                 $urlList       = $Urls->getList("member_id    = " . $memberID);
                 break;
-            case "social";    
+            case "social";
             default:
                 break;
         }
-        
+
         // If we had a fatal error, redirect to the error page
         if ($socialError) {
             return array(
@@ -202,11 +221,10 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls
             echo "<pre>".print_r($urlList[$memberID], true)."</pre>";
             echo "<hr />sociallist:<table>";
             echo "<pre>".print_r($socialList, true)."</pre>";
-            echo "</table>";            
+            echo "</table>";
         }
-        
+
         $templateData = array(
-            'displayData'   => $displayData,
             'socials'       => $socialList,
             'urlList'       => $memberUrlList,
             'assetsUrl'     => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL,
diff --git a/models/admin/settings/social.php b/models/admin/settings/social.php
deleted file mode 100644 (file)
index e4a2722..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
- * Gaslight Media Members Database
- * Admin Member User Profile
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Gaslight Media <dev@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/
- */
-
-class GlmMembersAdmin_settings_social // extends GlmDataContacts
-{
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-    /**
-     * Plugin Configuration Data
-     *
-     * @var $config
-     * @access public
-     */
-    public $config;
-    /**
-     * Member ID
-     *
-     * @var $memberID
-     * @access public
-     */
-    public $memberID = false;
-    /*
-     * Constructor
-     *
-     * This contructor performs the work for this model. This model returns
-     * an array containing the following.
-     *
-     * 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;
-
-    }
-
-    public function modelAction($actionData = false)
-    {
-        $displayData = 'Hello, World! This is the Social Add-On "settings" model talking to you from inside WordPress.';
-        $success = true;
-        $socialUpdated = false;
-        $socialError = false;
-        $statusMessage = 'Social Updated';
-        $option = false;
-        $debug = true;
-
-        require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php');
-        $Socials = new GlmDataSocials($this->wpdb, $this->config);
-        $socialList = $Socials->getList();
-        
-        if (isset($_REQUEST['option'])) {
-            $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING));
-        } else {
-            $option = "default";
-        }
-
-        echo "<hr />Request:<table>";
-        if ($debug) {
-            echo "<hr />Request:<table>";
-            foreach($_REQUEST as $key=>$value) {
-                echo("<tr><td>$key</td><td>$value</td></tr>");
-            }
-            echo "</table>";
-//            echo "<hr />UrlList:<table>";
-//            echo "<pre>".print_r($urlList[$memberID], true)."</pre>";
-//            echo "<hr />Recordlist:<table>";
-            echo "<pre>".print_r($socialList, true)."</pre>";
-//            echo "</table>";            
-        }
-        
-        switch ($option) {
-            case "submit":
-                $Socials->updateEntry();
-                break;
-            case "social";
-            default:
-
-                break;
-        }
-        
-        // If we had a fatal error, redirect to the error page
-        if ($socialError) {
-            return array(
-                'status' => $success,
-                'option' => $option,
-                'menuItemRedirect' => 'error',
-                'modelRedirect' => 'index',
-                'view' => 'admin/error/index.html',
-                'data' => false
-            );
-        }
-
-//        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
-//            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data');
-//        }
-        // Refresh the URL list before sending it to the front
-
-        // Compile template data
-        $templateData = array(
-            'displayData' => $displayData,
-            'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL,
-            'socialUpdated' => $socialUpdated,
-            'socialError' => $socialError,
-            'option' => $option,
-            'socials' => $socialList,
-            'statusMessage' => $statusMessage
-        );
-
-        // Return status, any suggested view, and any data to controller
-        return array(
-            'status' => true,
-            'modelRedirect' => false,
-            'view' => 'admin/settings/social.html',
-            'data' => $templateData
-        );
-    }
-}
index 60e25a6..087500c 100644 (file)
@@ -59,7 +59,7 @@ add_filter('glm-member-db-add-tab-for-member',
         return $addOnTabs;
     }
 );
-add_filter('glm-member-db-add-tab-for-settings',
+add_filter('glm-member-db-add-tab-for-management',
     function($addOnTabs) {
         $newTabs = array(
             array(
diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql
deleted file mode 100644 (file)
index 422e44c..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
--- Gaslight Media Members Database - Social 
--- File Created: 12/02/15 15:27:15
--- Database Version: 0.0.1
--- Database Creation Script
--- 
--- This file is called to create a new set of tables for this
--- add-on for the most recent database version for this add-on.
--- 
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
-CREATE TABLE {prefix}urls (
-    id INT NOT NULL AUTO_INCREMENT,
-    member_id INT NULL,
-    url TINYTEXT NULL,
-    medium TINYTEXT NULL,
-    PRIMARY KEY (id),
-    INDEX(id)
-);
-
-----
-
-CREATE TABLE {prefix}socials (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,
-  xpos int NULL,
-  ypos int NULL,
-  baseurl TINYTEXT NULL,
-  active BOOLEAN NOT NULL DEFAULT '1',
-  PRIMARY KEY (id),
-  INDEX(id)
-);
-
-----
-
-INSERT INTO {prefix}socials
-  (name, xpos, ypos, baseurl, active)
-  VALUES ('Facebook',-5,-5,'www.facebook.com',true),
-         ('Twitter',-44,-5,'www.twitter.com',true),
-         ('Pinterest',-84,-5,'www.pinterest.com',true),
-         ('GooglePlus',-124,-5,'www.google.com',true),
-         ('Digg',-163,-5,'www.digg.com',true),
-         ('LinkedIn',-203,-5,'www.linkedin.com',true),
-         ('Instagram',-242,-5,'www.instagram.com',true),
-         ('YouTube',-322,-5,'www.youtube.com',true),
-         ('Flickr',-44,-44,'www.flickr.com',true),
-         ('blog',-124,-45, '#',true),
-         ('Photobucket',-282,-45,'www.photobucket.com',true),
-         ('RSS',-282,-5,'#',false)
-;
-
-----
-
-INSERT INTO {prefix}urls
-  (member_id, url, medium)
-  VALUES (1,'facebook.com/1','Facebook'),
-         (1,'pinterest.com/1','Pinterest'),
-         (1,'Twitter.com/1','Twitter'),
-         (2,'pinterest.com/2','Pinterest'),
-         (2,'facebook.com/2','Facebook'),
-         (2,'Twitter.com/2','Twitter'),
-         (2,'instagram.com/2','Instagram'),
-         (2,'youtube.com/2','YouTube'),
-         (2,'flickr.com/2','Flickr'),
-         (1,'flickr.com/1','Flickr')
-;
\ No newline at end of file
diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql
new file mode 100644 (file)
index 0000000..30a1bd9
--- /dev/null
@@ -0,0 +1,53 @@
+-- Gaslight Media Members Database - Social 
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.1
+-- Database Creation Script
+-- 
+-- This file is called to create a new set of tables for this
+-- add-on for the most recent database version for this add-on.
+-- 
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+CREATE TABLE {prefix}socials (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NULL,
+    b64icon TEXT NULL,
+    baseurl TINYTEXT NULL,
+    active BOOLEAN NOT NULL DEFAULT '1',
+    PRIMARY KEY (id),
+    INDEX(id)
+);
+
+----
+
+CREATE TABLE {prefix}social_urls (
+    id INT NOT NULL AUTO_INCREMENT,
+    ref_type TINYINT NULL,
+    ref_dest INT NULL,
+    url TINYTEXT NULL,
+    social TINYINT NULL,
+    PRIMARY KEY (id),
+    INDEX(id)
+);
+
+----
+
+-- Add default social media types and icons (base64encoded icons)
+INSERT INTO {prefix}socials
+    (name, b64icon, baseurl, active)
+    VALUES ('Facebook','','www.facebook.com',true),
+        ('Twitter','','www.twitter.com',true),
+        ('Pinterest','','www.pinterest.com',true),
+        ('GooglePlus','','www.google.com',true),
+        ('Digg','','www.digg.com',true),
+        ('LinkedIn','','www.linkedin.com',true),
+        ('Instagram','','www.instagram.com',true),
+        ('YouTube','','www.youtube.com',true),
+        ('Flickr','','www.flickr.com',true),
+        ('blog','', '#',true),
+        ('Photobucket','','www.photobucket.com',true),
+        ('RSS','','#',false)
+;
index a721537..f7ffd3f 100644 (file)
@@ -34,5 +34,6 @@
 
 
 $glmMembersSocialDbVersions = array(
-            '0.0.1' => array('version' => '0.0.1', 'tables' => 2)
+    '0.0.1' => array('version' => '0.0.1', 'tables' => 2),
+    '0.0.2' => array('version' => '0.0.2', 'tables' => 2, 'date' => '5/12/2016')
 );
index ff3b4e7..141d8b5 100644 (file)
@@ -1,4 +1,41 @@
 This directory contains database creation and update scripts for this add-on.
 
-This directly is optional. If there are no data tables added by this add-on,
-this directory should be omitted.
+The files in this directory are checked by the checkDatabase() function in the
+main plugin classes/glmPluginSupport.php file.
+
+This directory is optional. If there are no data tables that need to be created
+for this add-on, there should be no files in this directory. The directory may
+also be deleted. 
+
+See the "examples" directory for a sample of what can go in this directory.
+Procedure to update database
+-----------------------------
+
+0) Make a backup copy of the site's database.
+
+1) Rename "create_database_Vx.x.x.sql" to new version number.
+    example: create_database_V0.0.9.sql -> create_database_V0.0.10.sql
+
+2) Edit renamed create database file and make desired changes
+
+3) Add a new "update_database_Vx.x.x.sql" named with the correct version #.
+
+4) Edit new update database files with SQL script to make the necessary changes
+   from the previous version to the new version. (i.e. to add new fields,
+   rename fields, insert records, ...)
+
+5) Optionally add an "update_database_Vx.x.x.php" file if PHP scripting is
+   needed to update database content. (i.e. to make changes to database content)
+
+6) Edit the "dbVersions.php" file and add a new line for the new version.
+   *** Now please be sure to add a date for each entry ***
+   i.e. '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16')
+
+7) When this is all done, edit the index.php file for the plugin/add-on and 
+   change "GLM_MEMBERS_{addon}_PLUGIN_DB_VERSION" defined parameter where
+   {addon} is the add-on name.
+
+8) Go to an admin menu item for the main member db plugin or any add-on. If all
+   goes well, the main plugin should have detected the change and updated the
+   database. If not, restore the database and try again.
+9) Check the database to make sure the changes to fields and data are correct.
diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql
new file mode 100644 (file)
index 0000000..6a00440
--- /dev/null
@@ -0,0 +1,65 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.9
+-- Database Update From Previous Version Script
+-- 
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+
+
+-- Drop existing socials table
+DROP TABLE {prefix}socials;
+
+----
+
+-- Create new socials table
+CREATE TABLE {prefix}socials (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NULL,
+    b64icon TEXT NULL,
+    baseurl TINYTEXT NULL,
+    active BOOLEAN NOT NULL DEFAULT '1',
+    PRIMARY KEY (id),
+    INDEX(id)
+);
+
+----
+
+-- Add default social media types and icons (base64encoded icons)
+-- NEED TO ADD DEFAULT ICON DATA HERE
+INSERT INTO {prefix}socials
+    (name, b64icon, baseurl, active)
+    VALUES ('Facebook','','www.facebook.com',true),
+        ('Twitter','','www.twitter.com',true),
+        ('Pinterest','','www.pinterest.com',true),
+        ('GooglePlus','','www.google.com',true),
+        ('Digg','','www.digg.com',true),
+        ('LinkedIn','','www.linkedin.com',true),
+        ('Instagram','','www.instagram.com',true),
+        ('YouTube','','www.youtube.com',true),
+        ('Flickr','','www.flickr.com',true),
+        ('blog','', '#',true),
+        ('Photobucket','','www.photobucket.com',true),
+        ('RSS','','#',false)
+;
+
+----
+
+-- Drop existing urls table
+DROP TABLE {prefix}urls;
+
+----
+
+-- Create new social_urls table (replaces urls)
+CREATE TABLE {prefix}social_urls (
+    id INT NOT NULL AUTO_INCREMENT,
+    ref_type TINYINT NULL,
+    ref_dest INT NULL,
+    url TINYTEXT NULL,
+    social TINYINT NULL,
+    PRIMARY KEY (id),
+    INDEX(id)
+);
+
+
index 4d54cde..62f1bd9 100644 (file)
@@ -49,7 +49,7 @@ $glmMembersSocialAddOnValidActions = array(
         'member' => array(
             'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG,
         ),
-        'settings' => array(
+        'management' => array(
             'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG
         )
     ),
diff --git a/views/admin/management/social.html b/views/admin/management/social.html
new file mode 100644 (file)
index 0000000..5b5baa7
--- /dev/null
@@ -0,0 +1,55 @@
+{include file='admin/management/header.html'}
+
+    <h2>{if $socialUpdated}<span class="glm-notice glm-flash-updated glm-right">{$statusMessage}</span>{/if}</h2>
+
+    <h3>Social Media Types</h3>
+    
+    <div id="glm-admin-content-container">
+
+            <table class="glm-admin-table">
+                <tr><th>Active</th><th>Name</th><th>Image</th></tr>
+        {foreach $socials as $s}
+                <tr>
+                    <td class="glm-member-db-social-management-checkbox">
+                        {$s.active.name}
+                    </td>
+                    <td>
+                        <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
+                        </div>
+                    </td>
+                    <td class="glm-member-db-social-management-name">
+                        {$socialItem.name}
+                    </td>
+                    <td>
+                        <div class="glm-galleryImage" data-id="logo">
+                            <img src="{$glmPluginMediaUrl}/images/small/{$member.fieldData.logo}">
+                        </div>
+                        <div id="glm-galleryImageLarger_logo" class="glm-imageDialog">
+                            <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
+                            </div>  
+                        </div>
+                    </td>
+
+                    <td class="glm-admin-image-edit-table">
+                        <div class="glm-galleryImage" data-id="logo">
+                            <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
+                            </div> 
+                        </div>
+                    </td>
+                    <td colspan="2"><b>New image:</b> <input type="file" name="logo_new"></td>
+                    <td><div id="glm-galleryImageLarger_logo" class="glm-imageDialog"></div></td>
+                </tr>
+        {/foreach}
+            </table>
+            <input type="submit" class="button glm-button submit" value="submit" name='submit'>
+        </form>
+    </div>
+    
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+            // Flash certain elements for a short time after display      
+            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+        });
+</script>
+{include file='admin/footer.html'}
index 5993e67..c4ac193 100644 (file)
@@ -1,4 +1,4 @@
-{include file='admin/members/header.html'}
+{include file='admin/member/header.html'}
 <h2>{if $urlUpdated}<span class="glm-notice glm-flash-updated glm-right">{$statusMessage}</span>{/if}</h2>
     <h3>Member Social Tab</h3>
     
 
 <script type="text/javascript">
     jQuery(document).ready(function($) {
+        
         // Flash certain elements for a short time after display      
         $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+        
+        // Image pop-up dialog box
         $("#editMemberTypeDialog").dialog({
             autoOpen: false,
             minWidth: 400,
@@ -77,6 +80,8 @@
         $('.editMemberType').click( function() {
         var typeID = $(this).attr('data-memberTypeID');
         var typeName = $(this).text();
+        
+        
 //        var typeDescr = $('#editMemberTypeDescr_' + typeID).html();
         $('#glmSocName').text(typeName);
         $('#editMemberTypeName').val(typeName.trim());
diff --git a/views/admin/settings/social.html b/views/admin/settings/social.html
deleted file mode 100644 (file)
index ae0c44d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-{include file='admin/members/header.html'}
-<h2>{if $socialUpdated}<span class="glm-notice glm-flash-updated glm-right">{$statusMessage}</span>{/if}</h2>
-    <h3>Member Social Tab</h3>
-    <p>{$displayData}</p>
-    <div id="glm-admin-content-container">
-        <form id="glm-member-db-social-management" action="{$thisUrl}?page={$thisPage}&glm_action=social" method="post" enctype="multipart/form-data">
-            <input type="submit" class="button glm-button submit" value="submit" name='submit'>
-            <input type="hidden" name="option" value="submit">
-            <div class="button glm-button right">Update</div>
-            <table class="glm-admin-table">
-                aaaa
-            {foreach from=$socials key=k item=socialItem}
-                {$socialField = $socialItem.name|lower}
-                <tr>
-                    <th class="glm-member-db-social-management-checkbox">
-                        <input type="checkbox" id="{$socialItem.name|lower}" name="{$socialItem.name|lower}" class="glm-form-text-input" value="{$socialField}" {if $socialItem.active.value == 1}checked{/if}>
-                    </th>
-                    <td class="glm-member-db-social-management-icon">
-                        <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
-                        </div>
-                    </td>
-                    <td class="glm-member-db-social-management-name">
-                        {$socialItem.name}
-                    </td>
--                    <td>
-                        <input type="button" class="button glm-button submit" value="Change Icon" name="newSocialIcon">
-                    </td>
-                    <td>
-                        <div class="glm-galleryImage" data-id="logo">
-                            <img src="{$glmPluginMediaUrl}/images/small/{$member.fieldData.logo}">
-                        </div>
-                        <div id="glm-galleryImageLarger_logo" class="glm-imageDialog">
-                            <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
-                            </div>  
-                        </div>
-                    </td>
-
-                    <td class="glm-admin-image-edit-table">
-                        <div class="glm-galleryImage" data-id="logo">
-                            <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
-                            </div> 
-                        </div>
-                    </td>
-                    <td colspan="2"><b>New image:</b> <input type="file" name="logo_new"></td>
-                    <td><div id="glm-galleryImageLarger_logo" class="glm-imageDialog"></div></td>
-                </tr>
-            {/foreach}
-            </table>
-            <input type="submit" class="button glm-button submit" value="submit" name='submit'>
-        </form>
-    </div>
-    
-
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
-            // Flash certain elements for a short time after display      
-            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
-        });
-</script>
-{include file='admin/footer.html'}